]> git.ipfire.org Git - thirdparty/grsecurity-scrape.git/blob - test/grsecurity-3.0-3.12.4-201312081754.patch
Auto commit, 1 new patch{es}.
[thirdparty/grsecurity-scrape.git] / test / grsecurity-3.0-3.12.4-201312081754.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 3b7165e..9112a63 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 be956db..c8f25e2 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 94f6b05..efd7312 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 @@ -422,12 +423,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 @@ -443,7 +438,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 @@ -469,41 +464,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 8fcda14..4512b9d 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 @@ -628,7 +633,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 @@ -885,7 +892,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 3d5db8c..ddfa144 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 0c63562..7128a90 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 5dfd248..64914ac 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 @@ -61,10 +64,11 @@ static int get_offset(struct address_space *mapping)
7270 return (unsigned long) mapping >> 8;
7271 }
7272
7273 -static unsigned long get_shared_area(struct address_space *mapping,
7274 - unsigned long addr, unsigned long len, unsigned long pgoff)
7275 +static unsigned long get_shared_area(struct file *filp, struct address_space *mapping,
7276 + unsigned long addr, unsigned long len, unsigned long pgoff, unsigned long flags)
7277 {
7278 struct vm_unmapped_area_info info;
7279 + unsigned long offset = gr_rand_threadstack_offset(current->mm, filp, flags);
7280
7281 info.flags = 0;
7282 info.length = len;
7283 @@ -72,6 +76,7 @@ static unsigned long get_shared_area(struct address_space *mapping,
7284 info.high_limit = TASK_SIZE;
7285 info.align_mask = PAGE_MASK & (SHMLBA - 1);
7286 info.align_offset = (get_offset(mapping) + pgoff) << PAGE_SHIFT;
7287 + info.threadstack_offset = offset;
7288 return vm_unmapped_area(&info);
7289 }
7290
7291 @@ -86,15 +91,22 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr,
7292 return -EINVAL;
7293 return addr;
7294 }
7295 - if (!addr)
7296 + if (!addr) {
7297 addr = TASK_UNMAPPED_BASE;
7298
7299 +#ifdef CONFIG_PAX_RANDMMAP
7300 + if (current->mm->pax_flags & MF_PAX_RANDMMAP)
7301 + addr += current->mm->delta_mmap;
7302 +#endif
7303 +
7304 + }
7305 +
7306 if (filp) {
7307 - addr = get_shared_area(filp->f_mapping, addr, len, pgoff);
7308 + addr = get_shared_area(filp, filp->f_mapping, addr, len, pgoff, flags);
7309 } else if(flags & MAP_SHARED) {
7310 - addr = get_shared_area(NULL, addr, len, pgoff);
7311 + addr = get_shared_area(filp, NULL, addr, len, pgoff, flags);
7312 } else {
7313 - addr = get_unshared_area(addr, len);
7314 + addr = get_unshared_area(filp, addr, len, flags);
7315 }
7316 return addr;
7317 }
7318 diff --git a/arch/parisc/kernel/traps.c b/arch/parisc/kernel/traps.c
7319 index 1cd1d0c..44ec918 100644
7320 --- a/arch/parisc/kernel/traps.c
7321 +++ b/arch/parisc/kernel/traps.c
7322 @@ -722,9 +722,7 @@ void notrace handle_interruption(int code, struct pt_regs *regs)
7323
7324 down_read(&current->mm->mmap_sem);
7325 vma = find_vma(current->mm,regs->iaoq[0]);
7326 - if (vma && (regs->iaoq[0] >= vma->vm_start)
7327 - && (vma->vm_flags & VM_EXEC)) {
7328 -
7329 + if (vma && (regs->iaoq[0] >= vma->vm_start)) {
7330 fault_address = regs->iaoq[0];
7331 fault_space = regs->iasq[0];
7332
7333 diff --git a/arch/parisc/mm/fault.c b/arch/parisc/mm/fault.c
7334 index 0293588..3b229aa 100644
7335 --- a/arch/parisc/mm/fault.c
7336 +++ b/arch/parisc/mm/fault.c
7337 @@ -15,6 +15,7 @@
7338 #include <linux/sched.h>
7339 #include <linux/interrupt.h>
7340 #include <linux/module.h>
7341 +#include <linux/unistd.h>
7342
7343 #include <asm/uaccess.h>
7344 #include <asm/traps.h>
7345 @@ -52,7 +53,7 @@ DEFINE_PER_CPU(struct exception_data, exception_data);
7346 static unsigned long
7347 parisc_acctyp(unsigned long code, unsigned int inst)
7348 {
7349 - if (code == 6 || code == 16)
7350 + if (code == 6 || code == 7 || code == 16)
7351 return VM_EXEC;
7352
7353 switch (inst & 0xf0000000) {
7354 @@ -138,6 +139,116 @@ parisc_acctyp(unsigned long code, unsigned int inst)
7355 }
7356 #endif
7357
7358 +#ifdef CONFIG_PAX_PAGEEXEC
7359 +/*
7360 + * PaX: decide what to do with offenders (instruction_pointer(regs) = fault address)
7361 + *
7362 + * returns 1 when task should be killed
7363 + * 2 when rt_sigreturn trampoline was detected
7364 + * 3 when unpatched PLT trampoline was detected
7365 + */
7366 +static int pax_handle_fetch_fault(struct pt_regs *regs)
7367 +{
7368 +
7369 +#ifdef CONFIG_PAX_EMUPLT
7370 + int err;
7371 +
7372 + do { /* PaX: unpatched PLT emulation */
7373 + unsigned int bl, depwi;
7374 +
7375 + err = get_user(bl, (unsigned int *)instruction_pointer(regs));
7376 + err |= get_user(depwi, (unsigned int *)(instruction_pointer(regs)+4));
7377 +
7378 + if (err)
7379 + break;
7380 +
7381 + if (bl == 0xEA9F1FDDU && depwi == 0xD6801C1EU) {
7382 + unsigned int ldw, bv, ldw2, addr = instruction_pointer(regs)-12;
7383 +
7384 + err = get_user(ldw, (unsigned int *)addr);
7385 + err |= get_user(bv, (unsigned int *)(addr+4));
7386 + err |= get_user(ldw2, (unsigned int *)(addr+8));
7387 +
7388 + if (err)
7389 + break;
7390 +
7391 + if (ldw == 0x0E801096U &&
7392 + bv == 0xEAC0C000U &&
7393 + ldw2 == 0x0E881095U)
7394 + {
7395 + unsigned int resolver, map;
7396 +
7397 + err = get_user(resolver, (unsigned int *)(instruction_pointer(regs)+8));
7398 + err |= get_user(map, (unsigned int *)(instruction_pointer(regs)+12));
7399 + if (err)
7400 + break;
7401 +
7402 + regs->gr[20] = instruction_pointer(regs)+8;
7403 + regs->gr[21] = map;
7404 + regs->gr[22] = resolver;
7405 + regs->iaoq[0] = resolver | 3UL;
7406 + regs->iaoq[1] = regs->iaoq[0] + 4;
7407 + return 3;
7408 + }
7409 + }
7410 + } while (0);
7411 +#endif
7412 +
7413 +#ifdef CONFIG_PAX_EMUTRAMP
7414 +
7415 +#ifndef CONFIG_PAX_EMUSIGRT
7416 + if (!(current->mm->pax_flags & MF_PAX_EMUTRAMP))
7417 + return 1;
7418 +#endif
7419 +
7420 + do { /* PaX: rt_sigreturn emulation */
7421 + unsigned int ldi1, ldi2, bel, nop;
7422 +
7423 + err = get_user(ldi1, (unsigned int *)instruction_pointer(regs));
7424 + err |= get_user(ldi2, (unsigned int *)(instruction_pointer(regs)+4));
7425 + err |= get_user(bel, (unsigned int *)(instruction_pointer(regs)+8));
7426 + err |= get_user(nop, (unsigned int *)(instruction_pointer(regs)+12));
7427 +
7428 + if (err)
7429 + break;
7430 +
7431 + if ((ldi1 == 0x34190000U || ldi1 == 0x34190002U) &&
7432 + ldi2 == 0x3414015AU &&
7433 + bel == 0xE4008200U &&
7434 + nop == 0x08000240U)
7435 + {
7436 + regs->gr[25] = (ldi1 & 2) >> 1;
7437 + regs->gr[20] = __NR_rt_sigreturn;
7438 + regs->gr[31] = regs->iaoq[1] + 16;
7439 + regs->sr[0] = regs->iasq[1];
7440 + regs->iaoq[0] = 0x100UL;
7441 + regs->iaoq[1] = regs->iaoq[0] + 4;
7442 + regs->iasq[0] = regs->sr[2];
7443 + regs->iasq[1] = regs->sr[2];
7444 + return 2;
7445 + }
7446 + } while (0);
7447 +#endif
7448 +
7449 + return 1;
7450 +}
7451 +
7452 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
7453 +{
7454 + unsigned long i;
7455 +
7456 + printk(KERN_ERR "PAX: bytes at PC: ");
7457 + for (i = 0; i < 5; i++) {
7458 + unsigned int c;
7459 + if (get_user(c, (unsigned int *)pc+i))
7460 + printk(KERN_CONT "???????? ");
7461 + else
7462 + printk(KERN_CONT "%08x ", c);
7463 + }
7464 + printk("\n");
7465 +}
7466 +#endif
7467 +
7468 int fixup_exception(struct pt_regs *regs)
7469 {
7470 const struct exception_table_entry *fix;
7471 @@ -204,8 +315,33 @@ retry:
7472
7473 good_area:
7474
7475 - if ((vma->vm_flags & acc_type) != acc_type)
7476 + if ((vma->vm_flags & acc_type) != acc_type) {
7477 +
7478 +#ifdef CONFIG_PAX_PAGEEXEC
7479 + if ((mm->pax_flags & MF_PAX_PAGEEXEC) && (acc_type & VM_EXEC) &&
7480 + (address & ~3UL) == instruction_pointer(regs))
7481 + {
7482 + up_read(&mm->mmap_sem);
7483 + switch (pax_handle_fetch_fault(regs)) {
7484 +
7485 +#ifdef CONFIG_PAX_EMUPLT
7486 + case 3:
7487 + return;
7488 +#endif
7489 +
7490 +#ifdef CONFIG_PAX_EMUTRAMP
7491 + case 2:
7492 + return;
7493 +#endif
7494 +
7495 + }
7496 + pax_report_fault(regs, (void *)instruction_pointer(regs), (void *)regs->gr[30]);
7497 + do_group_exit(SIGKILL);
7498 + }
7499 +#endif
7500 +
7501 goto bad_area;
7502 + }
7503
7504 /*
7505 * If for any reason at all we couldn't handle the fault, make
7506 diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
7507 index 38f3b7e..7e485c0 100644
7508 --- a/arch/powerpc/Kconfig
7509 +++ b/arch/powerpc/Kconfig
7510 @@ -378,6 +378,7 @@ config ARCH_ENABLE_MEMORY_HOTREMOVE
7511 config KEXEC
7512 bool "kexec system call"
7513 depends on (PPC_BOOK3S || FSL_BOOKE || (44x && !SMP))
7514 + depends on !GRKERNSEC_KMEM
7515 help
7516 kexec is a system call that implements the ability to shutdown your
7517 current kernel, and to start another kernel. It is like a reboot
7518 diff --git a/arch/powerpc/include/asm/atomic.h b/arch/powerpc/include/asm/atomic.h
7519 index e3b1d41..8e81edf 100644
7520 --- a/arch/powerpc/include/asm/atomic.h
7521 +++ b/arch/powerpc/include/asm/atomic.h
7522 @@ -523,6 +523,16 @@ static __inline__ long atomic64_inc_not_zero(atomic64_t *v)
7523 return t1;
7524 }
7525
7526 +#define atomic64_read_unchecked(v) atomic64_read(v)
7527 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
7528 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
7529 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
7530 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
7531 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
7532 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
7533 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
7534 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
7535 +
7536 #endif /* __powerpc64__ */
7537
7538 #endif /* __KERNEL__ */
7539 diff --git a/arch/powerpc/include/asm/cache.h b/arch/powerpc/include/asm/cache.h
7540 index 9e495c9..b6878e5 100644
7541 --- a/arch/powerpc/include/asm/cache.h
7542 +++ b/arch/powerpc/include/asm/cache.h
7543 @@ -3,6 +3,7 @@
7544
7545 #ifdef __KERNEL__
7546
7547 +#include <linux/const.h>
7548
7549 /* bytes per L1 cache line */
7550 #if defined(CONFIG_8xx) || defined(CONFIG_403GCX)
7551 @@ -22,7 +23,7 @@
7552 #define L1_CACHE_SHIFT 7
7553 #endif
7554
7555 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
7556 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
7557
7558 #define SMP_CACHE_BYTES L1_CACHE_BYTES
7559
7560 diff --git a/arch/powerpc/include/asm/elf.h b/arch/powerpc/include/asm/elf.h
7561 index cc0655a..13eac2e 100644
7562 --- a/arch/powerpc/include/asm/elf.h
7563 +++ b/arch/powerpc/include/asm/elf.h
7564 @@ -28,8 +28,19 @@
7565 the loader. We need to make sure that it is out of the way of the program
7566 that it will "exec", and that there is sufficient room for the brk. */
7567
7568 -extern unsigned long randomize_et_dyn(unsigned long base);
7569 -#define ELF_ET_DYN_BASE (randomize_et_dyn(0x20000000))
7570 +#define ELF_ET_DYN_BASE (0x20000000)
7571 +
7572 +#ifdef CONFIG_PAX_ASLR
7573 +#define PAX_ELF_ET_DYN_BASE (0x10000000UL)
7574 +
7575 +#ifdef __powerpc64__
7576 +#define PAX_DELTA_MMAP_LEN (is_32bit_task() ? 16 : 28)
7577 +#define PAX_DELTA_STACK_LEN (is_32bit_task() ? 16 : 28)
7578 +#else
7579 +#define PAX_DELTA_MMAP_LEN 15
7580 +#define PAX_DELTA_STACK_LEN 15
7581 +#endif
7582 +#endif
7583
7584 /*
7585 * Our registers are always unsigned longs, whether we're a 32 bit
7586 @@ -123,10 +134,6 @@ extern int arch_setup_additional_pages(struct linux_binprm *bprm,
7587 (0x7ff >> (PAGE_SHIFT - 12)) : \
7588 (0x3ffff >> (PAGE_SHIFT - 12)))
7589
7590 -extern unsigned long arch_randomize_brk(struct mm_struct *mm);
7591 -#define arch_randomize_brk arch_randomize_brk
7592 -
7593 -
7594 #ifdef CONFIG_SPU_BASE
7595 /* Notes used in ET_CORE. Note name is "SPU/<fd>/<filename>". */
7596 #define NT_SPU 1
7597 diff --git a/arch/powerpc/include/asm/exec.h b/arch/powerpc/include/asm/exec.h
7598 index 8196e9c..d83a9f3 100644
7599 --- a/arch/powerpc/include/asm/exec.h
7600 +++ b/arch/powerpc/include/asm/exec.h
7601 @@ -4,6 +4,6 @@
7602 #ifndef _ASM_POWERPC_EXEC_H
7603 #define _ASM_POWERPC_EXEC_H
7604
7605 -extern unsigned long arch_align_stack(unsigned long sp);
7606 +#define arch_align_stack(x) ((x) & ~0xfUL)
7607
7608 #endif /* _ASM_POWERPC_EXEC_H */
7609 diff --git a/arch/powerpc/include/asm/kmap_types.h b/arch/powerpc/include/asm/kmap_types.h
7610 index 5acabbd..7ea14fa 100644
7611 --- a/arch/powerpc/include/asm/kmap_types.h
7612 +++ b/arch/powerpc/include/asm/kmap_types.h
7613 @@ -10,7 +10,7 @@
7614 * 2 of the License, or (at your option) any later version.
7615 */
7616
7617 -#define KM_TYPE_NR 16
7618 +#define KM_TYPE_NR 17
7619
7620 #endif /* __KERNEL__ */
7621 #endif /* _ASM_POWERPC_KMAP_TYPES_H */
7622 diff --git a/arch/powerpc/include/asm/mman.h b/arch/powerpc/include/asm/mman.h
7623 index 8565c25..2865190 100644
7624 --- a/arch/powerpc/include/asm/mman.h
7625 +++ b/arch/powerpc/include/asm/mman.h
7626 @@ -24,7 +24,7 @@ static inline unsigned long arch_calc_vm_prot_bits(unsigned long prot)
7627 }
7628 #define arch_calc_vm_prot_bits(prot) arch_calc_vm_prot_bits(prot)
7629
7630 -static inline pgprot_t arch_vm_get_page_prot(unsigned long vm_flags)
7631 +static inline pgprot_t arch_vm_get_page_prot(vm_flags_t vm_flags)
7632 {
7633 return (vm_flags & VM_SAO) ? __pgprot(_PAGE_SAO) : __pgprot(0);
7634 }
7635 diff --git a/arch/powerpc/include/asm/page.h b/arch/powerpc/include/asm/page.h
7636 index b9f4262..dcf04f7 100644
7637 --- a/arch/powerpc/include/asm/page.h
7638 +++ b/arch/powerpc/include/asm/page.h
7639 @@ -230,8 +230,9 @@ extern long long virt_phys_offset;
7640 * and needs to be executable. This means the whole heap ends
7641 * up being executable.
7642 */
7643 -#define VM_DATA_DEFAULT_FLAGS32 (VM_READ | VM_WRITE | VM_EXEC | \
7644 - VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
7645 +#define VM_DATA_DEFAULT_FLAGS32 \
7646 + (((current->personality & READ_IMPLIES_EXEC) ? VM_EXEC : 0) | \
7647 + VM_READ | VM_WRITE | VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
7648
7649 #define VM_DATA_DEFAULT_FLAGS64 (VM_READ | VM_WRITE | \
7650 VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
7651 @@ -259,6 +260,9 @@ extern long long virt_phys_offset;
7652 #define is_kernel_addr(x) ((x) >= PAGE_OFFSET)
7653 #endif
7654
7655 +#define ktla_ktva(addr) (addr)
7656 +#define ktva_ktla(addr) (addr)
7657 +
7658 #ifndef CONFIG_PPC_BOOK3S_64
7659 /*
7660 * Use the top bit of the higher-level page table entries to indicate whether
7661 diff --git a/arch/powerpc/include/asm/page_64.h b/arch/powerpc/include/asm/page_64.h
7662 index 88693ce..ac6f9ab 100644
7663 --- a/arch/powerpc/include/asm/page_64.h
7664 +++ b/arch/powerpc/include/asm/page_64.h
7665 @@ -153,15 +153,18 @@ do { \
7666 * stack by default, so in the absence of a PT_GNU_STACK program header
7667 * we turn execute permission off.
7668 */
7669 -#define VM_STACK_DEFAULT_FLAGS32 (VM_READ | VM_WRITE | VM_EXEC | \
7670 - VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
7671 +#define VM_STACK_DEFAULT_FLAGS32 \
7672 + (((current->personality & READ_IMPLIES_EXEC) ? VM_EXEC : 0) | \
7673 + VM_READ | VM_WRITE | VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
7674
7675 #define VM_STACK_DEFAULT_FLAGS64 (VM_READ | VM_WRITE | \
7676 VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
7677
7678 +#ifndef CONFIG_PAX_PAGEEXEC
7679 #define VM_STACK_DEFAULT_FLAGS \
7680 (is_32bit_task() ? \
7681 VM_STACK_DEFAULT_FLAGS32 : VM_STACK_DEFAULT_FLAGS64)
7682 +#endif
7683
7684 #include <asm-generic/getorder.h>
7685
7686 diff --git a/arch/powerpc/include/asm/pgalloc-64.h b/arch/powerpc/include/asm/pgalloc-64.h
7687 index f65e27b..23ffb5b 100644
7688 --- a/arch/powerpc/include/asm/pgalloc-64.h
7689 +++ b/arch/powerpc/include/asm/pgalloc-64.h
7690 @@ -53,6 +53,7 @@ static inline void pgd_free(struct mm_struct *mm, pgd_t *pgd)
7691 #ifndef CONFIG_PPC_64K_PAGES
7692
7693 #define pgd_populate(MM, PGD, PUD) pgd_set(PGD, PUD)
7694 +#define pgd_populate_kernel(MM, PGD, PUD) pgd_populate((MM), (PGD), (PUD))
7695
7696 static inline pud_t *pud_alloc_one(struct mm_struct *mm, unsigned long addr)
7697 {
7698 @@ -70,6 +71,11 @@ static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
7699 pud_set(pud, (unsigned long)pmd);
7700 }
7701
7702 +static inline void pud_populate_kernel(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
7703 +{
7704 + pud_populate(mm, pud, pmd);
7705 +}
7706 +
7707 #define pmd_populate(mm, pmd, pte_page) \
7708 pmd_populate_kernel(mm, pmd, page_address(pte_page))
7709 #define pmd_populate_kernel(mm, pmd, pte) pmd_set(pmd, (unsigned long)(pte))
7710 @@ -171,6 +177,7 @@ extern void __tlb_remove_table(void *_table);
7711 #endif
7712
7713 #define pud_populate(mm, pud, pmd) pud_set(pud, (unsigned long)pmd)
7714 +#define pud_populate_kernel(mm, pud, pmd) pud_populate((mm), (pud), (pmd))
7715
7716 static inline void pmd_populate_kernel(struct mm_struct *mm, pmd_t *pmd,
7717 pte_t *pte)
7718 diff --git a/arch/powerpc/include/asm/pgtable.h b/arch/powerpc/include/asm/pgtable.h
7719 index 7d6eacf..14c0240 100644
7720 --- a/arch/powerpc/include/asm/pgtable.h
7721 +++ b/arch/powerpc/include/asm/pgtable.h
7722 @@ -2,6 +2,7 @@
7723 #define _ASM_POWERPC_PGTABLE_H
7724 #ifdef __KERNEL__
7725
7726 +#include <linux/const.h>
7727 #ifndef __ASSEMBLY__
7728 #include <asm/processor.h> /* For TASK_SIZE */
7729 #include <asm/mmu.h>
7730 diff --git a/arch/powerpc/include/asm/pte-hash32.h b/arch/powerpc/include/asm/pte-hash32.h
7731 index 4aad413..85d86bf 100644
7732 --- a/arch/powerpc/include/asm/pte-hash32.h
7733 +++ b/arch/powerpc/include/asm/pte-hash32.h
7734 @@ -21,6 +21,7 @@
7735 #define _PAGE_FILE 0x004 /* when !present: nonlinear file mapping */
7736 #define _PAGE_USER 0x004 /* usermode access allowed */
7737 #define _PAGE_GUARDED 0x008 /* G: prohibit speculative access */
7738 +#define _PAGE_EXEC _PAGE_GUARDED
7739 #define _PAGE_COHERENT 0x010 /* M: enforce memory coherence (SMP systems) */
7740 #define _PAGE_NO_CACHE 0x020 /* I: cache inhibit */
7741 #define _PAGE_WRITETHRU 0x040 /* W: cache write-through */
7742 diff --git a/arch/powerpc/include/asm/reg.h b/arch/powerpc/include/asm/reg.h
7743 index 10d1ef0..8f83abc 100644
7744 --- a/arch/powerpc/include/asm/reg.h
7745 +++ b/arch/powerpc/include/asm/reg.h
7746 @@ -234,6 +234,7 @@
7747 #define SPRN_DBCR 0x136 /* e300 Data Breakpoint Control Reg */
7748 #define SPRN_DSISR 0x012 /* Data Storage Interrupt Status Register */
7749 #define DSISR_NOHPTE 0x40000000 /* no translation found */
7750 +#define DSISR_GUARDED 0x10000000 /* fetch from guarded storage */
7751 #define DSISR_PROTFAULT 0x08000000 /* protection fault */
7752 #define DSISR_ISSTORE 0x02000000 /* access was a store */
7753 #define DSISR_DABRMATCH 0x00400000 /* hit data breakpoint */
7754 diff --git a/arch/powerpc/include/asm/smp.h b/arch/powerpc/include/asm/smp.h
7755 index 98da78e..dc68271 100644
7756 --- a/arch/powerpc/include/asm/smp.h
7757 +++ b/arch/powerpc/include/asm/smp.h
7758 @@ -50,7 +50,7 @@ struct smp_ops_t {
7759 int (*cpu_disable)(void);
7760 void (*cpu_die)(unsigned int nr);
7761 int (*cpu_bootable)(unsigned int nr);
7762 -};
7763 +} __no_const;
7764
7765 extern void smp_send_debugger_break(void);
7766 extern void start_secondary_resume(void);
7767 diff --git a/arch/powerpc/include/asm/thread_info.h b/arch/powerpc/include/asm/thread_info.h
7768 index ba7b197..d292e26 100644
7769 --- a/arch/powerpc/include/asm/thread_info.h
7770 +++ b/arch/powerpc/include/asm/thread_info.h
7771 @@ -93,7 +93,6 @@ static inline struct thread_info *current_thread_info(void)
7772 #define TIF_POLLING_NRFLAG 3 /* true if poll_idle() is polling
7773 TIF_NEED_RESCHED */
7774 #define TIF_32BIT 4 /* 32 bit binary */
7775 -#define TIF_PERFMON_WORK 5 /* work for pfm_handle_work() */
7776 #define TIF_PERFMON_CTXSW 6 /* perfmon needs ctxsw calls */
7777 #define TIF_SYSCALL_AUDIT 7 /* syscall auditing active */
7778 #define TIF_SINGLESTEP 8 /* singlestepping active */
7779 @@ -107,6 +106,9 @@ static inline struct thread_info *current_thread_info(void)
7780 #define TIF_EMULATE_STACK_STORE 16 /* Is an instruction emulation
7781 for stack store? */
7782 #define TIF_MEMDIE 17 /* is terminating due to OOM killer */
7783 +#define TIF_PERFMON_WORK 18 /* work for pfm_handle_work() */
7784 +/* mask must be expressable within 16 bits to satisfy 'andi' instruction reqs */
7785 +#define TIF_GRSEC_SETXID 5 /* update credentials on syscall entry/exit */
7786
7787 /* as above, but as bit values */
7788 #define _TIF_SYSCALL_TRACE (1<<TIF_SYSCALL_TRACE)
7789 @@ -126,9 +128,10 @@ static inline struct thread_info *current_thread_info(void)
7790 #define _TIF_SYSCALL_TRACEPOINT (1<<TIF_SYSCALL_TRACEPOINT)
7791 #define _TIF_EMULATE_STACK_STORE (1<<TIF_EMULATE_STACK_STORE)
7792 #define _TIF_NOHZ (1<<TIF_NOHZ)
7793 +#define _TIF_GRSEC_SETXID (1<<TIF_GRSEC_SETXID)
7794 #define _TIF_SYSCALL_T_OR_A (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | \
7795 _TIF_SECCOMP | _TIF_SYSCALL_TRACEPOINT | \
7796 - _TIF_NOHZ)
7797 + _TIF_NOHZ | _TIF_GRSEC_SETXID)
7798
7799 #define _TIF_USER_WORK_MASK (_TIF_SIGPENDING | _TIF_NEED_RESCHED | \
7800 _TIF_NOTIFY_RESUME | _TIF_UPROBE)
7801 diff --git a/arch/powerpc/include/asm/uaccess.h b/arch/powerpc/include/asm/uaccess.h
7802 index 9485b43..4718d50 100644
7803 --- a/arch/powerpc/include/asm/uaccess.h
7804 +++ b/arch/powerpc/include/asm/uaccess.h
7805 @@ -318,52 +318,6 @@ do { \
7806 extern unsigned long __copy_tofrom_user(void __user *to,
7807 const void __user *from, unsigned long size);
7808
7809 -#ifndef __powerpc64__
7810 -
7811 -static inline unsigned long copy_from_user(void *to,
7812 - const void __user *from, unsigned long n)
7813 -{
7814 - unsigned long over;
7815 -
7816 - if (access_ok(VERIFY_READ, from, n))
7817 - return __copy_tofrom_user((__force void __user *)to, from, n);
7818 - if ((unsigned long)from < TASK_SIZE) {
7819 - over = (unsigned long)from + n - TASK_SIZE;
7820 - return __copy_tofrom_user((__force void __user *)to, from,
7821 - n - over) + over;
7822 - }
7823 - return n;
7824 -}
7825 -
7826 -static inline unsigned long copy_to_user(void __user *to,
7827 - const void *from, unsigned long n)
7828 -{
7829 - unsigned long over;
7830 -
7831 - if (access_ok(VERIFY_WRITE, to, n))
7832 - return __copy_tofrom_user(to, (__force void __user *)from, n);
7833 - if ((unsigned long)to < TASK_SIZE) {
7834 - over = (unsigned long)to + n - TASK_SIZE;
7835 - return __copy_tofrom_user(to, (__force void __user *)from,
7836 - n - over) + over;
7837 - }
7838 - return n;
7839 -}
7840 -
7841 -#else /* __powerpc64__ */
7842 -
7843 -#define __copy_in_user(to, from, size) \
7844 - __copy_tofrom_user((to), (from), (size))
7845 -
7846 -extern unsigned long copy_from_user(void *to, const void __user *from,
7847 - unsigned long n);
7848 -extern unsigned long copy_to_user(void __user *to, const void *from,
7849 - unsigned long n);
7850 -extern unsigned long copy_in_user(void __user *to, const void __user *from,
7851 - unsigned long n);
7852 -
7853 -#endif /* __powerpc64__ */
7854 -
7855 static inline unsigned long __copy_from_user_inatomic(void *to,
7856 const void __user *from, unsigned long n)
7857 {
7858 @@ -387,6 +341,10 @@ static inline unsigned long __copy_from_user_inatomic(void *to,
7859 if (ret == 0)
7860 return 0;
7861 }
7862 +
7863 + if (!__builtin_constant_p(n))
7864 + check_object_size(to, n, false);
7865 +
7866 return __copy_tofrom_user((__force void __user *)to, from, n);
7867 }
7868
7869 @@ -413,6 +371,10 @@ static inline unsigned long __copy_to_user_inatomic(void __user *to,
7870 if (ret == 0)
7871 return 0;
7872 }
7873 +
7874 + if (!__builtin_constant_p(n))
7875 + check_object_size(from, n, true);
7876 +
7877 return __copy_tofrom_user(to, (__force const void __user *)from, n);
7878 }
7879
7880 @@ -430,6 +392,92 @@ static inline unsigned long __copy_to_user(void __user *to,
7881 return __copy_to_user_inatomic(to, from, size);
7882 }
7883
7884 +#ifndef __powerpc64__
7885 +
7886 +static inline unsigned long __must_check copy_from_user(void *to,
7887 + const void __user *from, unsigned long n)
7888 +{
7889 + unsigned long over;
7890 +
7891 + if ((long)n < 0)
7892 + return n;
7893 +
7894 + if (access_ok(VERIFY_READ, from, n)) {
7895 + if (!__builtin_constant_p(n))
7896 + check_object_size(to, n, false);
7897 + return __copy_tofrom_user((__force void __user *)to, from, n);
7898 + }
7899 + if ((unsigned long)from < TASK_SIZE) {
7900 + over = (unsigned long)from + n - TASK_SIZE;
7901 + if (!__builtin_constant_p(n - over))
7902 + check_object_size(to, n - over, false);
7903 + return __copy_tofrom_user((__force void __user *)to, from,
7904 + n - over) + over;
7905 + }
7906 + return n;
7907 +}
7908 +
7909 +static inline unsigned long __must_check copy_to_user(void __user *to,
7910 + const void *from, unsigned long n)
7911 +{
7912 + unsigned long over;
7913 +
7914 + if ((long)n < 0)
7915 + return n;
7916 +
7917 + if (access_ok(VERIFY_WRITE, to, n)) {
7918 + if (!__builtin_constant_p(n))
7919 + check_object_size(from, n, true);
7920 + return __copy_tofrom_user(to, (__force void __user *)from, n);
7921 + }
7922 + if ((unsigned long)to < TASK_SIZE) {
7923 + over = (unsigned long)to + n - TASK_SIZE;
7924 + if (!__builtin_constant_p(n))
7925 + check_object_size(from, n - over, true);
7926 + return __copy_tofrom_user(to, (__force void __user *)from,
7927 + n - over) + over;
7928 + }
7929 + return n;
7930 +}
7931 +
7932 +#else /* __powerpc64__ */
7933 +
7934 +#define __copy_in_user(to, from, size) \
7935 + __copy_tofrom_user((to), (from), (size))
7936 +
7937 +static inline unsigned long __must_check copy_from_user(void *to, const void __user *from, unsigned long n)
7938 +{
7939 + if ((long)n < 0 || n > INT_MAX)
7940 + return n;
7941 +
7942 + if (!__builtin_constant_p(n))
7943 + check_object_size(to, n, false);
7944 +
7945 + if (likely(access_ok(VERIFY_READ, from, n)))
7946 + n = __copy_from_user(to, from, n);
7947 + else
7948 + memset(to, 0, n);
7949 + return n;
7950 +}
7951 +
7952 +static inline unsigned long __must_check copy_to_user(void __user *to, const void *from, unsigned long n)
7953 +{
7954 + if ((long)n < 0 || n > INT_MAX)
7955 + return n;
7956 +
7957 + if (likely(access_ok(VERIFY_WRITE, to, n))) {
7958 + if (!__builtin_constant_p(n))
7959 + check_object_size(from, n, true);
7960 + n = __copy_to_user(to, from, n);
7961 + }
7962 + return n;
7963 +}
7964 +
7965 +extern unsigned long copy_in_user(void __user *to, const void __user *from,
7966 + unsigned long n);
7967 +
7968 +#endif /* __powerpc64__ */
7969 +
7970 extern unsigned long __clear_user(void __user *addr, unsigned long size);
7971
7972 static inline unsigned long clear_user(void __user *addr, unsigned long size)
7973 diff --git a/arch/powerpc/kernel/exceptions-64e.S b/arch/powerpc/kernel/exceptions-64e.S
7974 index 2d06704..1616f1b 100644
7975 --- a/arch/powerpc/kernel/exceptions-64e.S
7976 +++ b/arch/powerpc/kernel/exceptions-64e.S
7977 @@ -757,6 +757,7 @@ storage_fault_common:
7978 std r14,_DAR(r1)
7979 std r15,_DSISR(r1)
7980 addi r3,r1,STACK_FRAME_OVERHEAD
7981 + bl .save_nvgprs
7982 mr r4,r14
7983 mr r5,r15
7984 ld r14,PACA_EXGEN+EX_R14(r13)
7985 @@ -765,8 +766,7 @@ storage_fault_common:
7986 cmpdi r3,0
7987 bne- 1f
7988 b .ret_from_except_lite
7989 -1: bl .save_nvgprs
7990 - mr r5,r3
7991 +1: mr r5,r3
7992 addi r3,r1,STACK_FRAME_OVERHEAD
7993 ld r4,_DAR(r1)
7994 bl .bad_page_fault
7995 diff --git a/arch/powerpc/kernel/exceptions-64s.S b/arch/powerpc/kernel/exceptions-64s.S
7996 index 3a9ed6a..b534681 100644
7997 --- a/arch/powerpc/kernel/exceptions-64s.S
7998 +++ b/arch/powerpc/kernel/exceptions-64s.S
7999 @@ -1364,10 +1364,10 @@ handle_page_fault:
8000 11: ld r4,_DAR(r1)
8001 ld r5,_DSISR(r1)
8002 addi r3,r1,STACK_FRAME_OVERHEAD
8003 + bl .save_nvgprs
8004 bl .do_page_fault
8005 cmpdi r3,0
8006 beq+ 12f
8007 - bl .save_nvgprs
8008 mr r5,r3
8009 addi r3,r1,STACK_FRAME_OVERHEAD
8010 lwz r4,_DAR(r1)
8011 diff --git a/arch/powerpc/kernel/module_32.c b/arch/powerpc/kernel/module_32.c
8012 index 2e3200c..72095ce 100644
8013 --- a/arch/powerpc/kernel/module_32.c
8014 +++ b/arch/powerpc/kernel/module_32.c
8015 @@ -162,7 +162,7 @@ int module_frob_arch_sections(Elf32_Ehdr *hdr,
8016 me->arch.core_plt_section = i;
8017 }
8018 if (!me->arch.core_plt_section || !me->arch.init_plt_section) {
8019 - printk("Module doesn't contain .plt or .init.plt sections.\n");
8020 + printk("Module %s doesn't contain .plt or .init.plt sections.\n", me->name);
8021 return -ENOEXEC;
8022 }
8023
8024 @@ -192,11 +192,16 @@ static uint32_t do_plt_call(void *location,
8025
8026 DEBUGP("Doing plt for call to 0x%x at 0x%x\n", val, (unsigned int)location);
8027 /* Init, or core PLT? */
8028 - if (location >= mod->module_core
8029 - && location < mod->module_core + mod->core_size)
8030 + if ((location >= mod->module_core_rx && location < mod->module_core_rx + mod->core_size_rx) ||
8031 + (location >= mod->module_core_rw && location < mod->module_core_rw + mod->core_size_rw))
8032 entry = (void *)sechdrs[mod->arch.core_plt_section].sh_addr;
8033 - else
8034 + else if ((location >= mod->module_init_rx && location < mod->module_init_rx + mod->init_size_rx) ||
8035 + (location >= mod->module_init_rw && location < mod->module_init_rw + mod->init_size_rw))
8036 entry = (void *)sechdrs[mod->arch.init_plt_section].sh_addr;
8037 + else {
8038 + printk(KERN_ERR "%s: invalid R_PPC_REL24 entry found\n", mod->name);
8039 + return ~0UL;
8040 + }
8041
8042 /* Find this entry, or if that fails, the next avail. entry */
8043 while (entry->jump[0]) {
8044 diff --git a/arch/powerpc/kernel/process.c b/arch/powerpc/kernel/process.c
8045 index 96d2fdf..f6d10c8 100644
8046 --- a/arch/powerpc/kernel/process.c
8047 +++ b/arch/powerpc/kernel/process.c
8048 @@ -886,8 +886,8 @@ void show_regs(struct pt_regs * regs)
8049 * Lookup NIP late so we have the best change of getting the
8050 * above info out without failing
8051 */
8052 - printk("NIP ["REG"] %pS\n", regs->nip, (void *)regs->nip);
8053 - printk("LR ["REG"] %pS\n", regs->link, (void *)regs->link);
8054 + printk("NIP ["REG"] %pA\n", regs->nip, (void *)regs->nip);
8055 + printk("LR ["REG"] %pA\n", regs->link, (void *)regs->link);
8056 #endif
8057 #ifdef CONFIG_PPC_TRANSACTIONAL_MEM
8058 printk("PACATMSCRATCH [%llx]\n", get_paca()->tm_scratch);
8059 @@ -1352,10 +1352,10 @@ void show_stack(struct task_struct *tsk, unsigned long *stack)
8060 newsp = stack[0];
8061 ip = stack[STACK_FRAME_LR_SAVE];
8062 if (!firstframe || ip != lr) {
8063 - printk("["REG"] ["REG"] %pS", sp, ip, (void *)ip);
8064 + printk("["REG"] ["REG"] %pA", sp, ip, (void *)ip);
8065 #ifdef CONFIG_FUNCTION_GRAPH_TRACER
8066 if ((ip == rth || ip == mrth) && curr_frame >= 0) {
8067 - printk(" (%pS)",
8068 + printk(" (%pA)",
8069 (void *)current->ret_stack[curr_frame].ret);
8070 curr_frame--;
8071 }
8072 @@ -1375,7 +1375,7 @@ void show_stack(struct task_struct *tsk, unsigned long *stack)
8073 struct pt_regs *regs = (struct pt_regs *)
8074 (sp + STACK_FRAME_OVERHEAD);
8075 lr = regs->link;
8076 - printk("--- Exception: %lx at %pS\n LR = %pS\n",
8077 + printk("--- Exception: %lx at %pA\n LR = %pA\n",
8078 regs->trap, (void *)regs->nip, (void *)lr);
8079 firstframe = 1;
8080 }
8081 @@ -1411,58 +1411,3 @@ void notrace __ppc64_runlatch_off(void)
8082 mtspr(SPRN_CTRLT, ctrl);
8083 }
8084 #endif /* CONFIG_PPC64 */
8085 -
8086 -unsigned long arch_align_stack(unsigned long sp)
8087 -{
8088 - if (!(current->personality & ADDR_NO_RANDOMIZE) && randomize_va_space)
8089 - sp -= get_random_int() & ~PAGE_MASK;
8090 - return sp & ~0xf;
8091 -}
8092 -
8093 -static inline unsigned long brk_rnd(void)
8094 -{
8095 - unsigned long rnd = 0;
8096 -
8097 - /* 8MB for 32bit, 1GB for 64bit */
8098 - if (is_32bit_task())
8099 - rnd = (long)(get_random_int() % (1<<(23-PAGE_SHIFT)));
8100 - else
8101 - rnd = (long)(get_random_int() % (1<<(30-PAGE_SHIFT)));
8102 -
8103 - return rnd << PAGE_SHIFT;
8104 -}
8105 -
8106 -unsigned long arch_randomize_brk(struct mm_struct *mm)
8107 -{
8108 - unsigned long base = mm->brk;
8109 - unsigned long ret;
8110 -
8111 -#ifdef CONFIG_PPC_STD_MMU_64
8112 - /*
8113 - * If we are using 1TB segments and we are allowed to randomise
8114 - * the heap, we can put it above 1TB so it is backed by a 1TB
8115 - * segment. Otherwise the heap will be in the bottom 1TB
8116 - * which always uses 256MB segments and this may result in a
8117 - * performance penalty.
8118 - */
8119 - if (!is_32bit_task() && (mmu_highuser_ssize == MMU_SEGSIZE_1T))
8120 - base = max_t(unsigned long, mm->brk, 1UL << SID_SHIFT_1T);
8121 -#endif
8122 -
8123 - ret = PAGE_ALIGN(base + brk_rnd());
8124 -
8125 - if (ret < mm->brk)
8126 - return mm->brk;
8127 -
8128 - return ret;
8129 -}
8130 -
8131 -unsigned long randomize_et_dyn(unsigned long base)
8132 -{
8133 - unsigned long ret = PAGE_ALIGN(base + brk_rnd());
8134 -
8135 - if (ret < base)
8136 - return base;
8137 -
8138 - return ret;
8139 -}
8140 diff --git a/arch/powerpc/kernel/ptrace.c b/arch/powerpc/kernel/ptrace.c
8141 index 9a0d24c..e7fbedf 100644
8142 --- a/arch/powerpc/kernel/ptrace.c
8143 +++ b/arch/powerpc/kernel/ptrace.c
8144 @@ -1761,6 +1761,10 @@ long arch_ptrace(struct task_struct *child, long request,
8145 return ret;
8146 }
8147
8148 +#ifdef CONFIG_GRKERNSEC_SETXID
8149 +extern void gr_delayed_cred_worker(void);
8150 +#endif
8151 +
8152 /*
8153 * We must return the syscall number to actually look up in the table.
8154 * This can be -1L to skip running any syscall at all.
8155 @@ -1773,6 +1777,11 @@ long do_syscall_trace_enter(struct pt_regs *regs)
8156
8157 secure_computing_strict(regs->gpr[0]);
8158
8159 +#ifdef CONFIG_GRKERNSEC_SETXID
8160 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
8161 + gr_delayed_cred_worker();
8162 +#endif
8163 +
8164 if (test_thread_flag(TIF_SYSCALL_TRACE) &&
8165 tracehook_report_syscall_entry(regs))
8166 /*
8167 @@ -1807,6 +1816,11 @@ void do_syscall_trace_leave(struct pt_regs *regs)
8168 {
8169 int step;
8170
8171 +#ifdef CONFIG_GRKERNSEC_SETXID
8172 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
8173 + gr_delayed_cred_worker();
8174 +#endif
8175 +
8176 audit_syscall_exit(regs);
8177
8178 if (unlikely(test_thread_flag(TIF_SYSCALL_TRACEPOINT)))
8179 diff --git a/arch/powerpc/kernel/signal_32.c b/arch/powerpc/kernel/signal_32.c
8180 index fea2dba..a779f6b 100644
8181 --- a/arch/powerpc/kernel/signal_32.c
8182 +++ b/arch/powerpc/kernel/signal_32.c
8183 @@ -1002,7 +1002,7 @@ int handle_rt_signal32(unsigned long sig, struct k_sigaction *ka,
8184 /* Save user registers on the stack */
8185 frame = &rt_sf->uc.uc_mcontext;
8186 addr = frame;
8187 - if (vdso32_rt_sigtramp && current->mm->context.vdso_base) {
8188 + if (vdso32_rt_sigtramp && current->mm->context.vdso_base != ~0UL) {
8189 sigret = 0;
8190 tramp = current->mm->context.vdso_base + vdso32_rt_sigtramp;
8191 } else {
8192 diff --git a/arch/powerpc/kernel/signal_64.c b/arch/powerpc/kernel/signal_64.c
8193 index 1e7ba88..17afb1b 100644
8194 --- a/arch/powerpc/kernel/signal_64.c
8195 +++ b/arch/powerpc/kernel/signal_64.c
8196 @@ -763,7 +763,7 @@ int handle_rt_signal64(int signr, struct k_sigaction *ka, siginfo_t *info,
8197 #endif
8198
8199 /* Set up to return from userspace. */
8200 - if (vdso64_rt_sigtramp && current->mm->context.vdso_base) {
8201 + if (vdso64_rt_sigtramp && current->mm->context.vdso_base != ~0UL) {
8202 regs->link = current->mm->context.vdso_base + vdso64_rt_sigtramp;
8203 } else {
8204 err |= setup_trampoline(__NR_rt_sigreturn, &frame->tramp[0]);
8205 diff --git a/arch/powerpc/kernel/traps.c b/arch/powerpc/kernel/traps.c
8206 index f783c93..619baf1 100644
8207 --- a/arch/powerpc/kernel/traps.c
8208 +++ b/arch/powerpc/kernel/traps.c
8209 @@ -142,6 +142,8 @@ static unsigned __kprobes long oops_begin(struct pt_regs *regs)
8210 return flags;
8211 }
8212
8213 +extern void gr_handle_kernel_exploit(void);
8214 +
8215 static void __kprobes oops_end(unsigned long flags, struct pt_regs *regs,
8216 int signr)
8217 {
8218 @@ -191,6 +193,9 @@ static void __kprobes oops_end(unsigned long flags, struct pt_regs *regs,
8219 panic("Fatal exception in interrupt");
8220 if (panic_on_oops)
8221 panic("Fatal exception");
8222 +
8223 + gr_handle_kernel_exploit();
8224 +
8225 do_exit(signr);
8226 }
8227
8228 diff --git a/arch/powerpc/kernel/vdso.c b/arch/powerpc/kernel/vdso.c
8229 index 1d9c926..25f4741 100644
8230 --- a/arch/powerpc/kernel/vdso.c
8231 +++ b/arch/powerpc/kernel/vdso.c
8232 @@ -34,6 +34,7 @@
8233 #include <asm/firmware.h>
8234 #include <asm/vdso.h>
8235 #include <asm/vdso_datapage.h>
8236 +#include <asm/mman.h>
8237
8238 #include "setup.h"
8239
8240 @@ -222,7 +223,7 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
8241 vdso_base = VDSO32_MBASE;
8242 #endif
8243
8244 - current->mm->context.vdso_base = 0;
8245 + current->mm->context.vdso_base = ~0UL;
8246
8247 /* vDSO has a problem and was disabled, just don't "enable" it for the
8248 * process
8249 @@ -242,7 +243,7 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
8250 vdso_base = get_unmapped_area(NULL, vdso_base,
8251 (vdso_pages << PAGE_SHIFT) +
8252 ((VDSO_ALIGNMENT - 1) & PAGE_MASK),
8253 - 0, 0);
8254 + 0, MAP_PRIVATE | MAP_EXECUTABLE);
8255 if (IS_ERR_VALUE(vdso_base)) {
8256 rc = vdso_base;
8257 goto fail_mmapsem;
8258 diff --git a/arch/powerpc/lib/usercopy_64.c b/arch/powerpc/lib/usercopy_64.c
8259 index 5eea6f3..5d10396 100644
8260 --- a/arch/powerpc/lib/usercopy_64.c
8261 +++ b/arch/powerpc/lib/usercopy_64.c
8262 @@ -9,22 +9,6 @@
8263 #include <linux/module.h>
8264 #include <asm/uaccess.h>
8265
8266 -unsigned long copy_from_user(void *to, const void __user *from, unsigned long n)
8267 -{
8268 - if (likely(access_ok(VERIFY_READ, from, n)))
8269 - n = __copy_from_user(to, from, n);
8270 - else
8271 - memset(to, 0, n);
8272 - return n;
8273 -}
8274 -
8275 -unsigned long copy_to_user(void __user *to, const void *from, unsigned long n)
8276 -{
8277 - if (likely(access_ok(VERIFY_WRITE, to, n)))
8278 - n = __copy_to_user(to, from, n);
8279 - return n;
8280 -}
8281 -
8282 unsigned long copy_in_user(void __user *to, const void __user *from,
8283 unsigned long n)
8284 {
8285 @@ -35,7 +19,5 @@ unsigned long copy_in_user(void __user *to, const void __user *from,
8286 return n;
8287 }
8288
8289 -EXPORT_SYMBOL(copy_from_user);
8290 -EXPORT_SYMBOL(copy_to_user);
8291 EXPORT_SYMBOL(copy_in_user);
8292
8293 diff --git a/arch/powerpc/mm/fault.c b/arch/powerpc/mm/fault.c
8294 index 51ab9e7..7d3c78b 100644
8295 --- a/arch/powerpc/mm/fault.c
8296 +++ b/arch/powerpc/mm/fault.c
8297 @@ -33,6 +33,10 @@
8298 #include <linux/magic.h>
8299 #include <linux/ratelimit.h>
8300 #include <linux/context_tracking.h>
8301 +#include <linux/slab.h>
8302 +#include <linux/pagemap.h>
8303 +#include <linux/compiler.h>
8304 +#include <linux/unistd.h>
8305
8306 #include <asm/firmware.h>
8307 #include <asm/page.h>
8308 @@ -69,6 +73,33 @@ static inline int notify_page_fault(struct pt_regs *regs)
8309 }
8310 #endif
8311
8312 +#ifdef CONFIG_PAX_PAGEEXEC
8313 +/*
8314 + * PaX: decide what to do with offenders (regs->nip = fault address)
8315 + *
8316 + * returns 1 when task should be killed
8317 + */
8318 +static int pax_handle_fetch_fault(struct pt_regs *regs)
8319 +{
8320 + return 1;
8321 +}
8322 +
8323 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
8324 +{
8325 + unsigned long i;
8326 +
8327 + printk(KERN_ERR "PAX: bytes at PC: ");
8328 + for (i = 0; i < 5; i++) {
8329 + unsigned int c;
8330 + if (get_user(c, (unsigned int __user *)pc+i))
8331 + printk(KERN_CONT "???????? ");
8332 + else
8333 + printk(KERN_CONT "%08x ", c);
8334 + }
8335 + printk("\n");
8336 +}
8337 +#endif
8338 +
8339 /*
8340 * Check whether the instruction at regs->nip is a store using
8341 * an update addressing form which will update r1.
8342 @@ -216,7 +247,7 @@ int __kprobes do_page_fault(struct pt_regs *regs, unsigned long address,
8343 * indicate errors in DSISR but can validly be set in SRR1.
8344 */
8345 if (trap == 0x400)
8346 - error_code &= 0x48200000;
8347 + error_code &= 0x58200000;
8348 else
8349 is_write = error_code & DSISR_ISSTORE;
8350 #else
8351 @@ -378,7 +409,7 @@ good_area:
8352 * "undefined". Of those that can be set, this is the only
8353 * one which seems bad.
8354 */
8355 - if (error_code & 0x10000000)
8356 + if (error_code & DSISR_GUARDED)
8357 /* Guarded storage error. */
8358 goto bad_area;
8359 #endif /* CONFIG_8xx */
8360 @@ -393,7 +424,7 @@ good_area:
8361 * processors use the same I/D cache coherency mechanism
8362 * as embedded.
8363 */
8364 - if (error_code & DSISR_PROTFAULT)
8365 + if (error_code & (DSISR_PROTFAULT | DSISR_GUARDED))
8366 goto bad_area;
8367 #endif /* CONFIG_PPC_STD_MMU */
8368
8369 @@ -483,6 +514,23 @@ bad_area:
8370 bad_area_nosemaphore:
8371 /* User mode accesses cause a SIGSEGV */
8372 if (user_mode(regs)) {
8373 +
8374 +#ifdef CONFIG_PAX_PAGEEXEC
8375 + if (mm->pax_flags & MF_PAX_PAGEEXEC) {
8376 +#ifdef CONFIG_PPC_STD_MMU
8377 + if (is_exec && (error_code & (DSISR_PROTFAULT | DSISR_GUARDED))) {
8378 +#else
8379 + if (is_exec && regs->nip == address) {
8380 +#endif
8381 + switch (pax_handle_fetch_fault(regs)) {
8382 + }
8383 +
8384 + pax_report_fault(regs, (void *)regs->nip, (void *)regs->gpr[PT_R1]);
8385 + do_group_exit(SIGKILL);
8386 + }
8387 + }
8388 +#endif
8389 +
8390 _exception(SIGSEGV, regs, code, address);
8391 goto bail;
8392 }
8393 diff --git a/arch/powerpc/mm/mmap.c b/arch/powerpc/mm/mmap.c
8394 index cb8bdbe..d770680 100644
8395 --- a/arch/powerpc/mm/mmap.c
8396 +++ b/arch/powerpc/mm/mmap.c
8397 @@ -57,6 +57,10 @@ static unsigned long mmap_rnd(void)
8398 {
8399 unsigned long rnd = 0;
8400
8401 +#ifdef CONFIG_PAX_RANDMMAP
8402 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
8403 +#endif
8404 +
8405 if (current->flags & PF_RANDOMIZE) {
8406 /* 8MB for 32bit, 1GB for 64bit */
8407 if (is_32bit_task())
8408 @@ -91,9 +95,21 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
8409 */
8410 if (mmap_is_legacy()) {
8411 mm->mmap_base = TASK_UNMAPPED_BASE;
8412 +
8413 +#ifdef CONFIG_PAX_RANDMMAP
8414 + if (mm->pax_flags & MF_PAX_RANDMMAP)
8415 + mm->mmap_base += mm->delta_mmap;
8416 +#endif
8417 +
8418 mm->get_unmapped_area = arch_get_unmapped_area;
8419 } else {
8420 mm->mmap_base = mmap_base();
8421 +
8422 +#ifdef CONFIG_PAX_RANDMMAP
8423 + if (mm->pax_flags & MF_PAX_RANDMMAP)
8424 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
8425 +#endif
8426 +
8427 mm->get_unmapped_area = arch_get_unmapped_area_topdown;
8428 }
8429 }
8430 diff --git a/arch/powerpc/mm/slice.c b/arch/powerpc/mm/slice.c
8431 index 7ce9cf3..a964087 100644
8432 --- a/arch/powerpc/mm/slice.c
8433 +++ b/arch/powerpc/mm/slice.c
8434 @@ -103,7 +103,7 @@ static int slice_area_is_free(struct mm_struct *mm, unsigned long addr,
8435 if ((mm->task_size - len) < addr)
8436 return 0;
8437 vma = find_vma(mm, addr);
8438 - return (!vma || (addr + len) <= vma->vm_start);
8439 + return check_heap_stack_gap(vma, addr, len, 0);
8440 }
8441
8442 static int slice_low_has_vma(struct mm_struct *mm, unsigned long slice)
8443 @@ -277,6 +277,12 @@ static unsigned long slice_find_area_bottomup(struct mm_struct *mm,
8444 info.align_offset = 0;
8445
8446 addr = TASK_UNMAPPED_BASE;
8447 +
8448 +#ifdef CONFIG_PAX_RANDMMAP
8449 + if (mm->pax_flags & MF_PAX_RANDMMAP)
8450 + addr += mm->delta_mmap;
8451 +#endif
8452 +
8453 while (addr < TASK_SIZE) {
8454 info.low_limit = addr;
8455 if (!slice_scan_available(addr, available, 1, &addr))
8456 @@ -410,6 +416,11 @@ unsigned long slice_get_unmapped_area(unsigned long addr, unsigned long len,
8457 if (fixed && addr > (mm->task_size - len))
8458 return -EINVAL;
8459
8460 +#ifdef CONFIG_PAX_RANDMMAP
8461 + if (!fixed && (mm->pax_flags & MF_PAX_RANDMMAP))
8462 + addr = 0;
8463 +#endif
8464 +
8465 /* If hint, make sure it matches our alignment restrictions */
8466 if (!fixed && addr) {
8467 addr = _ALIGN_UP(addr, 1ul << pshift);
8468 diff --git a/arch/powerpc/platforms/cell/spufs/file.c b/arch/powerpc/platforms/cell/spufs/file.c
8469 index 9098692..3d54cd1 100644
8470 --- a/arch/powerpc/platforms/cell/spufs/file.c
8471 +++ b/arch/powerpc/platforms/cell/spufs/file.c
8472 @@ -280,9 +280,9 @@ spufs_mem_mmap_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
8473 return VM_FAULT_NOPAGE;
8474 }
8475
8476 -static int spufs_mem_mmap_access(struct vm_area_struct *vma,
8477 +static ssize_t spufs_mem_mmap_access(struct vm_area_struct *vma,
8478 unsigned long address,
8479 - void *buf, int len, int write)
8480 + void *buf, size_t len, int write)
8481 {
8482 struct spu_context *ctx = vma->vm_file->private_data;
8483 unsigned long offset = address - vma->vm_start;
8484 diff --git a/arch/s390/include/asm/atomic.h b/arch/s390/include/asm/atomic.h
8485 index c797832..ce575c8 100644
8486 --- a/arch/s390/include/asm/atomic.h
8487 +++ b/arch/s390/include/asm/atomic.h
8488 @@ -326,6 +326,16 @@ static inline long long atomic64_dec_if_positive(atomic64_t *v)
8489 #define atomic64_dec_and_test(_v) (atomic64_sub_return(1, _v) == 0)
8490 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1, 0)
8491
8492 +#define atomic64_read_unchecked(v) atomic64_read(v)
8493 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
8494 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
8495 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
8496 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
8497 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
8498 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
8499 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
8500 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
8501 +
8502 #define smp_mb__before_atomic_dec() smp_mb()
8503 #define smp_mb__after_atomic_dec() smp_mb()
8504 #define smp_mb__before_atomic_inc() smp_mb()
8505 diff --git a/arch/s390/include/asm/cache.h b/arch/s390/include/asm/cache.h
8506 index 4d7ccac..d03d0ad 100644
8507 --- a/arch/s390/include/asm/cache.h
8508 +++ b/arch/s390/include/asm/cache.h
8509 @@ -9,8 +9,10 @@
8510 #ifndef __ARCH_S390_CACHE_H
8511 #define __ARCH_S390_CACHE_H
8512
8513 -#define L1_CACHE_BYTES 256
8514 +#include <linux/const.h>
8515 +
8516 #define L1_CACHE_SHIFT 8
8517 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
8518 #define NET_SKB_PAD 32
8519
8520 #define __read_mostly __attribute__((__section__(".data..read_mostly")))
8521 diff --git a/arch/s390/include/asm/elf.h b/arch/s390/include/asm/elf.h
8522 index 78f4f87..598ce39 100644
8523 --- a/arch/s390/include/asm/elf.h
8524 +++ b/arch/s390/include/asm/elf.h
8525 @@ -162,8 +162,14 @@ extern unsigned int vdso_enabled;
8526 the loader. We need to make sure that it is out of the way of the program
8527 that it will "exec", and that there is sufficient room for the brk. */
8528
8529 -extern unsigned long randomize_et_dyn(unsigned long base);
8530 -#define ELF_ET_DYN_BASE (randomize_et_dyn(STACK_TOP / 3 * 2))
8531 +#define ELF_ET_DYN_BASE (STACK_TOP / 3 * 2)
8532 +
8533 +#ifdef CONFIG_PAX_ASLR
8534 +#define PAX_ELF_ET_DYN_BASE (test_thread_flag(TIF_31BIT) ? 0x10000UL : 0x80000000UL)
8535 +
8536 +#define PAX_DELTA_MMAP_LEN (test_thread_flag(TIF_31BIT) ? 15 : 26)
8537 +#define PAX_DELTA_STACK_LEN (test_thread_flag(TIF_31BIT) ? 15 : 26)
8538 +#endif
8539
8540 /* This yields a mask that user programs can use to figure out what
8541 instruction set this CPU supports. */
8542 @@ -222,9 +228,6 @@ struct linux_binprm;
8543 #define ARCH_HAS_SETUP_ADDITIONAL_PAGES 1
8544 int arch_setup_additional_pages(struct linux_binprm *, int);
8545
8546 -extern unsigned long arch_randomize_brk(struct mm_struct *mm);
8547 -#define arch_randomize_brk arch_randomize_brk
8548 -
8549 void *fill_cpu_elf_notes(void *ptr, struct save_area *sa);
8550
8551 #endif
8552 diff --git a/arch/s390/include/asm/exec.h b/arch/s390/include/asm/exec.h
8553 index c4a93d6..4d2a9b4 100644
8554 --- a/arch/s390/include/asm/exec.h
8555 +++ b/arch/s390/include/asm/exec.h
8556 @@ -7,6 +7,6 @@
8557 #ifndef __ASM_EXEC_H
8558 #define __ASM_EXEC_H
8559
8560 -extern unsigned long arch_align_stack(unsigned long sp);
8561 +#define arch_align_stack(x) ((x) & ~0xfUL)
8562
8563 #endif /* __ASM_EXEC_H */
8564 diff --git a/arch/s390/include/asm/uaccess.h b/arch/s390/include/asm/uaccess.h
8565 index 9c33ed4..e40cbef 100644
8566 --- a/arch/s390/include/asm/uaccess.h
8567 +++ b/arch/s390/include/asm/uaccess.h
8568 @@ -252,6 +252,10 @@ static inline unsigned long __must_check
8569 copy_to_user(void __user *to, const void *from, unsigned long n)
8570 {
8571 might_fault();
8572 +
8573 + if ((long)n < 0)
8574 + return n;
8575 +
8576 return __copy_to_user(to, from, n);
8577 }
8578
8579 @@ -275,6 +279,9 @@ copy_to_user(void __user *to, const void *from, unsigned long n)
8580 static inline unsigned long __must_check
8581 __copy_from_user(void *to, const void __user *from, unsigned long n)
8582 {
8583 + if ((long)n < 0)
8584 + return n;
8585 +
8586 if (__builtin_constant_p(n) && (n <= 256))
8587 return uaccess.copy_from_user_small(n, from, to);
8588 else
8589 @@ -306,10 +313,14 @@ __compiletime_warning("copy_from_user() buffer size is not provably correct")
8590 static inline unsigned long __must_check
8591 copy_from_user(void *to, const void __user *from, unsigned long n)
8592 {
8593 - unsigned int sz = __compiletime_object_size(to);
8594 + size_t sz = __compiletime_object_size(to);
8595
8596 might_fault();
8597 - if (unlikely(sz != -1 && sz < n)) {
8598 +
8599 + if ((long)n < 0)
8600 + return n;
8601 +
8602 + if (unlikely(sz != (size_t)-1 && sz < n)) {
8603 copy_from_user_overflow();
8604 return n;
8605 }
8606 diff --git a/arch/s390/kernel/module.c b/arch/s390/kernel/module.c
8607 index 7845e15..59c4353 100644
8608 --- a/arch/s390/kernel/module.c
8609 +++ b/arch/s390/kernel/module.c
8610 @@ -169,11 +169,11 @@ int module_frob_arch_sections(Elf_Ehdr *hdr, Elf_Shdr *sechdrs,
8611
8612 /* Increase core size by size of got & plt and set start
8613 offsets for got and plt. */
8614 - me->core_size = ALIGN(me->core_size, 4);
8615 - me->arch.got_offset = me->core_size;
8616 - me->core_size += me->arch.got_size;
8617 - me->arch.plt_offset = me->core_size;
8618 - me->core_size += me->arch.plt_size;
8619 + me->core_size_rw = ALIGN(me->core_size_rw, 4);
8620 + me->arch.got_offset = me->core_size_rw;
8621 + me->core_size_rw += me->arch.got_size;
8622 + me->arch.plt_offset = me->core_size_rx;
8623 + me->core_size_rx += me->arch.plt_size;
8624 return 0;
8625 }
8626
8627 @@ -289,7 +289,7 @@ static int apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
8628 if (info->got_initialized == 0) {
8629 Elf_Addr *gotent;
8630
8631 - gotent = me->module_core + me->arch.got_offset +
8632 + gotent = me->module_core_rw + me->arch.got_offset +
8633 info->got_offset;
8634 *gotent = val;
8635 info->got_initialized = 1;
8636 @@ -312,7 +312,7 @@ static int apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
8637 rc = apply_rela_bits(loc, val, 0, 64, 0);
8638 else if (r_type == R_390_GOTENT ||
8639 r_type == R_390_GOTPLTENT) {
8640 - val += (Elf_Addr) me->module_core - loc;
8641 + val += (Elf_Addr) me->module_core_rw - loc;
8642 rc = apply_rela_bits(loc, val, 1, 32, 1);
8643 }
8644 break;
8645 @@ -325,7 +325,7 @@ static int apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
8646 case R_390_PLTOFF64: /* 16 bit offset from GOT to PLT. */
8647 if (info->plt_initialized == 0) {
8648 unsigned int *ip;
8649 - ip = me->module_core + me->arch.plt_offset +
8650 + ip = me->module_core_rx + me->arch.plt_offset +
8651 info->plt_offset;
8652 #ifndef CONFIG_64BIT
8653 ip[0] = 0x0d105810; /* basr 1,0; l 1,6(1); br 1 */
8654 @@ -350,7 +350,7 @@ static int apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
8655 val - loc + 0xffffUL < 0x1ffffeUL) ||
8656 (r_type == R_390_PLT32DBL &&
8657 val - loc + 0xffffffffULL < 0x1fffffffeULL)))
8658 - val = (Elf_Addr) me->module_core +
8659 + val = (Elf_Addr) me->module_core_rx +
8660 me->arch.plt_offset +
8661 info->plt_offset;
8662 val += rela->r_addend - loc;
8663 @@ -372,7 +372,7 @@ static int apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
8664 case R_390_GOTOFF32: /* 32 bit offset to GOT. */
8665 case R_390_GOTOFF64: /* 64 bit offset to GOT. */
8666 val = val + rela->r_addend -
8667 - ((Elf_Addr) me->module_core + me->arch.got_offset);
8668 + ((Elf_Addr) me->module_core_rw + me->arch.got_offset);
8669 if (r_type == R_390_GOTOFF16)
8670 rc = apply_rela_bits(loc, val, 0, 16, 0);
8671 else if (r_type == R_390_GOTOFF32)
8672 @@ -382,7 +382,7 @@ static int apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
8673 break;
8674 case R_390_GOTPC: /* 32 bit PC relative offset to GOT. */
8675 case R_390_GOTPCDBL: /* 32 bit PC rel. off. to GOT shifted by 1. */
8676 - val = (Elf_Addr) me->module_core + me->arch.got_offset +
8677 + val = (Elf_Addr) me->module_core_rw + me->arch.got_offset +
8678 rela->r_addend - loc;
8679 if (r_type == R_390_GOTPC)
8680 rc = apply_rela_bits(loc, val, 1, 32, 0);
8681 diff --git a/arch/s390/kernel/process.c b/arch/s390/kernel/process.c
8682 index c5dbb33..b41f4ee 100644
8683 --- a/arch/s390/kernel/process.c
8684 +++ b/arch/s390/kernel/process.c
8685 @@ -237,39 +237,3 @@ unsigned long get_wchan(struct task_struct *p)
8686 }
8687 return 0;
8688 }
8689 -
8690 -unsigned long arch_align_stack(unsigned long sp)
8691 -{
8692 - if (!(current->personality & ADDR_NO_RANDOMIZE) && randomize_va_space)
8693 - sp -= get_random_int() & ~PAGE_MASK;
8694 - return sp & ~0xf;
8695 -}
8696 -
8697 -static inline unsigned long brk_rnd(void)
8698 -{
8699 - /* 8MB for 32bit, 1GB for 64bit */
8700 - if (is_32bit_task())
8701 - return (get_random_int() & 0x7ffUL) << PAGE_SHIFT;
8702 - else
8703 - return (get_random_int() & 0x3ffffUL) << PAGE_SHIFT;
8704 -}
8705 -
8706 -unsigned long arch_randomize_brk(struct mm_struct *mm)
8707 -{
8708 - unsigned long ret = PAGE_ALIGN(mm->brk + brk_rnd());
8709 -
8710 - if (ret < mm->brk)
8711 - return mm->brk;
8712 - return ret;
8713 -}
8714 -
8715 -unsigned long randomize_et_dyn(unsigned long base)
8716 -{
8717 - unsigned long ret = PAGE_ALIGN(base + brk_rnd());
8718 -
8719 - if (!(current->flags & PF_RANDOMIZE))
8720 - return base;
8721 - if (ret < base)
8722 - return base;
8723 - return ret;
8724 -}
8725 diff --git a/arch/s390/mm/mmap.c b/arch/s390/mm/mmap.c
8726 index 4002329..99b67cb 100644
8727 --- a/arch/s390/mm/mmap.c
8728 +++ b/arch/s390/mm/mmap.c
8729 @@ -90,9 +90,21 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
8730 */
8731 if (mmap_is_legacy()) {
8732 mm->mmap_base = TASK_UNMAPPED_BASE;
8733 +
8734 +#ifdef CONFIG_PAX_RANDMMAP
8735 + if (mm->pax_flags & MF_PAX_RANDMMAP)
8736 + mm->mmap_base += mm->delta_mmap;
8737 +#endif
8738 +
8739 mm->get_unmapped_area = arch_get_unmapped_area;
8740 } else {
8741 mm->mmap_base = mmap_base();
8742 +
8743 +#ifdef CONFIG_PAX_RANDMMAP
8744 + if (mm->pax_flags & MF_PAX_RANDMMAP)
8745 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
8746 +#endif
8747 +
8748 mm->get_unmapped_area = arch_get_unmapped_area_topdown;
8749 }
8750 }
8751 @@ -173,9 +185,21 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
8752 */
8753 if (mmap_is_legacy()) {
8754 mm->mmap_base = TASK_UNMAPPED_BASE;
8755 +
8756 +#ifdef CONFIG_PAX_RANDMMAP
8757 + if (mm->pax_flags & MF_PAX_RANDMMAP)
8758 + mm->mmap_base += mm->delta_mmap;
8759 +#endif
8760 +
8761 mm->get_unmapped_area = s390_get_unmapped_area;
8762 } else {
8763 mm->mmap_base = mmap_base();
8764 +
8765 +#ifdef CONFIG_PAX_RANDMMAP
8766 + if (mm->pax_flags & MF_PAX_RANDMMAP)
8767 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
8768 +#endif
8769 +
8770 mm->get_unmapped_area = s390_get_unmapped_area_topdown;
8771 }
8772 }
8773 diff --git a/arch/score/include/asm/cache.h b/arch/score/include/asm/cache.h
8774 index ae3d59f..f65f075 100644
8775 --- a/arch/score/include/asm/cache.h
8776 +++ b/arch/score/include/asm/cache.h
8777 @@ -1,7 +1,9 @@
8778 #ifndef _ASM_SCORE_CACHE_H
8779 #define _ASM_SCORE_CACHE_H
8780
8781 +#include <linux/const.h>
8782 +
8783 #define L1_CACHE_SHIFT 4
8784 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
8785 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
8786
8787 #endif /* _ASM_SCORE_CACHE_H */
8788 diff --git a/arch/score/include/asm/exec.h b/arch/score/include/asm/exec.h
8789 index f9f3cd5..58ff438 100644
8790 --- a/arch/score/include/asm/exec.h
8791 +++ b/arch/score/include/asm/exec.h
8792 @@ -1,6 +1,6 @@
8793 #ifndef _ASM_SCORE_EXEC_H
8794 #define _ASM_SCORE_EXEC_H
8795
8796 -extern unsigned long arch_align_stack(unsigned long sp);
8797 +#define arch_align_stack(x) (x)
8798
8799 #endif /* _ASM_SCORE_EXEC_H */
8800 diff --git a/arch/score/kernel/process.c b/arch/score/kernel/process.c
8801 index a1519ad3..e8ac1ff 100644
8802 --- a/arch/score/kernel/process.c
8803 +++ b/arch/score/kernel/process.c
8804 @@ -116,8 +116,3 @@ unsigned long get_wchan(struct task_struct *task)
8805
8806 return task_pt_regs(task)->cp0_epc;
8807 }
8808 -
8809 -unsigned long arch_align_stack(unsigned long sp)
8810 -{
8811 - return sp;
8812 -}
8813 diff --git a/arch/sh/include/asm/cache.h b/arch/sh/include/asm/cache.h
8814 index ef9e555..331bd29 100644
8815 --- a/arch/sh/include/asm/cache.h
8816 +++ b/arch/sh/include/asm/cache.h
8817 @@ -9,10 +9,11 @@
8818 #define __ASM_SH_CACHE_H
8819 #ifdef __KERNEL__
8820
8821 +#include <linux/const.h>
8822 #include <linux/init.h>
8823 #include <cpu/cache.h>
8824
8825 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
8826 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
8827
8828 #define __read_mostly __attribute__((__section__(".data..read_mostly")))
8829
8830 diff --git a/arch/sh/mm/mmap.c b/arch/sh/mm/mmap.c
8831 index 6777177..cb5e44f 100644
8832 --- a/arch/sh/mm/mmap.c
8833 +++ b/arch/sh/mm/mmap.c
8834 @@ -36,6 +36,7 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr,
8835 struct mm_struct *mm = current->mm;
8836 struct vm_area_struct *vma;
8837 int do_colour_align;
8838 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
8839 struct vm_unmapped_area_info info;
8840
8841 if (flags & MAP_FIXED) {
8842 @@ -55,6 +56,10 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr,
8843 if (filp || (flags & MAP_SHARED))
8844 do_colour_align = 1;
8845
8846 +#ifdef CONFIG_PAX_RANDMMAP
8847 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
8848 +#endif
8849 +
8850 if (addr) {
8851 if (do_colour_align)
8852 addr = COLOUR_ALIGN(addr, pgoff);
8853 @@ -62,14 +67,13 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr,
8854 addr = PAGE_ALIGN(addr);
8855
8856 vma = find_vma(mm, addr);
8857 - if (TASK_SIZE - len >= addr &&
8858 - (!vma || addr + len <= vma->vm_start))
8859 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
8860 return addr;
8861 }
8862
8863 info.flags = 0;
8864 info.length = len;
8865 - info.low_limit = TASK_UNMAPPED_BASE;
8866 + info.low_limit = mm->mmap_base;
8867 info.high_limit = TASK_SIZE;
8868 info.align_mask = do_colour_align ? (PAGE_MASK & shm_align_mask) : 0;
8869 info.align_offset = pgoff << PAGE_SHIFT;
8870 @@ -85,6 +89,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
8871 struct mm_struct *mm = current->mm;
8872 unsigned long addr = addr0;
8873 int do_colour_align;
8874 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
8875 struct vm_unmapped_area_info info;
8876
8877 if (flags & MAP_FIXED) {
8878 @@ -104,6 +109,10 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
8879 if (filp || (flags & MAP_SHARED))
8880 do_colour_align = 1;
8881
8882 +#ifdef CONFIG_PAX_RANDMMAP
8883 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
8884 +#endif
8885 +
8886 /* requesting a specific address */
8887 if (addr) {
8888 if (do_colour_align)
8889 @@ -112,8 +121,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
8890 addr = PAGE_ALIGN(addr);
8891
8892 vma = find_vma(mm, addr);
8893 - if (TASK_SIZE - len >= addr &&
8894 - (!vma || addr + len <= vma->vm_start))
8895 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
8896 return addr;
8897 }
8898
8899 @@ -135,6 +143,12 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
8900 VM_BUG_ON(addr != -ENOMEM);
8901 info.flags = 0;
8902 info.low_limit = TASK_UNMAPPED_BASE;
8903 +
8904 +#ifdef CONFIG_PAX_RANDMMAP
8905 + if (mm->pax_flags & MF_PAX_RANDMMAP)
8906 + info.low_limit += mm->delta_mmap;
8907 +#endif
8908 +
8909 info.high_limit = TASK_SIZE;
8910 addr = vm_unmapped_area(&info);
8911 }
8912 diff --git a/arch/sparc/include/asm/atomic_64.h b/arch/sparc/include/asm/atomic_64.h
8913 index be56a24..443328f 100644
8914 --- a/arch/sparc/include/asm/atomic_64.h
8915 +++ b/arch/sparc/include/asm/atomic_64.h
8916 @@ -14,18 +14,40 @@
8917 #define ATOMIC64_INIT(i) { (i) }
8918
8919 #define atomic_read(v) (*(volatile int *)&(v)->counter)
8920 +static inline int atomic_read_unchecked(const atomic_unchecked_t *v)
8921 +{
8922 + return v->counter;
8923 +}
8924 #define atomic64_read(v) (*(volatile long *)&(v)->counter)
8925 +static inline long atomic64_read_unchecked(const atomic64_unchecked_t *v)
8926 +{
8927 + return v->counter;
8928 +}
8929
8930 #define atomic_set(v, i) (((v)->counter) = i)
8931 +static inline void atomic_set_unchecked(atomic_unchecked_t *v, int i)
8932 +{
8933 + v->counter = i;
8934 +}
8935 #define atomic64_set(v, i) (((v)->counter) = i)
8936 +static inline void atomic64_set_unchecked(atomic64_unchecked_t *v, long i)
8937 +{
8938 + v->counter = i;
8939 +}
8940
8941 extern void atomic_add(int, atomic_t *);
8942 +extern void atomic_add_unchecked(int, atomic_unchecked_t *);
8943 extern void atomic64_add(long, atomic64_t *);
8944 +extern void atomic64_add_unchecked(long, atomic64_unchecked_t *);
8945 extern void atomic_sub(int, atomic_t *);
8946 +extern void atomic_sub_unchecked(int, atomic_unchecked_t *);
8947 extern void atomic64_sub(long, atomic64_t *);
8948 +extern void atomic64_sub_unchecked(long, atomic64_unchecked_t *);
8949
8950 extern int atomic_add_ret(int, atomic_t *);
8951 +extern int atomic_add_ret_unchecked(int, atomic_unchecked_t *);
8952 extern long atomic64_add_ret(long, atomic64_t *);
8953 +extern long atomic64_add_ret_unchecked(long, atomic64_unchecked_t *);
8954 extern int atomic_sub_ret(int, atomic_t *);
8955 extern long atomic64_sub_ret(long, atomic64_t *);
8956
8957 @@ -33,13 +55,29 @@ extern long atomic64_sub_ret(long, atomic64_t *);
8958 #define atomic64_dec_return(v) atomic64_sub_ret(1, v)
8959
8960 #define atomic_inc_return(v) atomic_add_ret(1, v)
8961 +static inline int atomic_inc_return_unchecked(atomic_unchecked_t *v)
8962 +{
8963 + return atomic_add_ret_unchecked(1, v);
8964 +}
8965 #define atomic64_inc_return(v) atomic64_add_ret(1, v)
8966 +static inline long atomic64_inc_return_unchecked(atomic64_unchecked_t *v)
8967 +{
8968 + return atomic64_add_ret_unchecked(1, v);
8969 +}
8970
8971 #define atomic_sub_return(i, v) atomic_sub_ret(i, v)
8972 #define atomic64_sub_return(i, v) atomic64_sub_ret(i, v)
8973
8974 #define atomic_add_return(i, v) atomic_add_ret(i, v)
8975 +static inline int atomic_add_return_unchecked(int i, atomic_unchecked_t *v)
8976 +{
8977 + return atomic_add_ret_unchecked(i, v);
8978 +}
8979 #define atomic64_add_return(i, v) atomic64_add_ret(i, v)
8980 +static inline long atomic64_add_return_unchecked(long i, atomic64_unchecked_t *v)
8981 +{
8982 + return atomic64_add_ret_unchecked(i, v);
8983 +}
8984
8985 /*
8986 * atomic_inc_and_test - increment and test
8987 @@ -50,6 +88,10 @@ extern long atomic64_sub_ret(long, atomic64_t *);
8988 * other cases.
8989 */
8990 #define atomic_inc_and_test(v) (atomic_inc_return(v) == 0)
8991 +static inline int atomic_inc_and_test_unchecked(atomic_unchecked_t *v)
8992 +{
8993 + return atomic_inc_return_unchecked(v) == 0;
8994 +}
8995 #define atomic64_inc_and_test(v) (atomic64_inc_return(v) == 0)
8996
8997 #define atomic_sub_and_test(i, v) (atomic_sub_ret(i, v) == 0)
8998 @@ -59,25 +101,60 @@ extern long atomic64_sub_ret(long, atomic64_t *);
8999 #define atomic64_dec_and_test(v) (atomic64_sub_ret(1, v) == 0)
9000
9001 #define atomic_inc(v) atomic_add(1, v)
9002 +static inline void atomic_inc_unchecked(atomic_unchecked_t *v)
9003 +{
9004 + atomic_add_unchecked(1, v);
9005 +}
9006 #define atomic64_inc(v) atomic64_add(1, v)
9007 +static inline void atomic64_inc_unchecked(atomic64_unchecked_t *v)
9008 +{
9009 + atomic64_add_unchecked(1, v);
9010 +}
9011
9012 #define atomic_dec(v) atomic_sub(1, v)
9013 +static inline void atomic_dec_unchecked(atomic_unchecked_t *v)
9014 +{
9015 + atomic_sub_unchecked(1, v);
9016 +}
9017 #define atomic64_dec(v) atomic64_sub(1, v)
9018 +static inline void atomic64_dec_unchecked(atomic64_unchecked_t *v)
9019 +{
9020 + atomic64_sub_unchecked(1, v);
9021 +}
9022
9023 #define atomic_add_negative(i, v) (atomic_add_ret(i, v) < 0)
9024 #define atomic64_add_negative(i, v) (atomic64_add_ret(i, v) < 0)
9025
9026 #define atomic_cmpxchg(v, o, n) (cmpxchg(&((v)->counter), (o), (n)))
9027 +static inline int atomic_cmpxchg_unchecked(atomic_unchecked_t *v, int old, int new)
9028 +{
9029 + return cmpxchg(&v->counter, old, new);
9030 +}
9031 #define atomic_xchg(v, new) (xchg(&((v)->counter), new))
9032 +static inline int atomic_xchg_unchecked(atomic_unchecked_t *v, int new)
9033 +{
9034 + return xchg(&v->counter, new);
9035 +}
9036
9037 static inline int __atomic_add_unless(atomic_t *v, int a, int u)
9038 {
9039 - int c, old;
9040 + int c, old, new;
9041 c = atomic_read(v);
9042 for (;;) {
9043 - if (unlikely(c == (u)))
9044 + if (unlikely(c == u))
9045 break;
9046 - old = atomic_cmpxchg((v), c, c + (a));
9047 +
9048 + asm volatile("addcc %2, %0, %0\n"
9049 +
9050 +#ifdef CONFIG_PAX_REFCOUNT
9051 + "tvs %%icc, 6\n"
9052 +#endif
9053 +
9054 + : "=r" (new)
9055 + : "0" (c), "ir" (a)
9056 + : "cc");
9057 +
9058 + old = atomic_cmpxchg(v, c, new);
9059 if (likely(old == c))
9060 break;
9061 c = old;
9062 @@ -88,20 +165,35 @@ static inline int __atomic_add_unless(atomic_t *v, int a, int u)
9063 #define atomic64_cmpxchg(v, o, n) \
9064 ((__typeof__((v)->counter))cmpxchg(&((v)->counter), (o), (n)))
9065 #define atomic64_xchg(v, new) (xchg(&((v)->counter), new))
9066 +static inline long atomic64_xchg_unchecked(atomic64_unchecked_t *v, long new)
9067 +{
9068 + return xchg(&v->counter, new);
9069 +}
9070
9071 static inline long atomic64_add_unless(atomic64_t *v, long a, long u)
9072 {
9073 - long c, old;
9074 + long c, old, new;
9075 c = atomic64_read(v);
9076 for (;;) {
9077 - if (unlikely(c == (u)))
9078 + if (unlikely(c == u))
9079 break;
9080 - old = atomic64_cmpxchg((v), c, c + (a));
9081 +
9082 + asm volatile("addcc %2, %0, %0\n"
9083 +
9084 +#ifdef CONFIG_PAX_REFCOUNT
9085 + "tvs %%xcc, 6\n"
9086 +#endif
9087 +
9088 + : "=r" (new)
9089 + : "0" (c), "ir" (a)
9090 + : "cc");
9091 +
9092 + old = atomic64_cmpxchg(v, c, new);
9093 if (likely(old == c))
9094 break;
9095 c = old;
9096 }
9097 - return c != (u);
9098 + return c != u;
9099 }
9100
9101 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1, 0)
9102 diff --git a/arch/sparc/include/asm/cache.h b/arch/sparc/include/asm/cache.h
9103 index 5bb6991..5c2132e 100644
9104 --- a/arch/sparc/include/asm/cache.h
9105 +++ b/arch/sparc/include/asm/cache.h
9106 @@ -7,10 +7,12 @@
9107 #ifndef _SPARC_CACHE_H
9108 #define _SPARC_CACHE_H
9109
9110 +#include <linux/const.h>
9111 +
9112 #define ARCH_SLAB_MINALIGN __alignof__(unsigned long long)
9113
9114 #define L1_CACHE_SHIFT 5
9115 -#define L1_CACHE_BYTES 32
9116 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
9117
9118 #ifdef CONFIG_SPARC32
9119 #define SMP_CACHE_BYTES_SHIFT 5
9120 diff --git a/arch/sparc/include/asm/elf_32.h b/arch/sparc/include/asm/elf_32.h
9121 index a24e41f..47677ff 100644
9122 --- a/arch/sparc/include/asm/elf_32.h
9123 +++ b/arch/sparc/include/asm/elf_32.h
9124 @@ -114,6 +114,13 @@ typedef struct {
9125
9126 #define ELF_ET_DYN_BASE (TASK_UNMAPPED_BASE)
9127
9128 +#ifdef CONFIG_PAX_ASLR
9129 +#define PAX_ELF_ET_DYN_BASE 0x10000UL
9130 +
9131 +#define PAX_DELTA_MMAP_LEN 16
9132 +#define PAX_DELTA_STACK_LEN 16
9133 +#endif
9134 +
9135 /* This yields a mask that user programs can use to figure out what
9136 instruction set this cpu supports. This can NOT be done in userspace
9137 on Sparc. */
9138 diff --git a/arch/sparc/include/asm/elf_64.h b/arch/sparc/include/asm/elf_64.h
9139 index 370ca1e..d4f4a98 100644
9140 --- a/arch/sparc/include/asm/elf_64.h
9141 +++ b/arch/sparc/include/asm/elf_64.h
9142 @@ -189,6 +189,13 @@ typedef struct {
9143 #define ELF_ET_DYN_BASE 0x0000010000000000UL
9144 #define COMPAT_ELF_ET_DYN_BASE 0x0000000070000000UL
9145
9146 +#ifdef CONFIG_PAX_ASLR
9147 +#define PAX_ELF_ET_DYN_BASE (test_thread_flag(TIF_32BIT) ? 0x10000UL : 0x100000UL)
9148 +
9149 +#define PAX_DELTA_MMAP_LEN (test_thread_flag(TIF_32BIT) ? 14 : 28)
9150 +#define PAX_DELTA_STACK_LEN (test_thread_flag(TIF_32BIT) ? 15 : 29)
9151 +#endif
9152 +
9153 extern unsigned long sparc64_elf_hwcap;
9154 #define ELF_HWCAP sparc64_elf_hwcap
9155
9156 diff --git a/arch/sparc/include/asm/pgalloc_32.h b/arch/sparc/include/asm/pgalloc_32.h
9157 index 9b1c36d..209298b 100644
9158 --- a/arch/sparc/include/asm/pgalloc_32.h
9159 +++ b/arch/sparc/include/asm/pgalloc_32.h
9160 @@ -33,6 +33,7 @@ static inline void pgd_set(pgd_t * pgdp, pmd_t * pmdp)
9161 }
9162
9163 #define pgd_populate(MM, PGD, PMD) pgd_set(PGD, PMD)
9164 +#define pgd_populate_kernel(MM, PGD, PMD) pgd_populate((MM), (PGD), (PMD))
9165
9166 static inline pmd_t *pmd_alloc_one(struct mm_struct *mm,
9167 unsigned long address)
9168 diff --git a/arch/sparc/include/asm/pgalloc_64.h b/arch/sparc/include/asm/pgalloc_64.h
9169 index bcfe063..b333142 100644
9170 --- a/arch/sparc/include/asm/pgalloc_64.h
9171 +++ b/arch/sparc/include/asm/pgalloc_64.h
9172 @@ -26,6 +26,7 @@ static inline void pgd_free(struct mm_struct *mm, pgd_t *pgd)
9173 }
9174
9175 #define pud_populate(MM, PUD, PMD) pud_set(PUD, PMD)
9176 +#define pud_populate_kernel(MM, PUD, PMD) pud_populate((MM), (PUD), (PMD))
9177
9178 static inline pmd_t *pmd_alloc_one(struct mm_struct *mm, unsigned long addr)
9179 {
9180 diff --git a/arch/sparc/include/asm/pgtable_32.h b/arch/sparc/include/asm/pgtable_32.h
9181 index 502f632..da1917f 100644
9182 --- a/arch/sparc/include/asm/pgtable_32.h
9183 +++ b/arch/sparc/include/asm/pgtable_32.h
9184 @@ -50,6 +50,9 @@ extern unsigned long calc_highpages(void);
9185 #define PAGE_SHARED SRMMU_PAGE_SHARED
9186 #define PAGE_COPY SRMMU_PAGE_COPY
9187 #define PAGE_READONLY SRMMU_PAGE_RDONLY
9188 +#define PAGE_SHARED_NOEXEC SRMMU_PAGE_SHARED_NOEXEC
9189 +#define PAGE_COPY_NOEXEC SRMMU_PAGE_COPY_NOEXEC
9190 +#define PAGE_READONLY_NOEXEC SRMMU_PAGE_RDONLY_NOEXEC
9191 #define PAGE_KERNEL SRMMU_PAGE_KERNEL
9192
9193 /* Top-level page directory - dummy used by init-mm.
9194 @@ -62,18 +65,18 @@ extern unsigned long ptr_in_current_pgd;
9195
9196 /* xwr */
9197 #define __P000 PAGE_NONE
9198 -#define __P001 PAGE_READONLY
9199 -#define __P010 PAGE_COPY
9200 -#define __P011 PAGE_COPY
9201 +#define __P001 PAGE_READONLY_NOEXEC
9202 +#define __P010 PAGE_COPY_NOEXEC
9203 +#define __P011 PAGE_COPY_NOEXEC
9204 #define __P100 PAGE_READONLY
9205 #define __P101 PAGE_READONLY
9206 #define __P110 PAGE_COPY
9207 #define __P111 PAGE_COPY
9208
9209 #define __S000 PAGE_NONE
9210 -#define __S001 PAGE_READONLY
9211 -#define __S010 PAGE_SHARED
9212 -#define __S011 PAGE_SHARED
9213 +#define __S001 PAGE_READONLY_NOEXEC
9214 +#define __S010 PAGE_SHARED_NOEXEC
9215 +#define __S011 PAGE_SHARED_NOEXEC
9216 #define __S100 PAGE_READONLY
9217 #define __S101 PAGE_READONLY
9218 #define __S110 PAGE_SHARED
9219 diff --git a/arch/sparc/include/asm/pgtsrmmu.h b/arch/sparc/include/asm/pgtsrmmu.h
9220 index 79da178..c2eede8 100644
9221 --- a/arch/sparc/include/asm/pgtsrmmu.h
9222 +++ b/arch/sparc/include/asm/pgtsrmmu.h
9223 @@ -115,6 +115,11 @@
9224 SRMMU_EXEC | SRMMU_REF)
9225 #define SRMMU_PAGE_RDONLY __pgprot(SRMMU_VALID | SRMMU_CACHE | \
9226 SRMMU_EXEC | SRMMU_REF)
9227 +
9228 +#define SRMMU_PAGE_SHARED_NOEXEC __pgprot(SRMMU_VALID | SRMMU_CACHE | SRMMU_WRITE | SRMMU_REF)
9229 +#define SRMMU_PAGE_COPY_NOEXEC __pgprot(SRMMU_VALID | SRMMU_CACHE | SRMMU_REF)
9230 +#define SRMMU_PAGE_RDONLY_NOEXEC __pgprot(SRMMU_VALID | SRMMU_CACHE | SRMMU_REF)
9231 +
9232 #define SRMMU_PAGE_KERNEL __pgprot(SRMMU_VALID | SRMMU_CACHE | SRMMU_PRIV | \
9233 SRMMU_DIRTY | SRMMU_REF)
9234
9235 diff --git a/arch/sparc/include/asm/spinlock_64.h b/arch/sparc/include/asm/spinlock_64.h
9236 index 9689176..63c18ea 100644
9237 --- a/arch/sparc/include/asm/spinlock_64.h
9238 +++ b/arch/sparc/include/asm/spinlock_64.h
9239 @@ -92,14 +92,19 @@ static inline void arch_spin_lock_flags(arch_spinlock_t *lock, unsigned long fla
9240
9241 /* Multi-reader locks, these are much saner than the 32-bit Sparc ones... */
9242
9243 -static void inline arch_read_lock(arch_rwlock_t *lock)
9244 +static inline void arch_read_lock(arch_rwlock_t *lock)
9245 {
9246 unsigned long tmp1, tmp2;
9247
9248 __asm__ __volatile__ (
9249 "1: ldsw [%2], %0\n"
9250 " brlz,pn %0, 2f\n"
9251 -"4: add %0, 1, %1\n"
9252 +"4: addcc %0, 1, %1\n"
9253 +
9254 +#ifdef CONFIG_PAX_REFCOUNT
9255 +" tvs %%icc, 6\n"
9256 +#endif
9257 +
9258 " cas [%2], %0, %1\n"
9259 " cmp %0, %1\n"
9260 " bne,pn %%icc, 1b\n"
9261 @@ -112,10 +117,10 @@ static void inline arch_read_lock(arch_rwlock_t *lock)
9262 " .previous"
9263 : "=&r" (tmp1), "=&r" (tmp2)
9264 : "r" (lock)
9265 - : "memory");
9266 + : "memory", "cc");
9267 }
9268
9269 -static int inline arch_read_trylock(arch_rwlock_t *lock)
9270 +static inline int arch_read_trylock(arch_rwlock_t *lock)
9271 {
9272 int tmp1, tmp2;
9273
9274 @@ -123,7 +128,12 @@ static int inline arch_read_trylock(arch_rwlock_t *lock)
9275 "1: ldsw [%2], %0\n"
9276 " brlz,a,pn %0, 2f\n"
9277 " mov 0, %0\n"
9278 -" add %0, 1, %1\n"
9279 +" addcc %0, 1, %1\n"
9280 +
9281 +#ifdef CONFIG_PAX_REFCOUNT
9282 +" tvs %%icc, 6\n"
9283 +#endif
9284 +
9285 " cas [%2], %0, %1\n"
9286 " cmp %0, %1\n"
9287 " bne,pn %%icc, 1b\n"
9288 @@ -136,13 +146,18 @@ static int inline arch_read_trylock(arch_rwlock_t *lock)
9289 return tmp1;
9290 }
9291
9292 -static void inline arch_read_unlock(arch_rwlock_t *lock)
9293 +static inline void arch_read_unlock(arch_rwlock_t *lock)
9294 {
9295 unsigned long tmp1, tmp2;
9296
9297 __asm__ __volatile__(
9298 "1: lduw [%2], %0\n"
9299 -" sub %0, 1, %1\n"
9300 +" subcc %0, 1, %1\n"
9301 +
9302 +#ifdef CONFIG_PAX_REFCOUNT
9303 +" tvs %%icc, 6\n"
9304 +#endif
9305 +
9306 " cas [%2], %0, %1\n"
9307 " cmp %0, %1\n"
9308 " bne,pn %%xcc, 1b\n"
9309 @@ -152,7 +167,7 @@ static void inline arch_read_unlock(arch_rwlock_t *lock)
9310 : "memory");
9311 }
9312
9313 -static void inline arch_write_lock(arch_rwlock_t *lock)
9314 +static inline void arch_write_lock(arch_rwlock_t *lock)
9315 {
9316 unsigned long mask, tmp1, tmp2;
9317
9318 @@ -177,7 +192,7 @@ static void inline arch_write_lock(arch_rwlock_t *lock)
9319 : "memory");
9320 }
9321
9322 -static void inline arch_write_unlock(arch_rwlock_t *lock)
9323 +static inline void arch_write_unlock(arch_rwlock_t *lock)
9324 {
9325 __asm__ __volatile__(
9326 " stw %%g0, [%0]"
9327 @@ -186,7 +201,7 @@ static void inline arch_write_unlock(arch_rwlock_t *lock)
9328 : "memory");
9329 }
9330
9331 -static int inline arch_write_trylock(arch_rwlock_t *lock)
9332 +static inline int arch_write_trylock(arch_rwlock_t *lock)
9333 {
9334 unsigned long mask, tmp1, tmp2, result;
9335
9336 diff --git a/arch/sparc/include/asm/thread_info_32.h b/arch/sparc/include/asm/thread_info_32.h
9337 index dd38075..e7cac83 100644
9338 --- a/arch/sparc/include/asm/thread_info_32.h
9339 +++ b/arch/sparc/include/asm/thread_info_32.h
9340 @@ -49,6 +49,8 @@ struct thread_info {
9341 unsigned long w_saved;
9342
9343 struct restart_block restart_block;
9344 +
9345 + unsigned long lowest_stack;
9346 };
9347
9348 /*
9349 diff --git a/arch/sparc/include/asm/thread_info_64.h b/arch/sparc/include/asm/thread_info_64.h
9350 index d5e5042..9bfee76 100644
9351 --- a/arch/sparc/include/asm/thread_info_64.h
9352 +++ b/arch/sparc/include/asm/thread_info_64.h
9353 @@ -63,6 +63,8 @@ struct thread_info {
9354 struct pt_regs *kern_una_regs;
9355 unsigned int kern_una_insn;
9356
9357 + unsigned long lowest_stack;
9358 +
9359 unsigned long fpregs[0] __attribute__ ((aligned(64)));
9360 };
9361
9362 @@ -192,10 +194,11 @@ register struct thread_info *current_thread_info_reg asm("g6");
9363 #define TIF_UNALIGNED 5 /* allowed to do unaligned accesses */
9364 /* flag bit 6 is available */
9365 #define TIF_32BIT 7 /* 32-bit binary */
9366 -/* flag bit 8 is available */
9367 +#define TIF_GRSEC_SETXID 8 /* update credentials on syscall entry/exit */
9368 #define TIF_SECCOMP 9 /* secure computing */
9369 #define TIF_SYSCALL_AUDIT 10 /* syscall auditing active */
9370 #define TIF_SYSCALL_TRACEPOINT 11 /* syscall tracepoint instrumentation */
9371 +
9372 /* NOTE: Thread flags >= 12 should be ones we have no interest
9373 * in using in assembly, else we can't use the mask as
9374 * an immediate value in instructions such as andcc.
9375 @@ -214,12 +217,18 @@ register struct thread_info *current_thread_info_reg asm("g6");
9376 #define _TIF_SYSCALL_AUDIT (1<<TIF_SYSCALL_AUDIT)
9377 #define _TIF_SYSCALL_TRACEPOINT (1<<TIF_SYSCALL_TRACEPOINT)
9378 #define _TIF_POLLING_NRFLAG (1<<TIF_POLLING_NRFLAG)
9379 +#define _TIF_GRSEC_SETXID (1<<TIF_GRSEC_SETXID)
9380
9381 #define _TIF_USER_WORK_MASK ((0xff << TI_FLAG_WSAVED_SHIFT) | \
9382 _TIF_DO_NOTIFY_RESUME_MASK | \
9383 _TIF_NEED_RESCHED)
9384 #define _TIF_DO_NOTIFY_RESUME_MASK (_TIF_NOTIFY_RESUME | _TIF_SIGPENDING)
9385
9386 +#define _TIF_WORK_SYSCALL \
9387 + (_TIF_SYSCALL_TRACE | _TIF_SECCOMP | _TIF_SYSCALL_AUDIT | \
9388 + _TIF_SYSCALL_TRACEPOINT | _TIF_GRSEC_SETXID)
9389 +
9390 +
9391 /*
9392 * Thread-synchronous status.
9393 *
9394 diff --git a/arch/sparc/include/asm/uaccess.h b/arch/sparc/include/asm/uaccess.h
9395 index 0167d26..767bb0c 100644
9396 --- a/arch/sparc/include/asm/uaccess.h
9397 +++ b/arch/sparc/include/asm/uaccess.h
9398 @@ -1,5 +1,6 @@
9399 #ifndef ___ASM_SPARC_UACCESS_H
9400 #define ___ASM_SPARC_UACCESS_H
9401 +
9402 #if defined(__sparc__) && defined(__arch64__)
9403 #include <asm/uaccess_64.h>
9404 #else
9405 diff --git a/arch/sparc/include/asm/uaccess_32.h b/arch/sparc/include/asm/uaccess_32.h
9406 index 53a28dd..50c38c3 100644
9407 --- a/arch/sparc/include/asm/uaccess_32.h
9408 +++ b/arch/sparc/include/asm/uaccess_32.h
9409 @@ -250,27 +250,46 @@ extern unsigned long __copy_user(void __user *to, const void __user *from, unsig
9410
9411 static inline unsigned long copy_to_user(void __user *to, const void *from, unsigned long n)
9412 {
9413 - if (n && __access_ok((unsigned long) to, n))
9414 + if ((long)n < 0)
9415 + return n;
9416 +
9417 + if (n && __access_ok((unsigned long) to, n)) {
9418 + if (!__builtin_constant_p(n))
9419 + check_object_size(from, n, true);
9420 return __copy_user(to, (__force void __user *) from, n);
9421 - else
9422 + } else
9423 return n;
9424 }
9425
9426 static inline unsigned long __copy_to_user(void __user *to, const void *from, unsigned long n)
9427 {
9428 + if ((long)n < 0)
9429 + return n;
9430 +
9431 + if (!__builtin_constant_p(n))
9432 + check_object_size(from, n, true);
9433 +
9434 return __copy_user(to, (__force void __user *) from, n);
9435 }
9436
9437 static inline unsigned long copy_from_user(void *to, const void __user *from, unsigned long n)
9438 {
9439 - if (n && __access_ok((unsigned long) from, n))
9440 + if ((long)n < 0)
9441 + return n;
9442 +
9443 + if (n && __access_ok((unsigned long) from, n)) {
9444 + if (!__builtin_constant_p(n))
9445 + check_object_size(to, n, false);
9446 return __copy_user((__force void __user *) to, from, n);
9447 - else
9448 + } else
9449 return n;
9450 }
9451
9452 static inline unsigned long __copy_from_user(void *to, const void __user *from, unsigned long n)
9453 {
9454 + if ((long)n < 0)
9455 + return n;
9456 +
9457 return __copy_user((__force void __user *) to, from, n);
9458 }
9459
9460 diff --git a/arch/sparc/include/asm/uaccess_64.h b/arch/sparc/include/asm/uaccess_64.h
9461 index e562d3c..191f176 100644
9462 --- a/arch/sparc/include/asm/uaccess_64.h
9463 +++ b/arch/sparc/include/asm/uaccess_64.h
9464 @@ -10,6 +10,7 @@
9465 #include <linux/compiler.h>
9466 #include <linux/string.h>
9467 #include <linux/thread_info.h>
9468 +#include <linux/kernel.h>
9469 #include <asm/asi.h>
9470 #include <asm/spitfire.h>
9471 #include <asm-generic/uaccess-unaligned.h>
9472 @@ -214,8 +215,15 @@ extern unsigned long copy_from_user_fixup(void *to, const void __user *from,
9473 static inline unsigned long __must_check
9474 copy_from_user(void *to, const void __user *from, unsigned long size)
9475 {
9476 - unsigned long ret = ___copy_from_user(to, from, size);
9477 + unsigned long ret;
9478
9479 + if ((long)size < 0 || size > INT_MAX)
9480 + return size;
9481 +
9482 + if (!__builtin_constant_p(size))
9483 + check_object_size(to, size, false);
9484 +
9485 + ret = ___copy_from_user(to, from, size);
9486 if (unlikely(ret))
9487 ret = copy_from_user_fixup(to, from, size);
9488
9489 @@ -231,8 +239,15 @@ extern unsigned long copy_to_user_fixup(void __user *to, const void *from,
9490 static inline unsigned long __must_check
9491 copy_to_user(void __user *to, const void *from, unsigned long size)
9492 {
9493 - unsigned long ret = ___copy_to_user(to, from, size);
9494 + unsigned long ret;
9495
9496 + if ((long)size < 0 || size > INT_MAX)
9497 + return size;
9498 +
9499 + if (!__builtin_constant_p(size))
9500 + check_object_size(from, size, true);
9501 +
9502 + ret = ___copy_to_user(to, from, size);
9503 if (unlikely(ret))
9504 ret = copy_to_user_fixup(to, from, size);
9505 return ret;
9506 diff --git a/arch/sparc/kernel/Makefile b/arch/sparc/kernel/Makefile
9507 index d15cc17..d0ae796 100644
9508 --- a/arch/sparc/kernel/Makefile
9509 +++ b/arch/sparc/kernel/Makefile
9510 @@ -4,7 +4,7 @@
9511 #
9512
9513 asflags-y := -ansi
9514 -ccflags-y := -Werror
9515 +#ccflags-y := -Werror
9516
9517 extra-y := head_$(BITS).o
9518
9519 diff --git a/arch/sparc/kernel/process_32.c b/arch/sparc/kernel/process_32.c
9520 index fdd819d..5af08c8 100644
9521 --- a/arch/sparc/kernel/process_32.c
9522 +++ b/arch/sparc/kernel/process_32.c
9523 @@ -116,14 +116,14 @@ void show_regs(struct pt_regs *r)
9524
9525 printk("PSR: %08lx PC: %08lx NPC: %08lx Y: %08lx %s\n",
9526 r->psr, r->pc, r->npc, r->y, print_tainted());
9527 - printk("PC: <%pS>\n", (void *) r->pc);
9528 + printk("PC: <%pA>\n", (void *) r->pc);
9529 printk("%%G: %08lx %08lx %08lx %08lx %08lx %08lx %08lx %08lx\n",
9530 r->u_regs[0], r->u_regs[1], r->u_regs[2], r->u_regs[3],
9531 r->u_regs[4], r->u_regs[5], r->u_regs[6], r->u_regs[7]);
9532 printk("%%O: %08lx %08lx %08lx %08lx %08lx %08lx %08lx %08lx\n",
9533 r->u_regs[8], r->u_regs[9], r->u_regs[10], r->u_regs[11],
9534 r->u_regs[12], r->u_regs[13], r->u_regs[14], r->u_regs[15]);
9535 - printk("RPC: <%pS>\n", (void *) r->u_regs[15]);
9536 + printk("RPC: <%pA>\n", (void *) r->u_regs[15]);
9537
9538 printk("%%L: %08lx %08lx %08lx %08lx %08lx %08lx %08lx %08lx\n",
9539 rw->locals[0], rw->locals[1], rw->locals[2], rw->locals[3],
9540 @@ -160,7 +160,7 @@ void show_stack(struct task_struct *tsk, unsigned long *_ksp)
9541 rw = (struct reg_window32 *) fp;
9542 pc = rw->ins[7];
9543 printk("[%08lx : ", pc);
9544 - printk("%pS ] ", (void *) pc);
9545 + printk("%pA ] ", (void *) pc);
9546 fp = rw->ins[6];
9547 } while (++count < 16);
9548 printk("\n");
9549 diff --git a/arch/sparc/kernel/process_64.c b/arch/sparc/kernel/process_64.c
9550 index baebab2..9cd13b1 100644
9551 --- a/arch/sparc/kernel/process_64.c
9552 +++ b/arch/sparc/kernel/process_64.c
9553 @@ -158,7 +158,7 @@ static void show_regwindow(struct pt_regs *regs)
9554 printk("i4: %016lx i5: %016lx i6: %016lx i7: %016lx\n",
9555 rwk->ins[4], rwk->ins[5], rwk->ins[6], rwk->ins[7]);
9556 if (regs->tstate & TSTATE_PRIV)
9557 - printk("I7: <%pS>\n", (void *) rwk->ins[7]);
9558 + printk("I7: <%pA>\n", (void *) rwk->ins[7]);
9559 }
9560
9561 void show_regs(struct pt_regs *regs)
9562 @@ -167,7 +167,7 @@ void show_regs(struct pt_regs *regs)
9563
9564 printk("TSTATE: %016lx TPC: %016lx TNPC: %016lx Y: %08x %s\n", regs->tstate,
9565 regs->tpc, regs->tnpc, regs->y, print_tainted());
9566 - printk("TPC: <%pS>\n", (void *) regs->tpc);
9567 + printk("TPC: <%pA>\n", (void *) regs->tpc);
9568 printk("g0: %016lx g1: %016lx g2: %016lx g3: %016lx\n",
9569 regs->u_regs[0], regs->u_regs[1], regs->u_regs[2],
9570 regs->u_regs[3]);
9571 @@ -180,7 +180,7 @@ void show_regs(struct pt_regs *regs)
9572 printk("o4: %016lx o5: %016lx sp: %016lx ret_pc: %016lx\n",
9573 regs->u_regs[12], regs->u_regs[13], regs->u_regs[14],
9574 regs->u_regs[15]);
9575 - printk("RPC: <%pS>\n", (void *) regs->u_regs[15]);
9576 + printk("RPC: <%pA>\n", (void *) regs->u_regs[15]);
9577 show_regwindow(regs);
9578 show_stack(current, (unsigned long *) regs->u_regs[UREG_FP]);
9579 }
9580 @@ -269,7 +269,7 @@ void arch_trigger_all_cpu_backtrace(void)
9581 ((tp && tp->task) ? tp->task->pid : -1));
9582
9583 if (gp->tstate & TSTATE_PRIV) {
9584 - printk(" TPC[%pS] O7[%pS] I7[%pS] RPC[%pS]\n",
9585 + printk(" TPC[%pA] O7[%pA] I7[%pA] RPC[%pA]\n",
9586 (void *) gp->tpc,
9587 (void *) gp->o7,
9588 (void *) gp->i7,
9589 diff --git a/arch/sparc/kernel/prom_common.c b/arch/sparc/kernel/prom_common.c
9590 index 79cc0d1..ec62734 100644
9591 --- a/arch/sparc/kernel/prom_common.c
9592 +++ b/arch/sparc/kernel/prom_common.c
9593 @@ -144,7 +144,7 @@ static int __init prom_common_nextprop(phandle node, char *prev, char *buf)
9594
9595 unsigned int prom_early_allocated __initdata;
9596
9597 -static struct of_pdt_ops prom_sparc_ops __initdata = {
9598 +static struct of_pdt_ops prom_sparc_ops __initconst = {
9599 .nextprop = prom_common_nextprop,
9600 .getproplen = prom_getproplen,
9601 .getproperty = prom_getproperty,
9602 diff --git a/arch/sparc/kernel/ptrace_64.c b/arch/sparc/kernel/ptrace_64.c
9603 index 773c1f2..a8bdd87 100644
9604 --- a/arch/sparc/kernel/ptrace_64.c
9605 +++ b/arch/sparc/kernel/ptrace_64.c
9606 @@ -1059,6 +1059,10 @@ long arch_ptrace(struct task_struct *child, long request,
9607 return ret;
9608 }
9609
9610 +#ifdef CONFIG_GRKERNSEC_SETXID
9611 +extern void gr_delayed_cred_worker(void);
9612 +#endif
9613 +
9614 asmlinkage int syscall_trace_enter(struct pt_regs *regs)
9615 {
9616 int ret = 0;
9617 @@ -1066,6 +1070,11 @@ asmlinkage int syscall_trace_enter(struct pt_regs *regs)
9618 /* do the secure computing check first */
9619 secure_computing_strict(regs->u_regs[UREG_G1]);
9620
9621 +#ifdef CONFIG_GRKERNSEC_SETXID
9622 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
9623 + gr_delayed_cred_worker();
9624 +#endif
9625 +
9626 if (test_thread_flag(TIF_SYSCALL_TRACE))
9627 ret = tracehook_report_syscall_entry(regs);
9628
9629 @@ -1086,6 +1095,11 @@ asmlinkage int syscall_trace_enter(struct pt_regs *regs)
9630
9631 asmlinkage void syscall_trace_leave(struct pt_regs *regs)
9632 {
9633 +#ifdef CONFIG_GRKERNSEC_SETXID
9634 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
9635 + gr_delayed_cred_worker();
9636 +#endif
9637 +
9638 audit_syscall_exit(regs);
9639
9640 if (unlikely(test_thread_flag(TIF_SYSCALL_TRACEPOINT)))
9641 diff --git a/arch/sparc/kernel/smp_64.c b/arch/sparc/kernel/smp_64.c
9642 index e142545..fd29654 100644
9643 --- a/arch/sparc/kernel/smp_64.c
9644 +++ b/arch/sparc/kernel/smp_64.c
9645 @@ -869,8 +869,8 @@ extern unsigned long xcall_flush_dcache_page_cheetah;
9646 extern unsigned long xcall_flush_dcache_page_spitfire;
9647
9648 #ifdef CONFIG_DEBUG_DCFLUSH
9649 -extern atomic_t dcpage_flushes;
9650 -extern atomic_t dcpage_flushes_xcall;
9651 +extern atomic_unchecked_t dcpage_flushes;
9652 +extern atomic_unchecked_t dcpage_flushes_xcall;
9653 #endif
9654
9655 static inline void __local_flush_dcache_page(struct page *page)
9656 @@ -894,7 +894,7 @@ void smp_flush_dcache_page_impl(struct page *page, int cpu)
9657 return;
9658
9659 #ifdef CONFIG_DEBUG_DCFLUSH
9660 - atomic_inc(&dcpage_flushes);
9661 + atomic_inc_unchecked(&dcpage_flushes);
9662 #endif
9663
9664 this_cpu = get_cpu();
9665 @@ -918,7 +918,7 @@ void smp_flush_dcache_page_impl(struct page *page, int cpu)
9666 xcall_deliver(data0, __pa(pg_addr),
9667 (u64) pg_addr, cpumask_of(cpu));
9668 #ifdef CONFIG_DEBUG_DCFLUSH
9669 - atomic_inc(&dcpage_flushes_xcall);
9670 + atomic_inc_unchecked(&dcpage_flushes_xcall);
9671 #endif
9672 }
9673 }
9674 @@ -937,7 +937,7 @@ void flush_dcache_page_all(struct mm_struct *mm, struct page *page)
9675 preempt_disable();
9676
9677 #ifdef CONFIG_DEBUG_DCFLUSH
9678 - atomic_inc(&dcpage_flushes);
9679 + atomic_inc_unchecked(&dcpage_flushes);
9680 #endif
9681 data0 = 0;
9682 pg_addr = page_address(page);
9683 @@ -954,7 +954,7 @@ void flush_dcache_page_all(struct mm_struct *mm, struct page *page)
9684 xcall_deliver(data0, __pa(pg_addr),
9685 (u64) pg_addr, cpu_online_mask);
9686 #ifdef CONFIG_DEBUG_DCFLUSH
9687 - atomic_inc(&dcpage_flushes_xcall);
9688 + atomic_inc_unchecked(&dcpage_flushes_xcall);
9689 #endif
9690 }
9691 __local_flush_dcache_page(page);
9692 diff --git a/arch/sparc/kernel/sys_sparc_32.c b/arch/sparc/kernel/sys_sparc_32.c
9693 index 3a8d184..49498a8 100644
9694 --- a/arch/sparc/kernel/sys_sparc_32.c
9695 +++ b/arch/sparc/kernel/sys_sparc_32.c
9696 @@ -52,7 +52,7 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
9697 if (len > TASK_SIZE - PAGE_SIZE)
9698 return -ENOMEM;
9699 if (!addr)
9700 - addr = TASK_UNMAPPED_BASE;
9701 + addr = current->mm->mmap_base;
9702
9703 info.flags = 0;
9704 info.length = len;
9705 diff --git a/arch/sparc/kernel/sys_sparc_64.c b/arch/sparc/kernel/sys_sparc_64.c
9706 index 51561b8..8256764 100644
9707 --- a/arch/sparc/kernel/sys_sparc_64.c
9708 +++ b/arch/sparc/kernel/sys_sparc_64.c
9709 @@ -90,13 +90,14 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
9710 struct vm_area_struct * vma;
9711 unsigned long task_size = TASK_SIZE;
9712 int do_color_align;
9713 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
9714 struct vm_unmapped_area_info info;
9715
9716 if (flags & MAP_FIXED) {
9717 /* We do not accept a shared mapping if it would violate
9718 * cache aliasing constraints.
9719 */
9720 - if ((flags & MAP_SHARED) &&
9721 + if ((filp || (flags & MAP_SHARED)) &&
9722 ((addr - (pgoff << PAGE_SHIFT)) & (SHMLBA - 1)))
9723 return -EINVAL;
9724 return addr;
9725 @@ -111,6 +112,10 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
9726 if (filp || (flags & MAP_SHARED))
9727 do_color_align = 1;
9728
9729 +#ifdef CONFIG_PAX_RANDMMAP
9730 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
9731 +#endif
9732 +
9733 if (addr) {
9734 if (do_color_align)
9735 addr = COLOR_ALIGN(addr, pgoff);
9736 @@ -118,22 +123,28 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
9737 addr = PAGE_ALIGN(addr);
9738
9739 vma = find_vma(mm, addr);
9740 - if (task_size - len >= addr &&
9741 - (!vma || addr + len <= vma->vm_start))
9742 + if (task_size - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
9743 return addr;
9744 }
9745
9746 info.flags = 0;
9747 info.length = len;
9748 - info.low_limit = TASK_UNMAPPED_BASE;
9749 + info.low_limit = mm->mmap_base;
9750 info.high_limit = min(task_size, VA_EXCLUDE_START);
9751 info.align_mask = do_color_align ? (PAGE_MASK & (SHMLBA - 1)) : 0;
9752 info.align_offset = pgoff << PAGE_SHIFT;
9753 + info.threadstack_offset = offset;
9754 addr = vm_unmapped_area(&info);
9755
9756 if ((addr & ~PAGE_MASK) && task_size > VA_EXCLUDE_END) {
9757 VM_BUG_ON(addr != -ENOMEM);
9758 info.low_limit = VA_EXCLUDE_END;
9759 +
9760 +#ifdef CONFIG_PAX_RANDMMAP
9761 + if (mm->pax_flags & MF_PAX_RANDMMAP)
9762 + info.low_limit += mm->delta_mmap;
9763 +#endif
9764 +
9765 info.high_limit = task_size;
9766 addr = vm_unmapped_area(&info);
9767 }
9768 @@ -151,6 +162,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
9769 unsigned long task_size = STACK_TOP32;
9770 unsigned long addr = addr0;
9771 int do_color_align;
9772 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
9773 struct vm_unmapped_area_info info;
9774
9775 /* This should only ever run for 32-bit processes. */
9776 @@ -160,7 +172,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
9777 /* We do not accept a shared mapping if it would violate
9778 * cache aliasing constraints.
9779 */
9780 - if ((flags & MAP_SHARED) &&
9781 + if ((filp || (flags & MAP_SHARED)) &&
9782 ((addr - (pgoff << PAGE_SHIFT)) & (SHMLBA - 1)))
9783 return -EINVAL;
9784 return addr;
9785 @@ -173,6 +185,10 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
9786 if (filp || (flags & MAP_SHARED))
9787 do_color_align = 1;
9788
9789 +#ifdef CONFIG_PAX_RANDMMAP
9790 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
9791 +#endif
9792 +
9793 /* requesting a specific address */
9794 if (addr) {
9795 if (do_color_align)
9796 @@ -181,8 +197,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
9797 addr = PAGE_ALIGN(addr);
9798
9799 vma = find_vma(mm, addr);
9800 - if (task_size - len >= addr &&
9801 - (!vma || addr + len <= vma->vm_start))
9802 + if (task_size - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
9803 return addr;
9804 }
9805
9806 @@ -192,6 +207,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
9807 info.high_limit = mm->mmap_base;
9808 info.align_mask = do_color_align ? (PAGE_MASK & (SHMLBA - 1)) : 0;
9809 info.align_offset = pgoff << PAGE_SHIFT;
9810 + info.threadstack_offset = offset;
9811 addr = vm_unmapped_area(&info);
9812
9813 /*
9814 @@ -204,6 +220,12 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
9815 VM_BUG_ON(addr != -ENOMEM);
9816 info.flags = 0;
9817 info.low_limit = TASK_UNMAPPED_BASE;
9818 +
9819 +#ifdef CONFIG_PAX_RANDMMAP
9820 + if (mm->pax_flags & MF_PAX_RANDMMAP)
9821 + info.low_limit += mm->delta_mmap;
9822 +#endif
9823 +
9824 info.high_limit = STACK_TOP32;
9825 addr = vm_unmapped_area(&info);
9826 }
9827 @@ -260,10 +282,14 @@ unsigned long get_fb_unmapped_area(struct file *filp, unsigned long orig_addr, u
9828 EXPORT_SYMBOL(get_fb_unmapped_area);
9829
9830 /* Essentially the same as PowerPC. */
9831 -static unsigned long mmap_rnd(void)
9832 +static unsigned long mmap_rnd(struct mm_struct *mm)
9833 {
9834 unsigned long rnd = 0UL;
9835
9836 +#ifdef CONFIG_PAX_RANDMMAP
9837 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
9838 +#endif
9839 +
9840 if (current->flags & PF_RANDOMIZE) {
9841 unsigned long val = get_random_int();
9842 if (test_thread_flag(TIF_32BIT))
9843 @@ -276,7 +302,7 @@ static unsigned long mmap_rnd(void)
9844
9845 void arch_pick_mmap_layout(struct mm_struct *mm)
9846 {
9847 - unsigned long random_factor = mmap_rnd();
9848 + unsigned long random_factor = mmap_rnd(mm);
9849 unsigned long gap;
9850
9851 /*
9852 @@ -289,6 +315,12 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
9853 gap == RLIM_INFINITY ||
9854 sysctl_legacy_va_layout) {
9855 mm->mmap_base = TASK_UNMAPPED_BASE + random_factor;
9856 +
9857 +#ifdef CONFIG_PAX_RANDMMAP
9858 + if (mm->pax_flags & MF_PAX_RANDMMAP)
9859 + mm->mmap_base += mm->delta_mmap;
9860 +#endif
9861 +
9862 mm->get_unmapped_area = arch_get_unmapped_area;
9863 } else {
9864 /* We know it's 32-bit */
9865 @@ -300,6 +332,12 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
9866 gap = (task_size / 6 * 5);
9867
9868 mm->mmap_base = PAGE_ALIGN(task_size - gap - random_factor);
9869 +
9870 +#ifdef CONFIG_PAX_RANDMMAP
9871 + if (mm->pax_flags & MF_PAX_RANDMMAP)
9872 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
9873 +#endif
9874 +
9875 mm->get_unmapped_area = arch_get_unmapped_area_topdown;
9876 }
9877 }
9878 diff --git a/arch/sparc/kernel/syscalls.S b/arch/sparc/kernel/syscalls.S
9879 index d950197..192f9d8 100644
9880 --- a/arch/sparc/kernel/syscalls.S
9881 +++ b/arch/sparc/kernel/syscalls.S
9882 @@ -52,7 +52,7 @@ sys32_rt_sigreturn:
9883 #endif
9884 .align 32
9885 1: ldx [%g6 + TI_FLAGS], %l5
9886 - andcc %l5, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT|_TIF_SYSCALL_TRACEPOINT), %g0
9887 + andcc %l5, _TIF_WORK_SYSCALL, %g0
9888 be,pt %icc, rtrap
9889 nop
9890 call syscall_trace_leave
9891 @@ -184,7 +184,7 @@ linux_sparc_syscall32:
9892
9893 srl %i3, 0, %o3 ! IEU0
9894 srl %i2, 0, %o2 ! IEU0 Group
9895 - andcc %l0, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT|_TIF_SYSCALL_TRACEPOINT), %g0
9896 + andcc %l0, _TIF_WORK_SYSCALL, %g0
9897 bne,pn %icc, linux_syscall_trace32 ! CTI
9898 mov %i0, %l5 ! IEU1
9899 5: call %l7 ! CTI Group brk forced
9900 @@ -207,7 +207,7 @@ linux_sparc_syscall:
9901
9902 mov %i3, %o3 ! IEU1
9903 mov %i4, %o4 ! IEU0 Group
9904 - andcc %l0, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT|_TIF_SYSCALL_TRACEPOINT), %g0
9905 + andcc %l0, _TIF_WORK_SYSCALL, %g0
9906 bne,pn %icc, linux_syscall_trace ! CTI Group
9907 mov %i0, %l5 ! IEU0
9908 2: call %l7 ! CTI Group brk forced
9909 @@ -223,7 +223,7 @@ ret_sys_call:
9910
9911 cmp %o0, -ERESTART_RESTARTBLOCK
9912 bgeu,pn %xcc, 1f
9913 - andcc %l0, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT|_TIF_SYSCALL_TRACEPOINT), %g0
9914 + andcc %l0, _TIF_WORK_SYSCALL, %g0
9915 ldx [%sp + PTREGS_OFF + PT_V9_TNPC], %l1 ! pc = npc
9916
9917 2:
9918 diff --git a/arch/sparc/kernel/traps_32.c b/arch/sparc/kernel/traps_32.c
9919 index 6629829..036032d 100644
9920 --- a/arch/sparc/kernel/traps_32.c
9921 +++ b/arch/sparc/kernel/traps_32.c
9922 @@ -44,6 +44,8 @@ static void instruction_dump(unsigned long *pc)
9923 #define __SAVE __asm__ __volatile__("save %sp, -0x40, %sp\n\t")
9924 #define __RESTORE __asm__ __volatile__("restore %g0, %g0, %g0\n\t")
9925
9926 +extern void gr_handle_kernel_exploit(void);
9927 +
9928 void die_if_kernel(char *str, struct pt_regs *regs)
9929 {
9930 static int die_counter;
9931 @@ -76,15 +78,17 @@ void die_if_kernel(char *str, struct pt_regs *regs)
9932 count++ < 30 &&
9933 (((unsigned long) rw) >= PAGE_OFFSET) &&
9934 !(((unsigned long) rw) & 0x7)) {
9935 - printk("Caller[%08lx]: %pS\n", rw->ins[7],
9936 + printk("Caller[%08lx]: %pA\n", rw->ins[7],
9937 (void *) rw->ins[7]);
9938 rw = (struct reg_window32 *)rw->ins[6];
9939 }
9940 }
9941 printk("Instruction DUMP:");
9942 instruction_dump ((unsigned long *) regs->pc);
9943 - if(regs->psr & PSR_PS)
9944 + if(regs->psr & PSR_PS) {
9945 + gr_handle_kernel_exploit();
9946 do_exit(SIGKILL);
9947 + }
9948 do_exit(SIGSEGV);
9949 }
9950
9951 diff --git a/arch/sparc/kernel/traps_64.c b/arch/sparc/kernel/traps_64.c
9952 index b3f833a..f485f80 100644
9953 --- a/arch/sparc/kernel/traps_64.c
9954 +++ b/arch/sparc/kernel/traps_64.c
9955 @@ -76,7 +76,7 @@ static void dump_tl1_traplog(struct tl1_traplog *p)
9956 i + 1,
9957 p->trapstack[i].tstate, p->trapstack[i].tpc,
9958 p->trapstack[i].tnpc, p->trapstack[i].tt);
9959 - printk("TRAPLOG: TPC<%pS>\n", (void *) p->trapstack[i].tpc);
9960 + printk("TRAPLOG: TPC<%pA>\n", (void *) p->trapstack[i].tpc);
9961 }
9962 }
9963
9964 @@ -96,6 +96,12 @@ void bad_trap(struct pt_regs *regs, long lvl)
9965
9966 lvl -= 0x100;
9967 if (regs->tstate & TSTATE_PRIV) {
9968 +
9969 +#ifdef CONFIG_PAX_REFCOUNT
9970 + if (lvl == 6)
9971 + pax_report_refcount_overflow(regs);
9972 +#endif
9973 +
9974 sprintf(buffer, "Kernel bad sw trap %lx", lvl);
9975 die_if_kernel(buffer, regs);
9976 }
9977 @@ -114,11 +120,16 @@ void bad_trap(struct pt_regs *regs, long lvl)
9978 void bad_trap_tl1(struct pt_regs *regs, long lvl)
9979 {
9980 char buffer[32];
9981 -
9982 +
9983 if (notify_die(DIE_TRAP_TL1, "bad trap tl1", regs,
9984 0, lvl, SIGTRAP) == NOTIFY_STOP)
9985 return;
9986
9987 +#ifdef CONFIG_PAX_REFCOUNT
9988 + if (lvl == 6)
9989 + pax_report_refcount_overflow(regs);
9990 +#endif
9991 +
9992 dump_tl1_traplog((struct tl1_traplog *)(regs + 1));
9993
9994 sprintf (buffer, "Bad trap %lx at tl>0", lvl);
9995 @@ -1142,7 +1153,7 @@ static void cheetah_log_errors(struct pt_regs *regs, struct cheetah_err_info *in
9996 regs->tpc, regs->tnpc, regs->u_regs[UREG_I7], regs->tstate);
9997 printk("%s" "ERROR(%d): ",
9998 (recoverable ? KERN_WARNING : KERN_CRIT), smp_processor_id());
9999 - printk("TPC<%pS>\n", (void *) regs->tpc);
10000 + printk("TPC<%pA>\n", (void *) regs->tpc);
10001 printk("%s" "ERROR(%d): M_SYND(%lx), E_SYND(%lx)%s%s\n",
10002 (recoverable ? KERN_WARNING : KERN_CRIT), smp_processor_id(),
10003 (afsr & CHAFSR_M_SYNDROME) >> CHAFSR_M_SYNDROME_SHIFT,
10004 @@ -1749,7 +1760,7 @@ void cheetah_plus_parity_error(int type, struct pt_regs *regs)
10005 smp_processor_id(),
10006 (type & 0x1) ? 'I' : 'D',
10007 regs->tpc);
10008 - printk(KERN_EMERG "TPC<%pS>\n", (void *) regs->tpc);
10009 + printk(KERN_EMERG "TPC<%pA>\n", (void *) regs->tpc);
10010 panic("Irrecoverable Cheetah+ parity error.");
10011 }
10012
10013 @@ -1757,7 +1768,7 @@ void cheetah_plus_parity_error(int type, struct pt_regs *regs)
10014 smp_processor_id(),
10015 (type & 0x1) ? 'I' : 'D',
10016 regs->tpc);
10017 - printk(KERN_WARNING "TPC<%pS>\n", (void *) regs->tpc);
10018 + printk(KERN_WARNING "TPC<%pA>\n", (void *) regs->tpc);
10019 }
10020
10021 struct sun4v_error_entry {
10022 @@ -1830,8 +1841,8 @@ struct sun4v_error_entry {
10023 /*0x38*/u64 reserved_5;
10024 };
10025
10026 -static atomic_t sun4v_resum_oflow_cnt = ATOMIC_INIT(0);
10027 -static atomic_t sun4v_nonresum_oflow_cnt = ATOMIC_INIT(0);
10028 +static atomic_unchecked_t sun4v_resum_oflow_cnt = ATOMIC_INIT(0);
10029 +static atomic_unchecked_t sun4v_nonresum_oflow_cnt = ATOMIC_INIT(0);
10030
10031 static const char *sun4v_err_type_to_str(u8 type)
10032 {
10033 @@ -1923,7 +1934,7 @@ static void sun4v_report_real_raddr(const char *pfx, struct pt_regs *regs)
10034 }
10035
10036 static void sun4v_log_error(struct pt_regs *regs, struct sun4v_error_entry *ent,
10037 - int cpu, const char *pfx, atomic_t *ocnt)
10038 + int cpu, const char *pfx, atomic_unchecked_t *ocnt)
10039 {
10040 u64 *raw_ptr = (u64 *) ent;
10041 u32 attrs;
10042 @@ -1981,8 +1992,8 @@ static void sun4v_log_error(struct pt_regs *regs, struct sun4v_error_entry *ent,
10043
10044 show_regs(regs);
10045
10046 - if ((cnt = atomic_read(ocnt)) != 0) {
10047 - atomic_set(ocnt, 0);
10048 + if ((cnt = atomic_read_unchecked(ocnt)) != 0) {
10049 + atomic_set_unchecked(ocnt, 0);
10050 wmb();
10051 printk("%s: Queue overflowed %d times.\n",
10052 pfx, cnt);
10053 @@ -2036,7 +2047,7 @@ void sun4v_resum_error(struct pt_regs *regs, unsigned long offset)
10054 */
10055 void sun4v_resum_overflow(struct pt_regs *regs)
10056 {
10057 - atomic_inc(&sun4v_resum_oflow_cnt);
10058 + atomic_inc_unchecked(&sun4v_resum_oflow_cnt);
10059 }
10060
10061 /* We run with %pil set to PIL_NORMAL_MAX and PSTATE_IE enabled in %pstate.
10062 @@ -2089,7 +2100,7 @@ void sun4v_nonresum_overflow(struct pt_regs *regs)
10063 /* XXX Actually even this can make not that much sense. Perhaps
10064 * XXX we should just pull the plug and panic directly from here?
10065 */
10066 - atomic_inc(&sun4v_nonresum_oflow_cnt);
10067 + atomic_inc_unchecked(&sun4v_nonresum_oflow_cnt);
10068 }
10069
10070 unsigned long sun4v_err_itlb_vaddr;
10071 @@ -2104,9 +2115,9 @@ void sun4v_itlb_error_report(struct pt_regs *regs, int tl)
10072
10073 printk(KERN_EMERG "SUN4V-ITLB: Error at TPC[%lx], tl %d\n",
10074 regs->tpc, tl);
10075 - printk(KERN_EMERG "SUN4V-ITLB: TPC<%pS>\n", (void *) regs->tpc);
10076 + printk(KERN_EMERG "SUN4V-ITLB: TPC<%pA>\n", (void *) regs->tpc);
10077 printk(KERN_EMERG "SUN4V-ITLB: O7[%lx]\n", regs->u_regs[UREG_I7]);
10078 - printk(KERN_EMERG "SUN4V-ITLB: O7<%pS>\n",
10079 + printk(KERN_EMERG "SUN4V-ITLB: O7<%pA>\n",
10080 (void *) regs->u_regs[UREG_I7]);
10081 printk(KERN_EMERG "SUN4V-ITLB: vaddr[%lx] ctx[%lx] "
10082 "pte[%lx] error[%lx]\n",
10083 @@ -2128,9 +2139,9 @@ void sun4v_dtlb_error_report(struct pt_regs *regs, int tl)
10084
10085 printk(KERN_EMERG "SUN4V-DTLB: Error at TPC[%lx], tl %d\n",
10086 regs->tpc, tl);
10087 - printk(KERN_EMERG "SUN4V-DTLB: TPC<%pS>\n", (void *) regs->tpc);
10088 + printk(KERN_EMERG "SUN4V-DTLB: TPC<%pA>\n", (void *) regs->tpc);
10089 printk(KERN_EMERG "SUN4V-DTLB: O7[%lx]\n", regs->u_regs[UREG_I7]);
10090 - printk(KERN_EMERG "SUN4V-DTLB: O7<%pS>\n",
10091 + printk(KERN_EMERG "SUN4V-DTLB: O7<%pA>\n",
10092 (void *) regs->u_regs[UREG_I7]);
10093 printk(KERN_EMERG "SUN4V-DTLB: vaddr[%lx] ctx[%lx] "
10094 "pte[%lx] error[%lx]\n",
10095 @@ -2336,13 +2347,13 @@ void show_stack(struct task_struct *tsk, unsigned long *_ksp)
10096 fp = (unsigned long)sf->fp + STACK_BIAS;
10097 }
10098
10099 - printk(" [%016lx] %pS\n", pc, (void *) pc);
10100 + printk(" [%016lx] %pA\n", pc, (void *) pc);
10101 #ifdef CONFIG_FUNCTION_GRAPH_TRACER
10102 if ((pc + 8UL) == (unsigned long) &return_to_handler) {
10103 int index = tsk->curr_ret_stack;
10104 if (tsk->ret_stack && index >= graph) {
10105 pc = tsk->ret_stack[index - graph].ret;
10106 - printk(" [%016lx] %pS\n", pc, (void *) pc);
10107 + printk(" [%016lx] %pA\n", pc, (void *) pc);
10108 graph++;
10109 }
10110 }
10111 @@ -2360,6 +2371,8 @@ static inline struct reg_window *kernel_stack_up(struct reg_window *rw)
10112 return (struct reg_window *) (fp + STACK_BIAS);
10113 }
10114
10115 +extern void gr_handle_kernel_exploit(void);
10116 +
10117 void die_if_kernel(char *str, struct pt_regs *regs)
10118 {
10119 static int die_counter;
10120 @@ -2388,7 +2401,7 @@ void die_if_kernel(char *str, struct pt_regs *regs)
10121 while (rw &&
10122 count++ < 30 &&
10123 kstack_valid(tp, (unsigned long) rw)) {
10124 - printk("Caller[%016lx]: %pS\n", rw->ins[7],
10125 + printk("Caller[%016lx]: %pA\n", rw->ins[7],
10126 (void *) rw->ins[7]);
10127
10128 rw = kernel_stack_up(rw);
10129 @@ -2401,8 +2414,10 @@ void die_if_kernel(char *str, struct pt_regs *regs)
10130 }
10131 user_instruction_dump ((unsigned int __user *) regs->tpc);
10132 }
10133 - if (regs->tstate & TSTATE_PRIV)
10134 + if (regs->tstate & TSTATE_PRIV) {
10135 + gr_handle_kernel_exploit();
10136 do_exit(SIGKILL);
10137 + }
10138 do_exit(SIGSEGV);
10139 }
10140 EXPORT_SYMBOL(die_if_kernel);
10141 diff --git a/arch/sparc/kernel/unaligned_64.c b/arch/sparc/kernel/unaligned_64.c
10142 index 8201c25e..072a2a7 100644
10143 --- a/arch/sparc/kernel/unaligned_64.c
10144 +++ b/arch/sparc/kernel/unaligned_64.c
10145 @@ -286,7 +286,7 @@ static void log_unaligned(struct pt_regs *regs)
10146 static DEFINE_RATELIMIT_STATE(ratelimit, 5 * HZ, 5);
10147
10148 if (__ratelimit(&ratelimit)) {
10149 - printk("Kernel unaligned access at TPC[%lx] %pS\n",
10150 + printk("Kernel unaligned access at TPC[%lx] %pA\n",
10151 regs->tpc, (void *) regs->tpc);
10152 }
10153 }
10154 diff --git a/arch/sparc/lib/Makefile b/arch/sparc/lib/Makefile
10155 index dbe119b..089c7c1 100644
10156 --- a/arch/sparc/lib/Makefile
10157 +++ b/arch/sparc/lib/Makefile
10158 @@ -2,7 +2,7 @@
10159 #
10160
10161 asflags-y := -ansi -DST_DIV0=0x02
10162 -ccflags-y := -Werror
10163 +#ccflags-y := -Werror
10164
10165 lib-$(CONFIG_SPARC32) += ashrdi3.o
10166 lib-$(CONFIG_SPARC32) += memcpy.o memset.o
10167 diff --git a/arch/sparc/lib/atomic_64.S b/arch/sparc/lib/atomic_64.S
10168 index 85c233d..68500e0 100644
10169 --- a/arch/sparc/lib/atomic_64.S
10170 +++ b/arch/sparc/lib/atomic_64.S
10171 @@ -17,7 +17,12 @@
10172 ENTRY(atomic_add) /* %o0 = increment, %o1 = atomic_ptr */
10173 BACKOFF_SETUP(%o2)
10174 1: lduw [%o1], %g1
10175 - add %g1, %o0, %g7
10176 + addcc %g1, %o0, %g7
10177 +
10178 +#ifdef CONFIG_PAX_REFCOUNT
10179 + tvs %icc, 6
10180 +#endif
10181 +
10182 cas [%o1], %g1, %g7
10183 cmp %g1, %g7
10184 bne,pn %icc, BACKOFF_LABEL(2f, 1b)
10185 @@ -27,10 +32,28 @@ ENTRY(atomic_add) /* %o0 = increment, %o1 = atomic_ptr */
10186 2: BACKOFF_SPIN(%o2, %o3, 1b)
10187 ENDPROC(atomic_add)
10188
10189 +ENTRY(atomic_add_unchecked) /* %o0 = increment, %o1 = atomic_ptr */
10190 + BACKOFF_SETUP(%o2)
10191 +1: lduw [%o1], %g1
10192 + add %g1, %o0, %g7
10193 + cas [%o1], %g1, %g7
10194 + cmp %g1, %g7
10195 + bne,pn %icc, 2f
10196 + nop
10197 + retl
10198 + nop
10199 +2: BACKOFF_SPIN(%o2, %o3, 1b)
10200 +ENDPROC(atomic_add_unchecked)
10201 +
10202 ENTRY(atomic_sub) /* %o0 = decrement, %o1 = atomic_ptr */
10203 BACKOFF_SETUP(%o2)
10204 1: lduw [%o1], %g1
10205 - sub %g1, %o0, %g7
10206 + subcc %g1, %o0, %g7
10207 +
10208 +#ifdef CONFIG_PAX_REFCOUNT
10209 + tvs %icc, 6
10210 +#endif
10211 +
10212 cas [%o1], %g1, %g7
10213 cmp %g1, %g7
10214 bne,pn %icc, BACKOFF_LABEL(2f, 1b)
10215 @@ -40,10 +63,28 @@ ENTRY(atomic_sub) /* %o0 = decrement, %o1 = atomic_ptr */
10216 2: BACKOFF_SPIN(%o2, %o3, 1b)
10217 ENDPROC(atomic_sub)
10218
10219 +ENTRY(atomic_sub_unchecked) /* %o0 = decrement, %o1 = atomic_ptr */
10220 + BACKOFF_SETUP(%o2)
10221 +1: lduw [%o1], %g1
10222 + sub %g1, %o0, %g7
10223 + cas [%o1], %g1, %g7
10224 + cmp %g1, %g7
10225 + bne,pn %icc, 2f
10226 + nop
10227 + retl
10228 + nop
10229 +2: BACKOFF_SPIN(%o2, %o3, 1b)
10230 +ENDPROC(atomic_sub_unchecked)
10231 +
10232 ENTRY(atomic_add_ret) /* %o0 = increment, %o1 = atomic_ptr */
10233 BACKOFF_SETUP(%o2)
10234 1: lduw [%o1], %g1
10235 - add %g1, %o0, %g7
10236 + addcc %g1, %o0, %g7
10237 +
10238 +#ifdef CONFIG_PAX_REFCOUNT
10239 + tvs %icc, 6
10240 +#endif
10241 +
10242 cas [%o1], %g1, %g7
10243 cmp %g1, %g7
10244 bne,pn %icc, BACKOFF_LABEL(2f, 1b)
10245 @@ -53,10 +94,29 @@ ENTRY(atomic_add_ret) /* %o0 = increment, %o1 = atomic_ptr */
10246 2: BACKOFF_SPIN(%o2, %o3, 1b)
10247 ENDPROC(atomic_add_ret)
10248
10249 +ENTRY(atomic_add_ret_unchecked) /* %o0 = increment, %o1 = atomic_ptr */
10250 + BACKOFF_SETUP(%o2)
10251 +1: lduw [%o1], %g1
10252 + addcc %g1, %o0, %g7
10253 + cas [%o1], %g1, %g7
10254 + cmp %g1, %g7
10255 + bne,pn %icc, 2f
10256 + add %g7, %o0, %g7
10257 + sra %g7, 0, %o0
10258 + retl
10259 + nop
10260 +2: BACKOFF_SPIN(%o2, %o3, 1b)
10261 +ENDPROC(atomic_add_ret_unchecked)
10262 +
10263 ENTRY(atomic_sub_ret) /* %o0 = decrement, %o1 = atomic_ptr */
10264 BACKOFF_SETUP(%o2)
10265 1: lduw [%o1], %g1
10266 - sub %g1, %o0, %g7
10267 + subcc %g1, %o0, %g7
10268 +
10269 +#ifdef CONFIG_PAX_REFCOUNT
10270 + tvs %icc, 6
10271 +#endif
10272 +
10273 cas [%o1], %g1, %g7
10274 cmp %g1, %g7
10275 bne,pn %icc, BACKOFF_LABEL(2f, 1b)
10276 @@ -69,7 +129,12 @@ ENDPROC(atomic_sub_ret)
10277 ENTRY(atomic64_add) /* %o0 = increment, %o1 = atomic_ptr */
10278 BACKOFF_SETUP(%o2)
10279 1: ldx [%o1], %g1
10280 - add %g1, %o0, %g7
10281 + addcc %g1, %o0, %g7
10282 +
10283 +#ifdef CONFIG_PAX_REFCOUNT
10284 + tvs %xcc, 6
10285 +#endif
10286 +
10287 casx [%o1], %g1, %g7
10288 cmp %g1, %g7
10289 bne,pn %xcc, BACKOFF_LABEL(2f, 1b)
10290 @@ -79,10 +144,28 @@ ENTRY(atomic64_add) /* %o0 = increment, %o1 = atomic_ptr */
10291 2: BACKOFF_SPIN(%o2, %o3, 1b)
10292 ENDPROC(atomic64_add)
10293
10294 +ENTRY(atomic64_add_unchecked) /* %o0 = increment, %o1 = atomic_ptr */
10295 + BACKOFF_SETUP(%o2)
10296 +1: ldx [%o1], %g1
10297 + addcc %g1, %o0, %g7
10298 + casx [%o1], %g1, %g7
10299 + cmp %g1, %g7
10300 + bne,pn %xcc, 2f
10301 + nop
10302 + retl
10303 + nop
10304 +2: BACKOFF_SPIN(%o2, %o3, 1b)
10305 +ENDPROC(atomic64_add_unchecked)
10306 +
10307 ENTRY(atomic64_sub) /* %o0 = decrement, %o1 = atomic_ptr */
10308 BACKOFF_SETUP(%o2)
10309 1: ldx [%o1], %g1
10310 - sub %g1, %o0, %g7
10311 + subcc %g1, %o0, %g7
10312 +
10313 +#ifdef CONFIG_PAX_REFCOUNT
10314 + tvs %xcc, 6
10315 +#endif
10316 +
10317 casx [%o1], %g1, %g7
10318 cmp %g1, %g7
10319 bne,pn %xcc, BACKOFF_LABEL(2f, 1b)
10320 @@ -92,10 +175,28 @@ ENTRY(atomic64_sub) /* %o0 = decrement, %o1 = atomic_ptr */
10321 2: BACKOFF_SPIN(%o2, %o3, 1b)
10322 ENDPROC(atomic64_sub)
10323
10324 +ENTRY(atomic64_sub_unchecked) /* %o0 = decrement, %o1 = atomic_ptr */
10325 + BACKOFF_SETUP(%o2)
10326 +1: ldx [%o1], %g1
10327 + subcc %g1, %o0, %g7
10328 + casx [%o1], %g1, %g7
10329 + cmp %g1, %g7
10330 + bne,pn %xcc, 2f
10331 + nop
10332 + retl
10333 + nop
10334 +2: BACKOFF_SPIN(%o2, %o3, 1b)
10335 +ENDPROC(atomic64_sub_unchecked)
10336 +
10337 ENTRY(atomic64_add_ret) /* %o0 = increment, %o1 = atomic_ptr */
10338 BACKOFF_SETUP(%o2)
10339 1: ldx [%o1], %g1
10340 - add %g1, %o0, %g7
10341 + addcc %g1, %o0, %g7
10342 +
10343 +#ifdef CONFIG_PAX_REFCOUNT
10344 + tvs %xcc, 6
10345 +#endif
10346 +
10347 casx [%o1], %g1, %g7
10348 cmp %g1, %g7
10349 bne,pn %xcc, BACKOFF_LABEL(2f, 1b)
10350 @@ -105,10 +206,29 @@ ENTRY(atomic64_add_ret) /* %o0 = increment, %o1 = atomic_ptr */
10351 2: BACKOFF_SPIN(%o2, %o3, 1b)
10352 ENDPROC(atomic64_add_ret)
10353
10354 +ENTRY(atomic64_add_ret_unchecked) /* %o0 = increment, %o1 = atomic_ptr */
10355 + BACKOFF_SETUP(%o2)
10356 +1: ldx [%o1], %g1
10357 + addcc %g1, %o0, %g7
10358 + casx [%o1], %g1, %g7
10359 + cmp %g1, %g7
10360 + bne,pn %xcc, 2f
10361 + add %g7, %o0, %g7
10362 + mov %g7, %o0
10363 + retl
10364 + nop
10365 +2: BACKOFF_SPIN(%o2, %o3, 1b)
10366 +ENDPROC(atomic64_add_ret_unchecked)
10367 +
10368 ENTRY(atomic64_sub_ret) /* %o0 = decrement, %o1 = atomic_ptr */
10369 BACKOFF_SETUP(%o2)
10370 1: ldx [%o1], %g1
10371 - sub %g1, %o0, %g7
10372 + subcc %g1, %o0, %g7
10373 +
10374 +#ifdef CONFIG_PAX_REFCOUNT
10375 + tvs %xcc, 6
10376 +#endif
10377 +
10378 casx [%o1], %g1, %g7
10379 cmp %g1, %g7
10380 bne,pn %xcc, BACKOFF_LABEL(2f, 1b)
10381 diff --git a/arch/sparc/lib/ksyms.c b/arch/sparc/lib/ksyms.c
10382 index 323335b..ed85ea2 100644
10383 --- a/arch/sparc/lib/ksyms.c
10384 +++ b/arch/sparc/lib/ksyms.c
10385 @@ -100,12 +100,18 @@ EXPORT_SYMBOL(__clear_user);
10386
10387 /* Atomic counter implementation. */
10388 EXPORT_SYMBOL(atomic_add);
10389 +EXPORT_SYMBOL(atomic_add_unchecked);
10390 EXPORT_SYMBOL(atomic_add_ret);
10391 +EXPORT_SYMBOL(atomic_add_ret_unchecked);
10392 EXPORT_SYMBOL(atomic_sub);
10393 +EXPORT_SYMBOL(atomic_sub_unchecked);
10394 EXPORT_SYMBOL(atomic_sub_ret);
10395 EXPORT_SYMBOL(atomic64_add);
10396 +EXPORT_SYMBOL(atomic64_add_unchecked);
10397 EXPORT_SYMBOL(atomic64_add_ret);
10398 +EXPORT_SYMBOL(atomic64_add_ret_unchecked);
10399 EXPORT_SYMBOL(atomic64_sub);
10400 +EXPORT_SYMBOL(atomic64_sub_unchecked);
10401 EXPORT_SYMBOL(atomic64_sub_ret);
10402 EXPORT_SYMBOL(atomic64_dec_if_positive);
10403
10404 diff --git a/arch/sparc/mm/Makefile b/arch/sparc/mm/Makefile
10405 index 30c3ecc..736f015 100644
10406 --- a/arch/sparc/mm/Makefile
10407 +++ b/arch/sparc/mm/Makefile
10408 @@ -2,7 +2,7 @@
10409 #
10410
10411 asflags-y := -ansi
10412 -ccflags-y := -Werror
10413 +#ccflags-y := -Werror
10414
10415 obj-$(CONFIG_SPARC64) += ultra.o tlb.o tsb.o gup.o
10416 obj-y += fault_$(BITS).o
10417 diff --git a/arch/sparc/mm/fault_32.c b/arch/sparc/mm/fault_32.c
10418 index 59dbd46..1dd7f5e 100644
10419 --- a/arch/sparc/mm/fault_32.c
10420 +++ b/arch/sparc/mm/fault_32.c
10421 @@ -21,6 +21,9 @@
10422 #include <linux/perf_event.h>
10423 #include <linux/interrupt.h>
10424 #include <linux/kdebug.h>
10425 +#include <linux/slab.h>
10426 +#include <linux/pagemap.h>
10427 +#include <linux/compiler.h>
10428
10429 #include <asm/page.h>
10430 #include <asm/pgtable.h>
10431 @@ -159,6 +162,277 @@ static unsigned long compute_si_addr(struct pt_regs *regs, int text_fault)
10432 return safe_compute_effective_address(regs, insn);
10433 }
10434
10435 +#ifdef CONFIG_PAX_PAGEEXEC
10436 +#ifdef CONFIG_PAX_DLRESOLVE
10437 +static void pax_emuplt_close(struct vm_area_struct *vma)
10438 +{
10439 + vma->vm_mm->call_dl_resolve = 0UL;
10440 +}
10441 +
10442 +static int pax_emuplt_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
10443 +{
10444 + unsigned int *kaddr;
10445 +
10446 + vmf->page = alloc_page(GFP_HIGHUSER);
10447 + if (!vmf->page)
10448 + return VM_FAULT_OOM;
10449 +
10450 + kaddr = kmap(vmf->page);
10451 + memset(kaddr, 0, PAGE_SIZE);
10452 + kaddr[0] = 0x9DE3BFA8U; /* save */
10453 + flush_dcache_page(vmf->page);
10454 + kunmap(vmf->page);
10455 + return VM_FAULT_MAJOR;
10456 +}
10457 +
10458 +static const struct vm_operations_struct pax_vm_ops = {
10459 + .close = pax_emuplt_close,
10460 + .fault = pax_emuplt_fault
10461 +};
10462 +
10463 +static int pax_insert_vma(struct vm_area_struct *vma, unsigned long addr)
10464 +{
10465 + int ret;
10466 +
10467 + INIT_LIST_HEAD(&vma->anon_vma_chain);
10468 + vma->vm_mm = current->mm;
10469 + vma->vm_start = addr;
10470 + vma->vm_end = addr + PAGE_SIZE;
10471 + vma->vm_flags = VM_READ | VM_EXEC | VM_MAYREAD | VM_MAYEXEC;
10472 + vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
10473 + vma->vm_ops = &pax_vm_ops;
10474 +
10475 + ret = insert_vm_struct(current->mm, vma);
10476 + if (ret)
10477 + return ret;
10478 +
10479 + ++current->mm->total_vm;
10480 + return 0;
10481 +}
10482 +#endif
10483 +
10484 +/*
10485 + * PaX: decide what to do with offenders (regs->pc = fault address)
10486 + *
10487 + * returns 1 when task should be killed
10488 + * 2 when patched PLT trampoline was detected
10489 + * 3 when unpatched PLT trampoline was detected
10490 + */
10491 +static int pax_handle_fetch_fault(struct pt_regs *regs)
10492 +{
10493 +
10494 +#ifdef CONFIG_PAX_EMUPLT
10495 + int err;
10496 +
10497 + do { /* PaX: patched PLT emulation #1 */
10498 + unsigned int sethi1, sethi2, jmpl;
10499 +
10500 + err = get_user(sethi1, (unsigned int *)regs->pc);
10501 + err |= get_user(sethi2, (unsigned int *)(regs->pc+4));
10502 + err |= get_user(jmpl, (unsigned int *)(regs->pc+8));
10503 +
10504 + if (err)
10505 + break;
10506 +
10507 + if ((sethi1 & 0xFFC00000U) == 0x03000000U &&
10508 + (sethi2 & 0xFFC00000U) == 0x03000000U &&
10509 + (jmpl & 0xFFFFE000U) == 0x81C06000U)
10510 + {
10511 + unsigned int addr;
10512 +
10513 + regs->u_regs[UREG_G1] = (sethi2 & 0x003FFFFFU) << 10;
10514 + addr = regs->u_regs[UREG_G1];
10515 + addr += (((jmpl | 0xFFFFE000U) ^ 0x00001000U) + 0x00001000U);
10516 + regs->pc = addr;
10517 + regs->npc = addr+4;
10518 + return 2;
10519 + }
10520 + } while (0);
10521 +
10522 + do { /* PaX: patched PLT emulation #2 */
10523 + unsigned int ba;
10524 +
10525 + err = get_user(ba, (unsigned int *)regs->pc);
10526 +
10527 + if (err)
10528 + break;
10529 +
10530 + if ((ba & 0xFFC00000U) == 0x30800000U || (ba & 0xFFF80000U) == 0x30480000U) {
10531 + unsigned int addr;
10532 +
10533 + if ((ba & 0xFFC00000U) == 0x30800000U)
10534 + addr = regs->pc + ((((ba | 0xFFC00000U) ^ 0x00200000U) + 0x00200000U) << 2);
10535 + else
10536 + addr = regs->pc + ((((ba | 0xFFF80000U) ^ 0x00040000U) + 0x00040000U) << 2);
10537 + regs->pc = addr;
10538 + regs->npc = addr+4;
10539 + return 2;
10540 + }
10541 + } while (0);
10542 +
10543 + do { /* PaX: patched PLT emulation #3 */
10544 + unsigned int sethi, bajmpl, nop;
10545 +
10546 + err = get_user(sethi, (unsigned int *)regs->pc);
10547 + err |= get_user(bajmpl, (unsigned int *)(regs->pc+4));
10548 + err |= get_user(nop, (unsigned int *)(regs->pc+8));
10549 +
10550 + if (err)
10551 + break;
10552 +
10553 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
10554 + ((bajmpl & 0xFFFFE000U) == 0x81C06000U || (bajmpl & 0xFFF80000U) == 0x30480000U) &&
10555 + nop == 0x01000000U)
10556 + {
10557 + unsigned int addr;
10558 +
10559 + addr = (sethi & 0x003FFFFFU) << 10;
10560 + regs->u_regs[UREG_G1] = addr;
10561 + if ((bajmpl & 0xFFFFE000U) == 0x81C06000U)
10562 + addr += (((bajmpl | 0xFFFFE000U) ^ 0x00001000U) + 0x00001000U);
10563 + else
10564 + addr = regs->pc + ((((bajmpl | 0xFFF80000U) ^ 0x00040000U) + 0x00040000U) << 2);
10565 + regs->pc = addr;
10566 + regs->npc = addr+4;
10567 + return 2;
10568 + }
10569 + } while (0);
10570 +
10571 + do { /* PaX: unpatched PLT emulation step 1 */
10572 + unsigned int sethi, ba, nop;
10573 +
10574 + err = get_user(sethi, (unsigned int *)regs->pc);
10575 + err |= get_user(ba, (unsigned int *)(regs->pc+4));
10576 + err |= get_user(nop, (unsigned int *)(regs->pc+8));
10577 +
10578 + if (err)
10579 + break;
10580 +
10581 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
10582 + ((ba & 0xFFC00000U) == 0x30800000U || (ba & 0xFFF80000U) == 0x30680000U) &&
10583 + nop == 0x01000000U)
10584 + {
10585 + unsigned int addr, save, call;
10586 +
10587 + if ((ba & 0xFFC00000U) == 0x30800000U)
10588 + addr = regs->pc + 4 + ((((ba | 0xFFC00000U) ^ 0x00200000U) + 0x00200000U) << 2);
10589 + else
10590 + addr = regs->pc + 4 + ((((ba | 0xFFF80000U) ^ 0x00040000U) + 0x00040000U) << 2);
10591 +
10592 + err = get_user(save, (unsigned int *)addr);
10593 + err |= get_user(call, (unsigned int *)(addr+4));
10594 + err |= get_user(nop, (unsigned int *)(addr+8));
10595 + if (err)
10596 + break;
10597 +
10598 +#ifdef CONFIG_PAX_DLRESOLVE
10599 + if (save == 0x9DE3BFA8U &&
10600 + (call & 0xC0000000U) == 0x40000000U &&
10601 + nop == 0x01000000U)
10602 + {
10603 + struct vm_area_struct *vma;
10604 + unsigned long call_dl_resolve;
10605 +
10606 + down_read(&current->mm->mmap_sem);
10607 + call_dl_resolve = current->mm->call_dl_resolve;
10608 + up_read(&current->mm->mmap_sem);
10609 + if (likely(call_dl_resolve))
10610 + goto emulate;
10611 +
10612 + vma = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
10613 +
10614 + down_write(&current->mm->mmap_sem);
10615 + if (current->mm->call_dl_resolve) {
10616 + call_dl_resolve = current->mm->call_dl_resolve;
10617 + up_write(&current->mm->mmap_sem);
10618 + if (vma)
10619 + kmem_cache_free(vm_area_cachep, vma);
10620 + goto emulate;
10621 + }
10622 +
10623 + call_dl_resolve = get_unmapped_area(NULL, 0UL, PAGE_SIZE, 0UL, MAP_PRIVATE);
10624 + if (!vma || (call_dl_resolve & ~PAGE_MASK)) {
10625 + up_write(&current->mm->mmap_sem);
10626 + if (vma)
10627 + kmem_cache_free(vm_area_cachep, vma);
10628 + return 1;
10629 + }
10630 +
10631 + if (pax_insert_vma(vma, call_dl_resolve)) {
10632 + up_write(&current->mm->mmap_sem);
10633 + kmem_cache_free(vm_area_cachep, vma);
10634 + return 1;
10635 + }
10636 +
10637 + current->mm->call_dl_resolve = call_dl_resolve;
10638 + up_write(&current->mm->mmap_sem);
10639 +
10640 +emulate:
10641 + regs->u_regs[UREG_G1] = (sethi & 0x003FFFFFU) << 10;
10642 + regs->pc = call_dl_resolve;
10643 + regs->npc = addr+4;
10644 + return 3;
10645 + }
10646 +#endif
10647 +
10648 + /* PaX: glibc 2.4+ generates sethi/jmpl instead of save/call */
10649 + if ((save & 0xFFC00000U) == 0x05000000U &&
10650 + (call & 0xFFFFE000U) == 0x85C0A000U &&
10651 + nop == 0x01000000U)
10652 + {
10653 + regs->u_regs[UREG_G1] = (sethi & 0x003FFFFFU) << 10;
10654 + regs->u_regs[UREG_G2] = addr + 4;
10655 + addr = (save & 0x003FFFFFU) << 10;
10656 + addr += (((call | 0xFFFFE000U) ^ 0x00001000U) + 0x00001000U);
10657 + regs->pc = addr;
10658 + regs->npc = addr+4;
10659 + return 3;
10660 + }
10661 + }
10662 + } while (0);
10663 +
10664 + do { /* PaX: unpatched PLT emulation step 2 */
10665 + unsigned int save, call, nop;
10666 +
10667 + err = get_user(save, (unsigned int *)(regs->pc-4));
10668 + err |= get_user(call, (unsigned int *)regs->pc);
10669 + err |= get_user(nop, (unsigned int *)(regs->pc+4));
10670 + if (err)
10671 + break;
10672 +
10673 + if (save == 0x9DE3BFA8U &&
10674 + (call & 0xC0000000U) == 0x40000000U &&
10675 + nop == 0x01000000U)
10676 + {
10677 + unsigned int dl_resolve = regs->pc + ((((call | 0xC0000000U) ^ 0x20000000U) + 0x20000000U) << 2);
10678 +
10679 + regs->u_regs[UREG_RETPC] = regs->pc;
10680 + regs->pc = dl_resolve;
10681 + regs->npc = dl_resolve+4;
10682 + return 3;
10683 + }
10684 + } while (0);
10685 +#endif
10686 +
10687 + return 1;
10688 +}
10689 +
10690 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
10691 +{
10692 + unsigned long i;
10693 +
10694 + printk(KERN_ERR "PAX: bytes at PC: ");
10695 + for (i = 0; i < 8; i++) {
10696 + unsigned int c;
10697 + if (get_user(c, (unsigned int *)pc+i))
10698 + printk(KERN_CONT "???????? ");
10699 + else
10700 + printk(KERN_CONT "%08x ", c);
10701 + }
10702 + printk("\n");
10703 +}
10704 +#endif
10705 +
10706 static noinline void do_fault_siginfo(int code, int sig, struct pt_regs *regs,
10707 int text_fault)
10708 {
10709 @@ -229,6 +503,24 @@ good_area:
10710 if (!(vma->vm_flags & VM_WRITE))
10711 goto bad_area;
10712 } else {
10713 +
10714 +#ifdef CONFIG_PAX_PAGEEXEC
10715 + if ((mm->pax_flags & MF_PAX_PAGEEXEC) && text_fault && !(vma->vm_flags & VM_EXEC)) {
10716 + up_read(&mm->mmap_sem);
10717 + switch (pax_handle_fetch_fault(regs)) {
10718 +
10719 +#ifdef CONFIG_PAX_EMUPLT
10720 + case 2:
10721 + case 3:
10722 + return;
10723 +#endif
10724 +
10725 + }
10726 + pax_report_fault(regs, (void *)regs->pc, (void *)regs->u_regs[UREG_FP]);
10727 + do_group_exit(SIGKILL);
10728 + }
10729 +#endif
10730 +
10731 /* Allow reads even for write-only mappings */
10732 if (!(vma->vm_flags & (VM_READ | VM_EXEC)))
10733 goto bad_area;
10734 diff --git a/arch/sparc/mm/fault_64.c b/arch/sparc/mm/fault_64.c
10735 index 2ebec26..b212598 100644
10736 --- a/arch/sparc/mm/fault_64.c
10737 +++ b/arch/sparc/mm/fault_64.c
10738 @@ -21,6 +21,9 @@
10739 #include <linux/kprobes.h>
10740 #include <linux/kdebug.h>
10741 #include <linux/percpu.h>
10742 +#include <linux/slab.h>
10743 +#include <linux/pagemap.h>
10744 +#include <linux/compiler.h>
10745
10746 #include <asm/page.h>
10747 #include <asm/pgtable.h>
10748 @@ -74,7 +77,7 @@ static void __kprobes bad_kernel_pc(struct pt_regs *regs, unsigned long vaddr)
10749 printk(KERN_CRIT "OOPS: Bogus kernel PC [%016lx] in fault handler\n",
10750 regs->tpc);
10751 printk(KERN_CRIT "OOPS: RPC [%016lx]\n", regs->u_regs[15]);
10752 - printk("OOPS: RPC <%pS>\n", (void *) regs->u_regs[15]);
10753 + printk("OOPS: RPC <%pA>\n", (void *) regs->u_regs[15]);
10754 printk(KERN_CRIT "OOPS: Fault was to vaddr[%lx]\n", vaddr);
10755 dump_stack();
10756 unhandled_fault(regs->tpc, current, regs);
10757 @@ -270,6 +273,466 @@ static void noinline __kprobes bogus_32bit_fault_address(struct pt_regs *regs,
10758 show_regs(regs);
10759 }
10760
10761 +#ifdef CONFIG_PAX_PAGEEXEC
10762 +#ifdef CONFIG_PAX_DLRESOLVE
10763 +static void pax_emuplt_close(struct vm_area_struct *vma)
10764 +{
10765 + vma->vm_mm->call_dl_resolve = 0UL;
10766 +}
10767 +
10768 +static int pax_emuplt_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
10769 +{
10770 + unsigned int *kaddr;
10771 +
10772 + vmf->page = alloc_page(GFP_HIGHUSER);
10773 + if (!vmf->page)
10774 + return VM_FAULT_OOM;
10775 +
10776 + kaddr = kmap(vmf->page);
10777 + memset(kaddr, 0, PAGE_SIZE);
10778 + kaddr[0] = 0x9DE3BFA8U; /* save */
10779 + flush_dcache_page(vmf->page);
10780 + kunmap(vmf->page);
10781 + return VM_FAULT_MAJOR;
10782 +}
10783 +
10784 +static const struct vm_operations_struct pax_vm_ops = {
10785 + .close = pax_emuplt_close,
10786 + .fault = pax_emuplt_fault
10787 +};
10788 +
10789 +static int pax_insert_vma(struct vm_area_struct *vma, unsigned long addr)
10790 +{
10791 + int ret;
10792 +
10793 + INIT_LIST_HEAD(&vma->anon_vma_chain);
10794 + vma->vm_mm = current->mm;
10795 + vma->vm_start = addr;
10796 + vma->vm_end = addr + PAGE_SIZE;
10797 + vma->vm_flags = VM_READ | VM_EXEC | VM_MAYREAD | VM_MAYEXEC;
10798 + vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
10799 + vma->vm_ops = &pax_vm_ops;
10800 +
10801 + ret = insert_vm_struct(current->mm, vma);
10802 + if (ret)
10803 + return ret;
10804 +
10805 + ++current->mm->total_vm;
10806 + return 0;
10807 +}
10808 +#endif
10809 +
10810 +/*
10811 + * PaX: decide what to do with offenders (regs->tpc = fault address)
10812 + *
10813 + * returns 1 when task should be killed
10814 + * 2 when patched PLT trampoline was detected
10815 + * 3 when unpatched PLT trampoline was detected
10816 + */
10817 +static int pax_handle_fetch_fault(struct pt_regs *regs)
10818 +{
10819 +
10820 +#ifdef CONFIG_PAX_EMUPLT
10821 + int err;
10822 +
10823 + do { /* PaX: patched PLT emulation #1 */
10824 + unsigned int sethi1, sethi2, jmpl;
10825 +
10826 + err = get_user(sethi1, (unsigned int *)regs->tpc);
10827 + err |= get_user(sethi2, (unsigned int *)(regs->tpc+4));
10828 + err |= get_user(jmpl, (unsigned int *)(regs->tpc+8));
10829 +
10830 + if (err)
10831 + break;
10832 +
10833 + if ((sethi1 & 0xFFC00000U) == 0x03000000U &&
10834 + (sethi2 & 0xFFC00000U) == 0x03000000U &&
10835 + (jmpl & 0xFFFFE000U) == 0x81C06000U)
10836 + {
10837 + unsigned long addr;
10838 +
10839 + regs->u_regs[UREG_G1] = (sethi2 & 0x003FFFFFU) << 10;
10840 + addr = regs->u_regs[UREG_G1];
10841 + addr += (((jmpl | 0xFFFFFFFFFFFFE000UL) ^ 0x00001000UL) + 0x00001000UL);
10842 +
10843 + if (test_thread_flag(TIF_32BIT))
10844 + addr &= 0xFFFFFFFFUL;
10845 +
10846 + regs->tpc = addr;
10847 + regs->tnpc = addr+4;
10848 + return 2;
10849 + }
10850 + } while (0);
10851 +
10852 + do { /* PaX: patched PLT emulation #2 */
10853 + unsigned int ba;
10854 +
10855 + err = get_user(ba, (unsigned int *)regs->tpc);
10856 +
10857 + if (err)
10858 + break;
10859 +
10860 + if ((ba & 0xFFC00000U) == 0x30800000U || (ba & 0xFFF80000U) == 0x30480000U) {
10861 + unsigned long addr;
10862 +
10863 + if ((ba & 0xFFC00000U) == 0x30800000U)
10864 + addr = regs->tpc + ((((ba | 0xFFFFFFFFFFC00000UL) ^ 0x00200000UL) + 0x00200000UL) << 2);
10865 + else
10866 + addr = regs->tpc + ((((ba | 0xFFFFFFFFFFF80000UL) ^ 0x00040000UL) + 0x00040000UL) << 2);
10867 +
10868 + if (test_thread_flag(TIF_32BIT))
10869 + addr &= 0xFFFFFFFFUL;
10870 +
10871 + regs->tpc = addr;
10872 + regs->tnpc = addr+4;
10873 + return 2;
10874 + }
10875 + } while (0);
10876 +
10877 + do { /* PaX: patched PLT emulation #3 */
10878 + unsigned int sethi, bajmpl, nop;
10879 +
10880 + err = get_user(sethi, (unsigned int *)regs->tpc);
10881 + err |= get_user(bajmpl, (unsigned int *)(regs->tpc+4));
10882 + err |= get_user(nop, (unsigned int *)(regs->tpc+8));
10883 +
10884 + if (err)
10885 + break;
10886 +
10887 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
10888 + ((bajmpl & 0xFFFFE000U) == 0x81C06000U || (bajmpl & 0xFFF80000U) == 0x30480000U) &&
10889 + nop == 0x01000000U)
10890 + {
10891 + unsigned long addr;
10892 +
10893 + addr = (sethi & 0x003FFFFFU) << 10;
10894 + regs->u_regs[UREG_G1] = addr;
10895 + if ((bajmpl & 0xFFFFE000U) == 0x81C06000U)
10896 + addr += (((bajmpl | 0xFFFFFFFFFFFFE000UL) ^ 0x00001000UL) + 0x00001000UL);
10897 + else
10898 + addr = regs->tpc + ((((bajmpl | 0xFFFFFFFFFFF80000UL) ^ 0x00040000UL) + 0x00040000UL) << 2);
10899 +
10900 + if (test_thread_flag(TIF_32BIT))
10901 + addr &= 0xFFFFFFFFUL;
10902 +
10903 + regs->tpc = addr;
10904 + regs->tnpc = addr+4;
10905 + return 2;
10906 + }
10907 + } while (0);
10908 +
10909 + do { /* PaX: patched PLT emulation #4 */
10910 + unsigned int sethi, mov1, call, mov2;
10911 +
10912 + err = get_user(sethi, (unsigned int *)regs->tpc);
10913 + err |= get_user(mov1, (unsigned int *)(regs->tpc+4));
10914 + err |= get_user(call, (unsigned int *)(regs->tpc+8));
10915 + err |= get_user(mov2, (unsigned int *)(regs->tpc+12));
10916 +
10917 + if (err)
10918 + break;
10919 +
10920 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
10921 + mov1 == 0x8210000FU &&
10922 + (call & 0xC0000000U) == 0x40000000U &&
10923 + mov2 == 0x9E100001U)
10924 + {
10925 + unsigned long addr;
10926 +
10927 + regs->u_regs[UREG_G1] = regs->u_regs[UREG_RETPC];
10928 + addr = regs->tpc + 4 + ((((call | 0xFFFFFFFFC0000000UL) ^ 0x20000000UL) + 0x20000000UL) << 2);
10929 +
10930 + if (test_thread_flag(TIF_32BIT))
10931 + addr &= 0xFFFFFFFFUL;
10932 +
10933 + regs->tpc = addr;
10934 + regs->tnpc = addr+4;
10935 + return 2;
10936 + }
10937 + } while (0);
10938 +
10939 + do { /* PaX: patched PLT emulation #5 */
10940 + unsigned int sethi, sethi1, sethi2, or1, or2, sllx, jmpl, nop;
10941 +
10942 + err = get_user(sethi, (unsigned int *)regs->tpc);
10943 + err |= get_user(sethi1, (unsigned int *)(regs->tpc+4));
10944 + err |= get_user(sethi2, (unsigned int *)(regs->tpc+8));
10945 + err |= get_user(or1, (unsigned int *)(regs->tpc+12));
10946 + err |= get_user(or2, (unsigned int *)(regs->tpc+16));
10947 + err |= get_user(sllx, (unsigned int *)(regs->tpc+20));
10948 + err |= get_user(jmpl, (unsigned int *)(regs->tpc+24));
10949 + err |= get_user(nop, (unsigned int *)(regs->tpc+28));
10950 +
10951 + if (err)
10952 + break;
10953 +
10954 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
10955 + (sethi1 & 0xFFC00000U) == 0x03000000U &&
10956 + (sethi2 & 0xFFC00000U) == 0x0B000000U &&
10957 + (or1 & 0xFFFFE000U) == 0x82106000U &&
10958 + (or2 & 0xFFFFE000U) == 0x8A116000U &&
10959 + sllx == 0x83287020U &&
10960 + jmpl == 0x81C04005U &&
10961 + nop == 0x01000000U)
10962 + {
10963 + unsigned long addr;
10964 +
10965 + regs->u_regs[UREG_G1] = ((sethi1 & 0x003FFFFFU) << 10) | (or1 & 0x000003FFU);
10966 + regs->u_regs[UREG_G1] <<= 32;
10967 + regs->u_regs[UREG_G5] = ((sethi2 & 0x003FFFFFU) << 10) | (or2 & 0x000003FFU);
10968 + addr = regs->u_regs[UREG_G1] + regs->u_regs[UREG_G5];
10969 + regs->tpc = addr;
10970 + regs->tnpc = addr+4;
10971 + return 2;
10972 + }
10973 + } while (0);
10974 +
10975 + do { /* PaX: patched PLT emulation #6 */
10976 + unsigned int sethi, sethi1, sethi2, sllx, or, jmpl, nop;
10977 +
10978 + err = get_user(sethi, (unsigned int *)regs->tpc);
10979 + err |= get_user(sethi1, (unsigned int *)(regs->tpc+4));
10980 + err |= get_user(sethi2, (unsigned int *)(regs->tpc+8));
10981 + err |= get_user(sllx, (unsigned int *)(regs->tpc+12));
10982 + err |= get_user(or, (unsigned int *)(regs->tpc+16));
10983 + err |= get_user(jmpl, (unsigned int *)(regs->tpc+20));
10984 + err |= get_user(nop, (unsigned int *)(regs->tpc+24));
10985 +
10986 + if (err)
10987 + break;
10988 +
10989 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
10990 + (sethi1 & 0xFFC00000U) == 0x03000000U &&
10991 + (sethi2 & 0xFFC00000U) == 0x0B000000U &&
10992 + sllx == 0x83287020U &&
10993 + (or & 0xFFFFE000U) == 0x8A116000U &&
10994 + jmpl == 0x81C04005U &&
10995 + nop == 0x01000000U)
10996 + {
10997 + unsigned long addr;
10998 +
10999 + regs->u_regs[UREG_G1] = (sethi1 & 0x003FFFFFU) << 10;
11000 + regs->u_regs[UREG_G1] <<= 32;
11001 + regs->u_regs[UREG_G5] = ((sethi2 & 0x003FFFFFU) << 10) | (or & 0x3FFU);
11002 + addr = regs->u_regs[UREG_G1] + regs->u_regs[UREG_G5];
11003 + regs->tpc = addr;
11004 + regs->tnpc = addr+4;
11005 + return 2;
11006 + }
11007 + } while (0);
11008 +
11009 + do { /* PaX: unpatched PLT emulation step 1 */
11010 + unsigned int sethi, ba, nop;
11011 +
11012 + err = get_user(sethi, (unsigned int *)regs->tpc);
11013 + err |= get_user(ba, (unsigned int *)(regs->tpc+4));
11014 + err |= get_user(nop, (unsigned int *)(regs->tpc+8));
11015 +
11016 + if (err)
11017 + break;
11018 +
11019 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
11020 + ((ba & 0xFFC00000U) == 0x30800000U || (ba & 0xFFF80000U) == 0x30680000U) &&
11021 + nop == 0x01000000U)
11022 + {
11023 + unsigned long addr;
11024 + unsigned int save, call;
11025 + unsigned int sethi1, sethi2, or1, or2, sllx, add, jmpl;
11026 +
11027 + if ((ba & 0xFFC00000U) == 0x30800000U)
11028 + addr = regs->tpc + 4 + ((((ba | 0xFFFFFFFFFFC00000UL) ^ 0x00200000UL) + 0x00200000UL) << 2);
11029 + else
11030 + addr = regs->tpc + 4 + ((((ba | 0xFFFFFFFFFFF80000UL) ^ 0x00040000UL) + 0x00040000UL) << 2);
11031 +
11032 + if (test_thread_flag(TIF_32BIT))
11033 + addr &= 0xFFFFFFFFUL;
11034 +
11035 + err = get_user(save, (unsigned int *)addr);
11036 + err |= get_user(call, (unsigned int *)(addr+4));
11037 + err |= get_user(nop, (unsigned int *)(addr+8));
11038 + if (err)
11039 + break;
11040 +
11041 +#ifdef CONFIG_PAX_DLRESOLVE
11042 + if (save == 0x9DE3BFA8U &&
11043 + (call & 0xC0000000U) == 0x40000000U &&
11044 + nop == 0x01000000U)
11045 + {
11046 + struct vm_area_struct *vma;
11047 + unsigned long call_dl_resolve;
11048 +
11049 + down_read(&current->mm->mmap_sem);
11050 + call_dl_resolve = current->mm->call_dl_resolve;
11051 + up_read(&current->mm->mmap_sem);
11052 + if (likely(call_dl_resolve))
11053 + goto emulate;
11054 +
11055 + vma = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
11056 +
11057 + down_write(&current->mm->mmap_sem);
11058 + if (current->mm->call_dl_resolve) {
11059 + call_dl_resolve = current->mm->call_dl_resolve;
11060 + up_write(&current->mm->mmap_sem);
11061 + if (vma)
11062 + kmem_cache_free(vm_area_cachep, vma);
11063 + goto emulate;
11064 + }
11065 +
11066 + call_dl_resolve = get_unmapped_area(NULL, 0UL, PAGE_SIZE, 0UL, MAP_PRIVATE);
11067 + if (!vma || (call_dl_resolve & ~PAGE_MASK)) {
11068 + up_write(&current->mm->mmap_sem);
11069 + if (vma)
11070 + kmem_cache_free(vm_area_cachep, vma);
11071 + return 1;
11072 + }
11073 +
11074 + if (pax_insert_vma(vma, call_dl_resolve)) {
11075 + up_write(&current->mm->mmap_sem);
11076 + kmem_cache_free(vm_area_cachep, vma);
11077 + return 1;
11078 + }
11079 +
11080 + current->mm->call_dl_resolve = call_dl_resolve;
11081 + up_write(&current->mm->mmap_sem);
11082 +
11083 +emulate:
11084 + regs->u_regs[UREG_G1] = (sethi & 0x003FFFFFU) << 10;
11085 + regs->tpc = call_dl_resolve;
11086 + regs->tnpc = addr+4;
11087 + return 3;
11088 + }
11089 +#endif
11090 +
11091 + /* PaX: glibc 2.4+ generates sethi/jmpl instead of save/call */
11092 + if ((save & 0xFFC00000U) == 0x05000000U &&
11093 + (call & 0xFFFFE000U) == 0x85C0A000U &&
11094 + nop == 0x01000000U)
11095 + {
11096 + regs->u_regs[UREG_G1] = (sethi & 0x003FFFFFU) << 10;
11097 + regs->u_regs[UREG_G2] = addr + 4;
11098 + addr = (save & 0x003FFFFFU) << 10;
11099 + addr += (((call | 0xFFFFFFFFFFFFE000UL) ^ 0x00001000UL) + 0x00001000UL);
11100 +
11101 + if (test_thread_flag(TIF_32BIT))
11102 + addr &= 0xFFFFFFFFUL;
11103 +
11104 + regs->tpc = addr;
11105 + regs->tnpc = addr+4;
11106 + return 3;
11107 + }
11108 +
11109 + /* PaX: 64-bit PLT stub */
11110 + err = get_user(sethi1, (unsigned int *)addr);
11111 + err |= get_user(sethi2, (unsigned int *)(addr+4));
11112 + err |= get_user(or1, (unsigned int *)(addr+8));
11113 + err |= get_user(or2, (unsigned int *)(addr+12));
11114 + err |= get_user(sllx, (unsigned int *)(addr+16));
11115 + err |= get_user(add, (unsigned int *)(addr+20));
11116 + err |= get_user(jmpl, (unsigned int *)(addr+24));
11117 + err |= get_user(nop, (unsigned int *)(addr+28));
11118 + if (err)
11119 + break;
11120 +
11121 + if ((sethi1 & 0xFFC00000U) == 0x09000000U &&
11122 + (sethi2 & 0xFFC00000U) == 0x0B000000U &&
11123 + (or1 & 0xFFFFE000U) == 0x88112000U &&
11124 + (or2 & 0xFFFFE000U) == 0x8A116000U &&
11125 + sllx == 0x89293020U &&
11126 + add == 0x8A010005U &&
11127 + jmpl == 0x89C14000U &&
11128 + nop == 0x01000000U)
11129 + {
11130 + regs->u_regs[UREG_G1] = (sethi & 0x003FFFFFU) << 10;
11131 + regs->u_regs[UREG_G4] = ((sethi1 & 0x003FFFFFU) << 10) | (or1 & 0x000003FFU);
11132 + regs->u_regs[UREG_G4] <<= 32;
11133 + regs->u_regs[UREG_G5] = ((sethi2 & 0x003FFFFFU) << 10) | (or2 & 0x000003FFU);
11134 + regs->u_regs[UREG_G5] += regs->u_regs[UREG_G4];
11135 + regs->u_regs[UREG_G4] = addr + 24;
11136 + addr = regs->u_regs[UREG_G5];
11137 + regs->tpc = addr;
11138 + regs->tnpc = addr+4;
11139 + return 3;
11140 + }
11141 + }
11142 + } while (0);
11143 +
11144 +#ifdef CONFIG_PAX_DLRESOLVE
11145 + do { /* PaX: unpatched PLT emulation step 2 */
11146 + unsigned int save, call, nop;
11147 +
11148 + err = get_user(save, (unsigned int *)(regs->tpc-4));
11149 + err |= get_user(call, (unsigned int *)regs->tpc);
11150 + err |= get_user(nop, (unsigned int *)(regs->tpc+4));
11151 + if (err)
11152 + break;
11153 +
11154 + if (save == 0x9DE3BFA8U &&
11155 + (call & 0xC0000000U) == 0x40000000U &&
11156 + nop == 0x01000000U)
11157 + {
11158 + unsigned long dl_resolve = regs->tpc + ((((call | 0xFFFFFFFFC0000000UL) ^ 0x20000000UL) + 0x20000000UL) << 2);
11159 +
11160 + if (test_thread_flag(TIF_32BIT))
11161 + dl_resolve &= 0xFFFFFFFFUL;
11162 +
11163 + regs->u_regs[UREG_RETPC] = regs->tpc;
11164 + regs->tpc = dl_resolve;
11165 + regs->tnpc = dl_resolve+4;
11166 + return 3;
11167 + }
11168 + } while (0);
11169 +#endif
11170 +
11171 + do { /* PaX: patched PLT emulation #7, must be AFTER the unpatched PLT emulation */
11172 + unsigned int sethi, ba, nop;
11173 +
11174 + err = get_user(sethi, (unsigned int *)regs->tpc);
11175 + err |= get_user(ba, (unsigned int *)(regs->tpc+4));
11176 + err |= get_user(nop, (unsigned int *)(regs->tpc+8));
11177 +
11178 + if (err)
11179 + break;
11180 +
11181 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
11182 + (ba & 0xFFF00000U) == 0x30600000U &&
11183 + nop == 0x01000000U)
11184 + {
11185 + unsigned long addr;
11186 +
11187 + addr = (sethi & 0x003FFFFFU) << 10;
11188 + regs->u_regs[UREG_G1] = addr;
11189 + addr = regs->tpc + ((((ba | 0xFFFFFFFFFFF80000UL) ^ 0x00040000UL) + 0x00040000UL) << 2);
11190 +
11191 + if (test_thread_flag(TIF_32BIT))
11192 + addr &= 0xFFFFFFFFUL;
11193 +
11194 + regs->tpc = addr;
11195 + regs->tnpc = addr+4;
11196 + return 2;
11197 + }
11198 + } while (0);
11199 +
11200 +#endif
11201 +
11202 + return 1;
11203 +}
11204 +
11205 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
11206 +{
11207 + unsigned long i;
11208 +
11209 + printk(KERN_ERR "PAX: bytes at PC: ");
11210 + for (i = 0; i < 8; i++) {
11211 + unsigned int c;
11212 + if (get_user(c, (unsigned int *)pc+i))
11213 + printk(KERN_CONT "???????? ");
11214 + else
11215 + printk(KERN_CONT "%08x ", c);
11216 + }
11217 + printk("\n");
11218 +}
11219 +#endif
11220 +
11221 asmlinkage void __kprobes do_sparc64_fault(struct pt_regs *regs)
11222 {
11223 struct mm_struct *mm = current->mm;
11224 @@ -342,6 +805,29 @@ retry:
11225 if (!vma)
11226 goto bad_area;
11227
11228 +#ifdef CONFIG_PAX_PAGEEXEC
11229 + /* PaX: detect ITLB misses on non-exec pages */
11230 + if ((mm->pax_flags & MF_PAX_PAGEEXEC) && vma->vm_start <= address &&
11231 + !(vma->vm_flags & VM_EXEC) && (fault_code & FAULT_CODE_ITLB))
11232 + {
11233 + if (address != regs->tpc)
11234 + goto good_area;
11235 +
11236 + up_read(&mm->mmap_sem);
11237 + switch (pax_handle_fetch_fault(regs)) {
11238 +
11239 +#ifdef CONFIG_PAX_EMUPLT
11240 + case 2:
11241 + case 3:
11242 + return;
11243 +#endif
11244 +
11245 + }
11246 + pax_report_fault(regs, (void *)regs->tpc, (void *)(regs->u_regs[UREG_FP] + STACK_BIAS));
11247 + do_group_exit(SIGKILL);
11248 + }
11249 +#endif
11250 +
11251 /* Pure DTLB misses do not tell us whether the fault causing
11252 * load/store/atomic was a write or not, it only says that there
11253 * was no match. So in such a case we (carefully) read the
11254 diff --git a/arch/sparc/mm/hugetlbpage.c b/arch/sparc/mm/hugetlbpage.c
11255 index 9639964..806cd0c 100644
11256 --- a/arch/sparc/mm/hugetlbpage.c
11257 +++ b/arch/sparc/mm/hugetlbpage.c
11258 @@ -28,7 +28,8 @@ static unsigned long hugetlb_get_unmapped_area_bottomup(struct file *filp,
11259 unsigned long addr,
11260 unsigned long len,
11261 unsigned long pgoff,
11262 - unsigned long flags)
11263 + unsigned long flags,
11264 + unsigned long offset)
11265 {
11266 unsigned long task_size = TASK_SIZE;
11267 struct vm_unmapped_area_info info;
11268 @@ -38,15 +39,22 @@ static unsigned long hugetlb_get_unmapped_area_bottomup(struct file *filp,
11269
11270 info.flags = 0;
11271 info.length = len;
11272 - info.low_limit = TASK_UNMAPPED_BASE;
11273 + info.low_limit = mm->mmap_base;
11274 info.high_limit = min(task_size, VA_EXCLUDE_START);
11275 info.align_mask = PAGE_MASK & ~HPAGE_MASK;
11276 info.align_offset = 0;
11277 + info.threadstack_offset = offset;
11278 addr = vm_unmapped_area(&info);
11279
11280 if ((addr & ~PAGE_MASK) && task_size > VA_EXCLUDE_END) {
11281 VM_BUG_ON(addr != -ENOMEM);
11282 info.low_limit = VA_EXCLUDE_END;
11283 +
11284 +#ifdef CONFIG_PAX_RANDMMAP
11285 + if (mm->pax_flags & MF_PAX_RANDMMAP)
11286 + info.low_limit += mm->delta_mmap;
11287 +#endif
11288 +
11289 info.high_limit = task_size;
11290 addr = vm_unmapped_area(&info);
11291 }
11292 @@ -58,7 +66,8 @@ static unsigned long
11293 hugetlb_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
11294 const unsigned long len,
11295 const unsigned long pgoff,
11296 - const unsigned long flags)
11297 + const unsigned long flags,
11298 + const unsigned long offset)
11299 {
11300 struct mm_struct *mm = current->mm;
11301 unsigned long addr = addr0;
11302 @@ -73,6 +82,7 @@ hugetlb_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
11303 info.high_limit = mm->mmap_base;
11304 info.align_mask = PAGE_MASK & ~HPAGE_MASK;
11305 info.align_offset = 0;
11306 + info.threadstack_offset = offset;
11307 addr = vm_unmapped_area(&info);
11308
11309 /*
11310 @@ -85,6 +95,12 @@ hugetlb_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
11311 VM_BUG_ON(addr != -ENOMEM);
11312 info.flags = 0;
11313 info.low_limit = TASK_UNMAPPED_BASE;
11314 +
11315 +#ifdef CONFIG_PAX_RANDMMAP
11316 + if (mm->pax_flags & MF_PAX_RANDMMAP)
11317 + info.low_limit += mm->delta_mmap;
11318 +#endif
11319 +
11320 info.high_limit = STACK_TOP32;
11321 addr = vm_unmapped_area(&info);
11322 }
11323 @@ -99,6 +115,7 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
11324 struct mm_struct *mm = current->mm;
11325 struct vm_area_struct *vma;
11326 unsigned long task_size = TASK_SIZE;
11327 + unsigned long offset = gr_rand_threadstack_offset(mm, file, flags);
11328
11329 if (test_thread_flag(TIF_32BIT))
11330 task_size = STACK_TOP32;
11331 @@ -114,19 +131,22 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
11332 return addr;
11333 }
11334
11335 +#ifdef CONFIG_PAX_RANDMMAP
11336 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
11337 +#endif
11338 +
11339 if (addr) {
11340 addr = ALIGN(addr, HPAGE_SIZE);
11341 vma = find_vma(mm, addr);
11342 - if (task_size - len >= addr &&
11343 - (!vma || addr + len <= vma->vm_start))
11344 + if (task_size - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
11345 return addr;
11346 }
11347 if (mm->get_unmapped_area == arch_get_unmapped_area)
11348 return hugetlb_get_unmapped_area_bottomup(file, addr, len,
11349 - pgoff, flags);
11350 + pgoff, flags, offset);
11351 else
11352 return hugetlb_get_unmapped_area_topdown(file, addr, len,
11353 - pgoff, flags);
11354 + pgoff, flags, offset);
11355 }
11356
11357 pte_t *huge_pte_alloc(struct mm_struct *mm,
11358 diff --git a/arch/sparc/mm/init_64.c b/arch/sparc/mm/init_64.c
11359 index ed82eda..0d80e77 100644
11360 --- a/arch/sparc/mm/init_64.c
11361 +++ b/arch/sparc/mm/init_64.c
11362 @@ -188,9 +188,9 @@ unsigned long sparc64_kern_sec_context __read_mostly;
11363 int num_kernel_image_mappings;
11364
11365 #ifdef CONFIG_DEBUG_DCFLUSH
11366 -atomic_t dcpage_flushes = ATOMIC_INIT(0);
11367 +atomic_unchecked_t dcpage_flushes = ATOMIC_INIT(0);
11368 #ifdef CONFIG_SMP
11369 -atomic_t dcpage_flushes_xcall = ATOMIC_INIT(0);
11370 +atomic_unchecked_t dcpage_flushes_xcall = ATOMIC_INIT(0);
11371 #endif
11372 #endif
11373
11374 @@ -198,7 +198,7 @@ inline void flush_dcache_page_impl(struct page *page)
11375 {
11376 BUG_ON(tlb_type == hypervisor);
11377 #ifdef CONFIG_DEBUG_DCFLUSH
11378 - atomic_inc(&dcpage_flushes);
11379 + atomic_inc_unchecked(&dcpage_flushes);
11380 #endif
11381
11382 #ifdef DCACHE_ALIASING_POSSIBLE
11383 @@ -466,10 +466,10 @@ void mmu_info(struct seq_file *m)
11384
11385 #ifdef CONFIG_DEBUG_DCFLUSH
11386 seq_printf(m, "DCPageFlushes\t: %d\n",
11387 - atomic_read(&dcpage_flushes));
11388 + atomic_read_unchecked(&dcpage_flushes));
11389 #ifdef CONFIG_SMP
11390 seq_printf(m, "DCPageFlushesXC\t: %d\n",
11391 - atomic_read(&dcpage_flushes_xcall));
11392 + atomic_read_unchecked(&dcpage_flushes_xcall));
11393 #endif /* CONFIG_SMP */
11394 #endif /* CONFIG_DEBUG_DCFLUSH */
11395 }
11396 diff --git a/arch/tile/Kconfig b/arch/tile/Kconfig
11397 index d45a2c4..3c05a78 100644
11398 --- a/arch/tile/Kconfig
11399 +++ b/arch/tile/Kconfig
11400 @@ -185,6 +185,7 @@ source "kernel/Kconfig.hz"
11401
11402 config KEXEC
11403 bool "kexec system call"
11404 + depends on !GRKERNSEC_KMEM
11405 ---help---
11406 kexec is a system call that implements the ability to shutdown your
11407 current kernel, and to start another kernel. It is like a reboot
11408 diff --git a/arch/tile/include/asm/atomic_64.h b/arch/tile/include/asm/atomic_64.h
11409 index ad220ee..2f537b3 100644
11410 --- a/arch/tile/include/asm/atomic_64.h
11411 +++ b/arch/tile/include/asm/atomic_64.h
11412 @@ -105,6 +105,16 @@ static inline long atomic64_add_unless(atomic64_t *v, long a, long u)
11413
11414 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1, 0)
11415
11416 +#define atomic64_read_unchecked(v) atomic64_read(v)
11417 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
11418 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
11419 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
11420 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
11421 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
11422 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
11423 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
11424 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
11425 +
11426 /* Atomic dec and inc don't implement barrier, so provide them if needed. */
11427 #define smp_mb__before_atomic_dec() smp_mb()
11428 #define smp_mb__after_atomic_dec() smp_mb()
11429 diff --git a/arch/tile/include/asm/cache.h b/arch/tile/include/asm/cache.h
11430 index 6160761..00cac88 100644
11431 --- a/arch/tile/include/asm/cache.h
11432 +++ b/arch/tile/include/asm/cache.h
11433 @@ -15,11 +15,12 @@
11434 #ifndef _ASM_TILE_CACHE_H
11435 #define _ASM_TILE_CACHE_H
11436
11437 +#include <linux/const.h>
11438 #include <arch/chip.h>
11439
11440 /* bytes per L1 data cache line */
11441 #define L1_CACHE_SHIFT CHIP_L1D_LOG_LINE_SIZE()
11442 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
11443 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
11444
11445 /* bytes per L2 cache line */
11446 #define L2_CACHE_SHIFT CHIP_L2_LOG_LINE_SIZE()
11447 diff --git a/arch/tile/include/asm/uaccess.h b/arch/tile/include/asm/uaccess.h
11448 index b6cde32..c0cb736 100644
11449 --- a/arch/tile/include/asm/uaccess.h
11450 +++ b/arch/tile/include/asm/uaccess.h
11451 @@ -414,9 +414,9 @@ static inline unsigned long __must_check copy_from_user(void *to,
11452 const void __user *from,
11453 unsigned long n)
11454 {
11455 - int sz = __compiletime_object_size(to);
11456 + size_t sz = __compiletime_object_size(to);
11457
11458 - if (likely(sz == -1 || sz >= n))
11459 + if (likely(sz == (size_t)-1 || sz >= n))
11460 n = _copy_from_user(to, from, n);
11461 else
11462 copy_from_user_overflow();
11463 diff --git a/arch/tile/mm/hugetlbpage.c b/arch/tile/mm/hugetlbpage.c
11464 index 0cb3bba..7338b2d 100644
11465 --- a/arch/tile/mm/hugetlbpage.c
11466 +++ b/arch/tile/mm/hugetlbpage.c
11467 @@ -212,6 +212,7 @@ static unsigned long hugetlb_get_unmapped_area_bottomup(struct file *file,
11468 info.high_limit = TASK_SIZE;
11469 info.align_mask = PAGE_MASK & ~huge_page_mask(h);
11470 info.align_offset = 0;
11471 + info.threadstack_offset = 0;
11472 return vm_unmapped_area(&info);
11473 }
11474
11475 @@ -229,6 +230,7 @@ static unsigned long hugetlb_get_unmapped_area_topdown(struct file *file,
11476 info.high_limit = current->mm->mmap_base;
11477 info.align_mask = PAGE_MASK & ~huge_page_mask(h);
11478 info.align_offset = 0;
11479 + info.threadstack_offset = 0;
11480 addr = vm_unmapped_area(&info);
11481
11482 /*
11483 diff --git a/arch/um/Makefile b/arch/um/Makefile
11484 index 133f7de..1d6f2f1 100644
11485 --- a/arch/um/Makefile
11486 +++ b/arch/um/Makefile
11487 @@ -62,6 +62,10 @@ USER_CFLAGS = $(patsubst $(KERNEL_DEFINES),,$(patsubst -D__KERNEL__,,\
11488 $(patsubst -I%,,$(KBUILD_CFLAGS)))) $(ARCH_INCLUDE) $(MODE_INCLUDE) \
11489 $(filter -I%,$(CFLAGS)) -D_FILE_OFFSET_BITS=64 -idirafter include
11490
11491 +ifdef CONSTIFY_PLUGIN
11492 +USER_CFLAGS += -fplugin-arg-constify_plugin-no-constify
11493 +endif
11494 +
11495 #This will adjust *FLAGS accordingly to the platform.
11496 include $(srctree)/$(ARCH_DIR)/Makefile-os-$(OS)
11497
11498 diff --git a/arch/um/defconfig b/arch/um/defconfig
11499 index 2665e6b..3e3822b 100644
11500 --- a/arch/um/defconfig
11501 +++ b/arch/um/defconfig
11502 @@ -51,7 +51,6 @@ CONFIG_X86_CMPXCHG=y
11503 CONFIG_X86_L1_CACHE_SHIFT=5
11504 CONFIG_X86_XADD=y
11505 CONFIG_X86_PPRO_FENCE=y
11506 -CONFIG_X86_WP_WORKS_OK=y
11507 CONFIG_X86_INVLPG=y
11508 CONFIG_X86_BSWAP=y
11509 CONFIG_X86_POPAD_OK=y
11510 diff --git a/arch/um/include/asm/cache.h b/arch/um/include/asm/cache.h
11511 index 19e1bdd..3665b77 100644
11512 --- a/arch/um/include/asm/cache.h
11513 +++ b/arch/um/include/asm/cache.h
11514 @@ -1,6 +1,7 @@
11515 #ifndef __UM_CACHE_H
11516 #define __UM_CACHE_H
11517
11518 +#include <linux/const.h>
11519
11520 #if defined(CONFIG_UML_X86) && !defined(CONFIG_64BIT)
11521 # define L1_CACHE_SHIFT (CONFIG_X86_L1_CACHE_SHIFT)
11522 @@ -12,6 +13,6 @@
11523 # define L1_CACHE_SHIFT 5
11524 #endif
11525
11526 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
11527 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
11528
11529 #endif
11530 diff --git a/arch/um/include/asm/kmap_types.h b/arch/um/include/asm/kmap_types.h
11531 index 2e0a6b1..a64d0f5 100644
11532 --- a/arch/um/include/asm/kmap_types.h
11533 +++ b/arch/um/include/asm/kmap_types.h
11534 @@ -8,6 +8,6 @@
11535
11536 /* No more #include "asm/arch/kmap_types.h" ! */
11537
11538 -#define KM_TYPE_NR 14
11539 +#define KM_TYPE_NR 15
11540
11541 #endif
11542 diff --git a/arch/um/include/asm/page.h b/arch/um/include/asm/page.h
11543 index 5ff53d9..5850cdf 100644
11544 --- a/arch/um/include/asm/page.h
11545 +++ b/arch/um/include/asm/page.h
11546 @@ -14,6 +14,9 @@
11547 #define PAGE_SIZE (_AC(1, UL) << PAGE_SHIFT)
11548 #define PAGE_MASK (~(PAGE_SIZE-1))
11549
11550 +#define ktla_ktva(addr) (addr)
11551 +#define ktva_ktla(addr) (addr)
11552 +
11553 #ifndef __ASSEMBLY__
11554
11555 struct page;
11556 diff --git a/arch/um/include/asm/pgtable-3level.h b/arch/um/include/asm/pgtable-3level.h
11557 index 0032f92..cd151e0 100644
11558 --- a/arch/um/include/asm/pgtable-3level.h
11559 +++ b/arch/um/include/asm/pgtable-3level.h
11560 @@ -58,6 +58,7 @@
11561 #define pud_present(x) (pud_val(x) & _PAGE_PRESENT)
11562 #define pud_populate(mm, pud, pmd) \
11563 set_pud(pud, __pud(_PAGE_TABLE + __pa(pmd)))
11564 +#define pud_populate_kernel(mm, pud, pmd) pud_populate((mm), (pud), (pmd))
11565
11566 #ifdef CONFIG_64BIT
11567 #define set_pud(pudptr, pudval) set_64bit((u64 *) (pudptr), pud_val(pudval))
11568 diff --git a/arch/um/kernel/process.c b/arch/um/kernel/process.c
11569 index bbcef52..6a2a483 100644
11570 --- a/arch/um/kernel/process.c
11571 +++ b/arch/um/kernel/process.c
11572 @@ -367,22 +367,6 @@ int singlestepping(void * t)
11573 return 2;
11574 }
11575
11576 -/*
11577 - * Only x86 and x86_64 have an arch_align_stack().
11578 - * All other arches have "#define arch_align_stack(x) (x)"
11579 - * in their asm/system.h
11580 - * As this is included in UML from asm-um/system-generic.h,
11581 - * we can use it to behave as the subarch does.
11582 - */
11583 -#ifndef arch_align_stack
11584 -unsigned long arch_align_stack(unsigned long sp)
11585 -{
11586 - if (!(current->personality & ADDR_NO_RANDOMIZE) && randomize_va_space)
11587 - sp -= get_random_int() % 8192;
11588 - return sp & ~0xf;
11589 -}
11590 -#endif
11591 -
11592 unsigned long get_wchan(struct task_struct *p)
11593 {
11594 unsigned long stack_page, sp, ip;
11595 diff --git a/arch/unicore32/include/asm/cache.h b/arch/unicore32/include/asm/cache.h
11596 index ad8f795..2c7eec6 100644
11597 --- a/arch/unicore32/include/asm/cache.h
11598 +++ b/arch/unicore32/include/asm/cache.h
11599 @@ -12,8 +12,10 @@
11600 #ifndef __UNICORE_CACHE_H__
11601 #define __UNICORE_CACHE_H__
11602
11603 -#define L1_CACHE_SHIFT (5)
11604 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
11605 +#include <linux/const.h>
11606 +
11607 +#define L1_CACHE_SHIFT 5
11608 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
11609
11610 /*
11611 * Memory returned by kmalloc() may be used for DMA, so we must make
11612 diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
11613 index f67e839..bfd4748 100644
11614 --- a/arch/x86/Kconfig
11615 +++ b/arch/x86/Kconfig
11616 @@ -247,7 +247,7 @@ config X86_HT
11617
11618 config X86_32_LAZY_GS
11619 def_bool y
11620 - depends on X86_32 && !CC_STACKPROTECTOR
11621 + depends on X86_32 && !CC_STACKPROTECTOR && !PAX_MEMORY_UDEREF
11622
11623 config ARCH_HWEIGHT_CFLAGS
11624 string
11625 @@ -1099,6 +1099,7 @@ config MICROCODE_EARLY
11626
11627 config X86_MSR
11628 tristate "/dev/cpu/*/msr - Model-specific register support"
11629 + depends on !GRKERNSEC_KMEM
11630 ---help---
11631 This device gives privileged processes access to the x86
11632 Model-Specific Registers (MSRs). It is a character device with
11633 @@ -1122,7 +1123,7 @@ choice
11634
11635 config NOHIGHMEM
11636 bool "off"
11637 - depends on !X86_NUMAQ
11638 + depends on !X86_NUMAQ && !(PAX_PAGEEXEC && PAX_ENABLE_PAE)
11639 ---help---
11640 Linux can use up to 64 Gigabytes of physical memory on x86 systems.
11641 However, the address space of 32-bit x86 processors is only 4
11642 @@ -1159,7 +1160,7 @@ config NOHIGHMEM
11643
11644 config HIGHMEM4G
11645 bool "4GB"
11646 - depends on !X86_NUMAQ
11647 + depends on !X86_NUMAQ && !(PAX_PAGEEXEC && PAX_ENABLE_PAE)
11648 ---help---
11649 Select this if you have a 32-bit processor and between 1 and 4
11650 gigabytes of physical RAM.
11651 @@ -1212,7 +1213,7 @@ config PAGE_OFFSET
11652 hex
11653 default 0xB0000000 if VMSPLIT_3G_OPT
11654 default 0x80000000 if VMSPLIT_2G
11655 - default 0x78000000 if VMSPLIT_2G_OPT
11656 + default 0x70000000 if VMSPLIT_2G_OPT
11657 default 0x40000000 if VMSPLIT_1G
11658 default 0xC0000000
11659 depends on X86_32
11660 @@ -1614,6 +1615,7 @@ config SECCOMP
11661
11662 config CC_STACKPROTECTOR
11663 bool "Enable -fstack-protector buffer overflow detection"
11664 + depends on X86_64 || !PAX_MEMORY_UDEREF
11665 ---help---
11666 This option turns on the -fstack-protector GCC feature. This
11667 feature puts, at the beginning of functions, a canary value on
11668 @@ -1632,6 +1634,7 @@ source kernel/Kconfig.hz
11669
11670 config KEXEC
11671 bool "kexec system call"
11672 + depends on !GRKERNSEC_KMEM
11673 ---help---
11674 kexec is a system call that implements the ability to shutdown your
11675 current kernel, and to start another kernel. It is like a reboot
11676 @@ -1733,6 +1736,8 @@ config X86_NEED_RELOCS
11677 config PHYSICAL_ALIGN
11678 hex "Alignment value to which kernel should be aligned"
11679 default "0x1000000"
11680 + range 0x200000 0x1000000 if PAX_KERNEXEC && X86_PAE
11681 + range 0x400000 0x1000000 if PAX_KERNEXEC && !X86_PAE
11682 range 0x2000 0x1000000 if X86_32
11683 range 0x200000 0x1000000 if X86_64
11684 ---help---
11685 @@ -1812,9 +1817,10 @@ config DEBUG_HOTPLUG_CPU0
11686 If unsure, say N.
11687
11688 config COMPAT_VDSO
11689 - def_bool y
11690 + def_bool n
11691 prompt "Compat VDSO support"
11692 depends on X86_32 || IA32_EMULATION
11693 + depends on !PAX_PAGEEXEC && !PAX_SEGMEXEC && !PAX_KERNEXEC && !PAX_MEMORY_UDEREF
11694 ---help---
11695 Map the 32-bit VDSO to the predictable old-style address too.
11696
11697 diff --git a/arch/x86/Kconfig.cpu b/arch/x86/Kconfig.cpu
11698 index c026cca..14657ae 100644
11699 --- a/arch/x86/Kconfig.cpu
11700 +++ b/arch/x86/Kconfig.cpu
11701 @@ -319,7 +319,7 @@ config X86_PPRO_FENCE
11702
11703 config X86_F00F_BUG
11704 def_bool y
11705 - depends on M586MMX || M586TSC || M586 || M486
11706 + depends on (M586MMX || M586TSC || M586 || M486) && !PAX_KERNEXEC
11707
11708 config X86_INVD_BUG
11709 def_bool y
11710 @@ -327,7 +327,7 @@ config X86_INVD_BUG
11711
11712 config X86_ALIGNMENT_16
11713 def_bool y
11714 - depends on MWINCHIP3D || MWINCHIPC6 || MCYRIXIII || MELAN || MK6 || M586MMX || M586TSC || M586 || M486 || MVIAC3_2 || MGEODEGX1
11715 + depends on MWINCHIP3D || MWINCHIPC6 || MCYRIXIII || X86_ELAN || MK8 || MK7 || MK6 || MCORE2 || MPENTIUM4 || MPENTIUMIII || MPENTIUMII || M686 || M586MMX || M586TSC || M586 || M486 || MVIAC3_2 || MGEODEGX1
11716
11717 config X86_INTEL_USERCOPY
11718 def_bool y
11719 @@ -373,7 +373,7 @@ config X86_CMPXCHG64
11720 # generates cmov.
11721 config X86_CMOV
11722 def_bool y
11723 - depends on (MK8 || MK7 || MCORE2 || MPENTIUM4 || MPENTIUMM || MPENTIUMIII || MPENTIUMII || M686 || MVIAC3_2 || MVIAC7 || MCRUSOE || MEFFICEON || X86_64 || MATOM || MGEODE_LX)
11724 + depends on (MK8 || MK7 || MCORE2 || MPSC || MPENTIUM4 || MPENTIUMM || MPENTIUMIII || MPENTIUMII || M686 || MVIAC3_2 || MVIAC7 || MCRUSOE || MEFFICEON || X86_64 || MATOM || MGEODE_LX)
11725
11726 config X86_MINIMUM_CPU_FAMILY
11727 int
11728 diff --git a/arch/x86/Kconfig.debug b/arch/x86/Kconfig.debug
11729 index 78d91af..8ceb94b 100644
11730 --- a/arch/x86/Kconfig.debug
11731 +++ b/arch/x86/Kconfig.debug
11732 @@ -74,7 +74,7 @@ config X86_PTDUMP
11733 config DEBUG_RODATA
11734 bool "Write protect kernel read-only data structures"
11735 default y
11736 - depends on DEBUG_KERNEL
11737 + depends on DEBUG_KERNEL && BROKEN
11738 ---help---
11739 Mark the kernel read-only data as write-protected in the pagetables,
11740 in order to catch accidental (and incorrect) writes to such const
11741 @@ -92,7 +92,7 @@ config DEBUG_RODATA_TEST
11742
11743 config DEBUG_SET_MODULE_RONX
11744 bool "Set loadable kernel module data as NX and text as RO"
11745 - depends on MODULES
11746 + depends on MODULES && BROKEN
11747 ---help---
11748 This option helps catch unintended modifications to loadable
11749 kernel module's text and read-only data. It also prevents execution
11750 diff --git a/arch/x86/Makefile b/arch/x86/Makefile
11751 index 41250fb..863762e 100644
11752 --- a/arch/x86/Makefile
11753 +++ b/arch/x86/Makefile
11754 @@ -46,14 +46,12 @@ ifeq ($(CONFIG_X86_32),y)
11755 # CPU-specific tuning. Anything which can be shared with UML should go here.
11756 include $(srctree)/arch/x86/Makefile_32.cpu
11757 KBUILD_CFLAGS += $(cflags-y)
11758 -
11759 - # temporary until string.h is fixed
11760 - KBUILD_CFLAGS += -ffreestanding
11761 else
11762 BITS := 64
11763 UTS_MACHINE := x86_64
11764 CHECKFLAGS += -D__x86_64__ -m64
11765
11766 + biarch := $(call cc-option,-m64)
11767 KBUILD_AFLAGS += -m64
11768 KBUILD_CFLAGS += -m64
11769
11770 @@ -83,6 +81,9 @@ else
11771 KBUILD_CFLAGS += -maccumulate-outgoing-args
11772 endif
11773
11774 +# temporary until string.h is fixed
11775 +KBUILD_CFLAGS += -ffreestanding
11776 +
11777 ifdef CONFIG_CC_STACKPROTECTOR
11778 cc_has_sp := $(srctree)/scripts/gcc-x86_$(BITS)-has-stack-protector.sh
11779 ifeq ($(shell $(CONFIG_SHELL) $(cc_has_sp) $(CC) $(KBUILD_CPPFLAGS) $(biarch)),y)
11780 @@ -241,3 +242,12 @@ define archhelp
11781 echo ' FDINITRD=file initrd for the booted kernel'
11782 echo ' kvmconfig - Enable additional options for guest kernel support'
11783 endef
11784 +
11785 +define OLD_LD
11786 +
11787 +*** ${VERSION}.${PATCHLEVEL} PaX kernels no longer build correctly with old versions of binutils.
11788 +*** Please upgrade your binutils to 2.18 or newer
11789 +endef
11790 +
11791 +archprepare:
11792 + $(if $(LDFLAGS_BUILD_ID),,$(error $(OLD_LD)))
11793 diff --git a/arch/x86/boot/Makefile b/arch/x86/boot/Makefile
11794 index 379814b..add62ce 100644
11795 --- a/arch/x86/boot/Makefile
11796 +++ b/arch/x86/boot/Makefile
11797 @@ -65,6 +65,9 @@ KBUILD_CFLAGS := $(USERINCLUDE) -g -Os -D_SETUP -D__KERNEL__ \
11798 $(call cc-option, -fno-stack-protector) \
11799 $(call cc-option, -mpreferred-stack-boundary=2)
11800 KBUILD_CFLAGS += $(call cc-option, -m32)
11801 +ifdef CONSTIFY_PLUGIN
11802 +KBUILD_CFLAGS += -fplugin-arg-constify_plugin-no-constify
11803 +endif
11804 KBUILD_AFLAGS := $(KBUILD_CFLAGS) -D__ASSEMBLY__
11805 GCOV_PROFILE := n
11806
11807 diff --git a/arch/x86/boot/bitops.h b/arch/x86/boot/bitops.h
11808 index 878e4b9..20537ab 100644
11809 --- a/arch/x86/boot/bitops.h
11810 +++ b/arch/x86/boot/bitops.h
11811 @@ -26,7 +26,7 @@ static inline int variable_test_bit(int nr, const void *addr)
11812 u8 v;
11813 const u32 *p = (const u32 *)addr;
11814
11815 - asm("btl %2,%1; setc %0" : "=qm" (v) : "m" (*p), "Ir" (nr));
11816 + asm volatile("btl %2,%1; setc %0" : "=qm" (v) : "m" (*p), "Ir" (nr));
11817 return v;
11818 }
11819
11820 @@ -37,7 +37,7 @@ static inline int variable_test_bit(int nr, const void *addr)
11821
11822 static inline void set_bit(int nr, void *addr)
11823 {
11824 - asm("btsl %1,%0" : "+m" (*(u32 *)addr) : "Ir" (nr));
11825 + asm volatile("btsl %1,%0" : "+m" (*(u32 *)addr) : "Ir" (nr));
11826 }
11827
11828 #endif /* BOOT_BITOPS_H */
11829 diff --git a/arch/x86/boot/boot.h b/arch/x86/boot/boot.h
11830 index ef72bae..353a184 100644
11831 --- a/arch/x86/boot/boot.h
11832 +++ b/arch/x86/boot/boot.h
11833 @@ -85,7 +85,7 @@ static inline void io_delay(void)
11834 static inline u16 ds(void)
11835 {
11836 u16 seg;
11837 - asm("movw %%ds,%0" : "=rm" (seg));
11838 + asm volatile("movw %%ds,%0" : "=rm" (seg));
11839 return seg;
11840 }
11841
11842 @@ -181,7 +181,7 @@ static inline void wrgs32(u32 v, addr_t addr)
11843 static inline int memcmp(const void *s1, const void *s2, size_t len)
11844 {
11845 u8 diff;
11846 - asm("repe; cmpsb; setnz %0"
11847 + asm volatile("repe; cmpsb; setnz %0"
11848 : "=qm" (diff), "+D" (s1), "+S" (s2), "+c" (len));
11849 return diff;
11850 }
11851 diff --git a/arch/x86/boot/compressed/Makefile b/arch/x86/boot/compressed/Makefile
11852 index dcd90df..c830d7d 100644
11853 --- a/arch/x86/boot/compressed/Makefile
11854 +++ b/arch/x86/boot/compressed/Makefile
11855 @@ -15,6 +15,9 @@ cflags-$(CONFIG_X86_64) := -mcmodel=small
11856 KBUILD_CFLAGS += $(cflags-y)
11857 KBUILD_CFLAGS += $(call cc-option,-ffreestanding)
11858 KBUILD_CFLAGS += $(call cc-option,-fno-stack-protector)
11859 +ifdef CONSTIFY_PLUGIN
11860 +KBUILD_CFLAGS += -fplugin-arg-constify_plugin-no-constify
11861 +endif
11862
11863 KBUILD_AFLAGS := $(KBUILD_CFLAGS) -D__ASSEMBLY__
11864 GCOV_PROFILE := n
11865 diff --git a/arch/x86/boot/compressed/eboot.c b/arch/x86/boot/compressed/eboot.c
11866 index b7388a4..03844ec 100644
11867 --- a/arch/x86/boot/compressed/eboot.c
11868 +++ b/arch/x86/boot/compressed/eboot.c
11869 @@ -150,7 +150,6 @@ again:
11870 *addr = max_addr;
11871 }
11872
11873 -free_pool:
11874 efi_call_phys1(sys_table->boottime->free_pool, map);
11875
11876 fail:
11877 @@ -214,7 +213,6 @@ static efi_status_t low_alloc(unsigned long size, unsigned long align,
11878 if (i == map_size / desc_size)
11879 status = EFI_NOT_FOUND;
11880
11881 -free_pool:
11882 efi_call_phys1(sys_table->boottime->free_pool, map);
11883 fail:
11884 return status;
11885 diff --git a/arch/x86/boot/compressed/efi_stub_32.S b/arch/x86/boot/compressed/efi_stub_32.S
11886 index a53440e..c3dbf1e 100644
11887 --- a/arch/x86/boot/compressed/efi_stub_32.S
11888 +++ b/arch/x86/boot/compressed/efi_stub_32.S
11889 @@ -46,16 +46,13 @@ ENTRY(efi_call_phys)
11890 * parameter 2, ..., param n. To make things easy, we save the return
11891 * address of efi_call_phys in a global variable.
11892 */
11893 - popl %ecx
11894 - movl %ecx, saved_return_addr(%edx)
11895 - /* get the function pointer into ECX*/
11896 - popl %ecx
11897 - movl %ecx, efi_rt_function_ptr(%edx)
11898 + popl saved_return_addr(%edx)
11899 + popl efi_rt_function_ptr(%edx)
11900
11901 /*
11902 * 3. Call the physical function.
11903 */
11904 - call *%ecx
11905 + call *efi_rt_function_ptr(%edx)
11906
11907 /*
11908 * 4. Balance the stack. And because EAX contain the return value,
11909 @@ -67,15 +64,12 @@ ENTRY(efi_call_phys)
11910 1: popl %edx
11911 subl $1b, %edx
11912
11913 - movl efi_rt_function_ptr(%edx), %ecx
11914 - pushl %ecx
11915 + pushl efi_rt_function_ptr(%edx)
11916
11917 /*
11918 * 10. Push the saved return address onto the stack and return.
11919 */
11920 - movl saved_return_addr(%edx), %ecx
11921 - pushl %ecx
11922 - ret
11923 + jmpl *saved_return_addr(%edx)
11924 ENDPROC(efi_call_phys)
11925 .previous
11926
11927 diff --git a/arch/x86/boot/compressed/head_32.S b/arch/x86/boot/compressed/head_32.S
11928 index 5d6f689..9d06730 100644
11929 --- a/arch/x86/boot/compressed/head_32.S
11930 +++ b/arch/x86/boot/compressed/head_32.S
11931 @@ -118,7 +118,7 @@ preferred_addr:
11932 notl %eax
11933 andl %eax, %ebx
11934 #else
11935 - movl $LOAD_PHYSICAL_ADDR, %ebx
11936 + movl $____LOAD_PHYSICAL_ADDR, %ebx
11937 #endif
11938
11939 /* Target address to relocate to for decompression */
11940 diff --git a/arch/x86/boot/compressed/head_64.S b/arch/x86/boot/compressed/head_64.S
11941 index c337422..2c5be72 100644
11942 --- a/arch/x86/boot/compressed/head_64.S
11943 +++ b/arch/x86/boot/compressed/head_64.S
11944 @@ -95,7 +95,7 @@ ENTRY(startup_32)
11945 notl %eax
11946 andl %eax, %ebx
11947 #else
11948 - movl $LOAD_PHYSICAL_ADDR, %ebx
11949 + movl $____LOAD_PHYSICAL_ADDR, %ebx
11950 #endif
11951
11952 /* Target address to relocate to for decompression */
11953 @@ -270,7 +270,7 @@ preferred_addr:
11954 notq %rax
11955 andq %rax, %rbp
11956 #else
11957 - movq $LOAD_PHYSICAL_ADDR, %rbp
11958 + movq $____LOAD_PHYSICAL_ADDR, %rbp
11959 #endif
11960
11961 /* Target address to relocate to for decompression */
11962 @@ -362,8 +362,8 @@ gdt:
11963 .long gdt
11964 .word 0
11965 .quad 0x0000000000000000 /* NULL descriptor */
11966 - .quad 0x00af9a000000ffff /* __KERNEL_CS */
11967 - .quad 0x00cf92000000ffff /* __KERNEL_DS */
11968 + .quad 0x00af9b000000ffff /* __KERNEL_CS */
11969 + .quad 0x00cf93000000ffff /* __KERNEL_DS */
11970 .quad 0x0080890000000000 /* TS descriptor */
11971 .quad 0x0000000000000000 /* TS continued */
11972 gdt_end:
11973 diff --git a/arch/x86/boot/compressed/misc.c b/arch/x86/boot/compressed/misc.c
11974 index 434f077..b6b4b38 100644
11975 --- a/arch/x86/boot/compressed/misc.c
11976 +++ b/arch/x86/boot/compressed/misc.c
11977 @@ -283,7 +283,7 @@ static void handle_relocations(void *output, unsigned long output_len)
11978 * Calculate the delta between where vmlinux was linked to load
11979 * and where it was actually loaded.
11980 */
11981 - delta = min_addr - LOAD_PHYSICAL_ADDR;
11982 + delta = min_addr - ____LOAD_PHYSICAL_ADDR;
11983 if (!delta) {
11984 debug_putstr("No relocation needed... ");
11985 return;
11986 @@ -380,7 +380,7 @@ static void parse_elf(void *output)
11987 case PT_LOAD:
11988 #ifdef CONFIG_RELOCATABLE
11989 dest = output;
11990 - dest += (phdr->p_paddr - LOAD_PHYSICAL_ADDR);
11991 + dest += (phdr->p_paddr - ____LOAD_PHYSICAL_ADDR);
11992 #else
11993 dest = (void *)(phdr->p_paddr);
11994 #endif
11995 @@ -432,7 +432,7 @@ asmlinkage void decompress_kernel(void *rmode, memptr heap,
11996 error("Destination address too large");
11997 #endif
11998 #ifndef CONFIG_RELOCATABLE
11999 - if ((unsigned long)output != LOAD_PHYSICAL_ADDR)
12000 + if ((unsigned long)output != ____LOAD_PHYSICAL_ADDR)
12001 error("Wrong destination address");
12002 #endif
12003
12004 diff --git a/arch/x86/boot/cpucheck.c b/arch/x86/boot/cpucheck.c
12005 index 4d3ff03..e4972ff 100644
12006 --- a/arch/x86/boot/cpucheck.c
12007 +++ b/arch/x86/boot/cpucheck.c
12008 @@ -74,7 +74,7 @@ static int has_fpu(void)
12009 u16 fcw = -1, fsw = -1;
12010 u32 cr0;
12011
12012 - asm("movl %%cr0,%0" : "=r" (cr0));
12013 + asm volatile("movl %%cr0,%0" : "=r" (cr0));
12014 if (cr0 & (X86_CR0_EM|X86_CR0_TS)) {
12015 cr0 &= ~(X86_CR0_EM|X86_CR0_TS);
12016 asm volatile("movl %0,%%cr0" : : "r" (cr0));
12017 @@ -90,7 +90,7 @@ static int has_eflag(u32 mask)
12018 {
12019 u32 f0, f1;
12020
12021 - asm("pushfl ; "
12022 + asm volatile("pushfl ; "
12023 "pushfl ; "
12024 "popl %0 ; "
12025 "movl %0,%1 ; "
12026 @@ -115,7 +115,7 @@ static void get_flags(void)
12027 set_bit(X86_FEATURE_FPU, cpu.flags);
12028
12029 if (has_eflag(X86_EFLAGS_ID)) {
12030 - asm("cpuid"
12031 + asm volatile("cpuid"
12032 : "=a" (max_intel_level),
12033 "=b" (cpu_vendor[0]),
12034 "=d" (cpu_vendor[1]),
12035 @@ -124,7 +124,7 @@ static void get_flags(void)
12036
12037 if (max_intel_level >= 0x00000001 &&
12038 max_intel_level <= 0x0000ffff) {
12039 - asm("cpuid"
12040 + asm volatile("cpuid"
12041 : "=a" (tfms),
12042 "=c" (cpu.flags[4]),
12043 "=d" (cpu.flags[0])
12044 @@ -136,7 +136,7 @@ static void get_flags(void)
12045 cpu.model += ((tfms >> 16) & 0xf) << 4;
12046 }
12047
12048 - asm("cpuid"
12049 + asm volatile("cpuid"
12050 : "=a" (max_amd_level)
12051 : "a" (0x80000000)
12052 : "ebx", "ecx", "edx");
12053 @@ -144,7 +144,7 @@ static void get_flags(void)
12054 if (max_amd_level >= 0x80000001 &&
12055 max_amd_level <= 0x8000ffff) {
12056 u32 eax = 0x80000001;
12057 - asm("cpuid"
12058 + asm volatile("cpuid"
12059 : "+a" (eax),
12060 "=c" (cpu.flags[6]),
12061 "=d" (cpu.flags[1])
12062 @@ -203,9 +203,9 @@ int check_cpu(int *cpu_level_ptr, int *req_level_ptr, u32 **err_flags_ptr)
12063 u32 ecx = MSR_K7_HWCR;
12064 u32 eax, edx;
12065
12066 - asm("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
12067 + asm volatile("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
12068 eax &= ~(1 << 15);
12069 - asm("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
12070 + asm volatile("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
12071
12072 get_flags(); /* Make sure it really did something */
12073 err = check_flags();
12074 @@ -218,9 +218,9 @@ int check_cpu(int *cpu_level_ptr, int *req_level_ptr, u32 **err_flags_ptr)
12075 u32 ecx = MSR_VIA_FCR;
12076 u32 eax, edx;
12077
12078 - asm("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
12079 + asm volatile("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
12080 eax |= (1<<1)|(1<<7);
12081 - asm("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
12082 + asm volatile("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
12083
12084 set_bit(X86_FEATURE_CX8, cpu.flags);
12085 err = check_flags();
12086 @@ -231,12 +231,12 @@ int check_cpu(int *cpu_level_ptr, int *req_level_ptr, u32 **err_flags_ptr)
12087 u32 eax, edx;
12088 u32 level = 1;
12089
12090 - asm("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
12091 - asm("wrmsr" : : "a" (~0), "d" (edx), "c" (ecx));
12092 - asm("cpuid"
12093 + asm volatile("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
12094 + asm volatile("wrmsr" : : "a" (~0), "d" (edx), "c" (ecx));
12095 + asm volatile("cpuid"
12096 : "+a" (level), "=d" (cpu.flags[0])
12097 : : "ecx", "ebx");
12098 - asm("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
12099 + asm volatile("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
12100
12101 err = check_flags();
12102 }
12103 diff --git a/arch/x86/boot/header.S b/arch/x86/boot/header.S
12104 index 9ec06a1..2c25e79 100644
12105 --- a/arch/x86/boot/header.S
12106 +++ b/arch/x86/boot/header.S
12107 @@ -409,10 +409,14 @@ setup_data: .quad 0 # 64-bit physical pointer to
12108 # single linked list of
12109 # struct setup_data
12110
12111 -pref_address: .quad LOAD_PHYSICAL_ADDR # preferred load addr
12112 +pref_address: .quad ____LOAD_PHYSICAL_ADDR # preferred load addr
12113
12114 #define ZO_INIT_SIZE (ZO__end - ZO_startup_32 + ZO_z_extract_offset)
12115 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
12116 +#define VO_INIT_SIZE (VO__end - VO__text - __PAGE_OFFSET - ____LOAD_PHYSICAL_ADDR)
12117 +#else
12118 #define VO_INIT_SIZE (VO__end - VO__text)
12119 +#endif
12120 #if ZO_INIT_SIZE > VO_INIT_SIZE
12121 #define INIT_SIZE ZO_INIT_SIZE
12122 #else
12123 diff --git a/arch/x86/boot/memory.c b/arch/x86/boot/memory.c
12124 index db75d07..8e6d0af 100644
12125 --- a/arch/x86/boot/memory.c
12126 +++ b/arch/x86/boot/memory.c
12127 @@ -19,7 +19,7 @@
12128
12129 static int detect_memory_e820(void)
12130 {
12131 - int count = 0;
12132 + unsigned int count = 0;
12133 struct biosregs ireg, oreg;
12134 struct e820entry *desc = boot_params.e820_map;
12135 static struct e820entry buf; /* static so it is zeroed */
12136 diff --git a/arch/x86/boot/video-vesa.c b/arch/x86/boot/video-vesa.c
12137 index 11e8c6e..fdbb1ed 100644
12138 --- a/arch/x86/boot/video-vesa.c
12139 +++ b/arch/x86/boot/video-vesa.c
12140 @@ -200,6 +200,7 @@ static void vesa_store_pm_info(void)
12141
12142 boot_params.screen_info.vesapm_seg = oreg.es;
12143 boot_params.screen_info.vesapm_off = oreg.di;
12144 + boot_params.screen_info.vesapm_size = oreg.cx;
12145 }
12146
12147 /*
12148 diff --git a/arch/x86/boot/video.c b/arch/x86/boot/video.c
12149 index 43eda28..5ab5fdb 100644
12150 --- a/arch/x86/boot/video.c
12151 +++ b/arch/x86/boot/video.c
12152 @@ -96,7 +96,7 @@ static void store_mode_params(void)
12153 static unsigned int get_entry(void)
12154 {
12155 char entry_buf[4];
12156 - int i, len = 0;
12157 + unsigned int i, len = 0;
12158 int key;
12159 unsigned int v;
12160
12161 diff --git a/arch/x86/crypto/aes-x86_64-asm_64.S b/arch/x86/crypto/aes-x86_64-asm_64.S
12162 index 9105655..5e37f27 100644
12163 --- a/arch/x86/crypto/aes-x86_64-asm_64.S
12164 +++ b/arch/x86/crypto/aes-x86_64-asm_64.S
12165 @@ -8,6 +8,8 @@
12166 * including this sentence is retained in full.
12167 */
12168
12169 +#include <asm/alternative-asm.h>
12170 +
12171 .extern crypto_ft_tab
12172 .extern crypto_it_tab
12173 .extern crypto_fl_tab
12174 @@ -70,6 +72,8 @@
12175 je B192; \
12176 leaq 32(r9),r9;
12177
12178 +#define ret pax_force_retaddr 0, 1; ret
12179 +
12180 #define epilogue(FUNC,r1,r2,r3,r4,r5,r6,r7,r8,r9) \
12181 movq r1,r2; \
12182 movq r3,r4; \
12183 diff --git a/arch/x86/crypto/aesni-intel_asm.S b/arch/x86/crypto/aesni-intel_asm.S
12184 index 477e9d7..3ab339f 100644
12185 --- a/arch/x86/crypto/aesni-intel_asm.S
12186 +++ b/arch/x86/crypto/aesni-intel_asm.S
12187 @@ -31,6 +31,7 @@
12188
12189 #include <linux/linkage.h>
12190 #include <asm/inst.h>
12191 +#include <asm/alternative-asm.h>
12192
12193 #ifdef __x86_64__
12194 .data
12195 @@ -1441,6 +1442,7 @@ _return_T_done_decrypt:
12196 pop %r14
12197 pop %r13
12198 pop %r12
12199 + pax_force_retaddr 0, 1
12200 ret
12201 ENDPROC(aesni_gcm_dec)
12202
12203 @@ -1705,6 +1707,7 @@ _return_T_done_encrypt:
12204 pop %r14
12205 pop %r13
12206 pop %r12
12207 + pax_force_retaddr 0, 1
12208 ret
12209 ENDPROC(aesni_gcm_enc)
12210
12211 @@ -1722,6 +1725,7 @@ _key_expansion_256a:
12212 pxor %xmm1, %xmm0
12213 movaps %xmm0, (TKEYP)
12214 add $0x10, TKEYP
12215 + pax_force_retaddr_bts
12216 ret
12217 ENDPROC(_key_expansion_128)
12218 ENDPROC(_key_expansion_256a)
12219 @@ -1748,6 +1752,7 @@ _key_expansion_192a:
12220 shufps $0b01001110, %xmm2, %xmm1
12221 movaps %xmm1, 0x10(TKEYP)
12222 add $0x20, TKEYP
12223 + pax_force_retaddr_bts
12224 ret
12225 ENDPROC(_key_expansion_192a)
12226
12227 @@ -1768,6 +1773,7 @@ _key_expansion_192b:
12228
12229 movaps %xmm0, (TKEYP)
12230 add $0x10, TKEYP
12231 + pax_force_retaddr_bts
12232 ret
12233 ENDPROC(_key_expansion_192b)
12234
12235 @@ -1781,6 +1787,7 @@ _key_expansion_256b:
12236 pxor %xmm1, %xmm2
12237 movaps %xmm2, (TKEYP)
12238 add $0x10, TKEYP
12239 + pax_force_retaddr_bts
12240 ret
12241 ENDPROC(_key_expansion_256b)
12242
12243 @@ -1894,6 +1901,7 @@ ENTRY(aesni_set_key)
12244 #ifndef __x86_64__
12245 popl KEYP
12246 #endif
12247 + pax_force_retaddr 0, 1
12248 ret
12249 ENDPROC(aesni_set_key)
12250
12251 @@ -1916,6 +1924,7 @@ ENTRY(aesni_enc)
12252 popl KLEN
12253 popl KEYP
12254 #endif
12255 + pax_force_retaddr 0, 1
12256 ret
12257 ENDPROC(aesni_enc)
12258
12259 @@ -1974,6 +1983,7 @@ _aesni_enc1:
12260 AESENC KEY STATE
12261 movaps 0x70(TKEYP), KEY
12262 AESENCLAST KEY STATE
12263 + pax_force_retaddr_bts
12264 ret
12265 ENDPROC(_aesni_enc1)
12266
12267 @@ -2083,6 +2093,7 @@ _aesni_enc4:
12268 AESENCLAST KEY STATE2
12269 AESENCLAST KEY STATE3
12270 AESENCLAST KEY STATE4
12271 + pax_force_retaddr_bts
12272 ret
12273 ENDPROC(_aesni_enc4)
12274
12275 @@ -2106,6 +2117,7 @@ ENTRY(aesni_dec)
12276 popl KLEN
12277 popl KEYP
12278 #endif
12279 + pax_force_retaddr 0, 1
12280 ret
12281 ENDPROC(aesni_dec)
12282
12283 @@ -2164,6 +2176,7 @@ _aesni_dec1:
12284 AESDEC KEY STATE
12285 movaps 0x70(TKEYP), KEY
12286 AESDECLAST KEY STATE
12287 + pax_force_retaddr_bts
12288 ret
12289 ENDPROC(_aesni_dec1)
12290
12291 @@ -2273,6 +2286,7 @@ _aesni_dec4:
12292 AESDECLAST KEY STATE2
12293 AESDECLAST KEY STATE3
12294 AESDECLAST KEY STATE4
12295 + pax_force_retaddr_bts
12296 ret
12297 ENDPROC(_aesni_dec4)
12298
12299 @@ -2331,6 +2345,7 @@ ENTRY(aesni_ecb_enc)
12300 popl KEYP
12301 popl LEN
12302 #endif
12303 + pax_force_retaddr 0, 1
12304 ret
12305 ENDPROC(aesni_ecb_enc)
12306
12307 @@ -2390,6 +2405,7 @@ ENTRY(aesni_ecb_dec)
12308 popl KEYP
12309 popl LEN
12310 #endif
12311 + pax_force_retaddr 0, 1
12312 ret
12313 ENDPROC(aesni_ecb_dec)
12314
12315 @@ -2432,6 +2448,7 @@ ENTRY(aesni_cbc_enc)
12316 popl LEN
12317 popl IVP
12318 #endif
12319 + pax_force_retaddr 0, 1
12320 ret
12321 ENDPROC(aesni_cbc_enc)
12322
12323 @@ -2523,6 +2540,7 @@ ENTRY(aesni_cbc_dec)
12324 popl LEN
12325 popl IVP
12326 #endif
12327 + pax_force_retaddr 0, 1
12328 ret
12329 ENDPROC(aesni_cbc_dec)
12330
12331 @@ -2550,6 +2568,7 @@ _aesni_inc_init:
12332 mov $1, TCTR_LOW
12333 MOVQ_R64_XMM TCTR_LOW INC
12334 MOVQ_R64_XMM CTR TCTR_LOW
12335 + pax_force_retaddr_bts
12336 ret
12337 ENDPROC(_aesni_inc_init)
12338
12339 @@ -2579,6 +2598,7 @@ _aesni_inc:
12340 .Linc_low:
12341 movaps CTR, IV
12342 PSHUFB_XMM BSWAP_MASK IV
12343 + pax_force_retaddr_bts
12344 ret
12345 ENDPROC(_aesni_inc)
12346
12347 @@ -2640,6 +2660,7 @@ ENTRY(aesni_ctr_enc)
12348 .Lctr_enc_ret:
12349 movups IV, (IVP)
12350 .Lctr_enc_just_ret:
12351 + pax_force_retaddr 0, 1
12352 ret
12353 ENDPROC(aesni_ctr_enc)
12354
12355 @@ -2766,6 +2787,7 @@ ENTRY(aesni_xts_crypt8)
12356 pxor INC, STATE4
12357 movdqu STATE4, 0x70(OUTP)
12358
12359 + pax_force_retaddr 0, 1
12360 ret
12361 ENDPROC(aesni_xts_crypt8)
12362
12363 diff --git a/arch/x86/crypto/blowfish-x86_64-asm_64.S b/arch/x86/crypto/blowfish-x86_64-asm_64.S
12364 index 246c670..4d1ed00 100644
12365 --- a/arch/x86/crypto/blowfish-x86_64-asm_64.S
12366 +++ b/arch/x86/crypto/blowfish-x86_64-asm_64.S
12367 @@ -21,6 +21,7 @@
12368 */
12369
12370 #include <linux/linkage.h>
12371 +#include <asm/alternative-asm.h>
12372
12373 .file "blowfish-x86_64-asm.S"
12374 .text
12375 @@ -149,9 +150,11 @@ ENTRY(__blowfish_enc_blk)
12376 jnz .L__enc_xor;
12377
12378 write_block();
12379 + pax_force_retaddr 0, 1
12380 ret;
12381 .L__enc_xor:
12382 xor_block();
12383 + pax_force_retaddr 0, 1
12384 ret;
12385 ENDPROC(__blowfish_enc_blk)
12386
12387 @@ -183,6 +186,7 @@ ENTRY(blowfish_dec_blk)
12388
12389 movq %r11, %rbp;
12390
12391 + pax_force_retaddr 0, 1
12392 ret;
12393 ENDPROC(blowfish_dec_blk)
12394
12395 @@ -334,6 +338,7 @@ ENTRY(__blowfish_enc_blk_4way)
12396
12397 popq %rbx;
12398 popq %rbp;
12399 + pax_force_retaddr 0, 1
12400 ret;
12401
12402 .L__enc_xor4:
12403 @@ -341,6 +346,7 @@ ENTRY(__blowfish_enc_blk_4way)
12404
12405 popq %rbx;
12406 popq %rbp;
12407 + pax_force_retaddr 0, 1
12408 ret;
12409 ENDPROC(__blowfish_enc_blk_4way)
12410
12411 @@ -375,5 +381,6 @@ ENTRY(blowfish_dec_blk_4way)
12412 popq %rbx;
12413 popq %rbp;
12414
12415 + pax_force_retaddr 0, 1
12416 ret;
12417 ENDPROC(blowfish_dec_blk_4way)
12418 diff --git a/arch/x86/crypto/camellia-aesni-avx-asm_64.S b/arch/x86/crypto/camellia-aesni-avx-asm_64.S
12419 index ce71f92..2dd5b1e 100644
12420 --- a/arch/x86/crypto/camellia-aesni-avx-asm_64.S
12421 +++ b/arch/x86/crypto/camellia-aesni-avx-asm_64.S
12422 @@ -16,6 +16,7 @@
12423 */
12424
12425 #include <linux/linkage.h>
12426 +#include <asm/alternative-asm.h>
12427
12428 #define CAMELLIA_TABLE_BYTE_LEN 272
12429
12430 @@ -191,6 +192,7 @@ roundsm16_x0_x1_x2_x3_x4_x5_x6_x7_y0_y1_y2_y3_y4_y5_y6_y7_cd:
12431 roundsm16(%xmm0, %xmm1, %xmm2, %xmm3, %xmm4, %xmm5, %xmm6, %xmm7,
12432 %xmm8, %xmm9, %xmm10, %xmm11, %xmm12, %xmm13, %xmm14, %xmm15,
12433 %rcx, (%r9));
12434 + pax_force_retaddr_bts
12435 ret;
12436 ENDPROC(roundsm16_x0_x1_x2_x3_x4_x5_x6_x7_y0_y1_y2_y3_y4_y5_y6_y7_cd)
12437
12438 @@ -199,6 +201,7 @@ roundsm16_x4_x5_x6_x7_x0_x1_x2_x3_y4_y5_y6_y7_y0_y1_y2_y3_ab:
12439 roundsm16(%xmm4, %xmm5, %xmm6, %xmm7, %xmm0, %xmm1, %xmm2, %xmm3,
12440 %xmm12, %xmm13, %xmm14, %xmm15, %xmm8, %xmm9, %xmm10, %xmm11,
12441 %rax, (%r9));
12442 + pax_force_retaddr_bts
12443 ret;
12444 ENDPROC(roundsm16_x4_x5_x6_x7_x0_x1_x2_x3_y4_y5_y6_y7_y0_y1_y2_y3_ab)
12445
12446 @@ -780,6 +783,7 @@ __camellia_enc_blk16:
12447 %xmm8, %xmm9, %xmm10, %xmm11, %xmm12, %xmm13, %xmm14,
12448 %xmm15, (key_table)(CTX, %r8, 8), (%rax), 1 * 16(%rax));
12449
12450 + pax_force_retaddr_bts
12451 ret;
12452
12453 .align 8
12454 @@ -865,6 +869,7 @@ __camellia_dec_blk16:
12455 %xmm8, %xmm9, %xmm10, %xmm11, %xmm12, %xmm13, %xmm14,
12456 %xmm15, (key_table)(CTX), (%rax), 1 * 16(%rax));
12457
12458 + pax_force_retaddr_bts
12459 ret;
12460
12461 .align 8
12462 @@ -904,6 +909,7 @@ ENTRY(camellia_ecb_enc_16way)
12463 %xmm15, %xmm14, %xmm13, %xmm12, %xmm11, %xmm10, %xmm9,
12464 %xmm8, %rsi);
12465
12466 + pax_force_retaddr 0, 1
12467 ret;
12468 ENDPROC(camellia_ecb_enc_16way)
12469
12470 @@ -932,6 +938,7 @@ ENTRY(camellia_ecb_dec_16way)
12471 %xmm15, %xmm14, %xmm13, %xmm12, %xmm11, %xmm10, %xmm9,
12472 %xmm8, %rsi);
12473
12474 + pax_force_retaddr 0, 1
12475 ret;
12476 ENDPROC(camellia_ecb_dec_16way)
12477
12478 @@ -981,6 +988,7 @@ ENTRY(camellia_cbc_dec_16way)
12479 %xmm15, %xmm14, %xmm13, %xmm12, %xmm11, %xmm10, %xmm9,
12480 %xmm8, %rsi);
12481
12482 + pax_force_retaddr 0, 1
12483 ret;
12484 ENDPROC(camellia_cbc_dec_16way)
12485
12486 @@ -1092,6 +1100,7 @@ ENTRY(camellia_ctr_16way)
12487 %xmm15, %xmm14, %xmm13, %xmm12, %xmm11, %xmm10, %xmm9,
12488 %xmm8, %rsi);
12489
12490 + pax_force_retaddr 0, 1
12491 ret;
12492 ENDPROC(camellia_ctr_16way)
12493
12494 @@ -1234,6 +1243,7 @@ camellia_xts_crypt_16way:
12495 %xmm15, %xmm14, %xmm13, %xmm12, %xmm11, %xmm10, %xmm9,
12496 %xmm8, %rsi);
12497
12498 + pax_force_retaddr 0, 1
12499 ret;
12500 ENDPROC(camellia_xts_crypt_16way)
12501
12502 diff --git a/arch/x86/crypto/camellia-aesni-avx2-asm_64.S b/arch/x86/crypto/camellia-aesni-avx2-asm_64.S
12503 index 0e0b886..8fc756a 100644
12504 --- a/arch/x86/crypto/camellia-aesni-avx2-asm_64.S
12505 +++ b/arch/x86/crypto/camellia-aesni-avx2-asm_64.S
12506 @@ -11,6 +11,7 @@
12507 */
12508
12509 #include <linux/linkage.h>
12510 +#include <asm/alternative-asm.h>
12511
12512 #define CAMELLIA_TABLE_BYTE_LEN 272
12513
12514 @@ -230,6 +231,7 @@ roundsm32_x0_x1_x2_x3_x4_x5_x6_x7_y0_y1_y2_y3_y4_y5_y6_y7_cd:
12515 roundsm32(%ymm0, %ymm1, %ymm2, %ymm3, %ymm4, %ymm5, %ymm6, %ymm7,
12516 %ymm8, %ymm9, %ymm10, %ymm11, %ymm12, %ymm13, %ymm14, %ymm15,
12517 %rcx, (%r9));
12518 + pax_force_retaddr_bts
12519 ret;
12520 ENDPROC(roundsm32_x0_x1_x2_x3_x4_x5_x6_x7_y0_y1_y2_y3_y4_y5_y6_y7_cd)
12521
12522 @@ -238,6 +240,7 @@ roundsm32_x4_x5_x6_x7_x0_x1_x2_x3_y4_y5_y6_y7_y0_y1_y2_y3_ab:
12523 roundsm32(%ymm4, %ymm5, %ymm6, %ymm7, %ymm0, %ymm1, %ymm2, %ymm3,
12524 %ymm12, %ymm13, %ymm14, %ymm15, %ymm8, %ymm9, %ymm10, %ymm11,
12525 %rax, (%r9));
12526 + pax_force_retaddr_bts
12527 ret;
12528 ENDPROC(roundsm32_x4_x5_x6_x7_x0_x1_x2_x3_y4_y5_y6_y7_y0_y1_y2_y3_ab)
12529
12530 @@ -820,6 +823,7 @@ __camellia_enc_blk32:
12531 %ymm8, %ymm9, %ymm10, %ymm11, %ymm12, %ymm13, %ymm14,
12532 %ymm15, (key_table)(CTX, %r8, 8), (%rax), 1 * 32(%rax));
12533
12534 + pax_force_retaddr_bts
12535 ret;
12536
12537 .align 8
12538 @@ -905,6 +909,7 @@ __camellia_dec_blk32:
12539 %ymm8, %ymm9, %ymm10, %ymm11, %ymm12, %ymm13, %ymm14,
12540 %ymm15, (key_table)(CTX), (%rax), 1 * 32(%rax));
12541
12542 + pax_force_retaddr_bts
12543 ret;
12544
12545 .align 8
12546 @@ -948,6 +953,7 @@ ENTRY(camellia_ecb_enc_32way)
12547
12548 vzeroupper;
12549
12550 + pax_force_retaddr 0, 1
12551 ret;
12552 ENDPROC(camellia_ecb_enc_32way)
12553
12554 @@ -980,6 +986,7 @@ ENTRY(camellia_ecb_dec_32way)
12555
12556 vzeroupper;
12557
12558 + pax_force_retaddr 0, 1
12559 ret;
12560 ENDPROC(camellia_ecb_dec_32way)
12561
12562 @@ -1046,6 +1053,7 @@ ENTRY(camellia_cbc_dec_32way)
12563
12564 vzeroupper;
12565
12566 + pax_force_retaddr 0, 1
12567 ret;
12568 ENDPROC(camellia_cbc_dec_32way)
12569
12570 @@ -1184,6 +1192,7 @@ ENTRY(camellia_ctr_32way)
12571
12572 vzeroupper;
12573
12574 + pax_force_retaddr 0, 1
12575 ret;
12576 ENDPROC(camellia_ctr_32way)
12577
12578 @@ -1349,6 +1358,7 @@ camellia_xts_crypt_32way:
12579
12580 vzeroupper;
12581
12582 + pax_force_retaddr 0, 1
12583 ret;
12584 ENDPROC(camellia_xts_crypt_32way)
12585
12586 diff --git a/arch/x86/crypto/camellia-x86_64-asm_64.S b/arch/x86/crypto/camellia-x86_64-asm_64.S
12587 index 310319c..ce174a4 100644
12588 --- a/arch/x86/crypto/camellia-x86_64-asm_64.S
12589 +++ b/arch/x86/crypto/camellia-x86_64-asm_64.S
12590 @@ -21,6 +21,7 @@
12591 */
12592
12593 #include <linux/linkage.h>
12594 +#include <asm/alternative-asm.h>
12595
12596 .file "camellia-x86_64-asm_64.S"
12597 .text
12598 @@ -228,12 +229,14 @@ ENTRY(__camellia_enc_blk)
12599 enc_outunpack(mov, RT1);
12600
12601 movq RRBP, %rbp;
12602 + pax_force_retaddr 0, 1
12603 ret;
12604
12605 .L__enc_xor:
12606 enc_outunpack(xor, RT1);
12607
12608 movq RRBP, %rbp;
12609 + pax_force_retaddr 0, 1
12610 ret;
12611 ENDPROC(__camellia_enc_blk)
12612
12613 @@ -272,6 +275,7 @@ ENTRY(camellia_dec_blk)
12614 dec_outunpack();
12615
12616 movq RRBP, %rbp;
12617 + pax_force_retaddr 0, 1
12618 ret;
12619 ENDPROC(camellia_dec_blk)
12620
12621 @@ -463,6 +467,7 @@ ENTRY(__camellia_enc_blk_2way)
12622
12623 movq RRBP, %rbp;
12624 popq %rbx;
12625 + pax_force_retaddr 0, 1
12626 ret;
12627
12628 .L__enc2_xor:
12629 @@ -470,6 +475,7 @@ ENTRY(__camellia_enc_blk_2way)
12630
12631 movq RRBP, %rbp;
12632 popq %rbx;
12633 + pax_force_retaddr 0, 1
12634 ret;
12635 ENDPROC(__camellia_enc_blk_2way)
12636
12637 @@ -510,5 +516,6 @@ ENTRY(camellia_dec_blk_2way)
12638
12639 movq RRBP, %rbp;
12640 movq RXOR, %rbx;
12641 + pax_force_retaddr 0, 1
12642 ret;
12643 ENDPROC(camellia_dec_blk_2way)
12644 diff --git a/arch/x86/crypto/cast5-avx-x86_64-asm_64.S b/arch/x86/crypto/cast5-avx-x86_64-asm_64.S
12645 index c35fd5d..c1ee236 100644
12646 --- a/arch/x86/crypto/cast5-avx-x86_64-asm_64.S
12647 +++ b/arch/x86/crypto/cast5-avx-x86_64-asm_64.S
12648 @@ -24,6 +24,7 @@
12649 */
12650
12651 #include <linux/linkage.h>
12652 +#include <asm/alternative-asm.h>
12653
12654 .file "cast5-avx-x86_64-asm_64.S"
12655
12656 @@ -281,6 +282,7 @@ __cast5_enc_blk16:
12657 outunpack_blocks(RR3, RL3, RTMP, RX, RKM);
12658 outunpack_blocks(RR4, RL4, RTMP, RX, RKM);
12659
12660 + pax_force_retaddr 0, 1
12661 ret;
12662 ENDPROC(__cast5_enc_blk16)
12663
12664 @@ -352,6 +354,7 @@ __cast5_dec_blk16:
12665 outunpack_blocks(RR3, RL3, RTMP, RX, RKM);
12666 outunpack_blocks(RR4, RL4, RTMP, RX, RKM);
12667
12668 + pax_force_retaddr 0, 1
12669 ret;
12670
12671 .L__skip_dec:
12672 @@ -388,6 +391,7 @@ ENTRY(cast5_ecb_enc_16way)
12673 vmovdqu RR4, (6*4*4)(%r11);
12674 vmovdqu RL4, (7*4*4)(%r11);
12675
12676 + pax_force_retaddr
12677 ret;
12678 ENDPROC(cast5_ecb_enc_16way)
12679
12680 @@ -420,6 +424,7 @@ ENTRY(cast5_ecb_dec_16way)
12681 vmovdqu RR4, (6*4*4)(%r11);
12682 vmovdqu RL4, (7*4*4)(%r11);
12683
12684 + pax_force_retaddr
12685 ret;
12686 ENDPROC(cast5_ecb_dec_16way)
12687
12688 @@ -469,6 +474,7 @@ ENTRY(cast5_cbc_dec_16way)
12689
12690 popq %r12;
12691
12692 + pax_force_retaddr
12693 ret;
12694 ENDPROC(cast5_cbc_dec_16way)
12695
12696 @@ -542,5 +548,6 @@ ENTRY(cast5_ctr_16way)
12697
12698 popq %r12;
12699
12700 + pax_force_retaddr
12701 ret;
12702 ENDPROC(cast5_ctr_16way)
12703 diff --git a/arch/x86/crypto/cast6-avx-x86_64-asm_64.S b/arch/x86/crypto/cast6-avx-x86_64-asm_64.S
12704 index e3531f8..18ded3a 100644
12705 --- a/arch/x86/crypto/cast6-avx-x86_64-asm_64.S
12706 +++ b/arch/x86/crypto/cast6-avx-x86_64-asm_64.S
12707 @@ -24,6 +24,7 @@
12708 */
12709
12710 #include <linux/linkage.h>
12711 +#include <asm/alternative-asm.h>
12712 #include "glue_helper-asm-avx.S"
12713
12714 .file "cast6-avx-x86_64-asm_64.S"
12715 @@ -295,6 +296,7 @@ __cast6_enc_blk8:
12716 outunpack_blocks(RA1, RB1, RC1, RD1, RTMP, RX, RKRF, RKM);
12717 outunpack_blocks(RA2, RB2, RC2, RD2, RTMP, RX, RKRF, RKM);
12718
12719 + pax_force_retaddr 0, 1
12720 ret;
12721 ENDPROC(__cast6_enc_blk8)
12722
12723 @@ -340,6 +342,7 @@ __cast6_dec_blk8:
12724 outunpack_blocks(RA1, RB1, RC1, RD1, RTMP, RX, RKRF, RKM);
12725 outunpack_blocks(RA2, RB2, RC2, RD2, RTMP, RX, RKRF, RKM);
12726
12727 + pax_force_retaddr 0, 1
12728 ret;
12729 ENDPROC(__cast6_dec_blk8)
12730
12731 @@ -358,6 +361,7 @@ ENTRY(cast6_ecb_enc_8way)
12732
12733 store_8way(%r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
12734
12735 + pax_force_retaddr
12736 ret;
12737 ENDPROC(cast6_ecb_enc_8way)
12738
12739 @@ -376,6 +380,7 @@ ENTRY(cast6_ecb_dec_8way)
12740
12741 store_8way(%r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
12742
12743 + pax_force_retaddr
12744 ret;
12745 ENDPROC(cast6_ecb_dec_8way)
12746
12747 @@ -399,6 +404,7 @@ ENTRY(cast6_cbc_dec_8way)
12748
12749 popq %r12;
12750
12751 + pax_force_retaddr
12752 ret;
12753 ENDPROC(cast6_cbc_dec_8way)
12754
12755 @@ -424,6 +430,7 @@ ENTRY(cast6_ctr_8way)
12756
12757 popq %r12;
12758
12759 + pax_force_retaddr
12760 ret;
12761 ENDPROC(cast6_ctr_8way)
12762
12763 @@ -446,6 +453,7 @@ ENTRY(cast6_xts_enc_8way)
12764 /* dst <= regs xor IVs(in dst) */
12765 store_xts_8way(%r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
12766
12767 + pax_force_retaddr
12768 ret;
12769 ENDPROC(cast6_xts_enc_8way)
12770
12771 @@ -468,5 +476,6 @@ ENTRY(cast6_xts_dec_8way)
12772 /* dst <= regs xor IVs(in dst) */
12773 store_xts_8way(%r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
12774
12775 + pax_force_retaddr
12776 ret;
12777 ENDPROC(cast6_xts_dec_8way)
12778 diff --git a/arch/x86/crypto/crc32c-pcl-intel-asm_64.S b/arch/x86/crypto/crc32c-pcl-intel-asm_64.S
12779 index dbc4339..3d868c5 100644
12780 --- a/arch/x86/crypto/crc32c-pcl-intel-asm_64.S
12781 +++ b/arch/x86/crypto/crc32c-pcl-intel-asm_64.S
12782 @@ -45,6 +45,7 @@
12783
12784 #include <asm/inst.h>
12785 #include <linux/linkage.h>
12786 +#include <asm/alternative-asm.h>
12787
12788 ## ISCSI CRC 32 Implementation with crc32 and pclmulqdq Instruction
12789
12790 @@ -312,6 +313,7 @@ do_return:
12791 popq %rsi
12792 popq %rdi
12793 popq %rbx
12794 + pax_force_retaddr 0, 1
12795 ret
12796
12797 ################################################################
12798 diff --git a/arch/x86/crypto/ghash-clmulni-intel_asm.S b/arch/x86/crypto/ghash-clmulni-intel_asm.S
12799 index 586f41a..d02851e 100644
12800 --- a/arch/x86/crypto/ghash-clmulni-intel_asm.S
12801 +++ b/arch/x86/crypto/ghash-clmulni-intel_asm.S
12802 @@ -18,6 +18,7 @@
12803
12804 #include <linux/linkage.h>
12805 #include <asm/inst.h>
12806 +#include <asm/alternative-asm.h>
12807
12808 .data
12809
12810 @@ -93,6 +94,7 @@ __clmul_gf128mul_ble:
12811 psrlq $1, T2
12812 pxor T2, T1
12813 pxor T1, DATA
12814 + pax_force_retaddr
12815 ret
12816 ENDPROC(__clmul_gf128mul_ble)
12817
12818 @@ -105,6 +107,7 @@ ENTRY(clmul_ghash_mul)
12819 call __clmul_gf128mul_ble
12820 PSHUFB_XMM BSWAP DATA
12821 movups DATA, (%rdi)
12822 + pax_force_retaddr
12823 ret
12824 ENDPROC(clmul_ghash_mul)
12825
12826 @@ -132,6 +135,7 @@ ENTRY(clmul_ghash_update)
12827 PSHUFB_XMM BSWAP DATA
12828 movups DATA, (%rdi)
12829 .Lupdate_just_ret:
12830 + pax_force_retaddr
12831 ret
12832 ENDPROC(clmul_ghash_update)
12833
12834 @@ -157,5 +161,6 @@ ENTRY(clmul_ghash_setkey)
12835 pand .Lpoly, %xmm1
12836 pxor %xmm1, %xmm0
12837 movups %xmm0, (%rdi)
12838 + pax_force_retaddr
12839 ret
12840 ENDPROC(clmul_ghash_setkey)
12841 diff --git a/arch/x86/crypto/salsa20-x86_64-asm_64.S b/arch/x86/crypto/salsa20-x86_64-asm_64.S
12842 index 9279e0b..9270820 100644
12843 --- a/arch/x86/crypto/salsa20-x86_64-asm_64.S
12844 +++ b/arch/x86/crypto/salsa20-x86_64-asm_64.S
12845 @@ -1,4 +1,5 @@
12846 #include <linux/linkage.h>
12847 +#include <asm/alternative-asm.h>
12848
12849 # enter salsa20_encrypt_bytes
12850 ENTRY(salsa20_encrypt_bytes)
12851 @@ -789,6 +790,7 @@ ENTRY(salsa20_encrypt_bytes)
12852 add %r11,%rsp
12853 mov %rdi,%rax
12854 mov %rsi,%rdx
12855 + pax_force_retaddr 0, 1
12856 ret
12857 # bytesatleast65:
12858 ._bytesatleast65:
12859 @@ -889,6 +891,7 @@ ENTRY(salsa20_keysetup)
12860 add %r11,%rsp
12861 mov %rdi,%rax
12862 mov %rsi,%rdx
12863 + pax_force_retaddr
12864 ret
12865 ENDPROC(salsa20_keysetup)
12866
12867 @@ -914,5 +917,6 @@ ENTRY(salsa20_ivsetup)
12868 add %r11,%rsp
12869 mov %rdi,%rax
12870 mov %rsi,%rdx
12871 + pax_force_retaddr
12872 ret
12873 ENDPROC(salsa20_ivsetup)
12874 diff --git a/arch/x86/crypto/serpent-avx-x86_64-asm_64.S b/arch/x86/crypto/serpent-avx-x86_64-asm_64.S
12875 index 2f202f4..d9164d6 100644
12876 --- a/arch/x86/crypto/serpent-avx-x86_64-asm_64.S
12877 +++ b/arch/x86/crypto/serpent-avx-x86_64-asm_64.S
12878 @@ -24,6 +24,7 @@
12879 */
12880
12881 #include <linux/linkage.h>
12882 +#include <asm/alternative-asm.h>
12883 #include "glue_helper-asm-avx.S"
12884
12885 .file "serpent-avx-x86_64-asm_64.S"
12886 @@ -618,6 +619,7 @@ __serpent_enc_blk8_avx:
12887 write_blocks(RA1, RB1, RC1, RD1, RK0, RK1, RK2);
12888 write_blocks(RA2, RB2, RC2, RD2, RK0, RK1, RK2);
12889
12890 + pax_force_retaddr
12891 ret;
12892 ENDPROC(__serpent_enc_blk8_avx)
12893
12894 @@ -672,6 +674,7 @@ __serpent_dec_blk8_avx:
12895 write_blocks(RC1, RD1, RB1, RE1, RK0, RK1, RK2);
12896 write_blocks(RC2, RD2, RB2, RE2, RK0, RK1, RK2);
12897
12898 + pax_force_retaddr
12899 ret;
12900 ENDPROC(__serpent_dec_blk8_avx)
12901
12902 @@ -688,6 +691,7 @@ ENTRY(serpent_ecb_enc_8way_avx)
12903
12904 store_8way(%rsi, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
12905
12906 + pax_force_retaddr
12907 ret;
12908 ENDPROC(serpent_ecb_enc_8way_avx)
12909
12910 @@ -704,6 +708,7 @@ ENTRY(serpent_ecb_dec_8way_avx)
12911
12912 store_8way(%rsi, RC1, RD1, RB1, RE1, RC2, RD2, RB2, RE2);
12913
12914 + pax_force_retaddr
12915 ret;
12916 ENDPROC(serpent_ecb_dec_8way_avx)
12917
12918 @@ -720,6 +725,7 @@ ENTRY(serpent_cbc_dec_8way_avx)
12919
12920 store_cbc_8way(%rdx, %rsi, RC1, RD1, RB1, RE1, RC2, RD2, RB2, RE2);
12921
12922 + pax_force_retaddr
12923 ret;
12924 ENDPROC(serpent_cbc_dec_8way_avx)
12925
12926 @@ -738,6 +744,7 @@ ENTRY(serpent_ctr_8way_avx)
12927
12928 store_ctr_8way(%rdx, %rsi, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
12929
12930 + pax_force_retaddr
12931 ret;
12932 ENDPROC(serpent_ctr_8way_avx)
12933
12934 @@ -758,6 +765,7 @@ ENTRY(serpent_xts_enc_8way_avx)
12935 /* dst <= regs xor IVs(in dst) */
12936 store_xts_8way(%rsi, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
12937
12938 + pax_force_retaddr
12939 ret;
12940 ENDPROC(serpent_xts_enc_8way_avx)
12941
12942 @@ -778,5 +786,6 @@ ENTRY(serpent_xts_dec_8way_avx)
12943 /* dst <= regs xor IVs(in dst) */
12944 store_xts_8way(%rsi, RC1, RD1, RB1, RE1, RC2, RD2, RB2, RE2);
12945
12946 + pax_force_retaddr
12947 ret;
12948 ENDPROC(serpent_xts_dec_8way_avx)
12949 diff --git a/arch/x86/crypto/serpent-avx2-asm_64.S b/arch/x86/crypto/serpent-avx2-asm_64.S
12950 index b222085..abd483c 100644
12951 --- a/arch/x86/crypto/serpent-avx2-asm_64.S
12952 +++ b/arch/x86/crypto/serpent-avx2-asm_64.S
12953 @@ -15,6 +15,7 @@
12954 */
12955
12956 #include <linux/linkage.h>
12957 +#include <asm/alternative-asm.h>
12958 #include "glue_helper-asm-avx2.S"
12959
12960 .file "serpent-avx2-asm_64.S"
12961 @@ -610,6 +611,7 @@ __serpent_enc_blk16:
12962 write_blocks(RA1, RB1, RC1, RD1, RK0, RK1, RK2);
12963 write_blocks(RA2, RB2, RC2, RD2, RK0, RK1, RK2);
12964
12965 + pax_force_retaddr
12966 ret;
12967 ENDPROC(__serpent_enc_blk16)
12968
12969 @@ -664,6 +666,7 @@ __serpent_dec_blk16:
12970 write_blocks(RC1, RD1, RB1, RE1, RK0, RK1, RK2);
12971 write_blocks(RC2, RD2, RB2, RE2, RK0, RK1, RK2);
12972
12973 + pax_force_retaddr
12974 ret;
12975 ENDPROC(__serpent_dec_blk16)
12976
12977 @@ -684,6 +687,7 @@ ENTRY(serpent_ecb_enc_16way)
12978
12979 vzeroupper;
12980
12981 + pax_force_retaddr
12982 ret;
12983 ENDPROC(serpent_ecb_enc_16way)
12984
12985 @@ -704,6 +708,7 @@ ENTRY(serpent_ecb_dec_16way)
12986
12987 vzeroupper;
12988
12989 + pax_force_retaddr
12990 ret;
12991 ENDPROC(serpent_ecb_dec_16way)
12992
12993 @@ -725,6 +730,7 @@ ENTRY(serpent_cbc_dec_16way)
12994
12995 vzeroupper;
12996
12997 + pax_force_retaddr
12998 ret;
12999 ENDPROC(serpent_cbc_dec_16way)
13000
13001 @@ -748,6 +754,7 @@ ENTRY(serpent_ctr_16way)
13002
13003 vzeroupper;
13004
13005 + pax_force_retaddr
13006 ret;
13007 ENDPROC(serpent_ctr_16way)
13008
13009 @@ -772,6 +779,7 @@ ENTRY(serpent_xts_enc_16way)
13010
13011 vzeroupper;
13012
13013 + pax_force_retaddr
13014 ret;
13015 ENDPROC(serpent_xts_enc_16way)
13016
13017 @@ -796,5 +804,6 @@ ENTRY(serpent_xts_dec_16way)
13018
13019 vzeroupper;
13020
13021 + pax_force_retaddr
13022 ret;
13023 ENDPROC(serpent_xts_dec_16way)
13024 diff --git a/arch/x86/crypto/serpent-sse2-x86_64-asm_64.S b/arch/x86/crypto/serpent-sse2-x86_64-asm_64.S
13025 index acc066c..1559cc4 100644
13026 --- a/arch/x86/crypto/serpent-sse2-x86_64-asm_64.S
13027 +++ b/arch/x86/crypto/serpent-sse2-x86_64-asm_64.S
13028 @@ -25,6 +25,7 @@
13029 */
13030
13031 #include <linux/linkage.h>
13032 +#include <asm/alternative-asm.h>
13033
13034 .file "serpent-sse2-x86_64-asm_64.S"
13035 .text
13036 @@ -690,12 +691,14 @@ ENTRY(__serpent_enc_blk_8way)
13037 write_blocks(%rsi, RA1, RB1, RC1, RD1, RK0, RK1, RK2);
13038 write_blocks(%rax, RA2, RB2, RC2, RD2, RK0, RK1, RK2);
13039
13040 + pax_force_retaddr
13041 ret;
13042
13043 .L__enc_xor8:
13044 xor_blocks(%rsi, RA1, RB1, RC1, RD1, RK0, RK1, RK2);
13045 xor_blocks(%rax, RA2, RB2, RC2, RD2, RK0, RK1, RK2);
13046
13047 + pax_force_retaddr
13048 ret;
13049 ENDPROC(__serpent_enc_blk_8way)
13050
13051 @@ -750,5 +753,6 @@ ENTRY(serpent_dec_blk_8way)
13052 write_blocks(%rsi, RC1, RD1, RB1, RE1, RK0, RK1, RK2);
13053 write_blocks(%rax, RC2, RD2, RB2, RE2, RK0, RK1, RK2);
13054
13055 + pax_force_retaddr
13056 ret;
13057 ENDPROC(serpent_dec_blk_8way)
13058 diff --git a/arch/x86/crypto/sha1_ssse3_asm.S b/arch/x86/crypto/sha1_ssse3_asm.S
13059 index a410950..3356d42 100644
13060 --- a/arch/x86/crypto/sha1_ssse3_asm.S
13061 +++ b/arch/x86/crypto/sha1_ssse3_asm.S
13062 @@ -29,6 +29,7 @@
13063 */
13064
13065 #include <linux/linkage.h>
13066 +#include <asm/alternative-asm.h>
13067
13068 #define CTX %rdi // arg1
13069 #define BUF %rsi // arg2
13070 @@ -104,6 +105,7 @@
13071 pop %r12
13072 pop %rbp
13073 pop %rbx
13074 + pax_force_retaddr 0, 1
13075 ret
13076
13077 ENDPROC(\name)
13078 diff --git a/arch/x86/crypto/sha256-avx-asm.S b/arch/x86/crypto/sha256-avx-asm.S
13079 index 642f156..4ab07b9 100644
13080 --- a/arch/x86/crypto/sha256-avx-asm.S
13081 +++ b/arch/x86/crypto/sha256-avx-asm.S
13082 @@ -49,6 +49,7 @@
13083
13084 #ifdef CONFIG_AS_AVX
13085 #include <linux/linkage.h>
13086 +#include <asm/alternative-asm.h>
13087
13088 ## assume buffers not aligned
13089 #define VMOVDQ vmovdqu
13090 @@ -460,6 +461,7 @@ done_hash:
13091 popq %r13
13092 popq %rbp
13093 popq %rbx
13094 + pax_force_retaddr 0, 1
13095 ret
13096 ENDPROC(sha256_transform_avx)
13097
13098 diff --git a/arch/x86/crypto/sha256-avx2-asm.S b/arch/x86/crypto/sha256-avx2-asm.S
13099 index 9e86944..2e7f95a 100644
13100 --- a/arch/x86/crypto/sha256-avx2-asm.S
13101 +++ b/arch/x86/crypto/sha256-avx2-asm.S
13102 @@ -50,6 +50,7 @@
13103
13104 #ifdef CONFIG_AS_AVX2
13105 #include <linux/linkage.h>
13106 +#include <asm/alternative-asm.h>
13107
13108 ## assume buffers not aligned
13109 #define VMOVDQ vmovdqu
13110 @@ -720,6 +721,7 @@ done_hash:
13111 popq %r12
13112 popq %rbp
13113 popq %rbx
13114 + pax_force_retaddr 0, 1
13115 ret
13116 ENDPROC(sha256_transform_rorx)
13117
13118 diff --git a/arch/x86/crypto/sha256-ssse3-asm.S b/arch/x86/crypto/sha256-ssse3-asm.S
13119 index f833b74..c36ed14 100644
13120 --- a/arch/x86/crypto/sha256-ssse3-asm.S
13121 +++ b/arch/x86/crypto/sha256-ssse3-asm.S
13122 @@ -47,6 +47,7 @@
13123 ########################################################################
13124
13125 #include <linux/linkage.h>
13126 +#include <asm/alternative-asm.h>
13127
13128 ## assume buffers not aligned
13129 #define MOVDQ movdqu
13130 @@ -471,6 +472,7 @@ done_hash:
13131 popq %rbp
13132 popq %rbx
13133
13134 + pax_force_retaddr 0, 1
13135 ret
13136 ENDPROC(sha256_transform_ssse3)
13137
13138 diff --git a/arch/x86/crypto/sha512-avx-asm.S b/arch/x86/crypto/sha512-avx-asm.S
13139 index 974dde9..4533d34 100644
13140 --- a/arch/x86/crypto/sha512-avx-asm.S
13141 +++ b/arch/x86/crypto/sha512-avx-asm.S
13142 @@ -49,6 +49,7 @@
13143
13144 #ifdef CONFIG_AS_AVX
13145 #include <linux/linkage.h>
13146 +#include <asm/alternative-asm.h>
13147
13148 .text
13149
13150 @@ -364,6 +365,7 @@ updateblock:
13151 mov frame_RSPSAVE(%rsp), %rsp
13152
13153 nowork:
13154 + pax_force_retaddr 0, 1
13155 ret
13156 ENDPROC(sha512_transform_avx)
13157
13158 diff --git a/arch/x86/crypto/sha512-avx2-asm.S b/arch/x86/crypto/sha512-avx2-asm.S
13159 index 568b961..061ef1d 100644
13160 --- a/arch/x86/crypto/sha512-avx2-asm.S
13161 +++ b/arch/x86/crypto/sha512-avx2-asm.S
13162 @@ -51,6 +51,7 @@
13163
13164 #ifdef CONFIG_AS_AVX2
13165 #include <linux/linkage.h>
13166 +#include <asm/alternative-asm.h>
13167
13168 .text
13169
13170 @@ -678,6 +679,7 @@ done_hash:
13171
13172 # Restore Stack Pointer
13173 mov frame_RSPSAVE(%rsp), %rsp
13174 + pax_force_retaddr 0, 1
13175 ret
13176 ENDPROC(sha512_transform_rorx)
13177
13178 diff --git a/arch/x86/crypto/sha512-ssse3-asm.S b/arch/x86/crypto/sha512-ssse3-asm.S
13179 index fb56855..e23914f 100644
13180 --- a/arch/x86/crypto/sha512-ssse3-asm.S
13181 +++ b/arch/x86/crypto/sha512-ssse3-asm.S
13182 @@ -48,6 +48,7 @@
13183 ########################################################################
13184
13185 #include <linux/linkage.h>
13186 +#include <asm/alternative-asm.h>
13187
13188 .text
13189
13190 @@ -363,6 +364,7 @@ updateblock:
13191 mov frame_RSPSAVE(%rsp), %rsp
13192
13193 nowork:
13194 + pax_force_retaddr 0, 1
13195 ret
13196 ENDPROC(sha512_transform_ssse3)
13197
13198 diff --git a/arch/x86/crypto/twofish-avx-x86_64-asm_64.S b/arch/x86/crypto/twofish-avx-x86_64-asm_64.S
13199 index 0505813..63b1d00 100644
13200 --- a/arch/x86/crypto/twofish-avx-x86_64-asm_64.S
13201 +++ b/arch/x86/crypto/twofish-avx-x86_64-asm_64.S
13202 @@ -24,6 +24,7 @@
13203 */
13204
13205 #include <linux/linkage.h>
13206 +#include <asm/alternative-asm.h>
13207 #include "glue_helper-asm-avx.S"
13208
13209 .file "twofish-avx-x86_64-asm_64.S"
13210 @@ -284,6 +285,7 @@ __twofish_enc_blk8:
13211 outunpack_blocks(RC1, RD1, RA1, RB1, RK1, RX0, RY0, RK2);
13212 outunpack_blocks(RC2, RD2, RA2, RB2, RK1, RX0, RY0, RK2);
13213
13214 + pax_force_retaddr 0, 1
13215 ret;
13216 ENDPROC(__twofish_enc_blk8)
13217
13218 @@ -324,6 +326,7 @@ __twofish_dec_blk8:
13219 outunpack_blocks(RA1, RB1, RC1, RD1, RK1, RX0, RY0, RK2);
13220 outunpack_blocks(RA2, RB2, RC2, RD2, RK1, RX0, RY0, RK2);
13221
13222 + pax_force_retaddr 0, 1
13223 ret;
13224 ENDPROC(__twofish_dec_blk8)
13225
13226 @@ -342,6 +345,7 @@ ENTRY(twofish_ecb_enc_8way)
13227
13228 store_8way(%r11, RC1, RD1, RA1, RB1, RC2, RD2, RA2, RB2);
13229
13230 + pax_force_retaddr 0, 1
13231 ret;
13232 ENDPROC(twofish_ecb_enc_8way)
13233
13234 @@ -360,6 +364,7 @@ ENTRY(twofish_ecb_dec_8way)
13235
13236 store_8way(%r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
13237
13238 + pax_force_retaddr 0, 1
13239 ret;
13240 ENDPROC(twofish_ecb_dec_8way)
13241
13242 @@ -383,6 +388,7 @@ ENTRY(twofish_cbc_dec_8way)
13243
13244 popq %r12;
13245
13246 + pax_force_retaddr 0, 1
13247 ret;
13248 ENDPROC(twofish_cbc_dec_8way)
13249
13250 @@ -408,6 +414,7 @@ ENTRY(twofish_ctr_8way)
13251
13252 popq %r12;
13253
13254 + pax_force_retaddr 0, 1
13255 ret;
13256 ENDPROC(twofish_ctr_8way)
13257
13258 @@ -430,6 +437,7 @@ ENTRY(twofish_xts_enc_8way)
13259 /* dst <= regs xor IVs(in dst) */
13260 store_xts_8way(%r11, RC1, RD1, RA1, RB1, RC2, RD2, RA2, RB2);
13261
13262 + pax_force_retaddr 0, 1
13263 ret;
13264 ENDPROC(twofish_xts_enc_8way)
13265
13266 @@ -452,5 +460,6 @@ ENTRY(twofish_xts_dec_8way)
13267 /* dst <= regs xor IVs(in dst) */
13268 store_xts_8way(%r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
13269
13270 + pax_force_retaddr 0, 1
13271 ret;
13272 ENDPROC(twofish_xts_dec_8way)
13273 diff --git a/arch/x86/crypto/twofish-x86_64-asm_64-3way.S b/arch/x86/crypto/twofish-x86_64-asm_64-3way.S
13274 index 1c3b7ce..b365c5e 100644
13275 --- a/arch/x86/crypto/twofish-x86_64-asm_64-3way.S
13276 +++ b/arch/x86/crypto/twofish-x86_64-asm_64-3way.S
13277 @@ -21,6 +21,7 @@
13278 */
13279
13280 #include <linux/linkage.h>
13281 +#include <asm/alternative-asm.h>
13282
13283 .file "twofish-x86_64-asm-3way.S"
13284 .text
13285 @@ -258,6 +259,7 @@ ENTRY(__twofish_enc_blk_3way)
13286 popq %r13;
13287 popq %r14;
13288 popq %r15;
13289 + pax_force_retaddr 0, 1
13290 ret;
13291
13292 .L__enc_xor3:
13293 @@ -269,6 +271,7 @@ ENTRY(__twofish_enc_blk_3way)
13294 popq %r13;
13295 popq %r14;
13296 popq %r15;
13297 + pax_force_retaddr 0, 1
13298 ret;
13299 ENDPROC(__twofish_enc_blk_3way)
13300
13301 @@ -308,5 +311,6 @@ ENTRY(twofish_dec_blk_3way)
13302 popq %r13;
13303 popq %r14;
13304 popq %r15;
13305 + pax_force_retaddr 0, 1
13306 ret;
13307 ENDPROC(twofish_dec_blk_3way)
13308 diff --git a/arch/x86/crypto/twofish-x86_64-asm_64.S b/arch/x86/crypto/twofish-x86_64-asm_64.S
13309 index a039d21..29e7615 100644
13310 --- a/arch/x86/crypto/twofish-x86_64-asm_64.S
13311 +++ b/arch/x86/crypto/twofish-x86_64-asm_64.S
13312 @@ -22,6 +22,7 @@
13313
13314 #include <linux/linkage.h>
13315 #include <asm/asm-offsets.h>
13316 +#include <asm/alternative-asm.h>
13317
13318 #define a_offset 0
13319 #define b_offset 4
13320 @@ -265,6 +266,7 @@ ENTRY(twofish_enc_blk)
13321
13322 popq R1
13323 movq $1,%rax
13324 + pax_force_retaddr 0, 1
13325 ret
13326 ENDPROC(twofish_enc_blk)
13327
13328 @@ -317,5 +319,6 @@ ENTRY(twofish_dec_blk)
13329
13330 popq R1
13331 movq $1,%rax
13332 + pax_force_retaddr 0, 1
13333 ret
13334 ENDPROC(twofish_dec_blk)
13335 diff --git a/arch/x86/ia32/ia32_aout.c b/arch/x86/ia32/ia32_aout.c
13336 index bae3aba..c1788c1 100644
13337 --- a/arch/x86/ia32/ia32_aout.c
13338 +++ b/arch/x86/ia32/ia32_aout.c
13339 @@ -159,6 +159,8 @@ static int aout_core_dump(long signr, struct pt_regs *regs, struct file *file,
13340 unsigned long dump_start, dump_size;
13341 struct user32 dump;
13342
13343 + memset(&dump, 0, sizeof(dump));
13344 +
13345 fs = get_fs();
13346 set_fs(KERNEL_DS);
13347 has_dumped = 1;
13348 diff --git a/arch/x86/ia32/ia32_signal.c b/arch/x86/ia32/ia32_signal.c
13349 index 665a730..8e7a67a 100644
13350 --- a/arch/x86/ia32/ia32_signal.c
13351 +++ b/arch/x86/ia32/ia32_signal.c
13352 @@ -338,7 +338,7 @@ static void __user *get_sigframe(struct ksignal *ksig, struct pt_regs *regs,
13353 sp -= frame_size;
13354 /* Align the stack pointer according to the i386 ABI,
13355 * i.e. so that on function entry ((sp + 4) & 15) == 0. */
13356 - sp = ((sp + 4) & -16ul) - 4;
13357 + sp = ((sp - 12) & -16ul) - 4;
13358 return (void __user *) sp;
13359 }
13360
13361 @@ -396,7 +396,7 @@ int ia32_setup_frame(int sig, struct ksignal *ksig,
13362 * These are actually not used anymore, but left because some
13363 * gdb versions depend on them as a marker.
13364 */
13365 - put_user_ex(*((u64 *)&code), (u64 __user *)frame->retcode);
13366 + put_user_ex(*((const u64 *)&code), (u64 __user *)frame->retcode);
13367 } put_user_catch(err);
13368
13369 if (err)
13370 @@ -438,7 +438,7 @@ int ia32_setup_rt_frame(int sig, struct ksignal *ksig,
13371 0xb8,
13372 __NR_ia32_rt_sigreturn,
13373 0x80cd,
13374 - 0,
13375 + 0
13376 };
13377
13378 frame = get_sigframe(ksig, regs, sizeof(*frame), &fpstate);
13379 @@ -461,16 +461,18 @@ int ia32_setup_rt_frame(int sig, struct ksignal *ksig,
13380
13381 if (ksig->ka.sa.sa_flags & SA_RESTORER)
13382 restorer = ksig->ka.sa.sa_restorer;
13383 + else if (current->mm->context.vdso)
13384 + /* Return stub is in 32bit vsyscall page */
13385 + restorer = VDSO32_SYMBOL(current->mm->context.vdso, rt_sigreturn);
13386 else
13387 - restorer = VDSO32_SYMBOL(current->mm->context.vdso,
13388 - rt_sigreturn);
13389 + restorer = &frame->retcode;
13390 put_user_ex(ptr_to_compat(restorer), &frame->pretcode);
13391
13392 /*
13393 * Not actually used anymore, but left because some gdb
13394 * versions need it.
13395 */
13396 - put_user_ex(*((u64 *)&code), (u64 __user *)frame->retcode);
13397 + put_user_ex(*((const u64 *)&code), (u64 __user *)frame->retcode);
13398 } put_user_catch(err);
13399
13400 err |= copy_siginfo_to_user32(&frame->info, &ksig->info);
13401 diff --git a/arch/x86/ia32/ia32entry.S b/arch/x86/ia32/ia32entry.S
13402 index 4299eb0..904b82a 100644
13403 --- a/arch/x86/ia32/ia32entry.S
13404 +++ b/arch/x86/ia32/ia32entry.S
13405 @@ -15,8 +15,10 @@
13406 #include <asm/irqflags.h>
13407 #include <asm/asm.h>
13408 #include <asm/smap.h>
13409 +#include <asm/pgtable.h>
13410 #include <linux/linkage.h>
13411 #include <linux/err.h>
13412 +#include <asm/alternative-asm.h>
13413
13414 /* Avoid __ASSEMBLER__'ifying <linux/audit.h> just for this. */
13415 #include <linux/elf-em.h>
13416 @@ -96,6 +98,32 @@ ENTRY(native_irq_enable_sysexit)
13417 ENDPROC(native_irq_enable_sysexit)
13418 #endif
13419
13420 + .macro pax_enter_kernel_user
13421 + pax_set_fptr_mask
13422 +#ifdef CONFIG_PAX_MEMORY_UDEREF
13423 + call pax_enter_kernel_user
13424 +#endif
13425 + .endm
13426 +
13427 + .macro pax_exit_kernel_user
13428 +#ifdef CONFIG_PAX_MEMORY_UDEREF
13429 + call pax_exit_kernel_user
13430 +#endif
13431 +#ifdef CONFIG_PAX_RANDKSTACK
13432 + pushq %rax
13433 + pushq %r11
13434 + call pax_randomize_kstack
13435 + popq %r11
13436 + popq %rax
13437 +#endif
13438 + .endm
13439 +
13440 + .macro pax_erase_kstack
13441 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
13442 + call pax_erase_kstack
13443 +#endif
13444 + .endm
13445 +
13446 /*
13447 * 32bit SYSENTER instruction entry.
13448 *
13449 @@ -122,12 +150,6 @@ ENTRY(ia32_sysenter_target)
13450 CFI_REGISTER rsp,rbp
13451 SWAPGS_UNSAFE_STACK
13452 movq PER_CPU_VAR(kernel_stack), %rsp
13453 - addq $(KERNEL_STACK_OFFSET),%rsp
13454 - /*
13455 - * No need to follow this irqs on/off section: the syscall
13456 - * disabled irqs, here we enable it straight after entry:
13457 - */
13458 - ENABLE_INTERRUPTS(CLBR_NONE)
13459 movl %ebp,%ebp /* zero extension */
13460 pushq_cfi $__USER32_DS
13461 /*CFI_REL_OFFSET ss,0*/
13462 @@ -135,24 +157,49 @@ ENTRY(ia32_sysenter_target)
13463 CFI_REL_OFFSET rsp,0
13464 pushfq_cfi
13465 /*CFI_REL_OFFSET rflags,0*/
13466 - movl TI_sysenter_return+THREAD_INFO(%rsp,3*8-KERNEL_STACK_OFFSET),%r10d
13467 - CFI_REGISTER rip,r10
13468 + orl $X86_EFLAGS_IF,(%rsp)
13469 + GET_THREAD_INFO(%r11)
13470 + movl TI_sysenter_return(%r11), %r11d
13471 + CFI_REGISTER rip,r11
13472 pushq_cfi $__USER32_CS
13473 /*CFI_REL_OFFSET cs,0*/
13474 movl %eax, %eax
13475 - pushq_cfi %r10
13476 + pushq_cfi %r11
13477 CFI_REL_OFFSET rip,0
13478 pushq_cfi %rax
13479 cld
13480 SAVE_ARGS 0,1,0
13481 + pax_enter_kernel_user
13482 +
13483 +#ifdef CONFIG_PAX_RANDKSTACK
13484 + pax_erase_kstack
13485 +#endif
13486 +
13487 + /*
13488 + * No need to follow this irqs on/off section: the syscall
13489 + * disabled irqs, here we enable it straight after entry:
13490 + */
13491 + ENABLE_INTERRUPTS(CLBR_NONE)
13492 /* no need to do an access_ok check here because rbp has been
13493 32bit zero extended */
13494 +
13495 +#ifdef CONFIG_PAX_MEMORY_UDEREF
13496 + addq pax_user_shadow_base,%rbp
13497 + ASM_PAX_OPEN_USERLAND
13498 +#endif
13499 +
13500 ASM_STAC
13501 1: movl (%rbp),%ebp
13502 _ASM_EXTABLE(1b,ia32_badarg)
13503 ASM_CLAC
13504 - orl $TS_COMPAT,TI_status+THREAD_INFO(%rsp,RIP-ARGOFFSET)
13505 - testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
13506 +
13507 +#ifdef CONFIG_PAX_MEMORY_UDEREF
13508 + ASM_PAX_CLOSE_USERLAND
13509 +#endif
13510 +
13511 + GET_THREAD_INFO(%r11)
13512 + orl $TS_COMPAT,TI_status(%r11)
13513 + testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%r11)
13514 CFI_REMEMBER_STATE
13515 jnz sysenter_tracesys
13516 cmpq $(IA32_NR_syscalls-1),%rax
13517 @@ -162,12 +209,15 @@ sysenter_do_call:
13518 sysenter_dispatch:
13519 call *ia32_sys_call_table(,%rax,8)
13520 movq %rax,RAX-ARGOFFSET(%rsp)
13521 + GET_THREAD_INFO(%r11)
13522 DISABLE_INTERRUPTS(CLBR_NONE)
13523 TRACE_IRQS_OFF
13524 - testl $_TIF_ALLWORK_MASK,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
13525 + testl $_TIF_ALLWORK_MASK,TI_flags(%r11)
13526 jnz sysexit_audit
13527 sysexit_from_sys_call:
13528 - andl $~TS_COMPAT,TI_status+THREAD_INFO(%rsp,RIP-ARGOFFSET)
13529 + pax_exit_kernel_user
13530 + pax_erase_kstack
13531 + andl $~TS_COMPAT,TI_status(%r11)
13532 /* clear IF, that popfq doesn't enable interrupts early */
13533 andl $~0x200,EFLAGS-R11(%rsp)
13534 movl RIP-R11(%rsp),%edx /* User %eip */
13535 @@ -193,6 +243,9 @@ sysexit_from_sys_call:
13536 movl %eax,%esi /* 2nd arg: syscall number */
13537 movl $AUDIT_ARCH_I386,%edi /* 1st arg: audit arch */
13538 call __audit_syscall_entry
13539 +
13540 + pax_erase_kstack
13541 +
13542 movl RAX-ARGOFFSET(%rsp),%eax /* reload syscall number */
13543 cmpq $(IA32_NR_syscalls-1),%rax
13544 ja ia32_badsys
13545 @@ -204,7 +257,7 @@ sysexit_from_sys_call:
13546 .endm
13547
13548 .macro auditsys_exit exit
13549 - testl $(_TIF_ALLWORK_MASK & ~_TIF_SYSCALL_AUDIT),TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
13550 + testl $(_TIF_ALLWORK_MASK & ~_TIF_SYSCALL_AUDIT),TI_flags(%r11)
13551 jnz ia32_ret_from_sys_call
13552 TRACE_IRQS_ON
13553 ENABLE_INTERRUPTS(CLBR_NONE)
13554 @@ -215,11 +268,12 @@ sysexit_from_sys_call:
13555 1: setbe %al /* 1 if error, 0 if not */
13556 movzbl %al,%edi /* zero-extend that into %edi */
13557 call __audit_syscall_exit
13558 + GET_THREAD_INFO(%r11)
13559 movq RAX-ARGOFFSET(%rsp),%rax /* reload syscall return value */
13560 movl $(_TIF_ALLWORK_MASK & ~_TIF_SYSCALL_AUDIT),%edi
13561 DISABLE_INTERRUPTS(CLBR_NONE)
13562 TRACE_IRQS_OFF
13563 - testl %edi,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
13564 + testl %edi,TI_flags(%r11)
13565 jz \exit
13566 CLEAR_RREGS -ARGOFFSET
13567 jmp int_with_check
13568 @@ -237,7 +291,7 @@ sysexit_audit:
13569
13570 sysenter_tracesys:
13571 #ifdef CONFIG_AUDITSYSCALL
13572 - testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
13573 + testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags(%r11)
13574 jz sysenter_auditsys
13575 #endif
13576 SAVE_REST
13577 @@ -249,6 +303,9 @@ sysenter_tracesys:
13578 RESTORE_REST
13579 cmpq $(IA32_NR_syscalls-1),%rax
13580 ja int_ret_from_sys_call /* sysenter_tracesys has set RAX(%rsp) */
13581 +
13582 + pax_erase_kstack
13583 +
13584 jmp sysenter_do_call
13585 CFI_ENDPROC
13586 ENDPROC(ia32_sysenter_target)
13587 @@ -276,19 +333,25 @@ ENDPROC(ia32_sysenter_target)
13588 ENTRY(ia32_cstar_target)
13589 CFI_STARTPROC32 simple
13590 CFI_SIGNAL_FRAME
13591 - CFI_DEF_CFA rsp,KERNEL_STACK_OFFSET
13592 + CFI_DEF_CFA rsp,0
13593 CFI_REGISTER rip,rcx
13594 /*CFI_REGISTER rflags,r11*/
13595 SWAPGS_UNSAFE_STACK
13596 movl %esp,%r8d
13597 CFI_REGISTER rsp,r8
13598 movq PER_CPU_VAR(kernel_stack),%rsp
13599 + SAVE_ARGS 8*6,0,0
13600 + pax_enter_kernel_user
13601 +
13602 +#ifdef CONFIG_PAX_RANDKSTACK
13603 + pax_erase_kstack
13604 +#endif
13605 +
13606 /*
13607 * No need to follow this irqs on/off section: the syscall
13608 * disabled irqs and here we enable it straight after entry:
13609 */
13610 ENABLE_INTERRUPTS(CLBR_NONE)
13611 - SAVE_ARGS 8,0,0
13612 movl %eax,%eax /* zero extension */
13613 movq %rax,ORIG_RAX-ARGOFFSET(%rsp)
13614 movq %rcx,RIP-ARGOFFSET(%rsp)
13615 @@ -304,12 +367,25 @@ ENTRY(ia32_cstar_target)
13616 /* no need to do an access_ok check here because r8 has been
13617 32bit zero extended */
13618 /* hardware stack frame is complete now */
13619 +
13620 +#ifdef CONFIG_PAX_MEMORY_UDEREF
13621 + ASM_PAX_OPEN_USERLAND
13622 + movq pax_user_shadow_base,%r8
13623 + addq RSP-ARGOFFSET(%rsp),%r8
13624 +#endif
13625 +
13626 ASM_STAC
13627 1: movl (%r8),%r9d
13628 _ASM_EXTABLE(1b,ia32_badarg)
13629 ASM_CLAC
13630 - orl $TS_COMPAT,TI_status+THREAD_INFO(%rsp,RIP-ARGOFFSET)
13631 - testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
13632 +
13633 +#ifdef CONFIG_PAX_MEMORY_UDEREF
13634 + ASM_PAX_CLOSE_USERLAND
13635 +#endif
13636 +
13637 + GET_THREAD_INFO(%r11)
13638 + orl $TS_COMPAT,TI_status(%r11)
13639 + testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%r11)
13640 CFI_REMEMBER_STATE
13641 jnz cstar_tracesys
13642 cmpq $IA32_NR_syscalls-1,%rax
13643 @@ -319,12 +395,15 @@ cstar_do_call:
13644 cstar_dispatch:
13645 call *ia32_sys_call_table(,%rax,8)
13646 movq %rax,RAX-ARGOFFSET(%rsp)
13647 + GET_THREAD_INFO(%r11)
13648 DISABLE_INTERRUPTS(CLBR_NONE)
13649 TRACE_IRQS_OFF
13650 - testl $_TIF_ALLWORK_MASK,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
13651 + testl $_TIF_ALLWORK_MASK,TI_flags(%r11)
13652 jnz sysretl_audit
13653 sysretl_from_sys_call:
13654 - andl $~TS_COMPAT,TI_status+THREAD_INFO(%rsp,RIP-ARGOFFSET)
13655 + pax_exit_kernel_user
13656 + pax_erase_kstack
13657 + andl $~TS_COMPAT,TI_status(%r11)
13658 RESTORE_ARGS 0,-ARG_SKIP,0,0,0
13659 movl RIP-ARGOFFSET(%rsp),%ecx
13660 CFI_REGISTER rip,rcx
13661 @@ -352,7 +431,7 @@ sysretl_audit:
13662
13663 cstar_tracesys:
13664 #ifdef CONFIG_AUDITSYSCALL
13665 - testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
13666 + testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags(%r11)
13667 jz cstar_auditsys
13668 #endif
13669 xchgl %r9d,%ebp
13670 @@ -366,11 +445,19 @@ cstar_tracesys:
13671 xchgl %ebp,%r9d
13672 cmpq $(IA32_NR_syscalls-1),%rax
13673 ja int_ret_from_sys_call /* cstar_tracesys has set RAX(%rsp) */
13674 +
13675 + pax_erase_kstack
13676 +
13677 jmp cstar_do_call
13678 END(ia32_cstar_target)
13679
13680 ia32_badarg:
13681 ASM_CLAC
13682 +
13683 +#ifdef CONFIG_PAX_MEMORY_UDEREF
13684 + ASM_PAX_CLOSE_USERLAND
13685 +#endif
13686 +
13687 movq $-EFAULT,%rax
13688 jmp ia32_sysret
13689 CFI_ENDPROC
13690 @@ -407,19 +494,26 @@ ENTRY(ia32_syscall)
13691 CFI_REL_OFFSET rip,RIP-RIP
13692 PARAVIRT_ADJUST_EXCEPTION_FRAME
13693 SWAPGS
13694 - /*
13695 - * No need to follow this irqs on/off section: the syscall
13696 - * disabled irqs and here we enable it straight after entry:
13697 - */
13698 - ENABLE_INTERRUPTS(CLBR_NONE)
13699 movl %eax,%eax
13700 pushq_cfi %rax
13701 cld
13702 /* note the registers are not zero extended to the sf.
13703 this could be a problem. */
13704 SAVE_ARGS 0,1,0
13705 - orl $TS_COMPAT,TI_status+THREAD_INFO(%rsp,RIP-ARGOFFSET)
13706 - testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
13707 + pax_enter_kernel_user
13708 +
13709 +#ifdef CONFIG_PAX_RANDKSTACK
13710 + pax_erase_kstack
13711 +#endif
13712 +
13713 + /*
13714 + * No need to follow this irqs on/off section: the syscall
13715 + * disabled irqs and here we enable it straight after entry:
13716 + */
13717 + ENABLE_INTERRUPTS(CLBR_NONE)
13718 + GET_THREAD_INFO(%r11)
13719 + orl $TS_COMPAT,TI_status(%r11)
13720 + testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%r11)
13721 jnz ia32_tracesys
13722 cmpq $(IA32_NR_syscalls-1),%rax
13723 ja ia32_badsys
13724 @@ -442,6 +536,9 @@ ia32_tracesys:
13725 RESTORE_REST
13726 cmpq $(IA32_NR_syscalls-1),%rax
13727 ja int_ret_from_sys_call /* ia32_tracesys has set RAX(%rsp) */
13728 +
13729 + pax_erase_kstack
13730 +
13731 jmp ia32_do_call
13732 END(ia32_syscall)
13733
13734 diff --git a/arch/x86/ia32/sys_ia32.c b/arch/x86/ia32/sys_ia32.c
13735 index 8e0ceec..af13504 100644
13736 --- a/arch/x86/ia32/sys_ia32.c
13737 +++ b/arch/x86/ia32/sys_ia32.c
13738 @@ -69,8 +69,8 @@ asmlinkage long sys32_ftruncate64(unsigned int fd, unsigned long offset_low,
13739 */
13740 static int cp_stat64(struct stat64 __user *ubuf, struct kstat *stat)
13741 {
13742 - typeof(ubuf->st_uid) uid = 0;
13743 - typeof(ubuf->st_gid) gid = 0;
13744 + typeof(((struct stat64 *)0)->st_uid) uid = 0;
13745 + typeof(((struct stat64 *)0)->st_gid) gid = 0;
13746 SET_UID(uid, from_kuid_munged(current_user_ns(), stat->uid));
13747 SET_GID(gid, from_kgid_munged(current_user_ns(), stat->gid));
13748 if (!access_ok(VERIFY_WRITE, ubuf, sizeof(struct stat64)) ||
13749 diff --git a/arch/x86/include/asm/alternative-asm.h b/arch/x86/include/asm/alternative-asm.h
13750 index 372231c..a5aa1a1 100644
13751 --- a/arch/x86/include/asm/alternative-asm.h
13752 +++ b/arch/x86/include/asm/alternative-asm.h
13753 @@ -18,6 +18,45 @@
13754 .endm
13755 #endif
13756
13757 +#ifdef KERNEXEC_PLUGIN
13758 + .macro pax_force_retaddr_bts rip=0
13759 + btsq $63,\rip(%rsp)
13760 + .endm
13761 +#ifdef CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_BTS
13762 + .macro pax_force_retaddr rip=0, reload=0
13763 + btsq $63,\rip(%rsp)
13764 + .endm
13765 + .macro pax_force_fptr ptr
13766 + btsq $63,\ptr
13767 + .endm
13768 + .macro pax_set_fptr_mask
13769 + .endm
13770 +#endif
13771 +#ifdef CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_OR
13772 + .macro pax_force_retaddr rip=0, reload=0
13773 + .if \reload
13774 + pax_set_fptr_mask
13775 + .endif
13776 + orq %r10,\rip(%rsp)
13777 + .endm
13778 + .macro pax_force_fptr ptr
13779 + orq %r10,\ptr
13780 + .endm
13781 + .macro pax_set_fptr_mask
13782 + movabs $0x8000000000000000,%r10
13783 + .endm
13784 +#endif
13785 +#else
13786 + .macro pax_force_retaddr rip=0, reload=0
13787 + .endm
13788 + .macro pax_force_fptr ptr
13789 + .endm
13790 + .macro pax_force_retaddr_bts rip=0
13791 + .endm
13792 + .macro pax_set_fptr_mask
13793 + .endm
13794 +#endif
13795 +
13796 .macro altinstruction_entry orig alt feature orig_len alt_len
13797 .long \orig - .
13798 .long \alt - .
13799 diff --git a/arch/x86/include/asm/alternative.h b/arch/x86/include/asm/alternative.h
13800 index 0a3f9c9..c9d081d 100644
13801 --- a/arch/x86/include/asm/alternative.h
13802 +++ b/arch/x86/include/asm/alternative.h
13803 @@ -106,7 +106,7 @@ static inline int alternatives_text_reserved(void *start, void *end)
13804 ".pushsection .discard,\"aw\",@progbits\n" \
13805 DISCARD_ENTRY(1) \
13806 ".popsection\n" \
13807 - ".pushsection .altinstr_replacement, \"ax\"\n" \
13808 + ".pushsection .altinstr_replacement, \"a\"\n" \
13809 ALTINSTR_REPLACEMENT(newinstr, feature, 1) \
13810 ".popsection"
13811
13812 @@ -120,7 +120,7 @@ static inline int alternatives_text_reserved(void *start, void *end)
13813 DISCARD_ENTRY(1) \
13814 DISCARD_ENTRY(2) \
13815 ".popsection\n" \
13816 - ".pushsection .altinstr_replacement, \"ax\"\n" \
13817 + ".pushsection .altinstr_replacement, \"a\"\n" \
13818 ALTINSTR_REPLACEMENT(newinstr1, feature1, 1) \
13819 ALTINSTR_REPLACEMENT(newinstr2, feature2, 2) \
13820 ".popsection"
13821 diff --git a/arch/x86/include/asm/apic.h b/arch/x86/include/asm/apic.h
13822 index 1d2091a..f5074c1 100644
13823 --- a/arch/x86/include/asm/apic.h
13824 +++ b/arch/x86/include/asm/apic.h
13825 @@ -45,7 +45,7 @@ static inline void generic_apic_probe(void)
13826
13827 #ifdef CONFIG_X86_LOCAL_APIC
13828
13829 -extern unsigned int apic_verbosity;
13830 +extern int apic_verbosity;
13831 extern int local_apic_timer_c2_ok;
13832
13833 extern int disable_apic;
13834 diff --git a/arch/x86/include/asm/apm.h b/arch/x86/include/asm/apm.h
13835 index 20370c6..a2eb9b0 100644
13836 --- a/arch/x86/include/asm/apm.h
13837 +++ b/arch/x86/include/asm/apm.h
13838 @@ -34,7 +34,7 @@ static inline void apm_bios_call_asm(u32 func, u32 ebx_in, u32 ecx_in,
13839 __asm__ __volatile__(APM_DO_ZERO_SEGS
13840 "pushl %%edi\n\t"
13841 "pushl %%ebp\n\t"
13842 - "lcall *%%cs:apm_bios_entry\n\t"
13843 + "lcall *%%ss:apm_bios_entry\n\t"
13844 "setc %%al\n\t"
13845 "popl %%ebp\n\t"
13846 "popl %%edi\n\t"
13847 @@ -58,7 +58,7 @@ static inline u8 apm_bios_call_simple_asm(u32 func, u32 ebx_in,
13848 __asm__ __volatile__(APM_DO_ZERO_SEGS
13849 "pushl %%edi\n\t"
13850 "pushl %%ebp\n\t"
13851 - "lcall *%%cs:apm_bios_entry\n\t"
13852 + "lcall *%%ss:apm_bios_entry\n\t"
13853 "setc %%bl\n\t"
13854 "popl %%ebp\n\t"
13855 "popl %%edi\n\t"
13856 diff --git a/arch/x86/include/asm/atomic.h b/arch/x86/include/asm/atomic.h
13857 index 722aa3b..3a0bb27 100644
13858 --- a/arch/x86/include/asm/atomic.h
13859 +++ b/arch/x86/include/asm/atomic.h
13860 @@ -22,7 +22,18 @@
13861 */
13862 static inline int atomic_read(const atomic_t *v)
13863 {
13864 - return (*(volatile int *)&(v)->counter);
13865 + return (*(volatile const int *)&(v)->counter);
13866 +}
13867 +
13868 +/**
13869 + * atomic_read_unchecked - read atomic variable
13870 + * @v: pointer of type atomic_unchecked_t
13871 + *
13872 + * Atomically reads the value of @v.
13873 + */
13874 +static inline int atomic_read_unchecked(const atomic_unchecked_t *v)
13875 +{
13876 + return (*(volatile const int *)&(v)->counter);
13877 }
13878
13879 /**
13880 @@ -38,6 +49,18 @@ static inline void atomic_set(atomic_t *v, int i)
13881 }
13882
13883 /**
13884 + * atomic_set_unchecked - set atomic variable
13885 + * @v: pointer of type atomic_unchecked_t
13886 + * @i: required value
13887 + *
13888 + * Atomically sets the value of @v to @i.
13889 + */
13890 +static inline void atomic_set_unchecked(atomic_unchecked_t *v, int i)
13891 +{
13892 + v->counter = i;
13893 +}
13894 +
13895 +/**
13896 * atomic_add - add integer to atomic variable
13897 * @i: integer value to add
13898 * @v: pointer of type atomic_t
13899 @@ -46,7 +69,29 @@ static inline void atomic_set(atomic_t *v, int i)
13900 */
13901 static inline void atomic_add(int i, atomic_t *v)
13902 {
13903 - asm volatile(LOCK_PREFIX "addl %1,%0"
13904 + asm volatile(LOCK_PREFIX "addl %1,%0\n"
13905 +
13906 +#ifdef CONFIG_PAX_REFCOUNT
13907 + "jno 0f\n"
13908 + LOCK_PREFIX "subl %1,%0\n"
13909 + "int $4\n0:\n"
13910 + _ASM_EXTABLE(0b, 0b)
13911 +#endif
13912 +
13913 + : "+m" (v->counter)
13914 + : "ir" (i));
13915 +}
13916 +
13917 +/**
13918 + * atomic_add_unchecked - add integer to atomic variable
13919 + * @i: integer value to add
13920 + * @v: pointer of type atomic_unchecked_t
13921 + *
13922 + * Atomically adds @i to @v.
13923 + */
13924 +static inline void atomic_add_unchecked(int i, atomic_unchecked_t *v)
13925 +{
13926 + asm volatile(LOCK_PREFIX "addl %1,%0\n"
13927 : "+m" (v->counter)
13928 : "ir" (i));
13929 }
13930 @@ -60,7 +105,29 @@ static inline void atomic_add(int i, atomic_t *v)
13931 */
13932 static inline void atomic_sub(int i, atomic_t *v)
13933 {
13934 - asm volatile(LOCK_PREFIX "subl %1,%0"
13935 + asm volatile(LOCK_PREFIX "subl %1,%0\n"
13936 +
13937 +#ifdef CONFIG_PAX_REFCOUNT
13938 + "jno 0f\n"
13939 + LOCK_PREFIX "addl %1,%0\n"
13940 + "int $4\n0:\n"
13941 + _ASM_EXTABLE(0b, 0b)
13942 +#endif
13943 +
13944 + : "+m" (v->counter)
13945 + : "ir" (i));
13946 +}
13947 +
13948 +/**
13949 + * atomic_sub_unchecked - subtract integer from atomic variable
13950 + * @i: integer value to subtract
13951 + * @v: pointer of type atomic_unchecked_t
13952 + *
13953 + * Atomically subtracts @i from @v.
13954 + */
13955 +static inline void atomic_sub_unchecked(int i, atomic_unchecked_t *v)
13956 +{
13957 + asm volatile(LOCK_PREFIX "subl %1,%0\n"
13958 : "+m" (v->counter)
13959 : "ir" (i));
13960 }
13961 @@ -78,7 +145,16 @@ static inline int atomic_sub_and_test(int i, atomic_t *v)
13962 {
13963 unsigned char c;
13964
13965 - asm volatile(LOCK_PREFIX "subl %2,%0; sete %1"
13966 + asm volatile(LOCK_PREFIX "subl %2,%0\n"
13967 +
13968 +#ifdef CONFIG_PAX_REFCOUNT
13969 + "jno 0f\n"
13970 + LOCK_PREFIX "addl %2,%0\n"
13971 + "int $4\n0:\n"
13972 + _ASM_EXTABLE(0b, 0b)
13973 +#endif
13974 +
13975 + "sete %1\n"
13976 : "+m" (v->counter), "=qm" (c)
13977 : "ir" (i) : "memory");
13978 return c;
13979 @@ -92,7 +168,27 @@ static inline int atomic_sub_and_test(int i, atomic_t *v)
13980 */
13981 static inline void atomic_inc(atomic_t *v)
13982 {
13983 - asm volatile(LOCK_PREFIX "incl %0"
13984 + asm volatile(LOCK_PREFIX "incl %0\n"
13985 +
13986 +#ifdef CONFIG_PAX_REFCOUNT
13987 + "jno 0f\n"
13988 + LOCK_PREFIX "decl %0\n"
13989 + "int $4\n0:\n"
13990 + _ASM_EXTABLE(0b, 0b)
13991 +#endif
13992 +
13993 + : "+m" (v->counter));
13994 +}
13995 +
13996 +/**
13997 + * atomic_inc_unchecked - increment atomic variable
13998 + * @v: pointer of type atomic_unchecked_t
13999 + *
14000 + * Atomically increments @v by 1.
14001 + */
14002 +static inline void atomic_inc_unchecked(atomic_unchecked_t *v)
14003 +{
14004 + asm volatile(LOCK_PREFIX "incl %0\n"
14005 : "+m" (v->counter));
14006 }
14007
14008 @@ -104,7 +200,27 @@ static inline void atomic_inc(atomic_t *v)
14009 */
14010 static inline void atomic_dec(atomic_t *v)
14011 {
14012 - asm volatile(LOCK_PREFIX "decl %0"
14013 + asm volatile(LOCK_PREFIX "decl %0\n"
14014 +
14015 +#ifdef CONFIG_PAX_REFCOUNT
14016 + "jno 0f\n"
14017 + LOCK_PREFIX "incl %0\n"
14018 + "int $4\n0:\n"
14019 + _ASM_EXTABLE(0b, 0b)
14020 +#endif
14021 +
14022 + : "+m" (v->counter));
14023 +}
14024 +
14025 +/**
14026 + * atomic_dec_unchecked - decrement atomic variable
14027 + * @v: pointer of type atomic_unchecked_t
14028 + *
14029 + * Atomically decrements @v by 1.
14030 + */
14031 +static inline void atomic_dec_unchecked(atomic_unchecked_t *v)
14032 +{
14033 + asm volatile(LOCK_PREFIX "decl %0\n"
14034 : "+m" (v->counter));
14035 }
14036
14037 @@ -120,7 +236,16 @@ static inline int atomic_dec_and_test(atomic_t *v)
14038 {
14039 unsigned char c;
14040
14041 - asm volatile(LOCK_PREFIX "decl %0; sete %1"
14042 + asm volatile(LOCK_PREFIX "decl %0\n"
14043 +
14044 +#ifdef CONFIG_PAX_REFCOUNT
14045 + "jno 0f\n"
14046 + LOCK_PREFIX "incl %0\n"
14047 + "int $4\n0:\n"
14048 + _ASM_EXTABLE(0b, 0b)
14049 +#endif
14050 +
14051 + "sete %1\n"
14052 : "+m" (v->counter), "=qm" (c)
14053 : : "memory");
14054 return c != 0;
14055 @@ -138,7 +263,35 @@ static inline int atomic_inc_and_test(atomic_t *v)
14056 {
14057 unsigned char c;
14058
14059 - asm volatile(LOCK_PREFIX "incl %0; sete %1"
14060 + asm volatile(LOCK_PREFIX "incl %0\n"
14061 +
14062 +#ifdef CONFIG_PAX_REFCOUNT
14063 + "jno 0f\n"
14064 + LOCK_PREFIX "decl %0\n"
14065 + "int $4\n0:\n"
14066 + _ASM_EXTABLE(0b, 0b)
14067 +#endif
14068 +
14069 + "sete %1\n"
14070 + : "+m" (v->counter), "=qm" (c)
14071 + : : "memory");
14072 + return c != 0;
14073 +}
14074 +
14075 +/**
14076 + * atomic_inc_and_test_unchecked - increment and test
14077 + * @v: pointer of type atomic_unchecked_t
14078 + *
14079 + * Atomically increments @v by 1
14080 + * and returns true if the result is zero, or false for all
14081 + * other cases.
14082 + */
14083 +static inline int atomic_inc_and_test_unchecked(atomic_unchecked_t *v)
14084 +{
14085 + unsigned char c;
14086 +
14087 + asm volatile(LOCK_PREFIX "incl %0\n"
14088 + "sete %1\n"
14089 : "+m" (v->counter), "=qm" (c)
14090 : : "memory");
14091 return c != 0;
14092 @@ -157,7 +310,16 @@ static inline int atomic_add_negative(int i, atomic_t *v)
14093 {
14094 unsigned char c;
14095
14096 - asm volatile(LOCK_PREFIX "addl %2,%0; sets %1"
14097 + asm volatile(LOCK_PREFIX "addl %2,%0\n"
14098 +
14099 +#ifdef CONFIG_PAX_REFCOUNT
14100 + "jno 0f\n"
14101 + LOCK_PREFIX "subl %2,%0\n"
14102 + "int $4\n0:\n"
14103 + _ASM_EXTABLE(0b, 0b)
14104 +#endif
14105 +
14106 + "sets %1\n"
14107 : "+m" (v->counter), "=qm" (c)
14108 : "ir" (i) : "memory");
14109 return c;
14110 @@ -172,6 +334,18 @@ static inline int atomic_add_negative(int i, atomic_t *v)
14111 */
14112 static inline int atomic_add_return(int i, atomic_t *v)
14113 {
14114 + return i + xadd_check_overflow(&v->counter, i);
14115 +}
14116 +
14117 +/**
14118 + * atomic_add_return_unchecked - add integer and return
14119 + * @i: integer value to add
14120 + * @v: pointer of type atomic_unchecked_t
14121 + *
14122 + * Atomically adds @i to @v and returns @i + @v
14123 + */
14124 +static inline int atomic_add_return_unchecked(int i, atomic_unchecked_t *v)
14125 +{
14126 return i + xadd(&v->counter, i);
14127 }
14128
14129 @@ -188,6 +362,10 @@ static inline int atomic_sub_return(int i, atomic_t *v)
14130 }
14131
14132 #define atomic_inc_return(v) (atomic_add_return(1, v))
14133 +static inline int atomic_inc_return_unchecked(atomic_unchecked_t *v)
14134 +{
14135 + return atomic_add_return_unchecked(1, v);
14136 +}
14137 #define atomic_dec_return(v) (atomic_sub_return(1, v))
14138
14139 static inline int atomic_cmpxchg(atomic_t *v, int old, int new)
14140 @@ -195,11 +373,21 @@ static inline int atomic_cmpxchg(atomic_t *v, int old, int new)
14141 return cmpxchg(&v->counter, old, new);
14142 }
14143
14144 +static inline int atomic_cmpxchg_unchecked(atomic_unchecked_t *v, int old, int new)
14145 +{
14146 + return cmpxchg(&v->counter, old, new);
14147 +}
14148 +
14149 static inline int atomic_xchg(atomic_t *v, int new)
14150 {
14151 return xchg(&v->counter, new);
14152 }
14153
14154 +static inline int atomic_xchg_unchecked(atomic_unchecked_t *v, int new)
14155 +{
14156 + return xchg(&v->counter, new);
14157 +}
14158 +
14159 /**
14160 * __atomic_add_unless - add unless the number is already a given value
14161 * @v: pointer of type atomic_t
14162 @@ -211,12 +399,25 @@ static inline int atomic_xchg(atomic_t *v, int new)
14163 */
14164 static inline int __atomic_add_unless(atomic_t *v, int a, int u)
14165 {
14166 - int c, old;
14167 + int c, old, new;
14168 c = atomic_read(v);
14169 for (;;) {
14170 - if (unlikely(c == (u)))
14171 + if (unlikely(c == u))
14172 break;
14173 - old = atomic_cmpxchg((v), c, c + (a));
14174 +
14175 + asm volatile("addl %2,%0\n"
14176 +
14177 +#ifdef CONFIG_PAX_REFCOUNT
14178 + "jno 0f\n"
14179 + "subl %2,%0\n"
14180 + "int $4\n0:\n"
14181 + _ASM_EXTABLE(0b, 0b)
14182 +#endif
14183 +
14184 + : "=r" (new)
14185 + : "0" (c), "ir" (a));
14186 +
14187 + old = atomic_cmpxchg(v, c, new);
14188 if (likely(old == c))
14189 break;
14190 c = old;
14191 @@ -225,6 +426,49 @@ static inline int __atomic_add_unless(atomic_t *v, int a, int u)
14192 }
14193
14194 /**
14195 + * atomic_inc_not_zero_hint - increment if not null
14196 + * @v: pointer of type atomic_t
14197 + * @hint: probable value of the atomic before the increment
14198 + *
14199 + * This version of atomic_inc_not_zero() gives a hint of probable
14200 + * value of the atomic. This helps processor to not read the memory
14201 + * before doing the atomic read/modify/write cycle, lowering
14202 + * number of bus transactions on some arches.
14203 + *
14204 + * Returns: 0 if increment was not done, 1 otherwise.
14205 + */
14206 +#define atomic_inc_not_zero_hint atomic_inc_not_zero_hint
14207 +static inline int atomic_inc_not_zero_hint(atomic_t *v, int hint)
14208 +{
14209 + int val, c = hint, new;
14210 +
14211 + /* sanity test, should be removed by compiler if hint is a constant */
14212 + if (!hint)
14213 + return __atomic_add_unless(v, 1, 0);
14214 +
14215 + do {
14216 + asm volatile("incl %0\n"
14217 +
14218 +#ifdef CONFIG_PAX_REFCOUNT
14219 + "jno 0f\n"
14220 + "decl %0\n"
14221 + "int $4\n0:\n"
14222 + _ASM_EXTABLE(0b, 0b)
14223 +#endif
14224 +
14225 + : "=r" (new)
14226 + : "0" (c));
14227 +
14228 + val = atomic_cmpxchg(v, c, new);
14229 + if (val == c)
14230 + return 1;
14231 + c = val;
14232 + } while (c);
14233 +
14234 + return 0;
14235 +}
14236 +
14237 +/**
14238 * atomic_inc_short - increment of a short integer
14239 * @v: pointer to type int
14240 *
14241 @@ -253,14 +497,37 @@ static inline void atomic_or_long(unsigned long *v1, unsigned long v2)
14242 #endif
14243
14244 /* These are x86-specific, used by some header files */
14245 -#define atomic_clear_mask(mask, addr) \
14246 - asm volatile(LOCK_PREFIX "andl %0,%1" \
14247 - : : "r" (~(mask)), "m" (*(addr)) : "memory")
14248 +static inline void atomic_clear_mask(unsigned int mask, atomic_t *v)
14249 +{
14250 + asm volatile(LOCK_PREFIX "andl %1,%0"
14251 + : "+m" (v->counter)
14252 + : "r" (~(mask))
14253 + : "memory");
14254 +}
14255
14256 -#define atomic_set_mask(mask, addr) \
14257 - asm volatile(LOCK_PREFIX "orl %0,%1" \
14258 - : : "r" ((unsigned)(mask)), "m" (*(addr)) \
14259 - : "memory")
14260 +static inline void atomic_clear_mask_unchecked(unsigned int mask, atomic_unchecked_t *v)
14261 +{
14262 + asm volatile(LOCK_PREFIX "andl %1,%0"
14263 + : "+m" (v->counter)
14264 + : "r" (~(mask))
14265 + : "memory");
14266 +}
14267 +
14268 +static inline void atomic_set_mask(unsigned int mask, atomic_t *v)
14269 +{
14270 + asm volatile(LOCK_PREFIX "orl %1,%0"
14271 + : "+m" (v->counter)
14272 + : "r" (mask)
14273 + : "memory");
14274 +}
14275 +
14276 +static inline void atomic_set_mask_unchecked(unsigned int mask, atomic_unchecked_t *v)
14277 +{
14278 + asm volatile(LOCK_PREFIX "orl %1,%0"
14279 + : "+m" (v->counter)
14280 + : "r" (mask)
14281 + : "memory");
14282 +}
14283
14284 /* Atomic operations are already serializing on x86 */
14285 #define smp_mb__before_atomic_dec() barrier()
14286 diff --git a/arch/x86/include/asm/atomic64_32.h b/arch/x86/include/asm/atomic64_32.h
14287 index b154de7..aadebd8 100644
14288 --- a/arch/x86/include/asm/atomic64_32.h
14289 +++ b/arch/x86/include/asm/atomic64_32.h
14290 @@ -12,6 +12,14 @@ typedef struct {
14291 u64 __aligned(8) counter;
14292 } atomic64_t;
14293
14294 +#ifdef CONFIG_PAX_REFCOUNT
14295 +typedef struct {
14296 + u64 __aligned(8) counter;
14297 +} atomic64_unchecked_t;
14298 +#else
14299 +typedef atomic64_t atomic64_unchecked_t;
14300 +#endif
14301 +
14302 #define ATOMIC64_INIT(val) { (val) }
14303
14304 #define __ATOMIC64_DECL(sym) void atomic64_##sym(atomic64_t *, ...)
14305 @@ -37,21 +45,31 @@ typedef struct {
14306 ATOMIC64_DECL_ONE(sym##_386)
14307
14308 ATOMIC64_DECL_ONE(add_386);
14309 +ATOMIC64_DECL_ONE(add_unchecked_386);
14310 ATOMIC64_DECL_ONE(sub_386);
14311 +ATOMIC64_DECL_ONE(sub_unchecked_386);
14312 ATOMIC64_DECL_ONE(inc_386);
14313 +ATOMIC64_DECL_ONE(inc_unchecked_386);
14314 ATOMIC64_DECL_ONE(dec_386);
14315 +ATOMIC64_DECL_ONE(dec_unchecked_386);
14316 #endif
14317
14318 #define alternative_atomic64(f, out, in...) \
14319 __alternative_atomic64(f, f, ASM_OUTPUT2(out), ## in)
14320
14321 ATOMIC64_DECL(read);
14322 +ATOMIC64_DECL(read_unchecked);
14323 ATOMIC64_DECL(set);
14324 +ATOMIC64_DECL(set_unchecked);
14325 ATOMIC64_DECL(xchg);
14326 ATOMIC64_DECL(add_return);
14327 +ATOMIC64_DECL(add_return_unchecked);
14328 ATOMIC64_DECL(sub_return);
14329 +ATOMIC64_DECL(sub_return_unchecked);
14330 ATOMIC64_DECL(inc_return);
14331 +ATOMIC64_DECL(inc_return_unchecked);
14332 ATOMIC64_DECL(dec_return);
14333 +ATOMIC64_DECL(dec_return_unchecked);
14334 ATOMIC64_DECL(dec_if_positive);
14335 ATOMIC64_DECL(inc_not_zero);
14336 ATOMIC64_DECL(add_unless);
14337 @@ -77,6 +95,21 @@ static inline long long atomic64_cmpxchg(atomic64_t *v, long long o, long long n
14338 }
14339
14340 /**
14341 + * atomic64_cmpxchg_unchecked - cmpxchg atomic64 variable
14342 + * @p: pointer to type atomic64_unchecked_t
14343 + * @o: expected value
14344 + * @n: new value
14345 + *
14346 + * Atomically sets @v to @n if it was equal to @o and returns
14347 + * the old value.
14348 + */
14349 +
14350 +static inline long long atomic64_cmpxchg_unchecked(atomic64_unchecked_t *v, long long o, long long n)
14351 +{
14352 + return cmpxchg64(&v->counter, o, n);
14353 +}
14354 +
14355 +/**
14356 * atomic64_xchg - xchg atomic64 variable
14357 * @v: pointer to type atomic64_t
14358 * @n: value to assign
14359 @@ -112,6 +145,22 @@ static inline void atomic64_set(atomic64_t *v, long long i)
14360 }
14361
14362 /**
14363 + * atomic64_set_unchecked - set atomic64 variable
14364 + * @v: pointer to type atomic64_unchecked_t
14365 + * @n: value to assign
14366 + *
14367 + * Atomically sets the value of @v to @n.
14368 + */
14369 +static inline void atomic64_set_unchecked(atomic64_unchecked_t *v, long long i)
14370 +{
14371 + unsigned high = (unsigned)(i >> 32);
14372 + unsigned low = (unsigned)i;
14373 + alternative_atomic64(set, /* no output */,
14374 + "S" (v), "b" (low), "c" (high)
14375 + : "eax", "edx", "memory");
14376 +}
14377 +
14378 +/**
14379 * atomic64_read - read atomic64 variable
14380 * @v: pointer to type atomic64_t
14381 *
14382 @@ -125,6 +174,19 @@ static inline long long atomic64_read(const atomic64_t *v)
14383 }
14384
14385 /**
14386 + * atomic64_read_unchecked - read atomic64 variable
14387 + * @v: pointer to type atomic64_unchecked_t
14388 + *
14389 + * Atomically reads the value of @v and returns it.
14390 + */
14391 +static inline long long atomic64_read_unchecked(atomic64_unchecked_t *v)
14392 +{
14393 + long long r;
14394 + alternative_atomic64(read, "=&A" (r), "c" (v) : "memory");
14395 + return r;
14396 + }
14397 +
14398 +/**
14399 * atomic64_add_return - add and return
14400 * @i: integer value to add
14401 * @v: pointer to type atomic64_t
14402 @@ -139,6 +201,21 @@ static inline long long atomic64_add_return(long long i, atomic64_t *v)
14403 return i;
14404 }
14405
14406 +/**
14407 + * atomic64_add_return_unchecked - add and return
14408 + * @i: integer value to add
14409 + * @v: pointer to type atomic64_unchecked_t
14410 + *
14411 + * Atomically adds @i to @v and returns @i + *@v
14412 + */
14413 +static inline long long atomic64_add_return_unchecked(long long i, atomic64_unchecked_t *v)
14414 +{
14415 + alternative_atomic64(add_return_unchecked,
14416 + ASM_OUTPUT2("+A" (i), "+c" (v)),
14417 + ASM_NO_INPUT_CLOBBER("memory"));
14418 + return i;
14419 +}
14420 +
14421 /*
14422 * Other variants with different arithmetic operators:
14423 */
14424 @@ -158,6 +235,14 @@ static inline long long atomic64_inc_return(atomic64_t *v)
14425 return a;
14426 }
14427
14428 +static inline long long atomic64_inc_return_unchecked(atomic64_unchecked_t *v)
14429 +{
14430 + long long a;
14431 + alternative_atomic64(inc_return_unchecked, "=&A" (a),
14432 + "S" (v) : "memory", "ecx");
14433 + return a;
14434 +}
14435 +
14436 static inline long long atomic64_dec_return(atomic64_t *v)
14437 {
14438 long long a;
14439 @@ -182,6 +267,21 @@ static inline long long atomic64_add(long long i, atomic64_t *v)
14440 }
14441
14442 /**
14443 + * atomic64_add_unchecked - add integer to atomic64 variable
14444 + * @i: integer value to add
14445 + * @v: pointer to type atomic64_unchecked_t
14446 + *
14447 + * Atomically adds @i to @v.
14448 + */
14449 +static inline long long atomic64_add_unchecked(long long i, atomic64_unchecked_t *v)
14450 +{
14451 + __alternative_atomic64(add_unchecked, add_return_unchecked,
14452 + ASM_OUTPUT2("+A" (i), "+c" (v)),
14453 + ASM_NO_INPUT_CLOBBER("memory"));
14454 + return i;
14455 +}
14456 +
14457 +/**
14458 * atomic64_sub - subtract the atomic64 variable
14459 * @i: integer value to subtract
14460 * @v: pointer to type atomic64_t
14461 diff --git a/arch/x86/include/asm/atomic64_64.h b/arch/x86/include/asm/atomic64_64.h
14462 index 0e1cbfc..5623683 100644
14463 --- a/arch/x86/include/asm/atomic64_64.h
14464 +++ b/arch/x86/include/asm/atomic64_64.h
14465 @@ -18,7 +18,19 @@
14466 */
14467 static inline long atomic64_read(const atomic64_t *v)
14468 {
14469 - return (*(volatile long *)&(v)->counter);
14470 + return (*(volatile const long *)&(v)->counter);
14471 +}
14472 +
14473 +/**
14474 + * atomic64_read_unchecked - read atomic64 variable
14475 + * @v: pointer of type atomic64_unchecked_t
14476 + *
14477 + * Atomically reads the value of @v.
14478 + * Doesn't imply a read memory barrier.
14479 + */
14480 +static inline long atomic64_read_unchecked(const atomic64_unchecked_t *v)
14481 +{
14482 + return (*(volatile const long *)&(v)->counter);
14483 }
14484
14485 /**
14486 @@ -34,6 +46,18 @@ static inline void atomic64_set(atomic64_t *v, long i)
14487 }
14488
14489 /**
14490 + * atomic64_set_unchecked - set atomic64 variable
14491 + * @v: pointer to type atomic64_unchecked_t
14492 + * @i: required value
14493 + *
14494 + * Atomically sets the value of @v to @i.
14495 + */
14496 +static inline void atomic64_set_unchecked(atomic64_unchecked_t *v, long i)
14497 +{
14498 + v->counter = i;
14499 +}
14500 +
14501 +/**
14502 * atomic64_add - add integer to atomic64 variable
14503 * @i: integer value to add
14504 * @v: pointer to type atomic64_t
14505 @@ -42,6 +66,28 @@ static inline void atomic64_set(atomic64_t *v, long i)
14506 */
14507 static inline void atomic64_add(long i, atomic64_t *v)
14508 {
14509 + asm volatile(LOCK_PREFIX "addq %1,%0\n"
14510 +
14511 +#ifdef CONFIG_PAX_REFCOUNT
14512 + "jno 0f\n"
14513 + LOCK_PREFIX "subq %1,%0\n"
14514 + "int $4\n0:\n"
14515 + _ASM_EXTABLE(0b, 0b)
14516 +#endif
14517 +
14518 + : "=m" (v->counter)
14519 + : "er" (i), "m" (v->counter));
14520 +}
14521 +
14522 +/**
14523 + * atomic64_add_unchecked - add integer to atomic64 variable
14524 + * @i: integer value to add
14525 + * @v: pointer to type atomic64_unchecked_t
14526 + *
14527 + * Atomically adds @i to @v.
14528 + */
14529 +static inline void atomic64_add_unchecked(long i, atomic64_unchecked_t *v)
14530 +{
14531 asm volatile(LOCK_PREFIX "addq %1,%0"
14532 : "=m" (v->counter)
14533 : "er" (i), "m" (v->counter));
14534 @@ -56,7 +102,29 @@ static inline void atomic64_add(long i, atomic64_t *v)
14535 */
14536 static inline void atomic64_sub(long i, atomic64_t *v)
14537 {
14538 - asm volatile(LOCK_PREFIX "subq %1,%0"
14539 + asm volatile(LOCK_PREFIX "subq %1,%0\n"
14540 +
14541 +#ifdef CONFIG_PAX_REFCOUNT
14542 + "jno 0f\n"
14543 + LOCK_PREFIX "addq %1,%0\n"
14544 + "int $4\n0:\n"
14545 + _ASM_EXTABLE(0b, 0b)
14546 +#endif
14547 +
14548 + : "=m" (v->counter)
14549 + : "er" (i), "m" (v->counter));
14550 +}
14551 +
14552 +/**
14553 + * atomic64_sub_unchecked - subtract the atomic64 variable
14554 + * @i: integer value to subtract
14555 + * @v: pointer to type atomic64_unchecked_t
14556 + *
14557 + * Atomically subtracts @i from @v.
14558 + */
14559 +static inline void atomic64_sub_unchecked(long i, atomic64_unchecked_t *v)
14560 +{
14561 + asm volatile(LOCK_PREFIX "subq %1,%0\n"
14562 : "=m" (v->counter)
14563 : "er" (i), "m" (v->counter));
14564 }
14565 @@ -74,7 +142,16 @@ static inline int atomic64_sub_and_test(long i, atomic64_t *v)
14566 {
14567 unsigned char c;
14568
14569 - asm volatile(LOCK_PREFIX "subq %2,%0; sete %1"
14570 + asm volatile(LOCK_PREFIX "subq %2,%0\n"
14571 +
14572 +#ifdef CONFIG_PAX_REFCOUNT
14573 + "jno 0f\n"
14574 + LOCK_PREFIX "addq %2,%0\n"
14575 + "int $4\n0:\n"
14576 + _ASM_EXTABLE(0b, 0b)
14577 +#endif
14578 +
14579 + "sete %1\n"
14580 : "=m" (v->counter), "=qm" (c)
14581 : "er" (i), "m" (v->counter) : "memory");
14582 return c;
14583 @@ -88,6 +165,27 @@ static inline int atomic64_sub_and_test(long i, atomic64_t *v)
14584 */
14585 static inline void atomic64_inc(atomic64_t *v)
14586 {
14587 + asm volatile(LOCK_PREFIX "incq %0\n"
14588 +
14589 +#ifdef CONFIG_PAX_REFCOUNT
14590 + "jno 0f\n"
14591 + LOCK_PREFIX "decq %0\n"
14592 + "int $4\n0:\n"
14593 + _ASM_EXTABLE(0b, 0b)
14594 +#endif
14595 +
14596 + : "=m" (v->counter)
14597 + : "m" (v->counter));
14598 +}
14599 +
14600 +/**
14601 + * atomic64_inc_unchecked - increment atomic64 variable
14602 + * @v: pointer to type atomic64_unchecked_t
14603 + *
14604 + * Atomically increments @v by 1.
14605 + */
14606 +static inline void atomic64_inc_unchecked(atomic64_unchecked_t *v)
14607 +{
14608 asm volatile(LOCK_PREFIX "incq %0"
14609 : "=m" (v->counter)
14610 : "m" (v->counter));
14611 @@ -101,7 +199,28 @@ static inline void atomic64_inc(atomic64_t *v)
14612 */
14613 static inline void atomic64_dec(atomic64_t *v)
14614 {
14615 - asm volatile(LOCK_PREFIX "decq %0"
14616 + asm volatile(LOCK_PREFIX "decq %0\n"
14617 +
14618 +#ifdef CONFIG_PAX_REFCOUNT
14619 + "jno 0f\n"
14620 + LOCK_PREFIX "incq %0\n"
14621 + "int $4\n0:\n"
14622 + _ASM_EXTABLE(0b, 0b)
14623 +#endif
14624 +
14625 + : "=m" (v->counter)
14626 + : "m" (v->counter));
14627 +}
14628 +
14629 +/**
14630 + * atomic64_dec_unchecked - decrement atomic64 variable
14631 + * @v: pointer to type atomic64_t
14632 + *
14633 + * Atomically decrements @v by 1.
14634 + */
14635 +static inline void atomic64_dec_unchecked(atomic64_unchecked_t *v)
14636 +{
14637 + asm volatile(LOCK_PREFIX "decq %0\n"
14638 : "=m" (v->counter)
14639 : "m" (v->counter));
14640 }
14641 @@ -118,7 +237,16 @@ static inline int atomic64_dec_and_test(atomic64_t *v)
14642 {
14643 unsigned char c;
14644
14645 - asm volatile(LOCK_PREFIX "decq %0; sete %1"
14646 + asm volatile(LOCK_PREFIX "decq %0\n"
14647 +
14648 +#ifdef CONFIG_PAX_REFCOUNT
14649 + "jno 0f\n"
14650 + LOCK_PREFIX "incq %0\n"
14651 + "int $4\n0:\n"
14652 + _ASM_EXTABLE(0b, 0b)
14653 +#endif
14654 +
14655 + "sete %1\n"
14656 : "=m" (v->counter), "=qm" (c)
14657 : "m" (v->counter) : "memory");
14658 return c != 0;
14659 @@ -136,7 +264,16 @@ static inline int atomic64_inc_and_test(atomic64_t *v)
14660 {
14661 unsigned char c;
14662
14663 - asm volatile(LOCK_PREFIX "incq %0; sete %1"
14664 + asm volatile(LOCK_PREFIX "incq %0\n"
14665 +
14666 +#ifdef CONFIG_PAX_REFCOUNT
14667 + "jno 0f\n"
14668 + LOCK_PREFIX "decq %0\n"
14669 + "int $4\n0:\n"
14670 + _ASM_EXTABLE(0b, 0b)
14671 +#endif
14672 +
14673 + "sete %1\n"
14674 : "=m" (v->counter), "=qm" (c)
14675 : "m" (v->counter) : "memory");
14676 return c != 0;
14677 @@ -155,7 +292,16 @@ static inline int atomic64_add_negative(long i, atomic64_t *v)
14678 {
14679 unsigned char c;
14680
14681 - asm volatile(LOCK_PREFIX "addq %2,%0; sets %1"
14682 + asm volatile(LOCK_PREFIX "addq %2,%0\n"
14683 +
14684 +#ifdef CONFIG_PAX_REFCOUNT
14685 + "jno 0f\n"
14686 + LOCK_PREFIX "subq %2,%0\n"
14687 + "int $4\n0:\n"
14688 + _ASM_EXTABLE(0b, 0b)
14689 +#endif
14690 +
14691 + "sets %1\n"
14692 : "=m" (v->counter), "=qm" (c)
14693 : "er" (i), "m" (v->counter) : "memory");
14694 return c;
14695 @@ -170,6 +316,18 @@ static inline int atomic64_add_negative(long i, atomic64_t *v)
14696 */
14697 static inline long atomic64_add_return(long i, atomic64_t *v)
14698 {
14699 + return i + xadd_check_overflow(&v->counter, i);
14700 +}
14701 +
14702 +/**
14703 + * atomic64_add_return_unchecked - add and return
14704 + * @i: integer value to add
14705 + * @v: pointer to type atomic64_unchecked_t
14706 + *
14707 + * Atomically adds @i to @v and returns @i + @v
14708 + */
14709 +static inline long atomic64_add_return_unchecked(long i, atomic64_unchecked_t *v)
14710 +{
14711 return i + xadd(&v->counter, i);
14712 }
14713
14714 @@ -179,6 +337,10 @@ static inline long atomic64_sub_return(long i, atomic64_t *v)
14715 }
14716
14717 #define atomic64_inc_return(v) (atomic64_add_return(1, (v)))
14718 +static inline long atomic64_inc_return_unchecked(atomic64_unchecked_t *v)
14719 +{
14720 + return atomic64_add_return_unchecked(1, v);
14721 +}
14722 #define atomic64_dec_return(v) (atomic64_sub_return(1, (v)))
14723
14724 static inline long atomic64_cmpxchg(atomic64_t *v, long old, long new)
14725 @@ -186,6 +348,11 @@ static inline long atomic64_cmpxchg(atomic64_t *v, long old, long new)
14726 return cmpxchg(&v->counter, old, new);
14727 }
14728
14729 +static inline long atomic64_cmpxchg_unchecked(atomic64_unchecked_t *v, long old, long new)
14730 +{
14731 + return cmpxchg(&v->counter, old, new);
14732 +}
14733 +
14734 static inline long atomic64_xchg(atomic64_t *v, long new)
14735 {
14736 return xchg(&v->counter, new);
14737 @@ -202,17 +369,30 @@ static inline long atomic64_xchg(atomic64_t *v, long new)
14738 */
14739 static inline int atomic64_add_unless(atomic64_t *v, long a, long u)
14740 {
14741 - long c, old;
14742 + long c, old, new;
14743 c = atomic64_read(v);
14744 for (;;) {
14745 - if (unlikely(c == (u)))
14746 + if (unlikely(c == u))
14747 break;
14748 - old = atomic64_cmpxchg((v), c, c + (a));
14749 +
14750 + asm volatile("add %2,%0\n"
14751 +
14752 +#ifdef CONFIG_PAX_REFCOUNT
14753 + "jno 0f\n"
14754 + "sub %2,%0\n"
14755 + "int $4\n0:\n"
14756 + _ASM_EXTABLE(0b, 0b)
14757 +#endif
14758 +
14759 + : "=r" (new)
14760 + : "0" (c), "ir" (a));
14761 +
14762 + old = atomic64_cmpxchg(v, c, new);
14763 if (likely(old == c))
14764 break;
14765 c = old;
14766 }
14767 - return c != (u);
14768 + return c != u;
14769 }
14770
14771 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1, 0)
14772 diff --git a/arch/x86/include/asm/bitops.h b/arch/x86/include/asm/bitops.h
14773 index 41639ce..ebce552 100644
14774 --- a/arch/x86/include/asm/bitops.h
14775 +++ b/arch/x86/include/asm/bitops.h
14776 @@ -48,7 +48,7 @@
14777 * a mask operation on a byte.
14778 */
14779 #define IS_IMMEDIATE(nr) (__builtin_constant_p(nr))
14780 -#define CONST_MASK_ADDR(nr, addr) BITOP_ADDR((void *)(addr) + ((nr)>>3))
14781 +#define CONST_MASK_ADDR(nr, addr) BITOP_ADDR((volatile void *)(addr) + ((nr)>>3))
14782 #define CONST_MASK(nr) (1 << ((nr) & 7))
14783
14784 /**
14785 @@ -361,7 +361,7 @@ static int test_bit(int nr, const volatile unsigned long *addr);
14786 *
14787 * Undefined if no bit exists, so code should check against 0 first.
14788 */
14789 -static inline unsigned long __ffs(unsigned long word)
14790 +static inline unsigned long __intentional_overflow(-1) __ffs(unsigned long word)
14791 {
14792 asm("rep; bsf %1,%0"
14793 : "=r" (word)
14794 @@ -375,7 +375,7 @@ static inline unsigned long __ffs(unsigned long word)
14795 *
14796 * Undefined if no zero exists, so code should check against ~0UL first.
14797 */
14798 -static inline unsigned long ffz(unsigned long word)
14799 +static inline unsigned long __intentional_overflow(-1) ffz(unsigned long word)
14800 {
14801 asm("rep; bsf %1,%0"
14802 : "=r" (word)
14803 @@ -389,7 +389,7 @@ static inline unsigned long ffz(unsigned long word)
14804 *
14805 * Undefined if no set bit exists, so code should check against 0 first.
14806 */
14807 -static inline unsigned long __fls(unsigned long word)
14808 +static inline unsigned long __intentional_overflow(-1) __fls(unsigned long word)
14809 {
14810 asm("bsr %1,%0"
14811 : "=r" (word)
14812 @@ -452,7 +452,7 @@ static inline int ffs(int x)
14813 * set bit if value is nonzero. The last (most significant) bit is
14814 * at position 32.
14815 */
14816 -static inline int fls(int x)
14817 +static inline int __intentional_overflow(-1) fls(int x)
14818 {
14819 int r;
14820
14821 @@ -494,7 +494,7 @@ static inline int fls(int x)
14822 * at position 64.
14823 */
14824 #ifdef CONFIG_X86_64
14825 -static __always_inline int fls64(__u64 x)
14826 +static __always_inline long fls64(__u64 x)
14827 {
14828 int bitpos = -1;
14829 /*
14830 diff --git a/arch/x86/include/asm/boot.h b/arch/x86/include/asm/boot.h
14831 index 4fa687a..60f2d39 100644
14832 --- a/arch/x86/include/asm/boot.h
14833 +++ b/arch/x86/include/asm/boot.h
14834 @@ -6,10 +6,15 @@
14835 #include <uapi/asm/boot.h>
14836
14837 /* Physical address where kernel should be loaded. */
14838 -#define LOAD_PHYSICAL_ADDR ((CONFIG_PHYSICAL_START \
14839 +#define ____LOAD_PHYSICAL_ADDR ((CONFIG_PHYSICAL_START \
14840 + (CONFIG_PHYSICAL_ALIGN - 1)) \
14841 & ~(CONFIG_PHYSICAL_ALIGN - 1))
14842
14843 +#ifndef __ASSEMBLY__
14844 +extern unsigned char __LOAD_PHYSICAL_ADDR[];
14845 +#define LOAD_PHYSICAL_ADDR ((unsigned long)__LOAD_PHYSICAL_ADDR)
14846 +#endif
14847 +
14848 /* Minimum kernel alignment, as a power of two */
14849 #ifdef CONFIG_X86_64
14850 #define MIN_KERNEL_ALIGN_LG2 PMD_SHIFT
14851 diff --git a/arch/x86/include/asm/cache.h b/arch/x86/include/asm/cache.h
14852 index 48f99f1..d78ebf9 100644
14853 --- a/arch/x86/include/asm/cache.h
14854 +++ b/arch/x86/include/asm/cache.h
14855 @@ -5,12 +5,13 @@
14856
14857 /* L1 cache line size */
14858 #define L1_CACHE_SHIFT (CONFIG_X86_L1_CACHE_SHIFT)
14859 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
14860 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
14861
14862 #define __read_mostly __attribute__((__section__(".data..read_mostly")))
14863 +#define __read_only __attribute__((__section__(".data..read_only")))
14864
14865 #define INTERNODE_CACHE_SHIFT CONFIG_X86_INTERNODE_CACHE_SHIFT
14866 -#define INTERNODE_CACHE_BYTES (1 << INTERNODE_CACHE_SHIFT)
14867 +#define INTERNODE_CACHE_BYTES (_AC(1,UL) << INTERNODE_CACHE_SHIFT)
14868
14869 #ifdef CONFIG_X86_VSMP
14870 #ifdef CONFIG_SMP
14871 diff --git a/arch/x86/include/asm/cacheflush.h b/arch/x86/include/asm/cacheflush.h
14872 index 9863ee3..4a1f8e1 100644
14873 --- a/arch/x86/include/asm/cacheflush.h
14874 +++ b/arch/x86/include/asm/cacheflush.h
14875 @@ -27,7 +27,7 @@ static inline unsigned long get_page_memtype(struct page *pg)
14876 unsigned long pg_flags = pg->flags & _PGMT_MASK;
14877
14878 if (pg_flags == _PGMT_DEFAULT)
14879 - return -1;
14880 + return ~0UL;
14881 else if (pg_flags == _PGMT_WC)
14882 return _PAGE_CACHE_WC;
14883 else if (pg_flags == _PGMT_UC_MINUS)
14884 diff --git a/arch/x86/include/asm/checksum_32.h b/arch/x86/include/asm/checksum_32.h
14885 index f50de69..2b0a458 100644
14886 --- a/arch/x86/include/asm/checksum_32.h
14887 +++ b/arch/x86/include/asm/checksum_32.h
14888 @@ -31,6 +31,14 @@ asmlinkage __wsum csum_partial_copy_generic(const void *src, void *dst,
14889 int len, __wsum sum,
14890 int *src_err_ptr, int *dst_err_ptr);
14891
14892 +asmlinkage __wsum csum_partial_copy_generic_to_user(const void *src, void *dst,
14893 + int len, __wsum sum,
14894 + int *src_err_ptr, int *dst_err_ptr);
14895 +
14896 +asmlinkage __wsum csum_partial_copy_generic_from_user(const void *src, void *dst,
14897 + int len, __wsum sum,
14898 + int *src_err_ptr, int *dst_err_ptr);
14899 +
14900 /*
14901 * Note: when you get a NULL pointer exception here this means someone
14902 * passed in an incorrect kernel address to one of these functions.
14903 @@ -53,7 +61,7 @@ static inline __wsum csum_partial_copy_from_user(const void __user *src,
14904
14905 might_sleep();
14906 stac();
14907 - ret = csum_partial_copy_generic((__force void *)src, dst,
14908 + ret = csum_partial_copy_generic_from_user((__force void *)src, dst,
14909 len, sum, err_ptr, NULL);
14910 clac();
14911
14912 @@ -187,7 +195,7 @@ static inline __wsum csum_and_copy_to_user(const void *src,
14913 might_sleep();
14914 if (access_ok(VERIFY_WRITE, dst, len)) {
14915 stac();
14916 - ret = csum_partial_copy_generic(src, (__force void *)dst,
14917 + ret = csum_partial_copy_generic_to_user(src, (__force void *)dst,
14918 len, sum, NULL, err_ptr);
14919 clac();
14920 return ret;
14921 diff --git a/arch/x86/include/asm/cmpxchg.h b/arch/x86/include/asm/cmpxchg.h
14922 index d47786a..ce1b05d 100644
14923 --- a/arch/x86/include/asm/cmpxchg.h
14924 +++ b/arch/x86/include/asm/cmpxchg.h
14925 @@ -14,8 +14,12 @@ extern void __cmpxchg_wrong_size(void)
14926 __compiletime_error("Bad argument size for cmpxchg");
14927 extern void __xadd_wrong_size(void)
14928 __compiletime_error("Bad argument size for xadd");
14929 +extern void __xadd_check_overflow_wrong_size(void)
14930 + __compiletime_error("Bad argument size for xadd_check_overflow");
14931 extern void __add_wrong_size(void)
14932 __compiletime_error("Bad argument size for add");
14933 +extern void __add_check_overflow_wrong_size(void)
14934 + __compiletime_error("Bad argument size for add_check_overflow");
14935
14936 /*
14937 * Constants for operation sizes. On 32-bit, the 64-bit size it set to
14938 @@ -67,6 +71,34 @@ extern void __add_wrong_size(void)
14939 __ret; \
14940 })
14941
14942 +#define __xchg_op_check_overflow(ptr, arg, op, lock) \
14943 + ({ \
14944 + __typeof__ (*(ptr)) __ret = (arg); \
14945 + switch (sizeof(*(ptr))) { \
14946 + case __X86_CASE_L: \
14947 + asm volatile (lock #op "l %0, %1\n" \
14948 + "jno 0f\n" \
14949 + "mov %0,%1\n" \
14950 + "int $4\n0:\n" \
14951 + _ASM_EXTABLE(0b, 0b) \
14952 + : "+r" (__ret), "+m" (*(ptr)) \
14953 + : : "memory", "cc"); \
14954 + break; \
14955 + case __X86_CASE_Q: \
14956 + asm volatile (lock #op "q %q0, %1\n" \
14957 + "jno 0f\n" \
14958 + "mov %0,%1\n" \
14959 + "int $4\n0:\n" \
14960 + _ASM_EXTABLE(0b, 0b) \
14961 + : "+r" (__ret), "+m" (*(ptr)) \
14962 + : : "memory", "cc"); \
14963 + break; \
14964 + default: \
14965 + __ ## op ## _check_overflow_wrong_size(); \
14966 + } \
14967 + __ret; \
14968 + })
14969 +
14970 /*
14971 * Note: no "lock" prefix even on SMP: xchg always implies lock anyway.
14972 * Since this is generally used to protect other memory information, we
14973 @@ -167,6 +199,9 @@ extern void __add_wrong_size(void)
14974 #define xadd_sync(ptr, inc) __xadd((ptr), (inc), "lock; ")
14975 #define xadd_local(ptr, inc) __xadd((ptr), (inc), "")
14976
14977 +#define __xadd_check_overflow(ptr, inc, lock) __xchg_op_check_overflow((ptr), (inc), xadd, lock)
14978 +#define xadd_check_overflow(ptr, inc) __xadd_check_overflow((ptr), (inc), LOCK_PREFIX)
14979 +
14980 #define __add(ptr, inc, lock) \
14981 ({ \
14982 __typeof__ (*(ptr)) __ret = (inc); \
14983 diff --git a/arch/x86/include/asm/compat.h b/arch/x86/include/asm/compat.h
14984 index 59c6c40..5e0b22c 100644
14985 --- a/arch/x86/include/asm/compat.h
14986 +++ b/arch/x86/include/asm/compat.h
14987 @@ -41,7 +41,7 @@ typedef s64 __attribute__((aligned(4))) compat_s64;
14988 typedef u32 compat_uint_t;
14989 typedef u32 compat_ulong_t;
14990 typedef u64 __attribute__((aligned(4))) compat_u64;
14991 -typedef u32 compat_uptr_t;
14992 +typedef u32 __user compat_uptr_t;
14993
14994 struct compat_timespec {
14995 compat_time_t tv_sec;
14996 diff --git a/arch/x86/include/asm/cpufeature.h b/arch/x86/include/asm/cpufeature.h
14997 index 89270b4..f0abf8e 100644
14998 --- a/arch/x86/include/asm/cpufeature.h
14999 +++ b/arch/x86/include/asm/cpufeature.h
15000 @@ -203,7 +203,7 @@
15001 #define X86_FEATURE_DECODEASSISTS (8*32+12) /* AMD Decode Assists support */
15002 #define X86_FEATURE_PAUSEFILTER (8*32+13) /* AMD filtered pause intercept */
15003 #define X86_FEATURE_PFTHRESHOLD (8*32+14) /* AMD pause filter threshold */
15004 -
15005 +#define X86_FEATURE_STRONGUDEREF (8*32+31) /* PaX PCID based strong UDEREF */
15006
15007 /* Intel-defined CPU features, CPUID level 0x00000007:0 (ebx), word 9 */
15008 #define X86_FEATURE_FSGSBASE (9*32+ 0) /* {RD/WR}{FS/GS}BASE instructions*/
15009 @@ -211,7 +211,7 @@
15010 #define X86_FEATURE_BMI1 (9*32+ 3) /* 1st group bit manipulation extensions */
15011 #define X86_FEATURE_HLE (9*32+ 4) /* Hardware Lock Elision */
15012 #define X86_FEATURE_AVX2 (9*32+ 5) /* AVX2 instructions */
15013 -#define X86_FEATURE_SMEP (9*32+ 7) /* Supervisor Mode Execution Protection */
15014 +#define X86_FEATURE_SMEP (9*32+ 7) /* Supervisor Mode Execution Prevention */
15015 #define X86_FEATURE_BMI2 (9*32+ 8) /* 2nd group bit manipulation extensions */
15016 #define X86_FEATURE_ERMS (9*32+ 9) /* Enhanced REP MOVSB/STOSB */
15017 #define X86_FEATURE_INVPCID (9*32+10) /* Invalidate Processor Context ID */
15018 @@ -353,6 +353,7 @@ extern const char * const x86_power_flags[32];
15019 #undef cpu_has_centaur_mcr
15020 #define cpu_has_centaur_mcr 0
15021
15022 +#define cpu_has_pcid boot_cpu_has(X86_FEATURE_PCID)
15023 #endif /* CONFIG_X86_64 */
15024
15025 #if __GNUC__ >= 4
15026 @@ -405,7 +406,8 @@ static __always_inline __pure bool __static_cpu_has(u16 bit)
15027
15028 #ifdef CONFIG_X86_DEBUG_STATIC_CPU_HAS
15029 t_warn:
15030 - warn_pre_alternatives();
15031 + if (bit != X86_FEATURE_PCID && bit != X86_FEATURE_INVPCID)
15032 + warn_pre_alternatives();
15033 return false;
15034 #endif
15035
15036 @@ -425,7 +427,7 @@ static __always_inline __pure bool __static_cpu_has(u16 bit)
15037 ".section .discard,\"aw\",@progbits\n"
15038 " .byte 0xff + (4f-3f) - (2b-1b)\n" /* size check */
15039 ".previous\n"
15040 - ".section .altinstr_replacement,\"ax\"\n"
15041 + ".section .altinstr_replacement,\"a\"\n"
15042 "3: movb $1,%0\n"
15043 "4:\n"
15044 ".previous\n"
15045 @@ -462,7 +464,7 @@ static __always_inline __pure bool _static_cpu_has_safe(u16 bit)
15046 " .byte 2b - 1b\n" /* src len */
15047 " .byte 4f - 3f\n" /* repl len */
15048 ".previous\n"
15049 - ".section .altinstr_replacement,\"ax\"\n"
15050 + ".section .altinstr_replacement,\"a\"\n"
15051 "3: .byte 0xe9\n .long %l[t_no] - 2b\n"
15052 "4:\n"
15053 ".previous\n"
15054 @@ -495,7 +497,7 @@ static __always_inline __pure bool _static_cpu_has_safe(u16 bit)
15055 ".section .discard,\"aw\",@progbits\n"
15056 " .byte 0xff + (4f-3f) - (2b-1b)\n" /* size check */
15057 ".previous\n"
15058 - ".section .altinstr_replacement,\"ax\"\n"
15059 + ".section .altinstr_replacement,\"a\"\n"
15060 "3: movb $0,%0\n"
15061 "4:\n"
15062 ".previous\n"
15063 @@ -509,7 +511,7 @@ static __always_inline __pure bool _static_cpu_has_safe(u16 bit)
15064 ".section .discard,\"aw\",@progbits\n"
15065 " .byte 0xff + (6f-5f) - (4b-3b)\n" /* size check */
15066 ".previous\n"
15067 - ".section .altinstr_replacement,\"ax\"\n"
15068 + ".section .altinstr_replacement,\"a\"\n"
15069 "5: movb $1,%0\n"
15070 "6:\n"
15071 ".previous\n"
15072 diff --git a/arch/x86/include/asm/desc.h b/arch/x86/include/asm/desc.h
15073 index b90e5df..b462c91 100644
15074 --- a/arch/x86/include/asm/desc.h
15075 +++ b/arch/x86/include/asm/desc.h
15076 @@ -4,6 +4,7 @@
15077 #include <asm/desc_defs.h>
15078 #include <asm/ldt.h>
15079 #include <asm/mmu.h>
15080 +#include <asm/pgtable.h>
15081
15082 #include <linux/smp.h>
15083 #include <linux/percpu.h>
15084 @@ -17,6 +18,7 @@ static inline void fill_ldt(struct desc_struct *desc, const struct user_desc *in
15085
15086 desc->type = (info->read_exec_only ^ 1) << 1;
15087 desc->type |= info->contents << 2;
15088 + desc->type |= info->seg_not_present ^ 1;
15089
15090 desc->s = 1;
15091 desc->dpl = 0x3;
15092 @@ -35,19 +37,14 @@ static inline void fill_ldt(struct desc_struct *desc, const struct user_desc *in
15093 }
15094
15095 extern struct desc_ptr idt_descr;
15096 -extern gate_desc idt_table[];
15097 -extern struct desc_ptr debug_idt_descr;
15098 -extern gate_desc debug_idt_table[];
15099 -
15100 -struct gdt_page {
15101 - struct desc_struct gdt[GDT_ENTRIES];
15102 -} __attribute__((aligned(PAGE_SIZE)));
15103 -
15104 -DECLARE_PER_CPU_PAGE_ALIGNED(struct gdt_page, gdt_page);
15105 +extern gate_desc idt_table[IDT_ENTRIES];
15106 +extern const struct desc_ptr debug_idt_descr;
15107 +extern gate_desc debug_idt_table[IDT_ENTRIES];
15108
15109 +extern struct desc_struct cpu_gdt_table[NR_CPUS][PAGE_SIZE / sizeof(struct desc_struct)];
15110 static inline struct desc_struct *get_cpu_gdt_table(unsigned int cpu)
15111 {
15112 - return per_cpu(gdt_page, cpu).gdt;
15113 + return cpu_gdt_table[cpu];
15114 }
15115
15116 #ifdef CONFIG_X86_64
15117 @@ -72,8 +69,14 @@ static inline void pack_gate(gate_desc *gate, unsigned char type,
15118 unsigned long base, unsigned dpl, unsigned flags,
15119 unsigned short seg)
15120 {
15121 - gate->a = (seg << 16) | (base & 0xffff);
15122 - gate->b = (base & 0xffff0000) | (((0x80 | type | (dpl << 5)) & 0xff) << 8);
15123 + gate->gate.offset_low = base;
15124 + gate->gate.seg = seg;
15125 + gate->gate.reserved = 0;
15126 + gate->gate.type = type;
15127 + gate->gate.s = 0;
15128 + gate->gate.dpl = dpl;
15129 + gate->gate.p = 1;
15130 + gate->gate.offset_high = base >> 16;
15131 }
15132
15133 #endif
15134 @@ -118,12 +121,16 @@ static inline void paravirt_free_ldt(struct desc_struct *ldt, unsigned entries)
15135
15136 static inline void native_write_idt_entry(gate_desc *idt, int entry, const gate_desc *gate)
15137 {
15138 + pax_open_kernel();
15139 memcpy(&idt[entry], gate, sizeof(*gate));
15140 + pax_close_kernel();
15141 }
15142
15143 static inline void native_write_ldt_entry(struct desc_struct *ldt, int entry, const void *desc)
15144 {
15145 + pax_open_kernel();
15146 memcpy(&ldt[entry], desc, 8);
15147 + pax_close_kernel();
15148 }
15149
15150 static inline void
15151 @@ -137,7 +144,9 @@ native_write_gdt_entry(struct desc_struct *gdt, int entry, const void *desc, int
15152 default: size = sizeof(*gdt); break;
15153 }
15154
15155 + pax_open_kernel();
15156 memcpy(&gdt[entry], desc, size);
15157 + pax_close_kernel();
15158 }
15159
15160 static inline void pack_descriptor(struct desc_struct *desc, unsigned long base,
15161 @@ -210,7 +219,9 @@ static inline void native_set_ldt(const void *addr, unsigned int entries)
15162
15163 static inline void native_load_tr_desc(void)
15164 {
15165 + pax_open_kernel();
15166 asm volatile("ltr %w0"::"q" (GDT_ENTRY_TSS*8));
15167 + pax_close_kernel();
15168 }
15169
15170 static inline void native_load_gdt(const struct desc_ptr *dtr)
15171 @@ -247,8 +258,10 @@ static inline void native_load_tls(struct thread_struct *t, unsigned int cpu)
15172 struct desc_struct *gdt = get_cpu_gdt_table(cpu);
15173 unsigned int i;
15174
15175 + pax_open_kernel();
15176 for (i = 0; i < GDT_ENTRY_TLS_ENTRIES; i++)
15177 gdt[GDT_ENTRY_TLS_MIN + i] = t->tls_array[i];
15178 + pax_close_kernel();
15179 }
15180
15181 #define _LDT_empty(info) \
15182 @@ -287,7 +300,7 @@ static inline void load_LDT(mm_context_t *pc)
15183 preempt_enable();
15184 }
15185
15186 -static inline unsigned long get_desc_base(const struct desc_struct *desc)
15187 +static inline unsigned long __intentional_overflow(-1) get_desc_base(const struct desc_struct *desc)
15188 {
15189 return (unsigned)(desc->base0 | ((desc->base1) << 16) | ((desc->base2) << 24));
15190 }
15191 @@ -311,7 +324,7 @@ static inline void set_desc_limit(struct desc_struct *desc, unsigned long limit)
15192 }
15193
15194 #ifdef CONFIG_X86_64
15195 -static inline void set_nmi_gate(int gate, void *addr)
15196 +static inline void set_nmi_gate(int gate, const void *addr)
15197 {
15198 gate_desc s;
15199
15200 @@ -321,8 +334,8 @@ static inline void set_nmi_gate(int gate, void *addr)
15201 #endif
15202
15203 #ifdef CONFIG_TRACING
15204 -extern struct desc_ptr trace_idt_descr;
15205 -extern gate_desc trace_idt_table[];
15206 +extern const struct desc_ptr trace_idt_descr;
15207 +extern gate_desc trace_idt_table[IDT_ENTRIES];
15208 static inline void write_trace_idt_entry(int entry, const gate_desc *gate)
15209 {
15210 write_idt_entry(trace_idt_table, entry, gate);
15211 @@ -333,7 +346,7 @@ static inline void write_trace_idt_entry(int entry, const gate_desc *gate)
15212 }
15213 #endif
15214
15215 -static inline void _set_gate(int gate, unsigned type, void *addr,
15216 +static inline void _set_gate(int gate, unsigned type, const void *addr,
15217 unsigned dpl, unsigned ist, unsigned seg)
15218 {
15219 gate_desc s;
15220 @@ -353,7 +366,7 @@ static inline void _set_gate(int gate, unsigned type, void *addr,
15221 * Pentium F0 0F bugfix can have resulted in the mapped
15222 * IDT being write-protected.
15223 */
15224 -static inline void set_intr_gate(unsigned int n, void *addr)
15225 +static inline void set_intr_gate(unsigned int n, const void *addr)
15226 {
15227 BUG_ON((unsigned)n > 0xFF);
15228 _set_gate(n, GATE_INTERRUPT, addr, 0, 0, __KERNEL_CS);
15229 @@ -410,19 +423,19 @@ static inline void __alloc_intr_gate(unsigned int n, void *addr)
15230 /*
15231 * This routine sets up an interrupt gate at directory privilege level 3.
15232 */
15233 -static inline void set_system_intr_gate(unsigned int n, void *addr)
15234 +static inline void set_system_intr_gate(unsigned int n, const void *addr)
15235 {
15236 BUG_ON((unsigned)n > 0xFF);
15237 _set_gate(n, GATE_INTERRUPT, addr, 0x3, 0, __KERNEL_CS);
15238 }
15239
15240 -static inline void set_system_trap_gate(unsigned int n, void *addr)
15241 +static inline void set_system_trap_gate(unsigned int n, const void *addr)
15242 {
15243 BUG_ON((unsigned)n > 0xFF);
15244 _set_gate(n, GATE_TRAP, addr, 0x3, 0, __KERNEL_CS);
15245 }
15246
15247 -static inline void set_trap_gate(unsigned int n, void *addr)
15248 +static inline void set_trap_gate(unsigned int n, const void *addr)
15249 {
15250 BUG_ON((unsigned)n > 0xFF);
15251 _set_gate(n, GATE_TRAP, addr, 0, 0, __KERNEL_CS);
15252 @@ -431,16 +444,16 @@ static inline void set_trap_gate(unsigned int n, void *addr)
15253 static inline void set_task_gate(unsigned int n, unsigned int gdt_entry)
15254 {
15255 BUG_ON((unsigned)n > 0xFF);
15256 - _set_gate(n, GATE_TASK, (void *)0, 0, 0, (gdt_entry<<3));
15257 + _set_gate(n, GATE_TASK, (const void *)0, 0, 0, (gdt_entry<<3));
15258 }
15259
15260 -static inline void set_intr_gate_ist(int n, void *addr, unsigned ist)
15261 +static inline void set_intr_gate_ist(int n, const void *addr, unsigned ist)
15262 {
15263 BUG_ON((unsigned)n > 0xFF);
15264 _set_gate(n, GATE_INTERRUPT, addr, 0, ist, __KERNEL_CS);
15265 }
15266
15267 -static inline void set_system_intr_gate_ist(int n, void *addr, unsigned ist)
15268 +static inline void set_system_intr_gate_ist(int n, const void *addr, unsigned ist)
15269 {
15270 BUG_ON((unsigned)n > 0xFF);
15271 _set_gate(n, GATE_INTERRUPT, addr, 0x3, ist, __KERNEL_CS);
15272 @@ -512,4 +525,17 @@ static inline void load_current_idt(void)
15273 else
15274 load_idt((const struct desc_ptr *)&idt_descr);
15275 }
15276 +
15277 +#ifdef CONFIG_X86_32
15278 +static inline void set_user_cs(unsigned long base, unsigned long limit, int cpu)
15279 +{
15280 + struct desc_struct d;
15281 +
15282 + if (likely(limit))
15283 + limit = (limit - 1UL) >> PAGE_SHIFT;
15284 + pack_descriptor(&d, base, limit, 0xFB, 0xC);
15285 + write_gdt_entry(get_cpu_gdt_table(cpu), GDT_ENTRY_DEFAULT_USER_CS, &d, DESCTYPE_S);
15286 +}
15287 +#endif
15288 +
15289 #endif /* _ASM_X86_DESC_H */
15290 diff --git a/arch/x86/include/asm/desc_defs.h b/arch/x86/include/asm/desc_defs.h
15291 index 278441f..b95a174 100644
15292 --- a/arch/x86/include/asm/desc_defs.h
15293 +++ b/arch/x86/include/asm/desc_defs.h
15294 @@ -31,6 +31,12 @@ struct desc_struct {
15295 unsigned base1: 8, type: 4, s: 1, dpl: 2, p: 1;
15296 unsigned limit: 4, avl: 1, l: 1, d: 1, g: 1, base2: 8;
15297 };
15298 + struct {
15299 + u16 offset_low;
15300 + u16 seg;
15301 + unsigned reserved: 8, type: 4, s: 1, dpl: 2, p: 1;
15302 + unsigned offset_high: 16;
15303 + } gate;
15304 };
15305 } __attribute__((packed));
15306
15307 diff --git a/arch/x86/include/asm/div64.h b/arch/x86/include/asm/div64.h
15308 index ced283a..ffe04cc 100644
15309 --- a/arch/x86/include/asm/div64.h
15310 +++ b/arch/x86/include/asm/div64.h
15311 @@ -39,7 +39,7 @@
15312 __mod; \
15313 })
15314
15315 -static inline u64 div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
15316 +static inline u64 __intentional_overflow(-1) div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
15317 {
15318 union {
15319 u64 v64;
15320 diff --git a/arch/x86/include/asm/elf.h b/arch/x86/include/asm/elf.h
15321 index 9c999c1..3860cb8 100644
15322 --- a/arch/x86/include/asm/elf.h
15323 +++ b/arch/x86/include/asm/elf.h
15324 @@ -243,7 +243,25 @@ extern int force_personality32;
15325 the loader. We need to make sure that it is out of the way of the program
15326 that it will "exec", and that there is sufficient room for the brk. */
15327
15328 +#ifdef CONFIG_PAX_SEGMEXEC
15329 +#define ELF_ET_DYN_BASE ((current->mm->pax_flags & MF_PAX_SEGMEXEC) ? SEGMEXEC_TASK_SIZE/3*2 : TASK_SIZE/3*2)
15330 +#else
15331 #define ELF_ET_DYN_BASE (TASK_SIZE / 3 * 2)
15332 +#endif
15333 +
15334 +#ifdef CONFIG_PAX_ASLR
15335 +#ifdef CONFIG_X86_32
15336 +#define PAX_ELF_ET_DYN_BASE 0x10000000UL
15337 +
15338 +#define PAX_DELTA_MMAP_LEN (current->mm->pax_flags & MF_PAX_SEGMEXEC ? 15 : 16)
15339 +#define PAX_DELTA_STACK_LEN (current->mm->pax_flags & MF_PAX_SEGMEXEC ? 15 : 16)
15340 +#else
15341 +#define PAX_ELF_ET_DYN_BASE 0x400000UL
15342 +
15343 +#define PAX_DELTA_MMAP_LEN ((test_thread_flag(TIF_ADDR32)) ? 16 : TASK_SIZE_MAX_SHIFT - PAGE_SHIFT - 3)
15344 +#define PAX_DELTA_STACK_LEN ((test_thread_flag(TIF_ADDR32)) ? 16 : TASK_SIZE_MAX_SHIFT - PAGE_SHIFT - 3)
15345 +#endif
15346 +#endif
15347
15348 /* This yields a mask that user programs can use to figure out what
15349 instruction set this CPU supports. This could be done in user space,
15350 @@ -296,16 +314,12 @@ do { \
15351
15352 #define ARCH_DLINFO \
15353 do { \
15354 - if (vdso_enabled) \
15355 - NEW_AUX_ENT(AT_SYSINFO_EHDR, \
15356 - (unsigned long)current->mm->context.vdso); \
15357 + NEW_AUX_ENT(AT_SYSINFO_EHDR, current->mm->context.vdso); \
15358 } while (0)
15359
15360 #define ARCH_DLINFO_X32 \
15361 do { \
15362 - if (vdso_enabled) \
15363 - NEW_AUX_ENT(AT_SYSINFO_EHDR, \
15364 - (unsigned long)current->mm->context.vdso); \
15365 + NEW_AUX_ENT(AT_SYSINFO_EHDR, current->mm->context.vdso); \
15366 } while (0)
15367
15368 #define AT_SYSINFO 32
15369 @@ -320,7 +334,7 @@ else \
15370
15371 #endif /* !CONFIG_X86_32 */
15372
15373 -#define VDSO_CURRENT_BASE ((unsigned long)current->mm->context.vdso)
15374 +#define VDSO_CURRENT_BASE (current->mm->context.vdso)
15375
15376 #define VDSO_ENTRY \
15377 ((unsigned long)VDSO32_SYMBOL(VDSO_CURRENT_BASE, vsyscall))
15378 @@ -336,9 +350,6 @@ extern int x32_setup_additional_pages(struct linux_binprm *bprm,
15379 extern int syscall32_setup_pages(struct linux_binprm *, int exstack);
15380 #define compat_arch_setup_additional_pages syscall32_setup_pages
15381
15382 -extern unsigned long arch_randomize_brk(struct mm_struct *mm);
15383 -#define arch_randomize_brk arch_randomize_brk
15384 -
15385 /*
15386 * True on X86_32 or when emulating IA32 on X86_64
15387 */
15388 diff --git a/arch/x86/include/asm/emergency-restart.h b/arch/x86/include/asm/emergency-restart.h
15389 index 77a99ac..39ff7f5 100644
15390 --- a/arch/x86/include/asm/emergency-restart.h
15391 +++ b/arch/x86/include/asm/emergency-restart.h
15392 @@ -1,6 +1,6 @@
15393 #ifndef _ASM_X86_EMERGENCY_RESTART_H
15394 #define _ASM_X86_EMERGENCY_RESTART_H
15395
15396 -extern void machine_emergency_restart(void);
15397 +extern void machine_emergency_restart(void) __noreturn;
15398
15399 #endif /* _ASM_X86_EMERGENCY_RESTART_H */
15400 diff --git a/arch/x86/include/asm/fpu-internal.h b/arch/x86/include/asm/fpu-internal.h
15401 index 4d0bda7..221da4d 100644
15402 --- a/arch/x86/include/asm/fpu-internal.h
15403 +++ b/arch/x86/include/asm/fpu-internal.h
15404 @@ -124,8 +124,11 @@ static inline void sanitize_i387_state(struct task_struct *tsk)
15405 #define user_insn(insn, output, input...) \
15406 ({ \
15407 int err; \
15408 + pax_open_userland(); \
15409 asm volatile(ASM_STAC "\n" \
15410 - "1:" #insn "\n\t" \
15411 + "1:" \
15412 + __copyuser_seg \
15413 + #insn "\n\t" \
15414 "2: " ASM_CLAC "\n" \
15415 ".section .fixup,\"ax\"\n" \
15416 "3: movl $-1,%[err]\n" \
15417 @@ -134,6 +137,7 @@ static inline void sanitize_i387_state(struct task_struct *tsk)
15418 _ASM_EXTABLE(1b, 3b) \
15419 : [err] "=r" (err), output \
15420 : "0"(0), input); \
15421 + pax_close_userland(); \
15422 err; \
15423 })
15424
15425 @@ -298,7 +302,7 @@ static inline int restore_fpu_checking(struct task_struct *tsk)
15426 "emms\n\t" /* clear stack tags */
15427 "fildl %P[addr]", /* set F?P to defined value */
15428 X86_FEATURE_FXSAVE_LEAK,
15429 - [addr] "m" (tsk->thread.fpu.has_fpu));
15430 + [addr] "m" (init_tss[raw_smp_processor_id()].x86_tss.sp0));
15431
15432 return fpu_restore_checking(&tsk->thread.fpu);
15433 }
15434 diff --git a/arch/x86/include/asm/futex.h b/arch/x86/include/asm/futex.h
15435 index be27ba1..04a8801 100644
15436 --- a/arch/x86/include/asm/futex.h
15437 +++ b/arch/x86/include/asm/futex.h
15438 @@ -12,6 +12,7 @@
15439 #include <asm/smap.h>
15440
15441 #define __futex_atomic_op1(insn, ret, oldval, uaddr, oparg) \
15442 + typecheck(u32 __user *, uaddr); \
15443 asm volatile("\t" ASM_STAC "\n" \
15444 "1:\t" insn "\n" \
15445 "2:\t" ASM_CLAC "\n" \
15446 @@ -20,15 +21,16 @@
15447 "\tjmp\t2b\n" \
15448 "\t.previous\n" \
15449 _ASM_EXTABLE(1b, 3b) \
15450 - : "=r" (oldval), "=r" (ret), "+m" (*uaddr) \
15451 + : "=r" (oldval), "=r" (ret), "+m" (*(u32 __user *)____m(uaddr)) \
15452 : "i" (-EFAULT), "0" (oparg), "1" (0))
15453
15454 #define __futex_atomic_op2(insn, ret, oldval, uaddr, oparg) \
15455 + typecheck(u32 __user *, uaddr); \
15456 asm volatile("\t" ASM_STAC "\n" \
15457 "1:\tmovl %2, %0\n" \
15458 "\tmovl\t%0, %3\n" \
15459 "\t" insn "\n" \
15460 - "2:\t" LOCK_PREFIX "cmpxchgl %3, %2\n" \
15461 + "2:\t" LOCK_PREFIX __copyuser_seg"cmpxchgl %3, %2\n" \
15462 "\tjnz\t1b\n" \
15463 "3:\t" ASM_CLAC "\n" \
15464 "\t.section .fixup,\"ax\"\n" \
15465 @@ -38,7 +40,7 @@
15466 _ASM_EXTABLE(1b, 4b) \
15467 _ASM_EXTABLE(2b, 4b) \
15468 : "=&a" (oldval), "=&r" (ret), \
15469 - "+m" (*uaddr), "=&r" (tem) \
15470 + "+m" (*(u32 __user *)____m(uaddr)), "=&r" (tem) \
15471 : "r" (oparg), "i" (-EFAULT), "1" (0))
15472
15473 static inline int futex_atomic_op_inuser(int encoded_op, u32 __user *uaddr)
15474 @@ -57,12 +59,13 @@ static inline int futex_atomic_op_inuser(int encoded_op, u32 __user *uaddr)
15475
15476 pagefault_disable();
15477
15478 + pax_open_userland();
15479 switch (op) {
15480 case FUTEX_OP_SET:
15481 - __futex_atomic_op1("xchgl %0, %2", ret, oldval, uaddr, oparg);
15482 + __futex_atomic_op1(__copyuser_seg"xchgl %0, %2", ret, oldval, uaddr, oparg);
15483 break;
15484 case FUTEX_OP_ADD:
15485 - __futex_atomic_op1(LOCK_PREFIX "xaddl %0, %2", ret, oldval,
15486 + __futex_atomic_op1(LOCK_PREFIX __copyuser_seg"xaddl %0, %2", ret, oldval,
15487 uaddr, oparg);
15488 break;
15489 case FUTEX_OP_OR:
15490 @@ -77,6 +80,7 @@ static inline int futex_atomic_op_inuser(int encoded_op, u32 __user *uaddr)
15491 default:
15492 ret = -ENOSYS;
15493 }
15494 + pax_close_userland();
15495
15496 pagefault_enable();
15497
15498 @@ -115,18 +119,20 @@ static inline int futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr,
15499 if (!access_ok(VERIFY_WRITE, uaddr, sizeof(u32)))
15500 return -EFAULT;
15501
15502 + pax_open_userland();
15503 asm volatile("\t" ASM_STAC "\n"
15504 - "1:\t" LOCK_PREFIX "cmpxchgl %4, %2\n"
15505 + "1:\t" LOCK_PREFIX __copyuser_seg"cmpxchgl %4, %2\n"
15506 "2:\t" ASM_CLAC "\n"
15507 "\t.section .fixup, \"ax\"\n"
15508 "3:\tmov %3, %0\n"
15509 "\tjmp 2b\n"
15510 "\t.previous\n"
15511 _ASM_EXTABLE(1b, 3b)
15512 - : "+r" (ret), "=a" (oldval), "+m" (*uaddr)
15513 + : "+r" (ret), "=a" (oldval), "+m" (*(u32 __user *)____m(uaddr))
15514 : "i" (-EFAULT), "r" (newval), "1" (oldval)
15515 : "memory"
15516 );
15517 + pax_close_userland();
15518
15519 *uval = oldval;
15520 return ret;
15521 diff --git a/arch/x86/include/asm/hw_irq.h b/arch/x86/include/asm/hw_irq.h
15522 index 92b3bae..3866449 100644
15523 --- a/arch/x86/include/asm/hw_irq.h
15524 +++ b/arch/x86/include/asm/hw_irq.h
15525 @@ -165,8 +165,8 @@ extern void setup_ioapic_dest(void);
15526 extern void enable_IO_APIC(void);
15527
15528 /* Statistics */
15529 -extern atomic_t irq_err_count;
15530 -extern atomic_t irq_mis_count;
15531 +extern atomic_unchecked_t irq_err_count;
15532 +extern atomic_unchecked_t irq_mis_count;
15533
15534 /* EISA */
15535 extern void eisa_set_level_irq(unsigned int irq);
15536 diff --git a/arch/x86/include/asm/i8259.h b/arch/x86/include/asm/i8259.h
15537 index a203659..9889f1c 100644
15538 --- a/arch/x86/include/asm/i8259.h
15539 +++ b/arch/x86/include/asm/i8259.h
15540 @@ -62,7 +62,7 @@ struct legacy_pic {
15541 void (*init)(int auto_eoi);
15542 int (*irq_pending)(unsigned int irq);
15543 void (*make_irq)(unsigned int irq);
15544 -};
15545 +} __do_const;
15546
15547 extern struct legacy_pic *legacy_pic;
15548 extern struct legacy_pic null_legacy_pic;
15549 diff --git a/arch/x86/include/asm/io.h b/arch/x86/include/asm/io.h
15550 index 34f69cb..6d95446 100644
15551 --- a/arch/x86/include/asm/io.h
15552 +++ b/arch/x86/include/asm/io.h
15553 @@ -51,12 +51,12 @@ static inline void name(type val, volatile void __iomem *addr) \
15554 "m" (*(volatile type __force *)addr) barrier); }
15555
15556 build_mmio_read(readb, "b", unsigned char, "=q", :"memory")
15557 -build_mmio_read(readw, "w", unsigned short, "=r", :"memory")
15558 -build_mmio_read(readl, "l", unsigned int, "=r", :"memory")
15559 +build_mmio_read(__intentional_overflow(-1) readw, "w", unsigned short, "=r", :"memory")
15560 +build_mmio_read(__intentional_overflow(-1) readl, "l", unsigned int, "=r", :"memory")
15561
15562 build_mmio_read(__readb, "b", unsigned char, "=q", )
15563 -build_mmio_read(__readw, "w", unsigned short, "=r", )
15564 -build_mmio_read(__readl, "l", unsigned int, "=r", )
15565 +build_mmio_read(__intentional_overflow(-1) __readw, "w", unsigned short, "=r", )
15566 +build_mmio_read(__intentional_overflow(-1) __readl, "l", unsigned int, "=r", )
15567
15568 build_mmio_write(writeb, "b", unsigned char, "q", :"memory")
15569 build_mmio_write(writew, "w", unsigned short, "r", :"memory")
15570 @@ -184,7 +184,7 @@ static inline void __iomem *ioremap(resource_size_t offset, unsigned long size)
15571 return ioremap_nocache(offset, size);
15572 }
15573
15574 -extern void iounmap(volatile void __iomem *addr);
15575 +extern void iounmap(const volatile void __iomem *addr);
15576
15577 extern void set_iounmap_nonlazy(void);
15578
15579 @@ -194,6 +194,17 @@ extern void set_iounmap_nonlazy(void);
15580
15581 #include <linux/vmalloc.h>
15582
15583 +#define ARCH_HAS_VALID_PHYS_ADDR_RANGE
15584 +static inline int valid_phys_addr_range(unsigned long addr, size_t count)
15585 +{
15586 + return ((addr + count + PAGE_SIZE - 1) >> PAGE_SHIFT) < (1ULL << (boot_cpu_data.x86_phys_bits - PAGE_SHIFT)) ? 1 : 0;
15587 +}
15588 +
15589 +static inline int valid_mmap_phys_addr_range(unsigned long pfn, size_t count)
15590 +{
15591 + return (pfn + (count >> PAGE_SHIFT)) < (1ULL << (boot_cpu_data.x86_phys_bits - PAGE_SHIFT)) ? 1 : 0;
15592 +}
15593 +
15594 /*
15595 * Convert a virtual cached pointer to an uncached pointer
15596 */
15597 diff --git a/arch/x86/include/asm/irqflags.h b/arch/x86/include/asm/irqflags.h
15598 index bba3cf8..06bc8da 100644
15599 --- a/arch/x86/include/asm/irqflags.h
15600 +++ b/arch/x86/include/asm/irqflags.h
15601 @@ -141,6 +141,11 @@ static inline notrace unsigned long arch_local_irq_save(void)
15602 sti; \
15603 sysexit
15604
15605 +#define GET_CR0_INTO_RDI mov %cr0, %rdi
15606 +#define SET_RDI_INTO_CR0 mov %rdi, %cr0
15607 +#define GET_CR3_INTO_RDI mov %cr3, %rdi
15608 +#define SET_RDI_INTO_CR3 mov %rdi, %cr3
15609 +
15610 #else
15611 #define INTERRUPT_RETURN iret
15612 #define ENABLE_INTERRUPTS_SYSEXIT sti; sysexit
15613 diff --git a/arch/x86/include/asm/kprobes.h b/arch/x86/include/asm/kprobes.h
15614 index 9454c16..e4100e3 100644
15615 --- a/arch/x86/include/asm/kprobes.h
15616 +++ b/arch/x86/include/asm/kprobes.h
15617 @@ -38,13 +38,8 @@ typedef u8 kprobe_opcode_t;
15618 #define RELATIVEJUMP_SIZE 5
15619 #define RELATIVECALL_OPCODE 0xe8
15620 #define RELATIVE_ADDR_SIZE 4
15621 -#define MAX_STACK_SIZE 64
15622 -#define MIN_STACK_SIZE(ADDR) \
15623 - (((MAX_STACK_SIZE) < (((unsigned long)current_thread_info()) + \
15624 - THREAD_SIZE - (unsigned long)(ADDR))) \
15625 - ? (MAX_STACK_SIZE) \
15626 - : (((unsigned long)current_thread_info()) + \
15627 - THREAD_SIZE - (unsigned long)(ADDR)))
15628 +#define MAX_STACK_SIZE 64UL
15629 +#define MIN_STACK_SIZE(ADDR) min(MAX_STACK_SIZE, current->thread.sp0 - (unsigned long)(ADDR))
15630
15631 #define flush_insn_slot(p) do { } while (0)
15632
15633 diff --git a/arch/x86/include/asm/local.h b/arch/x86/include/asm/local.h
15634 index 2d89e39..baee879 100644
15635 --- a/arch/x86/include/asm/local.h
15636 +++ b/arch/x86/include/asm/local.h
15637 @@ -10,33 +10,97 @@ typedef struct {
15638 atomic_long_t a;
15639 } local_t;
15640
15641 +typedef struct {
15642 + atomic_long_unchecked_t a;
15643 +} local_unchecked_t;
15644 +
15645 #define LOCAL_INIT(i) { ATOMIC_LONG_INIT(i) }
15646
15647 #define local_read(l) atomic_long_read(&(l)->a)
15648 +#define local_read_unchecked(l) atomic_long_read_unchecked(&(l)->a)
15649 #define local_set(l, i) atomic_long_set(&(l)->a, (i))
15650 +#define local_set_unchecked(l, i) atomic_long_set_unchecked(&(l)->a, (i))
15651
15652 static inline void local_inc(local_t *l)
15653 {
15654 - asm volatile(_ASM_INC "%0"
15655 + asm volatile(_ASM_INC "%0\n"
15656 +
15657 +#ifdef CONFIG_PAX_REFCOUNT
15658 + "jno 0f\n"
15659 + _ASM_DEC "%0\n"
15660 + "int $4\n0:\n"
15661 + _ASM_EXTABLE(0b, 0b)
15662 +#endif
15663 +
15664 + : "+m" (l->a.counter));
15665 +}
15666 +
15667 +static inline void local_inc_unchecked(local_unchecked_t *l)
15668 +{
15669 + asm volatile(_ASM_INC "%0\n"
15670 : "+m" (l->a.counter));
15671 }
15672
15673 static inline void local_dec(local_t *l)
15674 {
15675 - asm volatile(_ASM_DEC "%0"
15676 + asm volatile(_ASM_DEC "%0\n"
15677 +
15678 +#ifdef CONFIG_PAX_REFCOUNT
15679 + "jno 0f\n"
15680 + _ASM_INC "%0\n"
15681 + "int $4\n0:\n"
15682 + _ASM_EXTABLE(0b, 0b)
15683 +#endif
15684 +
15685 + : "+m" (l->a.counter));
15686 +}
15687 +
15688 +static inline void local_dec_unchecked(local_unchecked_t *l)
15689 +{
15690 + asm volatile(_ASM_DEC "%0\n"
15691 : "+m" (l->a.counter));
15692 }
15693
15694 static inline void local_add(long i, local_t *l)
15695 {
15696 - asm volatile(_ASM_ADD "%1,%0"
15697 + asm volatile(_ASM_ADD "%1,%0\n"
15698 +
15699 +#ifdef CONFIG_PAX_REFCOUNT
15700 + "jno 0f\n"
15701 + _ASM_SUB "%1,%0\n"
15702 + "int $4\n0:\n"
15703 + _ASM_EXTABLE(0b, 0b)
15704 +#endif
15705 +
15706 + : "+m" (l->a.counter)
15707 + : "ir" (i));
15708 +}
15709 +
15710 +static inline void local_add_unchecked(long i, local_unchecked_t *l)
15711 +{
15712 + asm volatile(_ASM_ADD "%1,%0\n"
15713 : "+m" (l->a.counter)
15714 : "ir" (i));
15715 }
15716
15717 static inline void local_sub(long i, local_t *l)
15718 {
15719 - asm volatile(_ASM_SUB "%1,%0"
15720 + asm volatile(_ASM_SUB "%1,%0\n"
15721 +
15722 +#ifdef CONFIG_PAX_REFCOUNT
15723 + "jno 0f\n"
15724 + _ASM_ADD "%1,%0\n"
15725 + "int $4\n0:\n"
15726 + _ASM_EXTABLE(0b, 0b)
15727 +#endif
15728 +
15729 + : "+m" (l->a.counter)
15730 + : "ir" (i));
15731 +}
15732 +
15733 +static inline void local_sub_unchecked(long i, local_unchecked_t *l)
15734 +{
15735 + asm volatile(_ASM_SUB "%1,%0\n"
15736 : "+m" (l->a.counter)
15737 : "ir" (i));
15738 }
15739 @@ -54,7 +118,16 @@ static inline int local_sub_and_test(long i, local_t *l)
15740 {
15741 unsigned char c;
15742
15743 - asm volatile(_ASM_SUB "%2,%0; sete %1"
15744 + asm volatile(_ASM_SUB "%2,%0\n"
15745 +
15746 +#ifdef CONFIG_PAX_REFCOUNT
15747 + "jno 0f\n"
15748 + _ASM_ADD "%2,%0\n"
15749 + "int $4\n0:\n"
15750 + _ASM_EXTABLE(0b, 0b)
15751 +#endif
15752 +
15753 + "sete %1\n"
15754 : "+m" (l->a.counter), "=qm" (c)
15755 : "ir" (i) : "memory");
15756 return c;
15757 @@ -72,7 +145,16 @@ static inline int local_dec_and_test(local_t *l)
15758 {
15759 unsigned char c;
15760
15761 - asm volatile(_ASM_DEC "%0; sete %1"
15762 + asm volatile(_ASM_DEC "%0\n"
15763 +
15764 +#ifdef CONFIG_PAX_REFCOUNT
15765 + "jno 0f\n"
15766 + _ASM_INC "%0\n"
15767 + "int $4\n0:\n"
15768 + _ASM_EXTABLE(0b, 0b)
15769 +#endif
15770 +
15771 + "sete %1\n"
15772 : "+m" (l->a.counter), "=qm" (c)
15773 : : "memory");
15774 return c != 0;
15775 @@ -90,7 +172,16 @@ static inline int local_inc_and_test(local_t *l)
15776 {
15777 unsigned char c;
15778
15779 - asm volatile(_ASM_INC "%0; sete %1"
15780 + asm volatile(_ASM_INC "%0\n"
15781 +
15782 +#ifdef CONFIG_PAX_REFCOUNT
15783 + "jno 0f\n"
15784 + _ASM_DEC "%0\n"
15785 + "int $4\n0:\n"
15786 + _ASM_EXTABLE(0b, 0b)
15787 +#endif
15788 +
15789 + "sete %1\n"
15790 : "+m" (l->a.counter), "=qm" (c)
15791 : : "memory");
15792 return c != 0;
15793 @@ -109,7 +200,16 @@ static inline int local_add_negative(long i, local_t *l)
15794 {
15795 unsigned char c;
15796
15797 - asm volatile(_ASM_ADD "%2,%0; sets %1"
15798 + asm volatile(_ASM_ADD "%2,%0\n"
15799 +
15800 +#ifdef CONFIG_PAX_REFCOUNT
15801 + "jno 0f\n"
15802 + _ASM_SUB "%2,%0\n"
15803 + "int $4\n0:\n"
15804 + _ASM_EXTABLE(0b, 0b)
15805 +#endif
15806 +
15807 + "sets %1\n"
15808 : "+m" (l->a.counter), "=qm" (c)
15809 : "ir" (i) : "memory");
15810 return c;
15811 @@ -125,6 +225,30 @@ static inline int local_add_negative(long i, local_t *l)
15812 static inline long local_add_return(long i, local_t *l)
15813 {
15814 long __i = i;
15815 + asm volatile(_ASM_XADD "%0, %1\n"
15816 +
15817 +#ifdef CONFIG_PAX_REFCOUNT
15818 + "jno 0f\n"
15819 + _ASM_MOV "%0,%1\n"
15820 + "int $4\n0:\n"
15821 + _ASM_EXTABLE(0b, 0b)
15822 +#endif
15823 +
15824 + : "+r" (i), "+m" (l->a.counter)
15825 + : : "memory");
15826 + return i + __i;
15827 +}
15828 +
15829 +/**
15830 + * local_add_return_unchecked - add and return
15831 + * @i: integer value to add
15832 + * @l: pointer to type local_unchecked_t
15833 + *
15834 + * Atomically adds @i to @l and returns @i + @l
15835 + */
15836 +static inline long local_add_return_unchecked(long i, local_unchecked_t *l)
15837 +{
15838 + long __i = i;
15839 asm volatile(_ASM_XADD "%0, %1;"
15840 : "+r" (i), "+m" (l->a.counter)
15841 : : "memory");
15842 @@ -141,6 +265,8 @@ static inline long local_sub_return(long i, local_t *l)
15843
15844 #define local_cmpxchg(l, o, n) \
15845 (cmpxchg_local(&((l)->a.counter), (o), (n)))
15846 +#define local_cmpxchg_unchecked(l, o, n) \
15847 + (cmpxchg_local(&((l)->a.counter), (o), (n)))
15848 /* Always has a lock prefix */
15849 #define local_xchg(l, n) (xchg(&((l)->a.counter), (n)))
15850
15851 diff --git a/arch/x86/include/asm/mman.h b/arch/x86/include/asm/mman.h
15852 new file mode 100644
15853 index 0000000..2bfd3ba
15854 --- /dev/null
15855 +++ b/arch/x86/include/asm/mman.h
15856 @@ -0,0 +1,15 @@
15857 +#ifndef _X86_MMAN_H
15858 +#define _X86_MMAN_H
15859 +
15860 +#include <uapi/asm/mman.h>
15861 +
15862 +#ifdef __KERNEL__
15863 +#ifndef __ASSEMBLY__
15864 +#ifdef CONFIG_X86_32
15865 +#define arch_mmap_check i386_mmap_check
15866 +int i386_mmap_check(unsigned long addr, unsigned long len, unsigned long flags);
15867 +#endif
15868 +#endif
15869 +#endif
15870 +
15871 +#endif /* X86_MMAN_H */
15872 diff --git a/arch/x86/include/asm/mmu.h b/arch/x86/include/asm/mmu.h
15873 index 5f55e69..e20bfb1 100644
15874 --- a/arch/x86/include/asm/mmu.h
15875 +++ b/arch/x86/include/asm/mmu.h
15876 @@ -9,7 +9,7 @@
15877 * we put the segment information here.
15878 */
15879 typedef struct {
15880 - void *ldt;
15881 + struct desc_struct *ldt;
15882 int size;
15883
15884 #ifdef CONFIG_X86_64
15885 @@ -18,7 +18,19 @@ typedef struct {
15886 #endif
15887
15888 struct mutex lock;
15889 - void *vdso;
15890 + unsigned long vdso;
15891 +
15892 +#ifdef CONFIG_X86_32
15893 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
15894 + unsigned long user_cs_base;
15895 + unsigned long user_cs_limit;
15896 +
15897 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_SMP)
15898 + cpumask_t cpu_user_cs_mask;
15899 +#endif
15900 +
15901 +#endif
15902 +#endif
15903 } mm_context_t;
15904
15905 #ifdef CONFIG_SMP
15906 diff --git a/arch/x86/include/asm/mmu_context.h b/arch/x86/include/asm/mmu_context.h
15907 index be12c53..4d24039 100644
15908 --- a/arch/x86/include/asm/mmu_context.h
15909 +++ b/arch/x86/include/asm/mmu_context.h
15910 @@ -24,6 +24,20 @@ void destroy_context(struct mm_struct *mm);
15911
15912 static inline void enter_lazy_tlb(struct mm_struct *mm, struct task_struct *tsk)
15913 {
15914 +
15915 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
15916 + if (!(static_cpu_has(X86_FEATURE_PCID))) {
15917 + unsigned int i;
15918 + pgd_t *pgd;
15919 +
15920 + pax_open_kernel();
15921 + pgd = get_cpu_pgd(smp_processor_id(), kernel);
15922 + for (i = USER_PGD_PTRS; i < 2 * USER_PGD_PTRS; ++i)
15923 + set_pgd_batched(pgd+i, native_make_pgd(0));
15924 + pax_close_kernel();
15925 + }
15926 +#endif
15927 +
15928 #ifdef CONFIG_SMP
15929 if (this_cpu_read(cpu_tlbstate.state) == TLBSTATE_OK)
15930 this_cpu_write(cpu_tlbstate.state, TLBSTATE_LAZY);
15931 @@ -34,16 +48,59 @@ static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next,
15932 struct task_struct *tsk)
15933 {
15934 unsigned cpu = smp_processor_id();
15935 +#if defined(CONFIG_X86_32) && defined(CONFIG_SMP) && (defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC))
15936 + int tlbstate = TLBSTATE_OK;
15937 +#endif
15938
15939 if (likely(prev != next)) {
15940 #ifdef CONFIG_SMP
15941 +#if defined(CONFIG_X86_32) && (defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC))
15942 + tlbstate = this_cpu_read(cpu_tlbstate.state);
15943 +#endif
15944 this_cpu_write(cpu_tlbstate.state, TLBSTATE_OK);
15945 this_cpu_write(cpu_tlbstate.active_mm, next);
15946 #endif
15947 cpumask_set_cpu(cpu, mm_cpumask(next));
15948
15949 /* Re-load page tables */
15950 +#ifdef CONFIG_PAX_PER_CPU_PGD
15951 + pax_open_kernel();
15952 +
15953 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
15954 + if (static_cpu_has(X86_FEATURE_PCID))
15955 + __clone_user_pgds(get_cpu_pgd(cpu, user), next->pgd);
15956 + else
15957 +#endif
15958 +
15959 + __clone_user_pgds(get_cpu_pgd(cpu, kernel), next->pgd);
15960 + __shadow_user_pgds(get_cpu_pgd(cpu, kernel) + USER_PGD_PTRS, next->pgd);
15961 + pax_close_kernel();
15962 + 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));
15963 +
15964 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
15965 + if (static_cpu_has(X86_FEATURE_PCID)) {
15966 + if (static_cpu_has(X86_FEATURE_INVPCID)) {
15967 + u64 descriptor[2];
15968 + descriptor[0] = PCID_USER;
15969 + asm volatile(__ASM_INVPCID : : "d"(&descriptor), "a"(INVPCID_SINGLE_CONTEXT) : "memory");
15970 + if (!static_cpu_has(X86_FEATURE_STRONGUDEREF)) {
15971 + descriptor[0] = PCID_KERNEL;
15972 + asm volatile(__ASM_INVPCID : : "d"(&descriptor), "a"(INVPCID_SINGLE_CONTEXT) : "memory");
15973 + }
15974 + } else {
15975 + write_cr3(__pa(get_cpu_pgd(cpu, user)) | PCID_USER);
15976 + if (static_cpu_has(X86_FEATURE_STRONGUDEREF))
15977 + write_cr3(__pa(get_cpu_pgd(cpu, kernel)) | PCID_KERNEL | PCID_NOFLUSH);
15978 + else
15979 + write_cr3(__pa(get_cpu_pgd(cpu, kernel)) | PCID_KERNEL);
15980 + }
15981 + } else
15982 +#endif
15983 +
15984 + load_cr3(get_cpu_pgd(cpu, kernel));
15985 +#else
15986 load_cr3(next->pgd);
15987 +#endif
15988
15989 /* Stop flush ipis for the previous mm */
15990 cpumask_clear_cpu(cpu, mm_cpumask(prev));
15991 @@ -51,9 +108,67 @@ static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next,
15992 /* Load the LDT, if the LDT is different: */
15993 if (unlikely(prev->context.ldt != next->context.ldt))
15994 load_LDT_nolock(&next->context);
15995 +
15996 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_SMP)
15997 + if (!(__supported_pte_mask & _PAGE_NX)) {
15998 + smp_mb__before_clear_bit();
15999 + cpu_clear(cpu, prev->context.cpu_user_cs_mask);
16000 + smp_mb__after_clear_bit();
16001 + cpu_set(cpu, next->context.cpu_user_cs_mask);
16002 + }
16003 +#endif
16004 +
16005 +#if defined(CONFIG_X86_32) && (defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC))
16006 + if (unlikely(prev->context.user_cs_base != next->context.user_cs_base ||
16007 + prev->context.user_cs_limit != next->context.user_cs_limit))
16008 + set_user_cs(next->context.user_cs_base, next->context.user_cs_limit, cpu);
16009 +#ifdef CONFIG_SMP
16010 + else if (unlikely(tlbstate != TLBSTATE_OK))
16011 + set_user_cs(next->context.user_cs_base, next->context.user_cs_limit, cpu);
16012 +#endif
16013 +#endif
16014 +
16015 }
16016 + else {
16017 +
16018 +#ifdef CONFIG_PAX_PER_CPU_PGD
16019 + pax_open_kernel();
16020 +
16021 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
16022 + if (static_cpu_has(X86_FEATURE_PCID))
16023 + __clone_user_pgds(get_cpu_pgd(cpu, user), next->pgd);
16024 + else
16025 +#endif
16026 +
16027 + __clone_user_pgds(get_cpu_pgd(cpu, kernel), next->pgd);
16028 + __shadow_user_pgds(get_cpu_pgd(cpu, kernel) + USER_PGD_PTRS, next->pgd);
16029 + pax_close_kernel();
16030 + 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));
16031 +
16032 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
16033 + if (static_cpu_has(X86_FEATURE_PCID)) {
16034 + if (static_cpu_has(X86_FEATURE_INVPCID)) {
16035 + u64 descriptor[2];
16036 + descriptor[0] = PCID_USER;
16037 + asm volatile(__ASM_INVPCID : : "d"(&descriptor), "a"(INVPCID_SINGLE_CONTEXT) : "memory");
16038 + if (!static_cpu_has(X86_FEATURE_STRONGUDEREF)) {
16039 + descriptor[0] = PCID_KERNEL;
16040 + asm volatile(__ASM_INVPCID : : "d"(&descriptor), "a"(INVPCID_SINGLE_CONTEXT) : "memory");
16041 + }
16042 + } else {
16043 + write_cr3(__pa(get_cpu_pgd(cpu, user)) | PCID_USER);
16044 + if (static_cpu_has(X86_FEATURE_STRONGUDEREF))
16045 + write_cr3(__pa(get_cpu_pgd(cpu, kernel)) | PCID_KERNEL | PCID_NOFLUSH);
16046 + else
16047 + write_cr3(__pa(get_cpu_pgd(cpu, kernel)) | PCID_KERNEL);
16048 + }
16049 + } else
16050 +#endif
16051 +
16052 + load_cr3(get_cpu_pgd(cpu, kernel));
16053 +#endif
16054 +
16055 #ifdef CONFIG_SMP
16056 - else {
16057 this_cpu_write(cpu_tlbstate.state, TLBSTATE_OK);
16058 BUG_ON(this_cpu_read(cpu_tlbstate.active_mm) != next);
16059
16060 @@ -70,11 +185,28 @@ static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next,
16061 * tlb flush IPI delivery. We must reload CR3
16062 * to make sure to use no freed page tables.
16063 */
16064 +
16065 +#ifndef CONFIG_PAX_PER_CPU_PGD
16066 load_cr3(next->pgd);
16067 +#endif
16068 +
16069 load_LDT_nolock(&next->context);
16070 +
16071 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_PAGEEXEC)
16072 + if (!(__supported_pte_mask & _PAGE_NX))
16073 + cpu_set(cpu, next->context.cpu_user_cs_mask);
16074 +#endif
16075 +
16076 +#if defined(CONFIG_X86_32) && (defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC))
16077 +#ifdef CONFIG_PAX_PAGEEXEC
16078 + if (!((next->pax_flags & MF_PAX_PAGEEXEC) && (__supported_pte_mask & _PAGE_NX)))
16079 +#endif
16080 + set_user_cs(next->context.user_cs_base, next->context.user_cs_limit, cpu);
16081 +#endif
16082 +
16083 }
16084 +#endif
16085 }
16086 -#endif
16087 }
16088
16089 #define activate_mm(prev, next) \
16090 diff --git a/arch/x86/include/asm/module.h b/arch/x86/include/asm/module.h
16091 index e3b7819..b257c64 100644
16092 --- a/arch/x86/include/asm/module.h
16093 +++ b/arch/x86/include/asm/module.h
16094 @@ -5,6 +5,7 @@
16095
16096 #ifdef CONFIG_X86_64
16097 /* X86_64 does not define MODULE_PROC_FAMILY */
16098 +#define MODULE_PROC_FAMILY ""
16099 #elif defined CONFIG_M486
16100 #define MODULE_PROC_FAMILY "486 "
16101 #elif defined CONFIG_M586
16102 @@ -57,8 +58,20 @@
16103 #error unknown processor family
16104 #endif
16105
16106 -#ifdef CONFIG_X86_32
16107 -# define MODULE_ARCH_VERMAGIC MODULE_PROC_FAMILY
16108 +#ifdef CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_BTS
16109 +#define MODULE_PAX_KERNEXEC "KERNEXEC_BTS "
16110 +#elif defined(CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_OR)
16111 +#define MODULE_PAX_KERNEXEC "KERNEXEC_OR "
16112 +#else
16113 +#define MODULE_PAX_KERNEXEC ""
16114 #endif
16115
16116 +#ifdef CONFIG_PAX_MEMORY_UDEREF
16117 +#define MODULE_PAX_UDEREF "UDEREF "
16118 +#else
16119 +#define MODULE_PAX_UDEREF ""
16120 +#endif
16121 +
16122 +#define MODULE_ARCH_VERMAGIC MODULE_PROC_FAMILY MODULE_PAX_KERNEXEC MODULE_PAX_UDEREF
16123 +
16124 #endif /* _ASM_X86_MODULE_H */
16125 diff --git a/arch/x86/include/asm/nmi.h b/arch/x86/include/asm/nmi.h
16126 index 86f9301..b365cda 100644
16127 --- a/arch/x86/include/asm/nmi.h
16128 +++ b/arch/x86/include/asm/nmi.h
16129 @@ -40,11 +40,11 @@ struct nmiaction {
16130 nmi_handler_t handler;
16131 unsigned long flags;
16132 const char *name;
16133 -};
16134 +} __do_const;
16135
16136 #define register_nmi_handler(t, fn, fg, n, init...) \
16137 ({ \
16138 - static struct nmiaction init fn##_na = { \
16139 + static const struct nmiaction init fn##_na = { \
16140 .handler = (fn), \
16141 .name = (n), \
16142 .flags = (fg), \
16143 @@ -52,7 +52,7 @@ struct nmiaction {
16144 __register_nmi_handler((t), &fn##_na); \
16145 })
16146
16147 -int __register_nmi_handler(unsigned int, struct nmiaction *);
16148 +int __register_nmi_handler(unsigned int, const struct nmiaction *);
16149
16150 void unregister_nmi_handler(unsigned int, const char *);
16151
16152 diff --git a/arch/x86/include/asm/page.h b/arch/x86/include/asm/page.h
16153 index c878924..21f4889 100644
16154 --- a/arch/x86/include/asm/page.h
16155 +++ b/arch/x86/include/asm/page.h
16156 @@ -52,6 +52,7 @@ static inline void copy_user_page(void *to, void *from, unsigned long vaddr,
16157 __phys_addr_symbol(__phys_reloc_hide((unsigned long)(x)))
16158
16159 #define __va(x) ((void *)((unsigned long)(x)+PAGE_OFFSET))
16160 +#define __early_va(x) ((void *)((unsigned long)(x)+__START_KERNEL_map - phys_base))
16161
16162 #define __boot_va(x) __va(x)
16163 #define __boot_pa(x) __pa(x)
16164 diff --git a/arch/x86/include/asm/page_64.h b/arch/x86/include/asm/page_64.h
16165 index 0f1ddee..e2fc3d1 100644
16166 --- a/arch/x86/include/asm/page_64.h
16167 +++ b/arch/x86/include/asm/page_64.h
16168 @@ -7,9 +7,9 @@
16169
16170 /* duplicated to the one in bootmem.h */
16171 extern unsigned long max_pfn;
16172 -extern unsigned long phys_base;
16173 +extern const unsigned long phys_base;
16174
16175 -static inline unsigned long __phys_addr_nodebug(unsigned long x)
16176 +static inline unsigned long __intentional_overflow(-1) __phys_addr_nodebug(unsigned long x)
16177 {
16178 unsigned long y = x - __START_KERNEL_map;
16179
16180 diff --git a/arch/x86/include/asm/paravirt.h b/arch/x86/include/asm/paravirt.h
16181 index 401f350..dee5d13 100644
16182 --- a/arch/x86/include/asm/paravirt.h
16183 +++ b/arch/x86/include/asm/paravirt.h
16184 @@ -560,7 +560,7 @@ static inline pmd_t __pmd(pmdval_t val)
16185 return (pmd_t) { ret };
16186 }
16187
16188 -static inline pmdval_t pmd_val(pmd_t pmd)
16189 +static inline __intentional_overflow(-1) pmdval_t pmd_val(pmd_t pmd)
16190 {
16191 pmdval_t ret;
16192
16193 @@ -626,6 +626,18 @@ static inline void set_pgd(pgd_t *pgdp, pgd_t pgd)
16194 val);
16195 }
16196
16197 +static inline void set_pgd_batched(pgd_t *pgdp, pgd_t pgd)
16198 +{
16199 + pgdval_t val = native_pgd_val(pgd);
16200 +
16201 + if (sizeof(pgdval_t) > sizeof(long))
16202 + PVOP_VCALL3(pv_mmu_ops.set_pgd_batched, pgdp,
16203 + val, (u64)val >> 32);
16204 + else
16205 + PVOP_VCALL2(pv_mmu_ops.set_pgd_batched, pgdp,
16206 + val);
16207 +}
16208 +
16209 static inline void pgd_clear(pgd_t *pgdp)
16210 {
16211 set_pgd(pgdp, __pgd(0));
16212 @@ -710,6 +722,21 @@ static inline void __set_fixmap(unsigned /* enum fixed_addresses */ idx,
16213 pv_mmu_ops.set_fixmap(idx, phys, flags);
16214 }
16215
16216 +#ifdef CONFIG_PAX_KERNEXEC
16217 +static inline unsigned long pax_open_kernel(void)
16218 +{
16219 + return PVOP_CALL0(unsigned long, pv_mmu_ops.pax_open_kernel);
16220 +}
16221 +
16222 +static inline unsigned long pax_close_kernel(void)
16223 +{
16224 + return PVOP_CALL0(unsigned long, pv_mmu_ops.pax_close_kernel);
16225 +}
16226 +#else
16227 +static inline unsigned long pax_open_kernel(void) { return 0; }
16228 +static inline unsigned long pax_close_kernel(void) { return 0; }
16229 +#endif
16230 +
16231 #if defined(CONFIG_SMP) && defined(CONFIG_PARAVIRT_SPINLOCKS)
16232
16233 static __always_inline void __ticket_lock_spinning(struct arch_spinlock *lock,
16234 @@ -906,7 +933,7 @@ extern void default_banner(void);
16235
16236 #define PARA_PATCH(struct, off) ((PARAVIRT_PATCH_##struct + (off)) / 4)
16237 #define PARA_SITE(ptype, clobbers, ops) _PVSITE(ptype, clobbers, ops, .long, 4)
16238 -#define PARA_INDIRECT(addr) *%cs:addr
16239 +#define PARA_INDIRECT(addr) *%ss:addr
16240 #endif
16241
16242 #define INTERRUPT_RETURN \
16243 @@ -981,6 +1008,21 @@ extern void default_banner(void);
16244 PARA_SITE(PARA_PATCH(pv_cpu_ops, PV_CPU_irq_enable_sysexit), \
16245 CLBR_NONE, \
16246 jmp PARA_INDIRECT(pv_cpu_ops+PV_CPU_irq_enable_sysexit))
16247 +
16248 +#define GET_CR0_INTO_RDI \
16249 + call PARA_INDIRECT(pv_cpu_ops+PV_CPU_read_cr0); \
16250 + mov %rax,%rdi
16251 +
16252 +#define SET_RDI_INTO_CR0 \
16253 + call PARA_INDIRECT(pv_cpu_ops+PV_CPU_write_cr0)
16254 +
16255 +#define GET_CR3_INTO_RDI \
16256 + call PARA_INDIRECT(pv_mmu_ops+PV_MMU_read_cr3); \
16257 + mov %rax,%rdi
16258 +
16259 +#define SET_RDI_INTO_CR3 \
16260 + call PARA_INDIRECT(pv_mmu_ops+PV_MMU_write_cr3)
16261 +
16262 #endif /* CONFIG_X86_32 */
16263
16264 #endif /* __ASSEMBLY__ */
16265 diff --git a/arch/x86/include/asm/paravirt_types.h b/arch/x86/include/asm/paravirt_types.h
16266 index aab8f67..2531748 100644
16267 --- a/arch/x86/include/asm/paravirt_types.h
16268 +++ b/arch/x86/include/asm/paravirt_types.h
16269 @@ -84,7 +84,7 @@ struct pv_init_ops {
16270 */
16271 unsigned (*patch)(u8 type, u16 clobber, void *insnbuf,
16272 unsigned long addr, unsigned len);
16273 -};
16274 +} __no_const;
16275
16276
16277 struct pv_lazy_ops {
16278 @@ -98,7 +98,7 @@ struct pv_time_ops {
16279 unsigned long long (*sched_clock)(void);
16280 unsigned long long (*steal_clock)(int cpu);
16281 unsigned long (*get_tsc_khz)(void);
16282 -};
16283 +} __no_const;
16284
16285 struct pv_cpu_ops {
16286 /* hooks for various privileged instructions */
16287 @@ -192,7 +192,7 @@ struct pv_cpu_ops {
16288
16289 void (*start_context_switch)(struct task_struct *prev);
16290 void (*end_context_switch)(struct task_struct *next);
16291 -};
16292 +} __no_const;
16293
16294 struct pv_irq_ops {
16295 /*
16296 @@ -223,7 +223,7 @@ struct pv_apic_ops {
16297 unsigned long start_eip,
16298 unsigned long start_esp);
16299 #endif
16300 -};
16301 +} __no_const;
16302
16303 struct pv_mmu_ops {
16304 unsigned long (*read_cr2)(void);
16305 @@ -313,6 +313,7 @@ struct pv_mmu_ops {
16306 struct paravirt_callee_save make_pud;
16307
16308 void (*set_pgd)(pgd_t *pudp, pgd_t pgdval);
16309 + void (*set_pgd_batched)(pgd_t *pudp, pgd_t pgdval);
16310 #endif /* PAGETABLE_LEVELS == 4 */
16311 #endif /* PAGETABLE_LEVELS >= 3 */
16312
16313 @@ -324,6 +325,12 @@ struct pv_mmu_ops {
16314 an mfn. We can tell which is which from the index. */
16315 void (*set_fixmap)(unsigned /* enum fixed_addresses */ idx,
16316 phys_addr_t phys, pgprot_t flags);
16317 +
16318 +#ifdef CONFIG_PAX_KERNEXEC
16319 + unsigned long (*pax_open_kernel)(void);
16320 + unsigned long (*pax_close_kernel)(void);
16321 +#endif
16322 +
16323 };
16324
16325 struct arch_spinlock;
16326 diff --git a/arch/x86/include/asm/pgalloc.h b/arch/x86/include/asm/pgalloc.h
16327 index b4389a4..7024269 100644
16328 --- a/arch/x86/include/asm/pgalloc.h
16329 +++ b/arch/x86/include/asm/pgalloc.h
16330 @@ -63,6 +63,13 @@ static inline void pmd_populate_kernel(struct mm_struct *mm,
16331 pmd_t *pmd, pte_t *pte)
16332 {
16333 paravirt_alloc_pte(mm, __pa(pte) >> PAGE_SHIFT);
16334 + set_pmd(pmd, __pmd(__pa(pte) | _KERNPG_TABLE));
16335 +}
16336 +
16337 +static inline void pmd_populate_user(struct mm_struct *mm,
16338 + pmd_t *pmd, pte_t *pte)
16339 +{
16340 + paravirt_alloc_pte(mm, __pa(pte) >> PAGE_SHIFT);
16341 set_pmd(pmd, __pmd(__pa(pte) | _PAGE_TABLE));
16342 }
16343
16344 @@ -99,12 +106,22 @@ static inline void __pmd_free_tlb(struct mmu_gather *tlb, pmd_t *pmd,
16345
16346 #ifdef CONFIG_X86_PAE
16347 extern void pud_populate(struct mm_struct *mm, pud_t *pudp, pmd_t *pmd);
16348 +static inline void pud_populate_kernel(struct mm_struct *mm, pud_t *pudp, pmd_t *pmd)
16349 +{
16350 + pud_populate(mm, pudp, pmd);
16351 +}
16352 #else /* !CONFIG_X86_PAE */
16353 static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
16354 {
16355 paravirt_alloc_pmd(mm, __pa(pmd) >> PAGE_SHIFT);
16356 set_pud(pud, __pud(_PAGE_TABLE | __pa(pmd)));
16357 }
16358 +
16359 +static inline void pud_populate_kernel(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
16360 +{
16361 + paravirt_alloc_pmd(mm, __pa(pmd) >> PAGE_SHIFT);
16362 + set_pud(pud, __pud(_KERNPG_TABLE | __pa(pmd)));
16363 +}
16364 #endif /* CONFIG_X86_PAE */
16365
16366 #if PAGETABLE_LEVELS > 3
16367 @@ -114,6 +131,12 @@ static inline void pgd_populate(struct mm_struct *mm, pgd_t *pgd, pud_t *pud)
16368 set_pgd(pgd, __pgd(_PAGE_TABLE | __pa(pud)));
16369 }
16370
16371 +static inline void pgd_populate_kernel(struct mm_struct *mm, pgd_t *pgd, pud_t *pud)
16372 +{
16373 + paravirt_alloc_pud(mm, __pa(pud) >> PAGE_SHIFT);
16374 + set_pgd(pgd, __pgd(_KERNPG_TABLE | __pa(pud)));
16375 +}
16376 +
16377 static inline pud_t *pud_alloc_one(struct mm_struct *mm, unsigned long addr)
16378 {
16379 return (pud_t *)get_zeroed_page(GFP_KERNEL|__GFP_REPEAT);
16380 diff --git a/arch/x86/include/asm/pgtable-2level.h b/arch/x86/include/asm/pgtable-2level.h
16381 index 3bf2dd0..23d2a9f 100644
16382 --- a/arch/x86/include/asm/pgtable-2level.h
16383 +++ b/arch/x86/include/asm/pgtable-2level.h
16384 @@ -18,7 +18,9 @@ static inline void native_set_pte(pte_t *ptep , pte_t pte)
16385
16386 static inline void native_set_pmd(pmd_t *pmdp, pmd_t pmd)
16387 {
16388 + pax_open_kernel();
16389 *pmdp = pmd;
16390 + pax_close_kernel();
16391 }
16392
16393 static inline void native_set_pte_atomic(pte_t *ptep, pte_t pte)
16394 diff --git a/arch/x86/include/asm/pgtable-3level.h b/arch/x86/include/asm/pgtable-3level.h
16395 index 81bb91b..9392125 100644
16396 --- a/arch/x86/include/asm/pgtable-3level.h
16397 +++ b/arch/x86/include/asm/pgtable-3level.h
16398 @@ -92,12 +92,16 @@ static inline void native_set_pte_atomic(pte_t *ptep, pte_t pte)
16399
16400 static inline void native_set_pmd(pmd_t *pmdp, pmd_t pmd)
16401 {
16402 + pax_open_kernel();
16403 set_64bit((unsigned long long *)(pmdp), native_pmd_val(pmd));
16404 + pax_close_kernel();
16405 }
16406
16407 static inline void native_set_pud(pud_t *pudp, pud_t pud)
16408 {
16409 + pax_open_kernel();
16410 set_64bit((unsigned long long *)(pudp), native_pud_val(pud));
16411 + pax_close_kernel();
16412 }
16413
16414 /*
16415 diff --git a/arch/x86/include/asm/pgtable.h b/arch/x86/include/asm/pgtable.h
16416 index 3d19994..732a48c 100644
16417 --- a/arch/x86/include/asm/pgtable.h
16418 +++ b/arch/x86/include/asm/pgtable.h
16419 @@ -45,6 +45,7 @@ extern struct mm_struct *pgd_page_get_mm(struct page *page);
16420
16421 #ifndef __PAGETABLE_PUD_FOLDED
16422 #define set_pgd(pgdp, pgd) native_set_pgd(pgdp, pgd)
16423 +#define set_pgd_batched(pgdp, pgd) native_set_pgd_batched(pgdp, pgd)
16424 #define pgd_clear(pgd) native_pgd_clear(pgd)
16425 #endif
16426
16427 @@ -82,12 +83,51 @@ extern struct mm_struct *pgd_page_get_mm(struct page *page);
16428
16429 #define arch_end_context_switch(prev) do {} while(0)
16430
16431 +#define pax_open_kernel() native_pax_open_kernel()
16432 +#define pax_close_kernel() native_pax_close_kernel()
16433 #endif /* CONFIG_PARAVIRT */
16434
16435 +#define __HAVE_ARCH_PAX_OPEN_KERNEL
16436 +#define __HAVE_ARCH_PAX_CLOSE_KERNEL
16437 +
16438 +#ifdef CONFIG_PAX_KERNEXEC
16439 +static inline unsigned long native_pax_open_kernel(void)
16440 +{
16441 + unsigned long cr0;
16442 +
16443 + preempt_disable();
16444 + barrier();
16445 + cr0 = read_cr0() ^ X86_CR0_WP;
16446 + BUG_ON(cr0 & X86_CR0_WP);
16447 + write_cr0(cr0);
16448 + return cr0 ^ X86_CR0_WP;
16449 +}
16450 +
16451 +static inline unsigned long native_pax_close_kernel(void)
16452 +{
16453 + unsigned long cr0;
16454 +
16455 + cr0 = read_cr0() ^ X86_CR0_WP;
16456 + BUG_ON(!(cr0 & X86_CR0_WP));
16457 + write_cr0(cr0);
16458 + barrier();
16459 + preempt_enable_no_resched();
16460 + return cr0 ^ X86_CR0_WP;
16461 +}
16462 +#else
16463 +static inline unsigned long native_pax_open_kernel(void) { return 0; }
16464 +static inline unsigned long native_pax_close_kernel(void) { return 0; }
16465 +#endif
16466 +
16467 /*
16468 * The following only work if pte_present() is true.
16469 * Undefined behaviour if not..
16470 */
16471 +static inline int pte_user(pte_t pte)
16472 +{
16473 + return pte_val(pte) & _PAGE_USER;
16474 +}
16475 +
16476 static inline int pte_dirty(pte_t pte)
16477 {
16478 return pte_flags(pte) & _PAGE_DIRTY;
16479 @@ -148,6 +188,11 @@ static inline unsigned long pud_pfn(pud_t pud)
16480 return (pud_val(pud) & PTE_PFN_MASK) >> PAGE_SHIFT;
16481 }
16482
16483 +static inline unsigned long pgd_pfn(pgd_t pgd)
16484 +{
16485 + return (pgd_val(pgd) & PTE_PFN_MASK) >> PAGE_SHIFT;
16486 +}
16487 +
16488 #define pte_page(pte) pfn_to_page(pte_pfn(pte))
16489
16490 static inline int pmd_large(pmd_t pte)
16491 @@ -201,9 +246,29 @@ static inline pte_t pte_wrprotect(pte_t pte)
16492 return pte_clear_flags(pte, _PAGE_RW);
16493 }
16494
16495 +static inline pte_t pte_mkread(pte_t pte)
16496 +{
16497 + return __pte(pte_val(pte) | _PAGE_USER);
16498 +}
16499 +
16500 static inline pte_t pte_mkexec(pte_t pte)
16501 {
16502 - return pte_clear_flags(pte, _PAGE_NX);
16503 +#ifdef CONFIG_X86_PAE
16504 + if (__supported_pte_mask & _PAGE_NX)
16505 + return pte_clear_flags(pte, _PAGE_NX);
16506 + else
16507 +#endif
16508 + return pte_set_flags(pte, _PAGE_USER);
16509 +}
16510 +
16511 +static inline pte_t pte_exprotect(pte_t pte)
16512 +{
16513 +#ifdef CONFIG_X86_PAE
16514 + if (__supported_pte_mask & _PAGE_NX)
16515 + return pte_set_flags(pte, _PAGE_NX);
16516 + else
16517 +#endif
16518 + return pte_clear_flags(pte, _PAGE_USER);
16519 }
16520
16521 static inline pte_t pte_mkdirty(pte_t pte)
16522 @@ -430,6 +495,16 @@ pte_t *populate_extra_pte(unsigned long vaddr);
16523 #endif
16524
16525 #ifndef __ASSEMBLY__
16526 +
16527 +#ifdef CONFIG_PAX_PER_CPU_PGD
16528 +extern pgd_t cpu_pgd[NR_CPUS][2][PTRS_PER_PGD];
16529 +enum cpu_pgd_type {kernel = 0, user = 1};
16530 +static inline pgd_t *get_cpu_pgd(unsigned int cpu, enum cpu_pgd_type type)
16531 +{
16532 + return cpu_pgd[cpu][type];
16533 +}
16534 +#endif
16535 +
16536 #include <linux/mm_types.h>
16537 #include <linux/mmdebug.h>
16538 #include <linux/log2.h>
16539 @@ -563,7 +638,7 @@ static inline unsigned long pud_page_vaddr(pud_t pud)
16540 * Currently stuck as a macro due to indirect forward reference to
16541 * linux/mmzone.h's __section_mem_map_addr() definition:
16542 */
16543 -#define pud_page(pud) pfn_to_page(pud_val(pud) >> PAGE_SHIFT)
16544 +#define pud_page(pud) pfn_to_page((pud_val(pud) & PTE_PFN_MASK) >> PAGE_SHIFT)
16545
16546 /* Find an entry in the second-level page table.. */
16547 static inline pmd_t *pmd_offset(pud_t *pud, unsigned long address)
16548 @@ -603,7 +678,7 @@ static inline unsigned long pgd_page_vaddr(pgd_t pgd)
16549 * Currently stuck as a macro due to indirect forward reference to
16550 * linux/mmzone.h's __section_mem_map_addr() definition:
16551 */
16552 -#define pgd_page(pgd) pfn_to_page(pgd_val(pgd) >> PAGE_SHIFT)
16553 +#define pgd_page(pgd) pfn_to_page((pgd_val(pgd) & PTE_PFN_MASK) >> PAGE_SHIFT)
16554
16555 /* to find an entry in a page-table-directory. */
16556 static inline unsigned long pud_index(unsigned long address)
16557 @@ -618,7 +693,7 @@ static inline pud_t *pud_offset(pgd_t *pgd, unsigned long address)
16558
16559 static inline int pgd_bad(pgd_t pgd)
16560 {
16561 - return (pgd_flags(pgd) & ~_PAGE_USER) != _KERNPG_TABLE;
16562 + return (pgd_flags(pgd) & ~(_PAGE_USER | _PAGE_NX)) != _KERNPG_TABLE;
16563 }
16564
16565 static inline int pgd_none(pgd_t pgd)
16566 @@ -641,7 +716,12 @@ static inline int pgd_none(pgd_t pgd)
16567 * pgd_offset() returns a (pgd_t *)
16568 * pgd_index() is used get the offset into the pgd page's array of pgd_t's;
16569 */
16570 -#define pgd_offset(mm, address) ((mm)->pgd + pgd_index((address)))
16571 +#define pgd_offset(mm, address) ((mm)->pgd + pgd_index(address))
16572 +
16573 +#ifdef CONFIG_PAX_PER_CPU_PGD
16574 +#define pgd_offset_cpu(cpu, type, address) (get_cpu_pgd(cpu, type) + pgd_index(address))
16575 +#endif
16576 +
16577 /*
16578 * a shortcut which implies the use of the kernel's pgd, instead
16579 * of a process's
16580 @@ -652,6 +732,23 @@ static inline int pgd_none(pgd_t pgd)
16581 #define KERNEL_PGD_BOUNDARY pgd_index(PAGE_OFFSET)
16582 #define KERNEL_PGD_PTRS (PTRS_PER_PGD - KERNEL_PGD_BOUNDARY)
16583
16584 +#ifdef CONFIG_X86_32
16585 +#define USER_PGD_PTRS KERNEL_PGD_BOUNDARY
16586 +#else
16587 +#define TASK_SIZE_MAX_SHIFT CONFIG_TASK_SIZE_MAX_SHIFT
16588 +#define USER_PGD_PTRS (_AC(1,UL) << (TASK_SIZE_MAX_SHIFT - PGDIR_SHIFT))
16589 +
16590 +#ifdef CONFIG_PAX_MEMORY_UDEREF
16591 +#ifdef __ASSEMBLY__
16592 +#define pax_user_shadow_base pax_user_shadow_base(%rip)
16593 +#else
16594 +extern unsigned long pax_user_shadow_base;
16595 +extern pgdval_t clone_pgd_mask;
16596 +#endif
16597 +#endif
16598 +
16599 +#endif
16600 +
16601 #ifndef __ASSEMBLY__
16602
16603 extern int direct_gbpages;
16604 @@ -818,11 +915,24 @@ static inline void pmdp_set_wrprotect(struct mm_struct *mm,
16605 * dst and src can be on the same page, but the range must not overlap,
16606 * and must not cross a page boundary.
16607 */
16608 -static inline void clone_pgd_range(pgd_t *dst, pgd_t *src, int count)
16609 +static inline void clone_pgd_range(pgd_t *dst, const pgd_t *src, int count)
16610 {
16611 - memcpy(dst, src, count * sizeof(pgd_t));
16612 + pax_open_kernel();
16613 + while (count--)
16614 + *dst++ = *src++;
16615 + pax_close_kernel();
16616 }
16617
16618 +#ifdef CONFIG_PAX_PER_CPU_PGD
16619 +extern void __clone_user_pgds(pgd_t *dst, const pgd_t *src);
16620 +#endif
16621 +
16622 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
16623 +extern void __shadow_user_pgds(pgd_t *dst, const pgd_t *src);
16624 +#else
16625 +static inline void __shadow_user_pgds(pgd_t *dst, const pgd_t *src) {}
16626 +#endif
16627 +
16628 #define PTE_SHIFT ilog2(PTRS_PER_PTE)
16629 static inline int page_level_shift(enum pg_level level)
16630 {
16631 diff --git a/arch/x86/include/asm/pgtable_32.h b/arch/x86/include/asm/pgtable_32.h
16632 index 9ee3221..b979c6b 100644
16633 --- a/arch/x86/include/asm/pgtable_32.h
16634 +++ b/arch/x86/include/asm/pgtable_32.h
16635 @@ -25,9 +25,6 @@
16636 struct mm_struct;
16637 struct vm_area_struct;
16638
16639 -extern pgd_t swapper_pg_dir[1024];
16640 -extern pgd_t initial_page_table[1024];
16641 -
16642 static inline void pgtable_cache_init(void) { }
16643 static inline void check_pgt_cache(void) { }
16644 void paging_init(void);
16645 @@ -48,6 +45,12 @@ extern void set_pmd_pfn(unsigned long, unsigned long, pgprot_t);
16646 # include <asm/pgtable-2level.h>
16647 #endif
16648
16649 +extern pgd_t swapper_pg_dir[PTRS_PER_PGD];
16650 +extern pgd_t initial_page_table[PTRS_PER_PGD];
16651 +#ifdef CONFIG_X86_PAE
16652 +extern pmd_t swapper_pm_dir[PTRS_PER_PGD][PTRS_PER_PMD];
16653 +#endif
16654 +
16655 #if defined(CONFIG_HIGHPTE)
16656 #define pte_offset_map(dir, address) \
16657 ((pte_t *)kmap_atomic(pmd_page(*(dir))) + \
16658 @@ -62,12 +65,17 @@ extern void set_pmd_pfn(unsigned long, unsigned long, pgprot_t);
16659 /* Clear a kernel PTE and flush it from the TLB */
16660 #define kpte_clear_flush(ptep, vaddr) \
16661 do { \
16662 + pax_open_kernel(); \
16663 pte_clear(&init_mm, (vaddr), (ptep)); \
16664 + pax_close_kernel(); \
16665 __flush_tlb_one((vaddr)); \
16666 } while (0)
16667
16668 #endif /* !__ASSEMBLY__ */
16669
16670 +#define HAVE_ARCH_UNMAPPED_AREA
16671 +#define HAVE_ARCH_UNMAPPED_AREA_TOPDOWN
16672 +
16673 /*
16674 * kern_addr_valid() is (1) for FLATMEM and (0) for
16675 * SPARSEMEM and DISCONTIGMEM
16676 diff --git a/arch/x86/include/asm/pgtable_32_types.h b/arch/x86/include/asm/pgtable_32_types.h
16677 index ed5903b..c7fe163 100644
16678 --- a/arch/x86/include/asm/pgtable_32_types.h
16679 +++ b/arch/x86/include/asm/pgtable_32_types.h
16680 @@ -8,7 +8,7 @@
16681 */
16682 #ifdef CONFIG_X86_PAE
16683 # include <asm/pgtable-3level_types.h>
16684 -# define PMD_SIZE (1UL << PMD_SHIFT)
16685 +# define PMD_SIZE (_AC(1, UL) << PMD_SHIFT)
16686 # define PMD_MASK (~(PMD_SIZE - 1))
16687 #else
16688 # include <asm/pgtable-2level_types.h>
16689 @@ -46,6 +46,19 @@ extern bool __vmalloc_start_set; /* set once high_memory is set */
16690 # define VMALLOC_END (FIXADDR_START - 2 * PAGE_SIZE)
16691 #endif
16692
16693 +#ifdef CONFIG_PAX_KERNEXEC
16694 +#ifndef __ASSEMBLY__
16695 +extern unsigned char MODULES_EXEC_VADDR[];
16696 +extern unsigned char MODULES_EXEC_END[];
16697 +#endif
16698 +#include <asm/boot.h>
16699 +#define ktla_ktva(addr) (addr + LOAD_PHYSICAL_ADDR + PAGE_OFFSET)
16700 +#define ktva_ktla(addr) (addr - LOAD_PHYSICAL_ADDR - PAGE_OFFSET)
16701 +#else
16702 +#define ktla_ktva(addr) (addr)
16703 +#define ktva_ktla(addr) (addr)
16704 +#endif
16705 +
16706 #define MODULES_VADDR VMALLOC_START
16707 #define MODULES_END VMALLOC_END
16708 #define MODULES_LEN (MODULES_VADDR - MODULES_END)
16709 diff --git a/arch/x86/include/asm/pgtable_64.h b/arch/x86/include/asm/pgtable_64.h
16710 index e22c1db..23a625a 100644
16711 --- a/arch/x86/include/asm/pgtable_64.h
16712 +++ b/arch/x86/include/asm/pgtable_64.h
16713 @@ -16,10 +16,14 @@
16714
16715 extern pud_t level3_kernel_pgt[512];
16716 extern pud_t level3_ident_pgt[512];
16717 +extern pud_t level3_vmalloc_start_pgt[512];
16718 +extern pud_t level3_vmalloc_end_pgt[512];
16719 +extern pud_t level3_vmemmap_pgt[512];
16720 +extern pud_t level2_vmemmap_pgt[512];
16721 extern pmd_t level2_kernel_pgt[512];
16722 extern pmd_t level2_fixmap_pgt[512];
16723 -extern pmd_t level2_ident_pgt[512];
16724 -extern pgd_t init_level4_pgt[];
16725 +extern pmd_t level2_ident_pgt[512*2];
16726 +extern pgd_t init_level4_pgt[512];
16727
16728 #define swapper_pg_dir init_level4_pgt
16729
16730 @@ -61,7 +65,9 @@ static inline void native_set_pte_atomic(pte_t *ptep, pte_t pte)
16731
16732 static inline void native_set_pmd(pmd_t *pmdp, pmd_t pmd)
16733 {
16734 + pax_open_kernel();
16735 *pmdp = pmd;
16736 + pax_close_kernel();
16737 }
16738
16739 static inline void native_pmd_clear(pmd_t *pmd)
16740 @@ -97,7 +103,9 @@ static inline pmd_t native_pmdp_get_and_clear(pmd_t *xp)
16741
16742 static inline void native_set_pud(pud_t *pudp, pud_t pud)
16743 {
16744 + pax_open_kernel();
16745 *pudp = pud;
16746 + pax_close_kernel();
16747 }
16748
16749 static inline void native_pud_clear(pud_t *pud)
16750 @@ -107,6 +115,13 @@ static inline void native_pud_clear(pud_t *pud)
16751
16752 static inline void native_set_pgd(pgd_t *pgdp, pgd_t pgd)
16753 {
16754 + pax_open_kernel();
16755 + *pgdp = pgd;
16756 + pax_close_kernel();
16757 +}
16758 +
16759 +static inline void native_set_pgd_batched(pgd_t *pgdp, pgd_t pgd)
16760 +{
16761 *pgdp = pgd;
16762 }
16763
16764 diff --git a/arch/x86/include/asm/pgtable_64_types.h b/arch/x86/include/asm/pgtable_64_types.h
16765 index 2d88344..4679fc3 100644
16766 --- a/arch/x86/include/asm/pgtable_64_types.h
16767 +++ b/arch/x86/include/asm/pgtable_64_types.h
16768 @@ -61,6 +61,11 @@ typedef struct { pteval_t pte; } pte_t;
16769 #define MODULES_VADDR _AC(0xffffffffa0000000, UL)
16770 #define MODULES_END _AC(0xffffffffff000000, UL)
16771 #define MODULES_LEN (MODULES_END - MODULES_VADDR)
16772 +#define MODULES_EXEC_VADDR MODULES_VADDR
16773 +#define MODULES_EXEC_END MODULES_END
16774 +
16775 +#define ktla_ktva(addr) (addr)
16776 +#define ktva_ktla(addr) (addr)
16777
16778 #define EARLY_DYNAMIC_PAGE_TABLES 64
16779
16780 diff --git a/arch/x86/include/asm/pgtable_types.h b/arch/x86/include/asm/pgtable_types.h
16781 index 0ecac25..306c276 100644
16782 --- a/arch/x86/include/asm/pgtable_types.h
16783 +++ b/arch/x86/include/asm/pgtable_types.h
16784 @@ -16,13 +16,12 @@
16785 #define _PAGE_BIT_PSE 7 /* 4 MB (or 2MB) page */
16786 #define _PAGE_BIT_PAT 7 /* on 4KB pages */
16787 #define _PAGE_BIT_GLOBAL 8 /* Global TLB entry PPro+ */
16788 -#define _PAGE_BIT_UNUSED1 9 /* available for programmer */
16789 +#define _PAGE_BIT_SPECIAL 9 /* special mappings, no associated struct page */
16790 #define _PAGE_BIT_IOMAP 10 /* flag used to indicate IO mapping */
16791 #define _PAGE_BIT_HIDDEN 11 /* hidden by kmemcheck */
16792 #define _PAGE_BIT_PAT_LARGE 12 /* On 2MB or 1GB pages */
16793 -#define _PAGE_BIT_SPECIAL _PAGE_BIT_UNUSED1
16794 -#define _PAGE_BIT_CPA_TEST _PAGE_BIT_UNUSED1
16795 -#define _PAGE_BIT_SPLITTING _PAGE_BIT_UNUSED1 /* only valid on a PSE pmd */
16796 +#define _PAGE_BIT_CPA_TEST _PAGE_BIT_SPECIAL
16797 +#define _PAGE_BIT_SPLITTING _PAGE_BIT_SPECIAL /* only valid on a PSE pmd */
16798 #define _PAGE_BIT_NX 63 /* No execute: only valid after cpuid check */
16799
16800 /* If _PAGE_BIT_PRESENT is clear, we use these: */
16801 @@ -40,7 +39,6 @@
16802 #define _PAGE_DIRTY (_AT(pteval_t, 1) << _PAGE_BIT_DIRTY)
16803 #define _PAGE_PSE (_AT(pteval_t, 1) << _PAGE_BIT_PSE)
16804 #define _PAGE_GLOBAL (_AT(pteval_t, 1) << _PAGE_BIT_GLOBAL)
16805 -#define _PAGE_UNUSED1 (_AT(pteval_t, 1) << _PAGE_BIT_UNUSED1)
16806 #define _PAGE_IOMAP (_AT(pteval_t, 1) << _PAGE_BIT_IOMAP)
16807 #define _PAGE_PAT (_AT(pteval_t, 1) << _PAGE_BIT_PAT)
16808 #define _PAGE_PAT_LARGE (_AT(pteval_t, 1) << _PAGE_BIT_PAT_LARGE)
16809 @@ -87,8 +85,10 @@
16810
16811 #if defined(CONFIG_X86_64) || defined(CONFIG_X86_PAE)
16812 #define _PAGE_NX (_AT(pteval_t, 1) << _PAGE_BIT_NX)
16813 -#else
16814 +#elif defined(CONFIG_KMEMCHECK)
16815 #define _PAGE_NX (_AT(pteval_t, 0))
16816 +#else
16817 +#define _PAGE_NX (_AT(pteval_t, 1) << _PAGE_BIT_HIDDEN)
16818 #endif
16819
16820 #define _PAGE_FILE (_AT(pteval_t, 1) << _PAGE_BIT_FILE)
16821 @@ -146,6 +146,9 @@
16822 #define PAGE_READONLY_EXEC __pgprot(_PAGE_PRESENT | _PAGE_USER | \
16823 _PAGE_ACCESSED)
16824
16825 +#define PAGE_READONLY_NOEXEC PAGE_READONLY
16826 +#define PAGE_SHARED_NOEXEC PAGE_SHARED
16827 +
16828 #define __PAGE_KERNEL_EXEC \
16829 (_PAGE_PRESENT | _PAGE_RW | _PAGE_DIRTY | _PAGE_ACCESSED | _PAGE_GLOBAL)
16830 #define __PAGE_KERNEL (__PAGE_KERNEL_EXEC | _PAGE_NX)
16831 @@ -156,7 +159,7 @@
16832 #define __PAGE_KERNEL_WC (__PAGE_KERNEL | _PAGE_CACHE_WC)
16833 #define __PAGE_KERNEL_NOCACHE (__PAGE_KERNEL | _PAGE_PCD | _PAGE_PWT)
16834 #define __PAGE_KERNEL_UC_MINUS (__PAGE_KERNEL | _PAGE_PCD)
16835 -#define __PAGE_KERNEL_VSYSCALL (__PAGE_KERNEL_RX | _PAGE_USER)
16836 +#define __PAGE_KERNEL_VSYSCALL (__PAGE_KERNEL_RO | _PAGE_USER)
16837 #define __PAGE_KERNEL_VVAR (__PAGE_KERNEL_RO | _PAGE_USER)
16838 #define __PAGE_KERNEL_VVAR_NOCACHE (__PAGE_KERNEL_VVAR | _PAGE_PCD | _PAGE_PWT)
16839 #define __PAGE_KERNEL_LARGE (__PAGE_KERNEL | _PAGE_PSE)
16840 @@ -218,8 +221,8 @@
16841 * bits are combined, this will alow user to access the high address mapped
16842 * VDSO in the presence of CONFIG_COMPAT_VDSO
16843 */
16844 -#define PTE_IDENT_ATTR 0x003 /* PRESENT+RW */
16845 -#define PDE_IDENT_ATTR 0x067 /* PRESENT+RW+USER+DIRTY+ACCESSED */
16846 +#define PTE_IDENT_ATTR 0x063 /* PRESENT+RW+DIRTY+ACCESSED */
16847 +#define PDE_IDENT_ATTR 0x063 /* PRESENT+RW+DIRTY+ACCESSED */
16848 #define PGD_IDENT_ATTR 0x001 /* PRESENT (no other attributes) */
16849 #endif
16850
16851 @@ -257,7 +260,17 @@ static inline pgdval_t pgd_flags(pgd_t pgd)
16852 {
16853 return native_pgd_val(pgd) & PTE_FLAGS_MASK;
16854 }
16855 +#endif
16856
16857 +#if PAGETABLE_LEVELS == 3
16858 +#include <asm-generic/pgtable-nopud.h>
16859 +#endif
16860 +
16861 +#if PAGETABLE_LEVELS == 2
16862 +#include <asm-generic/pgtable-nopmd.h>
16863 +#endif
16864 +
16865 +#ifndef __ASSEMBLY__
16866 #if PAGETABLE_LEVELS > 3
16867 typedef struct { pudval_t pud; } pud_t;
16868
16869 @@ -271,8 +284,6 @@ static inline pudval_t native_pud_val(pud_t pud)
16870 return pud.pud;
16871 }
16872 #else
16873 -#include <asm-generic/pgtable-nopud.h>
16874 -
16875 static inline pudval_t native_pud_val(pud_t pud)
16876 {
16877 return native_pgd_val(pud.pgd);
16878 @@ -292,8 +303,6 @@ static inline pmdval_t native_pmd_val(pmd_t pmd)
16879 return pmd.pmd;
16880 }
16881 #else
16882 -#include <asm-generic/pgtable-nopmd.h>
16883 -
16884 static inline pmdval_t native_pmd_val(pmd_t pmd)
16885 {
16886 return native_pgd_val(pmd.pud.pgd);
16887 @@ -333,7 +342,6 @@ typedef struct page *pgtable_t;
16888
16889 extern pteval_t __supported_pte_mask;
16890 extern void set_nx(void);
16891 -extern int nx_enabled;
16892
16893 #define pgprot_writecombine pgprot_writecombine
16894 extern pgprot_t pgprot_writecombine(pgprot_t prot);
16895 diff --git a/arch/x86/include/asm/processor.h b/arch/x86/include/asm/processor.h
16896 index 987c75e..2723054 100644
16897 --- a/arch/x86/include/asm/processor.h
16898 +++ b/arch/x86/include/asm/processor.h
16899 @@ -199,9 +199,21 @@ static inline void native_cpuid(unsigned int *eax, unsigned int *ebx,
16900 : "memory");
16901 }
16902
16903 +/* invpcid (%rdx),%rax */
16904 +#define __ASM_INVPCID ".byte 0x66,0x0f,0x38,0x82,0x02"
16905 +
16906 +#define INVPCID_SINGLE_ADDRESS 0UL
16907 +#define INVPCID_SINGLE_CONTEXT 1UL
16908 +#define INVPCID_ALL_GLOBAL 2UL
16909 +#define INVPCID_ALL_MONGLOBAL 3UL
16910 +
16911 +#define PCID_KERNEL 0UL
16912 +#define PCID_USER 1UL
16913 +#define PCID_NOFLUSH (1UL << 63)
16914 +
16915 static inline void load_cr3(pgd_t *pgdir)
16916 {
16917 - write_cr3(__pa(pgdir));
16918 + write_cr3(__pa(pgdir) | PCID_KERNEL);
16919 }
16920
16921 #ifdef CONFIG_X86_32
16922 @@ -283,7 +295,7 @@ struct tss_struct {
16923
16924 } ____cacheline_aligned;
16925
16926 -DECLARE_PER_CPU_SHARED_ALIGNED(struct tss_struct, init_tss);
16927 +extern struct tss_struct init_tss[NR_CPUS];
16928
16929 /*
16930 * Save the original ist values for checking stack pointers during debugging
16931 @@ -453,6 +465,7 @@ struct thread_struct {
16932 unsigned short ds;
16933 unsigned short fsindex;
16934 unsigned short gsindex;
16935 + unsigned short ss;
16936 #endif
16937 #ifdef CONFIG_X86_32
16938 unsigned long ip;
16939 @@ -553,29 +566,8 @@ static inline void load_sp0(struct tss_struct *tss,
16940 extern unsigned long mmu_cr4_features;
16941 extern u32 *trampoline_cr4_features;
16942
16943 -static inline void set_in_cr4(unsigned long mask)
16944 -{
16945 - unsigned long cr4;
16946 -
16947 - mmu_cr4_features |= mask;
16948 - if (trampoline_cr4_features)
16949 - *trampoline_cr4_features = mmu_cr4_features;
16950 - cr4 = read_cr4();
16951 - cr4 |= mask;
16952 - write_cr4(cr4);
16953 -}
16954 -
16955 -static inline void clear_in_cr4(unsigned long mask)
16956 -{
16957 - unsigned long cr4;
16958 -
16959 - mmu_cr4_features &= ~mask;
16960 - if (trampoline_cr4_features)
16961 - *trampoline_cr4_features = mmu_cr4_features;
16962 - cr4 = read_cr4();
16963 - cr4 &= ~mask;
16964 - write_cr4(cr4);
16965 -}
16966 +extern void set_in_cr4(unsigned long mask);
16967 +extern void clear_in_cr4(unsigned long mask);
16968
16969 typedef struct {
16970 unsigned long seg;
16971 @@ -824,11 +816,18 @@ static inline void spin_lock_prefetch(const void *x)
16972 */
16973 #define TASK_SIZE PAGE_OFFSET
16974 #define TASK_SIZE_MAX TASK_SIZE
16975 +
16976 +#ifdef CONFIG_PAX_SEGMEXEC
16977 +#define SEGMEXEC_TASK_SIZE (TASK_SIZE / 2)
16978 +#define STACK_TOP ((current->mm->pax_flags & MF_PAX_SEGMEXEC)?SEGMEXEC_TASK_SIZE:TASK_SIZE)
16979 +#else
16980 #define STACK_TOP TASK_SIZE
16981 -#define STACK_TOP_MAX STACK_TOP
16982 +#endif
16983 +
16984 +#define STACK_TOP_MAX TASK_SIZE
16985
16986 #define INIT_THREAD { \
16987 - .sp0 = sizeof(init_stack) + (long)&init_stack, \
16988 + .sp0 = sizeof(init_stack) + (long)&init_stack - 8, \
16989 .vm86_info = NULL, \
16990 .sysenter_cs = __KERNEL_CS, \
16991 .io_bitmap_ptr = NULL, \
16992 @@ -842,7 +841,7 @@ static inline void spin_lock_prefetch(const void *x)
16993 */
16994 #define INIT_TSS { \
16995 .x86_tss = { \
16996 - .sp0 = sizeof(init_stack) + (long)&init_stack, \
16997 + .sp0 = sizeof(init_stack) + (long)&init_stack - 8, \
16998 .ss0 = __KERNEL_DS, \
16999 .ss1 = __KERNEL_CS, \
17000 .io_bitmap_base = INVALID_IO_BITMAP_OFFSET, \
17001 @@ -853,11 +852,7 @@ static inline void spin_lock_prefetch(const void *x)
17002 extern unsigned long thread_saved_pc(struct task_struct *tsk);
17003
17004 #define THREAD_SIZE_LONGS (THREAD_SIZE/sizeof(unsigned long))
17005 -#define KSTK_TOP(info) \
17006 -({ \
17007 - unsigned long *__ptr = (unsigned long *)(info); \
17008 - (unsigned long)(&__ptr[THREAD_SIZE_LONGS]); \
17009 -})
17010 +#define KSTK_TOP(info) ((container_of(info, struct task_struct, tinfo))->thread.sp0)
17011
17012 /*
17013 * The below -8 is to reserve 8 bytes on top of the ring0 stack.
17014 @@ -872,7 +867,7 @@ extern unsigned long thread_saved_pc(struct task_struct *tsk);
17015 #define task_pt_regs(task) \
17016 ({ \
17017 struct pt_regs *__regs__; \
17018 - __regs__ = (struct pt_regs *)(KSTK_TOP(task_stack_page(task))-8); \
17019 + __regs__ = (struct pt_regs *)((task)->thread.sp0); \
17020 __regs__ - 1; \
17021 })
17022
17023 @@ -882,13 +877,13 @@ extern unsigned long thread_saved_pc(struct task_struct *tsk);
17024 /*
17025 * User space process size. 47bits minus one guard page.
17026 */
17027 -#define TASK_SIZE_MAX ((1UL << 47) - PAGE_SIZE)
17028 +#define TASK_SIZE_MAX ((1UL << TASK_SIZE_MAX_SHIFT) - PAGE_SIZE)
17029
17030 /* This decides where the kernel will search for a free chunk of vm
17031 * space during mmap's.
17032 */
17033 #define IA32_PAGE_OFFSET ((current->personality & ADDR_LIMIT_3GB) ? \
17034 - 0xc0000000 : 0xFFFFe000)
17035 + 0xc0000000 : 0xFFFFf000)
17036
17037 #define TASK_SIZE (test_thread_flag(TIF_ADDR32) ? \
17038 IA32_PAGE_OFFSET : TASK_SIZE_MAX)
17039 @@ -899,11 +894,11 @@ extern unsigned long thread_saved_pc(struct task_struct *tsk);
17040 #define STACK_TOP_MAX TASK_SIZE_MAX
17041
17042 #define INIT_THREAD { \
17043 - .sp0 = (unsigned long)&init_stack + sizeof(init_stack) \
17044 + .sp0 = (unsigned long)&init_stack + sizeof(init_stack) - 16 \
17045 }
17046
17047 #define INIT_TSS { \
17048 - .x86_tss.sp0 = (unsigned long)&init_stack + sizeof(init_stack) \
17049 + .x86_tss.sp0 = (unsigned long)&init_stack + sizeof(init_stack) - 16 \
17050 }
17051
17052 /*
17053 @@ -931,6 +926,10 @@ extern void start_thread(struct pt_regs *regs, unsigned long new_ip,
17054 */
17055 #define TASK_UNMAPPED_BASE (PAGE_ALIGN(TASK_SIZE / 3))
17056
17057 +#ifdef CONFIG_PAX_SEGMEXEC
17058 +#define SEGMEXEC_TASK_UNMAPPED_BASE (PAGE_ALIGN(SEGMEXEC_TASK_SIZE / 3))
17059 +#endif
17060 +
17061 #define KSTK_EIP(task) (task_pt_regs(task)->ip)
17062
17063 /* Get/set a process' ability to use the timestamp counter instruction */
17064 @@ -957,7 +956,7 @@ static inline uint32_t hypervisor_cpuid_base(const char *sig, uint32_t leaves)
17065 return 0;
17066 }
17067
17068 -extern unsigned long arch_align_stack(unsigned long sp);
17069 +#define arch_align_stack(x) ((x) & ~0xfUL)
17070 extern void free_init_pages(char *what, unsigned long begin, unsigned long end);
17071
17072 void default_idle(void);
17073 @@ -967,6 +966,6 @@ bool xen_set_default_idle(void);
17074 #define xen_set_default_idle 0
17075 #endif
17076
17077 -void stop_this_cpu(void *dummy);
17078 +void stop_this_cpu(void *dummy) __noreturn;
17079 void df_debug(struct pt_regs *regs, long error_code);
17080 #endif /* _ASM_X86_PROCESSOR_H */
17081 diff --git a/arch/x86/include/asm/ptrace.h b/arch/x86/include/asm/ptrace.h
17082 index 942a086..6c26446 100644
17083 --- a/arch/x86/include/asm/ptrace.h
17084 +++ b/arch/x86/include/asm/ptrace.h
17085 @@ -85,28 +85,29 @@ static inline unsigned long regs_return_value(struct pt_regs *regs)
17086 }
17087
17088 /*
17089 - * user_mode_vm(regs) determines whether a register set came from user mode.
17090 + * user_mode(regs) determines whether a register set came from user mode.
17091 * This is true if V8086 mode was enabled OR if the register set was from
17092 * protected mode with RPL-3 CS value. This tricky test checks that with
17093 * one comparison. Many places in the kernel can bypass this full check
17094 - * if they have already ruled out V8086 mode, so user_mode(regs) can be used.
17095 + * if they have already ruled out V8086 mode, so user_mode_novm(regs) can
17096 + * be used.
17097 */
17098 -static inline int user_mode(struct pt_regs *regs)
17099 +static inline int user_mode_novm(struct pt_regs *regs)
17100 {
17101 #ifdef CONFIG_X86_32
17102 return (regs->cs & SEGMENT_RPL_MASK) == USER_RPL;
17103 #else
17104 - return !!(regs->cs & 3);
17105 + return !!(regs->cs & SEGMENT_RPL_MASK);
17106 #endif
17107 }
17108
17109 -static inline int user_mode_vm(struct pt_regs *regs)
17110 +static inline int user_mode(struct pt_regs *regs)
17111 {
17112 #ifdef CONFIG_X86_32
17113 return ((regs->cs & SEGMENT_RPL_MASK) | (regs->flags & X86_VM_MASK)) >=
17114 USER_RPL;
17115 #else
17116 - return user_mode(regs);
17117 + return user_mode_novm(regs);
17118 #endif
17119 }
17120
17121 @@ -122,15 +123,16 @@ static inline int v8086_mode(struct pt_regs *regs)
17122 #ifdef CONFIG_X86_64
17123 static inline bool user_64bit_mode(struct pt_regs *regs)
17124 {
17125 + unsigned long cs = regs->cs & 0xffff;
17126 #ifndef CONFIG_PARAVIRT
17127 /*
17128 * On non-paravirt systems, this is the only long mode CPL 3
17129 * selector. We do not allow long mode selectors in the LDT.
17130 */
17131 - return regs->cs == __USER_CS;
17132 + return cs == __USER_CS;
17133 #else
17134 /* Headers are too twisted for this to go in paravirt.h. */
17135 - return regs->cs == __USER_CS || regs->cs == pv_info.extra_user_64bit_cs;
17136 + return cs == __USER_CS || cs == pv_info.extra_user_64bit_cs;
17137 #endif
17138 }
17139
17140 @@ -181,9 +183,11 @@ static inline unsigned long regs_get_register(struct pt_regs *regs,
17141 * Traps from the kernel do not save sp and ss.
17142 * Use the helper function to retrieve sp.
17143 */
17144 - if (offset == offsetof(struct pt_regs, sp) &&
17145 - regs->cs == __KERNEL_CS)
17146 - return kernel_stack_pointer(regs);
17147 + if (offset == offsetof(struct pt_regs, sp)) {
17148 + unsigned long cs = regs->cs & 0xffff;
17149 + if (cs == __KERNEL_CS || cs == __KERNEXEC_KERNEL_CS)
17150 + return kernel_stack_pointer(regs);
17151 + }
17152 #endif
17153 return *(unsigned long *)((unsigned long)regs + offset);
17154 }
17155 diff --git a/arch/x86/include/asm/realmode.h b/arch/x86/include/asm/realmode.h
17156 index 9c6b890..5305f53 100644
17157 --- a/arch/x86/include/asm/realmode.h
17158 +++ b/arch/x86/include/asm/realmode.h
17159 @@ -22,16 +22,14 @@ struct real_mode_header {
17160 #endif
17161 /* APM/BIOS reboot */
17162 u32 machine_real_restart_asm;
17163 -#ifdef CONFIG_X86_64
17164 u32 machine_real_restart_seg;
17165 -#endif
17166 };
17167
17168 /* This must match data at trampoline_32/64.S */
17169 struct trampoline_header {
17170 #ifdef CONFIG_X86_32
17171 u32 start;
17172 - u16 gdt_pad;
17173 + u16 boot_cs;
17174 u16 gdt_limit;
17175 u32 gdt_base;
17176 #else
17177 diff --git a/arch/x86/include/asm/reboot.h b/arch/x86/include/asm/reboot.h
17178 index a82c4f1..ac45053 100644
17179 --- a/arch/x86/include/asm/reboot.h
17180 +++ b/arch/x86/include/asm/reboot.h
17181 @@ -6,13 +6,13 @@
17182 struct pt_regs;
17183
17184 struct machine_ops {
17185 - void (*restart)(char *cmd);
17186 - void (*halt)(void);
17187 - void (*power_off)(void);
17188 + void (* __noreturn restart)(char *cmd);
17189 + void (* __noreturn halt)(void);
17190 + void (* __noreturn power_off)(void);
17191 void (*shutdown)(void);
17192 void (*crash_shutdown)(struct pt_regs *);
17193 - void (*emergency_restart)(void);
17194 -};
17195 + void (* __noreturn emergency_restart)(void);
17196 +} __no_const;
17197
17198 extern struct machine_ops machine_ops;
17199
17200 diff --git a/arch/x86/include/asm/rwsem.h b/arch/x86/include/asm/rwsem.h
17201 index cad82c9..2e5c5c1 100644
17202 --- a/arch/x86/include/asm/rwsem.h
17203 +++ b/arch/x86/include/asm/rwsem.h
17204 @@ -64,6 +64,14 @@ static inline void __down_read(struct rw_semaphore *sem)
17205 {
17206 asm volatile("# beginning down_read\n\t"
17207 LOCK_PREFIX _ASM_INC "(%1)\n\t"
17208 +
17209 +#ifdef CONFIG_PAX_REFCOUNT
17210 + "jno 0f\n"
17211 + LOCK_PREFIX _ASM_DEC "(%1)\n"
17212 + "int $4\n0:\n"
17213 + _ASM_EXTABLE(0b, 0b)
17214 +#endif
17215 +
17216 /* adds 0x00000001 */
17217 " jns 1f\n"
17218 " call call_rwsem_down_read_failed\n"
17219 @@ -85,6 +93,14 @@ static inline int __down_read_trylock(struct rw_semaphore *sem)
17220 "1:\n\t"
17221 " mov %1,%2\n\t"
17222 " add %3,%2\n\t"
17223 +
17224 +#ifdef CONFIG_PAX_REFCOUNT
17225 + "jno 0f\n"
17226 + "sub %3,%2\n"
17227 + "int $4\n0:\n"
17228 + _ASM_EXTABLE(0b, 0b)
17229 +#endif
17230 +
17231 " jle 2f\n\t"
17232 LOCK_PREFIX " cmpxchg %2,%0\n\t"
17233 " jnz 1b\n\t"
17234 @@ -104,6 +120,14 @@ static inline void __down_write_nested(struct rw_semaphore *sem, int subclass)
17235 long tmp;
17236 asm volatile("# beginning down_write\n\t"
17237 LOCK_PREFIX " xadd %1,(%2)\n\t"
17238 +
17239 +#ifdef CONFIG_PAX_REFCOUNT
17240 + "jno 0f\n"
17241 + "mov %1,(%2)\n"
17242 + "int $4\n0:\n"
17243 + _ASM_EXTABLE(0b, 0b)
17244 +#endif
17245 +
17246 /* adds 0xffff0001, returns the old value */
17247 " test " __ASM_SEL(%w1,%k1) "," __ASM_SEL(%w1,%k1) "\n\t"
17248 /* was the active mask 0 before? */
17249 @@ -155,6 +179,14 @@ static inline void __up_read(struct rw_semaphore *sem)
17250 long tmp;
17251 asm volatile("# beginning __up_read\n\t"
17252 LOCK_PREFIX " xadd %1,(%2)\n\t"
17253 +
17254 +#ifdef CONFIG_PAX_REFCOUNT
17255 + "jno 0f\n"
17256 + "mov %1,(%2)\n"
17257 + "int $4\n0:\n"
17258 + _ASM_EXTABLE(0b, 0b)
17259 +#endif
17260 +
17261 /* subtracts 1, returns the old value */
17262 " jns 1f\n\t"
17263 " call call_rwsem_wake\n" /* expects old value in %edx */
17264 @@ -173,6 +205,14 @@ static inline void __up_write(struct rw_semaphore *sem)
17265 long tmp;
17266 asm volatile("# beginning __up_write\n\t"
17267 LOCK_PREFIX " xadd %1,(%2)\n\t"
17268 +
17269 +#ifdef CONFIG_PAX_REFCOUNT
17270 + "jno 0f\n"
17271 + "mov %1,(%2)\n"
17272 + "int $4\n0:\n"
17273 + _ASM_EXTABLE(0b, 0b)
17274 +#endif
17275 +
17276 /* subtracts 0xffff0001, returns the old value */
17277 " jns 1f\n\t"
17278 " call call_rwsem_wake\n" /* expects old value in %edx */
17279 @@ -190,6 +230,14 @@ static inline void __downgrade_write(struct rw_semaphore *sem)
17280 {
17281 asm volatile("# beginning __downgrade_write\n\t"
17282 LOCK_PREFIX _ASM_ADD "%2,(%1)\n\t"
17283 +
17284 +#ifdef CONFIG_PAX_REFCOUNT
17285 + "jno 0f\n"
17286 + LOCK_PREFIX _ASM_SUB "%2,(%1)\n"
17287 + "int $4\n0:\n"
17288 + _ASM_EXTABLE(0b, 0b)
17289 +#endif
17290 +
17291 /*
17292 * transitions 0xZZZZ0001 -> 0xYYYY0001 (i386)
17293 * 0xZZZZZZZZ00000001 -> 0xYYYYYYYY00000001 (x86_64)
17294 @@ -208,7 +256,15 @@ static inline void __downgrade_write(struct rw_semaphore *sem)
17295 */
17296 static inline void rwsem_atomic_add(long delta, struct rw_semaphore *sem)
17297 {
17298 - asm volatile(LOCK_PREFIX _ASM_ADD "%1,%0"
17299 + asm volatile(LOCK_PREFIX _ASM_ADD "%1,%0\n"
17300 +
17301 +#ifdef CONFIG_PAX_REFCOUNT
17302 + "jno 0f\n"
17303 + LOCK_PREFIX _ASM_SUB "%1,%0\n"
17304 + "int $4\n0:\n"
17305 + _ASM_EXTABLE(0b, 0b)
17306 +#endif
17307 +
17308 : "+m" (sem->count)
17309 : "er" (delta));
17310 }
17311 @@ -218,7 +274,7 @@ static inline void rwsem_atomic_add(long delta, struct rw_semaphore *sem)
17312 */
17313 static inline long rwsem_atomic_update(long delta, struct rw_semaphore *sem)
17314 {
17315 - return delta + xadd(&sem->count, delta);
17316 + return delta + xadd_check_overflow(&sem->count, delta);
17317 }
17318
17319 #endif /* __KERNEL__ */
17320 diff --git a/arch/x86/include/asm/segment.h b/arch/x86/include/asm/segment.h
17321 index c48a950..bc40804 100644
17322 --- a/arch/x86/include/asm/segment.h
17323 +++ b/arch/x86/include/asm/segment.h
17324 @@ -64,10 +64,15 @@
17325 * 26 - ESPFIX small SS
17326 * 27 - per-cpu [ offset to per-cpu data area ]
17327 * 28 - stack_canary-20 [ for stack protector ]
17328 - * 29 - unused
17329 - * 30 - unused
17330 + * 29 - PCI BIOS CS
17331 + * 30 - PCI BIOS DS
17332 * 31 - TSS for double fault handler
17333 */
17334 +#define GDT_ENTRY_KERNEXEC_EFI_CS (1)
17335 +#define GDT_ENTRY_KERNEXEC_EFI_DS (2)
17336 +#define __KERNEXEC_EFI_CS (GDT_ENTRY_KERNEXEC_EFI_CS*8)
17337 +#define __KERNEXEC_EFI_DS (GDT_ENTRY_KERNEXEC_EFI_DS*8)
17338 +
17339 #define GDT_ENTRY_TLS_MIN 6
17340 #define GDT_ENTRY_TLS_MAX (GDT_ENTRY_TLS_MIN + GDT_ENTRY_TLS_ENTRIES - 1)
17341
17342 @@ -79,6 +84,8 @@
17343
17344 #define GDT_ENTRY_KERNEL_CS (GDT_ENTRY_KERNEL_BASE+0)
17345
17346 +#define GDT_ENTRY_KERNEXEC_KERNEL_CS (4)
17347 +
17348 #define GDT_ENTRY_KERNEL_DS (GDT_ENTRY_KERNEL_BASE+1)
17349
17350 #define GDT_ENTRY_TSS (GDT_ENTRY_KERNEL_BASE+4)
17351 @@ -104,6 +111,12 @@
17352 #define __KERNEL_STACK_CANARY 0
17353 #endif
17354
17355 +#define GDT_ENTRY_PCIBIOS_CS (GDT_ENTRY_KERNEL_BASE+17)
17356 +#define __PCIBIOS_CS (GDT_ENTRY_PCIBIOS_CS * 8)
17357 +
17358 +#define GDT_ENTRY_PCIBIOS_DS (GDT_ENTRY_KERNEL_BASE+18)
17359 +#define __PCIBIOS_DS (GDT_ENTRY_PCIBIOS_DS * 8)
17360 +
17361 #define GDT_ENTRY_DOUBLEFAULT_TSS 31
17362
17363 /*
17364 @@ -141,7 +154,7 @@
17365 */
17366
17367 /* Matches PNP_CS32 and PNP_CS16 (they must be consecutive) */
17368 -#define SEGMENT_IS_PNP_CODE(x) (((x) & 0xf4) == GDT_ENTRY_PNPBIOS_BASE * 8)
17369 +#define SEGMENT_IS_PNP_CODE(x) (((x) & 0xFFFCU) == PNP_CS32 || ((x) & 0xFFFCU) == PNP_CS16)
17370
17371
17372 #else
17373 @@ -165,6 +178,8 @@
17374 #define __USER32_CS (GDT_ENTRY_DEFAULT_USER32_CS*8+3)
17375 #define __USER32_DS __USER_DS
17376
17377 +#define GDT_ENTRY_KERNEXEC_KERNEL_CS 7
17378 +
17379 #define GDT_ENTRY_TSS 8 /* needs two entries */
17380 #define GDT_ENTRY_LDT 10 /* needs two entries */
17381 #define GDT_ENTRY_TLS_MIN 12
17382 @@ -173,6 +188,8 @@
17383 #define GDT_ENTRY_PER_CPU 15 /* Abused to load per CPU data from limit */
17384 #define __PER_CPU_SEG (GDT_ENTRY_PER_CPU * 8 + 3)
17385
17386 +#define GDT_ENTRY_UDEREF_KERNEL_DS 16
17387 +
17388 /* TLS indexes for 64bit - hardcoded in arch_prctl */
17389 #define FS_TLS 0
17390 #define GS_TLS 1
17391 @@ -180,12 +197,14 @@
17392 #define GS_TLS_SEL ((GDT_ENTRY_TLS_MIN+GS_TLS)*8 + 3)
17393 #define FS_TLS_SEL ((GDT_ENTRY_TLS_MIN+FS_TLS)*8 + 3)
17394
17395 -#define GDT_ENTRIES 16
17396 +#define GDT_ENTRIES 17
17397
17398 #endif
17399
17400 #define __KERNEL_CS (GDT_ENTRY_KERNEL_CS*8)
17401 +#define __KERNEXEC_KERNEL_CS (GDT_ENTRY_KERNEXEC_KERNEL_CS*8)
17402 #define __KERNEL_DS (GDT_ENTRY_KERNEL_DS*8)
17403 +#define __UDEREF_KERNEL_DS (GDT_ENTRY_UDEREF_KERNEL_DS*8)
17404 #define __USER_DS (GDT_ENTRY_DEFAULT_USER_DS*8+3)
17405 #define __USER_CS (GDT_ENTRY_DEFAULT_USER_CS*8+3)
17406 #ifndef CONFIG_PARAVIRT
17407 @@ -265,7 +284,7 @@ static inline unsigned long get_limit(unsigned long segment)
17408 {
17409 unsigned long __limit;
17410 asm("lsll %1,%0" : "=r" (__limit) : "r" (segment));
17411 - return __limit + 1;
17412 + return __limit;
17413 }
17414
17415 #endif /* !__ASSEMBLY__ */
17416 diff --git a/arch/x86/include/asm/smap.h b/arch/x86/include/asm/smap.h
17417 index 8d3120f..352b440 100644
17418 --- a/arch/x86/include/asm/smap.h
17419 +++ b/arch/x86/include/asm/smap.h
17420 @@ -25,11 +25,40 @@
17421
17422 #include <asm/alternative-asm.h>
17423
17424 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
17425 +#define ASM_PAX_OPEN_USERLAND \
17426 + 661: jmp 663f; \
17427 + .pushsection .altinstr_replacement, "a" ; \
17428 + 662: pushq %rax; nop; \
17429 + .popsection ; \
17430 + .pushsection .altinstructions, "a" ; \
17431 + altinstruction_entry 661b, 662b, X86_FEATURE_STRONGUDEREF, 2, 2;\
17432 + .popsection ; \
17433 + call __pax_open_userland; \
17434 + popq %rax; \
17435 + 663:
17436 +
17437 +#define ASM_PAX_CLOSE_USERLAND \
17438 + 661: jmp 663f; \
17439 + .pushsection .altinstr_replacement, "a" ; \
17440 + 662: pushq %rax; nop; \
17441 + .popsection; \
17442 + .pushsection .altinstructions, "a" ; \
17443 + altinstruction_entry 661b, 662b, X86_FEATURE_STRONGUDEREF, 2, 2;\
17444 + .popsection; \
17445 + call __pax_close_userland; \
17446 + popq %rax; \
17447 + 663:
17448 +#else
17449 +#define ASM_PAX_OPEN_USERLAND
17450 +#define ASM_PAX_CLOSE_USERLAND
17451 +#endif
17452 +
17453 #ifdef CONFIG_X86_SMAP
17454
17455 #define ASM_CLAC \
17456 661: ASM_NOP3 ; \
17457 - .pushsection .altinstr_replacement, "ax" ; \
17458 + .pushsection .altinstr_replacement, "a" ; \
17459 662: __ASM_CLAC ; \
17460 .popsection ; \
17461 .pushsection .altinstructions, "a" ; \
17462 @@ -38,7 +67,7 @@
17463
17464 #define ASM_STAC \
17465 661: ASM_NOP3 ; \
17466 - .pushsection .altinstr_replacement, "ax" ; \
17467 + .pushsection .altinstr_replacement, "a" ; \
17468 662: __ASM_STAC ; \
17469 .popsection ; \
17470 .pushsection .altinstructions, "a" ; \
17471 @@ -56,6 +85,37 @@
17472
17473 #include <asm/alternative.h>
17474
17475 +#define __HAVE_ARCH_PAX_OPEN_USERLAND
17476 +#define __HAVE_ARCH_PAX_CLOSE_USERLAND
17477 +
17478 +extern void __pax_open_userland(void);
17479 +static __always_inline unsigned long pax_open_userland(void)
17480 +{
17481 +
17482 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
17483 + asm volatile(ALTERNATIVE(ASM_NOP5, "call %P[open]", X86_FEATURE_STRONGUDEREF)
17484 + :
17485 + : [open] "i" (__pax_open_userland)
17486 + : "memory", "rax");
17487 +#endif
17488 +
17489 + return 0;
17490 +}
17491 +
17492 +extern void __pax_close_userland(void);
17493 +static __always_inline unsigned long pax_close_userland(void)
17494 +{
17495 +
17496 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
17497 + asm volatile(ALTERNATIVE(ASM_NOP5, "call %P[close]", X86_FEATURE_STRONGUDEREF)
17498 + :
17499 + : [close] "i" (__pax_close_userland)
17500 + : "memory", "rax");
17501 +#endif
17502 +
17503 + return 0;
17504 +}
17505 +
17506 #ifdef CONFIG_X86_SMAP
17507
17508 static __always_inline void clac(void)
17509 diff --git a/arch/x86/include/asm/smp.h b/arch/x86/include/asm/smp.h
17510 index 4137890..03fa172 100644
17511 --- a/arch/x86/include/asm/smp.h
17512 +++ b/arch/x86/include/asm/smp.h
17513 @@ -36,7 +36,7 @@ DECLARE_PER_CPU_READ_MOSTLY(cpumask_var_t, cpu_core_map);
17514 /* cpus sharing the last level cache: */
17515 DECLARE_PER_CPU_READ_MOSTLY(cpumask_var_t, cpu_llc_shared_map);
17516 DECLARE_PER_CPU_READ_MOSTLY(u16, cpu_llc_id);
17517 -DECLARE_PER_CPU_READ_MOSTLY(int, cpu_number);
17518 +DECLARE_PER_CPU_READ_MOSTLY(unsigned int, cpu_number);
17519
17520 static inline struct cpumask *cpu_sibling_mask(int cpu)
17521 {
17522 @@ -79,7 +79,7 @@ struct smp_ops {
17523
17524 void (*send_call_func_ipi)(const struct cpumask *mask);
17525 void (*send_call_func_single_ipi)(int cpu);
17526 -};
17527 +} __no_const;
17528
17529 /* Globals due to paravirt */
17530 extern void set_cpu_sibling_map(int cpu);
17531 @@ -191,14 +191,8 @@ extern unsigned disabled_cpus;
17532 extern int safe_smp_processor_id(void);
17533
17534 #elif defined(CONFIG_X86_64_SMP)
17535 -#define raw_smp_processor_id() (this_cpu_read(cpu_number))
17536 -
17537 -#define stack_smp_processor_id() \
17538 -({ \
17539 - struct thread_info *ti; \
17540 - __asm__("andq %%rsp,%0; ":"=r" (ti) : "0" (CURRENT_MASK)); \
17541 - ti->cpu; \
17542 -})
17543 +#define raw_smp_processor_id() (this_cpu_read(cpu_number))
17544 +#define stack_smp_processor_id() raw_smp_processor_id()
17545 #define safe_smp_processor_id() smp_processor_id()
17546
17547 #endif
17548 diff --git a/arch/x86/include/asm/spinlock.h b/arch/x86/include/asm/spinlock.h
17549 index bf156de..1a782ab 100644
17550 --- a/arch/x86/include/asm/spinlock.h
17551 +++ b/arch/x86/include/asm/spinlock.h
17552 @@ -223,6 +223,14 @@ static inline int arch_write_can_lock(arch_rwlock_t *lock)
17553 static inline void arch_read_lock(arch_rwlock_t *rw)
17554 {
17555 asm volatile(LOCK_PREFIX READ_LOCK_SIZE(dec) " (%0)\n\t"
17556 +
17557 +#ifdef CONFIG_PAX_REFCOUNT
17558 + "jno 0f\n"
17559 + LOCK_PREFIX READ_LOCK_SIZE(inc) " (%0)\n"
17560 + "int $4\n0:\n"
17561 + _ASM_EXTABLE(0b, 0b)
17562 +#endif
17563 +
17564 "jns 1f\n"
17565 "call __read_lock_failed\n\t"
17566 "1:\n"
17567 @@ -232,6 +240,14 @@ static inline void arch_read_lock(arch_rwlock_t *rw)
17568 static inline void arch_write_lock(arch_rwlock_t *rw)
17569 {
17570 asm volatile(LOCK_PREFIX WRITE_LOCK_SUB(%1) "(%0)\n\t"
17571 +
17572 +#ifdef CONFIG_PAX_REFCOUNT
17573 + "jno 0f\n"
17574 + LOCK_PREFIX WRITE_LOCK_ADD(%1) "(%0)\n"
17575 + "int $4\n0:\n"
17576 + _ASM_EXTABLE(0b, 0b)
17577 +#endif
17578 +
17579 "jz 1f\n"
17580 "call __write_lock_failed\n\t"
17581 "1:\n"
17582 @@ -261,13 +277,29 @@ static inline int arch_write_trylock(arch_rwlock_t *lock)
17583
17584 static inline void arch_read_unlock(arch_rwlock_t *rw)
17585 {
17586 - asm volatile(LOCK_PREFIX READ_LOCK_SIZE(inc) " %0"
17587 + asm volatile(LOCK_PREFIX READ_LOCK_SIZE(inc) " %0\n"
17588 +
17589 +#ifdef CONFIG_PAX_REFCOUNT
17590 + "jno 0f\n"
17591 + LOCK_PREFIX READ_LOCK_SIZE(dec) " %0\n"
17592 + "int $4\n0:\n"
17593 + _ASM_EXTABLE(0b, 0b)
17594 +#endif
17595 +
17596 :"+m" (rw->lock) : : "memory");
17597 }
17598
17599 static inline void arch_write_unlock(arch_rwlock_t *rw)
17600 {
17601 - asm volatile(LOCK_PREFIX WRITE_LOCK_ADD(%1) "%0"
17602 + asm volatile(LOCK_PREFIX WRITE_LOCK_ADD(%1) "%0\n"
17603 +
17604 +#ifdef CONFIG_PAX_REFCOUNT
17605 + "jno 0f\n"
17606 + LOCK_PREFIX WRITE_LOCK_SUB(%1) "%0\n"
17607 + "int $4\n0:\n"
17608 + _ASM_EXTABLE(0b, 0b)
17609 +#endif
17610 +
17611 : "+m" (rw->write) : "i" (RW_LOCK_BIAS) : "memory");
17612 }
17613
17614 diff --git a/arch/x86/include/asm/stackprotector.h b/arch/x86/include/asm/stackprotector.h
17615 index 6a99859..03cb807 100644
17616 --- a/arch/x86/include/asm/stackprotector.h
17617 +++ b/arch/x86/include/asm/stackprotector.h
17618 @@ -47,7 +47,7 @@
17619 * head_32 for boot CPU and setup_per_cpu_areas() for others.
17620 */
17621 #define GDT_STACK_CANARY_INIT \
17622 - [GDT_ENTRY_STACK_CANARY] = GDT_ENTRY_INIT(0x4090, 0, 0x18),
17623 + [GDT_ENTRY_STACK_CANARY] = GDT_ENTRY_INIT(0x4090, 0, 0x17),
17624
17625 /*
17626 * Initialize the stackprotector canary value.
17627 @@ -112,7 +112,7 @@ static inline void setup_stack_canary_segment(int cpu)
17628
17629 static inline void load_stack_canary_segment(void)
17630 {
17631 -#ifdef CONFIG_X86_32
17632 +#if defined(CONFIG_X86_32) && !defined(CONFIG_PAX_MEMORY_UDEREF)
17633 asm volatile ("mov %0, %%gs" : : "r" (0));
17634 #endif
17635 }
17636 diff --git a/arch/x86/include/asm/stacktrace.h b/arch/x86/include/asm/stacktrace.h
17637 index 70bbe39..4ae2bd4 100644
17638 --- a/arch/x86/include/asm/stacktrace.h
17639 +++ b/arch/x86/include/asm/stacktrace.h
17640 @@ -11,28 +11,20 @@
17641
17642 extern int kstack_depth_to_print;
17643
17644 -struct thread_info;
17645 +struct task_struct;
17646 struct stacktrace_ops;
17647
17648 -typedef unsigned long (*walk_stack_t)(struct thread_info *tinfo,
17649 - unsigned long *stack,
17650 - unsigned long bp,
17651 - const struct stacktrace_ops *ops,
17652 - void *data,
17653 - unsigned long *end,
17654 - int *graph);
17655 +typedef unsigned long walk_stack_t(struct task_struct *task,
17656 + void *stack_start,
17657 + unsigned long *stack,
17658 + unsigned long bp,
17659 + const struct stacktrace_ops *ops,
17660 + void *data,
17661 + unsigned long *end,
17662 + int *graph);
17663
17664 -extern unsigned long
17665 -print_context_stack(struct thread_info *tinfo,
17666 - unsigned long *stack, unsigned long bp,
17667 - const struct stacktrace_ops *ops, void *data,
17668 - unsigned long *end, int *graph);
17669 -
17670 -extern unsigned long
17671 -print_context_stack_bp(struct thread_info *tinfo,
17672 - unsigned long *stack, unsigned long bp,
17673 - const struct stacktrace_ops *ops, void *data,
17674 - unsigned long *end, int *graph);
17675 +extern walk_stack_t print_context_stack;
17676 +extern walk_stack_t print_context_stack_bp;
17677
17678 /* Generic stack tracer with callbacks */
17679
17680 @@ -40,7 +32,7 @@ struct stacktrace_ops {
17681 void (*address)(void *data, unsigned long address, int reliable);
17682 /* On negative return stop dumping */
17683 int (*stack)(void *data, char *name);
17684 - walk_stack_t walk_stack;
17685 + walk_stack_t *walk_stack;
17686 };
17687
17688 void dump_trace(struct task_struct *tsk, struct pt_regs *regs,
17689 diff --git a/arch/x86/include/asm/switch_to.h b/arch/x86/include/asm/switch_to.h
17690 index d7f3b3b..3cc39f1 100644
17691 --- a/arch/x86/include/asm/switch_to.h
17692 +++ b/arch/x86/include/asm/switch_to.h
17693 @@ -108,7 +108,7 @@ do { \
17694 "call __switch_to\n\t" \
17695 "movq "__percpu_arg([current_task])",%%rsi\n\t" \
17696 __switch_canary \
17697 - "movq %P[thread_info](%%rsi),%%r8\n\t" \
17698 + "movq "__percpu_arg([thread_info])",%%r8\n\t" \
17699 "movq %%rax,%%rdi\n\t" \
17700 "testl %[_tif_fork],%P[ti_flags](%%r8)\n\t" \
17701 "jnz ret_from_fork\n\t" \
17702 @@ -119,7 +119,7 @@ do { \
17703 [threadrsp] "i" (offsetof(struct task_struct, thread.sp)), \
17704 [ti_flags] "i" (offsetof(struct thread_info, flags)), \
17705 [_tif_fork] "i" (_TIF_FORK), \
17706 - [thread_info] "i" (offsetof(struct task_struct, stack)), \
17707 + [thread_info] "m" (current_tinfo), \
17708 [current_task] "m" (current_task) \
17709 __switch_canary_iparam \
17710 : "memory", "cc" __EXTRA_CLOBBER)
17711 diff --git a/arch/x86/include/asm/thread_info.h b/arch/x86/include/asm/thread_info.h
17712 index 2781119..618b59b 100644
17713 --- a/arch/x86/include/asm/thread_info.h
17714 +++ b/arch/x86/include/asm/thread_info.h
17715 @@ -10,6 +10,7 @@
17716 #include <linux/compiler.h>
17717 #include <asm/page.h>
17718 #include <asm/types.h>
17719 +#include <asm/percpu.h>
17720
17721 /*
17722 * low level task data that entry.S needs immediate access to
17723 @@ -23,7 +24,6 @@ struct exec_domain;
17724 #include <linux/atomic.h>
17725
17726 struct thread_info {
17727 - struct task_struct *task; /* main task structure */
17728 struct exec_domain *exec_domain; /* execution domain */
17729 __u32 flags; /* low level flags */
17730 __u32 status; /* thread synchronous flags */
17731 @@ -33,19 +33,13 @@ struct thread_info {
17732 mm_segment_t addr_limit;
17733 struct restart_block restart_block;
17734 void __user *sysenter_return;
17735 -#ifdef CONFIG_X86_32
17736 - unsigned long previous_esp; /* ESP of the previous stack in
17737 - case of nested (IRQ) stacks
17738 - */
17739 - __u8 supervisor_stack[0];
17740 -#endif
17741 + unsigned long lowest_stack;
17742 unsigned int sig_on_uaccess_error:1;
17743 unsigned int uaccess_err:1; /* uaccess failed */
17744 };
17745
17746 -#define INIT_THREAD_INFO(tsk) \
17747 +#define INIT_THREAD_INFO \
17748 { \
17749 - .task = &tsk, \
17750 .exec_domain = &default_exec_domain, \
17751 .flags = 0, \
17752 .cpu = 0, \
17753 @@ -56,7 +50,7 @@ struct thread_info {
17754 }, \
17755 }
17756
17757 -#define init_thread_info (init_thread_union.thread_info)
17758 +#define init_thread_info (init_thread_union.stack)
17759 #define init_stack (init_thread_union.stack)
17760
17761 #else /* !__ASSEMBLY__ */
17762 @@ -96,6 +90,7 @@ struct thread_info {
17763 #define TIF_SYSCALL_TRACEPOINT 28 /* syscall tracepoint instrumentation */
17764 #define TIF_ADDR32 29 /* 32-bit address space on 64 bits */
17765 #define TIF_X32 30 /* 32-bit native x86-64 binary */
17766 +#define TIF_GRSEC_SETXID 31 /* update credentials on syscall entry/exit */
17767
17768 #define _TIF_SYSCALL_TRACE (1 << TIF_SYSCALL_TRACE)
17769 #define _TIF_NOTIFY_RESUME (1 << TIF_NOTIFY_RESUME)
17770 @@ -119,17 +114,18 @@ struct thread_info {
17771 #define _TIF_SYSCALL_TRACEPOINT (1 << TIF_SYSCALL_TRACEPOINT)
17772 #define _TIF_ADDR32 (1 << TIF_ADDR32)
17773 #define _TIF_X32 (1 << TIF_X32)
17774 +#define _TIF_GRSEC_SETXID (1 << TIF_GRSEC_SETXID)
17775
17776 /* work to do in syscall_trace_enter() */
17777 #define _TIF_WORK_SYSCALL_ENTRY \
17778 (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_EMU | _TIF_SYSCALL_AUDIT | \
17779 _TIF_SECCOMP | _TIF_SINGLESTEP | _TIF_SYSCALL_TRACEPOINT | \
17780 - _TIF_NOHZ)
17781 + _TIF_NOHZ | _TIF_GRSEC_SETXID)
17782
17783 /* work to do in syscall_trace_leave() */
17784 #define _TIF_WORK_SYSCALL_EXIT \
17785 (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | _TIF_SINGLESTEP | \
17786 - _TIF_SYSCALL_TRACEPOINT | _TIF_NOHZ)
17787 + _TIF_SYSCALL_TRACEPOINT | _TIF_NOHZ | _TIF_GRSEC_SETXID)
17788
17789 /* work to do on interrupt/exception return */
17790 #define _TIF_WORK_MASK \
17791 @@ -140,7 +136,7 @@ struct thread_info {
17792 /* work to do on any return to user space */
17793 #define _TIF_ALLWORK_MASK \
17794 ((0x0000FFFF & ~_TIF_SECCOMP) | _TIF_SYSCALL_TRACEPOINT | \
17795 - _TIF_NOHZ)
17796 + _TIF_NOHZ | _TIF_GRSEC_SETXID)
17797
17798 /* Only used for 64 bit */
17799 #define _TIF_DO_NOTIFY_MASK \
17800 @@ -156,45 +152,40 @@ struct thread_info {
17801
17802 #define PREEMPT_ACTIVE 0x10000000
17803
17804 -#ifdef CONFIG_X86_32
17805 -
17806 -#define STACK_WARN (THREAD_SIZE/8)
17807 -/*
17808 - * macros/functions for gaining access to the thread information structure
17809 - *
17810 - * preempt_count needs to be 1 initially, until the scheduler is functional.
17811 - */
17812 -#ifndef __ASSEMBLY__
17813 -
17814 -
17815 -/* how to get the current stack pointer from C */
17816 -register unsigned long current_stack_pointer asm("esp") __used;
17817 -
17818 -/* how to get the thread information struct from C */
17819 -static inline struct thread_info *current_thread_info(void)
17820 -{
17821 - return (struct thread_info *)
17822 - (current_stack_pointer & ~(THREAD_SIZE - 1));
17823 -}
17824 -
17825 -#else /* !__ASSEMBLY__ */
17826 -
17827 +#ifdef __ASSEMBLY__
17828 /* how to get the thread information struct from ASM */
17829 #define GET_THREAD_INFO(reg) \
17830 - movl $-THREAD_SIZE, reg; \
17831 - andl %esp, reg
17832 + mov PER_CPU_VAR(current_tinfo), reg
17833
17834 /* use this one if reg already contains %esp */
17835 -#define GET_THREAD_INFO_WITH_ESP(reg) \
17836 - andl $-THREAD_SIZE, reg
17837 +#define GET_THREAD_INFO_WITH_ESP(reg) GET_THREAD_INFO(reg)
17838 +#else
17839 +/* how to get the thread information struct from C */
17840 +DECLARE_PER_CPU(struct thread_info *, current_tinfo);
17841 +
17842 +static __always_inline struct thread_info *current_thread_info(void)
17843 +{
17844 + return this_cpu_read_stable(current_tinfo);
17845 +}
17846 +#endif
17847 +
17848 +#ifdef CONFIG_X86_32
17849 +
17850 +#define STACK_WARN (THREAD_SIZE/8)
17851 +/*
17852 + * macros/functions for gaining access to the thread information structure
17853 + *
17854 + * preempt_count needs to be 1 initially, until the scheduler is functional.
17855 + */
17856 +#ifndef __ASSEMBLY__
17857 +
17858 +/* how to get the current stack pointer from C */
17859 +register unsigned long current_stack_pointer asm("esp") __used;
17860
17861 #endif
17862
17863 #else /* X86_32 */
17864
17865 -#include <asm/percpu.h>
17866 -#define KERNEL_STACK_OFFSET (5*8)
17867 -
17868 /*
17869 * macros/functions for gaining access to the thread information structure
17870 * preempt_count needs to be 1 initially, until the scheduler is functional.
17871 @@ -202,27 +193,8 @@ static inline struct thread_info *current_thread_info(void)
17872 #ifndef __ASSEMBLY__
17873 DECLARE_PER_CPU(unsigned long, kernel_stack);
17874
17875 -static inline struct thread_info *current_thread_info(void)
17876 -{
17877 - struct thread_info *ti;
17878 - ti = (void *)(this_cpu_read_stable(kernel_stack) +
17879 - KERNEL_STACK_OFFSET - THREAD_SIZE);
17880 - return ti;
17881 -}
17882 -
17883 -#else /* !__ASSEMBLY__ */
17884 -
17885 -/* how to get the thread information struct from ASM */
17886 -#define GET_THREAD_INFO(reg) \
17887 - movq PER_CPU_VAR(kernel_stack),reg ; \
17888 - subq $(THREAD_SIZE-KERNEL_STACK_OFFSET),reg
17889 -
17890 -/*
17891 - * Same if PER_CPU_VAR(kernel_stack) is, perhaps with some offset, already in
17892 - * a certain register (to be used in assembler memory operands).
17893 - */
17894 -#define THREAD_INFO(reg, off) KERNEL_STACK_OFFSET+(off)-THREAD_SIZE(reg)
17895 -
17896 +/* how to get the current stack pointer from C */
17897 +register unsigned long current_stack_pointer asm("rsp") __used;
17898 #endif
17899
17900 #endif /* !X86_32 */
17901 @@ -281,5 +253,12 @@ static inline bool is_ia32_task(void)
17902 extern void arch_task_cache_init(void);
17903 extern int arch_dup_task_struct(struct task_struct *dst, struct task_struct *src);
17904 extern void arch_release_task_struct(struct task_struct *tsk);
17905 +
17906 +#define __HAVE_THREAD_FUNCTIONS
17907 +#define task_thread_info(task) (&(task)->tinfo)
17908 +#define task_stack_page(task) ((task)->stack)
17909 +#define setup_thread_stack(p, org) do {} while (0)
17910 +#define end_of_stack(p) ((unsigned long *)task_stack_page(p) + 1)
17911 +
17912 #endif
17913 #endif /* _ASM_X86_THREAD_INFO_H */
17914 diff --git a/arch/x86/include/asm/tlbflush.h b/arch/x86/include/asm/tlbflush.h
17915 index e6d90ba..0897f44 100644
17916 --- a/arch/x86/include/asm/tlbflush.h
17917 +++ b/arch/x86/include/asm/tlbflush.h
17918 @@ -17,18 +17,44 @@
17919
17920 static inline void __native_flush_tlb(void)
17921 {
17922 + if (static_cpu_has(X86_FEATURE_INVPCID)) {
17923 + u64 descriptor[2];
17924 +
17925 + descriptor[0] = PCID_KERNEL;
17926 + asm volatile(__ASM_INVPCID : : "d"(&descriptor), "a"(INVPCID_ALL_MONGLOBAL) : "memory");
17927 + return;
17928 + }
17929 +
17930 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
17931 + if (static_cpu_has(X86_FEATURE_PCID)) {
17932 + unsigned int cpu = raw_get_cpu();
17933 +
17934 + native_write_cr3(__pa(get_cpu_pgd(cpu, user)) | PCID_USER);
17935 + native_write_cr3(__pa(get_cpu_pgd(cpu, kernel)) | PCID_KERNEL);
17936 + raw_put_cpu_no_resched();
17937 + return;
17938 + }
17939 +#endif
17940 +
17941 native_write_cr3(native_read_cr3());
17942 }
17943
17944 static inline void __native_flush_tlb_global_irq_disabled(void)
17945 {
17946 - unsigned long cr4;
17947 + if (static_cpu_has(X86_FEATURE_INVPCID)) {
17948 + u64 descriptor[2];
17949
17950 - cr4 = native_read_cr4();
17951 - /* clear PGE */
17952 - native_write_cr4(cr4 & ~X86_CR4_PGE);
17953 - /* write old PGE again and flush TLBs */
17954 - native_write_cr4(cr4);
17955 + descriptor[0] = PCID_KERNEL;
17956 + asm volatile(__ASM_INVPCID : : "d"(&descriptor), "a"(INVPCID_ALL_GLOBAL) : "memory");
17957 + } else {
17958 + unsigned long cr4;
17959 +
17960 + cr4 = native_read_cr4();
17961 + /* clear PGE */
17962 + native_write_cr4(cr4 & ~X86_CR4_PGE);
17963 + /* write old PGE again and flush TLBs */
17964 + native_write_cr4(cr4);
17965 + }
17966 }
17967
17968 static inline void __native_flush_tlb_global(void)
17969 @@ -49,6 +75,42 @@ static inline void __native_flush_tlb_global(void)
17970
17971 static inline void __native_flush_tlb_single(unsigned long addr)
17972 {
17973 +
17974 + if (static_cpu_has(X86_FEATURE_INVPCID)) {
17975 + u64 descriptor[2];
17976 +
17977 + descriptor[0] = PCID_KERNEL;
17978 + descriptor[1] = addr;
17979 +
17980 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
17981 + if (!static_cpu_has(X86_FEATURE_STRONGUDEREF) || addr >= TASK_SIZE_MAX) {
17982 + if (addr < TASK_SIZE_MAX)
17983 + descriptor[1] += pax_user_shadow_base;
17984 + asm volatile(__ASM_INVPCID : : "d"(&descriptor), "a"(INVPCID_SINGLE_ADDRESS) : "memory");
17985 + }
17986 +
17987 + descriptor[0] = PCID_USER;
17988 + descriptor[1] = addr;
17989 +#endif
17990 +
17991 + asm volatile(__ASM_INVPCID : : "d"(&descriptor), "a"(INVPCID_SINGLE_ADDRESS) : "memory");
17992 + return;
17993 + }
17994 +
17995 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
17996 + if (static_cpu_has(X86_FEATURE_PCID)) {
17997 + unsigned int cpu = raw_get_cpu();
17998 +
17999 + native_write_cr3(__pa(get_cpu_pgd(cpu, user)) | PCID_USER | PCID_NOFLUSH);
18000 + asm volatile("invlpg (%0)" ::"r" (addr) : "memory");
18001 + native_write_cr3(__pa(get_cpu_pgd(cpu, kernel)) | PCID_KERNEL | PCID_NOFLUSH);
18002 + raw_put_cpu_no_resched();
18003 +
18004 + if (!static_cpu_has(X86_FEATURE_STRONGUDEREF) && addr < TASK_SIZE_MAX)
18005 + addr += pax_user_shadow_base;
18006 + }
18007 +#endif
18008 +
18009 asm volatile("invlpg (%0)" ::"r" (addr) : "memory");
18010 }
18011
18012 diff --git a/arch/x86/include/asm/uaccess.h b/arch/x86/include/asm/uaccess.h
18013 index 5838fa9..f7ae572 100644
18014 --- a/arch/x86/include/asm/uaccess.h
18015 +++ b/arch/x86/include/asm/uaccess.h
18016 @@ -7,6 +7,7 @@
18017 #include <linux/compiler.h>
18018 #include <linux/thread_info.h>
18019 #include <linux/string.h>
18020 +#include <linux/sched.h>
18021 #include <asm/asm.h>
18022 #include <asm/page.h>
18023 #include <asm/smap.h>
18024 @@ -29,7 +30,12 @@
18025
18026 #define get_ds() (KERNEL_DS)
18027 #define get_fs() (current_thread_info()->addr_limit)
18028 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_MEMORY_UDEREF)
18029 +void __set_fs(mm_segment_t x);
18030 +void set_fs(mm_segment_t x);
18031 +#else
18032 #define set_fs(x) (current_thread_info()->addr_limit = (x))
18033 +#endif
18034
18035 #define segment_eq(a, b) ((a).seg == (b).seg)
18036
18037 @@ -77,8 +83,33 @@
18038 * checks that the pointer is in the user space range - after calling
18039 * this function, memory access functions may still return -EFAULT.
18040 */
18041 -#define access_ok(type, addr, size) \
18042 - (likely(__range_not_ok(addr, size, user_addr_max()) == 0))
18043 +#define __access_ok(type, addr, size) (likely(__range_not_ok(addr, size, user_addr_max()) == 0))
18044 +#define access_ok(type, addr, size) \
18045 +({ \
18046 + long __size = size; \
18047 + unsigned long __addr = (unsigned long)addr; \
18048 + unsigned long __addr_ao = __addr & PAGE_MASK; \
18049 + unsigned long __end_ao = __addr + __size - 1; \
18050 + bool __ret_ao = __range_not_ok(__addr, __size, user_addr_max()) == 0;\
18051 + if (__ret_ao && unlikely((__end_ao ^ __addr_ao) & PAGE_MASK)) { \
18052 + while(__addr_ao <= __end_ao) { \
18053 + char __c_ao; \
18054 + __addr_ao += PAGE_SIZE; \
18055 + if (__size > PAGE_SIZE) \
18056 + cond_resched(); \
18057 + if (__get_user(__c_ao, (char __user *)__addr)) \
18058 + break; \
18059 + if (type != VERIFY_WRITE) { \
18060 + __addr = __addr_ao; \
18061 + continue; \
18062 + } \
18063 + if (__put_user(__c_ao, (char __user *)__addr)) \
18064 + break; \
18065 + __addr = __addr_ao; \
18066 + } \
18067 + } \
18068 + __ret_ao; \
18069 +})
18070
18071 /*
18072 * The exception table consists of pairs of addresses relative to the
18073 @@ -168,10 +199,12 @@ __typeof__(__builtin_choose_expr(sizeof(x) > sizeof(0UL), 0ULL, 0UL))
18074 register __inttype(*(ptr)) __val_gu asm("%"_ASM_DX); \
18075 __chk_user_ptr(ptr); \
18076 might_fault(); \
18077 + pax_open_userland(); \
18078 asm volatile("call __get_user_%P3" \
18079 : "=a" (__ret_gu), "=r" (__val_gu) \
18080 : "0" (ptr), "i" (sizeof(*(ptr)))); \
18081 (x) = (__typeof__(*(ptr))) __val_gu; \
18082 + pax_close_userland(); \
18083 __ret_gu; \
18084 })
18085
18086 @@ -179,13 +212,21 @@ __typeof__(__builtin_choose_expr(sizeof(x) > sizeof(0UL), 0ULL, 0UL))
18087 asm volatile("call __put_user_" #size : "=a" (__ret_pu) \
18088 : "0" ((typeof(*(ptr)))(x)), "c" (ptr) : "ebx")
18089
18090 -
18091 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_MEMORY_UDEREF)
18092 +#define __copyuser_seg "gs;"
18093 +#define __COPYUSER_SET_ES "pushl %%gs; popl %%es\n"
18094 +#define __COPYUSER_RESTORE_ES "pushl %%ss; popl %%es\n"
18095 +#else
18096 +#define __copyuser_seg
18097 +#define __COPYUSER_SET_ES
18098 +#define __COPYUSER_RESTORE_ES
18099 +#endif
18100
18101 #ifdef CONFIG_X86_32
18102 #define __put_user_asm_u64(x, addr, err, errret) \
18103 asm volatile(ASM_STAC "\n" \
18104 - "1: movl %%eax,0(%2)\n" \
18105 - "2: movl %%edx,4(%2)\n" \
18106 + "1: "__copyuser_seg"movl %%eax,0(%2)\n" \
18107 + "2: "__copyuser_seg"movl %%edx,4(%2)\n" \
18108 "3: " ASM_CLAC "\n" \
18109 ".section .fixup,\"ax\"\n" \
18110 "4: movl %3,%0\n" \
18111 @@ -198,8 +239,8 @@ __typeof__(__builtin_choose_expr(sizeof(x) > sizeof(0UL), 0ULL, 0UL))
18112
18113 #define __put_user_asm_ex_u64(x, addr) \
18114 asm volatile(ASM_STAC "\n" \
18115 - "1: movl %%eax,0(%1)\n" \
18116 - "2: movl %%edx,4(%1)\n" \
18117 + "1: "__copyuser_seg"movl %%eax,0(%1)\n" \
18118 + "2: "__copyuser_seg"movl %%edx,4(%1)\n" \
18119 "3: " ASM_CLAC "\n" \
18120 _ASM_EXTABLE_EX(1b, 2b) \
18121 _ASM_EXTABLE_EX(2b, 3b) \
18122 @@ -249,7 +290,8 @@ extern void __put_user_8(void);
18123 __typeof__(*(ptr)) __pu_val; \
18124 __chk_user_ptr(ptr); \
18125 might_fault(); \
18126 - __pu_val = x; \
18127 + __pu_val = (x); \
18128 + pax_open_userland(); \
18129 switch (sizeof(*(ptr))) { \
18130 case 1: \
18131 __put_user_x(1, __pu_val, ptr, __ret_pu); \
18132 @@ -267,6 +309,7 @@ extern void __put_user_8(void);
18133 __put_user_x(X, __pu_val, ptr, __ret_pu); \
18134 break; \
18135 } \
18136 + pax_close_userland(); \
18137 __ret_pu; \
18138 })
18139
18140 @@ -347,8 +390,10 @@ do { \
18141 } while (0)
18142
18143 #define __get_user_asm(x, addr, err, itype, rtype, ltype, errret) \
18144 +do { \
18145 + pax_open_userland(); \
18146 asm volatile(ASM_STAC "\n" \
18147 - "1: mov"itype" %2,%"rtype"1\n" \
18148 + "1: "__copyuser_seg"mov"itype" %2,%"rtype"1\n"\
18149 "2: " ASM_CLAC "\n" \
18150 ".section .fixup,\"ax\"\n" \
18151 "3: mov %3,%0\n" \
18152 @@ -356,8 +401,10 @@ do { \
18153 " jmp 2b\n" \
18154 ".previous\n" \
18155 _ASM_EXTABLE(1b, 3b) \
18156 - : "=r" (err), ltype(x) \
18157 - : "m" (__m(addr)), "i" (errret), "0" (err))
18158 + : "=r" (err), ltype (x) \
18159 + : "m" (__m(addr)), "i" (errret), "0" (err)); \
18160 + pax_close_userland(); \
18161 +} while (0)
18162
18163 #define __get_user_size_ex(x, ptr, size) \
18164 do { \
18165 @@ -381,7 +428,7 @@ do { \
18166 } while (0)
18167
18168 #define __get_user_asm_ex(x, addr, itype, rtype, ltype) \
18169 - asm volatile("1: mov"itype" %1,%"rtype"0\n" \
18170 + asm volatile("1: "__copyuser_seg"mov"itype" %1,%"rtype"0\n"\
18171 "2:\n" \
18172 _ASM_EXTABLE_EX(1b, 2b) \
18173 : ltype(x) : "m" (__m(addr)))
18174 @@ -398,13 +445,24 @@ do { \
18175 int __gu_err; \
18176 unsigned long __gu_val; \
18177 __get_user_size(__gu_val, (ptr), (size), __gu_err, -EFAULT); \
18178 - (x) = (__force __typeof__(*(ptr)))__gu_val; \
18179 + (x) = (__typeof__(*(ptr)))__gu_val; \
18180 __gu_err; \
18181 })
18182
18183 /* FIXME: this hack is definitely wrong -AK */
18184 struct __large_struct { unsigned long buf[100]; };
18185 -#define __m(x) (*(struct __large_struct __user *)(x))
18186 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
18187 +#define ____m(x) \
18188 +({ \
18189 + unsigned long ____x = (unsigned long)(x); \
18190 + if (____x < pax_user_shadow_base) \
18191 + ____x += pax_user_shadow_base; \
18192 + (typeof(x))____x; \
18193 +})
18194 +#else
18195 +#define ____m(x) (x)
18196 +#endif
18197 +#define __m(x) (*(struct __large_struct __user *)____m(x))
18198
18199 /*
18200 * Tell gcc we read from memory instead of writing: this is because
18201 @@ -412,8 +470,10 @@ struct __large_struct { unsigned long buf[100]; };
18202 * aliasing issues.
18203 */
18204 #define __put_user_asm(x, addr, err, itype, rtype, ltype, errret) \
18205 +do { \
18206 + pax_open_userland(); \
18207 asm volatile(ASM_STAC "\n" \
18208 - "1: mov"itype" %"rtype"1,%2\n" \
18209 + "1: "__copyuser_seg"mov"itype" %"rtype"1,%2\n"\
18210 "2: " ASM_CLAC "\n" \
18211 ".section .fixup,\"ax\"\n" \
18212 "3: mov %3,%0\n" \
18213 @@ -421,10 +481,12 @@ struct __large_struct { unsigned long buf[100]; };
18214 ".previous\n" \
18215 _ASM_EXTABLE(1b, 3b) \
18216 : "=r"(err) \
18217 - : ltype(x), "m" (__m(addr)), "i" (errret), "0" (err))
18218 + : ltype (x), "m" (__m(addr)), "i" (errret), "0" (err));\
18219 + pax_close_userland(); \
18220 +} while (0)
18221
18222 #define __put_user_asm_ex(x, addr, itype, rtype, ltype) \
18223 - asm volatile("1: mov"itype" %"rtype"0,%1\n" \
18224 + asm volatile("1: "__copyuser_seg"mov"itype" %"rtype"0,%1\n"\
18225 "2:\n" \
18226 _ASM_EXTABLE_EX(1b, 2b) \
18227 : : ltype(x), "m" (__m(addr)))
18228 @@ -434,11 +496,13 @@ struct __large_struct { unsigned long buf[100]; };
18229 */
18230 #define uaccess_try do { \
18231 current_thread_info()->uaccess_err = 0; \
18232 + pax_open_userland(); \
18233 stac(); \
18234 barrier();
18235
18236 #define uaccess_catch(err) \
18237 clac(); \
18238 + pax_close_userland(); \
18239 (err) |= (current_thread_info()->uaccess_err ? -EFAULT : 0); \
18240 } while (0)
18241
18242 @@ -463,8 +527,12 @@ struct __large_struct { unsigned long buf[100]; };
18243 * On error, the variable @x is set to zero.
18244 */
18245
18246 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
18247 +#define __get_user(x, ptr) get_user((x), (ptr))
18248 +#else
18249 #define __get_user(x, ptr) \
18250 __get_user_nocheck((x), (ptr), sizeof(*(ptr)))
18251 +#endif
18252
18253 /**
18254 * __put_user: - Write a simple value into user space, with less checking.
18255 @@ -486,8 +554,12 @@ struct __large_struct { unsigned long buf[100]; };
18256 * Returns zero on success, or -EFAULT on error.
18257 */
18258
18259 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
18260 +#define __put_user(x, ptr) put_user((x), (ptr))
18261 +#else
18262 #define __put_user(x, ptr) \
18263 __put_user_nocheck((__typeof__(*(ptr)))(x), (ptr), sizeof(*(ptr)))
18264 +#endif
18265
18266 #define __get_user_unaligned __get_user
18267 #define __put_user_unaligned __put_user
18268 @@ -505,7 +577,7 @@ struct __large_struct { unsigned long buf[100]; };
18269 #define get_user_ex(x, ptr) do { \
18270 unsigned long __gue_val; \
18271 __get_user_size_ex((__gue_val), (ptr), (sizeof(*(ptr)))); \
18272 - (x) = (__force __typeof__(*(ptr)))__gue_val; \
18273 + (x) = (__typeof__(*(ptr)))__gue_val; \
18274 } while (0)
18275
18276 #define put_user_try uaccess_try
18277 diff --git a/arch/x86/include/asm/uaccess_32.h b/arch/x86/include/asm/uaccess_32.h
18278 index 7f760a9..b596b9a 100644
18279 --- a/arch/x86/include/asm/uaccess_32.h
18280 +++ b/arch/x86/include/asm/uaccess_32.h
18281 @@ -43,6 +43,11 @@ unsigned long __must_check __copy_from_user_ll_nocache_nozero
18282 static __always_inline unsigned long __must_check
18283 __copy_to_user_inatomic(void __user *to, const void *from, unsigned long n)
18284 {
18285 + if ((long)n < 0)
18286 + return n;
18287 +
18288 + check_object_size(from, n, true);
18289 +
18290 if (__builtin_constant_p(n)) {
18291 unsigned long ret;
18292
18293 @@ -82,12 +87,16 @@ static __always_inline unsigned long __must_check
18294 __copy_to_user(void __user *to, const void *from, unsigned long n)
18295 {
18296 might_fault();
18297 +
18298 return __copy_to_user_inatomic(to, from, n);
18299 }
18300
18301 static __always_inline unsigned long
18302 __copy_from_user_inatomic(void *to, const void __user *from, unsigned long n)
18303 {
18304 + if ((long)n < 0)
18305 + return n;
18306 +
18307 /* Avoid zeroing the tail if the copy fails..
18308 * If 'n' is constant and 1, 2, or 4, we do still zero on a failure,
18309 * but as the zeroing behaviour is only significant when n is not
18310 @@ -137,6 +146,12 @@ static __always_inline unsigned long
18311 __copy_from_user(void *to, const void __user *from, unsigned long n)
18312 {
18313 might_fault();
18314 +
18315 + if ((long)n < 0)
18316 + return n;
18317 +
18318 + check_object_size(to, n, false);
18319 +
18320 if (__builtin_constant_p(n)) {
18321 unsigned long ret;
18322
18323 @@ -159,6 +174,10 @@ static __always_inline unsigned long __copy_from_user_nocache(void *to,
18324 const void __user *from, unsigned long n)
18325 {
18326 might_fault();
18327 +
18328 + if ((long)n < 0)
18329 + return n;
18330 +
18331 if (__builtin_constant_p(n)) {
18332 unsigned long ret;
18333
18334 @@ -181,15 +200,19 @@ static __always_inline unsigned long
18335 __copy_from_user_inatomic_nocache(void *to, const void __user *from,
18336 unsigned long n)
18337 {
18338 - return __copy_from_user_ll_nocache_nozero(to, from, n);
18339 + if ((long)n < 0)
18340 + return n;
18341 +
18342 + return __copy_from_user_ll_nocache_nozero(to, from, n);
18343 }
18344
18345 -unsigned long __must_check copy_to_user(void __user *to,
18346 - const void *from, unsigned long n);
18347 -unsigned long __must_check _copy_from_user(void *to,
18348 - const void __user *from,
18349 - unsigned long n);
18350 -
18351 +extern void copy_to_user_overflow(void)
18352 +#ifdef CONFIG_DEBUG_STRICT_USER_COPY_CHECKS
18353 + __compiletime_error("copy_to_user() buffer size is not provably correct")
18354 +#else
18355 + __compiletime_warning("copy_to_user() buffer size is not provably correct")
18356 +#endif
18357 +;
18358
18359 extern void copy_from_user_overflow(void)
18360 #ifdef CONFIG_DEBUG_STRICT_USER_COPY_CHECKS
18361 @@ -199,17 +222,60 @@ extern void copy_from_user_overflow(void)
18362 #endif
18363 ;
18364
18365 -static inline unsigned long __must_check copy_from_user(void *to,
18366 - const void __user *from,
18367 - unsigned long n)
18368 +/**
18369 + * copy_to_user: - Copy a block of data into user space.
18370 + * @to: Destination address, in user space.
18371 + * @from: Source address, in kernel space.
18372 + * @n: Number of bytes to copy.
18373 + *
18374 + * Context: User context only. This function may sleep.
18375 + *
18376 + * Copy data from kernel space to user space.
18377 + *
18378 + * Returns number of bytes that could not be copied.
18379 + * On success, this will be zero.
18380 + */
18381 +static inline unsigned long __must_check
18382 +copy_to_user(void __user *to, const void *from, unsigned long n)
18383 {
18384 - int sz = __compiletime_object_size(to);
18385 + size_t sz = __compiletime_object_size(from);
18386
18387 - if (likely(sz == -1 || sz >= n))
18388 - n = _copy_from_user(to, from, n);
18389 - else
18390 + if (unlikely(sz != (size_t)-1 && sz < n))
18391 + copy_to_user_overflow();
18392 + else if (access_ok(VERIFY_WRITE, to, n))
18393 + n = __copy_to_user(to, from, n);
18394 + return n;
18395 +}
18396 +
18397 +/**
18398 + * copy_from_user: - Copy a block of data from user space.
18399 + * @to: Destination address, in kernel space.
18400 + * @from: Source address, in user space.
18401 + * @n: Number of bytes to copy.
18402 + *
18403 + * Context: User context only. This function may sleep.
18404 + *
18405 + * Copy data from user space to kernel space.
18406 + *
18407 + * Returns number of bytes that could not be copied.
18408 + * On success, this will be zero.
18409 + *
18410 + * If some data could not be copied, this function will pad the copied
18411 + * data to the requested size using zero bytes.
18412 + */
18413 +static inline unsigned long __must_check
18414 +copy_from_user(void *to, const void __user *from, unsigned long n)
18415 +{
18416 + size_t sz = __compiletime_object_size(to);
18417 +
18418 + check_object_size(to, n, false);
18419 +
18420 + if (unlikely(sz != (size_t)-1 && sz < n))
18421 copy_from_user_overflow();
18422 -
18423 + else if (access_ok(VERIFY_READ, from, n))
18424 + n = __copy_from_user(to, from, n);
18425 + else if ((long)n > 0)
18426 + memset(to, 0, n);
18427 return n;
18428 }
18429
18430 diff --git a/arch/x86/include/asm/uaccess_64.h b/arch/x86/include/asm/uaccess_64.h
18431 index 4f7923d..201b58d 100644
18432 --- a/arch/x86/include/asm/uaccess_64.h
18433 +++ b/arch/x86/include/asm/uaccess_64.h
18434 @@ -10,6 +10,9 @@
18435 #include <asm/alternative.h>
18436 #include <asm/cpufeature.h>
18437 #include <asm/page.h>
18438 +#include <asm/pgtable.h>
18439 +
18440 +#define set_fs(x) (current_thread_info()->addr_limit = (x))
18441
18442 /*
18443 * Copy To/From Userspace
18444 @@ -17,14 +20,14 @@
18445
18446 /* Handles exceptions in both to and from, but doesn't do access_ok */
18447 __must_check unsigned long
18448 -copy_user_enhanced_fast_string(void *to, const void *from, unsigned len);
18449 +copy_user_enhanced_fast_string(void *to, const void *from, unsigned len) __size_overflow(3);
18450 __must_check unsigned long
18451 -copy_user_generic_string(void *to, const void *from, unsigned len);
18452 +copy_user_generic_string(void *to, const void *from, unsigned len) __size_overflow(3);
18453 __must_check unsigned long
18454 -copy_user_generic_unrolled(void *to, const void *from, unsigned len);
18455 +copy_user_generic_unrolled(void *to, const void *from, unsigned len) __size_overflow(3);
18456
18457 -static __always_inline __must_check unsigned long
18458 -copy_user_generic(void *to, const void *from, unsigned len)
18459 +static __always_inline __must_check unsigned long
18460 +copy_user_generic(void *to, const void *from, unsigned long len)
18461 {
18462 unsigned ret;
18463
18464 @@ -45,138 +48,200 @@ copy_user_generic(void *to, const void *from, unsigned len)
18465 return ret;
18466 }
18467
18468 +static __always_inline __must_check unsigned long
18469 +__copy_to_user(void __user *to, const void *from, unsigned long len);
18470 +static __always_inline __must_check unsigned long
18471 +__copy_from_user(void *to, const void __user *from, unsigned long len);
18472 __must_check unsigned long
18473 -_copy_to_user(void __user *to, const void *from, unsigned len);
18474 -__must_check unsigned long
18475 -_copy_from_user(void *to, const void __user *from, unsigned len);
18476 -__must_check unsigned long
18477 -copy_in_user(void __user *to, const void __user *from, unsigned len);
18478 +copy_in_user(void __user *to, const void __user *from, unsigned long len);
18479 +
18480 +extern void copy_to_user_overflow(void)
18481 +#ifdef CONFIG_DEBUG_STRICT_USER_COPY_CHECKS
18482 + __compiletime_error("copy_to_user() buffer size is not provably correct")
18483 +#else
18484 + __compiletime_warning("copy_to_user() buffer size is not provably correct")
18485 +#endif
18486 +;
18487 +
18488 +extern void copy_from_user_overflow(void)
18489 +#ifdef CONFIG_DEBUG_STRICT_USER_COPY_CHECKS
18490 + __compiletime_error("copy_from_user() buffer size is not provably correct")
18491 +#else
18492 + __compiletime_warning("copy_from_user() buffer size is not provably correct")
18493 +#endif
18494 +;
18495
18496 static inline unsigned long __must_check copy_from_user(void *to,
18497 const void __user *from,
18498 unsigned long n)
18499 {
18500 - int sz = __compiletime_object_size(to);
18501 -
18502 might_fault();
18503 - if (likely(sz == -1 || sz >= n))
18504 - n = _copy_from_user(to, from, n);
18505 -#ifdef CONFIG_DEBUG_VM
18506 - else
18507 - WARN(1, "Buffer overflow detected!\n");
18508 -#endif
18509 +
18510 + check_object_size(to, n, false);
18511 +
18512 + if (access_ok(VERIFY_READ, from, n))
18513 + n = __copy_from_user(to, from, n);
18514 + else if (n < INT_MAX)
18515 + memset(to, 0, n);
18516 return n;
18517 }
18518
18519 static __always_inline __must_check
18520 -int copy_to_user(void __user *dst, const void *src, unsigned size)
18521 +int copy_to_user(void __user *dst, const void *src, unsigned long size)
18522 {
18523 might_fault();
18524
18525 - return _copy_to_user(dst, src, size);
18526 + if (access_ok(VERIFY_WRITE, dst, size))
18527 + size = __copy_to_user(dst, src, size);
18528 + return size;
18529 }
18530
18531 static __always_inline __must_check
18532 -int __copy_from_user(void *dst, const void __user *src, unsigned size)
18533 +unsigned long __copy_from_user(void *dst, const void __user *src, unsigned long size)
18534 {
18535 - int ret = 0;
18536 + size_t sz = __compiletime_object_size(dst);
18537 + unsigned ret = 0;
18538
18539 might_fault();
18540 +
18541 + if (size > INT_MAX)
18542 + return size;
18543 +
18544 + check_object_size(dst, size, false);
18545 +
18546 +#ifdef CONFIG_PAX_MEMORY_UDEREF
18547 + if (!__access_ok(VERIFY_READ, src, size))
18548 + return size;
18549 +#endif
18550 +
18551 + if (unlikely(sz != (size_t)-1 && sz < size)) {
18552 + copy_from_user_overflow();
18553 + return size;
18554 + }
18555 +
18556 if (!__builtin_constant_p(size))
18557 - return copy_user_generic(dst, (__force void *)src, size);
18558 + return copy_user_generic(dst, (__force_kernel const void *)____m(src), size);
18559 switch (size) {
18560 - case 1:__get_user_asm(*(u8 *)dst, (u8 __user *)src,
18561 + case 1:__get_user_asm(*(u8 *)dst, (const u8 __user *)src,
18562 ret, "b", "b", "=q", 1);
18563 return ret;
18564 - case 2:__get_user_asm(*(u16 *)dst, (u16 __user *)src,
18565 + case 2:__get_user_asm(*(u16 *)dst, (const u16 __user *)src,
18566 ret, "w", "w", "=r", 2);
18567 return ret;
18568 - case 4:__get_user_asm(*(u32 *)dst, (u32 __user *)src,
18569 + case 4:__get_user_asm(*(u32 *)dst, (const u32 __user *)src,
18570 ret, "l", "k", "=r", 4);
18571 return ret;
18572 - case 8:__get_user_asm(*(u64 *)dst, (u64 __user *)src,
18573 + case 8:__get_user_asm(*(u64 *)dst, (const u64 __user *)src,
18574 ret, "q", "", "=r", 8);
18575 return ret;
18576 case 10:
18577 - __get_user_asm(*(u64 *)dst, (u64 __user *)src,
18578 + __get_user_asm(*(u64 *)dst, (const u64 __user *)src,
18579 ret, "q", "", "=r", 10);
18580 if (unlikely(ret))
18581 return ret;
18582 __get_user_asm(*(u16 *)(8 + (char *)dst),
18583 - (u16 __user *)(8 + (char __user *)src),
18584 + (const u16 __user *)(8 + (const char __user *)src),
18585 ret, "w", "w", "=r", 2);
18586 return ret;
18587 case 16:
18588 - __get_user_asm(*(u64 *)dst, (u64 __user *)src,
18589 + __get_user_asm(*(u64 *)dst, (const u64 __user *)src,
18590 ret, "q", "", "=r", 16);
18591 if (unlikely(ret))
18592 return ret;
18593 __get_user_asm(*(u64 *)(8 + (char *)dst),
18594 - (u64 __user *)(8 + (char __user *)src),
18595 + (const u64 __user *)(8 + (const char __user *)src),
18596 ret, "q", "", "=r", 8);
18597 return ret;
18598 default:
18599 - return copy_user_generic(dst, (__force void *)src, size);
18600 + return copy_user_generic(dst, (__force_kernel const void *)____m(src), size);
18601 }
18602 }
18603
18604 static __always_inline __must_check
18605 -int __copy_to_user(void __user *dst, const void *src, unsigned size)
18606 +unsigned long __copy_to_user(void __user *dst, const void *src, unsigned long size)
18607 {
18608 - int ret = 0;
18609 + size_t sz = __compiletime_object_size(src);
18610 + unsigned ret = 0;
18611
18612 might_fault();
18613 +
18614 + if (size > INT_MAX)
18615 + return size;
18616 +
18617 + check_object_size(src, size, true);
18618 +
18619 +#ifdef CONFIG_PAX_MEMORY_UDEREF
18620 + if (!__access_ok(VERIFY_WRITE, dst, size))
18621 + return size;
18622 +#endif
18623 +
18624 + if (unlikely(sz != (size_t)-1 && sz < size)) {
18625 + copy_to_user_overflow();
18626 + return size;
18627 + }
18628 +
18629 if (!__builtin_constant_p(size))
18630 - return copy_user_generic((__force void *)dst, src, size);
18631 + return copy_user_generic((__force_kernel void *)____m(dst), src, size);
18632 switch (size) {
18633 - case 1:__put_user_asm(*(u8 *)src, (u8 __user *)dst,
18634 + case 1:__put_user_asm(*(const u8 *)src, (u8 __user *)dst,
18635 ret, "b", "b", "iq", 1);
18636 return ret;
18637 - case 2:__put_user_asm(*(u16 *)src, (u16 __user *)dst,
18638 + case 2:__put_user_asm(*(const u16 *)src, (u16 __user *)dst,
18639 ret, "w", "w", "ir", 2);
18640 return ret;
18641 - case 4:__put_user_asm(*(u32 *)src, (u32 __user *)dst,
18642 + case 4:__put_user_asm(*(const u32 *)src, (u32 __user *)dst,
18643 ret, "l", "k", "ir", 4);
18644 return ret;
18645 - case 8:__put_user_asm(*(u64 *)src, (u64 __user *)dst,
18646 + case 8:__put_user_asm(*(const u64 *)src, (u64 __user *)dst,
18647 ret, "q", "", "er", 8);
18648 return ret;
18649 case 10:
18650 - __put_user_asm(*(u64 *)src, (u64 __user *)dst,
18651 + __put_user_asm(*(const u64 *)src, (u64 __user *)dst,
18652 ret, "q", "", "er", 10);
18653 if (unlikely(ret))
18654 return ret;
18655 asm("":::"memory");
18656 - __put_user_asm(4[(u16 *)src], 4 + (u16 __user *)dst,
18657 + __put_user_asm(4[(const u16 *)src], 4 + (u16 __user *)dst,
18658 ret, "w", "w", "ir", 2);
18659 return ret;
18660 case 16:
18661 - __put_user_asm(*(u64 *)src, (u64 __user *)dst,
18662 + __put_user_asm(*(const u64 *)src, (u64 __user *)dst,
18663 ret, "q", "", "er", 16);
18664 if (unlikely(ret))
18665 return ret;
18666 asm("":::"memory");
18667 - __put_user_asm(1[(u64 *)src], 1 + (u64 __user *)dst,
18668 + __put_user_asm(1[(const u64 *)src], 1 + (u64 __user *)dst,
18669 ret, "q", "", "er", 8);
18670 return ret;
18671 default:
18672 - return copy_user_generic((__force void *)dst, src, size);
18673 + return copy_user_generic((__force_kernel void *)____m(dst), src, size);
18674 }
18675 }
18676
18677 static __always_inline __must_check
18678 -int __copy_in_user(void __user *dst, const void __user *src, unsigned size)
18679 +unsigned long __copy_in_user(void __user *dst, const void __user *src, unsigned long size)
18680 {
18681 - int ret = 0;
18682 + unsigned ret = 0;
18683
18684 might_fault();
18685 +
18686 + if (size > INT_MAX)
18687 + return size;
18688 +
18689 +#ifdef CONFIG_PAX_MEMORY_UDEREF
18690 + if (!__access_ok(VERIFY_READ, src, size))
18691 + return size;
18692 + if (!__access_ok(VERIFY_WRITE, dst, size))
18693 + return size;
18694 +#endif
18695 +
18696 if (!__builtin_constant_p(size))
18697 - return copy_user_generic((__force void *)dst,
18698 - (__force void *)src, size);
18699 + return copy_user_generic((__force_kernel void *)____m(dst),
18700 + (__force_kernel const void *)____m(src), size);
18701 switch (size) {
18702 case 1: {
18703 u8 tmp;
18704 - __get_user_asm(tmp, (u8 __user *)src,
18705 + __get_user_asm(tmp, (const u8 __user *)src,
18706 ret, "b", "b", "=q", 1);
18707 if (likely(!ret))
18708 __put_user_asm(tmp, (u8 __user *)dst,
18709 @@ -185,7 +250,7 @@ int __copy_in_user(void __user *dst, const void __user *src, unsigned size)
18710 }
18711 case 2: {
18712 u16 tmp;
18713 - __get_user_asm(tmp, (u16 __user *)src,
18714 + __get_user_asm(tmp, (const u16 __user *)src,
18715 ret, "w", "w", "=r", 2);
18716 if (likely(!ret))
18717 __put_user_asm(tmp, (u16 __user *)dst,
18718 @@ -195,7 +260,7 @@ int __copy_in_user(void __user *dst, const void __user *src, unsigned size)
18719
18720 case 4: {
18721 u32 tmp;
18722 - __get_user_asm(tmp, (u32 __user *)src,
18723 + __get_user_asm(tmp, (const u32 __user *)src,
18724 ret, "l", "k", "=r", 4);
18725 if (likely(!ret))
18726 __put_user_asm(tmp, (u32 __user *)dst,
18727 @@ -204,7 +269,7 @@ int __copy_in_user(void __user *dst, const void __user *src, unsigned size)
18728 }
18729 case 8: {
18730 u64 tmp;
18731 - __get_user_asm(tmp, (u64 __user *)src,
18732 + __get_user_asm(tmp, (const u64 __user *)src,
18733 ret, "q", "", "=r", 8);
18734 if (likely(!ret))
18735 __put_user_asm(tmp, (u64 __user *)dst,
18736 @@ -212,41 +277,74 @@ int __copy_in_user(void __user *dst, const void __user *src, unsigned size)
18737 return ret;
18738 }
18739 default:
18740 - return copy_user_generic((__force void *)dst,
18741 - (__force void *)src, size);
18742 + return copy_user_generic((__force_kernel void *)____m(dst),
18743 + (__force_kernel const void *)____m(src), size);
18744 }
18745 }
18746
18747 -static __must_check __always_inline int
18748 -__copy_from_user_inatomic(void *dst, const void __user *src, unsigned size)
18749 +static __must_check __always_inline unsigned long
18750 +__copy_from_user_inatomic(void *dst, const void __user *src, unsigned long size)
18751 {
18752 - return copy_user_generic(dst, (__force const void *)src, size);
18753 + if (size > INT_MAX)
18754 + return size;
18755 +
18756 +#ifdef CONFIG_PAX_MEMORY_UDEREF
18757 + if (!__access_ok(VERIFY_READ, src, size))
18758 + return size;
18759 +#endif
18760 +
18761 + return copy_user_generic(dst, (__force_kernel const void *)____m(src), size);
18762 }
18763
18764 -static __must_check __always_inline int
18765 -__copy_to_user_inatomic(void __user *dst, const void *src, unsigned size)
18766 +static __must_check __always_inline unsigned long
18767 +__copy_to_user_inatomic(void __user *dst, const void *src, unsigned long size)
18768 {
18769 - return copy_user_generic((__force void *)dst, src, size);
18770 + if (size > INT_MAX)
18771 + return size;
18772 +
18773 +#ifdef CONFIG_PAX_MEMORY_UDEREF
18774 + if (!__access_ok(VERIFY_WRITE, dst, size))
18775 + return size;
18776 +#endif
18777 +
18778 + return copy_user_generic((__force_kernel void *)____m(dst), src, size);
18779 }
18780
18781 -extern long __copy_user_nocache(void *dst, const void __user *src,
18782 - unsigned size, int zerorest);
18783 +extern unsigned long __copy_user_nocache(void *dst, const void __user *src,
18784 + unsigned long size, int zerorest);
18785
18786 -static inline int
18787 -__copy_from_user_nocache(void *dst, const void __user *src, unsigned size)
18788 +static inline unsigned long
18789 +__copy_from_user_nocache(void *dst, const void __user *src, unsigned long size)
18790 {
18791 might_fault();
18792 +
18793 + if (size > INT_MAX)
18794 + return size;
18795 +
18796 +#ifdef CONFIG_PAX_MEMORY_UDEREF
18797 + if (!__access_ok(VERIFY_READ, src, size))
18798 + return size;
18799 +#endif
18800 +
18801 return __copy_user_nocache(dst, src, size, 1);
18802 }
18803
18804 -static inline int
18805 +static inline unsigned long
18806 __copy_from_user_inatomic_nocache(void *dst, const void __user *src,
18807 - unsigned size)
18808 + unsigned long size)
18809 {
18810 + if (size > INT_MAX)
18811 + return size;
18812 +
18813 +#ifdef CONFIG_PAX_MEMORY_UDEREF
18814 + if (!__access_ok(VERIFY_READ, src, size))
18815 + return size;
18816 +#endif
18817 +
18818 return __copy_user_nocache(dst, src, size, 0);
18819 }
18820
18821 unsigned long
18822 -copy_user_handle_tail(char *to, char *from, unsigned len, unsigned zerorest);
18823 +copy_user_handle_tail(char __user *to, char __user *from, unsigned long len, unsigned zerorest) __size_overflow(3);
18824
18825 #endif /* _ASM_X86_UACCESS_64_H */
18826 diff --git a/arch/x86/include/asm/word-at-a-time.h b/arch/x86/include/asm/word-at-a-time.h
18827 index 5b238981..77fdd78 100644
18828 --- a/arch/x86/include/asm/word-at-a-time.h
18829 +++ b/arch/x86/include/asm/word-at-a-time.h
18830 @@ -11,7 +11,7 @@
18831 * and shift, for example.
18832 */
18833 struct word_at_a_time {
18834 - const unsigned long one_bits, high_bits;
18835 + unsigned long one_bits, high_bits;
18836 };
18837
18838 #define WORD_AT_A_TIME_CONSTANTS { REPEAT_BYTE(0x01), REPEAT_BYTE(0x80) }
18839 diff --git a/arch/x86/include/asm/x86_init.h b/arch/x86/include/asm/x86_init.h
18840 index 828a156..650e625 100644
18841 --- a/arch/x86/include/asm/x86_init.h
18842 +++ b/arch/x86/include/asm/x86_init.h
18843 @@ -129,7 +129,7 @@ struct x86_init_ops {
18844 struct x86_init_timers timers;
18845 struct x86_init_iommu iommu;
18846 struct x86_init_pci pci;
18847 -};
18848 +} __no_const;
18849
18850 /**
18851 * struct x86_cpuinit_ops - platform specific cpu hotplug setups
18852 @@ -140,7 +140,7 @@ struct x86_cpuinit_ops {
18853 void (*setup_percpu_clockev)(void);
18854 void (*early_percpu_clock_init)(void);
18855 void (*fixup_cpu_id)(struct cpuinfo_x86 *c, int node);
18856 -};
18857 +} __no_const;
18858
18859 struct timespec;
18860
18861 @@ -168,7 +168,7 @@ struct x86_platform_ops {
18862 void (*save_sched_clock_state)(void);
18863 void (*restore_sched_clock_state)(void);
18864 void (*apic_post_init)(void);
18865 -};
18866 +} __no_const;
18867
18868 struct pci_dev;
18869 struct msi_msg;
18870 @@ -182,7 +182,7 @@ struct x86_msi_ops {
18871 void (*teardown_msi_irqs)(struct pci_dev *dev);
18872 void (*restore_msi_irqs)(struct pci_dev *dev, int irq);
18873 int (*setup_hpet_msi)(unsigned int irq, unsigned int id);
18874 -};
18875 +} __no_const;
18876
18877 struct IO_APIC_route_entry;
18878 struct io_apic_irq_attr;
18879 @@ -203,7 +203,7 @@ struct x86_io_apic_ops {
18880 unsigned int destination, int vector,
18881 struct io_apic_irq_attr *attr);
18882 void (*eoi_ioapic_pin)(int apic, int pin, int vector);
18883 -};
18884 +} __no_const;
18885
18886 extern struct x86_init_ops x86_init;
18887 extern struct x86_cpuinit_ops x86_cpuinit;
18888 diff --git a/arch/x86/include/asm/xen/page.h b/arch/x86/include/asm/xen/page.h
18889 index b913915..4f5a581 100644
18890 --- a/arch/x86/include/asm/xen/page.h
18891 +++ b/arch/x86/include/asm/xen/page.h
18892 @@ -56,7 +56,7 @@ extern int m2p_remove_override(struct page *page,
18893 extern struct page *m2p_find_override(unsigned long mfn);
18894 extern unsigned long m2p_find_override_pfn(unsigned long mfn, unsigned long pfn);
18895
18896 -static inline unsigned long pfn_to_mfn(unsigned long pfn)
18897 +static inline unsigned long __intentional_overflow(-1) pfn_to_mfn(unsigned long pfn)
18898 {
18899 unsigned long mfn;
18900
18901 diff --git a/arch/x86/include/asm/xsave.h b/arch/x86/include/asm/xsave.h
18902 index 0415cda..3b22adc 100644
18903 --- a/arch/x86/include/asm/xsave.h
18904 +++ b/arch/x86/include/asm/xsave.h
18905 @@ -70,8 +70,11 @@ static inline int xsave_user(struct xsave_struct __user *buf)
18906 if (unlikely(err))
18907 return -EFAULT;
18908
18909 + pax_open_userland();
18910 __asm__ __volatile__(ASM_STAC "\n"
18911 - "1: .byte " REX_PREFIX "0x0f,0xae,0x27\n"
18912 + "1:"
18913 + __copyuser_seg
18914 + ".byte " REX_PREFIX "0x0f,0xae,0x27\n"
18915 "2: " ASM_CLAC "\n"
18916 ".section .fixup,\"ax\"\n"
18917 "3: movl $-1,%[err]\n"
18918 @@ -81,18 +84,22 @@ static inline int xsave_user(struct xsave_struct __user *buf)
18919 : [err] "=r" (err)
18920 : "D" (buf), "a" (-1), "d" (-1), "0" (0)
18921 : "memory");
18922 + pax_close_userland();
18923 return err;
18924 }
18925
18926 static inline int xrestore_user(struct xsave_struct __user *buf, u64 mask)
18927 {
18928 int err;
18929 - struct xsave_struct *xstate = ((__force struct xsave_struct *)buf);
18930 + struct xsave_struct *xstate = ((__force_kernel struct xsave_struct *)buf);
18931 u32 lmask = mask;
18932 u32 hmask = mask >> 32;
18933
18934 + pax_open_userland();
18935 __asm__ __volatile__(ASM_STAC "\n"
18936 - "1: .byte " REX_PREFIX "0x0f,0xae,0x2f\n"
18937 + "1:"
18938 + __copyuser_seg
18939 + ".byte " REX_PREFIX "0x0f,0xae,0x2f\n"
18940 "2: " ASM_CLAC "\n"
18941 ".section .fixup,\"ax\"\n"
18942 "3: movl $-1,%[err]\n"
18943 @@ -102,6 +109,7 @@ static inline int xrestore_user(struct xsave_struct __user *buf, u64 mask)
18944 : [err] "=r" (err)
18945 : "D" (xstate), "a" (lmask), "d" (hmask), "0" (0)
18946 : "memory"); /* memory required? */
18947 + pax_close_userland();
18948 return err;
18949 }
18950
18951 diff --git a/arch/x86/include/uapi/asm/e820.h b/arch/x86/include/uapi/asm/e820.h
18952 index bbae024..e1528f9 100644
18953 --- a/arch/x86/include/uapi/asm/e820.h
18954 +++ b/arch/x86/include/uapi/asm/e820.h
18955 @@ -63,7 +63,7 @@ struct e820map {
18956 #define ISA_START_ADDRESS 0xa0000
18957 #define ISA_END_ADDRESS 0x100000
18958
18959 -#define BIOS_BEGIN 0x000a0000
18960 +#define BIOS_BEGIN 0x000c0000
18961 #define BIOS_END 0x00100000
18962
18963 #define BIOS_ROM_BASE 0xffe00000
18964 diff --git a/arch/x86/kernel/Makefile b/arch/x86/kernel/Makefile
18965 index a5408b9..5133813 100644
18966 --- a/arch/x86/kernel/Makefile
18967 +++ b/arch/x86/kernel/Makefile
18968 @@ -24,7 +24,7 @@ obj-y += time.o ioport.o ldt.o dumpstack.o nmi.o
18969 obj-y += setup.o x86_init.o i8259.o irqinit.o jump_label.o
18970 obj-$(CONFIG_IRQ_WORK) += irq_work.o
18971 obj-y += probe_roms.o
18972 -obj-$(CONFIG_X86_32) += i386_ksyms_32.o
18973 +obj-$(CONFIG_X86_32) += sys_i386_32.o i386_ksyms_32.o
18974 obj-$(CONFIG_X86_64) += sys_x86_64.o x8664_ksyms_64.o
18975 obj-y += syscall_$(BITS).o
18976 obj-$(CONFIG_X86_64) += vsyscall_64.o
18977 diff --git a/arch/x86/kernel/acpi/boot.c b/arch/x86/kernel/acpi/boot.c
18978 index 40c7660..f709f4b 100644
18979 --- a/arch/x86/kernel/acpi/boot.c
18980 +++ b/arch/x86/kernel/acpi/boot.c
18981 @@ -1365,7 +1365,7 @@ static int __init dmi_ignore_irq0_timer_override(const struct dmi_system_id *d)
18982 * If your system is blacklisted here, but you find that acpi=force
18983 * works for you, please contact linux-acpi@vger.kernel.org
18984 */
18985 -static struct dmi_system_id __initdata acpi_dmi_table[] = {
18986 +static const struct dmi_system_id __initconst acpi_dmi_table[] = {
18987 /*
18988 * Boxes that need ACPI disabled
18989 */
18990 @@ -1440,7 +1440,7 @@ static struct dmi_system_id __initdata acpi_dmi_table[] = {
18991 };
18992
18993 /* second table for DMI checks that should run after early-quirks */
18994 -static struct dmi_system_id __initdata acpi_dmi_table_late[] = {
18995 +static const struct dmi_system_id __initconst acpi_dmi_table_late[] = {
18996 /*
18997 * HP laptops which use a DSDT reporting as HP/SB400/10000,
18998 * which includes some code which overrides all temperature
18999 diff --git a/arch/x86/kernel/acpi/sleep.c b/arch/x86/kernel/acpi/sleep.c
19000 index 3312010..a65ca7b 100644
19001 --- a/arch/x86/kernel/acpi/sleep.c
19002 +++ b/arch/x86/kernel/acpi/sleep.c
19003 @@ -88,8 +88,12 @@ int x86_acpi_suspend_lowlevel(void)
19004 #else /* CONFIG_64BIT */
19005 #ifdef CONFIG_SMP
19006 stack_start = (unsigned long)temp_stack + sizeof(temp_stack);
19007 +
19008 + pax_open_kernel();
19009 early_gdt_descr.address =
19010 (unsigned long)get_cpu_gdt_table(smp_processor_id());
19011 + pax_close_kernel();
19012 +
19013 initial_gs = per_cpu_offset(smp_processor_id());
19014 #endif
19015 initial_code = (unsigned long)wakeup_long64;
19016 diff --git a/arch/x86/kernel/acpi/wakeup_32.S b/arch/x86/kernel/acpi/wakeup_32.S
19017 index d1daa66..59fecba 100644
19018 --- a/arch/x86/kernel/acpi/wakeup_32.S
19019 +++ b/arch/x86/kernel/acpi/wakeup_32.S
19020 @@ -29,13 +29,11 @@ wakeup_pmode_return:
19021 # and restore the stack ... but you need gdt for this to work
19022 movl saved_context_esp, %esp
19023
19024 - movl %cs:saved_magic, %eax
19025 - cmpl $0x12345678, %eax
19026 + cmpl $0x12345678, saved_magic
19027 jne bogus_magic
19028
19029 # jump to place where we left off
19030 - movl saved_eip, %eax
19031 - jmp *%eax
19032 + jmp *(saved_eip)
19033
19034 bogus_magic:
19035 jmp bogus_magic
19036 diff --git a/arch/x86/kernel/alternative.c b/arch/x86/kernel/alternative.c
19037 index 15e8563..323cbe1 100644
19038 --- a/arch/x86/kernel/alternative.c
19039 +++ b/arch/x86/kernel/alternative.c
19040 @@ -269,6 +269,13 @@ void __init_or_module apply_alternatives(struct alt_instr *start,
19041 */
19042 for (a = start; a < end; a++) {
19043 instr = (u8 *)&a->instr_offset + a->instr_offset;
19044 +
19045 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
19046 + instr += ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
19047 + if (instr < (u8 *)_text || (u8 *)_einittext <= instr)
19048 + instr -= ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
19049 +#endif
19050 +
19051 replacement = (u8 *)&a->repl_offset + a->repl_offset;
19052 BUG_ON(a->replacementlen > a->instrlen);
19053 BUG_ON(a->instrlen > sizeof(insnbuf));
19054 @@ -300,10 +307,16 @@ static void alternatives_smp_lock(const s32 *start, const s32 *end,
19055 for (poff = start; poff < end; poff++) {
19056 u8 *ptr = (u8 *)poff + *poff;
19057
19058 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
19059 + ptr += ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
19060 + if (ptr < (u8 *)_text || (u8 *)_einittext <= ptr)
19061 + ptr -= ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
19062 +#endif
19063 +
19064 if (!*poff || ptr < text || ptr >= text_end)
19065 continue;
19066 /* turn DS segment override prefix into lock prefix */
19067 - if (*ptr == 0x3e)
19068 + if (*ktla_ktva(ptr) == 0x3e)
19069 text_poke(ptr, ((unsigned char []){0xf0}), 1);
19070 }
19071 mutex_unlock(&text_mutex);
19072 @@ -318,10 +331,16 @@ static void alternatives_smp_unlock(const s32 *start, const s32 *end,
19073 for (poff = start; poff < end; poff++) {
19074 u8 *ptr = (u8 *)poff + *poff;
19075
19076 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
19077 + ptr += ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
19078 + if (ptr < (u8 *)_text || (u8 *)_einittext <= ptr)
19079 + ptr -= ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
19080 +#endif
19081 +
19082 if (!*poff || ptr < text || ptr >= text_end)
19083 continue;
19084 /* turn lock prefix into DS segment override prefix */
19085 - if (*ptr == 0xf0)
19086 + if (*ktla_ktva(ptr) == 0xf0)
19087 text_poke(ptr, ((unsigned char []){0x3E}), 1);
19088 }
19089 mutex_unlock(&text_mutex);
19090 @@ -469,7 +488,7 @@ void __init_or_module apply_paravirt(struct paravirt_patch_site *start,
19091
19092 BUG_ON(p->len > MAX_PATCH_LEN);
19093 /* prep the buffer with the original instructions */
19094 - memcpy(insnbuf, p->instr, p->len);
19095 + memcpy(insnbuf, ktla_ktva(p->instr), p->len);
19096 used = pv_init_ops.patch(p->instrtype, p->clobbers, insnbuf,
19097 (unsigned long)p->instr, p->len);
19098
19099 @@ -516,7 +535,7 @@ void __init alternative_instructions(void)
19100 if (!uniproc_patched || num_possible_cpus() == 1)
19101 free_init_pages("SMP alternatives",
19102 (unsigned long)__smp_locks,
19103 - (unsigned long)__smp_locks_end);
19104 + PAGE_ALIGN((unsigned long)__smp_locks_end));
19105 #endif
19106
19107 apply_paravirt(__parainstructions, __parainstructions_end);
19108 @@ -536,13 +555,17 @@ void __init alternative_instructions(void)
19109 * instructions. And on the local CPU you need to be protected again NMI or MCE
19110 * handlers seeing an inconsistent instruction while you patch.
19111 */
19112 -void *__init_or_module text_poke_early(void *addr, const void *opcode,
19113 +void *__kprobes text_poke_early(void *addr, const void *opcode,
19114 size_t len)
19115 {
19116 unsigned long flags;
19117 local_irq_save(flags);
19118 - memcpy(addr, opcode, len);
19119 +
19120 + pax_open_kernel();
19121 + memcpy(ktla_ktva(addr), opcode, len);
19122 sync_core();
19123 + pax_close_kernel();
19124 +
19125 local_irq_restore(flags);
19126 /* Could also do a CLFLUSH here to speed up CPU recovery; but
19127 that causes hangs on some VIA CPUs. */
19128 @@ -564,36 +587,22 @@ void *__init_or_module text_poke_early(void *addr, const void *opcode,
19129 */
19130 void *__kprobes text_poke(void *addr, const void *opcode, size_t len)
19131 {
19132 - unsigned long flags;
19133 - char *vaddr;
19134 + unsigned char *vaddr = ktla_ktva(addr);
19135 struct page *pages[2];
19136 - int i;
19137 + size_t i;
19138
19139 if (!core_kernel_text((unsigned long)addr)) {
19140 - pages[0] = vmalloc_to_page(addr);
19141 - pages[1] = vmalloc_to_page(addr + PAGE_SIZE);
19142 + pages[0] = vmalloc_to_page(vaddr);
19143 + pages[1] = vmalloc_to_page(vaddr + PAGE_SIZE);
19144 } else {
19145 - pages[0] = virt_to_page(addr);
19146 + pages[0] = virt_to_page(vaddr);
19147 WARN_ON(!PageReserved(pages[0]));
19148 - pages[1] = virt_to_page(addr + PAGE_SIZE);
19149 + pages[1] = virt_to_page(vaddr + PAGE_SIZE);
19150 }
19151 BUG_ON(!pages[0]);
19152 - local_irq_save(flags);
19153 - set_fixmap(FIX_TEXT_POKE0, page_to_phys(pages[0]));
19154 - if (pages[1])
19155 - set_fixmap(FIX_TEXT_POKE1, page_to_phys(pages[1]));
19156 - vaddr = (char *)fix_to_virt(FIX_TEXT_POKE0);
19157 - memcpy(&vaddr[(unsigned long)addr & ~PAGE_MASK], opcode, len);
19158 - clear_fixmap(FIX_TEXT_POKE0);
19159 - if (pages[1])
19160 - clear_fixmap(FIX_TEXT_POKE1);
19161 - local_flush_tlb();
19162 - sync_core();
19163 - /* Could also do a CLFLUSH here to speed up CPU recovery; but
19164 - that causes hangs on some VIA CPUs. */
19165 + text_poke_early(addr, opcode, len);
19166 for (i = 0; i < len; i++)
19167 - BUG_ON(((char *)addr)[i] != ((char *)opcode)[i]);
19168 - local_irq_restore(flags);
19169 + BUG_ON((vaddr)[i] != ((const unsigned char *)opcode)[i]);
19170 return addr;
19171 }
19172
19173 @@ -613,7 +622,7 @@ int poke_int3_handler(struct pt_regs *regs)
19174 if (likely(!bp_patching_in_progress))
19175 return 0;
19176
19177 - if (user_mode_vm(regs) || regs->ip != (unsigned long)bp_int3_addr)
19178 + if (user_mode(regs) || regs->ip != (unsigned long)bp_int3_addr)
19179 return 0;
19180
19181 /* set up the specified breakpoint handler */
19182 @@ -647,7 +656,7 @@ int poke_int3_handler(struct pt_regs *regs)
19183 */
19184 void *text_poke_bp(void *addr, const void *opcode, size_t len, void *handler)
19185 {
19186 - unsigned char int3 = 0xcc;
19187 + const unsigned char int3 = 0xcc;
19188
19189 bp_int3_handler = handler;
19190 bp_int3_addr = (u8 *)addr + sizeof(int3);
19191 diff --git a/arch/x86/kernel/apic/apic.c b/arch/x86/kernel/apic/apic.c
19192 index a7eb82d..f6e52d4 100644
19193 --- a/arch/x86/kernel/apic/apic.c
19194 +++ b/arch/x86/kernel/apic/apic.c
19195 @@ -190,7 +190,7 @@ int first_system_vector = 0xfe;
19196 /*
19197 * Debug level, exported for io_apic.c
19198 */
19199 -unsigned int apic_verbosity;
19200 +int apic_verbosity;
19201
19202 int pic_mode;
19203
19204 @@ -1985,7 +1985,7 @@ static inline void __smp_error_interrupt(struct pt_regs *regs)
19205 apic_write(APIC_ESR, 0);
19206 v1 = apic_read(APIC_ESR);
19207 ack_APIC_irq();
19208 - atomic_inc(&irq_err_count);
19209 + atomic_inc_unchecked(&irq_err_count);
19210
19211 apic_printk(APIC_DEBUG, KERN_DEBUG "APIC error on CPU%d: %02x(%02x)",
19212 smp_processor_id(), v0 , v1);
19213 diff --git a/arch/x86/kernel/apic/apic_flat_64.c b/arch/x86/kernel/apic/apic_flat_64.c
19214 index 00c77cf..2dc6a2d 100644
19215 --- a/arch/x86/kernel/apic/apic_flat_64.c
19216 +++ b/arch/x86/kernel/apic/apic_flat_64.c
19217 @@ -157,7 +157,7 @@ static int flat_probe(void)
19218 return 1;
19219 }
19220
19221 -static struct apic apic_flat = {
19222 +static struct apic apic_flat __read_only = {
19223 .name = "flat",
19224 .probe = flat_probe,
19225 .acpi_madt_oem_check = flat_acpi_madt_oem_check,
19226 @@ -271,7 +271,7 @@ static int physflat_probe(void)
19227 return 0;
19228 }
19229
19230 -static struct apic apic_physflat = {
19231 +static struct apic apic_physflat __read_only = {
19232
19233 .name = "physical flat",
19234 .probe = physflat_probe,
19235 diff --git a/arch/x86/kernel/apic/apic_noop.c b/arch/x86/kernel/apic/apic_noop.c
19236 index e145f28..2752888 100644
19237 --- a/arch/x86/kernel/apic/apic_noop.c
19238 +++ b/arch/x86/kernel/apic/apic_noop.c
19239 @@ -119,7 +119,7 @@ static void noop_apic_write(u32 reg, u32 v)
19240 WARN_ON_ONCE(cpu_has_apic && !disable_apic);
19241 }
19242
19243 -struct apic apic_noop = {
19244 +struct apic apic_noop __read_only = {
19245 .name = "noop",
19246 .probe = noop_probe,
19247 .acpi_madt_oem_check = NULL,
19248 diff --git a/arch/x86/kernel/apic/bigsmp_32.c b/arch/x86/kernel/apic/bigsmp_32.c
19249 index d50e364..543bee3 100644
19250 --- a/arch/x86/kernel/apic/bigsmp_32.c
19251 +++ b/arch/x86/kernel/apic/bigsmp_32.c
19252 @@ -152,7 +152,7 @@ static int probe_bigsmp(void)
19253 return dmi_bigsmp;
19254 }
19255
19256 -static struct apic apic_bigsmp = {
19257 +static struct apic apic_bigsmp __read_only = {
19258
19259 .name = "bigsmp",
19260 .probe = probe_bigsmp,
19261 diff --git a/arch/x86/kernel/apic/es7000_32.c b/arch/x86/kernel/apic/es7000_32.c
19262 index c552247..587a316 100644
19263 --- a/arch/x86/kernel/apic/es7000_32.c
19264 +++ b/arch/x86/kernel/apic/es7000_32.c
19265 @@ -608,8 +608,7 @@ static int es7000_mps_oem_check_cluster(struct mpc_table *mpc, char *oem,
19266 return ret && es7000_apic_is_cluster();
19267 }
19268
19269 -/* We've been warned by a false positive warning.Use __refdata to keep calm. */
19270 -static struct apic __refdata apic_es7000_cluster = {
19271 +static struct apic apic_es7000_cluster __read_only = {
19272
19273 .name = "es7000",
19274 .probe = probe_es7000,
19275 @@ -675,7 +674,7 @@ static struct apic __refdata apic_es7000_cluster = {
19276 .x86_32_early_logical_apicid = es7000_early_logical_apicid,
19277 };
19278
19279 -static struct apic __refdata apic_es7000 = {
19280 +static struct apic apic_es7000 __read_only = {
19281
19282 .name = "es7000",
19283 .probe = probe_es7000,
19284 diff --git a/arch/x86/kernel/apic/io_apic.c b/arch/x86/kernel/apic/io_apic.c
19285 index e63a5bd..c0babf8 100644
19286 --- a/arch/x86/kernel/apic/io_apic.c
19287 +++ b/arch/x86/kernel/apic/io_apic.c
19288 @@ -1060,7 +1060,7 @@ int IO_APIC_get_PCI_irq_vector(int bus, int slot, int pin,
19289 }
19290 EXPORT_SYMBOL(IO_APIC_get_PCI_irq_vector);
19291
19292 -void lock_vector_lock(void)
19293 +void lock_vector_lock(void) __acquires(vector_lock)
19294 {
19295 /* Used to the online set of cpus does not change
19296 * during assign_irq_vector.
19297 @@ -1068,7 +1068,7 @@ void lock_vector_lock(void)
19298 raw_spin_lock(&vector_lock);
19299 }
19300
19301 -void unlock_vector_lock(void)
19302 +void unlock_vector_lock(void) __releases(vector_lock)
19303 {
19304 raw_spin_unlock(&vector_lock);
19305 }
19306 @@ -2367,7 +2367,7 @@ static void ack_apic_edge(struct irq_data *data)
19307 ack_APIC_irq();
19308 }
19309
19310 -atomic_t irq_mis_count;
19311 +atomic_unchecked_t irq_mis_count;
19312
19313 #ifdef CONFIG_GENERIC_PENDING_IRQ
19314 static bool io_apic_level_ack_pending(struct irq_cfg *cfg)
19315 @@ -2508,7 +2508,7 @@ static void ack_apic_level(struct irq_data *data)
19316 * at the cpu.
19317 */
19318 if (!(v & (1 << (i & 0x1f)))) {
19319 - atomic_inc(&irq_mis_count);
19320 + atomic_inc_unchecked(&irq_mis_count);
19321
19322 eoi_ioapic_irq(irq, cfg);
19323 }
19324 diff --git a/arch/x86/kernel/apic/numaq_32.c b/arch/x86/kernel/apic/numaq_32.c
19325 index 1e42e8f..daacf44 100644
19326 --- a/arch/x86/kernel/apic/numaq_32.c
19327 +++ b/arch/x86/kernel/apic/numaq_32.c
19328 @@ -455,8 +455,7 @@ static void numaq_setup_portio_remap(void)
19329 (u_long) xquad_portio, (u_long) num_quads*XQUAD_PORTIO_QUAD);
19330 }
19331
19332 -/* Use __refdata to keep false positive warning calm. */
19333 -static struct apic __refdata apic_numaq = {
19334 +static struct apic apic_numaq __read_only = {
19335
19336 .name = "NUMAQ",
19337 .probe = probe_numaq,
19338 diff --git a/arch/x86/kernel/apic/probe_32.c b/arch/x86/kernel/apic/probe_32.c
19339 index eb35ef9..f184a21 100644
19340 --- a/arch/x86/kernel/apic/probe_32.c
19341 +++ b/arch/x86/kernel/apic/probe_32.c
19342 @@ -72,7 +72,7 @@ static int probe_default(void)
19343 return 1;
19344 }
19345
19346 -static struct apic apic_default = {
19347 +static struct apic apic_default __read_only = {
19348
19349 .name = "default",
19350 .probe = probe_default,
19351 diff --git a/arch/x86/kernel/apic/summit_32.c b/arch/x86/kernel/apic/summit_32.c
19352 index 77c95c0..434f8a4 100644
19353 --- a/arch/x86/kernel/apic/summit_32.c
19354 +++ b/arch/x86/kernel/apic/summit_32.c
19355 @@ -486,7 +486,7 @@ void setup_summit(void)
19356 }
19357 #endif
19358
19359 -static struct apic apic_summit = {
19360 +static struct apic apic_summit __read_only = {
19361
19362 .name = "summit",
19363 .probe = probe_summit,
19364 diff --git a/arch/x86/kernel/apic/x2apic_cluster.c b/arch/x86/kernel/apic/x2apic_cluster.c
19365 index 140e29d..d88bc95 100644
19366 --- a/arch/x86/kernel/apic/x2apic_cluster.c
19367 +++ b/arch/x86/kernel/apic/x2apic_cluster.c
19368 @@ -183,7 +183,7 @@ update_clusterinfo(struct notifier_block *nfb, unsigned long action, void *hcpu)
19369 return notifier_from_errno(err);
19370 }
19371
19372 -static struct notifier_block __refdata x2apic_cpu_notifier = {
19373 +static struct notifier_block x2apic_cpu_notifier = {
19374 .notifier_call = update_clusterinfo,
19375 };
19376
19377 @@ -235,7 +235,7 @@ static void cluster_vector_allocation_domain(int cpu, struct cpumask *retmask,
19378 cpumask_and(retmask, mask, per_cpu(cpus_in_cluster, cpu));
19379 }
19380
19381 -static struct apic apic_x2apic_cluster = {
19382 +static struct apic apic_x2apic_cluster __read_only = {
19383
19384 .name = "cluster x2apic",
19385 .probe = x2apic_cluster_probe,
19386 diff --git a/arch/x86/kernel/apic/x2apic_phys.c b/arch/x86/kernel/apic/x2apic_phys.c
19387 index 562a76d..a003c0f 100644
19388 --- a/arch/x86/kernel/apic/x2apic_phys.c
19389 +++ b/arch/x86/kernel/apic/x2apic_phys.c
19390 @@ -89,7 +89,7 @@ static int x2apic_phys_probe(void)
19391 return apic == &apic_x2apic_phys;
19392 }
19393
19394 -static struct apic apic_x2apic_phys = {
19395 +static struct apic apic_x2apic_phys __read_only = {
19396
19397 .name = "physical x2apic",
19398 .probe = x2apic_phys_probe,
19399 diff --git a/arch/x86/kernel/apic/x2apic_uv_x.c b/arch/x86/kernel/apic/x2apic_uv_x.c
19400 index a419814..1dd34a0 100644
19401 --- a/arch/x86/kernel/apic/x2apic_uv_x.c
19402 +++ b/arch/x86/kernel/apic/x2apic_uv_x.c
19403 @@ -357,7 +357,7 @@ static int uv_probe(void)
19404 return apic == &apic_x2apic_uv_x;
19405 }
19406
19407 -static struct apic __refdata apic_x2apic_uv_x = {
19408 +static struct apic apic_x2apic_uv_x __read_only = {
19409
19410 .name = "UV large system",
19411 .probe = uv_probe,
19412 diff --git a/arch/x86/kernel/apm_32.c b/arch/x86/kernel/apm_32.c
19413 index 3ab0343..814c4787 100644
19414 --- a/arch/x86/kernel/apm_32.c
19415 +++ b/arch/x86/kernel/apm_32.c
19416 @@ -433,7 +433,7 @@ static DEFINE_MUTEX(apm_mutex);
19417 * This is for buggy BIOS's that refer to (real mode) segment 0x40
19418 * even though they are called in protected mode.
19419 */
19420 -static struct desc_struct bad_bios_desc = GDT_ENTRY_INIT(0x4092,
19421 +static const struct desc_struct bad_bios_desc = GDT_ENTRY_INIT(0x4093,
19422 (unsigned long)__va(0x400UL), PAGE_SIZE - 0x400 - 1);
19423
19424 static const char driver_version[] = "1.16ac"; /* no spaces */
19425 @@ -611,7 +611,10 @@ static long __apm_bios_call(void *_call)
19426 BUG_ON(cpu != 0);
19427 gdt = get_cpu_gdt_table(cpu);
19428 save_desc_40 = gdt[0x40 / 8];
19429 +
19430 + pax_open_kernel();
19431 gdt[0x40 / 8] = bad_bios_desc;
19432 + pax_close_kernel();
19433
19434 apm_irq_save(flags);
19435 APM_DO_SAVE_SEGS;
19436 @@ -620,7 +623,11 @@ static long __apm_bios_call(void *_call)
19437 &call->esi);
19438 APM_DO_RESTORE_SEGS;
19439 apm_irq_restore(flags);
19440 +
19441 + pax_open_kernel();
19442 gdt[0x40 / 8] = save_desc_40;
19443 + pax_close_kernel();
19444 +
19445 put_cpu();
19446
19447 return call->eax & 0xff;
19448 @@ -687,7 +694,10 @@ static long __apm_bios_call_simple(void *_call)
19449 BUG_ON(cpu != 0);
19450 gdt = get_cpu_gdt_table(cpu);
19451 save_desc_40 = gdt[0x40 / 8];
19452 +
19453 + pax_open_kernel();
19454 gdt[0x40 / 8] = bad_bios_desc;
19455 + pax_close_kernel();
19456
19457 apm_irq_save(flags);
19458 APM_DO_SAVE_SEGS;
19459 @@ -695,7 +705,11 @@ static long __apm_bios_call_simple(void *_call)
19460 &call->eax);
19461 APM_DO_RESTORE_SEGS;
19462 apm_irq_restore(flags);
19463 +
19464 + pax_open_kernel();
19465 gdt[0x40 / 8] = save_desc_40;
19466 + pax_close_kernel();
19467 +
19468 put_cpu();
19469 return error;
19470 }
19471 @@ -2362,12 +2376,15 @@ static int __init apm_init(void)
19472 * code to that CPU.
19473 */
19474 gdt = get_cpu_gdt_table(0);
19475 +
19476 + pax_open_kernel();
19477 set_desc_base(&gdt[APM_CS >> 3],
19478 (unsigned long)__va((unsigned long)apm_info.bios.cseg << 4));
19479 set_desc_base(&gdt[APM_CS_16 >> 3],
19480 (unsigned long)__va((unsigned long)apm_info.bios.cseg_16 << 4));
19481 set_desc_base(&gdt[APM_DS >> 3],
19482 (unsigned long)__va((unsigned long)apm_info.bios.dseg << 4));
19483 + pax_close_kernel();
19484
19485 proc_create("apm", 0, NULL, &apm_file_ops);
19486
19487 diff --git a/arch/x86/kernel/asm-offsets.c b/arch/x86/kernel/asm-offsets.c
19488 index 2861082..6d4718e 100644
19489 --- a/arch/x86/kernel/asm-offsets.c
19490 +++ b/arch/x86/kernel/asm-offsets.c
19491 @@ -33,6 +33,8 @@ void common(void) {
19492 OFFSET(TI_status, thread_info, status);
19493 OFFSET(TI_addr_limit, thread_info, addr_limit);
19494 OFFSET(TI_preempt_count, thread_info, preempt_count);
19495 + OFFSET(TI_lowest_stack, thread_info, lowest_stack);
19496 + DEFINE(TI_task_thread_sp0, offsetof(struct task_struct, thread.sp0) - offsetof(struct task_struct, tinfo));
19497
19498 BLANK();
19499 OFFSET(crypto_tfm_ctx_offset, crypto_tfm, __crt_ctx);
19500 @@ -53,8 +55,26 @@ void common(void) {
19501 OFFSET(PV_CPU_irq_enable_sysexit, pv_cpu_ops, irq_enable_sysexit);
19502 OFFSET(PV_CPU_read_cr0, pv_cpu_ops, read_cr0);
19503 OFFSET(PV_MMU_read_cr2, pv_mmu_ops, read_cr2);
19504 +
19505 +#ifdef CONFIG_PAX_KERNEXEC
19506 + OFFSET(PV_CPU_write_cr0, pv_cpu_ops, write_cr0);
19507 #endif
19508
19509 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19510 + OFFSET(PV_MMU_read_cr3, pv_mmu_ops, read_cr3);
19511 + OFFSET(PV_MMU_write_cr3, pv_mmu_ops, write_cr3);
19512 +#ifdef CONFIG_X86_64
19513 + OFFSET(PV_MMU_set_pgd_batched, pv_mmu_ops, set_pgd_batched);
19514 +#endif
19515 +#endif
19516 +
19517 +#endif
19518 +
19519 + BLANK();
19520 + DEFINE(PAGE_SIZE_asm, PAGE_SIZE);
19521 + DEFINE(PAGE_SHIFT_asm, PAGE_SHIFT);
19522 + DEFINE(THREAD_SIZE_asm, THREAD_SIZE);
19523 +
19524 #ifdef CONFIG_XEN
19525 BLANK();
19526 OFFSET(XEN_vcpu_info_mask, vcpu_info, evtchn_upcall_mask);
19527 diff --git a/arch/x86/kernel/asm-offsets_64.c b/arch/x86/kernel/asm-offsets_64.c
19528 index e7c798b..2b2019b 100644
19529 --- a/arch/x86/kernel/asm-offsets_64.c
19530 +++ b/arch/x86/kernel/asm-offsets_64.c
19531 @@ -77,6 +77,7 @@ int main(void)
19532 BLANK();
19533 #undef ENTRY
19534
19535 + DEFINE(TSS_size, sizeof(struct tss_struct));
19536 OFFSET(TSS_ist, tss_struct, x86_tss.ist);
19537 BLANK();
19538
19539 diff --git a/arch/x86/kernel/cpu/Makefile b/arch/x86/kernel/cpu/Makefile
19540 index 47b56a7..efc2bc6 100644
19541 --- a/arch/x86/kernel/cpu/Makefile
19542 +++ b/arch/x86/kernel/cpu/Makefile
19543 @@ -8,10 +8,6 @@ CFLAGS_REMOVE_common.o = -pg
19544 CFLAGS_REMOVE_perf_event.o = -pg
19545 endif
19546
19547 -# Make sure load_percpu_segment has no stackprotector
19548 -nostackp := $(call cc-option, -fno-stack-protector)
19549 -CFLAGS_common.o := $(nostackp)
19550 -
19551 obj-y := intel_cacheinfo.o scattered.o topology.o
19552 obj-y += proc.o capflags.o powerflags.o common.o
19553 obj-y += rdrand.o
19554 diff --git a/arch/x86/kernel/cpu/amd.c b/arch/x86/kernel/cpu/amd.c
19555 index 903a264..fc955f3 100644
19556 --- a/arch/x86/kernel/cpu/amd.c
19557 +++ b/arch/x86/kernel/cpu/amd.c
19558 @@ -743,7 +743,7 @@ static void init_amd(struct cpuinfo_x86 *c)
19559 static unsigned int amd_size_cache(struct cpuinfo_x86 *c, unsigned int size)
19560 {
19561 /* AMD errata T13 (order #21922) */
19562 - if ((c->x86 == 6)) {
19563 + if (c->x86 == 6) {
19564 /* Duron Rev A0 */
19565 if (c->x86_model == 3 && c->x86_mask == 0)
19566 size = 64;
19567 diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c
19568 index 2793d1f..b4f313a 100644
19569 --- a/arch/x86/kernel/cpu/common.c
19570 +++ b/arch/x86/kernel/cpu/common.c
19571 @@ -88,60 +88,6 @@ static const struct cpu_dev default_cpu = {
19572
19573 static const struct cpu_dev *this_cpu = &default_cpu;
19574
19575 -DEFINE_PER_CPU_PAGE_ALIGNED(struct gdt_page, gdt_page) = { .gdt = {
19576 -#ifdef CONFIG_X86_64
19577 - /*
19578 - * We need valid kernel segments for data and code in long mode too
19579 - * IRET will check the segment types kkeil 2000/10/28
19580 - * Also sysret mandates a special GDT layout
19581 - *
19582 - * TLS descriptors are currently at a different place compared to i386.
19583 - * Hopefully nobody expects them at a fixed place (Wine?)
19584 - */
19585 - [GDT_ENTRY_KERNEL32_CS] = GDT_ENTRY_INIT(0xc09b, 0, 0xfffff),
19586 - [GDT_ENTRY_KERNEL_CS] = GDT_ENTRY_INIT(0xa09b, 0, 0xfffff),
19587 - [GDT_ENTRY_KERNEL_DS] = GDT_ENTRY_INIT(0xc093, 0, 0xfffff),
19588 - [GDT_ENTRY_DEFAULT_USER32_CS] = GDT_ENTRY_INIT(0xc0fb, 0, 0xfffff),
19589 - [GDT_ENTRY_DEFAULT_USER_DS] = GDT_ENTRY_INIT(0xc0f3, 0, 0xfffff),
19590 - [GDT_ENTRY_DEFAULT_USER_CS] = GDT_ENTRY_INIT(0xa0fb, 0, 0xfffff),
19591 -#else
19592 - [GDT_ENTRY_KERNEL_CS] = GDT_ENTRY_INIT(0xc09a, 0, 0xfffff),
19593 - [GDT_ENTRY_KERNEL_DS] = GDT_ENTRY_INIT(0xc092, 0, 0xfffff),
19594 - [GDT_ENTRY_DEFAULT_USER_CS] = GDT_ENTRY_INIT(0xc0fa, 0, 0xfffff),
19595 - [GDT_ENTRY_DEFAULT_USER_DS] = GDT_ENTRY_INIT(0xc0f2, 0, 0xfffff),
19596 - /*
19597 - * Segments used for calling PnP BIOS have byte granularity.
19598 - * They code segments and data segments have fixed 64k limits,
19599 - * the transfer segment sizes are set at run time.
19600 - */
19601 - /* 32-bit code */
19602 - [GDT_ENTRY_PNPBIOS_CS32] = GDT_ENTRY_INIT(0x409a, 0, 0xffff),
19603 - /* 16-bit code */
19604 - [GDT_ENTRY_PNPBIOS_CS16] = GDT_ENTRY_INIT(0x009a, 0, 0xffff),
19605 - /* 16-bit data */
19606 - [GDT_ENTRY_PNPBIOS_DS] = GDT_ENTRY_INIT(0x0092, 0, 0xffff),
19607 - /* 16-bit data */
19608 - [GDT_ENTRY_PNPBIOS_TS1] = GDT_ENTRY_INIT(0x0092, 0, 0),
19609 - /* 16-bit data */
19610 - [GDT_ENTRY_PNPBIOS_TS2] = GDT_ENTRY_INIT(0x0092, 0, 0),
19611 - /*
19612 - * The APM segments have byte granularity and their bases
19613 - * are set at run time. All have 64k limits.
19614 - */
19615 - /* 32-bit code */
19616 - [GDT_ENTRY_APMBIOS_BASE] = GDT_ENTRY_INIT(0x409a, 0, 0xffff),
19617 - /* 16-bit code */
19618 - [GDT_ENTRY_APMBIOS_BASE+1] = GDT_ENTRY_INIT(0x009a, 0, 0xffff),
19619 - /* data */
19620 - [GDT_ENTRY_APMBIOS_BASE+2] = GDT_ENTRY_INIT(0x4092, 0, 0xffff),
19621 -
19622 - [GDT_ENTRY_ESPFIX_SS] = GDT_ENTRY_INIT(0xc092, 0, 0xfffff),
19623 - [GDT_ENTRY_PERCPU] = GDT_ENTRY_INIT(0xc092, 0, 0xfffff),
19624 - GDT_STACK_CANARY_INIT
19625 -#endif
19626 -} };
19627 -EXPORT_PER_CPU_SYMBOL_GPL(gdt_page);
19628 -
19629 static int __init x86_xsave_setup(char *s)
19630 {
19631 setup_clear_cpu_cap(X86_FEATURE_XSAVE);
19632 @@ -288,6 +234,59 @@ static __always_inline void setup_smap(struct cpuinfo_x86 *c)
19633 set_in_cr4(X86_CR4_SMAP);
19634 }
19635
19636 +#ifdef CONFIG_X86_64
19637 +static __init int setup_disable_pcid(char *arg)
19638 +{
19639 + setup_clear_cpu_cap(X86_FEATURE_PCID);
19640 + setup_clear_cpu_cap(X86_FEATURE_INVPCID);
19641 +
19642 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19643 + if (clone_pgd_mask != ~(pgdval_t)0UL)
19644 + pax_user_shadow_base = 1UL << TASK_SIZE_MAX_SHIFT;
19645 +#endif
19646 +
19647 + return 1;
19648 +}
19649 +__setup("nopcid", setup_disable_pcid);
19650 +
19651 +static void setup_pcid(struct cpuinfo_x86 *c)
19652 +{
19653 + if (!cpu_has(c, X86_FEATURE_PCID)) {
19654 + clear_cpu_cap(c, X86_FEATURE_INVPCID);
19655 +
19656 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19657 + if (clone_pgd_mask != ~(pgdval_t)0UL) {
19658 + pax_open_kernel();
19659 + pax_user_shadow_base = 1UL << TASK_SIZE_MAX_SHIFT;
19660 + pax_close_kernel();
19661 + printk("PAX: slow and weak UDEREF enabled\n");
19662 + } else
19663 + printk("PAX: UDEREF disabled\n");
19664 +#endif
19665 +
19666 + return;
19667 + }
19668 +
19669 + printk("PAX: PCID detected\n");
19670 + set_in_cr4(X86_CR4_PCIDE);
19671 +
19672 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19673 + pax_open_kernel();
19674 + clone_pgd_mask = ~(pgdval_t)0UL;
19675 + pax_close_kernel();
19676 + if (pax_user_shadow_base)
19677 + printk("PAX: weak UDEREF enabled\n");
19678 + else {
19679 + set_cpu_cap(c, X86_FEATURE_STRONGUDEREF);
19680 + printk("PAX: strong UDEREF enabled\n");
19681 + }
19682 +#endif
19683 +
19684 + if (cpu_has(c, X86_FEATURE_INVPCID))
19685 + printk("PAX: INVPCID detected\n");
19686 +}
19687 +#endif
19688 +
19689 /*
19690 * Some CPU features depend on higher CPUID levels, which may not always
19691 * be available due to CPUID level capping or broken virtualization
19692 @@ -386,7 +385,7 @@ void switch_to_new_gdt(int cpu)
19693 {
19694 struct desc_ptr gdt_descr;
19695
19696 - gdt_descr.address = (long)get_cpu_gdt_table(cpu);
19697 + gdt_descr.address = (unsigned long)get_cpu_gdt_table(cpu);
19698 gdt_descr.size = GDT_SIZE - 1;
19699 load_gdt(&gdt_descr);
19700 /* Reload the per-cpu base */
19701 @@ -875,6 +874,10 @@ static void identify_cpu(struct cpuinfo_x86 *c)
19702 setup_smep(c);
19703 setup_smap(c);
19704
19705 +#ifdef CONFIG_X86_64
19706 + setup_pcid(c);
19707 +#endif
19708 +
19709 /*
19710 * The vendor-specific functions might have changed features.
19711 * Now we do "generic changes."
19712 @@ -883,6 +886,10 @@ static void identify_cpu(struct cpuinfo_x86 *c)
19713 /* Filter out anything that depends on CPUID levels we don't have */
19714 filter_cpuid_features(c, true);
19715
19716 +#if defined(CONFIG_X86_32) && (defined(CONFIG_PAX_SEGMEXEC) || defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF))
19717 + setup_clear_cpu_cap(X86_FEATURE_SEP);
19718 +#endif
19719 +
19720 /* If the model name is still unset, do table lookup. */
19721 if (!c->x86_model_id[0]) {
19722 const char *p;
19723 @@ -1070,10 +1077,12 @@ static __init int setup_disablecpuid(char *arg)
19724 }
19725 __setup("clearcpuid=", setup_disablecpuid);
19726
19727 +DEFINE_PER_CPU(struct thread_info *, current_tinfo) = &init_task.tinfo;
19728 +EXPORT_PER_CPU_SYMBOL(current_tinfo);
19729 +
19730 #ifdef CONFIG_X86_64
19731 -struct desc_ptr idt_descr = { NR_VECTORS * 16 - 1, (unsigned long) idt_table };
19732 -struct desc_ptr debug_idt_descr = { NR_VECTORS * 16 - 1,
19733 - (unsigned long) debug_idt_table };
19734 +struct desc_ptr idt_descr __read_only = { NR_VECTORS * 16 - 1, (unsigned long) idt_table };
19735 +const struct desc_ptr debug_idt_descr = { NR_VECTORS * 16 - 1, (unsigned long) debug_idt_table };
19736
19737 DEFINE_PER_CPU_FIRST(union irq_stack_union,
19738 irq_stack_union) __aligned(PAGE_SIZE) __visible;
19739 @@ -1087,7 +1096,7 @@ DEFINE_PER_CPU(struct task_struct *, current_task) ____cacheline_aligned =
19740 EXPORT_PER_CPU_SYMBOL(current_task);
19741
19742 DEFINE_PER_CPU(unsigned long, kernel_stack) =
19743 - (unsigned long)&init_thread_union - KERNEL_STACK_OFFSET + THREAD_SIZE;
19744 + (unsigned long)&init_thread_union - 16 + THREAD_SIZE;
19745 EXPORT_PER_CPU_SYMBOL(kernel_stack);
19746
19747 DEFINE_PER_CPU(char *, irq_stack_ptr) =
19748 @@ -1232,7 +1241,7 @@ void cpu_init(void)
19749 load_ucode_ap();
19750
19751 cpu = stack_smp_processor_id();
19752 - t = &per_cpu(init_tss, cpu);
19753 + t = init_tss + cpu;
19754 oist = &per_cpu(orig_ist, cpu);
19755
19756 #ifdef CONFIG_NUMA
19757 @@ -1267,7 +1276,6 @@ void cpu_init(void)
19758 wrmsrl(MSR_KERNEL_GS_BASE, 0);
19759 barrier();
19760
19761 - x86_configure_nx();
19762 enable_x2apic();
19763
19764 /*
19765 @@ -1319,7 +1327,7 @@ void cpu_init(void)
19766 {
19767 int cpu = smp_processor_id();
19768 struct task_struct *curr = current;
19769 - struct tss_struct *t = &per_cpu(init_tss, cpu);
19770 + struct tss_struct *t = init_tss + cpu;
19771 struct thread_struct *thread = &curr->thread;
19772
19773 show_ucode_info_early();
19774 diff --git a/arch/x86/kernel/cpu/intel_cacheinfo.c b/arch/x86/kernel/cpu/intel_cacheinfo.c
19775 index 1414c90..1159406 100644
19776 --- a/arch/x86/kernel/cpu/intel_cacheinfo.c
19777 +++ b/arch/x86/kernel/cpu/intel_cacheinfo.c
19778 @@ -1014,6 +1014,22 @@ static struct attribute *default_attrs[] = {
19779 };
19780
19781 #ifdef CONFIG_AMD_NB
19782 +static struct attribute *default_attrs_amd_nb[] = {
19783 + &type.attr,
19784 + &level.attr,
19785 + &coherency_line_size.attr,
19786 + &physical_line_partition.attr,
19787 + &ways_of_associativity.attr,
19788 + &number_of_sets.attr,
19789 + &size.attr,
19790 + &shared_cpu_map.attr,
19791 + &shared_cpu_list.attr,
19792 + NULL,
19793 + NULL,
19794 + NULL,
19795 + NULL
19796 +};
19797 +
19798 static struct attribute **amd_l3_attrs(void)
19799 {
19800 static struct attribute **attrs;
19801 @@ -1024,18 +1040,7 @@ static struct attribute **amd_l3_attrs(void)
19802
19803 n = ARRAY_SIZE(default_attrs);
19804
19805 - if (amd_nb_has_feature(AMD_NB_L3_INDEX_DISABLE))
19806 - n += 2;
19807 -
19808 - if (amd_nb_has_feature(AMD_NB_L3_PARTITIONING))
19809 - n += 1;
19810 -
19811 - attrs = kzalloc(n * sizeof (struct attribute *), GFP_KERNEL);
19812 - if (attrs == NULL)
19813 - return attrs = default_attrs;
19814 -
19815 - for (n = 0; default_attrs[n]; n++)
19816 - attrs[n] = default_attrs[n];
19817 + attrs = default_attrs_amd_nb;
19818
19819 if (amd_nb_has_feature(AMD_NB_L3_INDEX_DISABLE)) {
19820 attrs[n++] = &cache_disable_0.attr;
19821 @@ -1086,6 +1091,13 @@ static struct kobj_type ktype_cache = {
19822 .default_attrs = default_attrs,
19823 };
19824
19825 +#ifdef CONFIG_AMD_NB
19826 +static struct kobj_type ktype_cache_amd_nb = {
19827 + .sysfs_ops = &sysfs_ops,
19828 + .default_attrs = default_attrs_amd_nb,
19829 +};
19830 +#endif
19831 +
19832 static struct kobj_type ktype_percpu_entry = {
19833 .sysfs_ops = &sysfs_ops,
19834 };
19835 @@ -1151,20 +1163,26 @@ static int cache_add_dev(struct device *dev)
19836 return retval;
19837 }
19838
19839 +#ifdef CONFIG_AMD_NB
19840 + amd_l3_attrs();
19841 +#endif
19842 +
19843 for (i = 0; i < num_cache_leaves; i++) {
19844 + struct kobj_type *ktype;
19845 +
19846 this_object = INDEX_KOBJECT_PTR(cpu, i);
19847 this_object->cpu = cpu;
19848 this_object->index = i;
19849
19850 this_leaf = CPUID4_INFO_IDX(cpu, i);
19851
19852 - ktype_cache.default_attrs = default_attrs;
19853 + ktype = &ktype_cache;
19854 #ifdef CONFIG_AMD_NB
19855 if (this_leaf->base.nb)
19856 - ktype_cache.default_attrs = amd_l3_attrs();
19857 + ktype = &ktype_cache_amd_nb;
19858 #endif
19859 retval = kobject_init_and_add(&(this_object->kobj),
19860 - &ktype_cache,
19861 + ktype,
19862 per_cpu(ici_cache_kobject, cpu),
19863 "index%1lu", i);
19864 if (unlikely(retval)) {
19865 diff --git a/arch/x86/kernel/cpu/mcheck/mce.c b/arch/x86/kernel/cpu/mcheck/mce.c
19866 index b3218cd..99a75de 100644
19867 --- a/arch/x86/kernel/cpu/mcheck/mce.c
19868 +++ b/arch/x86/kernel/cpu/mcheck/mce.c
19869 @@ -45,6 +45,7 @@
19870 #include <asm/processor.h>
19871 #include <asm/mce.h>
19872 #include <asm/msr.h>
19873 +#include <asm/local.h>
19874
19875 #include "mce-internal.h"
19876
19877 @@ -258,7 +259,7 @@ static void print_mce(struct mce *m)
19878 !(m->mcgstatus & MCG_STATUS_EIPV) ? " !INEXACT!" : "",
19879 m->cs, m->ip);
19880
19881 - if (m->cs == __KERNEL_CS)
19882 + if (m->cs == __KERNEL_CS || m->cs == __KERNEXEC_KERNEL_CS)
19883 print_symbol("{%s}", m->ip);
19884 pr_cont("\n");
19885 }
19886 @@ -291,10 +292,10 @@ static void print_mce(struct mce *m)
19887
19888 #define PANIC_TIMEOUT 5 /* 5 seconds */
19889
19890 -static atomic_t mce_paniced;
19891 +static atomic_unchecked_t mce_paniced;
19892
19893 static int fake_panic;
19894 -static atomic_t mce_fake_paniced;
19895 +static atomic_unchecked_t mce_fake_paniced;
19896
19897 /* Panic in progress. Enable interrupts and wait for final IPI */
19898 static void wait_for_panic(void)
19899 @@ -318,7 +319,7 @@ static void mce_panic(char *msg, struct mce *final, char *exp)
19900 /*
19901 * Make sure only one CPU runs in machine check panic
19902 */
19903 - if (atomic_inc_return(&mce_paniced) > 1)
19904 + if (atomic_inc_return_unchecked(&mce_paniced) > 1)
19905 wait_for_panic();
19906 barrier();
19907
19908 @@ -326,7 +327,7 @@ static void mce_panic(char *msg, struct mce *final, char *exp)
19909 console_verbose();
19910 } else {
19911 /* Don't log too much for fake panic */
19912 - if (atomic_inc_return(&mce_fake_paniced) > 1)
19913 + if (atomic_inc_return_unchecked(&mce_fake_paniced) > 1)
19914 return;
19915 }
19916 /* First print corrected ones that are still unlogged */
19917 @@ -365,7 +366,7 @@ static void mce_panic(char *msg, struct mce *final, char *exp)
19918 if (!fake_panic) {
19919 if (panic_timeout == 0)
19920 panic_timeout = mca_cfg.panic_timeout;
19921 - panic(msg);
19922 + panic("%s", msg);
19923 } else
19924 pr_emerg(HW_ERR "Fake kernel panic: %s\n", msg);
19925 }
19926 @@ -695,7 +696,7 @@ static int mce_timed_out(u64 *t)
19927 * might have been modified by someone else.
19928 */
19929 rmb();
19930 - if (atomic_read(&mce_paniced))
19931 + if (atomic_read_unchecked(&mce_paniced))
19932 wait_for_panic();
19933 if (!mca_cfg.monarch_timeout)
19934 goto out;
19935 @@ -1666,7 +1667,7 @@ static void unexpected_machine_check(struct pt_regs *regs, long error_code)
19936 }
19937
19938 /* Call the installed machine check handler for this CPU setup. */
19939 -void (*machine_check_vector)(struct pt_regs *, long error_code) =
19940 +void (*machine_check_vector)(struct pt_regs *, long error_code) __read_only =
19941 unexpected_machine_check;
19942
19943 /*
19944 @@ -1689,7 +1690,9 @@ void mcheck_cpu_init(struct cpuinfo_x86 *c)
19945 return;
19946 }
19947
19948 + pax_open_kernel();
19949 machine_check_vector = do_machine_check;
19950 + pax_close_kernel();
19951
19952 __mcheck_cpu_init_generic();
19953 __mcheck_cpu_init_vendor(c);
19954 @@ -1703,7 +1706,7 @@ void mcheck_cpu_init(struct cpuinfo_x86 *c)
19955 */
19956
19957 static DEFINE_SPINLOCK(mce_chrdev_state_lock);
19958 -static int mce_chrdev_open_count; /* #times opened */
19959 +static local_t mce_chrdev_open_count; /* #times opened */
19960 static int mce_chrdev_open_exclu; /* already open exclusive? */
19961
19962 static int mce_chrdev_open(struct inode *inode, struct file *file)
19963 @@ -1711,7 +1714,7 @@ static int mce_chrdev_open(struct inode *inode, struct file *file)
19964 spin_lock(&mce_chrdev_state_lock);
19965
19966 if (mce_chrdev_open_exclu ||
19967 - (mce_chrdev_open_count && (file->f_flags & O_EXCL))) {
19968 + (local_read(&mce_chrdev_open_count) && (file->f_flags & O_EXCL))) {
19969 spin_unlock(&mce_chrdev_state_lock);
19970
19971 return -EBUSY;
19972 @@ -1719,7 +1722,7 @@ static int mce_chrdev_open(struct inode *inode, struct file *file)
19973
19974 if (file->f_flags & O_EXCL)
19975 mce_chrdev_open_exclu = 1;
19976 - mce_chrdev_open_count++;
19977 + local_inc(&mce_chrdev_open_count);
19978
19979 spin_unlock(&mce_chrdev_state_lock);
19980
19981 @@ -1730,7 +1733,7 @@ static int mce_chrdev_release(struct inode *inode, struct file *file)
19982 {
19983 spin_lock(&mce_chrdev_state_lock);
19984
19985 - mce_chrdev_open_count--;
19986 + local_dec(&mce_chrdev_open_count);
19987 mce_chrdev_open_exclu = 0;
19988
19989 spin_unlock(&mce_chrdev_state_lock);
19990 @@ -2404,7 +2407,7 @@ static __init void mce_init_banks(void)
19991
19992 for (i = 0; i < mca_cfg.banks; i++) {
19993 struct mce_bank *b = &mce_banks[i];
19994 - struct device_attribute *a = &b->attr;
19995 + device_attribute_no_const *a = &b->attr;
19996
19997 sysfs_attr_init(&a->attr);
19998 a->attr.name = b->attrname;
19999 @@ -2472,7 +2475,7 @@ struct dentry *mce_get_debugfs_dir(void)
20000 static void mce_reset(void)
20001 {
20002 cpu_missing = 0;
20003 - atomic_set(&mce_fake_paniced, 0);
20004 + atomic_set_unchecked(&mce_fake_paniced, 0);
20005 atomic_set(&mce_executing, 0);
20006 atomic_set(&mce_callin, 0);
20007 atomic_set(&global_nwo, 0);
20008 diff --git a/arch/x86/kernel/cpu/mcheck/p5.c b/arch/x86/kernel/cpu/mcheck/p5.c
20009 index 1c044b1..37a2a43 100644
20010 --- a/arch/x86/kernel/cpu/mcheck/p5.c
20011 +++ b/arch/x86/kernel/cpu/mcheck/p5.c
20012 @@ -11,6 +11,7 @@
20013 #include <asm/processor.h>
20014 #include <asm/mce.h>
20015 #include <asm/msr.h>
20016 +#include <asm/pgtable.h>
20017
20018 /* By default disabled */
20019 int mce_p5_enabled __read_mostly;
20020 @@ -49,7 +50,9 @@ void intel_p5_mcheck_init(struct cpuinfo_x86 *c)
20021 if (!cpu_has(c, X86_FEATURE_MCE))
20022 return;
20023
20024 + pax_open_kernel();
20025 machine_check_vector = pentium_machine_check;
20026 + pax_close_kernel();
20027 /* Make sure the vector pointer is visible before we enable MCEs: */
20028 wmb();
20029
20030 diff --git a/arch/x86/kernel/cpu/mcheck/winchip.c b/arch/x86/kernel/cpu/mcheck/winchip.c
20031 index e9a701a..35317d6 100644
20032 --- a/arch/x86/kernel/cpu/mcheck/winchip.c
20033 +++ b/arch/x86/kernel/cpu/mcheck/winchip.c
20034 @@ -10,6 +10,7 @@
20035 #include <asm/processor.h>
20036 #include <asm/mce.h>
20037 #include <asm/msr.h>
20038 +#include <asm/pgtable.h>
20039
20040 /* Machine check handler for WinChip C6: */
20041 static void winchip_machine_check(struct pt_regs *regs, long error_code)
20042 @@ -23,7 +24,9 @@ void winchip_mcheck_init(struct cpuinfo_x86 *c)
20043 {
20044 u32 lo, hi;
20045
20046 + pax_open_kernel();
20047 machine_check_vector = winchip_machine_check;
20048 + pax_close_kernel();
20049 /* Make sure the vector pointer is visible before we enable MCEs: */
20050 wmb();
20051
20052 diff --git a/arch/x86/kernel/cpu/mtrr/main.c b/arch/x86/kernel/cpu/mtrr/main.c
20053 index f961de9..8a9d332 100644
20054 --- a/arch/x86/kernel/cpu/mtrr/main.c
20055 +++ b/arch/x86/kernel/cpu/mtrr/main.c
20056 @@ -66,7 +66,7 @@ static DEFINE_MUTEX(mtrr_mutex);
20057 u64 size_or_mask, size_and_mask;
20058 static bool mtrr_aps_delayed_init;
20059
20060 -static const struct mtrr_ops *mtrr_ops[X86_VENDOR_NUM];
20061 +static const struct mtrr_ops *mtrr_ops[X86_VENDOR_NUM] __read_only;
20062
20063 const struct mtrr_ops *mtrr_if;
20064
20065 diff --git a/arch/x86/kernel/cpu/mtrr/mtrr.h b/arch/x86/kernel/cpu/mtrr/mtrr.h
20066 index df5e41f..816c719 100644
20067 --- a/arch/x86/kernel/cpu/mtrr/mtrr.h
20068 +++ b/arch/x86/kernel/cpu/mtrr/mtrr.h
20069 @@ -25,7 +25,7 @@ struct mtrr_ops {
20070 int (*validate_add_page)(unsigned long base, unsigned long size,
20071 unsigned int type);
20072 int (*have_wrcomb)(void);
20073 -};
20074 +} __do_const;
20075
20076 extern int generic_get_free_region(unsigned long base, unsigned long size,
20077 int replace_reg);
20078 diff --git a/arch/x86/kernel/cpu/perf_event.c b/arch/x86/kernel/cpu/perf_event.c
20079 index 8a87a32..682a22a 100644
20080 --- a/arch/x86/kernel/cpu/perf_event.c
20081 +++ b/arch/x86/kernel/cpu/perf_event.c
20082 @@ -1348,7 +1348,7 @@ static void __init pmu_check_apic(void)
20083 pr_info("no hardware sampling interrupt available.\n");
20084 }
20085
20086 -static struct attribute_group x86_pmu_format_group = {
20087 +static attribute_group_no_const x86_pmu_format_group = {
20088 .name = "format",
20089 .attrs = NULL,
20090 };
20091 @@ -1447,7 +1447,7 @@ static struct attribute *events_attr[] = {
20092 NULL,
20093 };
20094
20095 -static struct attribute_group x86_pmu_events_group = {
20096 +static attribute_group_no_const x86_pmu_events_group = {
20097 .name = "events",
20098 .attrs = events_attr,
20099 };
20100 @@ -1958,7 +1958,7 @@ static unsigned long get_segment_base(unsigned int segment)
20101 if (idx > GDT_ENTRIES)
20102 return 0;
20103
20104 - desc = __this_cpu_ptr(&gdt_page.gdt[0]);
20105 + desc = get_cpu_gdt_table(smp_processor_id());
20106 }
20107
20108 return get_desc_base(desc + idx);
20109 @@ -2048,7 +2048,7 @@ perf_callchain_user(struct perf_callchain_entry *entry, struct pt_regs *regs)
20110 break;
20111
20112 perf_callchain_store(entry, frame.return_address);
20113 - fp = frame.next_frame;
20114 + fp = (const void __force_user *)frame.next_frame;
20115 }
20116 }
20117
20118 diff --git a/arch/x86/kernel/cpu/perf_event_amd_iommu.c b/arch/x86/kernel/cpu/perf_event_amd_iommu.c
20119 index 639d128..e92d7e5 100644
20120 --- a/arch/x86/kernel/cpu/perf_event_amd_iommu.c
20121 +++ b/arch/x86/kernel/cpu/perf_event_amd_iommu.c
20122 @@ -405,7 +405,7 @@ static void perf_iommu_del(struct perf_event *event, int flags)
20123 static __init int _init_events_attrs(struct perf_amd_iommu *perf_iommu)
20124 {
20125 struct attribute **attrs;
20126 - struct attribute_group *attr_group;
20127 + attribute_group_no_const *attr_group;
20128 int i = 0, j;
20129
20130 while (amd_iommu_v2_event_descs[i].attr.attr.name)
20131 diff --git a/arch/x86/kernel/cpu/perf_event_intel.c b/arch/x86/kernel/cpu/perf_event_intel.c
20132 index f31a165..7b46cd8 100644
20133 --- a/arch/x86/kernel/cpu/perf_event_intel.c
20134 +++ b/arch/x86/kernel/cpu/perf_event_intel.c
20135 @@ -2247,10 +2247,10 @@ __init int intel_pmu_init(void)
20136 * v2 and above have a perf capabilities MSR
20137 */
20138 if (version > 1) {
20139 - u64 capabilities;
20140 + u64 capabilities = x86_pmu.intel_cap.capabilities;
20141
20142 - rdmsrl(MSR_IA32_PERF_CAPABILITIES, capabilities);
20143 - x86_pmu.intel_cap.capabilities = capabilities;
20144 + if (rdmsrl_safe(MSR_IA32_PERF_CAPABILITIES, &x86_pmu.intel_cap.capabilities))
20145 + x86_pmu.intel_cap.capabilities = capabilities;
20146 }
20147
20148 intel_ds_init();
20149 diff --git a/arch/x86/kernel/cpu/perf_event_intel_uncore.c b/arch/x86/kernel/cpu/perf_event_intel_uncore.c
20150 index 4118f9f..f91d0ab 100644
20151 --- a/arch/x86/kernel/cpu/perf_event_intel_uncore.c
20152 +++ b/arch/x86/kernel/cpu/perf_event_intel_uncore.c
20153 @@ -3204,7 +3204,7 @@ static void __init uncore_types_exit(struct intel_uncore_type **types)
20154 static int __init uncore_type_init(struct intel_uncore_type *type)
20155 {
20156 struct intel_uncore_pmu *pmus;
20157 - struct attribute_group *attr_group;
20158 + attribute_group_no_const *attr_group;
20159 struct attribute **attrs;
20160 int i, j;
20161
20162 diff --git a/arch/x86/kernel/cpu/perf_event_intel_uncore.h b/arch/x86/kernel/cpu/perf_event_intel_uncore.h
20163 index a80ab71..4089da5 100644
20164 --- a/arch/x86/kernel/cpu/perf_event_intel_uncore.h
20165 +++ b/arch/x86/kernel/cpu/perf_event_intel_uncore.h
20166 @@ -498,7 +498,7 @@ struct intel_uncore_box {
20167 struct uncore_event_desc {
20168 struct kobj_attribute attr;
20169 const char *config;
20170 -};
20171 +} __do_const;
20172
20173 #define INTEL_UNCORE_EVENT_DESC(_name, _config) \
20174 { \
20175 diff --git a/arch/x86/kernel/cpuid.c b/arch/x86/kernel/cpuid.c
20176 index 7d9481c..99c7e4b 100644
20177 --- a/arch/x86/kernel/cpuid.c
20178 +++ b/arch/x86/kernel/cpuid.c
20179 @@ -170,7 +170,7 @@ static int cpuid_class_cpu_callback(struct notifier_block *nfb,
20180 return notifier_from_errno(err);
20181 }
20182
20183 -static struct notifier_block __refdata cpuid_class_cpu_notifier =
20184 +static struct notifier_block cpuid_class_cpu_notifier =
20185 {
20186 .notifier_call = cpuid_class_cpu_callback,
20187 };
20188 diff --git a/arch/x86/kernel/crash.c b/arch/x86/kernel/crash.c
20189 index 18677a9..f67c45b 100644
20190 --- a/arch/x86/kernel/crash.c
20191 +++ b/arch/x86/kernel/crash.c
20192 @@ -58,10 +58,8 @@ static void kdump_nmi_callback(int cpu, struct pt_regs *regs)
20193 {
20194 #ifdef CONFIG_X86_32
20195 struct pt_regs fixed_regs;
20196 -#endif
20197
20198 -#ifdef CONFIG_X86_32
20199 - if (!user_mode_vm(regs)) {
20200 + if (!user_mode(regs)) {
20201 crash_fixup_ss_esp(&fixed_regs, regs);
20202 regs = &fixed_regs;
20203 }
20204 diff --git a/arch/x86/kernel/crash_dump_64.c b/arch/x86/kernel/crash_dump_64.c
20205 index afa64ad..dce67dd 100644
20206 --- a/arch/x86/kernel/crash_dump_64.c
20207 +++ b/arch/x86/kernel/crash_dump_64.c
20208 @@ -36,7 +36,7 @@ ssize_t copy_oldmem_page(unsigned long pfn, char *buf,
20209 return -ENOMEM;
20210
20211 if (userbuf) {
20212 - if (copy_to_user(buf, vaddr + offset, csize)) {
20213 + if (copy_to_user((char __force_user *)buf, vaddr + offset, csize)) {
20214 iounmap(vaddr);
20215 return -EFAULT;
20216 }
20217 diff --git a/arch/x86/kernel/doublefault.c b/arch/x86/kernel/doublefault.c
20218 index 5d3fe8d..02e1429 100644
20219 --- a/arch/x86/kernel/doublefault.c
20220 +++ b/arch/x86/kernel/doublefault.c
20221 @@ -13,7 +13,7 @@
20222
20223 #define DOUBLEFAULT_STACKSIZE (1024)
20224 static unsigned long doublefault_stack[DOUBLEFAULT_STACKSIZE];
20225 -#define STACK_START (unsigned long)(doublefault_stack+DOUBLEFAULT_STACKSIZE)
20226 +#define STACK_START (unsigned long)(doublefault_stack+DOUBLEFAULT_STACKSIZE-2)
20227
20228 #define ptr_ok(x) ((x) > PAGE_OFFSET && (x) < PAGE_OFFSET + MAXMEM)
20229
20230 @@ -23,7 +23,7 @@ static void doublefault_fn(void)
20231 unsigned long gdt, tss;
20232
20233 native_store_gdt(&gdt_desc);
20234 - gdt = gdt_desc.address;
20235 + gdt = (unsigned long)gdt_desc.address;
20236
20237 printk(KERN_EMERG "PANIC: double fault, gdt at %08lx [%d bytes]\n", gdt, gdt_desc.size);
20238
20239 @@ -60,10 +60,10 @@ struct tss_struct doublefault_tss __cacheline_aligned = {
20240 /* 0x2 bit is always set */
20241 .flags = X86_EFLAGS_SF | 0x2,
20242 .sp = STACK_START,
20243 - .es = __USER_DS,
20244 + .es = __KERNEL_DS,
20245 .cs = __KERNEL_CS,
20246 .ss = __KERNEL_DS,
20247 - .ds = __USER_DS,
20248 + .ds = __KERNEL_DS,
20249 .fs = __KERNEL_PERCPU,
20250
20251 .__cr3 = __pa_nodebug(swapper_pg_dir),
20252 diff --git a/arch/x86/kernel/dumpstack.c b/arch/x86/kernel/dumpstack.c
20253 index deb6421..76bbc12 100644
20254 --- a/arch/x86/kernel/dumpstack.c
20255 +++ b/arch/x86/kernel/dumpstack.c
20256 @@ -2,6 +2,9 @@
20257 * Copyright (C) 1991, 1992 Linus Torvalds
20258 * Copyright (C) 2000, 2001, 2002 Andi Kleen, SuSE Labs
20259 */
20260 +#ifdef CONFIG_GRKERNSEC_HIDESYM
20261 +#define __INCLUDED_BY_HIDESYM 1
20262 +#endif
20263 #include <linux/kallsyms.h>
20264 #include <linux/kprobes.h>
20265 #include <linux/uaccess.h>
20266 @@ -35,16 +38,14 @@ void printk_address(unsigned long address, int reliable)
20267 static void
20268 print_ftrace_graph_addr(unsigned long addr, void *data,
20269 const struct stacktrace_ops *ops,
20270 - struct thread_info *tinfo, int *graph)
20271 + struct task_struct *task, int *graph)
20272 {
20273 - struct task_struct *task;
20274 unsigned long ret_addr;
20275 int index;
20276
20277 if (addr != (unsigned long)return_to_handler)
20278 return;
20279
20280 - task = tinfo->task;
20281 index = task->curr_ret_stack;
20282
20283 if (!task->ret_stack || index < *graph)
20284 @@ -61,7 +62,7 @@ print_ftrace_graph_addr(unsigned long addr, void *data,
20285 static inline void
20286 print_ftrace_graph_addr(unsigned long addr, void *data,
20287 const struct stacktrace_ops *ops,
20288 - struct thread_info *tinfo, int *graph)
20289 + struct task_struct *task, int *graph)
20290 { }
20291 #endif
20292
20293 @@ -72,10 +73,8 @@ print_ftrace_graph_addr(unsigned long addr, void *data,
20294 * severe exception (double fault, nmi, stack fault, debug, mce) hardware stack
20295 */
20296
20297 -static inline int valid_stack_ptr(struct thread_info *tinfo,
20298 - void *p, unsigned int size, void *end)
20299 +static inline int valid_stack_ptr(void *t, void *p, unsigned int size, void *end)
20300 {
20301 - void *t = tinfo;
20302 if (end) {
20303 if (p < end && p >= (end-THREAD_SIZE))
20304 return 1;
20305 @@ -86,14 +85,14 @@ static inline int valid_stack_ptr(struct thread_info *tinfo,
20306 }
20307
20308 unsigned long
20309 -print_context_stack(struct thread_info *tinfo,
20310 +print_context_stack(struct task_struct *task, void *stack_start,
20311 unsigned long *stack, unsigned long bp,
20312 const struct stacktrace_ops *ops, void *data,
20313 unsigned long *end, int *graph)
20314 {
20315 struct stack_frame *frame = (struct stack_frame *)bp;
20316
20317 - while (valid_stack_ptr(tinfo, stack, sizeof(*stack), end)) {
20318 + while (valid_stack_ptr(stack_start, stack, sizeof(*stack), end)) {
20319 unsigned long addr;
20320
20321 addr = *stack;
20322 @@ -105,7 +104,7 @@ print_context_stack(struct thread_info *tinfo,
20323 } else {
20324 ops->address(data, addr, 0);
20325 }
20326 - print_ftrace_graph_addr(addr, data, ops, tinfo, graph);
20327 + print_ftrace_graph_addr(addr, data, ops, task, graph);
20328 }
20329 stack++;
20330 }
20331 @@ -114,7 +113,7 @@ print_context_stack(struct thread_info *tinfo,
20332 EXPORT_SYMBOL_GPL(print_context_stack);
20333
20334 unsigned long
20335 -print_context_stack_bp(struct thread_info *tinfo,
20336 +print_context_stack_bp(struct task_struct *task, void *stack_start,
20337 unsigned long *stack, unsigned long bp,
20338 const struct stacktrace_ops *ops, void *data,
20339 unsigned long *end, int *graph)
20340 @@ -122,7 +121,7 @@ print_context_stack_bp(struct thread_info *tinfo,
20341 struct stack_frame *frame = (struct stack_frame *)bp;
20342 unsigned long *ret_addr = &frame->return_address;
20343
20344 - while (valid_stack_ptr(tinfo, ret_addr, sizeof(*ret_addr), end)) {
20345 + while (valid_stack_ptr(stack_start, ret_addr, sizeof(*ret_addr), end)) {
20346 unsigned long addr = *ret_addr;
20347
20348 if (!__kernel_text_address(addr))
20349 @@ -131,7 +130,7 @@ print_context_stack_bp(struct thread_info *tinfo,
20350 ops->address(data, addr, 1);
20351 frame = frame->next_frame;
20352 ret_addr = &frame->return_address;
20353 - print_ftrace_graph_addr(addr, data, ops, tinfo, graph);
20354 + print_ftrace_graph_addr(addr, data, ops, task, graph);
20355 }
20356
20357 return (unsigned long)frame;
20358 @@ -150,7 +149,7 @@ static int print_trace_stack(void *data, char *name)
20359 static void print_trace_address(void *data, unsigned long addr, int reliable)
20360 {
20361 touch_nmi_watchdog();
20362 - printk(data);
20363 + printk("%s", (char *)data);
20364 printk_address(addr, reliable);
20365 }
20366
20367 @@ -219,6 +218,8 @@ unsigned __kprobes long oops_begin(void)
20368 }
20369 EXPORT_SYMBOL_GPL(oops_begin);
20370
20371 +extern void gr_handle_kernel_exploit(void);
20372 +
20373 void __kprobes oops_end(unsigned long flags, struct pt_regs *regs, int signr)
20374 {
20375 if (regs && kexec_should_crash(current))
20376 @@ -240,7 +241,10 @@ void __kprobes oops_end(unsigned long flags, struct pt_regs *regs, int signr)
20377 panic("Fatal exception in interrupt");
20378 if (panic_on_oops)
20379 panic("Fatal exception");
20380 - do_exit(signr);
20381 +
20382 + gr_handle_kernel_exploit();
20383 +
20384 + do_group_exit(signr);
20385 }
20386
20387 int __kprobes __die(const char *str, struct pt_regs *regs, long err)
20388 @@ -268,7 +272,7 @@ int __kprobes __die(const char *str, struct pt_regs *regs, long err)
20389 print_modules();
20390 show_regs(regs);
20391 #ifdef CONFIG_X86_32
20392 - if (user_mode_vm(regs)) {
20393 + if (user_mode(regs)) {
20394 sp = regs->sp;
20395 ss = regs->ss & 0xffff;
20396 } else {
20397 @@ -296,7 +300,7 @@ void die(const char *str, struct pt_regs *regs, long err)
20398 unsigned long flags = oops_begin();
20399 int sig = SIGSEGV;
20400
20401 - if (!user_mode_vm(regs))
20402 + if (!user_mode(regs))
20403 report_bug(regs->ip, regs);
20404
20405 if (__die(str, regs, err))
20406 diff --git a/arch/x86/kernel/dumpstack_32.c b/arch/x86/kernel/dumpstack_32.c
20407 index f2a1770..540657f 100644
20408 --- a/arch/x86/kernel/dumpstack_32.c
20409 +++ b/arch/x86/kernel/dumpstack_32.c
20410 @@ -38,15 +38,13 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
20411 bp = stack_frame(task, regs);
20412
20413 for (;;) {
20414 - struct thread_info *context;
20415 + void *stack_start = (void *)((unsigned long)stack & ~(THREAD_SIZE-1));
20416
20417 - context = (struct thread_info *)
20418 - ((unsigned long)stack & (~(THREAD_SIZE - 1)));
20419 - bp = ops->walk_stack(context, stack, bp, ops, data, NULL, &graph);
20420 + bp = ops->walk_stack(task, stack_start, stack, bp, ops, data, NULL, &graph);
20421
20422 - stack = (unsigned long *)context->previous_esp;
20423 - if (!stack)
20424 + if (stack_start == task_stack_page(task))
20425 break;
20426 + stack = *(unsigned long **)stack_start;
20427 if (ops->stack(data, "IRQ") < 0)
20428 break;
20429 touch_nmi_watchdog();
20430 @@ -87,27 +85,28 @@ void show_regs(struct pt_regs *regs)
20431 int i;
20432
20433 show_regs_print_info(KERN_EMERG);
20434 - __show_regs(regs, !user_mode_vm(regs));
20435 + __show_regs(regs, !user_mode(regs));
20436
20437 /*
20438 * When in-kernel, we also print out the stack and code at the
20439 * time of the fault..
20440 */
20441 - if (!user_mode_vm(regs)) {
20442 + if (!user_mode(regs)) {
20443 unsigned int code_prologue = code_bytes * 43 / 64;
20444 unsigned int code_len = code_bytes;
20445 unsigned char c;
20446 u8 *ip;
20447 + unsigned long cs_base = get_desc_base(&get_cpu_gdt_table(0)[(0xffff & regs->cs) >> 3]);
20448
20449 pr_emerg("Stack:\n");
20450 show_stack_log_lvl(NULL, regs, &regs->sp, 0, KERN_EMERG);
20451
20452 pr_emerg("Code:");
20453
20454 - ip = (u8 *)regs->ip - code_prologue;
20455 + ip = (u8 *)regs->ip - code_prologue + cs_base;
20456 if (ip < (u8 *)PAGE_OFFSET || probe_kernel_address(ip, c)) {
20457 /* try starting at IP */
20458 - ip = (u8 *)regs->ip;
20459 + ip = (u8 *)regs->ip + cs_base;
20460 code_len = code_len - code_prologue + 1;
20461 }
20462 for (i = 0; i < code_len; i++, ip++) {
20463 @@ -116,7 +115,7 @@ void show_regs(struct pt_regs *regs)
20464 pr_cont(" Bad EIP value.");
20465 break;
20466 }
20467 - if (ip == (u8 *)regs->ip)
20468 + if (ip == (u8 *)regs->ip + cs_base)
20469 pr_cont(" <%02x>", c);
20470 else
20471 pr_cont(" %02x", c);
20472 @@ -129,6 +128,7 @@ int is_valid_bugaddr(unsigned long ip)
20473 {
20474 unsigned short ud2;
20475
20476 + ip = ktla_ktva(ip);
20477 if (ip < PAGE_OFFSET)
20478 return 0;
20479 if (probe_kernel_address((unsigned short *)ip, ud2))
20480 @@ -136,3 +136,15 @@ int is_valid_bugaddr(unsigned long ip)
20481
20482 return ud2 == 0x0b0f;
20483 }
20484 +
20485 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
20486 +void pax_check_alloca(unsigned long size)
20487 +{
20488 + unsigned long sp = (unsigned long)&sp, stack_left;
20489 +
20490 + /* all kernel stacks are of the same size */
20491 + stack_left = sp & (THREAD_SIZE - 1);
20492 + BUG_ON(stack_left < 256 || size >= stack_left - 256);
20493 +}
20494 +EXPORT_SYMBOL(pax_check_alloca);
20495 +#endif
20496 diff --git a/arch/x86/kernel/dumpstack_64.c b/arch/x86/kernel/dumpstack_64.c
20497 index addb207..99635fa 100644
20498 --- a/arch/x86/kernel/dumpstack_64.c
20499 +++ b/arch/x86/kernel/dumpstack_64.c
20500 @@ -119,9 +119,9 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
20501 unsigned long *irq_stack_end =
20502 (unsigned long *)per_cpu(irq_stack_ptr, cpu);
20503 unsigned used = 0;
20504 - struct thread_info *tinfo;
20505 int graph = 0;
20506 unsigned long dummy;
20507 + void *stack_start;
20508
20509 if (!task)
20510 task = current;
20511 @@ -142,10 +142,10 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
20512 * current stack address. If the stacks consist of nested
20513 * exceptions
20514 */
20515 - tinfo = task_thread_info(task);
20516 for (;;) {
20517 char *id;
20518 unsigned long *estack_end;
20519 +
20520 estack_end = in_exception_stack(cpu, (unsigned long)stack,
20521 &used, &id);
20522
20523 @@ -153,7 +153,7 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
20524 if (ops->stack(data, id) < 0)
20525 break;
20526
20527 - bp = ops->walk_stack(tinfo, stack, bp, ops,
20528 + bp = ops->walk_stack(task, estack_end - EXCEPTION_STKSZ, stack, bp, ops,
20529 data, estack_end, &graph);
20530 ops->stack(data, "<EOE>");
20531 /*
20532 @@ -161,6 +161,8 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
20533 * second-to-last pointer (index -2 to end) in the
20534 * exception stack:
20535 */
20536 + if ((u16)estack_end[-1] != __KERNEL_DS)
20537 + goto out;
20538 stack = (unsigned long *) estack_end[-2];
20539 continue;
20540 }
20541 @@ -172,7 +174,7 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
20542 if (in_irq_stack(stack, irq_stack, irq_stack_end)) {
20543 if (ops->stack(data, "IRQ") < 0)
20544 break;
20545 - bp = ops->walk_stack(tinfo, stack, bp,
20546 + bp = ops->walk_stack(task, irq_stack, stack, bp,
20547 ops, data, irq_stack_end, &graph);
20548 /*
20549 * We link to the next stack (which would be
20550 @@ -191,7 +193,9 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
20551 /*
20552 * This handles the process stack:
20553 */
20554 - bp = ops->walk_stack(tinfo, stack, bp, ops, data, NULL, &graph);
20555 + stack_start = (void *)((unsigned long)stack & ~(THREAD_SIZE-1));
20556 + bp = ops->walk_stack(task, stack_start, stack, bp, ops, data, NULL, &graph);
20557 +out:
20558 put_cpu();
20559 }
20560 EXPORT_SYMBOL(dump_trace);
20561 @@ -300,3 +304,50 @@ int is_valid_bugaddr(unsigned long ip)
20562
20563 return ud2 == 0x0b0f;
20564 }
20565 +
20566 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
20567 +void pax_check_alloca(unsigned long size)
20568 +{
20569 + unsigned long sp = (unsigned long)&sp, stack_start, stack_end;
20570 + unsigned cpu, used;
20571 + char *id;
20572 +
20573 + /* check the process stack first */
20574 + stack_start = (unsigned long)task_stack_page(current);
20575 + stack_end = stack_start + THREAD_SIZE;
20576 + if (likely(stack_start <= sp && sp < stack_end)) {
20577 + unsigned long stack_left = sp & (THREAD_SIZE - 1);
20578 + BUG_ON(stack_left < 256 || size >= stack_left - 256);
20579 + return;
20580 + }
20581 +
20582 + cpu = get_cpu();
20583 +
20584 + /* check the irq stacks */
20585 + stack_end = (unsigned long)per_cpu(irq_stack_ptr, cpu);
20586 + stack_start = stack_end - IRQ_STACK_SIZE;
20587 + if (stack_start <= sp && sp < stack_end) {
20588 + unsigned long stack_left = sp & (IRQ_STACK_SIZE - 1);
20589 + put_cpu();
20590 + BUG_ON(stack_left < 256 || size >= stack_left - 256);
20591 + return;
20592 + }
20593 +
20594 + /* check the exception stacks */
20595 + used = 0;
20596 + stack_end = (unsigned long)in_exception_stack(cpu, sp, &used, &id);
20597 + stack_start = stack_end - EXCEPTION_STKSZ;
20598 + if (stack_end && stack_start <= sp && sp < stack_end) {
20599 + unsigned long stack_left = sp & (EXCEPTION_STKSZ - 1);
20600 + put_cpu();
20601 + BUG_ON(stack_left < 256 || size >= stack_left - 256);
20602 + return;
20603 + }
20604 +
20605 + put_cpu();
20606 +
20607 + /* unknown stack */
20608 + BUG();
20609 +}
20610 +EXPORT_SYMBOL(pax_check_alloca);
20611 +#endif
20612 diff --git a/arch/x86/kernel/e820.c b/arch/x86/kernel/e820.c
20613 index 174da5f..5e55606 100644
20614 --- a/arch/x86/kernel/e820.c
20615 +++ b/arch/x86/kernel/e820.c
20616 @@ -803,8 +803,8 @@ unsigned long __init e820_end_of_low_ram_pfn(void)
20617
20618 static void early_panic(char *msg)
20619 {
20620 - early_printk(msg);
20621 - panic(msg);
20622 + early_printk("%s", msg);
20623 + panic("%s", msg);
20624 }
20625
20626 static int userdef __initdata;
20627 diff --git a/arch/x86/kernel/early_printk.c b/arch/x86/kernel/early_printk.c
20628 index d15f575..d692043 100644
20629 --- a/arch/x86/kernel/early_printk.c
20630 +++ b/arch/x86/kernel/early_printk.c
20631 @@ -7,6 +7,7 @@
20632 #include <linux/pci_regs.h>
20633 #include <linux/pci_ids.h>
20634 #include <linux/errno.h>
20635 +#include <linux/sched.h>
20636 #include <asm/io.h>
20637 #include <asm/processor.h>
20638 #include <asm/fcntl.h>
20639 diff --git a/arch/x86/kernel/entry_32.S b/arch/x86/kernel/entry_32.S
20640 index f0dcb0c..9f39b80 100644
20641 --- a/arch/x86/kernel/entry_32.S
20642 +++ b/arch/x86/kernel/entry_32.S
20643 @@ -177,13 +177,153 @@
20644 /*CFI_REL_OFFSET gs, PT_GS*/
20645 .endm
20646 .macro SET_KERNEL_GS reg
20647 +
20648 +#ifdef CONFIG_CC_STACKPROTECTOR
20649 movl $(__KERNEL_STACK_CANARY), \reg
20650 +#elif defined(CONFIG_PAX_MEMORY_UDEREF)
20651 + movl $(__USER_DS), \reg
20652 +#else
20653 + xorl \reg, \reg
20654 +#endif
20655 +
20656 movl \reg, %gs
20657 .endm
20658
20659 #endif /* CONFIG_X86_32_LAZY_GS */
20660
20661 -.macro SAVE_ALL
20662 +.macro pax_enter_kernel
20663 +#ifdef CONFIG_PAX_KERNEXEC
20664 + call pax_enter_kernel
20665 +#endif
20666 +.endm
20667 +
20668 +.macro pax_exit_kernel
20669 +#ifdef CONFIG_PAX_KERNEXEC
20670 + call pax_exit_kernel
20671 +#endif
20672 +.endm
20673 +
20674 +#ifdef CONFIG_PAX_KERNEXEC
20675 +ENTRY(pax_enter_kernel)
20676 +#ifdef CONFIG_PARAVIRT
20677 + pushl %eax
20678 + pushl %ecx
20679 + call PARA_INDIRECT(pv_cpu_ops+PV_CPU_read_cr0)
20680 + mov %eax, %esi
20681 +#else
20682 + mov %cr0, %esi
20683 +#endif
20684 + bts $16, %esi
20685 + jnc 1f
20686 + mov %cs, %esi
20687 + cmp $__KERNEL_CS, %esi
20688 + jz 3f
20689 + ljmp $__KERNEL_CS, $3f
20690 +1: ljmp $__KERNEXEC_KERNEL_CS, $2f
20691 +2:
20692 +#ifdef CONFIG_PARAVIRT
20693 + mov %esi, %eax
20694 + call PARA_INDIRECT(pv_cpu_ops+PV_CPU_write_cr0)
20695 +#else
20696 + mov %esi, %cr0
20697 +#endif
20698 +3:
20699 +#ifdef CONFIG_PARAVIRT
20700 + popl %ecx
20701 + popl %eax
20702 +#endif
20703 + ret
20704 +ENDPROC(pax_enter_kernel)
20705 +
20706 +ENTRY(pax_exit_kernel)
20707 +#ifdef CONFIG_PARAVIRT
20708 + pushl %eax
20709 + pushl %ecx
20710 +#endif
20711 + mov %cs, %esi
20712 + cmp $__KERNEXEC_KERNEL_CS, %esi
20713 + jnz 2f
20714 +#ifdef CONFIG_PARAVIRT
20715 + call PARA_INDIRECT(pv_cpu_ops+PV_CPU_read_cr0);
20716 + mov %eax, %esi
20717 +#else
20718 + mov %cr0, %esi
20719 +#endif
20720 + btr $16, %esi
20721 + ljmp $__KERNEL_CS, $1f
20722 +1:
20723 +#ifdef CONFIG_PARAVIRT
20724 + mov %esi, %eax
20725 + call PARA_INDIRECT(pv_cpu_ops+PV_CPU_write_cr0);
20726 +#else
20727 + mov %esi, %cr0
20728 +#endif
20729 +2:
20730 +#ifdef CONFIG_PARAVIRT
20731 + popl %ecx
20732 + popl %eax
20733 +#endif
20734 + ret
20735 +ENDPROC(pax_exit_kernel)
20736 +#endif
20737 +
20738 + .macro pax_erase_kstack
20739 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
20740 + call pax_erase_kstack
20741 +#endif
20742 + .endm
20743 +
20744 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
20745 +/*
20746 + * ebp: thread_info
20747 + */
20748 +ENTRY(pax_erase_kstack)
20749 + pushl %edi
20750 + pushl %ecx
20751 + pushl %eax
20752 +
20753 + mov TI_lowest_stack(%ebp), %edi
20754 + mov $-0xBEEF, %eax
20755 + std
20756 +
20757 +1: mov %edi, %ecx
20758 + and $THREAD_SIZE_asm - 1, %ecx
20759 + shr $2, %ecx
20760 + repne scasl
20761 + jecxz 2f
20762 +
20763 + cmp $2*16, %ecx
20764 + jc 2f
20765 +
20766 + mov $2*16, %ecx
20767 + repe scasl
20768 + jecxz 2f
20769 + jne 1b
20770 +
20771 +2: cld
20772 + mov %esp, %ecx
20773 + sub %edi, %ecx
20774 +
20775 + cmp $THREAD_SIZE_asm, %ecx
20776 + jb 3f
20777 + ud2
20778 +3:
20779 +
20780 + shr $2, %ecx
20781 + rep stosl
20782 +
20783 + mov TI_task_thread_sp0(%ebp), %edi
20784 + sub $128, %edi
20785 + mov %edi, TI_lowest_stack(%ebp)
20786 +
20787 + popl %eax
20788 + popl %ecx
20789 + popl %edi
20790 + ret
20791 +ENDPROC(pax_erase_kstack)
20792 +#endif
20793 +
20794 +.macro __SAVE_ALL _DS
20795 cld
20796 PUSH_GS
20797 pushl_cfi %fs
20798 @@ -206,7 +346,7 @@
20799 CFI_REL_OFFSET ecx, 0
20800 pushl_cfi %ebx
20801 CFI_REL_OFFSET ebx, 0
20802 - movl $(__USER_DS), %edx
20803 + movl $\_DS, %edx
20804 movl %edx, %ds
20805 movl %edx, %es
20806 movl $(__KERNEL_PERCPU), %edx
20807 @@ -214,6 +354,15 @@
20808 SET_KERNEL_GS %edx
20809 .endm
20810
20811 +.macro SAVE_ALL
20812 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
20813 + __SAVE_ALL __KERNEL_DS
20814 + pax_enter_kernel
20815 +#else
20816 + __SAVE_ALL __USER_DS
20817 +#endif
20818 +.endm
20819 +
20820 .macro RESTORE_INT_REGS
20821 popl_cfi %ebx
20822 CFI_RESTORE ebx
20823 @@ -297,7 +446,7 @@ ENTRY(ret_from_fork)
20824 popfl_cfi
20825 jmp syscall_exit
20826 CFI_ENDPROC
20827 -END(ret_from_fork)
20828 +ENDPROC(ret_from_fork)
20829
20830 ENTRY(ret_from_kernel_thread)
20831 CFI_STARTPROC
20832 @@ -344,7 +493,15 @@ ret_from_intr:
20833 andl $SEGMENT_RPL_MASK, %eax
20834 #endif
20835 cmpl $USER_RPL, %eax
20836 +
20837 +#ifdef CONFIG_PAX_KERNEXEC
20838 + jae resume_userspace
20839 +
20840 + pax_exit_kernel
20841 + jmp resume_kernel
20842 +#else
20843 jb resume_kernel # not returning to v8086 or userspace
20844 +#endif
20845
20846 ENTRY(resume_userspace)
20847 LOCKDEP_SYS_EXIT
20848 @@ -356,8 +513,8 @@ ENTRY(resume_userspace)
20849 andl $_TIF_WORK_MASK, %ecx # is there any work to be done on
20850 # int/exception return?
20851 jne work_pending
20852 - jmp restore_all
20853 -END(ret_from_exception)
20854 + jmp restore_all_pax
20855 +ENDPROC(ret_from_exception)
20856
20857 #ifdef CONFIG_PREEMPT
20858 ENTRY(resume_kernel)
20859 @@ -372,7 +529,7 @@ need_resched:
20860 jz restore_all
20861 call preempt_schedule_irq
20862 jmp need_resched
20863 -END(resume_kernel)
20864 +ENDPROC(resume_kernel)
20865 #endif
20866 CFI_ENDPROC
20867 /*
20868 @@ -406,30 +563,45 @@ sysenter_past_esp:
20869 /*CFI_REL_OFFSET cs, 0*/
20870 /*
20871 * Push current_thread_info()->sysenter_return to the stack.
20872 - * A tiny bit of offset fixup is necessary - 4*4 means the 4 words
20873 - * pushed above; +8 corresponds to copy_thread's esp0 setting.
20874 */
20875 - pushl_cfi ((TI_sysenter_return)-THREAD_SIZE+8+4*4)(%esp)
20876 + pushl_cfi $0
20877 CFI_REL_OFFSET eip, 0
20878
20879 pushl_cfi %eax
20880 SAVE_ALL
20881 + GET_THREAD_INFO(%ebp)
20882 + movl TI_sysenter_return(%ebp),%ebp
20883 + movl %ebp,PT_EIP(%esp)
20884 ENABLE_INTERRUPTS(CLBR_NONE)
20885
20886 /*
20887 * Load the potential sixth argument from user stack.
20888 * Careful about security.
20889 */
20890 + movl PT_OLDESP(%esp),%ebp
20891 +
20892 +#ifdef CONFIG_PAX_MEMORY_UDEREF
20893 + mov PT_OLDSS(%esp),%ds
20894 +1: movl %ds:(%ebp),%ebp
20895 + push %ss
20896 + pop %ds
20897 +#else
20898 cmpl $__PAGE_OFFSET-3,%ebp
20899 jae syscall_fault
20900 ASM_STAC
20901 1: movl (%ebp),%ebp
20902 ASM_CLAC
20903 +#endif
20904 +
20905 movl %ebp,PT_EBP(%esp)
20906 _ASM_EXTABLE(1b,syscall_fault)
20907
20908 GET_THREAD_INFO(%ebp)
20909
20910 +#ifdef CONFIG_PAX_RANDKSTACK
20911 + pax_erase_kstack
20912 +#endif
20913 +
20914 testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%ebp)
20915 jnz sysenter_audit
20916 sysenter_do_call:
20917 @@ -444,12 +616,24 @@ sysenter_do_call:
20918 testl $_TIF_ALLWORK_MASK, %ecx
20919 jne sysexit_audit
20920 sysenter_exit:
20921 +
20922 +#ifdef CONFIG_PAX_RANDKSTACK
20923 + pushl_cfi %eax
20924 + movl %esp, %eax
20925 + call pax_randomize_kstack
20926 + popl_cfi %eax
20927 +#endif
20928 +
20929 + pax_erase_kstack
20930 +
20931 /* if something modifies registers it must also disable sysexit */
20932 movl PT_EIP(%esp), %edx
20933 movl PT_OLDESP(%esp), %ecx
20934 xorl %ebp,%ebp
20935 TRACE_IRQS_ON
20936 1: mov PT_FS(%esp), %fs
20937 +2: mov PT_DS(%esp), %ds
20938 +3: mov PT_ES(%esp), %es
20939 PTGS_TO_GS
20940 ENABLE_INTERRUPTS_SYSEXIT
20941
20942 @@ -466,6 +650,9 @@ sysenter_audit:
20943 movl %eax,%edx /* 2nd arg: syscall number */
20944 movl $AUDIT_ARCH_I386,%eax /* 1st arg: audit arch */
20945 call __audit_syscall_entry
20946 +
20947 + pax_erase_kstack
20948 +
20949 pushl_cfi %ebx
20950 movl PT_EAX(%esp),%eax /* reload syscall number */
20951 jmp sysenter_do_call
20952 @@ -491,10 +678,16 @@ sysexit_audit:
20953
20954 CFI_ENDPROC
20955 .pushsection .fixup,"ax"
20956 -2: movl $0,PT_FS(%esp)
20957 +4: movl $0,PT_FS(%esp)
20958 + jmp 1b
20959 +5: movl $0,PT_DS(%esp)
20960 + jmp 1b
20961 +6: movl $0,PT_ES(%esp)
20962 jmp 1b
20963 .popsection
20964 - _ASM_EXTABLE(1b,2b)
20965 + _ASM_EXTABLE(1b,4b)
20966 + _ASM_EXTABLE(2b,5b)
20967 + _ASM_EXTABLE(3b,6b)
20968 PTGS_TO_GS_EX
20969 ENDPROC(ia32_sysenter_target)
20970
20971 @@ -509,6 +702,11 @@ ENTRY(system_call)
20972 pushl_cfi %eax # save orig_eax
20973 SAVE_ALL
20974 GET_THREAD_INFO(%ebp)
20975 +
20976 +#ifdef CONFIG_PAX_RANDKSTACK
20977 + pax_erase_kstack
20978 +#endif
20979 +
20980 # system call tracing in operation / emulation
20981 testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%ebp)
20982 jnz syscall_trace_entry
20983 @@ -527,6 +725,15 @@ syscall_exit:
20984 testl $_TIF_ALLWORK_MASK, %ecx # current->work
20985 jne syscall_exit_work
20986
20987 +restore_all_pax:
20988 +
20989 +#ifdef CONFIG_PAX_RANDKSTACK
20990 + movl %esp, %eax
20991 + call pax_randomize_kstack
20992 +#endif
20993 +
20994 + pax_erase_kstack
20995 +
20996 restore_all:
20997 TRACE_IRQS_IRET
20998 restore_all_notrace:
20999 @@ -583,14 +790,34 @@ ldt_ss:
21000 * compensating for the offset by changing to the ESPFIX segment with
21001 * a base address that matches for the difference.
21002 */
21003 -#define GDT_ESPFIX_SS PER_CPU_VAR(gdt_page) + (GDT_ENTRY_ESPFIX_SS * 8)
21004 +#define GDT_ESPFIX_SS (GDT_ENTRY_ESPFIX_SS * 8)(%ebx)
21005 mov %esp, %edx /* load kernel esp */
21006 mov PT_OLDESP(%esp), %eax /* load userspace esp */
21007 mov %dx, %ax /* eax: new kernel esp */
21008 sub %eax, %edx /* offset (low word is 0) */
21009 +#ifdef CONFIG_SMP
21010 + movl PER_CPU_VAR(cpu_number), %ebx
21011 + shll $PAGE_SHIFT_asm, %ebx
21012 + addl $cpu_gdt_table, %ebx
21013 +#else
21014 + movl $cpu_gdt_table, %ebx
21015 +#endif
21016 shr $16, %edx
21017 - mov %dl, GDT_ESPFIX_SS + 4 /* bits 16..23 */
21018 - mov %dh, GDT_ESPFIX_SS + 7 /* bits 24..31 */
21019 +
21020 +#ifdef CONFIG_PAX_KERNEXEC
21021 + mov %cr0, %esi
21022 + btr $16, %esi
21023 + mov %esi, %cr0
21024 +#endif
21025 +
21026 + mov %dl, 4 + GDT_ESPFIX_SS /* bits 16..23 */
21027 + mov %dh, 7 + GDT_ESPFIX_SS /* bits 24..31 */
21028 +
21029 +#ifdef CONFIG_PAX_KERNEXEC
21030 + bts $16, %esi
21031 + mov %esi, %cr0
21032 +#endif
21033 +
21034 pushl_cfi $__ESPFIX_SS
21035 pushl_cfi %eax /* new kernel esp */
21036 /* Disable interrupts, but do not irqtrace this section: we
21037 @@ -619,20 +846,18 @@ work_resched:
21038 movl TI_flags(%ebp), %ecx
21039 andl $_TIF_WORK_MASK, %ecx # is there any work to be done other
21040 # than syscall tracing?
21041 - jz restore_all
21042 + jz restore_all_pax
21043 testb $_TIF_NEED_RESCHED, %cl
21044 jnz work_resched
21045
21046 work_notifysig: # deal with pending signals and
21047 # notify-resume requests
21048 + movl %esp, %eax
21049 #ifdef CONFIG_VM86
21050 testl $X86_EFLAGS_VM, PT_EFLAGS(%esp)
21051 - movl %esp, %eax
21052 jne work_notifysig_v86 # returning to kernel-space or
21053 # vm86-space
21054 1:
21055 -#else
21056 - movl %esp, %eax
21057 #endif
21058 TRACE_IRQS_ON
21059 ENABLE_INTERRUPTS(CLBR_NONE)
21060 @@ -653,7 +878,7 @@ work_notifysig_v86:
21061 movl %eax, %esp
21062 jmp 1b
21063 #endif
21064 -END(work_pending)
21065 +ENDPROC(work_pending)
21066
21067 # perform syscall exit tracing
21068 ALIGN
21069 @@ -661,11 +886,14 @@ syscall_trace_entry:
21070 movl $-ENOSYS,PT_EAX(%esp)
21071 movl %esp, %eax
21072 call syscall_trace_enter
21073 +
21074 + pax_erase_kstack
21075 +
21076 /* What it returned is what we'll actually use. */
21077 cmpl $(NR_syscalls), %eax
21078 jnae syscall_call
21079 jmp syscall_exit
21080 -END(syscall_trace_entry)
21081 +ENDPROC(syscall_trace_entry)
21082
21083 # perform syscall exit tracing
21084 ALIGN
21085 @@ -678,21 +906,25 @@ syscall_exit_work:
21086 movl %esp, %eax
21087 call syscall_trace_leave
21088 jmp resume_userspace
21089 -END(syscall_exit_work)
21090 +ENDPROC(syscall_exit_work)
21091 CFI_ENDPROC
21092
21093 RING0_INT_FRAME # can't unwind into user space anyway
21094 syscall_fault:
21095 +#ifdef CONFIG_PAX_MEMORY_UDEREF
21096 + push %ss
21097 + pop %ds
21098 +#endif
21099 ASM_CLAC
21100 GET_THREAD_INFO(%ebp)
21101 movl $-EFAULT,PT_EAX(%esp)
21102 jmp resume_userspace
21103 -END(syscall_fault)
21104 +ENDPROC(syscall_fault)
21105
21106 syscall_badsys:
21107 movl $-ENOSYS,PT_EAX(%esp)
21108 jmp resume_userspace
21109 -END(syscall_badsys)
21110 +ENDPROC(syscall_badsys)
21111 CFI_ENDPROC
21112 /*
21113 * End of kprobes section
21114 @@ -708,8 +940,15 @@ END(syscall_badsys)
21115 * normal stack and adjusts ESP with the matching offset.
21116 */
21117 /* fixup the stack */
21118 - mov GDT_ESPFIX_SS + 4, %al /* bits 16..23 */
21119 - mov GDT_ESPFIX_SS + 7, %ah /* bits 24..31 */
21120 +#ifdef CONFIG_SMP
21121 + movl PER_CPU_VAR(cpu_number), %ebx
21122 + shll $PAGE_SHIFT_asm, %ebx
21123 + addl $cpu_gdt_table, %ebx
21124 +#else
21125 + movl $cpu_gdt_table, %ebx
21126 +#endif
21127 + mov 4 + GDT_ESPFIX_SS, %al /* bits 16..23 */
21128 + mov 7 + GDT_ESPFIX_SS, %ah /* bits 24..31 */
21129 shl $16, %eax
21130 addl %esp, %eax /* the adjusted stack pointer */
21131 pushl_cfi $__KERNEL_DS
21132 @@ -762,7 +1001,7 @@ vector=vector+1
21133 .endr
21134 2: jmp common_interrupt
21135 .endr
21136 -END(irq_entries_start)
21137 +ENDPROC(irq_entries_start)
21138
21139 .previous
21140 END(interrupt)
21141 @@ -823,7 +1062,7 @@ ENTRY(coprocessor_error)
21142 pushl_cfi $do_coprocessor_error
21143 jmp error_code
21144 CFI_ENDPROC
21145 -END(coprocessor_error)
21146 +ENDPROC(coprocessor_error)
21147
21148 ENTRY(simd_coprocessor_error)
21149 RING0_INT_FRAME
21150 @@ -836,7 +1075,7 @@ ENTRY(simd_coprocessor_error)
21151 .section .altinstructions,"a"
21152 altinstruction_entry 661b, 663f, X86_FEATURE_XMM, 662b-661b, 664f-663f
21153 .previous
21154 -.section .altinstr_replacement,"ax"
21155 +.section .altinstr_replacement,"a"
21156 663: pushl $do_simd_coprocessor_error
21157 664:
21158 .previous
21159 @@ -845,7 +1084,7 @@ ENTRY(simd_coprocessor_error)
21160 #endif
21161 jmp error_code
21162 CFI_ENDPROC
21163 -END(simd_coprocessor_error)
21164 +ENDPROC(simd_coprocessor_error)
21165
21166 ENTRY(device_not_available)
21167 RING0_INT_FRAME
21168 @@ -854,18 +1093,18 @@ ENTRY(device_not_available)
21169 pushl_cfi $do_device_not_available
21170 jmp error_code
21171 CFI_ENDPROC
21172 -END(device_not_available)
21173 +ENDPROC(device_not_available)
21174
21175 #ifdef CONFIG_PARAVIRT
21176 ENTRY(native_iret)
21177 iret
21178 _ASM_EXTABLE(native_iret, iret_exc)
21179 -END(native_iret)
21180 +ENDPROC(native_iret)
21181
21182 ENTRY(native_irq_enable_sysexit)
21183 sti
21184 sysexit
21185 -END(native_irq_enable_sysexit)
21186 +ENDPROC(native_irq_enable_sysexit)
21187 #endif
21188
21189 ENTRY(overflow)
21190 @@ -875,7 +1114,7 @@ ENTRY(overflow)
21191 pushl_cfi $do_overflow
21192 jmp error_code
21193 CFI_ENDPROC
21194 -END(overflow)
21195 +ENDPROC(overflow)
21196
21197 ENTRY(bounds)
21198 RING0_INT_FRAME
21199 @@ -884,7 +1123,7 @@ ENTRY(bounds)
21200 pushl_cfi $do_bounds
21201 jmp error_code
21202 CFI_ENDPROC
21203 -END(bounds)
21204 +ENDPROC(bounds)
21205
21206 ENTRY(invalid_op)
21207 RING0_INT_FRAME
21208 @@ -893,7 +1132,7 @@ ENTRY(invalid_op)
21209 pushl_cfi $do_invalid_op
21210 jmp error_code
21211 CFI_ENDPROC
21212 -END(invalid_op)
21213 +ENDPROC(invalid_op)
21214
21215 ENTRY(coprocessor_segment_overrun)
21216 RING0_INT_FRAME
21217 @@ -902,7 +1141,7 @@ ENTRY(coprocessor_segment_overrun)
21218 pushl_cfi $do_coprocessor_segment_overrun
21219 jmp error_code
21220 CFI_ENDPROC
21221 -END(coprocessor_segment_overrun)
21222 +ENDPROC(coprocessor_segment_overrun)
21223
21224 ENTRY(invalid_TSS)
21225 RING0_EC_FRAME
21226 @@ -910,7 +1149,7 @@ ENTRY(invalid_TSS)
21227 pushl_cfi $do_invalid_TSS
21228 jmp error_code
21229 CFI_ENDPROC
21230 -END(invalid_TSS)
21231 +ENDPROC(invalid_TSS)
21232
21233 ENTRY(segment_not_present)
21234 RING0_EC_FRAME
21235 @@ -918,7 +1157,7 @@ ENTRY(segment_not_present)
21236 pushl_cfi $do_segment_not_present
21237 jmp error_code
21238 CFI_ENDPROC
21239 -END(segment_not_present)
21240 +ENDPROC(segment_not_present)
21241
21242 ENTRY(stack_segment)
21243 RING0_EC_FRAME
21244 @@ -926,7 +1165,7 @@ ENTRY(stack_segment)
21245 pushl_cfi $do_stack_segment
21246 jmp error_code
21247 CFI_ENDPROC
21248 -END(stack_segment)
21249 +ENDPROC(stack_segment)
21250
21251 ENTRY(alignment_check)
21252 RING0_EC_FRAME
21253 @@ -934,7 +1173,7 @@ ENTRY(alignment_check)
21254 pushl_cfi $do_alignment_check
21255 jmp error_code
21256 CFI_ENDPROC
21257 -END(alignment_check)
21258 +ENDPROC(alignment_check)
21259
21260 ENTRY(divide_error)
21261 RING0_INT_FRAME
21262 @@ -943,7 +1182,7 @@ ENTRY(divide_error)
21263 pushl_cfi $do_divide_error
21264 jmp error_code
21265 CFI_ENDPROC
21266 -END(divide_error)
21267 +ENDPROC(divide_error)
21268
21269 #ifdef CONFIG_X86_MCE
21270 ENTRY(machine_check)
21271 @@ -953,7 +1192,7 @@ ENTRY(machine_check)
21272 pushl_cfi machine_check_vector
21273 jmp error_code
21274 CFI_ENDPROC
21275 -END(machine_check)
21276 +ENDPROC(machine_check)
21277 #endif
21278
21279 ENTRY(spurious_interrupt_bug)
21280 @@ -963,7 +1202,7 @@ ENTRY(spurious_interrupt_bug)
21281 pushl_cfi $do_spurious_interrupt_bug
21282 jmp error_code
21283 CFI_ENDPROC
21284 -END(spurious_interrupt_bug)
21285 +ENDPROC(spurious_interrupt_bug)
21286 /*
21287 * End of kprobes section
21288 */
21289 @@ -1073,7 +1312,7 @@ BUILD_INTERRUPT3(hyperv_callback_vector, HYPERVISOR_CALLBACK_VECTOR,
21290
21291 ENTRY(mcount)
21292 ret
21293 -END(mcount)
21294 +ENDPROC(mcount)
21295
21296 ENTRY(ftrace_caller)
21297 cmpl $0, function_trace_stop
21298 @@ -1106,7 +1345,7 @@ ftrace_graph_call:
21299 .globl ftrace_stub
21300 ftrace_stub:
21301 ret
21302 -END(ftrace_caller)
21303 +ENDPROC(ftrace_caller)
21304
21305 ENTRY(ftrace_regs_caller)
21306 pushf /* push flags before compare (in cs location) */
21307 @@ -1210,7 +1449,7 @@ trace:
21308 popl %ecx
21309 popl %eax
21310 jmp ftrace_stub
21311 -END(mcount)
21312 +ENDPROC(mcount)
21313 #endif /* CONFIG_DYNAMIC_FTRACE */
21314 #endif /* CONFIG_FUNCTION_TRACER */
21315
21316 @@ -1228,7 +1467,7 @@ ENTRY(ftrace_graph_caller)
21317 popl %ecx
21318 popl %eax
21319 ret
21320 -END(ftrace_graph_caller)
21321 +ENDPROC(ftrace_graph_caller)
21322
21323 .globl return_to_handler
21324 return_to_handler:
21325 @@ -1284,15 +1523,18 @@ error_code:
21326 movl $-1, PT_ORIG_EAX(%esp) # no syscall to restart
21327 REG_TO_PTGS %ecx
21328 SET_KERNEL_GS %ecx
21329 - movl $(__USER_DS), %ecx
21330 + movl $(__KERNEL_DS), %ecx
21331 movl %ecx, %ds
21332 movl %ecx, %es
21333 +
21334 + pax_enter_kernel
21335 +
21336 TRACE_IRQS_OFF
21337 movl %esp,%eax # pt_regs pointer
21338 call *%edi
21339 jmp ret_from_exception
21340 CFI_ENDPROC
21341 -END(page_fault)
21342 +ENDPROC(page_fault)
21343
21344 /*
21345 * Debug traps and NMI can happen at the one SYSENTER instruction
21346 @@ -1335,7 +1577,7 @@ debug_stack_correct:
21347 call do_debug
21348 jmp ret_from_exception
21349 CFI_ENDPROC
21350 -END(debug)
21351 +ENDPROC(debug)
21352
21353 /*
21354 * NMI is doubly nasty. It can happen _while_ we're handling
21355 @@ -1373,6 +1615,9 @@ nmi_stack_correct:
21356 xorl %edx,%edx # zero error code
21357 movl %esp,%eax # pt_regs pointer
21358 call do_nmi
21359 +
21360 + pax_exit_kernel
21361 +
21362 jmp restore_all_notrace
21363 CFI_ENDPROC
21364
21365 @@ -1409,12 +1654,15 @@ nmi_espfix_stack:
21366 FIXUP_ESPFIX_STACK # %eax == %esp
21367 xorl %edx,%edx # zero error code
21368 call do_nmi
21369 +
21370 + pax_exit_kernel
21371 +
21372 RESTORE_REGS
21373 lss 12+4(%esp), %esp # back to espfix stack
21374 CFI_ADJUST_CFA_OFFSET -24
21375 jmp irq_return
21376 CFI_ENDPROC
21377 -END(nmi)
21378 +ENDPROC(nmi)
21379
21380 ENTRY(int3)
21381 RING0_INT_FRAME
21382 @@ -1427,14 +1675,14 @@ ENTRY(int3)
21383 call do_int3
21384 jmp ret_from_exception
21385 CFI_ENDPROC
21386 -END(int3)
21387 +ENDPROC(int3)
21388
21389 ENTRY(general_protection)
21390 RING0_EC_FRAME
21391 pushl_cfi $do_general_protection
21392 jmp error_code
21393 CFI_ENDPROC
21394 -END(general_protection)
21395 +ENDPROC(general_protection)
21396
21397 #ifdef CONFIG_KVM_GUEST
21398 ENTRY(async_page_fault)
21399 @@ -1443,7 +1691,7 @@ ENTRY(async_page_fault)
21400 pushl_cfi $do_async_page_fault
21401 jmp error_code
21402 CFI_ENDPROC
21403 -END(async_page_fault)
21404 +ENDPROC(async_page_fault)
21405 #endif
21406
21407 /*
21408 diff --git a/arch/x86/kernel/entry_64.S b/arch/x86/kernel/entry_64.S
21409 index b077f4c..feb26c1 100644
21410 --- a/arch/x86/kernel/entry_64.S
21411 +++ b/arch/x86/kernel/entry_64.S
21412 @@ -59,6 +59,8 @@
21413 #include <asm/context_tracking.h>
21414 #include <asm/smap.h>
21415 #include <linux/err.h>
21416 +#include <asm/pgtable.h>
21417 +#include <asm/alternative-asm.h>
21418
21419 /* Avoid __ASSEMBLER__'ifying <linux/audit.h> just for this. */
21420 #include <linux/elf-em.h>
21421 @@ -80,8 +82,9 @@
21422 #ifdef CONFIG_DYNAMIC_FTRACE
21423
21424 ENTRY(function_hook)
21425 + pax_force_retaddr
21426 retq
21427 -END(function_hook)
21428 +ENDPROC(function_hook)
21429
21430 /* skip is set if stack has been adjusted */
21431 .macro ftrace_caller_setup skip=0
21432 @@ -122,8 +125,9 @@ GLOBAL(ftrace_graph_call)
21433 #endif
21434
21435 GLOBAL(ftrace_stub)
21436 + pax_force_retaddr
21437 retq
21438 -END(ftrace_caller)
21439 +ENDPROC(ftrace_caller)
21440
21441 ENTRY(ftrace_regs_caller)
21442 /* Save the current flags before compare (in SS location)*/
21443 @@ -191,7 +195,7 @@ ftrace_restore_flags:
21444 popfq
21445 jmp ftrace_stub
21446
21447 -END(ftrace_regs_caller)
21448 +ENDPROC(ftrace_regs_caller)
21449
21450
21451 #else /* ! CONFIG_DYNAMIC_FTRACE */
21452 @@ -212,6 +216,7 @@ ENTRY(function_hook)
21453 #endif
21454
21455 GLOBAL(ftrace_stub)
21456 + pax_force_retaddr
21457 retq
21458
21459 trace:
21460 @@ -225,12 +230,13 @@ trace:
21461 #endif
21462 subq $MCOUNT_INSN_SIZE, %rdi
21463
21464 + pax_force_fptr ftrace_trace_function
21465 call *ftrace_trace_function
21466
21467 MCOUNT_RESTORE_FRAME
21468
21469 jmp ftrace_stub
21470 -END(function_hook)
21471 +ENDPROC(function_hook)
21472 #endif /* CONFIG_DYNAMIC_FTRACE */
21473 #endif /* CONFIG_FUNCTION_TRACER */
21474
21475 @@ -252,8 +258,9 @@ ENTRY(ftrace_graph_caller)
21476
21477 MCOUNT_RESTORE_FRAME
21478
21479 + pax_force_retaddr
21480 retq
21481 -END(ftrace_graph_caller)
21482 +ENDPROC(ftrace_graph_caller)
21483
21484 GLOBAL(return_to_handler)
21485 subq $24, %rsp
21486 @@ -269,7 +276,9 @@ GLOBAL(return_to_handler)
21487 movq 8(%rsp), %rdx
21488 movq (%rsp), %rax
21489 addq $24, %rsp
21490 + pax_force_fptr %rdi
21491 jmp *%rdi
21492 +ENDPROC(return_to_handler)
21493 #endif
21494
21495
21496 @@ -284,6 +293,430 @@ ENTRY(native_usergs_sysret64)
21497 ENDPROC(native_usergs_sysret64)
21498 #endif /* CONFIG_PARAVIRT */
21499
21500 + .macro ljmpq sel, off
21501 +#if defined(CONFIG_MPSC) || defined(CONFIG_MCORE2) || defined (CONFIG_MATOM)
21502 + .byte 0x48; ljmp *1234f(%rip)
21503 + .pushsection .rodata
21504 + .align 16
21505 + 1234: .quad \off; .word \sel
21506 + .popsection
21507 +#else
21508 + pushq $\sel
21509 + pushq $\off
21510 + lretq
21511 +#endif
21512 + .endm
21513 +
21514 + .macro pax_enter_kernel
21515 + pax_set_fptr_mask
21516 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
21517 + call pax_enter_kernel
21518 +#endif
21519 + .endm
21520 +
21521 + .macro pax_exit_kernel
21522 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
21523 + call pax_exit_kernel
21524 +#endif
21525 +
21526 + .endm
21527 +
21528 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
21529 +ENTRY(pax_enter_kernel)
21530 + pushq %rdi
21531 +
21532 +#ifdef CONFIG_PARAVIRT
21533 + PV_SAVE_REGS(CLBR_RDI)
21534 +#endif
21535 +
21536 +#ifdef CONFIG_PAX_KERNEXEC
21537 + GET_CR0_INTO_RDI
21538 + bts $16,%rdi
21539 + jnc 3f
21540 + mov %cs,%edi
21541 + cmp $__KERNEL_CS,%edi
21542 + jnz 2f
21543 +1:
21544 +#endif
21545 +
21546 +#ifdef CONFIG_PAX_MEMORY_UDEREF
21547 + 661: jmp 111f
21548 + .pushsection .altinstr_replacement, "a"
21549 + 662: ASM_NOP2
21550 + .popsection
21551 + .pushsection .altinstructions, "a"
21552 + altinstruction_entry 661b, 662b, X86_FEATURE_PCID, 2, 2
21553 + .popsection
21554 + GET_CR3_INTO_RDI
21555 + cmp $0,%dil
21556 + jnz 112f
21557 + mov $__KERNEL_DS,%edi
21558 + mov %edi,%ss
21559 + jmp 111f
21560 +112: cmp $1,%dil
21561 + jz 113f
21562 + ud2
21563 +113: sub $4097,%rdi
21564 + bts $63,%rdi
21565 + SET_RDI_INTO_CR3
21566 + mov $__UDEREF_KERNEL_DS,%edi
21567 + mov %edi,%ss
21568 +111:
21569 +#endif
21570 +
21571 +#ifdef CONFIG_PARAVIRT
21572 + PV_RESTORE_REGS(CLBR_RDI)
21573 +#endif
21574 +
21575 + popq %rdi
21576 + pax_force_retaddr
21577 + retq
21578 +
21579 +#ifdef CONFIG_PAX_KERNEXEC
21580 +2: ljmpq __KERNEL_CS,1b
21581 +3: ljmpq __KERNEXEC_KERNEL_CS,4f
21582 +4: SET_RDI_INTO_CR0
21583 + jmp 1b
21584 +#endif
21585 +ENDPROC(pax_enter_kernel)
21586 +
21587 +ENTRY(pax_exit_kernel)
21588 + pushq %rdi
21589 +
21590 +#ifdef CONFIG_PARAVIRT
21591 + PV_SAVE_REGS(CLBR_RDI)
21592 +#endif
21593 +
21594 +#ifdef CONFIG_PAX_KERNEXEC
21595 + mov %cs,%rdi
21596 + cmp $__KERNEXEC_KERNEL_CS,%edi
21597 + jz 2f
21598 + GET_CR0_INTO_RDI
21599 + bts $16,%rdi
21600 + jnc 4f
21601 +1:
21602 +#endif
21603 +
21604 +#ifdef CONFIG_PAX_MEMORY_UDEREF
21605 + 661: jmp 111f
21606 + .pushsection .altinstr_replacement, "a"
21607 + 662: ASM_NOP2
21608 + .popsection
21609 + .pushsection .altinstructions, "a"
21610 + altinstruction_entry 661b, 662b, X86_FEATURE_PCID, 2, 2
21611 + .popsection
21612 + mov %ss,%edi
21613 + cmp $__UDEREF_KERNEL_DS,%edi
21614 + jnz 111f
21615 + GET_CR3_INTO_RDI
21616 + cmp $0,%dil
21617 + jz 112f
21618 + ud2
21619 +112: add $4097,%rdi
21620 + bts $63,%rdi
21621 + SET_RDI_INTO_CR3
21622 + mov $__KERNEL_DS,%edi
21623 + mov %edi,%ss
21624 +111:
21625 +#endif
21626 +
21627 +#ifdef CONFIG_PARAVIRT
21628 + PV_RESTORE_REGS(CLBR_RDI);
21629 +#endif
21630 +
21631 + popq %rdi
21632 + pax_force_retaddr
21633 + retq
21634 +
21635 +#ifdef CONFIG_PAX_KERNEXEC
21636 +2: GET_CR0_INTO_RDI
21637 + btr $16,%rdi
21638 + jnc 4f
21639 + ljmpq __KERNEL_CS,3f
21640 +3: SET_RDI_INTO_CR0
21641 + jmp 1b
21642 +4: ud2
21643 + jmp 4b
21644 +#endif
21645 +ENDPROC(pax_exit_kernel)
21646 +#endif
21647 +
21648 + .macro pax_enter_kernel_user
21649 + pax_set_fptr_mask
21650 +#ifdef CONFIG_PAX_MEMORY_UDEREF
21651 + call pax_enter_kernel_user
21652 +#endif
21653 + .endm
21654 +
21655 + .macro pax_exit_kernel_user
21656 +#ifdef CONFIG_PAX_MEMORY_UDEREF
21657 + call pax_exit_kernel_user
21658 +#endif
21659 +#ifdef CONFIG_PAX_RANDKSTACK
21660 + pushq %rax
21661 + pushq %r11
21662 + call pax_randomize_kstack
21663 + popq %r11
21664 + popq %rax
21665 +#endif
21666 + .endm
21667 +
21668 +#ifdef CONFIG_PAX_MEMORY_UDEREF
21669 +ENTRY(pax_enter_kernel_user)
21670 + pushq %rdi
21671 + pushq %rbx
21672 +
21673 +#ifdef CONFIG_PARAVIRT
21674 + PV_SAVE_REGS(CLBR_RDI)
21675 +#endif
21676 +
21677 + 661: jmp 111f
21678 + .pushsection .altinstr_replacement, "a"
21679 + 662: ASM_NOP2
21680 + .popsection
21681 + .pushsection .altinstructions, "a"
21682 + altinstruction_entry 661b, 662b, X86_FEATURE_PCID, 2, 2
21683 + .popsection
21684 + GET_CR3_INTO_RDI
21685 + cmp $1,%dil
21686 + jnz 4f
21687 + sub $4097,%rdi
21688 + bts $63,%rdi
21689 + SET_RDI_INTO_CR3
21690 + jmp 3f
21691 +111:
21692 +
21693 + GET_CR3_INTO_RDI
21694 + mov %rdi,%rbx
21695 + add $__START_KERNEL_map,%rbx
21696 + sub phys_base(%rip),%rbx
21697 +
21698 +#ifdef CONFIG_PARAVIRT
21699 + cmpl $0, pv_info+PARAVIRT_enabled
21700 + jz 1f
21701 + pushq %rdi
21702 + i = 0
21703 + .rept USER_PGD_PTRS
21704 + mov i*8(%rbx),%rsi
21705 + mov $0,%sil
21706 + lea i*8(%rbx),%rdi
21707 + call PARA_INDIRECT(pv_mmu_ops+PV_MMU_set_pgd_batched)
21708 + i = i + 1
21709 + .endr
21710 + popq %rdi
21711 + jmp 2f
21712 +1:
21713 +#endif
21714 +
21715 + i = 0
21716 + .rept USER_PGD_PTRS
21717 + movb $0,i*8(%rbx)
21718 + i = i + 1
21719 + .endr
21720 +
21721 +2: SET_RDI_INTO_CR3
21722 +
21723 +#ifdef CONFIG_PAX_KERNEXEC
21724 + GET_CR0_INTO_RDI
21725 + bts $16,%rdi
21726 + SET_RDI_INTO_CR0
21727 +#endif
21728 +
21729 +3:
21730 +
21731 +#ifdef CONFIG_PARAVIRT
21732 + PV_RESTORE_REGS(CLBR_RDI)
21733 +#endif
21734 +
21735 + popq %rbx
21736 + popq %rdi
21737 + pax_force_retaddr
21738 + retq
21739 +4: ud2
21740 +ENDPROC(pax_enter_kernel_user)
21741 +
21742 +ENTRY(pax_exit_kernel_user)
21743 + pushq %rdi
21744 + pushq %rbx
21745 +
21746 +#ifdef CONFIG_PARAVIRT
21747 + PV_SAVE_REGS(CLBR_RDI)
21748 +#endif
21749 +
21750 + GET_CR3_INTO_RDI
21751 + 661: jmp 1f
21752 + .pushsection .altinstr_replacement, "a"
21753 + 662: ASM_NOP2
21754 + .popsection
21755 + .pushsection .altinstructions, "a"
21756 + altinstruction_entry 661b, 662b, X86_FEATURE_PCID, 2, 2
21757 + .popsection
21758 + cmp $0,%dil
21759 + jnz 3f
21760 + add $4097,%rdi
21761 + bts $63,%rdi
21762 + SET_RDI_INTO_CR3
21763 + jmp 2f
21764 +1:
21765 +
21766 + mov %rdi,%rbx
21767 +
21768 +#ifdef CONFIG_PAX_KERNEXEC
21769 + GET_CR0_INTO_RDI
21770 + btr $16,%rdi
21771 + jnc 3f
21772 + SET_RDI_INTO_CR0
21773 +#endif
21774 +
21775 + add $__START_KERNEL_map,%rbx
21776 + sub phys_base(%rip),%rbx
21777 +
21778 +#ifdef CONFIG_PARAVIRT
21779 + cmpl $0, pv_info+PARAVIRT_enabled
21780 + jz 1f
21781 + i = 0
21782 + .rept USER_PGD_PTRS
21783 + mov i*8(%rbx),%rsi
21784 + mov $0x67,%sil
21785 + lea i*8(%rbx),%rdi
21786 + call PARA_INDIRECT(pv_mmu_ops+PV_MMU_set_pgd_batched)
21787 + i = i + 1
21788 + .endr
21789 + jmp 2f
21790 +1:
21791 +#endif
21792 +
21793 + i = 0
21794 + .rept USER_PGD_PTRS
21795 + movb $0x67,i*8(%rbx)
21796 + i = i + 1
21797 + .endr
21798 +2:
21799 +
21800 +#ifdef CONFIG_PARAVIRT
21801 + PV_RESTORE_REGS(CLBR_RDI)
21802 +#endif
21803 +
21804 + popq %rbx
21805 + popq %rdi
21806 + pax_force_retaddr
21807 + retq
21808 +3: ud2
21809 +ENDPROC(pax_exit_kernel_user)
21810 +#endif
21811 +
21812 + .macro pax_enter_kernel_nmi
21813 + pax_set_fptr_mask
21814 +
21815 +#ifdef CONFIG_PAX_KERNEXEC
21816 + GET_CR0_INTO_RDI
21817 + bts $16,%rdi
21818 + jc 110f
21819 + SET_RDI_INTO_CR0
21820 + or $2,%ebx
21821 +110:
21822 +#endif
21823 +
21824 +#ifdef CONFIG_PAX_MEMORY_UDEREF
21825 + 661: jmp 111f
21826 + .pushsection .altinstr_replacement, "a"
21827 + 662: ASM_NOP2
21828 + .popsection
21829 + .pushsection .altinstructions, "a"
21830 + altinstruction_entry 661b, 662b, X86_FEATURE_PCID, 2, 2
21831 + .popsection
21832 + GET_CR3_INTO_RDI
21833 + cmp $0,%dil
21834 + jz 111f
21835 + sub $4097,%rdi
21836 + or $4,%ebx
21837 + bts $63,%rdi
21838 + SET_RDI_INTO_CR3
21839 + mov $__UDEREF_KERNEL_DS,%edi
21840 + mov %edi,%ss
21841 +111:
21842 +#endif
21843 + .endm
21844 +
21845 + .macro pax_exit_kernel_nmi
21846 +#ifdef CONFIG_PAX_KERNEXEC
21847 + btr $1,%ebx
21848 + jnc 110f
21849 + GET_CR0_INTO_RDI
21850 + btr $16,%rdi
21851 + SET_RDI_INTO_CR0
21852 +110:
21853 +#endif
21854 +
21855 +#ifdef CONFIG_PAX_MEMORY_UDEREF
21856 + btr $2,%ebx
21857 + jnc 111f
21858 + GET_CR3_INTO_RDI
21859 + add $4097,%rdi
21860 + bts $63,%rdi
21861 + SET_RDI_INTO_CR3
21862 + mov $__KERNEL_DS,%edi
21863 + mov %edi,%ss
21864 +111:
21865 +#endif
21866 + .endm
21867 +
21868 + .macro pax_erase_kstack
21869 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
21870 + call pax_erase_kstack
21871 +#endif
21872 + .endm
21873 +
21874 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
21875 +ENTRY(pax_erase_kstack)
21876 + pushq %rdi
21877 + pushq %rcx
21878 + pushq %rax
21879 + pushq %r11
21880 +
21881 + GET_THREAD_INFO(%r11)
21882 + mov TI_lowest_stack(%r11), %rdi
21883 + mov $-0xBEEF, %rax
21884 + std
21885 +
21886 +1: mov %edi, %ecx
21887 + and $THREAD_SIZE_asm - 1, %ecx
21888 + shr $3, %ecx
21889 + repne scasq
21890 + jecxz 2f
21891 +
21892 + cmp $2*8, %ecx
21893 + jc 2f
21894 +
21895 + mov $2*8, %ecx
21896 + repe scasq
21897 + jecxz 2f
21898 + jne 1b
21899 +
21900 +2: cld
21901 + mov %esp, %ecx
21902 + sub %edi, %ecx
21903 +
21904 + cmp $THREAD_SIZE_asm, %rcx
21905 + jb 3f
21906 + ud2
21907 +3:
21908 +
21909 + shr $3, %ecx
21910 + rep stosq
21911 +
21912 + mov TI_task_thread_sp0(%r11), %rdi
21913 + sub $256, %rdi
21914 + mov %rdi, TI_lowest_stack(%r11)
21915 +
21916 + popq %r11
21917 + popq %rax
21918 + popq %rcx
21919 + popq %rdi
21920 + pax_force_retaddr
21921 + ret
21922 +ENDPROC(pax_erase_kstack)
21923 +#endif
21924
21925 .macro TRACE_IRQS_IRETQ offset=ARGOFFSET
21926 #ifdef CONFIG_TRACE_IRQFLAGS
21927 @@ -375,8 +808,8 @@ ENDPROC(native_usergs_sysret64)
21928 .endm
21929
21930 .macro UNFAKE_STACK_FRAME
21931 - addq $8*6, %rsp
21932 - CFI_ADJUST_CFA_OFFSET -(6*8)
21933 + addq $8*6 + ARG_SKIP, %rsp
21934 + CFI_ADJUST_CFA_OFFSET -(6*8 + ARG_SKIP)
21935 .endm
21936
21937 /*
21938 @@ -463,7 +896,7 @@ ENDPROC(native_usergs_sysret64)
21939 movq %rsp, %rsi
21940
21941 leaq -RBP(%rsp),%rdi /* arg1 for handler */
21942 - testl $3, CS-RBP(%rsi)
21943 + testb $3, CS-RBP(%rsi)
21944 je 1f
21945 SWAPGS
21946 /*
21947 @@ -514,9 +947,10 @@ ENTRY(save_paranoid)
21948 js 1f /* negative -> in kernel */
21949 SWAPGS
21950 xorl %ebx,%ebx
21951 -1: ret
21952 +1: pax_force_retaddr_bts
21953 + ret
21954 CFI_ENDPROC
21955 -END(save_paranoid)
21956 +ENDPROC(save_paranoid)
21957 .popsection
21958
21959 /*
21960 @@ -538,7 +972,7 @@ ENTRY(ret_from_fork)
21961
21962 RESTORE_REST
21963
21964 - testl $3, CS-ARGOFFSET(%rsp) # from kernel_thread?
21965 + testb $3, CS-ARGOFFSET(%rsp) # from kernel_thread?
21966 jz 1f
21967
21968 testl $_TIF_IA32, TI_flags(%rcx) # 32-bit compat task needs IRET
21969 @@ -556,7 +990,7 @@ ENTRY(ret_from_fork)
21970 RESTORE_REST
21971 jmp int_ret_from_sys_call
21972 CFI_ENDPROC
21973 -END(ret_from_fork)
21974 +ENDPROC(ret_from_fork)
21975
21976 /*
21977 * System call entry. Up to 6 arguments in registers are supported.
21978 @@ -593,7 +1027,7 @@ END(ret_from_fork)
21979 ENTRY(system_call)
21980 CFI_STARTPROC simple
21981 CFI_SIGNAL_FRAME
21982 - CFI_DEF_CFA rsp,KERNEL_STACK_OFFSET
21983 + CFI_DEF_CFA rsp,0
21984 CFI_REGISTER rip,rcx
21985 /*CFI_REGISTER rflags,r11*/
21986 SWAPGS_UNSAFE_STACK
21987 @@ -606,16 +1040,23 @@ GLOBAL(system_call_after_swapgs)
21988
21989 movq %rsp,PER_CPU_VAR(old_rsp)
21990 movq PER_CPU_VAR(kernel_stack),%rsp
21991 + SAVE_ARGS 8*6,0
21992 + pax_enter_kernel_user
21993 +
21994 +#ifdef CONFIG_PAX_RANDKSTACK
21995 + pax_erase_kstack
21996 +#endif
21997 +
21998 /*
21999 * No need to follow this irqs off/on section - it's straight
22000 * and short:
22001 */
22002 ENABLE_INTERRUPTS(CLBR_NONE)
22003 - SAVE_ARGS 8,0
22004 movq %rax,ORIG_RAX-ARGOFFSET(%rsp)
22005 movq %rcx,RIP-ARGOFFSET(%rsp)
22006 CFI_REL_OFFSET rip,RIP-ARGOFFSET
22007 - testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
22008 + GET_THREAD_INFO(%rcx)
22009 + testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%rcx)
22010 jnz tracesys
22011 system_call_fastpath:
22012 #if __SYSCALL_MASK == ~0
22013 @@ -625,7 +1066,7 @@ system_call_fastpath:
22014 cmpl $__NR_syscall_max,%eax
22015 #endif
22016 ja badsys
22017 - movq %r10,%rcx
22018 + movq R10-ARGOFFSET(%rsp),%rcx
22019 call *sys_call_table(,%rax,8) # XXX: rip relative
22020 movq %rax,RAX-ARGOFFSET(%rsp)
22021 /*
22022 @@ -639,10 +1080,13 @@ sysret_check:
22023 LOCKDEP_SYS_EXIT
22024 DISABLE_INTERRUPTS(CLBR_NONE)
22025 TRACE_IRQS_OFF
22026 - movl TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET),%edx
22027 + GET_THREAD_INFO(%rcx)
22028 + movl TI_flags(%rcx),%edx
22029 andl %edi,%edx
22030 jnz sysret_careful
22031 CFI_REMEMBER_STATE
22032 + pax_exit_kernel_user
22033 + pax_erase_kstack
22034 /*
22035 * sysretq will re-enable interrupts:
22036 */
22037 @@ -694,14 +1138,18 @@ badsys:
22038 * jump back to the normal fast path.
22039 */
22040 auditsys:
22041 - movq %r10,%r9 /* 6th arg: 4th syscall arg */
22042 + movq R10-ARGOFFSET(%rsp),%r9 /* 6th arg: 4th syscall arg */
22043 movq %rdx,%r8 /* 5th arg: 3rd syscall arg */
22044 movq %rsi,%rcx /* 4th arg: 2nd syscall arg */
22045 movq %rdi,%rdx /* 3rd arg: 1st syscall arg */
22046 movq %rax,%rsi /* 2nd arg: syscall number */
22047 movl $AUDIT_ARCH_X86_64,%edi /* 1st arg: audit arch */
22048 call __audit_syscall_entry
22049 +
22050 + pax_erase_kstack
22051 +
22052 LOAD_ARGS 0 /* reload call-clobbered registers */
22053 + pax_set_fptr_mask
22054 jmp system_call_fastpath
22055
22056 /*
22057 @@ -722,7 +1170,7 @@ sysret_audit:
22058 /* Do syscall tracing */
22059 tracesys:
22060 #ifdef CONFIG_AUDITSYSCALL
22061 - testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
22062 + testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags(%rcx)
22063 jz auditsys
22064 #endif
22065 SAVE_REST
22066 @@ -730,12 +1178,16 @@ tracesys:
22067 FIXUP_TOP_OF_STACK %rdi
22068 movq %rsp,%rdi
22069 call syscall_trace_enter
22070 +
22071 + pax_erase_kstack
22072 +
22073 /*
22074 * Reload arg registers from stack in case ptrace changed them.
22075 * We don't reload %rax because syscall_trace_enter() returned
22076 * the value it wants us to use in the table lookup.
22077 */
22078 LOAD_ARGS ARGOFFSET, 1
22079 + pax_set_fptr_mask
22080 RESTORE_REST
22081 #if __SYSCALL_MASK == ~0
22082 cmpq $__NR_syscall_max,%rax
22083 @@ -744,7 +1196,7 @@ tracesys:
22084 cmpl $__NR_syscall_max,%eax
22085 #endif
22086 ja int_ret_from_sys_call /* RAX(%rsp) set to -ENOSYS above */
22087 - movq %r10,%rcx /* fixup for C */
22088 + movq R10-ARGOFFSET(%rsp),%rcx /* fixup for C */
22089 call *sys_call_table(,%rax,8)
22090 movq %rax,RAX-ARGOFFSET(%rsp)
22091 /* Use IRET because user could have changed frame */
22092 @@ -765,7 +1217,9 @@ GLOBAL(int_with_check)
22093 andl %edi,%edx
22094 jnz int_careful
22095 andl $~TS_COMPAT,TI_status(%rcx)
22096 - jmp retint_swapgs
22097 + pax_exit_kernel_user
22098 + pax_erase_kstack
22099 + jmp retint_swapgs_pax
22100
22101 /* Either reschedule or signal or syscall exit tracking needed. */
22102 /* First do a reschedule test. */
22103 @@ -811,7 +1265,7 @@ int_restore_rest:
22104 TRACE_IRQS_OFF
22105 jmp int_with_check
22106 CFI_ENDPROC
22107 -END(system_call)
22108 +ENDPROC(system_call)
22109
22110 .macro FORK_LIKE func
22111 ENTRY(stub_\func)
22112 @@ -824,9 +1278,10 @@ ENTRY(stub_\func)
22113 DEFAULT_FRAME 0 8 /* offset 8: return address */
22114 call sys_\func
22115 RESTORE_TOP_OF_STACK %r11, 8
22116 + pax_force_retaddr
22117 ret $REST_SKIP /* pop extended registers */
22118 CFI_ENDPROC
22119 -END(stub_\func)
22120 +ENDPROC(stub_\func)
22121 .endm
22122
22123 .macro FIXED_FRAME label,func
22124 @@ -836,9 +1291,10 @@ ENTRY(\label)
22125 FIXUP_TOP_OF_STACK %r11, 8-ARGOFFSET
22126 call \func
22127 RESTORE_TOP_OF_STACK %r11, 8-ARGOFFSET
22128 + pax_force_retaddr
22129 ret
22130 CFI_ENDPROC
22131 -END(\label)
22132 +ENDPROC(\label)
22133 .endm
22134
22135 FORK_LIKE clone
22136 @@ -855,9 +1311,10 @@ ENTRY(ptregscall_common)
22137 movq_cfi_restore R12+8, r12
22138 movq_cfi_restore RBP+8, rbp
22139 movq_cfi_restore RBX+8, rbx
22140 + pax_force_retaddr
22141 ret $REST_SKIP /* pop extended registers */
22142 CFI_ENDPROC
22143 -END(ptregscall_common)
22144 +ENDPROC(ptregscall_common)
22145
22146 ENTRY(stub_execve)
22147 CFI_STARTPROC
22148 @@ -870,7 +1327,7 @@ ENTRY(stub_execve)
22149 RESTORE_REST
22150 jmp int_ret_from_sys_call
22151 CFI_ENDPROC
22152 -END(stub_execve)
22153 +ENDPROC(stub_execve)
22154
22155 /*
22156 * sigreturn is special because it needs to restore all registers on return.
22157 @@ -887,7 +1344,7 @@ ENTRY(stub_rt_sigreturn)
22158 RESTORE_REST
22159 jmp int_ret_from_sys_call
22160 CFI_ENDPROC
22161 -END(stub_rt_sigreturn)
22162 +ENDPROC(stub_rt_sigreturn)
22163
22164 #ifdef CONFIG_X86_X32_ABI
22165 ENTRY(stub_x32_rt_sigreturn)
22166 @@ -901,7 +1358,7 @@ ENTRY(stub_x32_rt_sigreturn)
22167 RESTORE_REST
22168 jmp int_ret_from_sys_call
22169 CFI_ENDPROC
22170 -END(stub_x32_rt_sigreturn)
22171 +ENDPROC(stub_x32_rt_sigreturn)
22172
22173 ENTRY(stub_x32_execve)
22174 CFI_STARTPROC
22175 @@ -915,7 +1372,7 @@ ENTRY(stub_x32_execve)
22176 RESTORE_REST
22177 jmp int_ret_from_sys_call
22178 CFI_ENDPROC
22179 -END(stub_x32_execve)
22180 +ENDPROC(stub_x32_execve)
22181
22182 #endif
22183
22184 @@ -952,7 +1409,7 @@ vector=vector+1
22185 2: jmp common_interrupt
22186 .endr
22187 CFI_ENDPROC
22188 -END(irq_entries_start)
22189 +ENDPROC(irq_entries_start)
22190
22191 .previous
22192 END(interrupt)
22193 @@ -972,6 +1429,16 @@ END(interrupt)
22194 subq $ORIG_RAX-RBP, %rsp
22195 CFI_ADJUST_CFA_OFFSET ORIG_RAX-RBP
22196 SAVE_ARGS_IRQ
22197 +#ifdef CONFIG_PAX_MEMORY_UDEREF
22198 + testb $3, CS(%rdi)
22199 + jnz 1f
22200 + pax_enter_kernel
22201 + jmp 2f
22202 +1: pax_enter_kernel_user
22203 +2:
22204 +#else
22205 + pax_enter_kernel
22206 +#endif
22207 call \func
22208 .endm
22209
22210 @@ -1004,7 +1471,7 @@ ret_from_intr:
22211
22212 exit_intr:
22213 GET_THREAD_INFO(%rcx)
22214 - testl $3,CS-ARGOFFSET(%rsp)
22215 + testb $3,CS-ARGOFFSET(%rsp)
22216 je retint_kernel
22217
22218 /* Interrupt came from user space */
22219 @@ -1026,12 +1493,16 @@ retint_swapgs: /* return to user-space */
22220 * The iretq could re-enable interrupts:
22221 */
22222 DISABLE_INTERRUPTS(CLBR_ANY)
22223 + pax_exit_kernel_user
22224 +retint_swapgs_pax:
22225 TRACE_IRQS_IRETQ
22226 SWAPGS
22227 jmp restore_args
22228
22229 retint_restore_args: /* return to kernel space */
22230 DISABLE_INTERRUPTS(CLBR_ANY)
22231 + pax_exit_kernel
22232 + pax_force_retaddr (RIP-ARGOFFSET)
22233 /*
22234 * The iretq could re-enable interrupts:
22235 */
22236 @@ -1114,7 +1585,7 @@ ENTRY(retint_kernel)
22237 #endif
22238
22239 CFI_ENDPROC
22240 -END(common_interrupt)
22241 +ENDPROC(common_interrupt)
22242 /*
22243 * End of kprobes section
22244 */
22245 @@ -1132,7 +1603,7 @@ ENTRY(\sym)
22246 interrupt \do_sym
22247 jmp ret_from_intr
22248 CFI_ENDPROC
22249 -END(\sym)
22250 +ENDPROC(\sym)
22251 .endm
22252
22253 #ifdef CONFIG_TRACING
22254 @@ -1215,12 +1686,22 @@ ENTRY(\sym)
22255 CFI_ADJUST_CFA_OFFSET ORIG_RAX-R15
22256 call error_entry
22257 DEFAULT_FRAME 0
22258 +#ifdef CONFIG_PAX_MEMORY_UDEREF
22259 + testb $3, CS(%rsp)
22260 + jnz 1f
22261 + pax_enter_kernel
22262 + jmp 2f
22263 +1: pax_enter_kernel_user
22264 +2:
22265 +#else
22266 + pax_enter_kernel
22267 +#endif
22268 movq %rsp,%rdi /* pt_regs pointer */
22269 xorl %esi,%esi /* no error code */
22270 call \do_sym
22271 jmp error_exit /* %ebx: no swapgs flag */
22272 CFI_ENDPROC
22273 -END(\sym)
22274 +ENDPROC(\sym)
22275 .endm
22276
22277 .macro paranoidzeroentry sym do_sym
22278 @@ -1233,15 +1714,25 @@ ENTRY(\sym)
22279 CFI_ADJUST_CFA_OFFSET ORIG_RAX-R15
22280 call save_paranoid
22281 TRACE_IRQS_OFF
22282 +#ifdef CONFIG_PAX_MEMORY_UDEREF
22283 + testb $3, CS(%rsp)
22284 + jnz 1f
22285 + pax_enter_kernel
22286 + jmp 2f
22287 +1: pax_enter_kernel_user
22288 +2:
22289 +#else
22290 + pax_enter_kernel
22291 +#endif
22292 movq %rsp,%rdi /* pt_regs pointer */
22293 xorl %esi,%esi /* no error code */
22294 call \do_sym
22295 jmp paranoid_exit /* %ebx: no swapgs flag */
22296 CFI_ENDPROC
22297 -END(\sym)
22298 +ENDPROC(\sym)
22299 .endm
22300
22301 -#define INIT_TSS_IST(x) PER_CPU_VAR(init_tss) + (TSS_ist + ((x) - 1) * 8)
22302 +#define INIT_TSS_IST(x) (TSS_ist + ((x) - 1) * 8)(%r12)
22303 .macro paranoidzeroentry_ist sym do_sym ist
22304 ENTRY(\sym)
22305 INTR_FRAME
22306 @@ -1252,14 +1743,30 @@ ENTRY(\sym)
22307 CFI_ADJUST_CFA_OFFSET ORIG_RAX-R15
22308 call save_paranoid
22309 TRACE_IRQS_OFF_DEBUG
22310 +#ifdef CONFIG_PAX_MEMORY_UDEREF
22311 + testb $3, CS(%rsp)
22312 + jnz 1f
22313 + pax_enter_kernel
22314 + jmp 2f
22315 +1: pax_enter_kernel_user
22316 +2:
22317 +#else
22318 + pax_enter_kernel
22319 +#endif
22320 movq %rsp,%rdi /* pt_regs pointer */
22321 xorl %esi,%esi /* no error code */
22322 +#ifdef CONFIG_SMP
22323 + imul $TSS_size, PER_CPU_VAR(cpu_number), %r12d
22324 + lea init_tss(%r12), %r12
22325 +#else
22326 + lea init_tss(%rip), %r12
22327 +#endif
22328 subq $EXCEPTION_STKSZ, INIT_TSS_IST(\ist)
22329 call \do_sym
22330 addq $EXCEPTION_STKSZ, INIT_TSS_IST(\ist)
22331 jmp paranoid_exit /* %ebx: no swapgs flag */
22332 CFI_ENDPROC
22333 -END(\sym)
22334 +ENDPROC(\sym)
22335 .endm
22336
22337 .macro errorentry sym do_sym
22338 @@ -1271,13 +1778,23 @@ ENTRY(\sym)
22339 CFI_ADJUST_CFA_OFFSET ORIG_RAX-R15
22340 call error_entry
22341 DEFAULT_FRAME 0
22342 +#ifdef CONFIG_PAX_MEMORY_UDEREF
22343 + testb $3, CS(%rsp)
22344 + jnz 1f
22345 + pax_enter_kernel
22346 + jmp 2f
22347 +1: pax_enter_kernel_user
22348 +2:
22349 +#else
22350 + pax_enter_kernel
22351 +#endif
22352 movq %rsp,%rdi /* pt_regs pointer */
22353 movq ORIG_RAX(%rsp),%rsi /* get error code */
22354 movq $-1,ORIG_RAX(%rsp) /* no syscall to restart */
22355 call \do_sym
22356 jmp error_exit /* %ebx: no swapgs flag */
22357 CFI_ENDPROC
22358 -END(\sym)
22359 +ENDPROC(\sym)
22360 .endm
22361
22362 /* error code is on the stack already */
22363 @@ -1291,13 +1808,23 @@ ENTRY(\sym)
22364 call save_paranoid
22365 DEFAULT_FRAME 0
22366 TRACE_IRQS_OFF
22367 +#ifdef CONFIG_PAX_MEMORY_UDEREF
22368 + testb $3, CS(%rsp)
22369 + jnz 1f
22370 + pax_enter_kernel
22371 + jmp 2f
22372 +1: pax_enter_kernel_user
22373 +2:
22374 +#else
22375 + pax_enter_kernel
22376 +#endif
22377 movq %rsp,%rdi /* pt_regs pointer */
22378 movq ORIG_RAX(%rsp),%rsi /* get error code */
22379 movq $-1,ORIG_RAX(%rsp) /* no syscall to restart */
22380 call \do_sym
22381 jmp paranoid_exit /* %ebx: no swapgs flag */
22382 CFI_ENDPROC
22383 -END(\sym)
22384 +ENDPROC(\sym)
22385 .endm
22386
22387 zeroentry divide_error do_divide_error
22388 @@ -1327,9 +1854,10 @@ gs_change:
22389 2: mfence /* workaround */
22390 SWAPGS
22391 popfq_cfi
22392 + pax_force_retaddr
22393 ret
22394 CFI_ENDPROC
22395 -END(native_load_gs_index)
22396 +ENDPROC(native_load_gs_index)
22397
22398 _ASM_EXTABLE(gs_change,bad_gs)
22399 .section .fixup,"ax"
22400 @@ -1357,9 +1885,10 @@ ENTRY(call_softirq)
22401 CFI_DEF_CFA_REGISTER rsp
22402 CFI_ADJUST_CFA_OFFSET -8
22403 decl PER_CPU_VAR(irq_count)
22404 + pax_force_retaddr
22405 ret
22406 CFI_ENDPROC
22407 -END(call_softirq)
22408 +ENDPROC(call_softirq)
22409
22410 #ifdef CONFIG_XEN
22411 zeroentry xen_hypervisor_callback xen_do_hypervisor_callback
22412 @@ -1397,7 +1926,7 @@ ENTRY(xen_do_hypervisor_callback) # do_hypervisor_callback(struct *pt_regs)
22413 decl PER_CPU_VAR(irq_count)
22414 jmp error_exit
22415 CFI_ENDPROC
22416 -END(xen_do_hypervisor_callback)
22417 +ENDPROC(xen_do_hypervisor_callback)
22418
22419 /*
22420 * Hypervisor uses this for application faults while it executes.
22421 @@ -1456,7 +1985,7 @@ ENTRY(xen_failsafe_callback)
22422 SAVE_ALL
22423 jmp error_exit
22424 CFI_ENDPROC
22425 -END(xen_failsafe_callback)
22426 +ENDPROC(xen_failsafe_callback)
22427
22428 apicinterrupt3 HYPERVISOR_CALLBACK_VECTOR \
22429 xen_hvm_callback_vector xen_evtchn_do_upcall
22430 @@ -1508,18 +2037,33 @@ ENTRY(paranoid_exit)
22431 DEFAULT_FRAME
22432 DISABLE_INTERRUPTS(CLBR_NONE)
22433 TRACE_IRQS_OFF_DEBUG
22434 - testl %ebx,%ebx /* swapgs needed? */
22435 + testl $1,%ebx /* swapgs needed? */
22436 jnz paranoid_restore
22437 - testl $3,CS(%rsp)
22438 + testb $3,CS(%rsp)
22439 jnz paranoid_userspace
22440 +#ifdef CONFIG_PAX_MEMORY_UDEREF
22441 + pax_exit_kernel
22442 + TRACE_IRQS_IRETQ 0
22443 + SWAPGS_UNSAFE_STACK
22444 + RESTORE_ALL 8
22445 + pax_force_retaddr_bts
22446 + jmp irq_return
22447 +#endif
22448 paranoid_swapgs:
22449 +#ifdef CONFIG_PAX_MEMORY_UDEREF
22450 + pax_exit_kernel_user
22451 +#else
22452 + pax_exit_kernel
22453 +#endif
22454 TRACE_IRQS_IRETQ 0
22455 SWAPGS_UNSAFE_STACK
22456 RESTORE_ALL 8
22457 jmp irq_return
22458 paranoid_restore:
22459 + pax_exit_kernel
22460 TRACE_IRQS_IRETQ_DEBUG 0
22461 RESTORE_ALL 8
22462 + pax_force_retaddr_bts
22463 jmp irq_return
22464 paranoid_userspace:
22465 GET_THREAD_INFO(%rcx)
22466 @@ -1548,7 +2092,7 @@ paranoid_schedule:
22467 TRACE_IRQS_OFF
22468 jmp paranoid_userspace
22469 CFI_ENDPROC
22470 -END(paranoid_exit)
22471 +ENDPROC(paranoid_exit)
22472
22473 /*
22474 * Exception entry point. This expects an error code/orig_rax on the stack.
22475 @@ -1575,12 +2119,13 @@ ENTRY(error_entry)
22476 movq_cfi r14, R14+8
22477 movq_cfi r15, R15+8
22478 xorl %ebx,%ebx
22479 - testl $3,CS+8(%rsp)
22480 + testb $3,CS+8(%rsp)
22481 je error_kernelspace
22482 error_swapgs:
22483 SWAPGS
22484 error_sti:
22485 TRACE_IRQS_OFF
22486 + pax_force_retaddr_bts
22487 ret
22488
22489 /*
22490 @@ -1607,7 +2152,7 @@ bstep_iret:
22491 movq %rcx,RIP+8(%rsp)
22492 jmp error_swapgs
22493 CFI_ENDPROC
22494 -END(error_entry)
22495 +ENDPROC(error_entry)
22496
22497
22498 /* ebx: no swapgs flag (1: don't need swapgs, 0: need it) */
22499 @@ -1618,7 +2163,7 @@ ENTRY(error_exit)
22500 DISABLE_INTERRUPTS(CLBR_NONE)
22501 TRACE_IRQS_OFF
22502 GET_THREAD_INFO(%rcx)
22503 - testl %eax,%eax
22504 + testl $1,%eax
22505 jne retint_kernel
22506 LOCKDEP_SYS_EXIT_IRQ
22507 movl TI_flags(%rcx),%edx
22508 @@ -1627,7 +2172,7 @@ ENTRY(error_exit)
22509 jnz retint_careful
22510 jmp retint_swapgs
22511 CFI_ENDPROC
22512 -END(error_exit)
22513 +ENDPROC(error_exit)
22514
22515 /*
22516 * Test if a given stack is an NMI stack or not.
22517 @@ -1685,9 +2230,11 @@ ENTRY(nmi)
22518 * If %cs was not the kernel segment, then the NMI triggered in user
22519 * space, which means it is definitely not nested.
22520 */
22521 + cmpl $__KERNEXEC_KERNEL_CS, 16(%rsp)
22522 + je 1f
22523 cmpl $__KERNEL_CS, 16(%rsp)
22524 jne first_nmi
22525 -
22526 +1:
22527 /*
22528 * Check the special variable on the stack to see if NMIs are
22529 * executing.
22530 @@ -1721,8 +2268,7 @@ nested_nmi:
22531
22532 1:
22533 /* Set up the interrupted NMIs stack to jump to repeat_nmi */
22534 - leaq -1*8(%rsp), %rdx
22535 - movq %rdx, %rsp
22536 + subq $8, %rsp
22537 CFI_ADJUST_CFA_OFFSET 1*8
22538 leaq -10*8(%rsp), %rdx
22539 pushq_cfi $__KERNEL_DS
22540 @@ -1740,6 +2286,7 @@ nested_nmi_out:
22541 CFI_RESTORE rdx
22542
22543 /* No need to check faults here */
22544 +# pax_force_retaddr_bts
22545 INTERRUPT_RETURN
22546
22547 CFI_RESTORE_STATE
22548 @@ -1856,6 +2403,8 @@ end_repeat_nmi:
22549 */
22550 movq %cr2, %r12
22551
22552 + pax_enter_kernel_nmi
22553 +
22554 /* paranoidentry do_nmi, 0; without TRACE_IRQS_OFF */
22555 movq %rsp,%rdi
22556 movq $-1,%rsi
22557 @@ -1868,26 +2417,31 @@ end_repeat_nmi:
22558 movq %r12, %cr2
22559 1:
22560
22561 - testl %ebx,%ebx /* swapgs needed? */
22562 + testl $1,%ebx /* swapgs needed? */
22563 jnz nmi_restore
22564 nmi_swapgs:
22565 SWAPGS_UNSAFE_STACK
22566 nmi_restore:
22567 + pax_exit_kernel_nmi
22568 /* Pop the extra iret frame at once */
22569 RESTORE_ALL 6*8
22570 + testb $3, 8(%rsp)
22571 + jnz 1f
22572 + pax_force_retaddr_bts
22573 +1:
22574
22575 /* Clear the NMI executing stack variable */
22576 movq $0, 5*8(%rsp)
22577 jmp irq_return
22578 CFI_ENDPROC
22579 -END(nmi)
22580 +ENDPROC(nmi)
22581
22582 ENTRY(ignore_sysret)
22583 CFI_STARTPROC
22584 mov $-ENOSYS,%eax
22585 sysret
22586 CFI_ENDPROC
22587 -END(ignore_sysret)
22588 +ENDPROC(ignore_sysret)
22589
22590 /*
22591 * End of kprobes section
22592 diff --git a/arch/x86/kernel/ftrace.c b/arch/x86/kernel/ftrace.c
22593 index d4bdd25..912664c 100644
22594 --- a/arch/x86/kernel/ftrace.c
22595 +++ b/arch/x86/kernel/ftrace.c
22596 @@ -105,6 +105,8 @@ ftrace_modify_code_direct(unsigned long ip, unsigned const char *old_code,
22597 {
22598 unsigned char replaced[MCOUNT_INSN_SIZE];
22599
22600 + ip = ktla_ktva(ip);
22601 +
22602 /*
22603 * Note: Due to modules and __init, code can
22604 * disappear and change, we need to protect against faulting
22605 @@ -227,7 +229,7 @@ int ftrace_update_ftrace_func(ftrace_func_t func)
22606 unsigned char old[MCOUNT_INSN_SIZE], *new;
22607 int ret;
22608
22609 - memcpy(old, &ftrace_call, MCOUNT_INSN_SIZE);
22610 + memcpy(old, (void *)ktla_ktva((unsigned long)ftrace_call), MCOUNT_INSN_SIZE);
22611 new = ftrace_call_replace(ip, (unsigned long)func);
22612
22613 /* See comment above by declaration of modifying_ftrace_code */
22614 @@ -238,7 +240,7 @@ int ftrace_update_ftrace_func(ftrace_func_t func)
22615 /* Also update the regs callback function */
22616 if (!ret) {
22617 ip = (unsigned long)(&ftrace_regs_call);
22618 - memcpy(old, &ftrace_regs_call, MCOUNT_INSN_SIZE);
22619 + memcpy(old, ktla_ktva((void *)&ftrace_regs_call), MCOUNT_INSN_SIZE);
22620 new = ftrace_call_replace(ip, (unsigned long)func);
22621 ret = ftrace_modify_code(ip, old, new);
22622 }
22623 @@ -291,7 +293,7 @@ static int ftrace_write(unsigned long ip, const char *val, int size)
22624 * kernel identity mapping to modify code.
22625 */
22626 if (within(ip, (unsigned long)_text, (unsigned long)_etext))
22627 - ip = (unsigned long)__va(__pa_symbol(ip));
22628 + ip = (unsigned long)__va(__pa_symbol(ktla_ktva(ip)));
22629
22630 return probe_kernel_write((void *)ip, val, size);
22631 }
22632 @@ -301,7 +303,7 @@ static int add_break(unsigned long ip, const char *old)
22633 unsigned char replaced[MCOUNT_INSN_SIZE];
22634 unsigned char brk = BREAKPOINT_INSTRUCTION;
22635
22636 - if (probe_kernel_read(replaced, (void *)ip, MCOUNT_INSN_SIZE))
22637 + if (probe_kernel_read(replaced, (void *)ktla_ktva(ip), MCOUNT_INSN_SIZE))
22638 return -EFAULT;
22639
22640 /* Make sure it is what we expect it to be */
22641 @@ -649,7 +651,7 @@ ftrace_modify_code(unsigned long ip, unsigned const char *old_code,
22642 return ret;
22643
22644 fail_update:
22645 - probe_kernel_write((void *)ip, &old_code[0], 1);
22646 + probe_kernel_write((void *)ktla_ktva(ip), &old_code[0], 1);
22647 goto out;
22648 }
22649
22650 @@ -682,6 +684,8 @@ static int ftrace_mod_jmp(unsigned long ip,
22651 {
22652 unsigned char code[MCOUNT_INSN_SIZE];
22653
22654 + ip = ktla_ktva(ip);
22655 +
22656 if (probe_kernel_read(code, (void *)ip, MCOUNT_INSN_SIZE))
22657 return -EFAULT;
22658
22659 diff --git a/arch/x86/kernel/head64.c b/arch/x86/kernel/head64.c
22660 index 1be8e43..d9b9ef6 100644
22661 --- a/arch/x86/kernel/head64.c
22662 +++ b/arch/x86/kernel/head64.c
22663 @@ -67,12 +67,12 @@ again:
22664 pgd = *pgd_p;
22665
22666 /*
22667 - * The use of __START_KERNEL_map rather than __PAGE_OFFSET here is
22668 - * critical -- __PAGE_OFFSET would point us back into the dynamic
22669 + * The use of __early_va rather than __va here is critical:
22670 + * __va would point us back into the dynamic
22671 * range and we might end up looping forever...
22672 */
22673 if (pgd)
22674 - pud_p = (pudval_t *)((pgd & PTE_PFN_MASK) + __START_KERNEL_map - phys_base);
22675 + pud_p = (pudval_t *)(__early_va(pgd & PTE_PFN_MASK));
22676 else {
22677 if (next_early_pgt >= EARLY_DYNAMIC_PAGE_TABLES) {
22678 reset_early_page_tables();
22679 @@ -82,13 +82,13 @@ again:
22680 pud_p = (pudval_t *)early_dynamic_pgts[next_early_pgt++];
22681 for (i = 0; i < PTRS_PER_PUD; i++)
22682 pud_p[i] = 0;
22683 - *pgd_p = (pgdval_t)pud_p - __START_KERNEL_map + phys_base + _KERNPG_TABLE;
22684 + *pgd_p = (pgdval_t)__pa(pud_p) + _KERNPG_TABLE;
22685 }
22686 pud_p += pud_index(address);
22687 pud = *pud_p;
22688
22689 if (pud)
22690 - pmd_p = (pmdval_t *)((pud & PTE_PFN_MASK) + __START_KERNEL_map - phys_base);
22691 + pmd_p = (pmdval_t *)(__early_va(pud & PTE_PFN_MASK));
22692 else {
22693 if (next_early_pgt >= EARLY_DYNAMIC_PAGE_TABLES) {
22694 reset_early_page_tables();
22695 @@ -98,7 +98,7 @@ again:
22696 pmd_p = (pmdval_t *)early_dynamic_pgts[next_early_pgt++];
22697 for (i = 0; i < PTRS_PER_PMD; i++)
22698 pmd_p[i] = 0;
22699 - *pud_p = (pudval_t)pmd_p - __START_KERNEL_map + phys_base + _KERNPG_TABLE;
22700 + *pud_p = (pudval_t)__pa(pmd_p) + _KERNPG_TABLE;
22701 }
22702 pmd = (physaddr & PMD_MASK) + early_pmd_flags;
22703 pmd_p[pmd_index(address)] = pmd;
22704 @@ -175,7 +175,6 @@ asmlinkage void __init x86_64_start_kernel(char * real_mode_data)
22705 if (console_loglevel == 10)
22706 early_printk("Kernel alive\n");
22707
22708 - clear_page(init_level4_pgt);
22709 /* set init_level4_pgt kernel high mapping*/
22710 init_level4_pgt[511] = early_level4_pgt[511];
22711
22712 diff --git a/arch/x86/kernel/head_32.S b/arch/x86/kernel/head_32.S
22713 index 81ba276..30c5411 100644
22714 --- a/arch/x86/kernel/head_32.S
22715 +++ b/arch/x86/kernel/head_32.S
22716 @@ -26,6 +26,12 @@
22717 /* Physical address */
22718 #define pa(X) ((X) - __PAGE_OFFSET)
22719
22720 +#ifdef CONFIG_PAX_KERNEXEC
22721 +#define ta(X) (X)
22722 +#else
22723 +#define ta(X) ((X) - __PAGE_OFFSET)
22724 +#endif
22725 +
22726 /*
22727 * References to members of the new_cpu_data structure.
22728 */
22729 @@ -55,11 +61,7 @@
22730 * and small than max_low_pfn, otherwise will waste some page table entries
22731 */
22732
22733 -#if PTRS_PER_PMD > 1
22734 -#define PAGE_TABLE_SIZE(pages) (((pages) / PTRS_PER_PMD) + PTRS_PER_PGD)
22735 -#else
22736 -#define PAGE_TABLE_SIZE(pages) ((pages) / PTRS_PER_PGD)
22737 -#endif
22738 +#define PAGE_TABLE_SIZE(pages) ((pages) / PTRS_PER_PTE)
22739
22740 /* Number of possible pages in the lowmem region */
22741 LOWMEM_PAGES = (((1<<32) - __PAGE_OFFSET) >> PAGE_SHIFT)
22742 @@ -78,6 +80,12 @@ INIT_MAP_SIZE = PAGE_TABLE_SIZE(KERNEL_PAGES) * PAGE_SIZE
22743 RESERVE_BRK(pagetables, INIT_MAP_SIZE)
22744
22745 /*
22746 + * Real beginning of normal "text" segment
22747 + */
22748 +ENTRY(stext)
22749 +ENTRY(_stext)
22750 +
22751 +/*
22752 * 32-bit kernel entrypoint; only used by the boot CPU. On entry,
22753 * %esi points to the real-mode code as a 32-bit pointer.
22754 * CS and DS must be 4 GB flat segments, but we don't depend on
22755 @@ -85,6 +93,13 @@ RESERVE_BRK(pagetables, INIT_MAP_SIZE)
22756 * can.
22757 */
22758 __HEAD
22759 +
22760 +#ifdef CONFIG_PAX_KERNEXEC
22761 + jmp startup_32
22762 +/* PaX: fill first page in .text with int3 to catch NULL derefs in kernel mode */
22763 +.fill PAGE_SIZE-5,1,0xcc
22764 +#endif
22765 +
22766 ENTRY(startup_32)
22767 movl pa(stack_start),%ecx
22768
22769 @@ -106,6 +121,59 @@ ENTRY(startup_32)
22770 2:
22771 leal -__PAGE_OFFSET(%ecx),%esp
22772
22773 +#ifdef CONFIG_SMP
22774 + movl $pa(cpu_gdt_table),%edi
22775 + movl $__per_cpu_load,%eax
22776 + movw %ax,GDT_ENTRY_PERCPU * 8 + 2(%edi)
22777 + rorl $16,%eax
22778 + movb %al,GDT_ENTRY_PERCPU * 8 + 4(%edi)
22779 + movb %ah,GDT_ENTRY_PERCPU * 8 + 7(%edi)
22780 + movl $__per_cpu_end - 1,%eax
22781 + subl $__per_cpu_start,%eax
22782 + movw %ax,GDT_ENTRY_PERCPU * 8 + 0(%edi)
22783 +#endif
22784 +
22785 +#ifdef CONFIG_PAX_MEMORY_UDEREF
22786 + movl $NR_CPUS,%ecx
22787 + movl $pa(cpu_gdt_table),%edi
22788 +1:
22789 + movl $((((__PAGE_OFFSET-1) & 0xf0000000) >> 12) | 0x00c09700),GDT_ENTRY_KERNEL_DS * 8 + 4(%edi)
22790 + movl $((((__PAGE_OFFSET-1) & 0xf0000000) >> 12) | 0x00c0fb00),GDT_ENTRY_DEFAULT_USER_CS * 8 + 4(%edi)
22791 + movl $((((__PAGE_OFFSET-1) & 0xf0000000) >> 12) | 0x00c0f300),GDT_ENTRY_DEFAULT_USER_DS * 8 + 4(%edi)
22792 + addl $PAGE_SIZE_asm,%edi
22793 + loop 1b
22794 +#endif
22795 +
22796 +#ifdef CONFIG_PAX_KERNEXEC
22797 + movl $pa(boot_gdt),%edi
22798 + movl $__LOAD_PHYSICAL_ADDR,%eax
22799 + movw %ax,GDT_ENTRY_BOOT_CS * 8 + 2(%edi)
22800 + rorl $16,%eax
22801 + movb %al,GDT_ENTRY_BOOT_CS * 8 + 4(%edi)
22802 + movb %ah,GDT_ENTRY_BOOT_CS * 8 + 7(%edi)
22803 + rorl $16,%eax
22804 +
22805 + ljmp $(__BOOT_CS),$1f
22806 +1:
22807 +
22808 + movl $NR_CPUS,%ecx
22809 + movl $pa(cpu_gdt_table),%edi
22810 + addl $__PAGE_OFFSET,%eax
22811 +1:
22812 + movb $0xc0,GDT_ENTRY_KERNEL_CS * 8 + 6(%edi)
22813 + movb $0xc0,GDT_ENTRY_KERNEXEC_KERNEL_CS * 8 + 6(%edi)
22814 + movw %ax,GDT_ENTRY_KERNEL_CS * 8 + 2(%edi)
22815 + movw %ax,GDT_ENTRY_KERNEXEC_KERNEL_CS * 8 + 2(%edi)
22816 + rorl $16,%eax
22817 + movb %al,GDT_ENTRY_KERNEL_CS * 8 + 4(%edi)
22818 + movb %al,GDT_ENTRY_KERNEXEC_KERNEL_CS * 8 + 4(%edi)
22819 + movb %ah,GDT_ENTRY_KERNEL_CS * 8 + 7(%edi)
22820 + movb %ah,GDT_ENTRY_KERNEXEC_KERNEL_CS * 8 + 7(%edi)
22821 + rorl $16,%eax
22822 + addl $PAGE_SIZE_asm,%edi
22823 + loop 1b
22824 +#endif
22825 +
22826 /*
22827 * Clear BSS first so that there are no surprises...
22828 */
22829 @@ -201,8 +269,11 @@ ENTRY(startup_32)
22830 movl %eax, pa(max_pfn_mapped)
22831
22832 /* Do early initialization of the fixmap area */
22833 - movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR,%eax
22834 - movl %eax,pa(initial_pg_pmd+0x1000*KPMDS-8)
22835 +#ifdef CONFIG_COMPAT_VDSO
22836 + movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR+_PAGE_USER,pa(initial_pg_pmd+0x1000*KPMDS-8)
22837 +#else
22838 + movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR,pa(initial_pg_pmd+0x1000*KPMDS-8)
22839 +#endif
22840 #else /* Not PAE */
22841
22842 page_pde_offset = (__PAGE_OFFSET >> 20);
22843 @@ -232,8 +303,11 @@ page_pde_offset = (__PAGE_OFFSET >> 20);
22844 movl %eax, pa(max_pfn_mapped)
22845
22846 /* Do early initialization of the fixmap area */
22847 - movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR,%eax
22848 - movl %eax,pa(initial_page_table+0xffc)
22849 +#ifdef CONFIG_COMPAT_VDSO
22850 + movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR+_PAGE_USER,pa(initial_page_table+0xffc)
22851 +#else
22852 + movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR,pa(initial_page_table+0xffc)
22853 +#endif
22854 #endif
22855
22856 #ifdef CONFIG_PARAVIRT
22857 @@ -247,9 +321,7 @@ page_pde_offset = (__PAGE_OFFSET >> 20);
22858 cmpl $num_subarch_entries, %eax
22859 jae bad_subarch
22860
22861 - movl pa(subarch_entries)(,%eax,4), %eax
22862 - subl $__PAGE_OFFSET, %eax
22863 - jmp *%eax
22864 + jmp *pa(subarch_entries)(,%eax,4)
22865
22866 bad_subarch:
22867 WEAK(lguest_entry)
22868 @@ -261,10 +333,10 @@ WEAK(xen_entry)
22869 __INITDATA
22870
22871 subarch_entries:
22872 - .long default_entry /* normal x86/PC */
22873 - .long lguest_entry /* lguest hypervisor */
22874 - .long xen_entry /* Xen hypervisor */
22875 - .long default_entry /* Moorestown MID */
22876 + .long ta(default_entry) /* normal x86/PC */
22877 + .long ta(lguest_entry) /* lguest hypervisor */
22878 + .long ta(xen_entry) /* Xen hypervisor */
22879 + .long ta(default_entry) /* Moorestown MID */
22880 num_subarch_entries = (. - subarch_entries) / 4
22881 .previous
22882 #else
22883 @@ -354,6 +426,7 @@ default_entry:
22884 movl pa(mmu_cr4_features),%eax
22885 movl %eax,%cr4
22886
22887 +#ifdef CONFIG_X86_PAE
22888 testb $X86_CR4_PAE, %al # check if PAE is enabled
22889 jz enable_paging
22890
22891 @@ -382,6 +455,9 @@ default_entry:
22892 /* Make changes effective */
22893 wrmsr
22894
22895 + btsl $_PAGE_BIT_NX-32,pa(__supported_pte_mask+4)
22896 +#endif
22897 +
22898 enable_paging:
22899
22900 /*
22901 @@ -449,14 +525,20 @@ is486:
22902 1: movl $(__KERNEL_DS),%eax # reload all the segment registers
22903 movl %eax,%ss # after changing gdt.
22904
22905 - movl $(__USER_DS),%eax # DS/ES contains default USER segment
22906 +# movl $(__KERNEL_DS),%eax # DS/ES contains default KERNEL segment
22907 movl %eax,%ds
22908 movl %eax,%es
22909
22910 movl $(__KERNEL_PERCPU), %eax
22911 movl %eax,%fs # set this cpu's percpu
22912
22913 +#ifdef CONFIG_CC_STACKPROTECTOR
22914 movl $(__KERNEL_STACK_CANARY),%eax
22915 +#elif defined(CONFIG_PAX_MEMORY_UDEREF)
22916 + movl $(__USER_DS),%eax
22917 +#else
22918 + xorl %eax,%eax
22919 +#endif
22920 movl %eax,%gs
22921
22922 xorl %eax,%eax # Clear LDT
22923 @@ -512,8 +594,11 @@ setup_once:
22924 * relocation. Manually set base address in stack canary
22925 * segment descriptor.
22926 */
22927 - movl $gdt_page,%eax
22928 + movl $cpu_gdt_table,%eax
22929 movl $stack_canary,%ecx
22930 +#ifdef CONFIG_SMP
22931 + addl $__per_cpu_load,%ecx
22932 +#endif
22933 movw %cx, 8 * GDT_ENTRY_STACK_CANARY + 2(%eax)
22934 shrl $16, %ecx
22935 movb %cl, 8 * GDT_ENTRY_STACK_CANARY + 4(%eax)
22936 @@ -544,7 +629,7 @@ ENDPROC(early_idt_handlers)
22937 /* This is global to keep gas from relaxing the jumps */
22938 ENTRY(early_idt_handler)
22939 cld
22940 - cmpl $2,%ss:early_recursion_flag
22941 + cmpl $1,%ss:early_recursion_flag
22942 je hlt_loop
22943 incl %ss:early_recursion_flag
22944
22945 @@ -582,8 +667,8 @@ ENTRY(early_idt_handler)
22946 pushl (20+6*4)(%esp) /* trapno */
22947 pushl $fault_msg
22948 call printk
22949 -#endif
22950 call dump_stack
22951 +#endif
22952 hlt_loop:
22953 hlt
22954 jmp hlt_loop
22955 @@ -602,8 +687,11 @@ ENDPROC(early_idt_handler)
22956 /* This is the default interrupt "handler" :-) */
22957 ALIGN
22958 ignore_int:
22959 - cld
22960 #ifdef CONFIG_PRINTK
22961 + cmpl $2,%ss:early_recursion_flag
22962 + je hlt_loop
22963 + incl %ss:early_recursion_flag
22964 + cld
22965 pushl %eax
22966 pushl %ecx
22967 pushl %edx
22968 @@ -612,9 +700,6 @@ ignore_int:
22969 movl $(__KERNEL_DS),%eax
22970 movl %eax,%ds
22971 movl %eax,%es
22972 - cmpl $2,early_recursion_flag
22973 - je hlt_loop
22974 - incl early_recursion_flag
22975 pushl 16(%esp)
22976 pushl 24(%esp)
22977 pushl 32(%esp)
22978 @@ -648,29 +733,34 @@ ENTRY(setup_once_ref)
22979 /*
22980 * BSS section
22981 */
22982 -__PAGE_ALIGNED_BSS
22983 - .align PAGE_SIZE
22984 #ifdef CONFIG_X86_PAE
22985 +.section .initial_pg_pmd,"a",@progbits
22986 initial_pg_pmd:
22987 .fill 1024*KPMDS,4,0
22988 #else
22989 +.section .initial_page_table,"a",@progbits
22990 ENTRY(initial_page_table)
22991 .fill 1024,4,0
22992 #endif
22993 +.section .initial_pg_fixmap,"a",@progbits
22994 initial_pg_fixmap:
22995 .fill 1024,4,0
22996 +.section .empty_zero_page,"a",@progbits
22997 ENTRY(empty_zero_page)
22998 .fill 4096,1,0
22999 +.section .swapper_pg_dir,"a",@progbits
23000 ENTRY(swapper_pg_dir)
23001 +#ifdef CONFIG_X86_PAE
23002 + .fill 4,8,0
23003 +#else
23004 .fill 1024,4,0
23005 +#endif
23006
23007 /*
23008 * This starts the data section.
23009 */
23010 #ifdef CONFIG_X86_PAE
23011 -__PAGE_ALIGNED_DATA
23012 - /* Page-aligned for the benefit of paravirt? */
23013 - .align PAGE_SIZE
23014 +.section .initial_page_table,"a",@progbits
23015 ENTRY(initial_page_table)
23016 .long pa(initial_pg_pmd+PGD_IDENT_ATTR),0 /* low identity map */
23017 # if KPMDS == 3
23018 @@ -689,12 +779,20 @@ ENTRY(initial_page_table)
23019 # error "Kernel PMDs should be 1, 2 or 3"
23020 # endif
23021 .align PAGE_SIZE /* needs to be page-sized too */
23022 +
23023 +#ifdef CONFIG_PAX_PER_CPU_PGD
23024 +ENTRY(cpu_pgd)
23025 + .rept 2*NR_CPUS
23026 + .fill 4,8,0
23027 + .endr
23028 +#endif
23029 +
23030 #endif
23031
23032 .data
23033 .balign 4
23034 ENTRY(stack_start)
23035 - .long init_thread_union+THREAD_SIZE
23036 + .long init_thread_union+THREAD_SIZE-8
23037
23038 __INITRODATA
23039 int_msg:
23040 @@ -722,7 +820,7 @@ fault_msg:
23041 * segment size, and 32-bit linear address value:
23042 */
23043
23044 - .data
23045 +.section .rodata,"a",@progbits
23046 .globl boot_gdt_descr
23047 .globl idt_descr
23048
23049 @@ -731,7 +829,7 @@ fault_msg:
23050 .word 0 # 32 bit align gdt_desc.address
23051 boot_gdt_descr:
23052 .word __BOOT_DS+7
23053 - .long boot_gdt - __PAGE_OFFSET
23054 + .long pa(boot_gdt)
23055
23056 .word 0 # 32-bit align idt_desc.address
23057 idt_descr:
23058 @@ -742,7 +840,7 @@ idt_descr:
23059 .word 0 # 32 bit align gdt_desc.address
23060 ENTRY(early_gdt_descr)
23061 .word GDT_ENTRIES*8-1
23062 - .long gdt_page /* Overwritten for secondary CPUs */
23063 + .long cpu_gdt_table /* Overwritten for secondary CPUs */
23064
23065 /*
23066 * The boot_gdt must mirror the equivalent in setup.S and is
23067 @@ -751,5 +849,65 @@ ENTRY(early_gdt_descr)
23068 .align L1_CACHE_BYTES
23069 ENTRY(boot_gdt)
23070 .fill GDT_ENTRY_BOOT_CS,8,0
23071 - .quad 0x00cf9a000000ffff /* kernel 4GB code at 0x00000000 */
23072 - .quad 0x00cf92000000ffff /* kernel 4GB data at 0x00000000 */
23073 + .quad 0x00cf9b000000ffff /* kernel 4GB code at 0x00000000 */
23074 + .quad 0x00cf93000000ffff /* kernel 4GB data at 0x00000000 */
23075 +
23076 + .align PAGE_SIZE_asm
23077 +ENTRY(cpu_gdt_table)
23078 + .rept NR_CPUS
23079 + .quad 0x0000000000000000 /* NULL descriptor */
23080 + .quad 0x0000000000000000 /* 0x0b reserved */
23081 + .quad 0x0000000000000000 /* 0x13 reserved */
23082 + .quad 0x0000000000000000 /* 0x1b reserved */
23083 +
23084 +#ifdef CONFIG_PAX_KERNEXEC
23085 + .quad 0x00cf9b000000ffff /* 0x20 alternate kernel 4GB code at 0x00000000 */
23086 +#else
23087 + .quad 0x0000000000000000 /* 0x20 unused */
23088 +#endif
23089 +
23090 + .quad 0x0000000000000000 /* 0x28 unused */
23091 + .quad 0x0000000000000000 /* 0x33 TLS entry 1 */
23092 + .quad 0x0000000000000000 /* 0x3b TLS entry 2 */
23093 + .quad 0x0000000000000000 /* 0x43 TLS entry 3 */
23094 + .quad 0x0000000000000000 /* 0x4b reserved */
23095 + .quad 0x0000000000000000 /* 0x53 reserved */
23096 + .quad 0x0000000000000000 /* 0x5b reserved */
23097 +
23098 + .quad 0x00cf9b000000ffff /* 0x60 kernel 4GB code at 0x00000000 */
23099 + .quad 0x00cf93000000ffff /* 0x68 kernel 4GB data at 0x00000000 */
23100 + .quad 0x00cffb000000ffff /* 0x73 user 4GB code at 0x00000000 */
23101 + .quad 0x00cff3000000ffff /* 0x7b user 4GB data at 0x00000000 */
23102 +
23103 + .quad 0x0000000000000000 /* 0x80 TSS descriptor */
23104 + .quad 0x0000000000000000 /* 0x88 LDT descriptor */
23105 +
23106 + /*
23107 + * Segments used for calling PnP BIOS have byte granularity.
23108 + * The code segments and data segments have fixed 64k limits,
23109 + * the transfer segment sizes are set at run time.
23110 + */
23111 + .quad 0x00409b000000ffff /* 0x90 32-bit code */
23112 + .quad 0x00009b000000ffff /* 0x98 16-bit code */
23113 + .quad 0x000093000000ffff /* 0xa0 16-bit data */
23114 + .quad 0x0000930000000000 /* 0xa8 16-bit data */
23115 + .quad 0x0000930000000000 /* 0xb0 16-bit data */
23116 +
23117 + /*
23118 + * The APM segments have byte granularity and their bases
23119 + * are set at run time. All have 64k limits.
23120 + */
23121 + .quad 0x00409b000000ffff /* 0xb8 APM CS code */
23122 + .quad 0x00009b000000ffff /* 0xc0 APM CS 16 code (16 bit) */
23123 + .quad 0x004093000000ffff /* 0xc8 APM DS data */
23124 +
23125 + .quad 0x00c0930000000000 /* 0xd0 - ESPFIX SS */
23126 + .quad 0x0040930000000000 /* 0xd8 - PERCPU */
23127 + .quad 0x0040910000000017 /* 0xe0 - STACK_CANARY */
23128 + .quad 0x0000000000000000 /* 0xe8 - PCIBIOS_CS */
23129 + .quad 0x0000000000000000 /* 0xf0 - PCIBIOS_DS */
23130 + .quad 0x0000000000000000 /* 0xf8 - GDT entry 31: double-fault TSS */
23131 +
23132 + /* Be sure this is zeroed to avoid false validations in Xen */
23133 + .fill PAGE_SIZE_asm - GDT_SIZE,1,0
23134 + .endr
23135 diff --git a/arch/x86/kernel/head_64.S b/arch/x86/kernel/head_64.S
23136 index e1aabdb..fee4fee 100644
23137 --- a/arch/x86/kernel/head_64.S
23138 +++ b/arch/x86/kernel/head_64.S
23139 @@ -20,6 +20,8 @@
23140 #include <asm/processor-flags.h>
23141 #include <asm/percpu.h>
23142 #include <asm/nops.h>
23143 +#include <asm/cpufeature.h>
23144 +#include <asm/alternative-asm.h>
23145
23146 #ifdef CONFIG_PARAVIRT
23147 #include <asm/asm-offsets.h>
23148 @@ -41,6 +43,12 @@ L4_PAGE_OFFSET = pgd_index(__PAGE_OFFSET)
23149 L3_PAGE_OFFSET = pud_index(__PAGE_OFFSET)
23150 L4_START_KERNEL = pgd_index(__START_KERNEL_map)
23151 L3_START_KERNEL = pud_index(__START_KERNEL_map)
23152 +L4_VMALLOC_START = pgd_index(VMALLOC_START)
23153 +L3_VMALLOC_START = pud_index(VMALLOC_START)
23154 +L4_VMALLOC_END = pgd_index(VMALLOC_END)
23155 +L3_VMALLOC_END = pud_index(VMALLOC_END)
23156 +L4_VMEMMAP_START = pgd_index(VMEMMAP_START)
23157 +L3_VMEMMAP_START = pud_index(VMEMMAP_START)
23158
23159 .text
23160 __HEAD
23161 @@ -89,11 +97,24 @@ startup_64:
23162 * Fixup the physical addresses in the page table
23163 */
23164 addq %rbp, early_level4_pgt + (L4_START_KERNEL*8)(%rip)
23165 + addq %rbp, init_level4_pgt + (L4_PAGE_OFFSET*8)(%rip)
23166 + addq %rbp, init_level4_pgt + (L4_VMALLOC_START*8)(%rip)
23167 + addq %rbp, init_level4_pgt + (L4_VMALLOC_END*8)(%rip)
23168 + addq %rbp, init_level4_pgt + (L4_VMEMMAP_START*8)(%rip)
23169 + addq %rbp, init_level4_pgt + (L4_START_KERNEL*8)(%rip)
23170
23171 - addq %rbp, level3_kernel_pgt + (510*8)(%rip)
23172 - addq %rbp, level3_kernel_pgt + (511*8)(%rip)
23173 + addq %rbp, level3_ident_pgt + (0*8)(%rip)
23174 +#ifndef CONFIG_XEN
23175 + addq %rbp, level3_ident_pgt + (1*8)(%rip)
23176 +#endif
23177 +
23178 + addq %rbp, level3_vmemmap_pgt + (L3_VMEMMAP_START*8)(%rip)
23179 +
23180 + addq %rbp, level3_kernel_pgt + (L3_START_KERNEL*8)(%rip)
23181 + addq %rbp, level3_kernel_pgt + ((L3_START_KERNEL+1)*8)(%rip)
23182
23183 addq %rbp, level2_fixmap_pgt + (506*8)(%rip)
23184 + addq %rbp, level2_fixmap_pgt + (507*8)(%rip)
23185
23186 /*
23187 * Set up the identity mapping for the switchover. These
23188 @@ -177,8 +198,8 @@ ENTRY(secondary_startup_64)
23189 movq $(init_level4_pgt - __START_KERNEL_map), %rax
23190 1:
23191
23192 - /* Enable PAE mode and PGE */
23193 - movl $(X86_CR4_PAE | X86_CR4_PGE), %ecx
23194 + /* Enable PAE mode and PSE/PGE */
23195 + movl $(X86_CR4_PSE | X86_CR4_PAE | X86_CR4_PGE), %ecx
23196 movq %rcx, %cr4
23197
23198 /* Setup early boot stage 4 level pagetables. */
23199 @@ -199,10 +220,19 @@ ENTRY(secondary_startup_64)
23200 movl $MSR_EFER, %ecx
23201 rdmsr
23202 btsl $_EFER_SCE, %eax /* Enable System Call */
23203 - btl $20,%edi /* No Execute supported? */
23204 + btl $(X86_FEATURE_NX & 31),%edi /* No Execute supported? */
23205 jnc 1f
23206 btsl $_EFER_NX, %eax
23207 btsq $_PAGE_BIT_NX,early_pmd_flags(%rip)
23208 +#ifndef CONFIG_EFI
23209 + btsq $_PAGE_BIT_NX, init_level4_pgt + 8*L4_PAGE_OFFSET(%rip)
23210 +#endif
23211 + btsq $_PAGE_BIT_NX, init_level4_pgt + 8*L4_VMALLOC_START(%rip)
23212 + btsq $_PAGE_BIT_NX, init_level4_pgt + 8*L4_VMALLOC_END(%rip)
23213 + btsq $_PAGE_BIT_NX, init_level4_pgt + 8*L4_VMEMMAP_START(%rip)
23214 + btsq $_PAGE_BIT_NX, level2_fixmap_pgt + 8*506(%rip)
23215 + btsq $_PAGE_BIT_NX, level2_fixmap_pgt + 8*507(%rip)
23216 + btsq $_PAGE_BIT_NX, __supported_pte_mask(%rip)
23217 1: wrmsr /* Make changes effective */
23218
23219 /* Setup cr0 */
23220 @@ -282,6 +312,7 @@ ENTRY(secondary_startup_64)
23221 * REX.W + FF /5 JMP m16:64 Jump far, absolute indirect,
23222 * address given in m16:64.
23223 */
23224 + pax_set_fptr_mask
23225 movq initial_code(%rip),%rax
23226 pushq $0 # fake return address to stop unwinder
23227 pushq $__KERNEL_CS # set correct cs
23228 @@ -388,7 +419,7 @@ ENTRY(early_idt_handler)
23229 call dump_stack
23230 #ifdef CONFIG_KALLSYMS
23231 leaq early_idt_ripmsg(%rip),%rdi
23232 - movq 40(%rsp),%rsi # %rip again
23233 + movq 88(%rsp),%rsi # %rip again
23234 call __print_symbol
23235 #endif
23236 #endif /* EARLY_PRINTK */
23237 @@ -416,6 +447,7 @@ ENDPROC(early_idt_handler)
23238 early_recursion_flag:
23239 .long 0
23240
23241 + .section .rodata,"a",@progbits
23242 #ifdef CONFIG_EARLY_PRINTK
23243 early_idt_msg:
23244 .asciz "PANIC: early exception %02lx rip %lx:%lx error %lx cr2 %lx\n"
23245 @@ -443,29 +475,52 @@ NEXT_PAGE(early_level4_pgt)
23246 NEXT_PAGE(early_dynamic_pgts)
23247 .fill 512*EARLY_DYNAMIC_PAGE_TABLES,8,0
23248
23249 - .data
23250 + .section .rodata,"a",@progbits
23251
23252 -#ifndef CONFIG_XEN
23253 NEXT_PAGE(init_level4_pgt)
23254 - .fill 512,8,0
23255 -#else
23256 -NEXT_PAGE(init_level4_pgt)
23257 - .quad level3_ident_pgt - __START_KERNEL_map + _KERNPG_TABLE
23258 .org init_level4_pgt + L4_PAGE_OFFSET*8, 0
23259 .quad level3_ident_pgt - __START_KERNEL_map + _KERNPG_TABLE
23260 + .org init_level4_pgt + L4_VMALLOC_START*8, 0
23261 + .quad level3_vmalloc_start_pgt - __START_KERNEL_map + _KERNPG_TABLE
23262 + .org init_level4_pgt + L4_VMALLOC_END*8, 0
23263 + .quad level3_vmalloc_end_pgt - __START_KERNEL_map + _KERNPG_TABLE
23264 + .org init_level4_pgt + L4_VMEMMAP_START*8, 0
23265 + .quad level3_vmemmap_pgt - __START_KERNEL_map + _KERNPG_TABLE
23266 .org init_level4_pgt + L4_START_KERNEL*8, 0
23267 /* (2^48-(2*1024*1024*1024))/(2^39) = 511 */
23268 .quad level3_kernel_pgt - __START_KERNEL_map + _PAGE_TABLE
23269
23270 +#ifdef CONFIG_PAX_PER_CPU_PGD
23271 +NEXT_PAGE(cpu_pgd)
23272 + .rept 2*NR_CPUS
23273 + .fill 512,8,0
23274 + .endr
23275 +#endif
23276 +
23277 NEXT_PAGE(level3_ident_pgt)
23278 .quad level2_ident_pgt - __START_KERNEL_map + _KERNPG_TABLE
23279 +#ifdef CONFIG_XEN
23280 .fill 511, 8, 0
23281 +#else
23282 + .quad level2_ident_pgt + PAGE_SIZE - __START_KERNEL_map + _KERNPG_TABLE
23283 + .fill 510,8,0
23284 +#endif
23285 +
23286 +NEXT_PAGE(level3_vmalloc_start_pgt)
23287 + .fill 512,8,0
23288 +
23289 +NEXT_PAGE(level3_vmalloc_end_pgt)
23290 + .fill 512,8,0
23291 +
23292 +NEXT_PAGE(level3_vmemmap_pgt)
23293 + .fill L3_VMEMMAP_START,8,0
23294 + .quad level2_vmemmap_pgt - __START_KERNEL_map + _KERNPG_TABLE
23295 +
23296 NEXT_PAGE(level2_ident_pgt)
23297 - /* Since I easily can, map the first 1G.
23298 + /* Since I easily can, map the first 2G.
23299 * Don't set NX because code runs from these pages.
23300 */
23301 - PMDS(0, __PAGE_KERNEL_IDENT_LARGE_EXEC, PTRS_PER_PMD)
23302 -#endif
23303 + PMDS(0, __PAGE_KERNEL_IDENT_LARGE_EXEC, 2*PTRS_PER_PMD)
23304
23305 NEXT_PAGE(level3_kernel_pgt)
23306 .fill L3_START_KERNEL,8,0
23307 @@ -473,6 +528,9 @@ NEXT_PAGE(level3_kernel_pgt)
23308 .quad level2_kernel_pgt - __START_KERNEL_map + _KERNPG_TABLE
23309 .quad level2_fixmap_pgt - __START_KERNEL_map + _PAGE_TABLE
23310
23311 +NEXT_PAGE(level2_vmemmap_pgt)
23312 + .fill 512,8,0
23313 +
23314 NEXT_PAGE(level2_kernel_pgt)
23315 /*
23316 * 512 MB kernel mapping. We spend a full page on this pagetable
23317 @@ -490,28 +548,64 @@ NEXT_PAGE(level2_kernel_pgt)
23318 NEXT_PAGE(level2_fixmap_pgt)
23319 .fill 506,8,0
23320 .quad level1_fixmap_pgt - __START_KERNEL_map + _PAGE_TABLE
23321 - /* 8MB reserved for vsyscalls + a 2MB hole = 4 + 1 entries */
23322 - .fill 5,8,0
23323 + .quad level1_vsyscall_pgt - __START_KERNEL_map + _PAGE_TABLE
23324 + /* 6MB reserved for vsyscalls + a 2MB hole = 3 + 1 entries */
23325 + .fill 4,8,0
23326
23327 NEXT_PAGE(level1_fixmap_pgt)
23328 .fill 512,8,0
23329
23330 +NEXT_PAGE(level1_vsyscall_pgt)
23331 + .fill 512,8,0
23332 +
23333 #undef PMDS
23334
23335 - .data
23336 + .align PAGE_SIZE
23337 +ENTRY(cpu_gdt_table)
23338 + .rept NR_CPUS
23339 + .quad 0x0000000000000000 /* NULL descriptor */
23340 + .quad 0x00cf9b000000ffff /* __KERNEL32_CS */
23341 + .quad 0x00af9b000000ffff /* __KERNEL_CS */
23342 + .quad 0x00cf93000000ffff /* __KERNEL_DS */
23343 + .quad 0x00cffb000000ffff /* __USER32_CS */
23344 + .quad 0x00cff3000000ffff /* __USER_DS, __USER32_DS */
23345 + .quad 0x00affb000000ffff /* __USER_CS */
23346 +
23347 +#ifdef CONFIG_PAX_KERNEXEC
23348 + .quad 0x00af9b000000ffff /* __KERNEXEC_KERNEL_CS */
23349 +#else
23350 + .quad 0x0 /* unused */
23351 +#endif
23352 +
23353 + .quad 0,0 /* TSS */
23354 + .quad 0,0 /* LDT */
23355 + .quad 0,0,0 /* three TLS descriptors */
23356 + .quad 0x0000f40000000000 /* node/CPU stored in limit */
23357 + /* asm/segment.h:GDT_ENTRIES must match this */
23358 +
23359 +#ifdef CONFIG_PAX_MEMORY_UDEREF
23360 + .quad 0x00cf93000000ffff /* __UDEREF_KERNEL_DS */
23361 +#else
23362 + .quad 0x0 /* unused */
23363 +#endif
23364 +
23365 + /* zero the remaining page */
23366 + .fill PAGE_SIZE / 8 - GDT_ENTRIES,8,0
23367 + .endr
23368 +
23369 .align 16
23370 .globl early_gdt_descr
23371 early_gdt_descr:
23372 .word GDT_ENTRIES*8-1
23373 early_gdt_descr_base:
23374 - .quad INIT_PER_CPU_VAR(gdt_page)
23375 + .quad cpu_gdt_table
23376
23377 ENTRY(phys_base)
23378 /* This must match the first entry in level2_kernel_pgt */
23379 .quad 0x0000000000000000
23380
23381 #include "../../x86/xen/xen-head.S"
23382 -
23383 - __PAGE_ALIGNED_BSS
23384 +
23385 + .section .rodata,"a",@progbits
23386 NEXT_PAGE(empty_zero_page)
23387 .skip PAGE_SIZE
23388 diff --git a/arch/x86/kernel/i386_ksyms_32.c b/arch/x86/kernel/i386_ksyms_32.c
23389 index 0fa6912..b37438b 100644
23390 --- a/arch/x86/kernel/i386_ksyms_32.c
23391 +++ b/arch/x86/kernel/i386_ksyms_32.c
23392 @@ -20,8 +20,12 @@ extern void cmpxchg8b_emu(void);
23393 EXPORT_SYMBOL(cmpxchg8b_emu);
23394 #endif
23395
23396 +EXPORT_SYMBOL_GPL(cpu_gdt_table);
23397 +
23398 /* Networking helper routines. */
23399 EXPORT_SYMBOL(csum_partial_copy_generic);
23400 +EXPORT_SYMBOL(csum_partial_copy_generic_to_user);
23401 +EXPORT_SYMBOL(csum_partial_copy_generic_from_user);
23402
23403 EXPORT_SYMBOL(__get_user_1);
23404 EXPORT_SYMBOL(__get_user_2);
23405 @@ -37,3 +41,11 @@ EXPORT_SYMBOL(strstr);
23406
23407 EXPORT_SYMBOL(csum_partial);
23408 EXPORT_SYMBOL(empty_zero_page);
23409 +
23410 +#ifdef CONFIG_PAX_KERNEXEC
23411 +EXPORT_SYMBOL(__LOAD_PHYSICAL_ADDR);
23412 +#endif
23413 +
23414 +#ifdef CONFIG_PAX_PER_CPU_PGD
23415 +EXPORT_SYMBOL(cpu_pgd);
23416 +#endif
23417 diff --git a/arch/x86/kernel/i387.c b/arch/x86/kernel/i387.c
23418 index 5d576ab..1403a03 100644
23419 --- a/arch/x86/kernel/i387.c
23420 +++ b/arch/x86/kernel/i387.c
23421 @@ -51,7 +51,7 @@ static inline bool interrupted_kernel_fpu_idle(void)
23422 static inline bool interrupted_user_mode(void)
23423 {
23424 struct pt_regs *regs = get_irq_regs();
23425 - return regs && user_mode_vm(regs);
23426 + return regs && user_mode(regs);
23427 }
23428
23429 /*
23430 diff --git a/arch/x86/kernel/i8259.c b/arch/x86/kernel/i8259.c
23431 index 9a5c460..84868423 100644
23432 --- a/arch/x86/kernel/i8259.c
23433 +++ b/arch/x86/kernel/i8259.c
23434 @@ -110,7 +110,7 @@ static int i8259A_irq_pending(unsigned int irq)
23435 static void make_8259A_irq(unsigned int irq)
23436 {
23437 disable_irq_nosync(irq);
23438 - io_apic_irqs &= ~(1<<irq);
23439 + io_apic_irqs &= ~(1UL<<irq);
23440 irq_set_chip_and_handler_name(irq, &i8259A_chip, handle_level_irq,
23441 i8259A_chip.name);
23442 enable_irq(irq);
23443 @@ -209,7 +209,7 @@ spurious_8259A_irq:
23444 "spurious 8259A interrupt: IRQ%d.\n", irq);
23445 spurious_irq_mask |= irqmask;
23446 }
23447 - atomic_inc(&irq_err_count);
23448 + atomic_inc_unchecked(&irq_err_count);
23449 /*
23450 * Theoretically we do not have to handle this IRQ,
23451 * but in Linux this does not cause problems and is
23452 @@ -333,14 +333,16 @@ static void init_8259A(int auto_eoi)
23453 /* (slave's support for AEOI in flat mode is to be investigated) */
23454 outb_pic(SLAVE_ICW4_DEFAULT, PIC_SLAVE_IMR);
23455
23456 + pax_open_kernel();
23457 if (auto_eoi)
23458 /*
23459 * In AEOI mode we just have to mask the interrupt
23460 * when acking.
23461 */
23462 - i8259A_chip.irq_mask_ack = disable_8259A_irq;
23463 + *(void **)&i8259A_chip.irq_mask_ack = disable_8259A_irq;
23464 else
23465 - i8259A_chip.irq_mask_ack = mask_and_ack_8259A;
23466 + *(void **)&i8259A_chip.irq_mask_ack = mask_and_ack_8259A;
23467 + pax_close_kernel();
23468
23469 udelay(100); /* wait for 8259A to initialize */
23470
23471 diff --git a/arch/x86/kernel/io_delay.c b/arch/x86/kernel/io_delay.c
23472 index a979b5b..1d6db75 100644
23473 --- a/arch/x86/kernel/io_delay.c
23474 +++ b/arch/x86/kernel/io_delay.c
23475 @@ -58,7 +58,7 @@ static int __init dmi_io_delay_0xed_port(const struct dmi_system_id *id)
23476 * Quirk table for systems that misbehave (lock up, etc.) if port
23477 * 0x80 is used:
23478 */
23479 -static struct dmi_system_id __initdata io_delay_0xed_port_dmi_table[] = {
23480 +static const struct dmi_system_id __initconst io_delay_0xed_port_dmi_table[] = {
23481 {
23482 .callback = dmi_io_delay_0xed_port,
23483 .ident = "Compaq Presario V6000",
23484 diff --git a/arch/x86/kernel/ioport.c b/arch/x86/kernel/ioport.c
23485 index 4ddaf66..49d5c18 100644
23486 --- a/arch/x86/kernel/ioport.c
23487 +++ b/arch/x86/kernel/ioport.c
23488 @@ -6,6 +6,7 @@
23489 #include <linux/sched.h>
23490 #include <linux/kernel.h>
23491 #include <linux/capability.h>
23492 +#include <linux/security.h>
23493 #include <linux/errno.h>
23494 #include <linux/types.h>
23495 #include <linux/ioport.h>
23496 @@ -30,6 +31,12 @@ asmlinkage long sys_ioperm(unsigned long from, unsigned long num, int turn_on)
23497 return -EINVAL;
23498 if (turn_on && !capable(CAP_SYS_RAWIO))
23499 return -EPERM;
23500 +#ifdef CONFIG_GRKERNSEC_IO
23501 + if (turn_on && grsec_disable_privio) {
23502 + gr_handle_ioperm();
23503 + return -ENODEV;
23504 + }
23505 +#endif
23506
23507 /*
23508 * If it's the first ioperm() call in this thread's lifetime, set the
23509 @@ -54,7 +61,7 @@ asmlinkage long sys_ioperm(unsigned long from, unsigned long num, int turn_on)
23510 * because the ->io_bitmap_max value must match the bitmap
23511 * contents:
23512 */
23513 - tss = &per_cpu(init_tss, get_cpu());
23514 + tss = init_tss + get_cpu();
23515
23516 if (turn_on)
23517 bitmap_clear(t->io_bitmap_ptr, from, num);
23518 @@ -105,6 +112,12 @@ SYSCALL_DEFINE1(iopl, unsigned int, level)
23519 if (level > old) {
23520 if (!capable(CAP_SYS_RAWIO))
23521 return -EPERM;
23522 +#ifdef CONFIG_GRKERNSEC_IO
23523 + if (grsec_disable_privio) {
23524 + gr_handle_iopl();
23525 + return -ENODEV;
23526 + }
23527 +#endif
23528 }
23529 regs->flags = (regs->flags & ~X86_EFLAGS_IOPL) | (level << 12);
23530 t->iopl = level << 12;
23531 diff --git a/arch/x86/kernel/irq.c b/arch/x86/kernel/irq.c
23532 index 22d0687..e07b2a5 100644
23533 --- a/arch/x86/kernel/irq.c
23534 +++ b/arch/x86/kernel/irq.c
23535 @@ -21,7 +21,7 @@
23536 #define CREATE_TRACE_POINTS
23537 #include <asm/trace/irq_vectors.h>
23538
23539 -atomic_t irq_err_count;
23540 +atomic_unchecked_t irq_err_count;
23541
23542 /* Function pointer for generic interrupt vector handling */
23543 void (*x86_platform_ipi_callback)(void) = NULL;
23544 @@ -125,9 +125,9 @@ int arch_show_interrupts(struct seq_file *p, int prec)
23545 seq_printf(p, "%10u ", per_cpu(mce_poll_count, j));
23546 seq_printf(p, " Machine check polls\n");
23547 #endif
23548 - seq_printf(p, "%*s: %10u\n", prec, "ERR", atomic_read(&irq_err_count));
23549 + seq_printf(p, "%*s: %10u\n", prec, "ERR", atomic_read_unchecked(&irq_err_count));
23550 #if defined(CONFIG_X86_IO_APIC)
23551 - seq_printf(p, "%*s: %10u\n", prec, "MIS", atomic_read(&irq_mis_count));
23552 + seq_printf(p, "%*s: %10u\n", prec, "MIS", atomic_read_unchecked(&irq_mis_count));
23553 #endif
23554 return 0;
23555 }
23556 @@ -167,7 +167,7 @@ u64 arch_irq_stat_cpu(unsigned int cpu)
23557
23558 u64 arch_irq_stat(void)
23559 {
23560 - u64 sum = atomic_read(&irq_err_count);
23561 + u64 sum = atomic_read_unchecked(&irq_err_count);
23562 return sum;
23563 }
23564
23565 diff --git a/arch/x86/kernel/irq_32.c b/arch/x86/kernel/irq_32.c
23566 index 4186755..784efa0 100644
23567 --- a/arch/x86/kernel/irq_32.c
23568 +++ b/arch/x86/kernel/irq_32.c
23569 @@ -39,7 +39,7 @@ static int check_stack_overflow(void)
23570 __asm__ __volatile__("andl %%esp,%0" :
23571 "=r" (sp) : "0" (THREAD_SIZE - 1));
23572
23573 - return sp < (sizeof(struct thread_info) + STACK_WARN);
23574 + return sp < STACK_WARN;
23575 }
23576
23577 static void print_stack_overflow(void)
23578 @@ -59,8 +59,8 @@ static inline void print_stack_overflow(void) { }
23579 * per-CPU IRQ handling contexts (thread information and stack)
23580 */
23581 union irq_ctx {
23582 - struct thread_info tinfo;
23583 - u32 stack[THREAD_SIZE/sizeof(u32)];
23584 + unsigned long previous_esp;
23585 + u32 stack[THREAD_SIZE/sizeof(u32)];
23586 } __attribute__((aligned(THREAD_SIZE)));
23587
23588 static DEFINE_PER_CPU(union irq_ctx *, hardirq_ctx);
23589 @@ -80,10 +80,9 @@ static void call_on_stack(void *func, void *stack)
23590 static inline int
23591 execute_on_irq_stack(int overflow, struct irq_desc *desc, int irq)
23592 {
23593 - union irq_ctx *curctx, *irqctx;
23594 + union irq_ctx *irqctx;
23595 u32 *isp, arg1, arg2;
23596
23597 - curctx = (union irq_ctx *) current_thread_info();
23598 irqctx = __this_cpu_read(hardirq_ctx);
23599
23600 /*
23601 @@ -92,16 +91,16 @@ execute_on_irq_stack(int overflow, struct irq_desc *desc, int irq)
23602 * handler) we can't do that and just have to keep using the
23603 * current stack (which is the irq stack already after all)
23604 */
23605 - if (unlikely(curctx == irqctx))
23606 + if (unlikely((void *)current_stack_pointer - (void *)irqctx < THREAD_SIZE))
23607 return 0;
23608
23609 /* build the stack frame on the IRQ stack */
23610 - isp = (u32 *) ((char *)irqctx + sizeof(*irqctx));
23611 - irqctx->tinfo.task = curctx->tinfo.task;
23612 - irqctx->tinfo.previous_esp = current_stack_pointer;
23613 + isp = (u32 *) ((char *)irqctx + sizeof(*irqctx) - 8);
23614 + irqctx->previous_esp = current_stack_pointer;
23615
23616 - /* Copy the preempt_count so that the [soft]irq checks work. */
23617 - irqctx->tinfo.preempt_count = curctx->tinfo.preempt_count;
23618 +#ifdef CONFIG_PAX_MEMORY_UDEREF
23619 + __set_fs(MAKE_MM_SEG(0));
23620 +#endif
23621
23622 if (unlikely(overflow))
23623 call_on_stack(print_stack_overflow, isp);
23624 @@ -113,6 +112,11 @@ execute_on_irq_stack(int overflow, struct irq_desc *desc, int irq)
23625 : "0" (irq), "1" (desc), "2" (isp),
23626 "D" (desc->handle_irq)
23627 : "memory", "cc", "ecx");
23628 +
23629 +#ifdef CONFIG_PAX_MEMORY_UDEREF
23630 + __set_fs(current_thread_info()->addr_limit);
23631 +#endif
23632 +
23633 return 1;
23634 }
23635
23636 @@ -121,29 +125,14 @@ execute_on_irq_stack(int overflow, struct irq_desc *desc, int irq)
23637 */
23638 void irq_ctx_init(int cpu)
23639 {
23640 - union irq_ctx *irqctx;
23641 -
23642 if (per_cpu(hardirq_ctx, cpu))
23643 return;
23644
23645 - irqctx = page_address(alloc_pages_node(cpu_to_node(cpu),
23646 - THREADINFO_GFP,
23647 - THREAD_SIZE_ORDER));
23648 - memset(&irqctx->tinfo, 0, sizeof(struct thread_info));
23649 - irqctx->tinfo.cpu = cpu;
23650 - irqctx->tinfo.preempt_count = HARDIRQ_OFFSET;
23651 - irqctx->tinfo.addr_limit = MAKE_MM_SEG(0);
23652 + per_cpu(hardirq_ctx, cpu) = page_address(alloc_pages_node(cpu_to_node(cpu), THREADINFO_GFP, THREAD_SIZE_ORDER));
23653 + per_cpu(softirq_ctx, cpu) = page_address(alloc_pages_node(cpu_to_node(cpu), THREADINFO_GFP, THREAD_SIZE_ORDER));
23654
23655 - per_cpu(hardirq_ctx, cpu) = irqctx;
23656 -
23657 - irqctx = page_address(alloc_pages_node(cpu_to_node(cpu),
23658 - THREADINFO_GFP,
23659 - THREAD_SIZE_ORDER));
23660 - memset(&irqctx->tinfo, 0, sizeof(struct thread_info));
23661 - irqctx->tinfo.cpu = cpu;
23662 - irqctx->tinfo.addr_limit = MAKE_MM_SEG(0);
23663 -
23664 - per_cpu(softirq_ctx, cpu) = irqctx;
23665 + printk(KERN_DEBUG "CPU %u irqstacks, hard=%p soft=%p\n",
23666 + cpu, per_cpu(hardirq_ctx, cpu), per_cpu(softirq_ctx, cpu));
23667
23668 printk(KERN_DEBUG "CPU %u irqstacks, hard=%p soft=%p\n",
23669 cpu, per_cpu(hardirq_ctx, cpu), per_cpu(softirq_ctx, cpu));
23670 @@ -152,7 +141,6 @@ void irq_ctx_init(int cpu)
23671 asmlinkage void do_softirq(void)
23672 {
23673 unsigned long flags;
23674 - struct thread_info *curctx;
23675 union irq_ctx *irqctx;
23676 u32 *isp;
23677
23678 @@ -162,15 +150,22 @@ asmlinkage void do_softirq(void)
23679 local_irq_save(flags);
23680
23681 if (local_softirq_pending()) {
23682 - curctx = current_thread_info();
23683 irqctx = __this_cpu_read(softirq_ctx);
23684 - irqctx->tinfo.task = curctx->task;
23685 - irqctx->tinfo.previous_esp = current_stack_pointer;
23686 + irqctx->previous_esp = current_stack_pointer;
23687
23688 /* build the stack frame on the softirq stack */
23689 - isp = (u32 *) ((char *)irqctx + sizeof(*irqctx));
23690 + isp = (u32 *) ((char *)irqctx + sizeof(*irqctx) - 8);
23691 +
23692 +#ifdef CONFIG_PAX_MEMORY_UDEREF
23693 + __set_fs(MAKE_MM_SEG(0));
23694 +#endif
23695
23696 call_on_stack(__do_softirq, isp);
23697 +
23698 +#ifdef CONFIG_PAX_MEMORY_UDEREF
23699 + __set_fs(current_thread_info()->addr_limit);
23700 +#endif
23701 +
23702 /*
23703 * Shouldn't happen, we returned above if in_interrupt():
23704 */
23705 @@ -191,7 +186,7 @@ bool handle_irq(unsigned irq, struct pt_regs *regs)
23706 if (unlikely(!desc))
23707 return false;
23708
23709 - if (user_mode_vm(regs) || !execute_on_irq_stack(overflow, desc, irq)) {
23710 + if (user_mode(regs) || !execute_on_irq_stack(overflow, desc, irq)) {
23711 if (unlikely(overflow))
23712 print_stack_overflow();
23713 desc->handle_irq(irq, desc);
23714 diff --git a/arch/x86/kernel/irq_64.c b/arch/x86/kernel/irq_64.c
23715 index d04d3ec..ea4b374 100644
23716 --- a/arch/x86/kernel/irq_64.c
23717 +++ b/arch/x86/kernel/irq_64.c
23718 @@ -44,7 +44,7 @@ static inline void stack_overflow_check(struct pt_regs *regs)
23719 u64 estack_top, estack_bottom;
23720 u64 curbase = (u64)task_stack_page(current);
23721
23722 - if (user_mode_vm(regs))
23723 + if (user_mode(regs))
23724 return;
23725
23726 if (regs->sp >= curbase + sizeof(struct thread_info) +
23727 diff --git a/arch/x86/kernel/jump_label.c b/arch/x86/kernel/jump_label.c
23728 index ee11b7d..4df4d0c 100644
23729 --- a/arch/x86/kernel/jump_label.c
23730 +++ b/arch/x86/kernel/jump_label.c
23731 @@ -49,7 +49,7 @@ static void __jump_label_transform(struct jump_entry *entry,
23732 * We are enabling this jump label. If it is not a nop
23733 * then something must have gone wrong.
23734 */
23735 - if (unlikely(memcmp((void *)entry->code, ideal_nop, 5) != 0))
23736 + if (unlikely(memcmp((void *)ktla_ktva(entry->code), ideal_nop, 5) != 0))
23737 bug_at((void *)entry->code, __LINE__);
23738
23739 code.jump = 0xe9;
23740 @@ -64,13 +64,13 @@ static void __jump_label_transform(struct jump_entry *entry,
23741 */
23742 if (init) {
23743 const unsigned char default_nop[] = { STATIC_KEY_INIT_NOP };
23744 - if (unlikely(memcmp((void *)entry->code, default_nop, 5) != 0))
23745 + if (unlikely(memcmp((void *)ktla_ktva(entry->code), default_nop, 5) != 0))
23746 bug_at((void *)entry->code, __LINE__);
23747 } else {
23748 code.jump = 0xe9;
23749 code.offset = entry->target -
23750 (entry->code + JUMP_LABEL_NOP_SIZE);
23751 - if (unlikely(memcmp((void *)entry->code, &code, 5) != 0))
23752 + if (unlikely(memcmp((void *)ktla_ktva(entry->code), &code, 5) != 0))
23753 bug_at((void *)entry->code, __LINE__);
23754 }
23755 memcpy(&code, ideal_nops[NOP_ATOMIC5], JUMP_LABEL_NOP_SIZE);
23756 diff --git a/arch/x86/kernel/kgdb.c b/arch/x86/kernel/kgdb.c
23757 index 836f832..a8bda67 100644
23758 --- a/arch/x86/kernel/kgdb.c
23759 +++ b/arch/x86/kernel/kgdb.c
23760 @@ -127,11 +127,11 @@ char *dbg_get_reg(int regno, void *mem, struct pt_regs *regs)
23761 #ifdef CONFIG_X86_32
23762 switch (regno) {
23763 case GDB_SS:
23764 - if (!user_mode_vm(regs))
23765 + if (!user_mode(regs))
23766 *(unsigned long *)mem = __KERNEL_DS;
23767 break;
23768 case GDB_SP:
23769 - if (!user_mode_vm(regs))
23770 + if (!user_mode(regs))
23771 *(unsigned long *)mem = kernel_stack_pointer(regs);
23772 break;
23773 case GDB_GS:
23774 @@ -229,7 +229,10 @@ static void kgdb_correct_hw_break(void)
23775 bp->attr.bp_addr = breakinfo[breakno].addr;
23776 bp->attr.bp_len = breakinfo[breakno].len;
23777 bp->attr.bp_type = breakinfo[breakno].type;
23778 - info->address = breakinfo[breakno].addr;
23779 + if (breakinfo[breakno].type == X86_BREAKPOINT_EXECUTE)
23780 + info->address = ktla_ktva(breakinfo[breakno].addr);
23781 + else
23782 + info->address = breakinfo[breakno].addr;
23783 info->len = breakinfo[breakno].len;
23784 info->type = breakinfo[breakno].type;
23785 val = arch_install_hw_breakpoint(bp);
23786 @@ -476,12 +479,12 @@ int kgdb_arch_handle_exception(int e_vector, int signo, int err_code,
23787 case 'k':
23788 /* clear the trace bit */
23789 linux_regs->flags &= ~X86_EFLAGS_TF;
23790 - atomic_set(&kgdb_cpu_doing_single_step, -1);
23791 + atomic_set_unchecked(&kgdb_cpu_doing_single_step, -1);
23792
23793 /* set the trace bit if we're stepping */
23794 if (remcomInBuffer[0] == 's') {
23795 linux_regs->flags |= X86_EFLAGS_TF;
23796 - atomic_set(&kgdb_cpu_doing_single_step,
23797 + atomic_set_unchecked(&kgdb_cpu_doing_single_step,
23798 raw_smp_processor_id());
23799 }
23800
23801 @@ -546,7 +549,7 @@ static int __kgdb_notify(struct die_args *args, unsigned long cmd)
23802
23803 switch (cmd) {
23804 case DIE_DEBUG:
23805 - if (atomic_read(&kgdb_cpu_doing_single_step) != -1) {
23806 + if (atomic_read_unchecked(&kgdb_cpu_doing_single_step) != -1) {
23807 if (user_mode(regs))
23808 return single_step_cont(regs, args);
23809 break;
23810 @@ -751,11 +754,11 @@ int kgdb_arch_set_breakpoint(struct kgdb_bkpt *bpt)
23811 #endif /* CONFIG_DEBUG_RODATA */
23812
23813 bpt->type = BP_BREAKPOINT;
23814 - err = probe_kernel_read(bpt->saved_instr, (char *)bpt->bpt_addr,
23815 + err = probe_kernel_read(bpt->saved_instr, ktla_ktva((char *)bpt->bpt_addr),
23816 BREAK_INSTR_SIZE);
23817 if (err)
23818 return err;
23819 - err = probe_kernel_write((char *)bpt->bpt_addr,
23820 + err = probe_kernel_write(ktla_ktva((char *)bpt->bpt_addr),
23821 arch_kgdb_ops.gdb_bpt_instr, BREAK_INSTR_SIZE);
23822 #ifdef CONFIG_DEBUG_RODATA
23823 if (!err)
23824 @@ -768,7 +771,7 @@ int kgdb_arch_set_breakpoint(struct kgdb_bkpt *bpt)
23825 return -EBUSY;
23826 text_poke((void *)bpt->bpt_addr, arch_kgdb_ops.gdb_bpt_instr,
23827 BREAK_INSTR_SIZE);
23828 - err = probe_kernel_read(opc, (char *)bpt->bpt_addr, BREAK_INSTR_SIZE);
23829 + err = probe_kernel_read(opc, ktla_ktva((char *)bpt->bpt_addr), BREAK_INSTR_SIZE);
23830 if (err)
23831 return err;
23832 if (memcmp(opc, arch_kgdb_ops.gdb_bpt_instr, BREAK_INSTR_SIZE))
23833 @@ -793,13 +796,13 @@ int kgdb_arch_remove_breakpoint(struct kgdb_bkpt *bpt)
23834 if (mutex_is_locked(&text_mutex))
23835 goto knl_write;
23836 text_poke((void *)bpt->bpt_addr, bpt->saved_instr, BREAK_INSTR_SIZE);
23837 - err = probe_kernel_read(opc, (char *)bpt->bpt_addr, BREAK_INSTR_SIZE);
23838 + err = probe_kernel_read(opc, ktla_ktva((char *)bpt->bpt_addr), BREAK_INSTR_SIZE);
23839 if (err || memcmp(opc, bpt->saved_instr, BREAK_INSTR_SIZE))
23840 goto knl_write;
23841 return err;
23842 knl_write:
23843 #endif /* CONFIG_DEBUG_RODATA */
23844 - return probe_kernel_write((char *)bpt->bpt_addr,
23845 + return probe_kernel_write(ktla_ktva((char *)bpt->bpt_addr),
23846 (char *)bpt->saved_instr, BREAK_INSTR_SIZE);
23847 }
23848
23849 diff --git a/arch/x86/kernel/kprobes/core.c b/arch/x86/kernel/kprobes/core.c
23850 index 79a3f96..6ba030a 100644
23851 --- a/arch/x86/kernel/kprobes/core.c
23852 +++ b/arch/x86/kernel/kprobes/core.c
23853 @@ -119,9 +119,12 @@ static void __kprobes __synthesize_relative_insn(void *from, void *to, u8 op)
23854 s32 raddr;
23855 } __packed *insn;
23856
23857 - insn = (struct __arch_relative_insn *)from;
23858 + insn = (struct __arch_relative_insn *)ktla_ktva(from);
23859 +
23860 + pax_open_kernel();
23861 insn->raddr = (s32)((long)(to) - ((long)(from) + 5));
23862 insn->op = op;
23863 + pax_close_kernel();
23864 }
23865
23866 /* Insert a jump instruction at address 'from', which jumps to address 'to'.*/
23867 @@ -164,7 +167,7 @@ int __kprobes can_boost(kprobe_opcode_t *opcodes)
23868 kprobe_opcode_t opcode;
23869 kprobe_opcode_t *orig_opcodes = opcodes;
23870
23871 - if (search_exception_tables((unsigned long)opcodes))
23872 + if (search_exception_tables(ktva_ktla((unsigned long)opcodes)))
23873 return 0; /* Page fault may occur on this address. */
23874
23875 retry:
23876 @@ -238,9 +241,9 @@ __recover_probed_insn(kprobe_opcode_t *buf, unsigned long addr)
23877 * for the first byte, we can recover the original instruction
23878 * from it and kp->opcode.
23879 */
23880 - memcpy(buf, kp->addr, MAX_INSN_SIZE * sizeof(kprobe_opcode_t));
23881 + memcpy(buf, ktla_ktva(kp->addr), MAX_INSN_SIZE * sizeof(kprobe_opcode_t));
23882 buf[0] = kp->opcode;
23883 - return (unsigned long)buf;
23884 + return ktva_ktla((unsigned long)buf);
23885 }
23886
23887 /*
23888 @@ -332,7 +335,9 @@ int __kprobes __copy_instruction(u8 *dest, u8 *src)
23889 /* Another subsystem puts a breakpoint, failed to recover */
23890 if (insn.opcode.bytes[0] == BREAKPOINT_INSTRUCTION)
23891 return 0;
23892 + pax_open_kernel();
23893 memcpy(dest, insn.kaddr, insn.length);
23894 + pax_close_kernel();
23895
23896 #ifdef CONFIG_X86_64
23897 if (insn_rip_relative(&insn)) {
23898 @@ -359,7 +364,9 @@ int __kprobes __copy_instruction(u8 *dest, u8 *src)
23899 return 0;
23900 }
23901 disp = (u8 *) dest + insn_offset_displacement(&insn);
23902 + pax_open_kernel();
23903 *(s32 *) disp = (s32) newdisp;
23904 + pax_close_kernel();
23905 }
23906 #endif
23907 return insn.length;
23908 @@ -498,7 +505,7 @@ setup_singlestep(struct kprobe *p, struct pt_regs *regs, struct kprobe_ctlblk *k
23909 * nor set current_kprobe, because it doesn't use single
23910 * stepping.
23911 */
23912 - regs->ip = (unsigned long)p->ainsn.insn;
23913 + regs->ip = ktva_ktla((unsigned long)p->ainsn.insn);
23914 preempt_enable_no_resched();
23915 return;
23916 }
23917 @@ -515,9 +522,9 @@ setup_singlestep(struct kprobe *p, struct pt_regs *regs, struct kprobe_ctlblk *k
23918 regs->flags &= ~X86_EFLAGS_IF;
23919 /* single step inline if the instruction is an int3 */
23920 if (p->opcode == BREAKPOINT_INSTRUCTION)
23921 - regs->ip = (unsigned long)p->addr;
23922 + regs->ip = ktla_ktva((unsigned long)p->addr);
23923 else
23924 - regs->ip = (unsigned long)p->ainsn.insn;
23925 + regs->ip = ktva_ktla((unsigned long)p->ainsn.insn);
23926 }
23927
23928 /*
23929 @@ -596,7 +603,7 @@ static int __kprobes kprobe_handler(struct pt_regs *regs)
23930 setup_singlestep(p, regs, kcb, 0);
23931 return 1;
23932 }
23933 - } else if (*addr != BREAKPOINT_INSTRUCTION) {
23934 + } else if (*(kprobe_opcode_t *)ktla_ktva((unsigned long)addr) != BREAKPOINT_INSTRUCTION) {
23935 /*
23936 * The breakpoint instruction was removed right
23937 * after we hit it. Another cpu has removed
23938 @@ -642,6 +649,9 @@ static void __used __kprobes kretprobe_trampoline_holder(void)
23939 " movq %rax, 152(%rsp)\n"
23940 RESTORE_REGS_STRING
23941 " popfq\n"
23942 +#ifdef KERNEXEC_PLUGIN
23943 + " btsq $63,(%rsp)\n"
23944 +#endif
23945 #else
23946 " pushf\n"
23947 SAVE_REGS_STRING
23948 @@ -779,7 +789,7 @@ static void __kprobes
23949 resume_execution(struct kprobe *p, struct pt_regs *regs, struct kprobe_ctlblk *kcb)
23950 {
23951 unsigned long *tos = stack_addr(regs);
23952 - unsigned long copy_ip = (unsigned long)p->ainsn.insn;
23953 + unsigned long copy_ip = ktva_ktla((unsigned long)p->ainsn.insn);
23954 unsigned long orig_ip = (unsigned long)p->addr;
23955 kprobe_opcode_t *insn = p->ainsn.insn;
23956
23957 @@ -961,7 +971,7 @@ kprobe_exceptions_notify(struct notifier_block *self, unsigned long val, void *d
23958 struct die_args *args = data;
23959 int ret = NOTIFY_DONE;
23960
23961 - if (args->regs && user_mode_vm(args->regs))
23962 + if (args->regs && user_mode(args->regs))
23963 return ret;
23964
23965 switch (val) {
23966 diff --git a/arch/x86/kernel/kprobes/opt.c b/arch/x86/kernel/kprobes/opt.c
23967 index 898160b..758cde8 100644
23968 --- a/arch/x86/kernel/kprobes/opt.c
23969 +++ b/arch/x86/kernel/kprobes/opt.c
23970 @@ -79,6 +79,7 @@ found:
23971 /* Insert a move instruction which sets a pointer to eax/rdi (1st arg). */
23972 static void __kprobes synthesize_set_arg1(kprobe_opcode_t *addr, unsigned long val)
23973 {
23974 + pax_open_kernel();
23975 #ifdef CONFIG_X86_64
23976 *addr++ = 0x48;
23977 *addr++ = 0xbf;
23978 @@ -86,6 +87,7 @@ static void __kprobes synthesize_set_arg1(kprobe_opcode_t *addr, unsigned long v
23979 *addr++ = 0xb8;
23980 #endif
23981 *(unsigned long *)addr = val;
23982 + pax_close_kernel();
23983 }
23984
23985 asm (
23986 @@ -335,7 +337,7 @@ int __kprobes arch_prepare_optimized_kprobe(struct optimized_kprobe *op)
23987 * Verify if the address gap is in 2GB range, because this uses
23988 * a relative jump.
23989 */
23990 - rel = (long)op->optinsn.insn - (long)op->kp.addr + RELATIVEJUMP_SIZE;
23991 + rel = (long)op->optinsn.insn - ktla_ktva((long)op->kp.addr) + RELATIVEJUMP_SIZE;
23992 if (abs(rel) > 0x7fffffff)
23993 return -ERANGE;
23994
23995 @@ -350,16 +352,18 @@ int __kprobes arch_prepare_optimized_kprobe(struct optimized_kprobe *op)
23996 op->optinsn.size = ret;
23997
23998 /* Copy arch-dep-instance from template */
23999 - memcpy(buf, &optprobe_template_entry, TMPL_END_IDX);
24000 + pax_open_kernel();
24001 + memcpy(buf, ktla_ktva(&optprobe_template_entry), TMPL_END_IDX);
24002 + pax_close_kernel();
24003
24004 /* Set probe information */
24005 synthesize_set_arg1(buf + TMPL_MOVE_IDX, (unsigned long)op);
24006
24007 /* Set probe function call */
24008 - synthesize_relcall(buf + TMPL_CALL_IDX, optimized_callback);
24009 + synthesize_relcall(ktva_ktla(buf) + TMPL_CALL_IDX, optimized_callback);
24010
24011 /* Set returning jmp instruction at the tail of out-of-line buffer */
24012 - synthesize_reljump(buf + TMPL_END_IDX + op->optinsn.size,
24013 + synthesize_reljump(ktva_ktla(buf) + TMPL_END_IDX + op->optinsn.size,
24014 (u8 *)op->kp.addr + op->optinsn.size);
24015
24016 flush_icache_range((unsigned long) buf,
24017 @@ -384,7 +388,7 @@ void __kprobes arch_optimize_kprobes(struct list_head *oplist)
24018 WARN_ON(kprobe_disabled(&op->kp));
24019
24020 /* Backup instructions which will be replaced by jump address */
24021 - memcpy(op->optinsn.copied_insn, op->kp.addr + INT3_SIZE,
24022 + memcpy(op->optinsn.copied_insn, ktla_ktva(op->kp.addr) + INT3_SIZE,
24023 RELATIVE_ADDR_SIZE);
24024
24025 insn_buf[0] = RELATIVEJUMP_OPCODE;
24026 @@ -433,7 +437,7 @@ setup_detour_execution(struct kprobe *p, struct pt_regs *regs, int reenter)
24027 /* This kprobe is really able to run optimized path. */
24028 op = container_of(p, struct optimized_kprobe, kp);
24029 /* Detour through copied instructions */
24030 - regs->ip = (unsigned long)op->optinsn.insn + TMPL_END_IDX;
24031 + regs->ip = ktva_ktla((unsigned long)op->optinsn.insn) + TMPL_END_IDX;
24032 if (!reenter)
24033 reset_current_kprobe();
24034 preempt_enable_no_resched();
24035 diff --git a/arch/x86/kernel/ldt.c b/arch/x86/kernel/ldt.c
24036 index ebc9873..1b9724b 100644
24037 --- a/arch/x86/kernel/ldt.c
24038 +++ b/arch/x86/kernel/ldt.c
24039 @@ -66,13 +66,13 @@ static int alloc_ldt(mm_context_t *pc, int mincount, int reload)
24040 if (reload) {
24041 #ifdef CONFIG_SMP
24042 preempt_disable();
24043 - load_LDT(pc);
24044 + load_LDT_nolock(pc);
24045 if (!cpumask_equal(mm_cpumask(current->mm),
24046 cpumask_of(smp_processor_id())))
24047 smp_call_function(flush_ldt, current->mm, 1);
24048 preempt_enable();
24049 #else
24050 - load_LDT(pc);
24051 + load_LDT_nolock(pc);
24052 #endif
24053 }
24054 if (oldsize) {
24055 @@ -94,7 +94,7 @@ static inline int copy_ldt(mm_context_t *new, mm_context_t *old)
24056 return err;
24057
24058 for (i = 0; i < old->size; i++)
24059 - write_ldt_entry(new->ldt, i, old->ldt + i * LDT_ENTRY_SIZE);
24060 + write_ldt_entry(new->ldt, i, old->ldt + i);
24061 return 0;
24062 }
24063
24064 @@ -115,6 +115,24 @@ int init_new_context(struct task_struct *tsk, struct mm_struct *mm)
24065 retval = copy_ldt(&mm->context, &old_mm->context);
24066 mutex_unlock(&old_mm->context.lock);
24067 }
24068 +
24069 + if (tsk == current) {
24070 + mm->context.vdso = 0;
24071 +
24072 +#ifdef CONFIG_X86_32
24073 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
24074 + mm->context.user_cs_base = 0UL;
24075 + mm->context.user_cs_limit = ~0UL;
24076 +
24077 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_SMP)
24078 + cpus_clear(mm->context.cpu_user_cs_mask);
24079 +#endif
24080 +
24081 +#endif
24082 +#endif
24083 +
24084 + }
24085 +
24086 return retval;
24087 }
24088
24089 @@ -229,6 +247,13 @@ static int write_ldt(void __user *ptr, unsigned long bytecount, int oldmode)
24090 }
24091 }
24092
24093 +#ifdef CONFIG_PAX_SEGMEXEC
24094 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && (ldt_info.contents & MODIFY_LDT_CONTENTS_CODE)) {
24095 + error = -EINVAL;
24096 + goto out_unlock;
24097 + }
24098 +#endif
24099 +
24100 fill_ldt(&ldt, &ldt_info);
24101 if (oldmode)
24102 ldt.avl = 0;
24103 diff --git a/arch/x86/kernel/machine_kexec_32.c b/arch/x86/kernel/machine_kexec_32.c
24104 index 5b19e4d..6476a76 100644
24105 --- a/arch/x86/kernel/machine_kexec_32.c
24106 +++ b/arch/x86/kernel/machine_kexec_32.c
24107 @@ -26,7 +26,7 @@
24108 #include <asm/cacheflush.h>
24109 #include <asm/debugreg.h>
24110
24111 -static void set_idt(void *newidt, __u16 limit)
24112 +static void set_idt(struct desc_struct *newidt, __u16 limit)
24113 {
24114 struct desc_ptr curidt;
24115
24116 @@ -38,7 +38,7 @@ static void set_idt(void *newidt, __u16 limit)
24117 }
24118
24119
24120 -static void set_gdt(void *newgdt, __u16 limit)
24121 +static void set_gdt(struct desc_struct *newgdt, __u16 limit)
24122 {
24123 struct desc_ptr curgdt;
24124
24125 @@ -216,7 +216,7 @@ void machine_kexec(struct kimage *image)
24126 }
24127
24128 control_page = page_address(image->control_code_page);
24129 - memcpy(control_page, relocate_kernel, KEXEC_CONTROL_CODE_MAX_SIZE);
24130 + memcpy(control_page, (void *)ktla_ktva((unsigned long)relocate_kernel), KEXEC_CONTROL_CODE_MAX_SIZE);
24131
24132 relocate_kernel_ptr = control_page;
24133 page_list[PA_CONTROL_PAGE] = __pa(control_page);
24134 diff --git a/arch/x86/kernel/microcode_core.c b/arch/x86/kernel/microcode_core.c
24135 index 15c9876..0a43909 100644
24136 --- a/arch/x86/kernel/microcode_core.c
24137 +++ b/arch/x86/kernel/microcode_core.c
24138 @@ -513,7 +513,7 @@ mc_cpu_callback(struct notifier_block *nb, unsigned long action, void *hcpu)
24139 return NOTIFY_OK;
24140 }
24141
24142 -static struct notifier_block __refdata mc_cpu_notifier = {
24143 +static struct notifier_block mc_cpu_notifier = {
24144 .notifier_call = mc_cpu_callback,
24145 };
24146
24147 diff --git a/arch/x86/kernel/microcode_intel.c b/arch/x86/kernel/microcode_intel.c
24148 index 5fb2ceb..3ae90bb 100644
24149 --- a/arch/x86/kernel/microcode_intel.c
24150 +++ b/arch/x86/kernel/microcode_intel.c
24151 @@ -293,13 +293,13 @@ static enum ucode_state request_microcode_fw(int cpu, struct device *device,
24152
24153 static int get_ucode_user(void *to, const void *from, size_t n)
24154 {
24155 - return copy_from_user(to, from, n);
24156 + return copy_from_user(to, (const void __force_user *)from, n);
24157 }
24158
24159 static enum ucode_state
24160 request_microcode_user(int cpu, const void __user *buf, size_t size)
24161 {
24162 - return generic_load_microcode(cpu, (void *)buf, size, &get_ucode_user);
24163 + return generic_load_microcode(cpu, (__force_kernel void *)buf, size, &get_ucode_user);
24164 }
24165
24166 static void microcode_fini_cpu(int cpu)
24167 diff --git a/arch/x86/kernel/module.c b/arch/x86/kernel/module.c
24168 index 216a4d7..228255a 100644
24169 --- a/arch/x86/kernel/module.c
24170 +++ b/arch/x86/kernel/module.c
24171 @@ -43,15 +43,60 @@ do { \
24172 } while (0)
24173 #endif
24174
24175 -void *module_alloc(unsigned long size)
24176 +static inline void *__module_alloc(unsigned long size, pgprot_t prot)
24177 {
24178 - if (PAGE_ALIGN(size) > MODULES_LEN)
24179 + if (!size || PAGE_ALIGN(size) > MODULES_LEN)
24180 return NULL;
24181 return __vmalloc_node_range(size, 1, MODULES_VADDR, MODULES_END,
24182 - GFP_KERNEL | __GFP_HIGHMEM, PAGE_KERNEL_EXEC,
24183 + GFP_KERNEL | __GFP_HIGHMEM | __GFP_ZERO, prot,
24184 -1, __builtin_return_address(0));
24185 }
24186
24187 +void *module_alloc(unsigned long size)
24188 +{
24189 +
24190 +#ifdef CONFIG_PAX_KERNEXEC
24191 + return __module_alloc(size, PAGE_KERNEL);
24192 +#else
24193 + return __module_alloc(size, PAGE_KERNEL_EXEC);
24194 +#endif
24195 +
24196 +}
24197 +
24198 +#ifdef CONFIG_PAX_KERNEXEC
24199 +#ifdef CONFIG_X86_32
24200 +void *module_alloc_exec(unsigned long size)
24201 +{
24202 + struct vm_struct *area;
24203 +
24204 + if (size == 0)
24205 + return NULL;
24206 +
24207 + area = __get_vm_area(size, VM_ALLOC, (unsigned long)&MODULES_EXEC_VADDR, (unsigned long)&MODULES_EXEC_END);
24208 + return area ? area->addr : NULL;
24209 +}
24210 +EXPORT_SYMBOL(module_alloc_exec);
24211 +
24212 +void module_free_exec(struct module *mod, void *module_region)
24213 +{
24214 + vunmap(module_region);
24215 +}
24216 +EXPORT_SYMBOL(module_free_exec);
24217 +#else
24218 +void module_free_exec(struct module *mod, void *module_region)
24219 +{
24220 + module_free(mod, module_region);
24221 +}
24222 +EXPORT_SYMBOL(module_free_exec);
24223 +
24224 +void *module_alloc_exec(unsigned long size)
24225 +{
24226 + return __module_alloc(size, PAGE_KERNEL_RX);
24227 +}
24228 +EXPORT_SYMBOL(module_alloc_exec);
24229 +#endif
24230 +#endif
24231 +
24232 #ifdef CONFIG_X86_32
24233 int apply_relocate(Elf32_Shdr *sechdrs,
24234 const char *strtab,
24235 @@ -62,14 +107,16 @@ int apply_relocate(Elf32_Shdr *sechdrs,
24236 unsigned int i;
24237 Elf32_Rel *rel = (void *)sechdrs[relsec].sh_addr;
24238 Elf32_Sym *sym;
24239 - uint32_t *location;
24240 + uint32_t *plocation, location;
24241
24242 DEBUGP("Applying relocate section %u to %u\n",
24243 relsec, sechdrs[relsec].sh_info);
24244 for (i = 0; i < sechdrs[relsec].sh_size / sizeof(*rel); i++) {
24245 /* This is where to make the change */
24246 - location = (void *)sechdrs[sechdrs[relsec].sh_info].sh_addr
24247 - + rel[i].r_offset;
24248 + plocation = (void *)sechdrs[sechdrs[relsec].sh_info].sh_addr + rel[i].r_offset;
24249 + location = (uint32_t)plocation;
24250 + if (sechdrs[sechdrs[relsec].sh_info].sh_flags & SHF_EXECINSTR)
24251 + plocation = ktla_ktva((void *)plocation);
24252 /* This is the symbol it is referring to. Note that all
24253 undefined symbols have been resolved. */
24254 sym = (Elf32_Sym *)sechdrs[symindex].sh_addr
24255 @@ -78,11 +125,15 @@ int apply_relocate(Elf32_Shdr *sechdrs,
24256 switch (ELF32_R_TYPE(rel[i].r_info)) {
24257 case R_386_32:
24258 /* We add the value into the location given */
24259 - *location += sym->st_value;
24260 + pax_open_kernel();
24261 + *plocation += sym->st_value;
24262 + pax_close_kernel();
24263 break;
24264 case R_386_PC32:
24265 /* Add the value, subtract its position */
24266 - *location += sym->st_value - (uint32_t)location;
24267 + pax_open_kernel();
24268 + *plocation += sym->st_value - location;
24269 + pax_close_kernel();
24270 break;
24271 default:
24272 pr_err("%s: Unknown relocation: %u\n",
24273 @@ -127,21 +178,30 @@ int apply_relocate_add(Elf64_Shdr *sechdrs,
24274 case R_X86_64_NONE:
24275 break;
24276 case R_X86_64_64:
24277 + pax_open_kernel();
24278 *(u64 *)loc = val;
24279 + pax_close_kernel();
24280 break;
24281 case R_X86_64_32:
24282 + pax_open_kernel();
24283 *(u32 *)loc = val;
24284 + pax_close_kernel();
24285 if (val != *(u32 *)loc)
24286 goto overflow;
24287 break;
24288 case R_X86_64_32S:
24289 + pax_open_kernel();
24290 *(s32 *)loc = val;
24291 + pax_close_kernel();
24292 if ((s64)val != *(s32 *)loc)
24293 goto overflow;
24294 break;
24295 case R_X86_64_PC32:
24296 val -= (u64)loc;
24297 + pax_open_kernel();
24298 *(u32 *)loc = val;
24299 + pax_close_kernel();
24300 +
24301 #if 0
24302 if ((s64)val != *(s32 *)loc)
24303 goto overflow;
24304 diff --git a/arch/x86/kernel/msr.c b/arch/x86/kernel/msr.c
24305 index 88458fa..349f7a4 100644
24306 --- a/arch/x86/kernel/msr.c
24307 +++ b/arch/x86/kernel/msr.c
24308 @@ -233,7 +233,7 @@ static int msr_class_cpu_callback(struct notifier_block *nfb,
24309 return notifier_from_errno(err);
24310 }
24311
24312 -static struct notifier_block __refdata msr_class_cpu_notifier = {
24313 +static struct notifier_block msr_class_cpu_notifier = {
24314 .notifier_call = msr_class_cpu_callback,
24315 };
24316
24317 diff --git a/arch/x86/kernel/nmi.c b/arch/x86/kernel/nmi.c
24318 index 6fcb49c..5b3f4ff 100644
24319 --- a/arch/x86/kernel/nmi.c
24320 +++ b/arch/x86/kernel/nmi.c
24321 @@ -138,7 +138,7 @@ static int __kprobes nmi_handle(unsigned int type, struct pt_regs *regs, bool b2
24322 return handled;
24323 }
24324
24325 -int __register_nmi_handler(unsigned int type, struct nmiaction *action)
24326 +int __register_nmi_handler(unsigned int type, const struct nmiaction *action)
24327 {
24328 struct nmi_desc *desc = nmi_to_desc(type);
24329 unsigned long flags;
24330 @@ -162,9 +162,9 @@ int __register_nmi_handler(unsigned int type, struct nmiaction *action)
24331 * event confuses some handlers (kdump uses this flag)
24332 */
24333 if (action->flags & NMI_FLAG_FIRST)
24334 - list_add_rcu(&action->list, &desc->head);
24335 + pax_list_add_rcu((struct list_head *)&action->list, &desc->head);
24336 else
24337 - list_add_tail_rcu(&action->list, &desc->head);
24338 + pax_list_add_tail_rcu((struct list_head *)&action->list, &desc->head);
24339
24340 spin_unlock_irqrestore(&desc->lock, flags);
24341 return 0;
24342 @@ -187,7 +187,7 @@ void unregister_nmi_handler(unsigned int type, const char *name)
24343 if (!strcmp(n->name, name)) {
24344 WARN(in_nmi(),
24345 "Trying to free NMI (%s) from NMI context!\n", n->name);
24346 - list_del_rcu(&n->list);
24347 + pax_list_del_rcu((struct list_head *)&n->list);
24348 break;
24349 }
24350 }
24351 @@ -512,6 +512,17 @@ static inline void nmi_nesting_postprocess(void)
24352 dotraplinkage notrace __kprobes void
24353 do_nmi(struct pt_regs *regs, long error_code)
24354 {
24355 +
24356 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
24357 + if (!user_mode(regs)) {
24358 + unsigned long cs = regs->cs & 0xFFFF;
24359 + unsigned long ip = ktva_ktla(regs->ip);
24360 +
24361 + if ((cs == __KERNEL_CS || cs == __KERNEXEC_KERNEL_CS) && ip <= (unsigned long)_etext)
24362 + regs->ip = ip;
24363 + }
24364 +#endif
24365 +
24366 nmi_nesting_preprocess(regs);
24367
24368 nmi_enter();
24369 diff --git a/arch/x86/kernel/nmi_selftest.c b/arch/x86/kernel/nmi_selftest.c
24370 index 6d9582e..f746287 100644
24371 --- a/arch/x86/kernel/nmi_selftest.c
24372 +++ b/arch/x86/kernel/nmi_selftest.c
24373 @@ -43,7 +43,7 @@ static void __init init_nmi_testsuite(void)
24374 {
24375 /* trap all the unknown NMIs we may generate */
24376 register_nmi_handler(NMI_UNKNOWN, nmi_unk_cb, 0, "nmi_selftest_unk",
24377 - __initdata);
24378 + __initconst);
24379 }
24380
24381 static void __init cleanup_nmi_testsuite(void)
24382 @@ -66,7 +66,7 @@ static void __init test_nmi_ipi(struct cpumask *mask)
24383 unsigned long timeout;
24384
24385 if (register_nmi_handler(NMI_LOCAL, test_nmi_ipi_callback,
24386 - NMI_FLAG_FIRST, "nmi_selftest", __initdata)) {
24387 + NMI_FLAG_FIRST, "nmi_selftest", __initconst)) {
24388 nmi_fail = FAILURE;
24389 return;
24390 }
24391 diff --git a/arch/x86/kernel/paravirt-spinlocks.c b/arch/x86/kernel/paravirt-spinlocks.c
24392 index bbb6c73..24a58ef 100644
24393 --- a/arch/x86/kernel/paravirt-spinlocks.c
24394 +++ b/arch/x86/kernel/paravirt-spinlocks.c
24395 @@ -8,7 +8,7 @@
24396
24397 #include <asm/paravirt.h>
24398
24399 -struct pv_lock_ops pv_lock_ops = {
24400 +struct pv_lock_ops pv_lock_ops __read_only = {
24401 #ifdef CONFIG_SMP
24402 .lock_spinning = __PV_IS_CALLEE_SAVE(paravirt_nop),
24403 .unlock_kick = paravirt_nop,
24404 diff --git a/arch/x86/kernel/paravirt.c b/arch/x86/kernel/paravirt.c
24405 index 1b10af8..0b58cbc 100644
24406 --- a/arch/x86/kernel/paravirt.c
24407 +++ b/arch/x86/kernel/paravirt.c
24408 @@ -55,6 +55,9 @@ u64 _paravirt_ident_64(u64 x)
24409 {
24410 return x;
24411 }
24412 +#if defined(CONFIG_X86_32) && defined(CONFIG_X86_PAE)
24413 +PV_CALLEE_SAVE_REGS_THUNK(_paravirt_ident_64);
24414 +#endif
24415
24416 void __init default_banner(void)
24417 {
24418 @@ -142,15 +145,19 @@ unsigned paravirt_patch_default(u8 type, u16 clobbers, void *insnbuf,
24419 if (opfunc == NULL)
24420 /* If there's no function, patch it with a ud2a (BUG) */
24421 ret = paravirt_patch_insns(insnbuf, len, ud2a, ud2a+sizeof(ud2a));
24422 - else if (opfunc == _paravirt_nop)
24423 + else if (opfunc == (void *)_paravirt_nop)
24424 /* If the operation is a nop, then nop the callsite */
24425 ret = paravirt_patch_nop();
24426
24427 /* identity functions just return their single argument */
24428 - else if (opfunc == _paravirt_ident_32)
24429 + else if (opfunc == (void *)_paravirt_ident_32)
24430 ret = paravirt_patch_ident_32(insnbuf, len);
24431 - else if (opfunc == _paravirt_ident_64)
24432 + else if (opfunc == (void *)_paravirt_ident_64)
24433 ret = paravirt_patch_ident_64(insnbuf, len);
24434 +#if defined(CONFIG_X86_32) && defined(CONFIG_X86_PAE)
24435 + else if (opfunc == (void *)__raw_callee_save__paravirt_ident_64)
24436 + ret = paravirt_patch_ident_64(insnbuf, len);
24437 +#endif
24438
24439 else if (type == PARAVIRT_PATCH(pv_cpu_ops.iret) ||
24440 type == PARAVIRT_PATCH(pv_cpu_ops.irq_enable_sysexit) ||
24441 @@ -175,7 +182,7 @@ unsigned paravirt_patch_insns(void *insnbuf, unsigned len,
24442 if (insn_len > len || start == NULL)
24443 insn_len = len;
24444 else
24445 - memcpy(insnbuf, start, insn_len);
24446 + memcpy(insnbuf, ktla_ktva(start), insn_len);
24447
24448 return insn_len;
24449 }
24450 @@ -299,7 +306,7 @@ enum paravirt_lazy_mode paravirt_get_lazy_mode(void)
24451 return this_cpu_read(paravirt_lazy_mode);
24452 }
24453
24454 -struct pv_info pv_info = {
24455 +struct pv_info pv_info __read_only = {
24456 .name = "bare hardware",
24457 .paravirt_enabled = 0,
24458 .kernel_rpl = 0,
24459 @@ -310,16 +317,16 @@ struct pv_info pv_info = {
24460 #endif
24461 };
24462
24463 -struct pv_init_ops pv_init_ops = {
24464 +struct pv_init_ops pv_init_ops __read_only = {
24465 .patch = native_patch,
24466 };
24467
24468 -struct pv_time_ops pv_time_ops = {
24469 +struct pv_time_ops pv_time_ops __read_only = {
24470 .sched_clock = native_sched_clock,
24471 .steal_clock = native_steal_clock,
24472 };
24473
24474 -__visible struct pv_irq_ops pv_irq_ops = {
24475 +__visible struct pv_irq_ops pv_irq_ops __read_only = {
24476 .save_fl = __PV_IS_CALLEE_SAVE(native_save_fl),
24477 .restore_fl = __PV_IS_CALLEE_SAVE(native_restore_fl),
24478 .irq_disable = __PV_IS_CALLEE_SAVE(native_irq_disable),
24479 @@ -331,7 +338,7 @@ __visible struct pv_irq_ops pv_irq_ops = {
24480 #endif
24481 };
24482
24483 -__visible struct pv_cpu_ops pv_cpu_ops = {
24484 +__visible struct pv_cpu_ops pv_cpu_ops __read_only = {
24485 .cpuid = native_cpuid,
24486 .get_debugreg = native_get_debugreg,
24487 .set_debugreg = native_set_debugreg,
24488 @@ -389,21 +396,26 @@ __visible struct pv_cpu_ops pv_cpu_ops = {
24489 .end_context_switch = paravirt_nop,
24490 };
24491
24492 -struct pv_apic_ops pv_apic_ops = {
24493 +struct pv_apic_ops pv_apic_ops __read_only= {
24494 #ifdef CONFIG_X86_LOCAL_APIC
24495 .startup_ipi_hook = paravirt_nop,
24496 #endif
24497 };
24498
24499 -#if defined(CONFIG_X86_32) && !defined(CONFIG_X86_PAE)
24500 +#ifdef CONFIG_X86_32
24501 +#ifdef CONFIG_X86_PAE
24502 +/* 64-bit pagetable entries */
24503 +#define PTE_IDENT PV_CALLEE_SAVE(_paravirt_ident_64)
24504 +#else
24505 /* 32-bit pagetable entries */
24506 #define PTE_IDENT __PV_IS_CALLEE_SAVE(_paravirt_ident_32)
24507 +#endif
24508 #else
24509 /* 64-bit pagetable entries */
24510 #define PTE_IDENT __PV_IS_CALLEE_SAVE(_paravirt_ident_64)
24511 #endif
24512
24513 -struct pv_mmu_ops pv_mmu_ops = {
24514 +struct pv_mmu_ops pv_mmu_ops __read_only = {
24515
24516 .read_cr2 = native_read_cr2,
24517 .write_cr2 = native_write_cr2,
24518 @@ -453,6 +465,7 @@ struct pv_mmu_ops pv_mmu_ops = {
24519 .make_pud = PTE_IDENT,
24520
24521 .set_pgd = native_set_pgd,
24522 + .set_pgd_batched = native_set_pgd_batched,
24523 #endif
24524 #endif /* PAGETABLE_LEVELS >= 3 */
24525
24526 @@ -473,6 +486,12 @@ struct pv_mmu_ops pv_mmu_ops = {
24527 },
24528
24529 .set_fixmap = native_set_fixmap,
24530 +
24531 +#ifdef CONFIG_PAX_KERNEXEC
24532 + .pax_open_kernel = native_pax_open_kernel,
24533 + .pax_close_kernel = native_pax_close_kernel,
24534 +#endif
24535 +
24536 };
24537
24538 EXPORT_SYMBOL_GPL(pv_time_ops);
24539 diff --git a/arch/x86/kernel/pci-calgary_64.c b/arch/x86/kernel/pci-calgary_64.c
24540 index 299d493..2ccb0ee 100644
24541 --- a/arch/x86/kernel/pci-calgary_64.c
24542 +++ b/arch/x86/kernel/pci-calgary_64.c
24543 @@ -1339,7 +1339,7 @@ static void __init get_tce_space_from_tar(void)
24544 tce_space = be64_to_cpu(readq(target));
24545 tce_space = tce_space & TAR_SW_BITS;
24546
24547 - tce_space = tce_space & (~specified_table_size);
24548 + tce_space = tce_space & (~(unsigned long)specified_table_size);
24549 info->tce_space = (u64 *)__va(tce_space);
24550 }
24551 }
24552 diff --git a/arch/x86/kernel/pci-iommu_table.c b/arch/x86/kernel/pci-iommu_table.c
24553 index 35ccf75..7a15747 100644
24554 --- a/arch/x86/kernel/pci-iommu_table.c
24555 +++ b/arch/x86/kernel/pci-iommu_table.c
24556 @@ -2,7 +2,7 @@
24557 #include <asm/iommu_table.h>
24558 #include <linux/string.h>
24559 #include <linux/kallsyms.h>
24560 -
24561 +#include <linux/sched.h>
24562
24563 #define DEBUG 1
24564
24565 diff --git a/arch/x86/kernel/pci-swiotlb.c b/arch/x86/kernel/pci-swiotlb.c
24566 index 6c483ba..d10ce2f 100644
24567 --- a/arch/x86/kernel/pci-swiotlb.c
24568 +++ b/arch/x86/kernel/pci-swiotlb.c
24569 @@ -32,7 +32,7 @@ static void x86_swiotlb_free_coherent(struct device *dev, size_t size,
24570 void *vaddr, dma_addr_t dma_addr,
24571 struct dma_attrs *attrs)
24572 {
24573 - swiotlb_free_coherent(dev, size, vaddr, dma_addr);
24574 + swiotlb_free_coherent(dev, size, vaddr, dma_addr, attrs);
24575 }
24576
24577 static struct dma_map_ops swiotlb_dma_ops = {
24578 diff --git a/arch/x86/kernel/process.c b/arch/x86/kernel/process.c
24579 index 3fb8d95..254dc51 100644
24580 --- a/arch/x86/kernel/process.c
24581 +++ b/arch/x86/kernel/process.c
24582 @@ -36,7 +36,8 @@
24583 * section. Since TSS's are completely CPU-local, we want them
24584 * on exact cacheline boundaries, to eliminate cacheline ping-pong.
24585 */
24586 -__visible DEFINE_PER_CPU_SHARED_ALIGNED(struct tss_struct, init_tss) = INIT_TSS;
24587 +struct tss_struct init_tss[NR_CPUS] __visible ____cacheline_internodealigned_in_smp = { [0 ... NR_CPUS-1] = INIT_TSS };
24588 +EXPORT_SYMBOL(init_tss);
24589
24590 #ifdef CONFIG_X86_64
24591 static DEFINE_PER_CPU(unsigned char, is_idle);
24592 @@ -92,7 +93,7 @@ void arch_task_cache_init(void)
24593 task_xstate_cachep =
24594 kmem_cache_create("task_xstate", xstate_size,
24595 __alignof__(union thread_xstate),
24596 - SLAB_PANIC | SLAB_NOTRACK, NULL);
24597 + SLAB_PANIC | SLAB_NOTRACK | SLAB_USERCOPY, NULL);
24598 }
24599
24600 /*
24601 @@ -105,7 +106,7 @@ void exit_thread(void)
24602 unsigned long *bp = t->io_bitmap_ptr;
24603
24604 if (bp) {
24605 - struct tss_struct *tss = &per_cpu(init_tss, get_cpu());
24606 + struct tss_struct *tss = init_tss + get_cpu();
24607
24608 t->io_bitmap_ptr = NULL;
24609 clear_thread_flag(TIF_IO_BITMAP);
24610 @@ -125,6 +126,9 @@ void flush_thread(void)
24611 {
24612 struct task_struct *tsk = current;
24613
24614 +#if defined(CONFIG_X86_32) && !defined(CONFIG_CC_STACKPROTECTOR) && !defined(CONFIG_PAX_MEMORY_UDEREF)
24615 + loadsegment(gs, 0);
24616 +#endif
24617 flush_ptrace_hw_breakpoint(tsk);
24618 memset(tsk->thread.tls_array, 0, sizeof(tsk->thread.tls_array));
24619 drop_init_fpu(tsk);
24620 @@ -271,7 +275,7 @@ static void __exit_idle(void)
24621 void exit_idle(void)
24622 {
24623 /* idle loop has pid 0 */
24624 - if (current->pid)
24625 + if (task_pid_nr(current))
24626 return;
24627 __exit_idle();
24628 }
24629 @@ -327,7 +331,7 @@ bool xen_set_default_idle(void)
24630 return ret;
24631 }
24632 #endif
24633 -void stop_this_cpu(void *dummy)
24634 +__noreturn void stop_this_cpu(void *dummy)
24635 {
24636 local_irq_disable();
24637 /*
24638 @@ -456,16 +460,37 @@ static int __init idle_setup(char *str)
24639 }
24640 early_param("idle", idle_setup);
24641
24642 -unsigned long arch_align_stack(unsigned long sp)
24643 +#ifdef CONFIG_PAX_RANDKSTACK
24644 +void pax_randomize_kstack(struct pt_regs *regs)
24645 {
24646 - if (!(current->personality & ADDR_NO_RANDOMIZE) && randomize_va_space)
24647 - sp -= get_random_int() % 8192;
24648 - return sp & ~0xf;
24649 -}
24650 + struct thread_struct *thread = &current->thread;
24651 + unsigned long time;
24652
24653 -unsigned long arch_randomize_brk(struct mm_struct *mm)
24654 -{
24655 - unsigned long range_end = mm->brk + 0x02000000;
24656 - return randomize_range(mm->brk, range_end, 0) ? : mm->brk;
24657 -}
24658 + if (!randomize_va_space)
24659 + return;
24660 +
24661 + if (v8086_mode(regs))
24662 + return;
24663
24664 + rdtscl(time);
24665 +
24666 + /* P4 seems to return a 0 LSB, ignore it */
24667 +#ifdef CONFIG_MPENTIUM4
24668 + time &= 0x3EUL;
24669 + time <<= 2;
24670 +#elif defined(CONFIG_X86_64)
24671 + time &= 0xFUL;
24672 + time <<= 4;
24673 +#else
24674 + time &= 0x1FUL;
24675 + time <<= 3;
24676 +#endif
24677 +
24678 + thread->sp0 ^= time;
24679 + load_sp0(init_tss + smp_processor_id(), thread);
24680 +
24681 +#ifdef CONFIG_X86_64
24682 + this_cpu_write(kernel_stack, thread->sp0);
24683 +#endif
24684 +}
24685 +#endif
24686 diff --git a/arch/x86/kernel/process_32.c b/arch/x86/kernel/process_32.c
24687 index 884f98f..ec23e04 100644
24688 --- a/arch/x86/kernel/process_32.c
24689 +++ b/arch/x86/kernel/process_32.c
24690 @@ -65,6 +65,7 @@ asmlinkage void ret_from_kernel_thread(void) __asm__("ret_from_kernel_thread");
24691 unsigned long thread_saved_pc(struct task_struct *tsk)
24692 {
24693 return ((unsigned long *)tsk->thread.sp)[3];
24694 +//XXX return tsk->thread.eip;
24695 }
24696
24697 void __show_regs(struct pt_regs *regs, int all)
24698 @@ -74,19 +75,18 @@ void __show_regs(struct pt_regs *regs, int all)
24699 unsigned long sp;
24700 unsigned short ss, gs;
24701
24702 - if (user_mode_vm(regs)) {
24703 + if (user_mode(regs)) {
24704 sp = regs->sp;
24705 ss = regs->ss & 0xffff;
24706 - gs = get_user_gs(regs);
24707 } else {
24708 sp = kernel_stack_pointer(regs);
24709 savesegment(ss, ss);
24710 - savesegment(gs, gs);
24711 }
24712 + gs = get_user_gs(regs);
24713
24714 printk(KERN_DEFAULT "EIP: %04x:[<%08lx>] EFLAGS: %08lx CPU: %d\n",
24715 (u16)regs->cs, regs->ip, regs->flags,
24716 - smp_processor_id());
24717 + raw_smp_processor_id());
24718 print_symbol("EIP is at %s\n", regs->ip);
24719
24720 printk(KERN_DEFAULT "EAX: %08lx EBX: %08lx ECX: %08lx EDX: %08lx\n",
24721 @@ -133,20 +133,21 @@ void release_thread(struct task_struct *dead_task)
24722 int copy_thread(unsigned long clone_flags, unsigned long sp,
24723 unsigned long arg, struct task_struct *p)
24724 {
24725 - struct pt_regs *childregs = task_pt_regs(p);
24726 + struct pt_regs *childregs = task_stack_page(p) + THREAD_SIZE - sizeof(struct pt_regs) - 8;
24727 struct task_struct *tsk;
24728 int err;
24729
24730 p->thread.sp = (unsigned long) childregs;
24731 p->thread.sp0 = (unsigned long) (childregs+1);
24732 + p->tinfo.lowest_stack = (unsigned long)task_stack_page(p);
24733
24734 if (unlikely(p->flags & PF_KTHREAD)) {
24735 /* kernel thread */
24736 memset(childregs, 0, sizeof(struct pt_regs));
24737 p->thread.ip = (unsigned long) ret_from_kernel_thread;
24738 - task_user_gs(p) = __KERNEL_STACK_CANARY;
24739 - childregs->ds = __USER_DS;
24740 - childregs->es = __USER_DS;
24741 + savesegment(gs, childregs->gs);
24742 + childregs->ds = __KERNEL_DS;
24743 + childregs->es = __KERNEL_DS;
24744 childregs->fs = __KERNEL_PERCPU;
24745 childregs->bx = sp; /* function */
24746 childregs->bp = arg;
24747 @@ -253,7 +254,7 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
24748 struct thread_struct *prev = &prev_p->thread,
24749 *next = &next_p->thread;
24750 int cpu = smp_processor_id();
24751 - struct tss_struct *tss = &per_cpu(init_tss, cpu);
24752 + struct tss_struct *tss = init_tss + cpu;
24753 fpu_switch_t fpu;
24754
24755 /* never put a printk in __switch_to... printk() calls wake_up*() indirectly */
24756 @@ -277,6 +278,10 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
24757 */
24758 lazy_save_gs(prev->gs);
24759
24760 +#ifdef CONFIG_PAX_MEMORY_UDEREF
24761 + __set_fs(task_thread_info(next_p)->addr_limit);
24762 +#endif
24763 +
24764 /*
24765 * Load the per-thread Thread-Local Storage descriptor.
24766 */
24767 @@ -307,6 +312,9 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
24768 */
24769 arch_end_context_switch(next_p);
24770
24771 + this_cpu_write(current_task, next_p);
24772 + this_cpu_write(current_tinfo, &next_p->tinfo);
24773 +
24774 /*
24775 * Restore %gs if needed (which is common)
24776 */
24777 @@ -315,8 +323,6 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
24778
24779 switch_fpu_finish(next_p, fpu);
24780
24781 - this_cpu_write(current_task, next_p);
24782 -
24783 return prev_p;
24784 }
24785
24786 @@ -346,4 +352,3 @@ unsigned long get_wchan(struct task_struct *p)
24787 } while (count++ < 16);
24788 return 0;
24789 }
24790 -
24791 diff --git a/arch/x86/kernel/process_64.c b/arch/x86/kernel/process_64.c
24792 index bb1dc51..08dda7f 100644
24793 --- a/arch/x86/kernel/process_64.c
24794 +++ b/arch/x86/kernel/process_64.c
24795 @@ -158,10 +158,11 @@ int copy_thread(unsigned long clone_flags, unsigned long sp,
24796 struct pt_regs *childregs;
24797 struct task_struct *me = current;
24798
24799 - p->thread.sp0 = (unsigned long)task_stack_page(p) + THREAD_SIZE;
24800 + p->thread.sp0 = (unsigned long)task_stack_page(p) + THREAD_SIZE - 16;
24801 childregs = task_pt_regs(p);
24802 p->thread.sp = (unsigned long) childregs;
24803 p->thread.usersp = me->thread.usersp;
24804 + p->tinfo.lowest_stack = (unsigned long)task_stack_page(p);
24805 set_tsk_thread_flag(p, TIF_FORK);
24806 p->fpu_counter = 0;
24807 p->thread.io_bitmap_ptr = NULL;
24808 @@ -172,6 +173,8 @@ int copy_thread(unsigned long clone_flags, unsigned long sp,
24809 p->thread.fs = p->thread.fsindex ? 0 : me->thread.fs;
24810 savesegment(es, p->thread.es);
24811 savesegment(ds, p->thread.ds);
24812 + savesegment(ss, p->thread.ss);
24813 + BUG_ON(p->thread.ss == __UDEREF_KERNEL_DS);
24814 memset(p->thread.ptrace_bps, 0, sizeof(p->thread.ptrace_bps));
24815
24816 if (unlikely(p->flags & PF_KTHREAD)) {
24817 @@ -280,7 +283,7 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
24818 struct thread_struct *prev = &prev_p->thread;
24819 struct thread_struct *next = &next_p->thread;
24820 int cpu = smp_processor_id();
24821 - struct tss_struct *tss = &per_cpu(init_tss, cpu);
24822 + struct tss_struct *tss = init_tss + cpu;
24823 unsigned fsindex, gsindex;
24824 fpu_switch_t fpu;
24825
24826 @@ -303,6 +306,9 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
24827 if (unlikely(next->ds | prev->ds))
24828 loadsegment(ds, next->ds);
24829
24830 + savesegment(ss, prev->ss);
24831 + if (unlikely(next->ss != prev->ss))
24832 + loadsegment(ss, next->ss);
24833
24834 /* We must save %fs and %gs before load_TLS() because
24835 * %fs and %gs may be cleared by load_TLS().
24836 @@ -362,10 +368,9 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
24837 prev->usersp = this_cpu_read(old_rsp);
24838 this_cpu_write(old_rsp, next->usersp);
24839 this_cpu_write(current_task, next_p);
24840 + this_cpu_write(current_tinfo, &next_p->tinfo);
24841
24842 - this_cpu_write(kernel_stack,
24843 - (unsigned long)task_stack_page(next_p) +
24844 - THREAD_SIZE - KERNEL_STACK_OFFSET);
24845 + this_cpu_write(kernel_stack, next->sp0);
24846
24847 /*
24848 * Now maybe reload the debug registers and handle I/O bitmaps
24849 @@ -434,12 +439,11 @@ unsigned long get_wchan(struct task_struct *p)
24850 if (!p || p == current || p->state == TASK_RUNNING)
24851 return 0;
24852 stack = (unsigned long)task_stack_page(p);
24853 - if (p->thread.sp < stack || p->thread.sp >= stack+THREAD_SIZE)
24854 + if (p->thread.sp < stack || p->thread.sp > stack+THREAD_SIZE-16-sizeof(u64))
24855 return 0;
24856 fp = *(u64 *)(p->thread.sp);
24857 do {
24858 - if (fp < (unsigned long)stack ||
24859 - fp >= (unsigned long)stack+THREAD_SIZE)
24860 + if (fp < stack || fp > stack+THREAD_SIZE-16-sizeof(u64))
24861 return 0;
24862 ip = *(u64 *)(fp+8);
24863 if (!in_sched_functions(ip))
24864 diff --git a/arch/x86/kernel/ptrace.c b/arch/x86/kernel/ptrace.c
24865 index 7461f50..1334029 100644
24866 --- a/arch/x86/kernel/ptrace.c
24867 +++ b/arch/x86/kernel/ptrace.c
24868 @@ -184,14 +184,13 @@ unsigned long kernel_stack_pointer(struct pt_regs *regs)
24869 {
24870 unsigned long context = (unsigned long)regs & ~(THREAD_SIZE - 1);
24871 unsigned long sp = (unsigned long)&regs->sp;
24872 - struct thread_info *tinfo;
24873
24874 - if (context == (sp & ~(THREAD_SIZE - 1)))
24875 + if (context == ((sp + 8) & ~(THREAD_SIZE - 1)))
24876 return sp;
24877
24878 - tinfo = (struct thread_info *)context;
24879 - if (tinfo->previous_esp)
24880 - return tinfo->previous_esp;
24881 + sp = *(unsigned long *)context;
24882 + if (sp)
24883 + return sp;
24884
24885 return (unsigned long)regs;
24886 }
24887 @@ -588,7 +587,7 @@ static void ptrace_triggered(struct perf_event *bp,
24888 static unsigned long ptrace_get_dr7(struct perf_event *bp[])
24889 {
24890 int i;
24891 - int dr7 = 0;
24892 + unsigned long dr7 = 0;
24893 struct arch_hw_breakpoint *info;
24894
24895 for (i = 0; i < HBP_NUM; i++) {
24896 @@ -822,7 +821,7 @@ long arch_ptrace(struct task_struct *child, long request,
24897 unsigned long addr, unsigned long data)
24898 {
24899 int ret;
24900 - unsigned long __user *datap = (unsigned long __user *)data;
24901 + unsigned long __user *datap = (__force unsigned long __user *)data;
24902
24903 switch (request) {
24904 /* read the word at location addr in the USER area. */
24905 @@ -907,14 +906,14 @@ long arch_ptrace(struct task_struct *child, long request,
24906 if ((int) addr < 0)
24907 return -EIO;
24908 ret = do_get_thread_area(child, addr,
24909 - (struct user_desc __user *)data);
24910 + (__force struct user_desc __user *) data);
24911 break;
24912
24913 case PTRACE_SET_THREAD_AREA:
24914 if ((int) addr < 0)
24915 return -EIO;
24916 ret = do_set_thread_area(child, addr,
24917 - (struct user_desc __user *)data, 0);
24918 + (__force struct user_desc __user *) data, 0);
24919 break;
24920 #endif
24921
24922 @@ -1292,7 +1291,7 @@ long compat_arch_ptrace(struct task_struct *child, compat_long_t request,
24923
24924 #ifdef CONFIG_X86_64
24925
24926 -static struct user_regset x86_64_regsets[] __read_mostly = {
24927 +static user_regset_no_const x86_64_regsets[] __read_only = {
24928 [REGSET_GENERAL] = {
24929 .core_note_type = NT_PRSTATUS,
24930 .n = sizeof(struct user_regs_struct) / sizeof(long),
24931 @@ -1333,7 +1332,7 @@ static const struct user_regset_view user_x86_64_view = {
24932 #endif /* CONFIG_X86_64 */
24933
24934 #if defined CONFIG_X86_32 || defined CONFIG_IA32_EMULATION
24935 -static struct user_regset x86_32_regsets[] __read_mostly = {
24936 +static user_regset_no_const x86_32_regsets[] __read_only = {
24937 [REGSET_GENERAL] = {
24938 .core_note_type = NT_PRSTATUS,
24939 .n = sizeof(struct user_regs_struct32) / sizeof(u32),
24940 @@ -1386,7 +1385,7 @@ static const struct user_regset_view user_x86_32_view = {
24941 */
24942 u64 xstate_fx_sw_bytes[USER_XSTATE_FX_SW_WORDS];
24943
24944 -void update_regset_xstate_info(unsigned int size, u64 xstate_mask)
24945 +void __init update_regset_xstate_info(unsigned int size, u64 xstate_mask)
24946 {
24947 #ifdef CONFIG_X86_64
24948 x86_64_regsets[REGSET_XSTATE].n = size / sizeof(u64);
24949 @@ -1421,7 +1420,7 @@ static void fill_sigtrap_info(struct task_struct *tsk,
24950 memset(info, 0, sizeof(*info));
24951 info->si_signo = SIGTRAP;
24952 info->si_code = si_code;
24953 - info->si_addr = user_mode_vm(regs) ? (void __user *)regs->ip : NULL;
24954 + info->si_addr = user_mode(regs) ? (__force void __user *)regs->ip : NULL;
24955 }
24956
24957 void user_single_step_siginfo(struct task_struct *tsk,
24958 @@ -1450,6 +1449,10 @@ void send_sigtrap(struct task_struct *tsk, struct pt_regs *regs,
24959 # define IS_IA32 0
24960 #endif
24961
24962 +#ifdef CONFIG_GRKERNSEC_SETXID
24963 +extern void gr_delayed_cred_worker(void);
24964 +#endif
24965 +
24966 /*
24967 * We must return the syscall number to actually look up in the table.
24968 * This can be -1L to skip running any syscall at all.
24969 @@ -1460,6 +1463,11 @@ long syscall_trace_enter(struct pt_regs *regs)
24970
24971 user_exit();
24972
24973 +#ifdef CONFIG_GRKERNSEC_SETXID
24974 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
24975 + gr_delayed_cred_worker();
24976 +#endif
24977 +
24978 /*
24979 * If we stepped into a sysenter/syscall insn, it trapped in
24980 * kernel mode; do_debug() cleared TF and set TIF_SINGLESTEP.
24981 @@ -1515,6 +1523,11 @@ void syscall_trace_leave(struct pt_regs *regs)
24982 */
24983 user_exit();
24984
24985 +#ifdef CONFIG_GRKERNSEC_SETXID
24986 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
24987 + gr_delayed_cred_worker();
24988 +#endif
24989 +
24990 audit_syscall_exit(regs);
24991
24992 if (unlikely(test_thread_flag(TIF_SYSCALL_TRACEPOINT)))
24993 diff --git a/arch/x86/kernel/pvclock.c b/arch/x86/kernel/pvclock.c
24994 index a16bae3..1f65f25 100644
24995 --- a/arch/x86/kernel/pvclock.c
24996 +++ b/arch/x86/kernel/pvclock.c
24997 @@ -43,11 +43,11 @@ unsigned long pvclock_tsc_khz(struct pvclock_vcpu_time_info *src)
24998 return pv_tsc_khz;
24999 }
25000
25001 -static atomic64_t last_value = ATOMIC64_INIT(0);
25002 +static atomic64_unchecked_t last_value = ATOMIC64_INIT(0);
25003
25004 void pvclock_resume(void)
25005 {
25006 - atomic64_set(&last_value, 0);
25007 + atomic64_set_unchecked(&last_value, 0);
25008 }
25009
25010 u8 pvclock_read_flags(struct pvclock_vcpu_time_info *src)
25011 @@ -92,11 +92,11 @@ cycle_t pvclock_clocksource_read(struct pvclock_vcpu_time_info *src)
25012 * updating at the same time, and one of them could be slightly behind,
25013 * making the assumption that last_value always go forward fail to hold.
25014 */
25015 - last = atomic64_read(&last_value);
25016 + last = atomic64_read_unchecked(&last_value);
25017 do {
25018 if (ret < last)
25019 return last;
25020 - last = atomic64_cmpxchg(&last_value, last, ret);
25021 + last = atomic64_cmpxchg_unchecked(&last_value, last, ret);
25022 } while (unlikely(last != ret));
25023
25024 return ret;
25025 diff --git a/arch/x86/kernel/reboot.c b/arch/x86/kernel/reboot.c
25026 index 618ce26..ec7e21c 100644
25027 --- a/arch/x86/kernel/reboot.c
25028 +++ b/arch/x86/kernel/reboot.c
25029 @@ -68,6 +68,11 @@ static int __init set_bios_reboot(const struct dmi_system_id *d)
25030
25031 void __noreturn machine_real_restart(unsigned int type)
25032 {
25033 +
25034 +#if defined(CONFIG_X86_32) && (defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF))
25035 + struct desc_struct *gdt;
25036 +#endif
25037 +
25038 local_irq_disable();
25039
25040 /*
25041 @@ -95,7 +100,29 @@ void __noreturn machine_real_restart(unsigned int type)
25042
25043 /* Jump to the identity-mapped low memory code */
25044 #ifdef CONFIG_X86_32
25045 - asm volatile("jmpl *%0" : :
25046 +
25047 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
25048 + gdt = get_cpu_gdt_table(smp_processor_id());
25049 + pax_open_kernel();
25050 +#ifdef CONFIG_PAX_MEMORY_UDEREF
25051 + gdt[GDT_ENTRY_KERNEL_DS].type = 3;
25052 + gdt[GDT_ENTRY_KERNEL_DS].limit = 0xf;
25053 + loadsegment(ds, __KERNEL_DS);
25054 + loadsegment(es, __KERNEL_DS);
25055 + loadsegment(ss, __KERNEL_DS);
25056 +#endif
25057 +#ifdef CONFIG_PAX_KERNEXEC
25058 + gdt[GDT_ENTRY_KERNEL_CS].base0 = 0;
25059 + gdt[GDT_ENTRY_KERNEL_CS].base1 = 0;
25060 + gdt[GDT_ENTRY_KERNEL_CS].base2 = 0;
25061 + gdt[GDT_ENTRY_KERNEL_CS].limit0 = 0xffff;
25062 + gdt[GDT_ENTRY_KERNEL_CS].limit = 0xf;
25063 + gdt[GDT_ENTRY_KERNEL_CS].g = 1;
25064 +#endif
25065 + pax_close_kernel();
25066 +#endif
25067 +
25068 + asm volatile("ljmpl *%0" : :
25069 "rm" (real_mode_header->machine_real_restart_asm),
25070 "a" (type));
25071 #else
25072 @@ -466,7 +493,7 @@ void __attribute__((weak)) mach_reboot_fixups(void)
25073 * try to force a triple fault and then cycle between hitting the keyboard
25074 * controller and doing that
25075 */
25076 -static void native_machine_emergency_restart(void)
25077 +static void __noreturn native_machine_emergency_restart(void)
25078 {
25079 int i;
25080 int attempt = 0;
25081 @@ -575,13 +602,13 @@ void native_machine_shutdown(void)
25082 #endif
25083 }
25084
25085 -static void __machine_emergency_restart(int emergency)
25086 +static void __noreturn __machine_emergency_restart(int emergency)
25087 {
25088 reboot_emergency = emergency;
25089 machine_ops.emergency_restart();
25090 }
25091
25092 -static void native_machine_restart(char *__unused)
25093 +static void __noreturn native_machine_restart(char *__unused)
25094 {
25095 pr_notice("machine restart\n");
25096
25097 @@ -590,7 +617,7 @@ static void native_machine_restart(char *__unused)
25098 __machine_emergency_restart(0);
25099 }
25100
25101 -static void native_machine_halt(void)
25102 +static void __noreturn native_machine_halt(void)
25103 {
25104 /* Stop other cpus and apics */
25105 machine_shutdown();
25106 @@ -600,7 +627,7 @@ static void native_machine_halt(void)
25107 stop_this_cpu(NULL);
25108 }
25109
25110 -static void native_machine_power_off(void)
25111 +static void __noreturn native_machine_power_off(void)
25112 {
25113 if (pm_power_off) {
25114 if (!reboot_force)
25115 @@ -609,9 +636,10 @@ static void native_machine_power_off(void)
25116 }
25117 /* A fallback in case there is no PM info available */
25118 tboot_shutdown(TB_SHUTDOWN_HALT);
25119 + unreachable();
25120 }
25121
25122 -struct machine_ops machine_ops = {
25123 +struct machine_ops machine_ops __read_only = {
25124 .power_off = native_machine_power_off,
25125 .shutdown = native_machine_shutdown,
25126 .emergency_restart = native_machine_emergency_restart,
25127 diff --git a/arch/x86/kernel/reboot_fixups_32.c b/arch/x86/kernel/reboot_fixups_32.c
25128 index c8e41e9..64049ef 100644
25129 --- a/arch/x86/kernel/reboot_fixups_32.c
25130 +++ b/arch/x86/kernel/reboot_fixups_32.c
25131 @@ -57,7 +57,7 @@ struct device_fixup {
25132 unsigned int vendor;
25133 unsigned int device;
25134 void (*reboot_fixup)(struct pci_dev *);
25135 -};
25136 +} __do_const;
25137
25138 /*
25139 * PCI ids solely used for fixups_table go here
25140 diff --git a/arch/x86/kernel/relocate_kernel_64.S b/arch/x86/kernel/relocate_kernel_64.S
25141 index 3fd2c69..16ef367 100644
25142 --- a/arch/x86/kernel/relocate_kernel_64.S
25143 +++ b/arch/x86/kernel/relocate_kernel_64.S
25144 @@ -11,6 +11,7 @@
25145 #include <asm/kexec.h>
25146 #include <asm/processor-flags.h>
25147 #include <asm/pgtable_types.h>
25148 +#include <asm/alternative-asm.h>
25149
25150 /*
25151 * Must be relocatable PIC code callable as a C function
25152 @@ -96,8 +97,7 @@ relocate_kernel:
25153
25154 /* jump to identity mapped page */
25155 addq $(identity_mapped - relocate_kernel), %r8
25156 - pushq %r8
25157 - ret
25158 + jmp *%r8
25159
25160 identity_mapped:
25161 /* set return address to 0 if not preserving context */
25162 @@ -167,6 +167,7 @@ identity_mapped:
25163 xorl %r14d, %r14d
25164 xorl %r15d, %r15d
25165
25166 + pax_force_retaddr 0, 1
25167 ret
25168
25169 1:
25170 diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c
25171 index f0de629..a4978a8f 100644
25172 --- a/arch/x86/kernel/setup.c
25173 +++ b/arch/x86/kernel/setup.c
25174 @@ -110,6 +110,7 @@
25175 #include <asm/mce.h>
25176 #include <asm/alternative.h>
25177 #include <asm/prom.h>
25178 +#include <asm/boot.h>
25179
25180 /*
25181 * max_low_pfn_mapped: highest direct mapped pfn under 4GB
25182 @@ -205,12 +206,50 @@ EXPORT_SYMBOL(boot_cpu_data);
25183 #endif
25184
25185
25186 -#if !defined(CONFIG_X86_PAE) || defined(CONFIG_X86_64)
25187 -__visible unsigned long mmu_cr4_features;
25188 +#ifdef CONFIG_X86_64
25189 +__visible unsigned long mmu_cr4_features __read_only = X86_CR4_PSE | X86_CR4_PAE | X86_CR4_PGE;
25190 +#elif defined(CONFIG_X86_PAE)
25191 +__visible unsigned long mmu_cr4_features __read_only = X86_CR4_PAE;
25192 #else
25193 -__visible unsigned long mmu_cr4_features = X86_CR4_PAE;
25194 +__visible unsigned long mmu_cr4_features __read_only;
25195 #endif
25196
25197 +void set_in_cr4(unsigned long mask)
25198 +{
25199 + unsigned long cr4 = read_cr4();
25200 +
25201 + if ((cr4 & mask) == mask && cr4 == mmu_cr4_features)
25202 + return;
25203 +
25204 + pax_open_kernel();
25205 + mmu_cr4_features |= mask;
25206 + pax_close_kernel();
25207 +
25208 + if (trampoline_cr4_features)
25209 + *trampoline_cr4_features = mmu_cr4_features;
25210 + cr4 |= mask;
25211 + write_cr4(cr4);
25212 +}
25213 +EXPORT_SYMBOL(set_in_cr4);
25214 +
25215 +void clear_in_cr4(unsigned long mask)
25216 +{
25217 + unsigned long cr4 = read_cr4();
25218 +
25219 + if (!(cr4 & mask) && cr4 == mmu_cr4_features)
25220 + return;
25221 +
25222 + pax_open_kernel();
25223 + mmu_cr4_features &= ~mask;
25224 + pax_close_kernel();
25225 +
25226 + if (trampoline_cr4_features)
25227 + *trampoline_cr4_features = mmu_cr4_features;
25228 + cr4 &= ~mask;
25229 + write_cr4(cr4);
25230 +}
25231 +EXPORT_SYMBOL(clear_in_cr4);
25232 +
25233 /* Boot loader ID and version as integers, for the benefit of proc_dointvec */
25234 int bootloader_type, bootloader_version;
25235
25236 @@ -768,7 +807,7 @@ static void __init trim_bios_range(void)
25237 * area (640->1Mb) as ram even though it is not.
25238 * take them out.
25239 */
25240 - e820_remove_range(BIOS_BEGIN, BIOS_END - BIOS_BEGIN, E820_RAM, 1);
25241 + e820_remove_range(ISA_START_ADDRESS, ISA_END_ADDRESS - ISA_START_ADDRESS, E820_RAM, 1);
25242
25243 sanitize_e820_map(e820.map, ARRAY_SIZE(e820.map), &e820.nr_map);
25244 }
25245 @@ -776,7 +815,7 @@ static void __init trim_bios_range(void)
25246 /* called before trim_bios_range() to spare extra sanitize */
25247 static void __init e820_add_kernel_range(void)
25248 {
25249 - u64 start = __pa_symbol(_text);
25250 + u64 start = __pa_symbol(ktla_ktva(_text));
25251 u64 size = __pa_symbol(_end) - start;
25252
25253 /*
25254 @@ -838,8 +877,12 @@ static void __init trim_low_memory_range(void)
25255
25256 void __init setup_arch(char **cmdline_p)
25257 {
25258 +#ifdef CONFIG_X86_32
25259 + memblock_reserve(LOAD_PHYSICAL_ADDR, __pa_symbol(__bss_stop) - LOAD_PHYSICAL_ADDR);
25260 +#else
25261 memblock_reserve(__pa_symbol(_text),
25262 (unsigned long)__bss_stop - (unsigned long)_text);
25263 +#endif
25264
25265 early_reserve_initrd();
25266
25267 @@ -931,14 +974,14 @@ void __init setup_arch(char **cmdline_p)
25268
25269 if (!boot_params.hdr.root_flags)
25270 root_mountflags &= ~MS_RDONLY;
25271 - init_mm.start_code = (unsigned long) _text;
25272 - init_mm.end_code = (unsigned long) _etext;
25273 + init_mm.start_code = ktla_ktva((unsigned long) _text);
25274 + init_mm.end_code = ktla_ktva((unsigned long) _etext);
25275 init_mm.end_data = (unsigned long) _edata;
25276 init_mm.brk = _brk_end;
25277
25278 - code_resource.start = __pa_symbol(_text);
25279 - code_resource.end = __pa_symbol(_etext)-1;
25280 - data_resource.start = __pa_symbol(_etext);
25281 + code_resource.start = __pa_symbol(ktla_ktva(_text));
25282 + code_resource.end = __pa_symbol(ktla_ktva(_etext))-1;
25283 + data_resource.start = __pa_symbol(_sdata);
25284 data_resource.end = __pa_symbol(_edata)-1;
25285 bss_resource.start = __pa_symbol(__bss_start);
25286 bss_resource.end = __pa_symbol(__bss_stop)-1;
25287 diff --git a/arch/x86/kernel/setup_percpu.c b/arch/x86/kernel/setup_percpu.c
25288 index 5cdff03..80fa283 100644
25289 --- a/arch/x86/kernel/setup_percpu.c
25290 +++ b/arch/x86/kernel/setup_percpu.c
25291 @@ -21,19 +21,17 @@
25292 #include <asm/cpu.h>
25293 #include <asm/stackprotector.h>
25294
25295 -DEFINE_PER_CPU_READ_MOSTLY(int, cpu_number);
25296 +#ifdef CONFIG_SMP
25297 +DEFINE_PER_CPU_READ_MOSTLY(unsigned int, cpu_number);
25298 EXPORT_PER_CPU_SYMBOL(cpu_number);
25299 +#endif
25300
25301 -#ifdef CONFIG_X86_64
25302 #define BOOT_PERCPU_OFFSET ((unsigned long)__per_cpu_load)
25303 -#else
25304 -#define BOOT_PERCPU_OFFSET 0
25305 -#endif
25306
25307 DEFINE_PER_CPU(unsigned long, this_cpu_off) = BOOT_PERCPU_OFFSET;
25308 EXPORT_PER_CPU_SYMBOL(this_cpu_off);
25309
25310 -unsigned long __per_cpu_offset[NR_CPUS] __read_mostly = {
25311 +unsigned long __per_cpu_offset[NR_CPUS] __read_only = {
25312 [0 ... NR_CPUS-1] = BOOT_PERCPU_OFFSET,
25313 };
25314 EXPORT_SYMBOL(__per_cpu_offset);
25315 @@ -66,7 +64,7 @@ static bool __init pcpu_need_numa(void)
25316 {
25317 #ifdef CONFIG_NEED_MULTIPLE_NODES
25318 pg_data_t *last = NULL;
25319 - unsigned int cpu;
25320 + int cpu;
25321
25322 for_each_possible_cpu(cpu) {
25323 int node = early_cpu_to_node(cpu);
25324 @@ -155,10 +153,10 @@ static inline void setup_percpu_segment(int cpu)
25325 {
25326 #ifdef CONFIG_X86_32
25327 struct desc_struct gdt;
25328 + unsigned long base = per_cpu_offset(cpu);
25329
25330 - pack_descriptor(&gdt, per_cpu_offset(cpu), 0xFFFFF,
25331 - 0x2 | DESCTYPE_S, 0x8);
25332 - gdt.s = 1;
25333 + pack_descriptor(&gdt, base, (VMALLOC_END - base - 1) >> PAGE_SHIFT,
25334 + 0x83 | DESCTYPE_S, 0xC);
25335 write_gdt_entry(get_cpu_gdt_table(cpu),
25336 GDT_ENTRY_PERCPU, &gdt, DESCTYPE_S);
25337 #endif
25338 @@ -219,6 +217,11 @@ void __init setup_per_cpu_areas(void)
25339 /* alrighty, percpu areas up and running */
25340 delta = (unsigned long)pcpu_base_addr - (unsigned long)__per_cpu_start;
25341 for_each_possible_cpu(cpu) {
25342 +#ifdef CONFIG_CC_STACKPROTECTOR
25343 +#ifdef CONFIG_X86_32
25344 + unsigned long canary = per_cpu(stack_canary.canary, cpu);
25345 +#endif
25346 +#endif
25347 per_cpu_offset(cpu) = delta + pcpu_unit_offsets[cpu];
25348 per_cpu(this_cpu_off, cpu) = per_cpu_offset(cpu);
25349 per_cpu(cpu_number, cpu) = cpu;
25350 @@ -259,6 +262,12 @@ void __init setup_per_cpu_areas(void)
25351 */
25352 set_cpu_numa_node(cpu, early_cpu_to_node(cpu));
25353 #endif
25354 +#ifdef CONFIG_CC_STACKPROTECTOR
25355 +#ifdef CONFIG_X86_32
25356 + if (!cpu)
25357 + per_cpu(stack_canary.canary, cpu) = canary;
25358 +#endif
25359 +#endif
25360 /*
25361 * Up to this point, the boot CPU has been using .init.data
25362 * area. Reload any changed state for the boot CPU.
25363 diff --git a/arch/x86/kernel/signal.c b/arch/x86/kernel/signal.c
25364 index 9e5de68..16c53cb 100644
25365 --- a/arch/x86/kernel/signal.c
25366 +++ b/arch/x86/kernel/signal.c
25367 @@ -190,7 +190,7 @@ static unsigned long align_sigframe(unsigned long sp)
25368 * Align the stack pointer according to the i386 ABI,
25369 * i.e. so that on function entry ((sp + 4) & 15) == 0.
25370 */
25371 - sp = ((sp + 4) & -16ul) - 4;
25372 + sp = ((sp - 12) & -16ul) - 4;
25373 #else /* !CONFIG_X86_32 */
25374 sp = round_down(sp, 16) - 8;
25375 #endif
25376 @@ -298,9 +298,9 @@ __setup_frame(int sig, struct ksignal *ksig, sigset_t *set,
25377 }
25378
25379 if (current->mm->context.vdso)
25380 - restorer = VDSO32_SYMBOL(current->mm->context.vdso, sigreturn);
25381 + restorer = (__force void __user *)VDSO32_SYMBOL(current->mm->context.vdso, sigreturn);
25382 else
25383 - restorer = &frame->retcode;
25384 + restorer = (void __user *)&frame->retcode;
25385 if (ksig->ka.sa.sa_flags & SA_RESTORER)
25386 restorer = ksig->ka.sa.sa_restorer;
25387
25388 @@ -314,7 +314,7 @@ __setup_frame(int sig, struct ksignal *ksig, sigset_t *set,
25389 * reasons and because gdb uses it as a signature to notice
25390 * signal handler stack frames.
25391 */
25392 - err |= __put_user(*((u64 *)&retcode), (u64 *)frame->retcode);
25393 + err |= __put_user(*((u64 *)&retcode), (u64 __user *)frame->retcode);
25394
25395 if (err)
25396 return -EFAULT;
25397 @@ -361,7 +361,10 @@ static int __setup_rt_frame(int sig, struct ksignal *ksig,
25398 save_altstack_ex(&frame->uc.uc_stack, regs->sp);
25399
25400 /* Set up to return from userspace. */
25401 - restorer = VDSO32_SYMBOL(current->mm->context.vdso, rt_sigreturn);
25402 + if (current->mm->context.vdso)
25403 + restorer = (__force void __user *)VDSO32_SYMBOL(current->mm->context.vdso, rt_sigreturn);
25404 + else
25405 + restorer = (void __user *)&frame->retcode;
25406 if (ksig->ka.sa.sa_flags & SA_RESTORER)
25407 restorer = ksig->ka.sa.sa_restorer;
25408 put_user_ex(restorer, &frame->pretcode);
25409 @@ -373,7 +376,7 @@ static int __setup_rt_frame(int sig, struct ksignal *ksig,
25410 * reasons and because gdb uses it as a signature to notice
25411 * signal handler stack frames.
25412 */
25413 - put_user_ex(*((u64 *)&rt_retcode), (u64 *)frame->retcode);
25414 + put_user_ex(*((u64 *)&rt_retcode), (u64 __user *)frame->retcode);
25415 } put_user_catch(err);
25416
25417 err |= copy_siginfo_to_user(&frame->info, &ksig->info);
25418 @@ -609,7 +612,12 @@ setup_rt_frame(struct ksignal *ksig, struct pt_regs *regs)
25419 {
25420 int usig = signr_convert(ksig->sig);
25421 sigset_t *set = sigmask_to_save();
25422 - compat_sigset_t *cset = (compat_sigset_t *) set;
25423 + sigset_t sigcopy;
25424 + compat_sigset_t *cset;
25425 +
25426 + sigcopy = *set;
25427 +
25428 + cset = (compat_sigset_t *) &sigcopy;
25429
25430 /* Set up the stack frame */
25431 if (is_ia32_frame()) {
25432 @@ -620,7 +628,7 @@ setup_rt_frame(struct ksignal *ksig, struct pt_regs *regs)
25433 } else if (is_x32_frame()) {
25434 return x32_setup_rt_frame(ksig, cset, regs);
25435 } else {
25436 - return __setup_rt_frame(ksig->sig, ksig, set, regs);
25437 + return __setup_rt_frame(ksig->sig, ksig, &sigcopy, regs);
25438 }
25439 }
25440
25441 diff --git a/arch/x86/kernel/smp.c b/arch/x86/kernel/smp.c
25442 index 7c3a5a6..f0a8961 100644
25443 --- a/arch/x86/kernel/smp.c
25444 +++ b/arch/x86/kernel/smp.c
25445 @@ -341,7 +341,7 @@ static int __init nonmi_ipi_setup(char *str)
25446
25447 __setup("nonmi_ipi", nonmi_ipi_setup);
25448
25449 -struct smp_ops smp_ops = {
25450 +struct smp_ops smp_ops __read_only = {
25451 .smp_prepare_boot_cpu = native_smp_prepare_boot_cpu,
25452 .smp_prepare_cpus = native_smp_prepare_cpus,
25453 .smp_cpus_done = native_smp_cpus_done,
25454 diff --git a/arch/x86/kernel/smpboot.c b/arch/x86/kernel/smpboot.c
25455 index 6cacab6..750636a 100644
25456 --- a/arch/x86/kernel/smpboot.c
25457 +++ b/arch/x86/kernel/smpboot.c
25458 @@ -251,14 +251,18 @@ static void notrace start_secondary(void *unused)
25459
25460 enable_start_cpu0 = 0;
25461
25462 -#ifdef CONFIG_X86_32
25463 - /* switch away from the initial page table */
25464 - load_cr3(swapper_pg_dir);
25465 - __flush_tlb_all();
25466 -#endif
25467 -
25468 /* otherwise gcc will move up smp_processor_id before the cpu_init */
25469 barrier();
25470 +
25471 + /* switch away from the initial page table */
25472 +#ifdef CONFIG_PAX_PER_CPU_PGD
25473 + load_cr3(get_cpu_pgd(smp_processor_id(), kernel));
25474 + __flush_tlb_all();
25475 +#elif defined(CONFIG_X86_32)
25476 + load_cr3(swapper_pg_dir);
25477 + __flush_tlb_all();
25478 +#endif
25479 +
25480 /*
25481 * Check TSC synchronization with the BP:
25482 */
25483 @@ -749,6 +753,7 @@ static int do_boot_cpu(int apicid, int cpu, struct task_struct *idle)
25484 idle->thread.sp = (unsigned long) (((struct pt_regs *)
25485 (THREAD_SIZE + task_stack_page(idle))) - 1);
25486 per_cpu(current_task, cpu) = idle;
25487 + per_cpu(current_tinfo, cpu) = &idle->tinfo;
25488
25489 #ifdef CONFIG_X86_32
25490 /* Stack for startup_32 can be just as for start_secondary onwards */
25491 @@ -756,11 +761,13 @@ static int do_boot_cpu(int apicid, int cpu, struct task_struct *idle)
25492 #else
25493 clear_tsk_thread_flag(idle, TIF_FORK);
25494 initial_gs = per_cpu_offset(cpu);
25495 - per_cpu(kernel_stack, cpu) =
25496 - (unsigned long)task_stack_page(idle) -
25497 - KERNEL_STACK_OFFSET + THREAD_SIZE;
25498 + per_cpu(kernel_stack, cpu) = (unsigned long)task_stack_page(idle) - 16 + THREAD_SIZE;
25499 #endif
25500 +
25501 + pax_open_kernel();
25502 early_gdt_descr.address = (unsigned long)get_cpu_gdt_table(cpu);
25503 + pax_close_kernel();
25504 +
25505 initial_code = (unsigned long)start_secondary;
25506 stack_start = idle->thread.sp;
25507
25508 @@ -909,6 +916,15 @@ int native_cpu_up(unsigned int cpu, struct task_struct *tidle)
25509 /* the FPU context is blank, nobody can own it */
25510 __cpu_disable_lazy_restore(cpu);
25511
25512 +#ifdef CONFIG_PAX_PER_CPU_PGD
25513 + clone_pgd_range(get_cpu_pgd(cpu, kernel) + KERNEL_PGD_BOUNDARY,
25514 + swapper_pg_dir + KERNEL_PGD_BOUNDARY,
25515 + KERNEL_PGD_PTRS);
25516 + clone_pgd_range(get_cpu_pgd(cpu, user) + KERNEL_PGD_BOUNDARY,
25517 + swapper_pg_dir + KERNEL_PGD_BOUNDARY,
25518 + KERNEL_PGD_PTRS);
25519 +#endif
25520 +
25521 err = do_boot_cpu(apicid, cpu, tidle);
25522 if (err) {
25523 pr_debug("do_boot_cpu failed %d\n", err);
25524 diff --git a/arch/x86/kernel/step.c b/arch/x86/kernel/step.c
25525 index 9b4d51d..5d28b58 100644
25526 --- a/arch/x86/kernel/step.c
25527 +++ b/arch/x86/kernel/step.c
25528 @@ -27,10 +27,10 @@ unsigned long convert_ip_to_linear(struct task_struct *child, struct pt_regs *re
25529 struct desc_struct *desc;
25530 unsigned long base;
25531
25532 - seg &= ~7UL;
25533 + seg >>= 3;
25534
25535 mutex_lock(&child->mm->context.lock);
25536 - if (unlikely((seg >> 3) >= child->mm->context.size))
25537 + if (unlikely(seg >= child->mm->context.size))
25538 addr = -1L; /* bogus selector, access would fault */
25539 else {
25540 desc = child->mm->context.ldt + seg;
25541 @@ -42,7 +42,8 @@ unsigned long convert_ip_to_linear(struct task_struct *child, struct pt_regs *re
25542 addr += base;
25543 }
25544 mutex_unlock(&child->mm->context.lock);
25545 - }
25546 + } else if (seg == __KERNEL_CS || seg == __KERNEXEC_KERNEL_CS)
25547 + addr = ktla_ktva(addr);
25548
25549 return addr;
25550 }
25551 @@ -53,6 +54,9 @@ static int is_setting_trap_flag(struct task_struct *child, struct pt_regs *regs)
25552 unsigned char opcode[15];
25553 unsigned long addr = convert_ip_to_linear(child, regs);
25554
25555 + if (addr == -EINVAL)
25556 + return 0;
25557 +
25558 copied = access_process_vm(child, addr, opcode, sizeof(opcode), 0);
25559 for (i = 0; i < copied; i++) {
25560 switch (opcode[i]) {
25561 diff --git a/arch/x86/kernel/sys_i386_32.c b/arch/x86/kernel/sys_i386_32.c
25562 new file mode 100644
25563 index 0000000..5877189
25564 --- /dev/null
25565 +++ b/arch/x86/kernel/sys_i386_32.c
25566 @@ -0,0 +1,189 @@
25567 +/*
25568 + * This file contains various random system calls that
25569 + * have a non-standard calling sequence on the Linux/i386
25570 + * platform.
25571 + */
25572 +
25573 +#include <linux/errno.h>
25574 +#include <linux/sched.h>
25575 +#include <linux/mm.h>
25576 +#include <linux/fs.h>
25577 +#include <linux/smp.h>
25578 +#include <linux/sem.h>
25579 +#include <linux/msg.h>
25580 +#include <linux/shm.h>
25581 +#include <linux/stat.h>
25582 +#include <linux/syscalls.h>
25583 +#include <linux/mman.h>
25584 +#include <linux/file.h>
25585 +#include <linux/utsname.h>
25586 +#include <linux/ipc.h>
25587 +#include <linux/elf.h>
25588 +
25589 +#include <linux/uaccess.h>
25590 +#include <linux/unistd.h>
25591 +
25592 +#include <asm/syscalls.h>
25593 +
25594 +int i386_mmap_check(unsigned long addr, unsigned long len, unsigned long flags)
25595 +{
25596 + unsigned long pax_task_size = TASK_SIZE;
25597 +
25598 +#ifdef CONFIG_PAX_SEGMEXEC
25599 + if (current->mm->pax_flags & MF_PAX_SEGMEXEC)
25600 + pax_task_size = SEGMEXEC_TASK_SIZE;
25601 +#endif
25602 +
25603 + if (flags & MAP_FIXED)
25604 + if (len > pax_task_size || addr > pax_task_size - len)
25605 + return -EINVAL;
25606 +
25607 + return 0;
25608 +}
25609 +
25610 +/*
25611 + * Align a virtual address to avoid aliasing in the I$ on AMD F15h.
25612 + */
25613 +static unsigned long get_align_mask(void)
25614 +{
25615 + if (va_align.flags < 0 || !(va_align.flags & ALIGN_VA_32))
25616 + return 0;
25617 +
25618 + if (!(current->flags & PF_RANDOMIZE))
25619 + return 0;
25620 +
25621 + return va_align.mask;
25622 +}
25623 +
25624 +unsigned long
25625 +arch_get_unmapped_area(struct file *filp, unsigned long addr,
25626 + unsigned long len, unsigned long pgoff, unsigned long flags)
25627 +{
25628 + struct mm_struct *mm = current->mm;
25629 + struct vm_area_struct *vma;
25630 + unsigned long pax_task_size = TASK_SIZE;
25631 + struct vm_unmapped_area_info info;
25632 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
25633 +
25634 +#ifdef CONFIG_PAX_SEGMEXEC
25635 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
25636 + pax_task_size = SEGMEXEC_TASK_SIZE;
25637 +#endif
25638 +
25639 + pax_task_size -= PAGE_SIZE;
25640 +
25641 + if (len > pax_task_size)
25642 + return -ENOMEM;
25643 +
25644 + if (flags & MAP_FIXED)
25645 + return addr;
25646 +
25647 +#ifdef CONFIG_PAX_RANDMMAP
25648 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
25649 +#endif
25650 +
25651 + if (addr) {
25652 + addr = PAGE_ALIGN(addr);
25653 + if (pax_task_size - len >= addr) {
25654 + vma = find_vma(mm, addr);
25655 + if (check_heap_stack_gap(vma, addr, len, offset))
25656 + return addr;
25657 + }
25658 + }
25659 +
25660 + info.flags = 0;
25661 + info.length = len;
25662 + info.align_mask = filp ? get_align_mask() : 0;
25663 + info.align_offset = pgoff << PAGE_SHIFT;
25664 + info.threadstack_offset = offset;
25665 +
25666 +#ifdef CONFIG_PAX_PAGEEXEC
25667 + if (!(__supported_pte_mask & _PAGE_NX) && (mm->pax_flags & MF_PAX_PAGEEXEC) && (flags & MAP_EXECUTABLE)) {
25668 + info.low_limit = 0x00110000UL;
25669 + info.high_limit = mm->start_code;
25670 +
25671 +#ifdef CONFIG_PAX_RANDMMAP
25672 + if (mm->pax_flags & MF_PAX_RANDMMAP)
25673 + info.low_limit += mm->delta_mmap & 0x03FFF000UL;
25674 +#endif
25675 +
25676 + if (info.low_limit < info.high_limit) {
25677 + addr = vm_unmapped_area(&info);
25678 + if (!IS_ERR_VALUE(addr))
25679 + return addr;
25680 + }
25681 + } else
25682 +#endif
25683 +
25684 + info.low_limit = mm->mmap_base;
25685 + info.high_limit = pax_task_size;
25686 +
25687 + return vm_unmapped_area(&info);
25688 +}
25689 +
25690 +unsigned long
25691 +arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
25692 + const unsigned long len, const unsigned long pgoff,
25693 + const unsigned long flags)
25694 +{
25695 + struct vm_area_struct *vma;
25696 + struct mm_struct *mm = current->mm;
25697 + unsigned long addr = addr0, pax_task_size = TASK_SIZE;
25698 + struct vm_unmapped_area_info info;
25699 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
25700 +
25701 +#ifdef CONFIG_PAX_SEGMEXEC
25702 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
25703 + pax_task_size = SEGMEXEC_TASK_SIZE;
25704 +#endif
25705 +
25706 + pax_task_size -= PAGE_SIZE;
25707 +
25708 + /* requested length too big for entire address space */
25709 + if (len > pax_task_size)
25710 + return -ENOMEM;
25711 +
25712 + if (flags & MAP_FIXED)
25713 + return addr;
25714 +
25715 +#ifdef CONFIG_PAX_PAGEEXEC
25716 + if (!(__supported_pte_mask & _PAGE_NX) && (mm->pax_flags & MF_PAX_PAGEEXEC) && (flags & MAP_EXECUTABLE))
25717 + goto bottomup;
25718 +#endif
25719 +
25720 +#ifdef CONFIG_PAX_RANDMMAP
25721 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
25722 +#endif
25723 +
25724 + /* requesting a specific address */
25725 + if (addr) {
25726 + addr = PAGE_ALIGN(addr);
25727 + if (pax_task_size - len >= addr) {
25728 + vma = find_vma(mm, addr);
25729 + if (check_heap_stack_gap(vma, addr, len, offset))
25730 + return addr;
25731 + }
25732 + }
25733 +
25734 + info.flags = VM_UNMAPPED_AREA_TOPDOWN;
25735 + info.length = len;
25736 + info.low_limit = PAGE_SIZE;
25737 + info.high_limit = mm->mmap_base;
25738 + info.align_mask = filp ? get_align_mask() : 0;
25739 + info.align_offset = pgoff << PAGE_SHIFT;
25740 + info.threadstack_offset = offset;
25741 +
25742 + addr = vm_unmapped_area(&info);
25743 + if (!(addr & ~PAGE_MASK))
25744 + return addr;
25745 + VM_BUG_ON(addr != -ENOMEM);
25746 +
25747 +bottomup:
25748 + /*
25749 + * A failed mmap() very likely causes application failure,
25750 + * so fall back to the bottom-up function here. This scenario
25751 + * can happen with large stack limits and large mmap()
25752 + * allocations.
25753 + */
25754 + return arch_get_unmapped_area(filp, addr0, len, pgoff, flags);
25755 +}
25756 diff --git a/arch/x86/kernel/sys_x86_64.c b/arch/x86/kernel/sys_x86_64.c
25757 index 30277e2..5664a29 100644
25758 --- a/arch/x86/kernel/sys_x86_64.c
25759 +++ b/arch/x86/kernel/sys_x86_64.c
25760 @@ -81,8 +81,8 @@ out:
25761 return error;
25762 }
25763
25764 -static void find_start_end(unsigned long flags, unsigned long *begin,
25765 - unsigned long *end)
25766 +static void find_start_end(struct mm_struct *mm, unsigned long flags,
25767 + unsigned long *begin, unsigned long *end)
25768 {
25769 if (!test_thread_flag(TIF_ADDR32) && (flags & MAP_32BIT)) {
25770 unsigned long new_begin;
25771 @@ -101,7 +101,7 @@ static void find_start_end(unsigned long flags, unsigned long *begin,
25772 *begin = new_begin;
25773 }
25774 } else {
25775 - *begin = current->mm->mmap_legacy_base;
25776 + *begin = mm->mmap_legacy_base;
25777 *end = TASK_SIZE;
25778 }
25779 }
25780 @@ -114,20 +114,24 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
25781 struct vm_area_struct *vma;
25782 struct vm_unmapped_area_info info;
25783 unsigned long begin, end;
25784 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
25785
25786 if (flags & MAP_FIXED)
25787 return addr;
25788
25789 - find_start_end(flags, &begin, &end);
25790 + find_start_end(mm, flags, &begin, &end);
25791
25792 if (len > end)
25793 return -ENOMEM;
25794
25795 +#ifdef CONFIG_PAX_RANDMMAP
25796 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
25797 +#endif
25798 +
25799 if (addr) {
25800 addr = PAGE_ALIGN(addr);
25801 vma = find_vma(mm, addr);
25802 - if (end - len >= addr &&
25803 - (!vma || addr + len <= vma->vm_start))
25804 + if (end - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
25805 return addr;
25806 }
25807
25808 @@ -137,6 +141,7 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
25809 info.high_limit = end;
25810 info.align_mask = filp ? get_align_mask() : 0;
25811 info.align_offset = pgoff << PAGE_SHIFT;
25812 + info.threadstack_offset = offset;
25813 return vm_unmapped_area(&info);
25814 }
25815
25816 @@ -149,6 +154,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
25817 struct mm_struct *mm = current->mm;
25818 unsigned long addr = addr0;
25819 struct vm_unmapped_area_info info;
25820 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
25821
25822 /* requested length too big for entire address space */
25823 if (len > TASK_SIZE)
25824 @@ -161,12 +167,15 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
25825 if (!test_thread_flag(TIF_ADDR32) && (flags & MAP_32BIT))
25826 goto bottomup;
25827
25828 +#ifdef CONFIG_PAX_RANDMMAP
25829 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
25830 +#endif
25831 +
25832 /* requesting a specific address */
25833 if (addr) {
25834 addr = PAGE_ALIGN(addr);
25835 vma = find_vma(mm, addr);
25836 - if (TASK_SIZE - len >= addr &&
25837 - (!vma || addr + len <= vma->vm_start))
25838 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
25839 return addr;
25840 }
25841
25842 @@ -176,6 +185,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
25843 info.high_limit = mm->mmap_base;
25844 info.align_mask = filp ? get_align_mask() : 0;
25845 info.align_offset = pgoff << PAGE_SHIFT;
25846 + info.threadstack_offset = offset;
25847 addr = vm_unmapped_area(&info);
25848 if (!(addr & ~PAGE_MASK))
25849 return addr;
25850 diff --git a/arch/x86/kernel/tboot.c b/arch/x86/kernel/tboot.c
25851 index 91a4496..1730bff 100644
25852 --- a/arch/x86/kernel/tboot.c
25853 +++ b/arch/x86/kernel/tboot.c
25854 @@ -221,7 +221,7 @@ static int tboot_setup_sleep(void)
25855
25856 void tboot_shutdown(u32 shutdown_type)
25857 {
25858 - void (*shutdown)(void);
25859 + void (* __noreturn shutdown)(void);
25860
25861 if (!tboot_enabled())
25862 return;
25863 @@ -243,7 +243,7 @@ void tboot_shutdown(u32 shutdown_type)
25864
25865 switch_to_tboot_pt();
25866
25867 - shutdown = (void(*)(void))(unsigned long)tboot->shutdown_entry;
25868 + shutdown = (void *)tboot->shutdown_entry;
25869 shutdown();
25870
25871 /* should not reach here */
25872 @@ -310,7 +310,7 @@ static int tboot_extended_sleep(u8 sleep_state, u32 val_a, u32 val_b)
25873 return -ENODEV;
25874 }
25875
25876 -static atomic_t ap_wfs_count;
25877 +static atomic_unchecked_t ap_wfs_count;
25878
25879 static int tboot_wait_for_aps(int num_aps)
25880 {
25881 @@ -334,9 +334,9 @@ static int tboot_cpu_callback(struct notifier_block *nfb, unsigned long action,
25882 {
25883 switch (action) {
25884 case CPU_DYING:
25885 - atomic_inc(&ap_wfs_count);
25886 + atomic_inc_unchecked(&ap_wfs_count);
25887 if (num_online_cpus() == 1)
25888 - if (tboot_wait_for_aps(atomic_read(&ap_wfs_count)))
25889 + if (tboot_wait_for_aps(atomic_read_unchecked(&ap_wfs_count)))
25890 return NOTIFY_BAD;
25891 break;
25892 }
25893 @@ -422,7 +422,7 @@ static __init int tboot_late_init(void)
25894
25895 tboot_create_trampoline();
25896
25897 - atomic_set(&ap_wfs_count, 0);
25898 + atomic_set_unchecked(&ap_wfs_count, 0);
25899 register_hotcpu_notifier(&tboot_cpu_notifier);
25900
25901 #ifdef CONFIG_DEBUG_FS
25902 diff --git a/arch/x86/kernel/time.c b/arch/x86/kernel/time.c
25903 index 24d3c91..d06b473 100644
25904 --- a/arch/x86/kernel/time.c
25905 +++ b/arch/x86/kernel/time.c
25906 @@ -30,9 +30,9 @@ unsigned long profile_pc(struct pt_regs *regs)
25907 {
25908 unsigned long pc = instruction_pointer(regs);
25909
25910 - if (!user_mode_vm(regs) && in_lock_functions(pc)) {
25911 + if (!user_mode(regs) && in_lock_functions(pc)) {
25912 #ifdef CONFIG_FRAME_POINTER
25913 - return *(unsigned long *)(regs->bp + sizeof(long));
25914 + return ktla_ktva(*(unsigned long *)(regs->bp + sizeof(long)));
25915 #else
25916 unsigned long *sp =
25917 (unsigned long *)kernel_stack_pointer(regs);
25918 @@ -41,11 +41,17 @@ unsigned long profile_pc(struct pt_regs *regs)
25919 * or above a saved flags. Eflags has bits 22-31 zero,
25920 * kernel addresses don't.
25921 */
25922 +
25923 +#ifdef CONFIG_PAX_KERNEXEC
25924 + return ktla_ktva(sp[0]);
25925 +#else
25926 if (sp[0] >> 22)
25927 return sp[0];
25928 if (sp[1] >> 22)
25929 return sp[1];
25930 #endif
25931 +
25932 +#endif
25933 }
25934 return pc;
25935 }
25936 diff --git a/arch/x86/kernel/tls.c b/arch/x86/kernel/tls.c
25937 index f7fec09..9991981 100644
25938 --- a/arch/x86/kernel/tls.c
25939 +++ b/arch/x86/kernel/tls.c
25940 @@ -84,6 +84,11 @@ int do_set_thread_area(struct task_struct *p, int idx,
25941 if (idx < GDT_ENTRY_TLS_MIN || idx > GDT_ENTRY_TLS_MAX)
25942 return -EINVAL;
25943
25944 +#ifdef CONFIG_PAX_SEGMEXEC
25945 + if ((p->mm->pax_flags & MF_PAX_SEGMEXEC) && (info.contents & MODIFY_LDT_CONTENTS_CODE))
25946 + return -EINVAL;
25947 +#endif
25948 +
25949 set_tls_desc(p, idx, &info, 1);
25950
25951 return 0;
25952 @@ -200,7 +205,7 @@ int regset_tls_set(struct task_struct *target, const struct user_regset *regset,
25953
25954 if (kbuf)
25955 info = kbuf;
25956 - else if (__copy_from_user(infobuf, ubuf, count))
25957 + else if (count > sizeof infobuf || __copy_from_user(infobuf, ubuf, count))
25958 return -EFAULT;
25959 else
25960 info = infobuf;
25961 diff --git a/arch/x86/kernel/tracepoint.c b/arch/x86/kernel/tracepoint.c
25962 index 1c113db..287b42e 100644
25963 --- a/arch/x86/kernel/tracepoint.c
25964 +++ b/arch/x86/kernel/tracepoint.c
25965 @@ -9,11 +9,11 @@
25966 #include <linux/atomic.h>
25967
25968 atomic_t trace_idt_ctr = ATOMIC_INIT(0);
25969 -struct desc_ptr trace_idt_descr = { NR_VECTORS * 16 - 1,
25970 +const struct desc_ptr trace_idt_descr = { NR_VECTORS * 16 - 1,
25971 (unsigned long) trace_idt_table };
25972
25973 /* No need to be aligned, but done to keep all IDTs defined the same way. */
25974 -gate_desc trace_idt_table[NR_VECTORS] __page_aligned_bss;
25975 +gate_desc trace_idt_table[NR_VECTORS] __page_aligned_rodata;
25976
25977 static int trace_irq_vector_refcount;
25978 static DEFINE_MUTEX(irq_vector_mutex);
25979 diff --git a/arch/x86/kernel/traps.c b/arch/x86/kernel/traps.c
25980 index 8c8093b..c93f581 100644
25981 --- a/arch/x86/kernel/traps.c
25982 +++ b/arch/x86/kernel/traps.c
25983 @@ -66,7 +66,7 @@
25984 #include <asm/proto.h>
25985
25986 /* No need to be aligned, but done to keep all IDTs defined the same way. */
25987 -gate_desc debug_idt_table[NR_VECTORS] __page_aligned_bss;
25988 +gate_desc debug_idt_table[NR_VECTORS] __page_aligned_rodata;
25989 #else
25990 #include <asm/processor-flags.h>
25991 #include <asm/setup.h>
25992 @@ -75,7 +75,7 @@ asmlinkage int system_call(void);
25993 #endif
25994
25995 /* Must be page-aligned because the real IDT is used in a fixmap. */
25996 -gate_desc idt_table[NR_VECTORS] __page_aligned_bss;
25997 +gate_desc idt_table[NR_VECTORS] __page_aligned_rodata;
25998
25999 DECLARE_BITMAP(used_vectors, NR_VECTORS);
26000 EXPORT_SYMBOL_GPL(used_vectors);
26001 @@ -107,11 +107,11 @@ static inline void preempt_conditional_cli(struct pt_regs *regs)
26002 }
26003
26004 static int __kprobes
26005 -do_trap_no_signal(struct task_struct *tsk, int trapnr, char *str,
26006 +do_trap_no_signal(struct task_struct *tsk, int trapnr, const char *str,
26007 struct pt_regs *regs, long error_code)
26008 {
26009 #ifdef CONFIG_X86_32
26010 - if (regs->flags & X86_VM_MASK) {
26011 + if (v8086_mode(regs)) {
26012 /*
26013 * Traps 0, 1, 3, 4, and 5 should be forwarded to vm86.
26014 * On nmi (interrupt 2), do_trap should not be called.
26015 @@ -124,12 +124,24 @@ do_trap_no_signal(struct task_struct *tsk, int trapnr, char *str,
26016 return -1;
26017 }
26018 #endif
26019 - if (!user_mode(regs)) {
26020 + if (!user_mode_novm(regs)) {
26021 if (!fixup_exception(regs)) {
26022 tsk->thread.error_code = error_code;
26023 tsk->thread.trap_nr = trapnr;
26024 +
26025 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
26026 + if (trapnr == 12 && ((regs->cs & 0xFFFF) == __KERNEL_CS || (regs->cs & 0xFFFF) == __KERNEXEC_KERNEL_CS))
26027 + str = "PAX: suspicious stack segment fault";
26028 +#endif
26029 +
26030 die(str, regs, error_code);
26031 }
26032 +
26033 +#ifdef CONFIG_PAX_REFCOUNT
26034 + if (trapnr == 4)
26035 + pax_report_refcount_overflow(regs);
26036 +#endif
26037 +
26038 return 0;
26039 }
26040
26041 @@ -137,7 +149,7 @@ do_trap_no_signal(struct task_struct *tsk, int trapnr, char *str,
26042 }
26043
26044 static void __kprobes
26045 -do_trap(int trapnr, int signr, char *str, struct pt_regs *regs,
26046 +do_trap(int trapnr, int signr, const char *str, struct pt_regs *regs,
26047 long error_code, siginfo_t *info)
26048 {
26049 struct task_struct *tsk = current;
26050 @@ -161,7 +173,7 @@ do_trap(int trapnr, int signr, char *str, struct pt_regs *regs,
26051 if (show_unhandled_signals && unhandled_signal(tsk, signr) &&
26052 printk_ratelimit()) {
26053 pr_info("%s[%d] trap %s ip:%lx sp:%lx error:%lx",
26054 - tsk->comm, tsk->pid, str,
26055 + tsk->comm, task_pid_nr(tsk), str,
26056 regs->ip, regs->sp, error_code);
26057 print_vma_addr(" in ", regs->ip);
26058 pr_cont("\n");
26059 @@ -277,7 +289,7 @@ do_general_protection(struct pt_regs *regs, long error_code)
26060 conditional_sti(regs);
26061
26062 #ifdef CONFIG_X86_32
26063 - if (regs->flags & X86_VM_MASK) {
26064 + if (v8086_mode(regs)) {
26065 local_irq_enable();
26066 handle_vm86_fault((struct kernel_vm86_regs *) regs, error_code);
26067 goto exit;
26068 @@ -285,18 +297,42 @@ do_general_protection(struct pt_regs *regs, long error_code)
26069 #endif
26070
26071 tsk = current;
26072 - if (!user_mode(regs)) {
26073 + if (!user_mode_novm(regs)) {
26074 if (fixup_exception(regs))
26075 goto exit;
26076
26077 tsk->thread.error_code = error_code;
26078 tsk->thread.trap_nr = X86_TRAP_GP;
26079 if (notify_die(DIE_GPF, "general protection fault", regs, error_code,
26080 - X86_TRAP_GP, SIGSEGV) != NOTIFY_STOP)
26081 + X86_TRAP_GP, SIGSEGV) != NOTIFY_STOP) {
26082 +
26083 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
26084 + if ((regs->cs & 0xFFFF) == __KERNEL_CS || (regs->cs & 0xFFFF) == __KERNEXEC_KERNEL_CS)
26085 + die("PAX: suspicious general protection fault", regs, error_code);
26086 + else
26087 +#endif
26088 +
26089 die("general protection fault", regs, error_code);
26090 + }
26091 goto exit;
26092 }
26093
26094 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_PAGEEXEC)
26095 + if (!(__supported_pte_mask & _PAGE_NX) && tsk->mm && (tsk->mm->pax_flags & MF_PAX_PAGEEXEC)) {
26096 + struct mm_struct *mm = tsk->mm;
26097 + unsigned long limit;
26098 +
26099 + down_write(&mm->mmap_sem);
26100 + limit = mm->context.user_cs_limit;
26101 + if (limit < TASK_SIZE) {
26102 + track_exec_limit(mm, limit, TASK_SIZE, VM_EXEC);
26103 + up_write(&mm->mmap_sem);
26104 + return;
26105 + }
26106 + up_write(&mm->mmap_sem);
26107 + }
26108 +#endif
26109 +
26110 tsk->thread.error_code = error_code;
26111 tsk->thread.trap_nr = X86_TRAP_GP;
26112
26113 @@ -457,7 +493,7 @@ dotraplinkage void __kprobes do_debug(struct pt_regs *regs, long error_code)
26114 /* It's safe to allow irq's after DR6 has been saved */
26115 preempt_conditional_sti(regs);
26116
26117 - if (regs->flags & X86_VM_MASK) {
26118 + if (v8086_mode(regs)) {
26119 handle_vm86_trap((struct kernel_vm86_regs *) regs, error_code,
26120 X86_TRAP_DB);
26121 preempt_conditional_cli(regs);
26122 @@ -472,7 +508,7 @@ dotraplinkage void __kprobes do_debug(struct pt_regs *regs, long error_code)
26123 * We already checked v86 mode above, so we can check for kernel mode
26124 * by just checking the CPL of CS.
26125 */
26126 - if ((dr6 & DR_STEP) && !user_mode(regs)) {
26127 + if ((dr6 & DR_STEP) && !user_mode_novm(regs)) {
26128 tsk->thread.debugreg6 &= ~DR_STEP;
26129 set_tsk_thread_flag(tsk, TIF_SINGLESTEP);
26130 regs->flags &= ~X86_EFLAGS_TF;
26131 @@ -504,7 +540,7 @@ void math_error(struct pt_regs *regs, int error_code, int trapnr)
26132 return;
26133 conditional_sti(regs);
26134
26135 - if (!user_mode_vm(regs))
26136 + if (!user_mode(regs))
26137 {
26138 if (!fixup_exception(regs)) {
26139 task->thread.error_code = error_code;
26140 diff --git a/arch/x86/kernel/uprobes.c b/arch/x86/kernel/uprobes.c
26141 index 2ed8459..7cf329f 100644
26142 --- a/arch/x86/kernel/uprobes.c
26143 +++ b/arch/x86/kernel/uprobes.c
26144 @@ -629,7 +629,7 @@ int arch_uprobe_exception_notify(struct notifier_block *self, unsigned long val,
26145 int ret = NOTIFY_DONE;
26146
26147 /* We are only interested in userspace traps */
26148 - if (regs && !user_mode_vm(regs))
26149 + if (regs && !user_mode(regs))
26150 return NOTIFY_DONE;
26151
26152 switch (val) {
26153 @@ -719,7 +719,7 @@ arch_uretprobe_hijack_return_addr(unsigned long trampoline_vaddr, struct pt_regs
26154
26155 if (ncopied != rasize) {
26156 pr_err("uprobe: return address clobbered: pid=%d, %%sp=%#lx, "
26157 - "%%ip=%#lx\n", current->pid, regs->sp, regs->ip);
26158 + "%%ip=%#lx\n", task_pid_nr(current), regs->sp, regs->ip);
26159
26160 force_sig_info(SIGSEGV, SEND_SIG_FORCED, current);
26161 }
26162 diff --git a/arch/x86/kernel/verify_cpu.S b/arch/x86/kernel/verify_cpu.S
26163 index b9242ba..50c5edd 100644
26164 --- a/arch/x86/kernel/verify_cpu.S
26165 +++ b/arch/x86/kernel/verify_cpu.S
26166 @@ -20,6 +20,7 @@
26167 * arch/x86/boot/compressed/head_64.S: Boot cpu verification
26168 * arch/x86/kernel/trampoline_64.S: secondary processor verification
26169 * arch/x86/kernel/head_32.S: processor startup
26170 + * arch/x86/kernel/acpi/realmode/wakeup.S: 32bit processor resume
26171 *
26172 * verify_cpu, returns the status of longmode and SSE in register %eax.
26173 * 0: Success 1: Failure
26174 diff --git a/arch/x86/kernel/vm86_32.c b/arch/x86/kernel/vm86_32.c
26175 index e8edcf5..27f9344 100644
26176 --- a/arch/x86/kernel/vm86_32.c
26177 +++ b/arch/x86/kernel/vm86_32.c
26178 @@ -44,6 +44,7 @@
26179 #include <linux/ptrace.h>
26180 #include <linux/audit.h>
26181 #include <linux/stddef.h>
26182 +#include <linux/grsecurity.h>
26183
26184 #include <asm/uaccess.h>
26185 #include <asm/io.h>
26186 @@ -150,7 +151,7 @@ struct pt_regs *save_v86_state(struct kernel_vm86_regs *regs)
26187 do_exit(SIGSEGV);
26188 }
26189
26190 - tss = &per_cpu(init_tss, get_cpu());
26191 + tss = init_tss + get_cpu();
26192 current->thread.sp0 = current->thread.saved_sp0;
26193 current->thread.sysenter_cs = __KERNEL_CS;
26194 load_sp0(tss, &current->thread);
26195 @@ -214,6 +215,14 @@ SYSCALL_DEFINE1(vm86old, struct vm86_struct __user *, v86)
26196
26197 if (tsk->thread.saved_sp0)
26198 return -EPERM;
26199 +
26200 +#ifdef CONFIG_GRKERNSEC_VM86
26201 + if (!capable(CAP_SYS_RAWIO)) {
26202 + gr_handle_vm86();
26203 + return -EPERM;
26204 + }
26205 +#endif
26206 +
26207 tmp = copy_vm86_regs_from_user(&info.regs, &v86->regs,
26208 offsetof(struct kernel_vm86_struct, vm86plus) -
26209 sizeof(info.regs));
26210 @@ -238,6 +247,13 @@ SYSCALL_DEFINE2(vm86, unsigned long, cmd, unsigned long, arg)
26211 int tmp;
26212 struct vm86plus_struct __user *v86;
26213
26214 +#ifdef CONFIG_GRKERNSEC_VM86
26215 + if (!capable(CAP_SYS_RAWIO)) {
26216 + gr_handle_vm86();
26217 + return -EPERM;
26218 + }
26219 +#endif
26220 +
26221 tsk = current;
26222 switch (cmd) {
26223 case VM86_REQUEST_IRQ:
26224 @@ -318,7 +334,7 @@ static void do_sys_vm86(struct kernel_vm86_struct *info, struct task_struct *tsk
26225 tsk->thread.saved_fs = info->regs32->fs;
26226 tsk->thread.saved_gs = get_user_gs(info->regs32);
26227
26228 - tss = &per_cpu(init_tss, get_cpu());
26229 + tss = init_tss + get_cpu();
26230 tsk->thread.sp0 = (unsigned long) &info->VM86_TSS_ESP0;
26231 if (cpu_has_sep)
26232 tsk->thread.sysenter_cs = 0;
26233 @@ -525,7 +541,7 @@ static void do_int(struct kernel_vm86_regs *regs, int i,
26234 goto cannot_handle;
26235 if (i == 0x21 && is_revectored(AH(regs), &KVM86->int21_revectored))
26236 goto cannot_handle;
26237 - intr_ptr = (unsigned long __user *) (i << 2);
26238 + intr_ptr = (__force unsigned long __user *) (i << 2);
26239 if (get_user(segoffs, intr_ptr))
26240 goto cannot_handle;
26241 if ((segoffs >> 16) == BIOSSEG)
26242 diff --git a/arch/x86/kernel/vmlinux.lds.S b/arch/x86/kernel/vmlinux.lds.S
26243 index 10c4f30..65408b9 100644
26244 --- a/arch/x86/kernel/vmlinux.lds.S
26245 +++ b/arch/x86/kernel/vmlinux.lds.S
26246 @@ -26,6 +26,13 @@
26247 #include <asm/page_types.h>
26248 #include <asm/cache.h>
26249 #include <asm/boot.h>
26250 +#include <asm/segment.h>
26251 +
26252 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
26253 +#define __KERNEL_TEXT_OFFSET (LOAD_OFFSET + ____LOAD_PHYSICAL_ADDR)
26254 +#else
26255 +#define __KERNEL_TEXT_OFFSET 0
26256 +#endif
26257
26258 #undef i386 /* in case the preprocessor is a 32bit one */
26259
26260 @@ -69,30 +76,43 @@ jiffies_64 = jiffies;
26261
26262 PHDRS {
26263 text PT_LOAD FLAGS(5); /* R_E */
26264 +#ifdef CONFIG_X86_32
26265 + module PT_LOAD FLAGS(5); /* R_E */
26266 +#endif
26267 +#ifdef CONFIG_XEN
26268 + rodata PT_LOAD FLAGS(5); /* R_E */
26269 +#else
26270 + rodata PT_LOAD FLAGS(4); /* R__ */
26271 +#endif
26272 data PT_LOAD FLAGS(6); /* RW_ */
26273 -#ifdef CONFIG_X86_64
26274 + init.begin PT_LOAD FLAGS(6); /* RW_ */
26275 #ifdef CONFIG_SMP
26276 percpu PT_LOAD FLAGS(6); /* RW_ */
26277 #endif
26278 + text.init PT_LOAD FLAGS(5); /* R_E */
26279 + text.exit PT_LOAD FLAGS(5); /* R_E */
26280 init PT_LOAD FLAGS(7); /* RWE */
26281 -#endif
26282 note PT_NOTE FLAGS(0); /* ___ */
26283 }
26284
26285 SECTIONS
26286 {
26287 #ifdef CONFIG_X86_32
26288 - . = LOAD_OFFSET + LOAD_PHYSICAL_ADDR;
26289 - phys_startup_32 = startup_32 - LOAD_OFFSET;
26290 + . = LOAD_OFFSET + ____LOAD_PHYSICAL_ADDR;
26291 #else
26292 - . = __START_KERNEL;
26293 - phys_startup_64 = startup_64 - LOAD_OFFSET;
26294 + . = __START_KERNEL;
26295 #endif
26296
26297 /* Text and read-only data */
26298 - .text : AT(ADDR(.text) - LOAD_OFFSET) {
26299 - _text = .;
26300 + .text (. - __KERNEL_TEXT_OFFSET): AT(ADDR(.text) - LOAD_OFFSET + __KERNEL_TEXT_OFFSET) {
26301 /* bootstrapping code */
26302 +#ifdef CONFIG_X86_32
26303 + phys_startup_32 = startup_32 - LOAD_OFFSET + __KERNEL_TEXT_OFFSET;
26304 +#else
26305 + phys_startup_64 = startup_64 - LOAD_OFFSET + __KERNEL_TEXT_OFFSET;
26306 +#endif
26307 + __LOAD_PHYSICAL_ADDR = . - LOAD_OFFSET + __KERNEL_TEXT_OFFSET;
26308 + _text = .;
26309 HEAD_TEXT
26310 . = ALIGN(8);
26311 _stext = .;
26312 @@ -104,13 +124,47 @@ SECTIONS
26313 IRQENTRY_TEXT
26314 *(.fixup)
26315 *(.gnu.warning)
26316 - /* End of text section */
26317 - _etext = .;
26318 } :text = 0x9090
26319
26320 - NOTES :text :note
26321 + . += __KERNEL_TEXT_OFFSET;
26322
26323 - EXCEPTION_TABLE(16) :text = 0x9090
26324 +#ifdef CONFIG_X86_32
26325 + . = ALIGN(PAGE_SIZE);
26326 + .module.text : AT(ADDR(.module.text) - LOAD_OFFSET) {
26327 +
26328 +#ifdef CONFIG_PAX_KERNEXEC
26329 + MODULES_EXEC_VADDR = .;
26330 + BYTE(0)
26331 + . += (CONFIG_PAX_KERNEXEC_MODULE_TEXT * 1024 * 1024);
26332 + . = ALIGN(HPAGE_SIZE) - 1;
26333 + MODULES_EXEC_END = .;
26334 +#endif
26335 +
26336 + } :module
26337 +#endif
26338 +
26339 + .text.end : AT(ADDR(.text.end) - LOAD_OFFSET) {
26340 + /* End of text section */
26341 + BYTE(0)
26342 + _etext = . - __KERNEL_TEXT_OFFSET;
26343 + }
26344 +
26345 +#ifdef CONFIG_X86_32
26346 + . = ALIGN(PAGE_SIZE);
26347 + .rodata.page_aligned : AT(ADDR(.rodata.page_aligned) - LOAD_OFFSET) {
26348 + . = ALIGN(PAGE_SIZE);
26349 + *(.empty_zero_page)
26350 + *(.initial_pg_fixmap)
26351 + *(.initial_pg_pmd)
26352 + *(.initial_page_table)
26353 + *(.swapper_pg_dir)
26354 + } :rodata
26355 +#endif
26356 +
26357 + . = ALIGN(PAGE_SIZE);
26358 + NOTES :rodata :note
26359 +
26360 + EXCEPTION_TABLE(16) :rodata
26361
26362 #if defined(CONFIG_DEBUG_RODATA)
26363 /* .text should occupy whole number of pages */
26364 @@ -122,16 +176,20 @@ SECTIONS
26365
26366 /* Data */
26367 .data : AT(ADDR(.data) - LOAD_OFFSET) {
26368 +
26369 +#ifdef CONFIG_PAX_KERNEXEC
26370 + . = ALIGN(HPAGE_SIZE);
26371 +#else
26372 + . = ALIGN(PAGE_SIZE);
26373 +#endif
26374 +
26375 /* Start of data section */
26376 _sdata = .;
26377
26378 /* init_task */
26379 INIT_TASK_DATA(THREAD_SIZE)
26380
26381 -#ifdef CONFIG_X86_32
26382 - /* 32 bit has nosave before _edata */
26383 NOSAVE_DATA
26384 -#endif
26385
26386 PAGE_ALIGNED_DATA(PAGE_SIZE)
26387
26388 @@ -172,12 +230,19 @@ SECTIONS
26389 #endif /* CONFIG_X86_64 */
26390
26391 /* Init code and data - will be freed after init */
26392 - . = ALIGN(PAGE_SIZE);
26393 .init.begin : AT(ADDR(.init.begin) - LOAD_OFFSET) {
26394 + BYTE(0)
26395 +
26396 +#ifdef CONFIG_PAX_KERNEXEC
26397 + . = ALIGN(HPAGE_SIZE);
26398 +#else
26399 + . = ALIGN(PAGE_SIZE);
26400 +#endif
26401 +
26402 __init_begin = .; /* paired with __init_end */
26403 - }
26404 + } :init.begin
26405
26406 -#if defined(CONFIG_X86_64) && defined(CONFIG_SMP)
26407 +#ifdef CONFIG_SMP
26408 /*
26409 * percpu offsets are zero-based on SMP. PERCPU_VADDR() changes the
26410 * output PHDR, so the next output section - .init.text - should
26411 @@ -186,12 +251,27 @@ SECTIONS
26412 PERCPU_VADDR(INTERNODE_CACHE_BYTES, 0, :percpu)
26413 #endif
26414
26415 - INIT_TEXT_SECTION(PAGE_SIZE)
26416 -#ifdef CONFIG_X86_64
26417 - :init
26418 -#endif
26419 + . = ALIGN(PAGE_SIZE);
26420 + init_begin = .;
26421 + .init.text (. - __KERNEL_TEXT_OFFSET): AT(init_begin - LOAD_OFFSET) {
26422 + VMLINUX_SYMBOL(_sinittext) = .;
26423 + INIT_TEXT
26424 + VMLINUX_SYMBOL(_einittext) = .;
26425 + . = ALIGN(PAGE_SIZE);
26426 + } :text.init
26427
26428 - INIT_DATA_SECTION(16)
26429 + /*
26430 + * .exit.text is discard at runtime, not link time, to deal with
26431 + * references from .altinstructions and .eh_frame
26432 + */
26433 + .exit.text : AT(ADDR(.exit.text) - LOAD_OFFSET + __KERNEL_TEXT_OFFSET) {
26434 + EXIT_TEXT
26435 + . = ALIGN(16);
26436 + } :text.exit
26437 + . = init_begin + SIZEOF(.init.text) + SIZEOF(.exit.text);
26438 +
26439 + . = ALIGN(PAGE_SIZE);
26440 + INIT_DATA_SECTION(16) :init
26441
26442 .x86_cpu_dev.init : AT(ADDR(.x86_cpu_dev.init) - LOAD_OFFSET) {
26443 __x86_cpu_dev_start = .;
26444 @@ -253,19 +333,12 @@ SECTIONS
26445 }
26446
26447 . = ALIGN(8);
26448 - /*
26449 - * .exit.text is discard at runtime, not link time, to deal with
26450 - * references from .altinstructions and .eh_frame
26451 - */
26452 - .exit.text : AT(ADDR(.exit.text) - LOAD_OFFSET) {
26453 - EXIT_TEXT
26454 - }
26455
26456 .exit.data : AT(ADDR(.exit.data) - LOAD_OFFSET) {
26457 EXIT_DATA
26458 }
26459
26460 -#if !defined(CONFIG_X86_64) || !defined(CONFIG_SMP)
26461 +#ifndef CONFIG_SMP
26462 PERCPU_SECTION(INTERNODE_CACHE_BYTES)
26463 #endif
26464
26465 @@ -284,16 +357,10 @@ SECTIONS
26466 .smp_locks : AT(ADDR(.smp_locks) - LOAD_OFFSET) {
26467 __smp_locks = .;
26468 *(.smp_locks)
26469 - . = ALIGN(PAGE_SIZE);
26470 __smp_locks_end = .;
26471 + . = ALIGN(PAGE_SIZE);
26472 }
26473
26474 -#ifdef CONFIG_X86_64
26475 - .data_nosave : AT(ADDR(.data_nosave) - LOAD_OFFSET) {
26476 - NOSAVE_DATA
26477 - }
26478 -#endif
26479 -
26480 /* BSS */
26481 . = ALIGN(PAGE_SIZE);
26482 .bss : AT(ADDR(.bss) - LOAD_OFFSET) {
26483 @@ -309,6 +376,7 @@ SECTIONS
26484 __brk_base = .;
26485 . += 64 * 1024; /* 64k alignment slop space */
26486 *(.brk_reservation) /* areas brk users have reserved */
26487 + . = ALIGN(HPAGE_SIZE);
26488 __brk_limit = .;
26489 }
26490
26491 @@ -335,13 +403,12 @@ SECTIONS
26492 * for the boot processor.
26493 */
26494 #define INIT_PER_CPU(x) init_per_cpu__##x = x + __per_cpu_load
26495 -INIT_PER_CPU(gdt_page);
26496 INIT_PER_CPU(irq_stack_union);
26497
26498 /*
26499 * Build-time check on the image size:
26500 */
26501 -. = ASSERT((_end - _text <= KERNEL_IMAGE_SIZE),
26502 +. = ASSERT((_end - _text - __KERNEL_TEXT_OFFSET <= KERNEL_IMAGE_SIZE),
26503 "kernel image bigger than KERNEL_IMAGE_SIZE");
26504
26505 #ifdef CONFIG_SMP
26506 diff --git a/arch/x86/kernel/vsyscall_64.c b/arch/x86/kernel/vsyscall_64.c
26507 index 1f96f93..d5c8f7a 100644
26508 --- a/arch/x86/kernel/vsyscall_64.c
26509 +++ b/arch/x86/kernel/vsyscall_64.c
26510 @@ -56,15 +56,13 @@
26511 DEFINE_VVAR(int, vgetcpu_mode);
26512 DEFINE_VVAR(struct vsyscall_gtod_data, vsyscall_gtod_data);
26513
26514 -static enum { EMULATE, NATIVE, NONE } vsyscall_mode = EMULATE;
26515 +static enum { EMULATE, NONE } vsyscall_mode = EMULATE;
26516
26517 static int __init vsyscall_setup(char *str)
26518 {
26519 if (str) {
26520 if (!strcmp("emulate", str))
26521 vsyscall_mode = EMULATE;
26522 - else if (!strcmp("native", str))
26523 - vsyscall_mode = NATIVE;
26524 else if (!strcmp("none", str))
26525 vsyscall_mode = NONE;
26526 else
26527 @@ -323,8 +321,7 @@ do_ret:
26528 return true;
26529
26530 sigsegv:
26531 - force_sig(SIGSEGV, current);
26532 - return true;
26533 + do_group_exit(SIGKILL);
26534 }
26535
26536 /*
26537 @@ -377,10 +374,7 @@ void __init map_vsyscall(void)
26538 extern char __vvar_page;
26539 unsigned long physaddr_vvar_page = __pa_symbol(&__vvar_page);
26540
26541 - __set_fixmap(VSYSCALL_FIRST_PAGE, physaddr_vsyscall,
26542 - vsyscall_mode == NATIVE
26543 - ? PAGE_KERNEL_VSYSCALL
26544 - : PAGE_KERNEL_VVAR);
26545 + __set_fixmap(VSYSCALL_FIRST_PAGE, physaddr_vsyscall, PAGE_KERNEL_VVAR);
26546 BUILD_BUG_ON((unsigned long)__fix_to_virt(VSYSCALL_FIRST_PAGE) !=
26547 (unsigned long)VSYSCALL_START);
26548
26549 diff --git a/arch/x86/kernel/x8664_ksyms_64.c b/arch/x86/kernel/x8664_ksyms_64.c
26550 index b014d94..e775258 100644
26551 --- a/arch/x86/kernel/x8664_ksyms_64.c
26552 +++ b/arch/x86/kernel/x8664_ksyms_64.c
26553 @@ -34,8 +34,6 @@ EXPORT_SYMBOL(copy_user_generic_string);
26554 EXPORT_SYMBOL(copy_user_generic_unrolled);
26555 EXPORT_SYMBOL(copy_user_enhanced_fast_string);
26556 EXPORT_SYMBOL(__copy_user_nocache);
26557 -EXPORT_SYMBOL(_copy_from_user);
26558 -EXPORT_SYMBOL(_copy_to_user);
26559
26560 EXPORT_SYMBOL(copy_page);
26561 EXPORT_SYMBOL(clear_page);
26562 @@ -66,3 +64,7 @@ EXPORT_SYMBOL(empty_zero_page);
26563 #ifndef CONFIG_PARAVIRT
26564 EXPORT_SYMBOL(native_load_gs_index);
26565 #endif
26566 +
26567 +#ifdef CONFIG_PAX_PER_CPU_PGD
26568 +EXPORT_SYMBOL(cpu_pgd);
26569 +#endif
26570 diff --git a/arch/x86/kernel/x86_init.c b/arch/x86/kernel/x86_init.c
26571 index 8ce0072..431a0e7 100644
26572 --- a/arch/x86/kernel/x86_init.c
26573 +++ b/arch/x86/kernel/x86_init.c
26574 @@ -93,7 +93,7 @@ struct x86_cpuinit_ops x86_cpuinit = {
26575 static void default_nmi_init(void) { };
26576 static int default_i8042_detect(void) { return 1; };
26577
26578 -struct x86_platform_ops x86_platform = {
26579 +struct x86_platform_ops x86_platform __read_only = {
26580 .calibrate_tsc = native_calibrate_tsc,
26581 .get_wallclock = mach_get_cmos_time,
26582 .set_wallclock = mach_set_rtc_mmss,
26583 @@ -109,7 +109,7 @@ struct x86_platform_ops x86_platform = {
26584 EXPORT_SYMBOL_GPL(x86_platform);
26585
26586 #if defined(CONFIG_PCI_MSI)
26587 -struct x86_msi_ops x86_msi = {
26588 +struct x86_msi_ops x86_msi __read_only = {
26589 .setup_msi_irqs = native_setup_msi_irqs,
26590 .compose_msi_msg = native_compose_msi_msg,
26591 .teardown_msi_irq = native_teardown_msi_irq,
26592 @@ -140,7 +140,7 @@ void arch_restore_msi_irqs(struct pci_dev *dev, int irq)
26593 }
26594 #endif
26595
26596 -struct x86_io_apic_ops x86_io_apic_ops = {
26597 +struct x86_io_apic_ops x86_io_apic_ops __read_only = {
26598 .init = native_io_apic_init_mappings,
26599 .read = native_io_apic_read,
26600 .write = native_io_apic_write,
26601 diff --git a/arch/x86/kernel/xsave.c b/arch/x86/kernel/xsave.c
26602 index 422fd82..c3687ca 100644
26603 --- a/arch/x86/kernel/xsave.c
26604 +++ b/arch/x86/kernel/xsave.c
26605 @@ -199,6 +199,7 @@ static inline int save_user_xstate(struct xsave_struct __user *buf)
26606 {
26607 int err;
26608
26609 + buf = (struct xsave_struct __user *)____m(buf);
26610 if (use_xsave())
26611 err = xsave_user(buf);
26612 else if (use_fxsr())
26613 @@ -311,6 +312,7 @@ sanitize_restored_xstate(struct task_struct *tsk,
26614 */
26615 static inline int restore_user_xstate(void __user *buf, u64 xbv, int fx_only)
26616 {
26617 + buf = (void __user *)____m(buf);
26618 if (use_xsave()) {
26619 if ((unsigned long)buf % 64 || fx_only) {
26620 u64 init_bv = pcntxt_mask & ~XSTATE_FPSSE;
26621 diff --git a/arch/x86/kvm/cpuid.c b/arch/x86/kvm/cpuid.c
26622 index b110fe6..d9c19f2 100644
26623 --- a/arch/x86/kvm/cpuid.c
26624 +++ b/arch/x86/kvm/cpuid.c
26625 @@ -124,15 +124,20 @@ int kvm_vcpu_ioctl_set_cpuid2(struct kvm_vcpu *vcpu,
26626 struct kvm_cpuid2 *cpuid,
26627 struct kvm_cpuid_entry2 __user *entries)
26628 {
26629 - int r;
26630 + int r, i;
26631
26632 r = -E2BIG;
26633 if (cpuid->nent > KVM_MAX_CPUID_ENTRIES)
26634 goto out;
26635 r = -EFAULT;
26636 - if (copy_from_user(&vcpu->arch.cpuid_entries, entries,
26637 - cpuid->nent * sizeof(struct kvm_cpuid_entry2)))
26638 + if (!access_ok(VERIFY_READ, entries, cpuid->nent * sizeof(struct kvm_cpuid_entry2)))
26639 goto out;
26640 + for (i = 0; i < cpuid->nent; ++i) {
26641 + struct kvm_cpuid_entry2 cpuid_entry;
26642 + if (__copy_from_user(&cpuid_entry, entries + i, sizeof(cpuid_entry)))
26643 + goto out;
26644 + vcpu->arch.cpuid_entries[i] = cpuid_entry;
26645 + }
26646 vcpu->arch.cpuid_nent = cpuid->nent;
26647 kvm_apic_set_version(vcpu);
26648 kvm_x86_ops->cpuid_update(vcpu);
26649 @@ -147,15 +152,19 @@ int kvm_vcpu_ioctl_get_cpuid2(struct kvm_vcpu *vcpu,
26650 struct kvm_cpuid2 *cpuid,
26651 struct kvm_cpuid_entry2 __user *entries)
26652 {
26653 - int r;
26654 + int r, i;
26655
26656 r = -E2BIG;
26657 if (cpuid->nent < vcpu->arch.cpuid_nent)
26658 goto out;
26659 r = -EFAULT;
26660 - if (copy_to_user(entries, &vcpu->arch.cpuid_entries,
26661 - vcpu->arch.cpuid_nent * sizeof(struct kvm_cpuid_entry2)))
26662 + if (!access_ok(VERIFY_WRITE, entries, vcpu->arch.cpuid_nent * sizeof(struct kvm_cpuid_entry2)))
26663 goto out;
26664 + for (i = 0; i < vcpu->arch.cpuid_nent; ++i) {
26665 + struct kvm_cpuid_entry2 cpuid_entry = vcpu->arch.cpuid_entries[i];
26666 + if (__copy_to_user(entries + i, &cpuid_entry, sizeof(cpuid_entry)))
26667 + goto out;
26668 + }
26669 return 0;
26670
26671 out:
26672 diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c
26673 index 5439117..d08f3d4 100644
26674 --- a/arch/x86/kvm/lapic.c
26675 +++ b/arch/x86/kvm/lapic.c
26676 @@ -55,7 +55,7 @@
26677 #define APIC_BUS_CYCLE_NS 1
26678
26679 /* #define apic_debug(fmt,arg...) printk(KERN_WARNING fmt,##arg) */
26680 -#define apic_debug(fmt, arg...)
26681 +#define apic_debug(fmt, arg...) do {} while (0)
26682
26683 #define APIC_LVT_NUM 6
26684 /* 14 is the version for Xeon and Pentium 8.4.8*/
26685 diff --git a/arch/x86/kvm/paging_tmpl.h b/arch/x86/kvm/paging_tmpl.h
26686 index ad75d77..a679d32 100644
26687 --- a/arch/x86/kvm/paging_tmpl.h
26688 +++ b/arch/x86/kvm/paging_tmpl.h
26689 @@ -331,7 +331,7 @@ retry_walk:
26690 if (unlikely(kvm_is_error_hva(host_addr)))
26691 goto error;
26692
26693 - ptep_user = (pt_element_t __user *)((void *)host_addr + offset);
26694 + ptep_user = (pt_element_t __force_user *)((void *)host_addr + offset);
26695 if (unlikely(__copy_from_user(&pte, ptep_user, sizeof(pte))))
26696 goto error;
26697 walker->ptep_user[walker->level - 1] = ptep_user;
26698 diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c
26699 index c0bc803..6837a50 100644
26700 --- a/arch/x86/kvm/svm.c
26701 +++ b/arch/x86/kvm/svm.c
26702 @@ -3501,7 +3501,11 @@ static void reload_tss(struct kvm_vcpu *vcpu)
26703 int cpu = raw_smp_processor_id();
26704
26705 struct svm_cpu_data *sd = per_cpu(svm_data, cpu);
26706 +
26707 + pax_open_kernel();
26708 sd->tss_desc->type = 9; /* available 32/64-bit TSS */
26709 + pax_close_kernel();
26710 +
26711 load_TR_desc();
26712 }
26713
26714 @@ -3902,6 +3906,10 @@ static void svm_vcpu_run(struct kvm_vcpu *vcpu)
26715 #endif
26716 #endif
26717
26718 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_MEMORY_UDEREF)
26719 + __set_fs(current_thread_info()->addr_limit);
26720 +#endif
26721 +
26722 reload_tss(vcpu);
26723
26724 local_irq_disable();
26725 diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
26726 index 2b2fce1..da76be4 100644
26727 --- a/arch/x86/kvm/vmx.c
26728 +++ b/arch/x86/kvm/vmx.c
26729 @@ -1316,12 +1316,12 @@ static void vmcs_write64(unsigned long field, u64 value)
26730 #endif
26731 }
26732
26733 -static void vmcs_clear_bits(unsigned long field, u32 mask)
26734 +static void vmcs_clear_bits(unsigned long field, unsigned long mask)
26735 {
26736 vmcs_writel(field, vmcs_readl(field) & ~mask);
26737 }
26738
26739 -static void vmcs_set_bits(unsigned long field, u32 mask)
26740 +static void vmcs_set_bits(unsigned long field, unsigned long mask)
26741 {
26742 vmcs_writel(field, vmcs_readl(field) | mask);
26743 }
26744 @@ -1522,7 +1522,11 @@ static void reload_tss(void)
26745 struct desc_struct *descs;
26746
26747 descs = (void *)gdt->address;
26748 +
26749 + pax_open_kernel();
26750 descs[GDT_ENTRY_TSS].type = 9; /* available TSS */
26751 + pax_close_kernel();
26752 +
26753 load_TR_desc();
26754 }
26755
26756 @@ -1746,6 +1750,10 @@ static void vmx_vcpu_load(struct kvm_vcpu *vcpu, int cpu)
26757 vmcs_writel(HOST_TR_BASE, kvm_read_tr_base()); /* 22.2.4 */
26758 vmcs_writel(HOST_GDTR_BASE, gdt->address); /* 22.2.4 */
26759
26760 +#ifdef CONFIG_PAX_PER_CPU_PGD
26761 + vmcs_writel(HOST_CR3, read_cr3()); /* 22.2.3 FIXME: shadow tables */
26762 +#endif
26763 +
26764 rdmsrl(MSR_IA32_SYSENTER_ESP, sysenter_esp);
26765 vmcs_writel(HOST_IA32_SYSENTER_ESP, sysenter_esp); /* 22.2.3 */
26766 vmx->loaded_vmcs->cpu = cpu;
26767 @@ -2037,7 +2045,7 @@ static void setup_msrs(struct vcpu_vmx *vmx)
26768 * reads and returns guest's timestamp counter "register"
26769 * guest_tsc = host_tsc + tsc_offset -- 21.3
26770 */
26771 -static u64 guest_read_tsc(void)
26772 +static u64 __intentional_overflow(-1) guest_read_tsc(void)
26773 {
26774 u64 host_tsc, tsc_offset;
26775
26776 @@ -2982,8 +2990,11 @@ static __init int hardware_setup(void)
26777 if (!cpu_has_vmx_flexpriority())
26778 flexpriority_enabled = 0;
26779
26780 - if (!cpu_has_vmx_tpr_shadow())
26781 - kvm_x86_ops->update_cr8_intercept = NULL;
26782 + if (!cpu_has_vmx_tpr_shadow()) {
26783 + pax_open_kernel();
26784 + *(void **)&kvm_x86_ops->update_cr8_intercept = NULL;
26785 + pax_close_kernel();
26786 + }
26787
26788 if (enable_ept && !cpu_has_vmx_ept_2m_page())
26789 kvm_disable_largepages();
26790 @@ -2994,13 +3005,15 @@ static __init int hardware_setup(void)
26791 if (!cpu_has_vmx_apicv())
26792 enable_apicv = 0;
26793
26794 + pax_open_kernel();
26795 if (enable_apicv)
26796 - kvm_x86_ops->update_cr8_intercept = NULL;
26797 + *(void **)&kvm_x86_ops->update_cr8_intercept = NULL;
26798 else {
26799 - kvm_x86_ops->hwapic_irr_update = NULL;
26800 - kvm_x86_ops->deliver_posted_interrupt = NULL;
26801 - kvm_x86_ops->sync_pir_to_irr = vmx_sync_pir_to_irr_dummy;
26802 + *(void **)&kvm_x86_ops->hwapic_irr_update = NULL;
26803 + *(void **)&kvm_x86_ops->deliver_posted_interrupt = NULL;
26804 + *(void **)&kvm_x86_ops->sync_pir_to_irr = vmx_sync_pir_to_irr_dummy;
26805 }
26806 + pax_close_kernel();
26807
26808 if (nested)
26809 nested_vmx_setup_ctls_msrs();
26810 @@ -4127,7 +4140,10 @@ static void vmx_set_constant_host_state(struct vcpu_vmx *vmx)
26811
26812 vmcs_writel(HOST_CR0, read_cr0() & ~X86_CR0_TS); /* 22.2.3 */
26813 vmcs_writel(HOST_CR4, read_cr4()); /* 22.2.3, 22.2.5 */
26814 +
26815 +#ifndef CONFIG_PAX_PER_CPU_PGD
26816 vmcs_writel(HOST_CR3, read_cr3()); /* 22.2.3 FIXME: shadow tables */
26817 +#endif
26818
26819 vmcs_write16(HOST_CS_SELECTOR, __KERNEL_CS); /* 22.2.4 */
26820 #ifdef CONFIG_X86_64
26821 @@ -4149,7 +4165,7 @@ static void vmx_set_constant_host_state(struct vcpu_vmx *vmx)
26822 vmcs_writel(HOST_IDTR_BASE, dt.address); /* 22.2.4 */
26823 vmx->host_idt_base = dt.address;
26824
26825 - vmcs_writel(HOST_RIP, vmx_return); /* 22.2.5 */
26826 + vmcs_writel(HOST_RIP, ktla_ktva(vmx_return)); /* 22.2.5 */
26827
26828 rdmsr(MSR_IA32_SYSENTER_CS, low32, high32);
26829 vmcs_write32(HOST_IA32_SYSENTER_CS, low32);
26830 @@ -7191,6 +7207,12 @@ static void __noclone vmx_vcpu_run(struct kvm_vcpu *vcpu)
26831 "jmp 2f \n\t"
26832 "1: " __ex(ASM_VMX_VMRESUME) "\n\t"
26833 "2: "
26834 +
26835 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
26836 + "ljmp %[cs],$3f\n\t"
26837 + "3: "
26838 +#endif
26839 +
26840 /* Save guest registers, load host registers, keep flags */
26841 "mov %0, %c[wordsize](%%" _ASM_SP ") \n\t"
26842 "pop %0 \n\t"
26843 @@ -7243,6 +7265,11 @@ static void __noclone vmx_vcpu_run(struct kvm_vcpu *vcpu)
26844 #endif
26845 [cr2]"i"(offsetof(struct vcpu_vmx, vcpu.arch.cr2)),
26846 [wordsize]"i"(sizeof(ulong))
26847 +
26848 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
26849 + ,[cs]"i"(__KERNEL_CS)
26850 +#endif
26851 +
26852 : "cc", "memory"
26853 #ifdef CONFIG_X86_64
26854 , "rax", "rbx", "rdi", "rsi"
26855 @@ -7256,7 +7283,7 @@ static void __noclone vmx_vcpu_run(struct kvm_vcpu *vcpu)
26856 if (debugctlmsr)
26857 update_debugctlmsr(debugctlmsr);
26858
26859 -#ifndef CONFIG_X86_64
26860 +#ifdef CONFIG_X86_32
26861 /*
26862 * The sysexit path does not restore ds/es, so we must set them to
26863 * a reasonable value ourselves.
26864 @@ -7265,8 +7292,18 @@ static void __noclone vmx_vcpu_run(struct kvm_vcpu *vcpu)
26865 * may be executed in interrupt context, which saves and restore segments
26866 * around it, nullifying its effect.
26867 */
26868 - loadsegment(ds, __USER_DS);
26869 - loadsegment(es, __USER_DS);
26870 + loadsegment(ds, __KERNEL_DS);
26871 + loadsegment(es, __KERNEL_DS);
26872 + loadsegment(ss, __KERNEL_DS);
26873 +
26874 +#ifdef CONFIG_PAX_KERNEXEC
26875 + loadsegment(fs, __KERNEL_PERCPU);
26876 +#endif
26877 +
26878 +#ifdef CONFIG_PAX_MEMORY_UDEREF
26879 + __set_fs(current_thread_info()->addr_limit);
26880 +#endif
26881 +
26882 #endif
26883
26884 vcpu->arch.regs_avail = ~((1 << VCPU_REGS_RIP) | (1 << VCPU_REGS_RSP)
26885 diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
26886 index e5ca72a..83d5177 100644
26887 --- a/arch/x86/kvm/x86.c
26888 +++ b/arch/x86/kvm/x86.c
26889 @@ -1779,8 +1779,8 @@ static int xen_hvm_config(struct kvm_vcpu *vcpu, u64 data)
26890 {
26891 struct kvm *kvm = vcpu->kvm;
26892 int lm = is_long_mode(vcpu);
26893 - u8 *blob_addr = lm ? (u8 *)(long)kvm->arch.xen_hvm_config.blob_addr_64
26894 - : (u8 *)(long)kvm->arch.xen_hvm_config.blob_addr_32;
26895 + u8 __user *blob_addr = lm ? (u8 __user *)(long)kvm->arch.xen_hvm_config.blob_addr_64
26896 + : (u8 __user *)(long)kvm->arch.xen_hvm_config.blob_addr_32;
26897 u8 blob_size = lm ? kvm->arch.xen_hvm_config.blob_size_64
26898 : kvm->arch.xen_hvm_config.blob_size_32;
26899 u32 page_num = data & ~PAGE_MASK;
26900 @@ -2663,6 +2663,8 @@ long kvm_arch_dev_ioctl(struct file *filp,
26901 if (n < msr_list.nmsrs)
26902 goto out;
26903 r = -EFAULT;
26904 + if (num_msrs_to_save > ARRAY_SIZE(msrs_to_save))
26905 + goto out;
26906 if (copy_to_user(user_msr_list->indices, &msrs_to_save,
26907 num_msrs_to_save * sizeof(u32)))
26908 goto out;
26909 @@ -5462,7 +5464,7 @@ static struct notifier_block pvclock_gtod_notifier = {
26910 };
26911 #endif
26912
26913 -int kvm_arch_init(void *opaque)
26914 +int kvm_arch_init(const void *opaque)
26915 {
26916 int r;
26917 struct kvm_x86_ops *ops = opaque;
26918 diff --git a/arch/x86/lguest/boot.c b/arch/x86/lguest/boot.c
26919 index bdf8532..f63c587 100644
26920 --- a/arch/x86/lguest/boot.c
26921 +++ b/arch/x86/lguest/boot.c
26922 @@ -1206,9 +1206,10 @@ static __init int early_put_chars(u32 vtermno, const char *buf, int count)
26923 * Rebooting also tells the Host we're finished, but the RESTART flag tells the
26924 * Launcher to reboot us.
26925 */
26926 -static void lguest_restart(char *reason)
26927 +static __noreturn void lguest_restart(char *reason)
26928 {
26929 hcall(LHCALL_SHUTDOWN, __pa(reason), LGUEST_SHUTDOWN_RESTART, 0, 0);
26930 + BUG();
26931 }
26932
26933 /*G:050
26934 diff --git a/arch/x86/lib/atomic64_386_32.S b/arch/x86/lib/atomic64_386_32.S
26935 index 00933d5..3a64af9 100644
26936 --- a/arch/x86/lib/atomic64_386_32.S
26937 +++ b/arch/x86/lib/atomic64_386_32.S
26938 @@ -48,6 +48,10 @@ BEGIN(read)
26939 movl (v), %eax
26940 movl 4(v), %edx
26941 RET_ENDP
26942 +BEGIN(read_unchecked)
26943 + movl (v), %eax
26944 + movl 4(v), %edx
26945 +RET_ENDP
26946 #undef v
26947
26948 #define v %esi
26949 @@ -55,6 +59,10 @@ BEGIN(set)
26950 movl %ebx, (v)
26951 movl %ecx, 4(v)
26952 RET_ENDP
26953 +BEGIN(set_unchecked)
26954 + movl %ebx, (v)
26955 + movl %ecx, 4(v)
26956 +RET_ENDP
26957 #undef v
26958
26959 #define v %esi
26960 @@ -70,6 +78,20 @@ RET_ENDP
26961 BEGIN(add)
26962 addl %eax, (v)
26963 adcl %edx, 4(v)
26964 +
26965 +#ifdef CONFIG_PAX_REFCOUNT
26966 + jno 0f
26967 + subl %eax, (v)
26968 + sbbl %edx, 4(v)
26969 + int $4
26970 +0:
26971 + _ASM_EXTABLE(0b, 0b)
26972 +#endif
26973 +
26974 +RET_ENDP
26975 +BEGIN(add_unchecked)
26976 + addl %eax, (v)
26977 + adcl %edx, 4(v)
26978 RET_ENDP
26979 #undef v
26980
26981 @@ -77,6 +99,24 @@ RET_ENDP
26982 BEGIN(add_return)
26983 addl (v), %eax
26984 adcl 4(v), %edx
26985 +
26986 +#ifdef CONFIG_PAX_REFCOUNT
26987 + into
26988 +1234:
26989 + _ASM_EXTABLE(1234b, 2f)
26990 +#endif
26991 +
26992 + movl %eax, (v)
26993 + movl %edx, 4(v)
26994 +
26995 +#ifdef CONFIG_PAX_REFCOUNT
26996 +2:
26997 +#endif
26998 +
26999 +RET_ENDP
27000 +BEGIN(add_return_unchecked)
27001 + addl (v), %eax
27002 + adcl 4(v), %edx
27003 movl %eax, (v)
27004 movl %edx, 4(v)
27005 RET_ENDP
27006 @@ -86,6 +126,20 @@ RET_ENDP
27007 BEGIN(sub)
27008 subl %eax, (v)
27009 sbbl %edx, 4(v)
27010 +
27011 +#ifdef CONFIG_PAX_REFCOUNT
27012 + jno 0f
27013 + addl %eax, (v)
27014 + adcl %edx, 4(v)
27015 + int $4
27016 +0:
27017 + _ASM_EXTABLE(0b, 0b)
27018 +#endif
27019 +
27020 +RET_ENDP
27021 +BEGIN(sub_unchecked)
27022 + subl %eax, (v)
27023 + sbbl %edx, 4(v)
27024 RET_ENDP
27025 #undef v
27026
27027 @@ -96,6 +150,27 @@ BEGIN(sub_return)
27028 sbbl $0, %edx
27029 addl (v), %eax
27030 adcl 4(v), %edx
27031 +
27032 +#ifdef CONFIG_PAX_REFCOUNT
27033 + into
27034 +1234:
27035 + _ASM_EXTABLE(1234b, 2f)
27036 +#endif
27037 +
27038 + movl %eax, (v)
27039 + movl %edx, 4(v)
27040 +
27041 +#ifdef CONFIG_PAX_REFCOUNT
27042 +2:
27043 +#endif
27044 +
27045 +RET_ENDP
27046 +BEGIN(sub_return_unchecked)
27047 + negl %edx
27048 + negl %eax
27049 + sbbl $0, %edx
27050 + addl (v), %eax
27051 + adcl 4(v), %edx
27052 movl %eax, (v)
27053 movl %edx, 4(v)
27054 RET_ENDP
27055 @@ -105,6 +180,20 @@ RET_ENDP
27056 BEGIN(inc)
27057 addl $1, (v)
27058 adcl $0, 4(v)
27059 +
27060 +#ifdef CONFIG_PAX_REFCOUNT
27061 + jno 0f
27062 + subl $1, (v)
27063 + sbbl $0, 4(v)
27064 + int $4
27065 +0:
27066 + _ASM_EXTABLE(0b, 0b)
27067 +#endif
27068 +
27069 +RET_ENDP
27070 +BEGIN(inc_unchecked)
27071 + addl $1, (v)
27072 + adcl $0, 4(v)
27073 RET_ENDP
27074 #undef v
27075
27076 @@ -114,6 +203,26 @@ BEGIN(inc_return)
27077 movl 4(v), %edx
27078 addl $1, %eax
27079 adcl $0, %edx
27080 +
27081 +#ifdef CONFIG_PAX_REFCOUNT
27082 + into
27083 +1234:
27084 + _ASM_EXTABLE(1234b, 2f)
27085 +#endif
27086 +
27087 + movl %eax, (v)
27088 + movl %edx, 4(v)
27089 +
27090 +#ifdef CONFIG_PAX_REFCOUNT
27091 +2:
27092 +#endif
27093 +
27094 +RET_ENDP
27095 +BEGIN(inc_return_unchecked)
27096 + movl (v), %eax
27097 + movl 4(v), %edx
27098 + addl $1, %eax
27099 + adcl $0, %edx
27100 movl %eax, (v)
27101 movl %edx, 4(v)
27102 RET_ENDP
27103 @@ -123,6 +232,20 @@ RET_ENDP
27104 BEGIN(dec)
27105 subl $1, (v)
27106 sbbl $0, 4(v)
27107 +
27108 +#ifdef CONFIG_PAX_REFCOUNT
27109 + jno 0f
27110 + addl $1, (v)
27111 + adcl $0, 4(v)
27112 + int $4
27113 +0:
27114 + _ASM_EXTABLE(0b, 0b)
27115 +#endif
27116 +
27117 +RET_ENDP
27118 +BEGIN(dec_unchecked)
27119 + subl $1, (v)
27120 + sbbl $0, 4(v)
27121 RET_ENDP
27122 #undef v
27123
27124 @@ -132,6 +255,26 @@ BEGIN(dec_return)
27125 movl 4(v), %edx
27126 subl $1, %eax
27127 sbbl $0, %edx
27128 +
27129 +#ifdef CONFIG_PAX_REFCOUNT
27130 + into
27131 +1234:
27132 + _ASM_EXTABLE(1234b, 2f)
27133 +#endif
27134 +
27135 + movl %eax, (v)
27136 + movl %edx, 4(v)
27137 +
27138 +#ifdef CONFIG_PAX_REFCOUNT
27139 +2:
27140 +#endif
27141 +
27142 +RET_ENDP
27143 +BEGIN(dec_return_unchecked)
27144 + movl (v), %eax
27145 + movl 4(v), %edx
27146 + subl $1, %eax
27147 + sbbl $0, %edx
27148 movl %eax, (v)
27149 movl %edx, 4(v)
27150 RET_ENDP
27151 @@ -143,6 +286,13 @@ BEGIN(add_unless)
27152 adcl %edx, %edi
27153 addl (v), %eax
27154 adcl 4(v), %edx
27155 +
27156 +#ifdef CONFIG_PAX_REFCOUNT
27157 + into
27158 +1234:
27159 + _ASM_EXTABLE(1234b, 2f)
27160 +#endif
27161 +
27162 cmpl %eax, %ecx
27163 je 3f
27164 1:
27165 @@ -168,6 +318,13 @@ BEGIN(inc_not_zero)
27166 1:
27167 addl $1, %eax
27168 adcl $0, %edx
27169 +
27170 +#ifdef CONFIG_PAX_REFCOUNT
27171 + into
27172 +1234:
27173 + _ASM_EXTABLE(1234b, 2f)
27174 +#endif
27175 +
27176 movl %eax, (v)
27177 movl %edx, 4(v)
27178 movl $1, %eax
27179 @@ -186,6 +343,13 @@ BEGIN(dec_if_positive)
27180 movl 4(v), %edx
27181 subl $1, %eax
27182 sbbl $0, %edx
27183 +
27184 +#ifdef CONFIG_PAX_REFCOUNT
27185 + into
27186 +1234:
27187 + _ASM_EXTABLE(1234b, 1f)
27188 +#endif
27189 +
27190 js 1f
27191 movl %eax, (v)
27192 movl %edx, 4(v)
27193 diff --git a/arch/x86/lib/atomic64_cx8_32.S b/arch/x86/lib/atomic64_cx8_32.S
27194 index f5cc9eb..51fa319 100644
27195 --- a/arch/x86/lib/atomic64_cx8_32.S
27196 +++ b/arch/x86/lib/atomic64_cx8_32.S
27197 @@ -35,10 +35,20 @@ ENTRY(atomic64_read_cx8)
27198 CFI_STARTPROC
27199
27200 read64 %ecx
27201 + pax_force_retaddr
27202 ret
27203 CFI_ENDPROC
27204 ENDPROC(atomic64_read_cx8)
27205
27206 +ENTRY(atomic64_read_unchecked_cx8)
27207 + CFI_STARTPROC
27208 +
27209 + read64 %ecx
27210 + pax_force_retaddr
27211 + ret
27212 + CFI_ENDPROC
27213 +ENDPROC(atomic64_read_unchecked_cx8)
27214 +
27215 ENTRY(atomic64_set_cx8)
27216 CFI_STARTPROC
27217
27218 @@ -48,10 +58,25 @@ ENTRY(atomic64_set_cx8)
27219 cmpxchg8b (%esi)
27220 jne 1b
27221
27222 + pax_force_retaddr
27223 ret
27224 CFI_ENDPROC
27225 ENDPROC(atomic64_set_cx8)
27226
27227 +ENTRY(atomic64_set_unchecked_cx8)
27228 + CFI_STARTPROC
27229 +
27230 +1:
27231 +/* we don't need LOCK_PREFIX since aligned 64-bit writes
27232 + * are atomic on 586 and newer */
27233 + cmpxchg8b (%esi)
27234 + jne 1b
27235 +
27236 + pax_force_retaddr
27237 + ret
27238 + CFI_ENDPROC
27239 +ENDPROC(atomic64_set_unchecked_cx8)
27240 +
27241 ENTRY(atomic64_xchg_cx8)
27242 CFI_STARTPROC
27243
27244 @@ -60,12 +85,13 @@ ENTRY(atomic64_xchg_cx8)
27245 cmpxchg8b (%esi)
27246 jne 1b
27247
27248 + pax_force_retaddr
27249 ret
27250 CFI_ENDPROC
27251 ENDPROC(atomic64_xchg_cx8)
27252
27253 -.macro addsub_return func ins insc
27254 -ENTRY(atomic64_\func\()_return_cx8)
27255 +.macro addsub_return func ins insc unchecked=""
27256 +ENTRY(atomic64_\func\()_return\unchecked\()_cx8)
27257 CFI_STARTPROC
27258 SAVE ebp
27259 SAVE ebx
27260 @@ -82,27 +108,44 @@ ENTRY(atomic64_\func\()_return_cx8)
27261 movl %edx, %ecx
27262 \ins\()l %esi, %ebx
27263 \insc\()l %edi, %ecx
27264 +
27265 +.ifb \unchecked
27266 +#ifdef CONFIG_PAX_REFCOUNT
27267 + into
27268 +2:
27269 + _ASM_EXTABLE(2b, 3f)
27270 +#endif
27271 +.endif
27272 +
27273 LOCK_PREFIX
27274 cmpxchg8b (%ebp)
27275 jne 1b
27276 -
27277 -10:
27278 movl %ebx, %eax
27279 movl %ecx, %edx
27280 +
27281 +.ifb \unchecked
27282 +#ifdef CONFIG_PAX_REFCOUNT
27283 +3:
27284 +#endif
27285 +.endif
27286 +
27287 RESTORE edi
27288 RESTORE esi
27289 RESTORE ebx
27290 RESTORE ebp
27291 + pax_force_retaddr
27292 ret
27293 CFI_ENDPROC
27294 -ENDPROC(atomic64_\func\()_return_cx8)
27295 +ENDPROC(atomic64_\func\()_return\unchecked\()_cx8)
27296 .endm
27297
27298 addsub_return add add adc
27299 addsub_return sub sub sbb
27300 +addsub_return add add adc _unchecked
27301 +addsub_return sub sub sbb _unchecked
27302
27303 -.macro incdec_return func ins insc
27304 -ENTRY(atomic64_\func\()_return_cx8)
27305 +.macro incdec_return func ins insc unchecked=""
27306 +ENTRY(atomic64_\func\()_return\unchecked\()_cx8)
27307 CFI_STARTPROC
27308 SAVE ebx
27309
27310 @@ -112,21 +155,39 @@ ENTRY(atomic64_\func\()_return_cx8)
27311 movl %edx, %ecx
27312 \ins\()l $1, %ebx
27313 \insc\()l $0, %ecx
27314 +
27315 +.ifb \unchecked
27316 +#ifdef CONFIG_PAX_REFCOUNT
27317 + into
27318 +2:
27319 + _ASM_EXTABLE(2b, 3f)
27320 +#endif
27321 +.endif
27322 +
27323 LOCK_PREFIX
27324 cmpxchg8b (%esi)
27325 jne 1b
27326
27327 -10:
27328 movl %ebx, %eax
27329 movl %ecx, %edx
27330 +
27331 +.ifb \unchecked
27332 +#ifdef CONFIG_PAX_REFCOUNT
27333 +3:
27334 +#endif
27335 +.endif
27336 +
27337 RESTORE ebx
27338 + pax_force_retaddr
27339 ret
27340 CFI_ENDPROC
27341 -ENDPROC(atomic64_\func\()_return_cx8)
27342 +ENDPROC(atomic64_\func\()_return\unchecked\()_cx8)
27343 .endm
27344
27345 incdec_return inc add adc
27346 incdec_return dec sub sbb
27347 +incdec_return inc add adc _unchecked
27348 +incdec_return dec sub sbb _unchecked
27349
27350 ENTRY(atomic64_dec_if_positive_cx8)
27351 CFI_STARTPROC
27352 @@ -138,6 +199,13 @@ ENTRY(atomic64_dec_if_positive_cx8)
27353 movl %edx, %ecx
27354 subl $1, %ebx
27355 sbb $0, %ecx
27356 +
27357 +#ifdef CONFIG_PAX_REFCOUNT
27358 + into
27359 +1234:
27360 + _ASM_EXTABLE(1234b, 2f)
27361 +#endif
27362 +
27363 js 2f
27364 LOCK_PREFIX
27365 cmpxchg8b (%esi)
27366 @@ -147,6 +215,7 @@ ENTRY(atomic64_dec_if_positive_cx8)
27367 movl %ebx, %eax
27368 movl %ecx, %edx
27369 RESTORE ebx
27370 + pax_force_retaddr
27371 ret
27372 CFI_ENDPROC
27373 ENDPROC(atomic64_dec_if_positive_cx8)
27374 @@ -171,6 +240,13 @@ ENTRY(atomic64_add_unless_cx8)
27375 movl %edx, %ecx
27376 addl %ebp, %ebx
27377 adcl %edi, %ecx
27378 +
27379 +#ifdef CONFIG_PAX_REFCOUNT
27380 + into
27381 +1234:
27382 + _ASM_EXTABLE(1234b, 3f)
27383 +#endif
27384 +
27385 LOCK_PREFIX
27386 cmpxchg8b (%esi)
27387 jne 1b
27388 @@ -181,6 +257,7 @@ ENTRY(atomic64_add_unless_cx8)
27389 CFI_ADJUST_CFA_OFFSET -8
27390 RESTORE ebx
27391 RESTORE ebp
27392 + pax_force_retaddr
27393 ret
27394 4:
27395 cmpl %edx, 4(%esp)
27396 @@ -203,6 +280,13 @@ ENTRY(atomic64_inc_not_zero_cx8)
27397 xorl %ecx, %ecx
27398 addl $1, %ebx
27399 adcl %edx, %ecx
27400 +
27401 +#ifdef CONFIG_PAX_REFCOUNT
27402 + into
27403 +1234:
27404 + _ASM_EXTABLE(1234b, 3f)
27405 +#endif
27406 +
27407 LOCK_PREFIX
27408 cmpxchg8b (%esi)
27409 jne 1b
27410 @@ -210,6 +294,7 @@ ENTRY(atomic64_inc_not_zero_cx8)
27411 movl $1, %eax
27412 3:
27413 RESTORE ebx
27414 + pax_force_retaddr
27415 ret
27416 CFI_ENDPROC
27417 ENDPROC(atomic64_inc_not_zero_cx8)
27418 diff --git a/arch/x86/lib/checksum_32.S b/arch/x86/lib/checksum_32.S
27419 index e78b8ee..7e173a8 100644
27420 --- a/arch/x86/lib/checksum_32.S
27421 +++ b/arch/x86/lib/checksum_32.S
27422 @@ -29,7 +29,8 @@
27423 #include <asm/dwarf2.h>
27424 #include <asm/errno.h>
27425 #include <asm/asm.h>
27426 -
27427 +#include <asm/segment.h>
27428 +
27429 /*
27430 * computes a partial checksum, e.g. for TCP/UDP fragments
27431 */
27432 @@ -293,9 +294,24 @@ unsigned int csum_partial_copy_generic (const char *src, char *dst,
27433
27434 #define ARGBASE 16
27435 #define FP 12
27436 -
27437 -ENTRY(csum_partial_copy_generic)
27438 +
27439 +ENTRY(csum_partial_copy_generic_to_user)
27440 CFI_STARTPROC
27441 +
27442 +#ifdef CONFIG_PAX_MEMORY_UDEREF
27443 + pushl_cfi %gs
27444 + popl_cfi %es
27445 + jmp csum_partial_copy_generic
27446 +#endif
27447 +
27448 +ENTRY(csum_partial_copy_generic_from_user)
27449 +
27450 +#ifdef CONFIG_PAX_MEMORY_UDEREF
27451 + pushl_cfi %gs
27452 + popl_cfi %ds
27453 +#endif
27454 +
27455 +ENTRY(csum_partial_copy_generic)
27456 subl $4,%esp
27457 CFI_ADJUST_CFA_OFFSET 4
27458 pushl_cfi %edi
27459 @@ -317,7 +333,7 @@ ENTRY(csum_partial_copy_generic)
27460 jmp 4f
27461 SRC(1: movw (%esi), %bx )
27462 addl $2, %esi
27463 -DST( movw %bx, (%edi) )
27464 +DST( movw %bx, %es:(%edi) )
27465 addl $2, %edi
27466 addw %bx, %ax
27467 adcl $0, %eax
27468 @@ -329,30 +345,30 @@ DST( movw %bx, (%edi) )
27469 SRC(1: movl (%esi), %ebx )
27470 SRC( movl 4(%esi), %edx )
27471 adcl %ebx, %eax
27472 -DST( movl %ebx, (%edi) )
27473 +DST( movl %ebx, %es:(%edi) )
27474 adcl %edx, %eax
27475 -DST( movl %edx, 4(%edi) )
27476 +DST( movl %edx, %es:4(%edi) )
27477
27478 SRC( movl 8(%esi), %ebx )
27479 SRC( movl 12(%esi), %edx )
27480 adcl %ebx, %eax
27481 -DST( movl %ebx, 8(%edi) )
27482 +DST( movl %ebx, %es:8(%edi) )
27483 adcl %edx, %eax
27484 -DST( movl %edx, 12(%edi) )
27485 +DST( movl %edx, %es:12(%edi) )
27486
27487 SRC( movl 16(%esi), %ebx )
27488 SRC( movl 20(%esi), %edx )
27489 adcl %ebx, %eax
27490 -DST( movl %ebx, 16(%edi) )
27491 +DST( movl %ebx, %es:16(%edi) )
27492 adcl %edx, %eax
27493 -DST( movl %edx, 20(%edi) )
27494 +DST( movl %edx, %es:20(%edi) )
27495
27496 SRC( movl 24(%esi), %ebx )
27497 SRC( movl 28(%esi), %edx )
27498 adcl %ebx, %eax
27499 -DST( movl %ebx, 24(%edi) )
27500 +DST( movl %ebx, %es:24(%edi) )
27501 adcl %edx, %eax
27502 -DST( movl %edx, 28(%edi) )
27503 +DST( movl %edx, %es:28(%edi) )
27504
27505 lea 32(%esi), %esi
27506 lea 32(%edi), %edi
27507 @@ -366,7 +382,7 @@ DST( movl %edx, 28(%edi) )
27508 shrl $2, %edx # This clears CF
27509 SRC(3: movl (%esi), %ebx )
27510 adcl %ebx, %eax
27511 -DST( movl %ebx, (%edi) )
27512 +DST( movl %ebx, %es:(%edi) )
27513 lea 4(%esi), %esi
27514 lea 4(%edi), %edi
27515 dec %edx
27516 @@ -378,12 +394,12 @@ DST( movl %ebx, (%edi) )
27517 jb 5f
27518 SRC( movw (%esi), %cx )
27519 leal 2(%esi), %esi
27520 -DST( movw %cx, (%edi) )
27521 +DST( movw %cx, %es:(%edi) )
27522 leal 2(%edi), %edi
27523 je 6f
27524 shll $16,%ecx
27525 SRC(5: movb (%esi), %cl )
27526 -DST( movb %cl, (%edi) )
27527 +DST( movb %cl, %es:(%edi) )
27528 6: addl %ecx, %eax
27529 adcl $0, %eax
27530 7:
27531 @@ -394,7 +410,7 @@ DST( movb %cl, (%edi) )
27532
27533 6001:
27534 movl ARGBASE+20(%esp), %ebx # src_err_ptr
27535 - movl $-EFAULT, (%ebx)
27536 + movl $-EFAULT, %ss:(%ebx)
27537
27538 # zero the complete destination - computing the rest
27539 # is too much work
27540 @@ -407,11 +423,15 @@ DST( movb %cl, (%edi) )
27541
27542 6002:
27543 movl ARGBASE+24(%esp), %ebx # dst_err_ptr
27544 - movl $-EFAULT,(%ebx)
27545 + movl $-EFAULT,%ss:(%ebx)
27546 jmp 5000b
27547
27548 .previous
27549
27550 + pushl_cfi %ss
27551 + popl_cfi %ds
27552 + pushl_cfi %ss
27553 + popl_cfi %es
27554 popl_cfi %ebx
27555 CFI_RESTORE ebx
27556 popl_cfi %esi
27557 @@ -421,26 +441,43 @@ DST( movb %cl, (%edi) )
27558 popl_cfi %ecx # equivalent to addl $4,%esp
27559 ret
27560 CFI_ENDPROC
27561 -ENDPROC(csum_partial_copy_generic)
27562 +ENDPROC(csum_partial_copy_generic_to_user)
27563
27564 #else
27565
27566 /* Version for PentiumII/PPro */
27567
27568 #define ROUND1(x) \
27569 + nop; nop; nop; \
27570 SRC(movl x(%esi), %ebx ) ; \
27571 addl %ebx, %eax ; \
27572 - DST(movl %ebx, x(%edi) ) ;
27573 + DST(movl %ebx, %es:x(%edi)) ;
27574
27575 #define ROUND(x) \
27576 + nop; nop; nop; \
27577 SRC(movl x(%esi), %ebx ) ; \
27578 adcl %ebx, %eax ; \
27579 - DST(movl %ebx, x(%edi) ) ;
27580 + DST(movl %ebx, %es:x(%edi)) ;
27581
27582 #define ARGBASE 12
27583 -
27584 -ENTRY(csum_partial_copy_generic)
27585 +
27586 +ENTRY(csum_partial_copy_generic_to_user)
27587 CFI_STARTPROC
27588 +
27589 +#ifdef CONFIG_PAX_MEMORY_UDEREF
27590 + pushl_cfi %gs
27591 + popl_cfi %es
27592 + jmp csum_partial_copy_generic
27593 +#endif
27594 +
27595 +ENTRY(csum_partial_copy_generic_from_user)
27596 +
27597 +#ifdef CONFIG_PAX_MEMORY_UDEREF
27598 + pushl_cfi %gs
27599 + popl_cfi %ds
27600 +#endif
27601 +
27602 +ENTRY(csum_partial_copy_generic)
27603 pushl_cfi %ebx
27604 CFI_REL_OFFSET ebx, 0
27605 pushl_cfi %edi
27606 @@ -461,7 +498,7 @@ ENTRY(csum_partial_copy_generic)
27607 subl %ebx, %edi
27608 lea -1(%esi),%edx
27609 andl $-32,%edx
27610 - lea 3f(%ebx,%ebx), %ebx
27611 + lea 3f(%ebx,%ebx,2), %ebx
27612 testl %esi, %esi
27613 jmp *%ebx
27614 1: addl $64,%esi
27615 @@ -482,19 +519,19 @@ ENTRY(csum_partial_copy_generic)
27616 jb 5f
27617 SRC( movw (%esi), %dx )
27618 leal 2(%esi), %esi
27619 -DST( movw %dx, (%edi) )
27620 +DST( movw %dx, %es:(%edi) )
27621 leal 2(%edi), %edi
27622 je 6f
27623 shll $16,%edx
27624 5:
27625 SRC( movb (%esi), %dl )
27626 -DST( movb %dl, (%edi) )
27627 +DST( movb %dl, %es:(%edi) )
27628 6: addl %edx, %eax
27629 adcl $0, %eax
27630 7:
27631 .section .fixup, "ax"
27632 6001: movl ARGBASE+20(%esp), %ebx # src_err_ptr
27633 - movl $-EFAULT, (%ebx)
27634 + movl $-EFAULT, %ss:(%ebx)
27635 # zero the complete destination (computing the rest is too much work)
27636 movl ARGBASE+8(%esp),%edi # dst
27637 movl ARGBASE+12(%esp),%ecx # len
27638 @@ -502,10 +539,17 @@ DST( movb %dl, (%edi) )
27639 rep; stosb
27640 jmp 7b
27641 6002: movl ARGBASE+24(%esp), %ebx # dst_err_ptr
27642 - movl $-EFAULT, (%ebx)
27643 + movl $-EFAULT, %ss:(%ebx)
27644 jmp 7b
27645 .previous
27646
27647 +#ifdef CONFIG_PAX_MEMORY_UDEREF
27648 + pushl_cfi %ss
27649 + popl_cfi %ds
27650 + pushl_cfi %ss
27651 + popl_cfi %es
27652 +#endif
27653 +
27654 popl_cfi %esi
27655 CFI_RESTORE esi
27656 popl_cfi %edi
27657 @@ -514,7 +558,7 @@ DST( movb %dl, (%edi) )
27658 CFI_RESTORE ebx
27659 ret
27660 CFI_ENDPROC
27661 -ENDPROC(csum_partial_copy_generic)
27662 +ENDPROC(csum_partial_copy_generic_to_user)
27663
27664 #undef ROUND
27665 #undef ROUND1
27666 diff --git a/arch/x86/lib/clear_page_64.S b/arch/x86/lib/clear_page_64.S
27667 index f2145cf..cea889d 100644
27668 --- a/arch/x86/lib/clear_page_64.S
27669 +++ b/arch/x86/lib/clear_page_64.S
27670 @@ -11,6 +11,7 @@ ENTRY(clear_page_c)
27671 movl $4096/8,%ecx
27672 xorl %eax,%eax
27673 rep stosq
27674 + pax_force_retaddr
27675 ret
27676 CFI_ENDPROC
27677 ENDPROC(clear_page_c)
27678 @@ -20,6 +21,7 @@ ENTRY(clear_page_c_e)
27679 movl $4096,%ecx
27680 xorl %eax,%eax
27681 rep stosb
27682 + pax_force_retaddr
27683 ret
27684 CFI_ENDPROC
27685 ENDPROC(clear_page_c_e)
27686 @@ -43,6 +45,7 @@ ENTRY(clear_page)
27687 leaq 64(%rdi),%rdi
27688 jnz .Lloop
27689 nop
27690 + pax_force_retaddr
27691 ret
27692 CFI_ENDPROC
27693 .Lclear_page_end:
27694 @@ -58,7 +61,7 @@ ENDPROC(clear_page)
27695
27696 #include <asm/cpufeature.h>
27697
27698 - .section .altinstr_replacement,"ax"
27699 + .section .altinstr_replacement,"a"
27700 1: .byte 0xeb /* jmp <disp8> */
27701 .byte (clear_page_c - clear_page) - (2f - 1b) /* offset */
27702 2: .byte 0xeb /* jmp <disp8> */
27703 diff --git a/arch/x86/lib/cmpxchg16b_emu.S b/arch/x86/lib/cmpxchg16b_emu.S
27704 index 1e572c5..2a162cd 100644
27705 --- a/arch/x86/lib/cmpxchg16b_emu.S
27706 +++ b/arch/x86/lib/cmpxchg16b_emu.S
27707 @@ -53,11 +53,13 @@ this_cpu_cmpxchg16b_emu:
27708
27709 popf
27710 mov $1, %al
27711 + pax_force_retaddr
27712 ret
27713
27714 not_same:
27715 popf
27716 xor %al,%al
27717 + pax_force_retaddr
27718 ret
27719
27720 CFI_ENDPROC
27721 diff --git a/arch/x86/lib/copy_page_64.S b/arch/x86/lib/copy_page_64.S
27722 index 176cca6..1166c50 100644
27723 --- a/arch/x86/lib/copy_page_64.S
27724 +++ b/arch/x86/lib/copy_page_64.S
27725 @@ -9,6 +9,7 @@ copy_page_rep:
27726 CFI_STARTPROC
27727 movl $4096/8, %ecx
27728 rep movsq
27729 + pax_force_retaddr
27730 ret
27731 CFI_ENDPROC
27732 ENDPROC(copy_page_rep)
27733 @@ -20,12 +21,14 @@ ENDPROC(copy_page_rep)
27734
27735 ENTRY(copy_page)
27736 CFI_STARTPROC
27737 - subq $2*8, %rsp
27738 - CFI_ADJUST_CFA_OFFSET 2*8
27739 + subq $3*8, %rsp
27740 + CFI_ADJUST_CFA_OFFSET 3*8
27741 movq %rbx, (%rsp)
27742 CFI_REL_OFFSET rbx, 0
27743 movq %r12, 1*8(%rsp)
27744 CFI_REL_OFFSET r12, 1*8
27745 + movq %r13, 2*8(%rsp)
27746 + CFI_REL_OFFSET r13, 2*8
27747
27748 movl $(4096/64)-5, %ecx
27749 .p2align 4
27750 @@ -36,7 +39,7 @@ ENTRY(copy_page)
27751 movq 0x8*2(%rsi), %rdx
27752 movq 0x8*3(%rsi), %r8
27753 movq 0x8*4(%rsi), %r9
27754 - movq 0x8*5(%rsi), %r10
27755 + movq 0x8*5(%rsi), %r13
27756 movq 0x8*6(%rsi), %r11
27757 movq 0x8*7(%rsi), %r12
27758
27759 @@ -47,7 +50,7 @@ ENTRY(copy_page)
27760 movq %rdx, 0x8*2(%rdi)
27761 movq %r8, 0x8*3(%rdi)
27762 movq %r9, 0x8*4(%rdi)
27763 - movq %r10, 0x8*5(%rdi)
27764 + movq %r13, 0x8*5(%rdi)
27765 movq %r11, 0x8*6(%rdi)
27766 movq %r12, 0x8*7(%rdi)
27767
27768 @@ -66,7 +69,7 @@ ENTRY(copy_page)
27769 movq 0x8*2(%rsi), %rdx
27770 movq 0x8*3(%rsi), %r8
27771 movq 0x8*4(%rsi), %r9
27772 - movq 0x8*5(%rsi), %r10
27773 + movq 0x8*5(%rsi), %r13
27774 movq 0x8*6(%rsi), %r11
27775 movq 0x8*7(%rsi), %r12
27776
27777 @@ -75,7 +78,7 @@ ENTRY(copy_page)
27778 movq %rdx, 0x8*2(%rdi)
27779 movq %r8, 0x8*3(%rdi)
27780 movq %r9, 0x8*4(%rdi)
27781 - movq %r10, 0x8*5(%rdi)
27782 + movq %r13, 0x8*5(%rdi)
27783 movq %r11, 0x8*6(%rdi)
27784 movq %r12, 0x8*7(%rdi)
27785
27786 @@ -87,8 +90,11 @@ ENTRY(copy_page)
27787 CFI_RESTORE rbx
27788 movq 1*8(%rsp), %r12
27789 CFI_RESTORE r12
27790 - addq $2*8, %rsp
27791 - CFI_ADJUST_CFA_OFFSET -2*8
27792 + movq 2*8(%rsp), %r13
27793 + CFI_RESTORE r13
27794 + addq $3*8, %rsp
27795 + CFI_ADJUST_CFA_OFFSET -3*8
27796 + pax_force_retaddr
27797 ret
27798 .Lcopy_page_end:
27799 CFI_ENDPROC
27800 @@ -99,7 +105,7 @@ ENDPROC(copy_page)
27801
27802 #include <asm/cpufeature.h>
27803
27804 - .section .altinstr_replacement,"ax"
27805 + .section .altinstr_replacement,"a"
27806 1: .byte 0xeb /* jmp <disp8> */
27807 .byte (copy_page_rep - copy_page) - (2f - 1b) /* offset */
27808 2:
27809 diff --git a/arch/x86/lib/copy_user_64.S b/arch/x86/lib/copy_user_64.S
27810 index a30ca15..6b3f4e1 100644
27811 --- a/arch/x86/lib/copy_user_64.S
27812 +++ b/arch/x86/lib/copy_user_64.S
27813 @@ -18,31 +18,7 @@
27814 #include <asm/alternative-asm.h>
27815 #include <asm/asm.h>
27816 #include <asm/smap.h>
27817 -
27818 -/*
27819 - * By placing feature2 after feature1 in altinstructions section, we logically
27820 - * implement:
27821 - * If CPU has feature2, jmp to alt2 is used
27822 - * else if CPU has feature1, jmp to alt1 is used
27823 - * else jmp to orig is used.
27824 - */
27825 - .macro ALTERNATIVE_JUMP feature1,feature2,orig,alt1,alt2
27826 -0:
27827 - .byte 0xe9 /* 32bit jump */
27828 - .long \orig-1f /* by default jump to orig */
27829 -1:
27830 - .section .altinstr_replacement,"ax"
27831 -2: .byte 0xe9 /* near jump with 32bit immediate */
27832 - .long \alt1-1b /* offset */ /* or alternatively to alt1 */
27833 -3: .byte 0xe9 /* near jump with 32bit immediate */
27834 - .long \alt2-1b /* offset */ /* or alternatively to alt2 */
27835 - .previous
27836 -
27837 - .section .altinstructions,"a"
27838 - altinstruction_entry 0b,2b,\feature1,5,5
27839 - altinstruction_entry 0b,3b,\feature2,5,5
27840 - .previous
27841 - .endm
27842 +#include <asm/pgtable.h>
27843
27844 .macro ALIGN_DESTINATION
27845 #ifdef FIX_ALIGNMENT
27846 @@ -70,52 +46,6 @@
27847 #endif
27848 .endm
27849
27850 -/* Standard copy_to_user with segment limit checking */
27851 -ENTRY(_copy_to_user)
27852 - CFI_STARTPROC
27853 - GET_THREAD_INFO(%rax)
27854 - movq %rdi,%rcx
27855 - addq %rdx,%rcx
27856 - jc bad_to_user
27857 - cmpq TI_addr_limit(%rax),%rcx
27858 - ja bad_to_user
27859 - ALTERNATIVE_JUMP X86_FEATURE_REP_GOOD,X86_FEATURE_ERMS, \
27860 - copy_user_generic_unrolled,copy_user_generic_string, \
27861 - copy_user_enhanced_fast_string
27862 - CFI_ENDPROC
27863 -ENDPROC(_copy_to_user)
27864 -
27865 -/* Standard copy_from_user with segment limit checking */
27866 -ENTRY(_copy_from_user)
27867 - CFI_STARTPROC
27868 - GET_THREAD_INFO(%rax)
27869 - movq %rsi,%rcx
27870 - addq %rdx,%rcx
27871 - jc bad_from_user
27872 - cmpq TI_addr_limit(%rax),%rcx
27873 - ja bad_from_user
27874 - ALTERNATIVE_JUMP X86_FEATURE_REP_GOOD,X86_FEATURE_ERMS, \
27875 - copy_user_generic_unrolled,copy_user_generic_string, \
27876 - copy_user_enhanced_fast_string
27877 - CFI_ENDPROC
27878 -ENDPROC(_copy_from_user)
27879 -
27880 - .section .fixup,"ax"
27881 - /* must zero dest */
27882 -ENTRY(bad_from_user)
27883 -bad_from_user:
27884 - CFI_STARTPROC
27885 - movl %edx,%ecx
27886 - xorl %eax,%eax
27887 - rep
27888 - stosb
27889 -bad_to_user:
27890 - movl %edx,%eax
27891 - ret
27892 - CFI_ENDPROC
27893 -ENDPROC(bad_from_user)
27894 - .previous
27895 -
27896 /*
27897 * copy_user_generic_unrolled - memory copy with exception handling.
27898 * This version is for CPUs like P4 that don't have efficient micro
27899 @@ -131,6 +61,7 @@ ENDPROC(bad_from_user)
27900 */
27901 ENTRY(copy_user_generic_unrolled)
27902 CFI_STARTPROC
27903 + ASM_PAX_OPEN_USERLAND
27904 ASM_STAC
27905 cmpl $8,%edx
27906 jb 20f /* less then 8 bytes, go to byte copy loop */
27907 @@ -141,19 +72,19 @@ ENTRY(copy_user_generic_unrolled)
27908 jz 17f
27909 1: movq (%rsi),%r8
27910 2: movq 1*8(%rsi),%r9
27911 -3: movq 2*8(%rsi),%r10
27912 +3: movq 2*8(%rsi),%rax
27913 4: movq 3*8(%rsi),%r11
27914 5: movq %r8,(%rdi)
27915 6: movq %r9,1*8(%rdi)
27916 -7: movq %r10,2*8(%rdi)
27917 +7: movq %rax,2*8(%rdi)
27918 8: movq %r11,3*8(%rdi)
27919 9: movq 4*8(%rsi),%r8
27920 10: movq 5*8(%rsi),%r9
27921 -11: movq 6*8(%rsi),%r10
27922 +11: movq 6*8(%rsi),%rax
27923 12: movq 7*8(%rsi),%r11
27924 13: movq %r8,4*8(%rdi)
27925 14: movq %r9,5*8(%rdi)
27926 -15: movq %r10,6*8(%rdi)
27927 +15: movq %rax,6*8(%rdi)
27928 16: movq %r11,7*8(%rdi)
27929 leaq 64(%rsi),%rsi
27930 leaq 64(%rdi),%rdi
27931 @@ -180,6 +111,8 @@ ENTRY(copy_user_generic_unrolled)
27932 jnz 21b
27933 23: xor %eax,%eax
27934 ASM_CLAC
27935 + ASM_PAX_CLOSE_USERLAND
27936 + pax_force_retaddr
27937 ret
27938
27939 .section .fixup,"ax"
27940 @@ -235,6 +168,7 @@ ENDPROC(copy_user_generic_unrolled)
27941 */
27942 ENTRY(copy_user_generic_string)
27943 CFI_STARTPROC
27944 + ASM_PAX_OPEN_USERLAND
27945 ASM_STAC
27946 andl %edx,%edx
27947 jz 4f
27948 @@ -251,6 +185,8 @@ ENTRY(copy_user_generic_string)
27949 movsb
27950 4: xorl %eax,%eax
27951 ASM_CLAC
27952 + ASM_PAX_CLOSE_USERLAND
27953 + pax_force_retaddr
27954 ret
27955
27956 .section .fixup,"ax"
27957 @@ -278,6 +214,7 @@ ENDPROC(copy_user_generic_string)
27958 */
27959 ENTRY(copy_user_enhanced_fast_string)
27960 CFI_STARTPROC
27961 + ASM_PAX_OPEN_USERLAND
27962 ASM_STAC
27963 andl %edx,%edx
27964 jz 2f
27965 @@ -286,6 +223,8 @@ ENTRY(copy_user_enhanced_fast_string)
27966 movsb
27967 2: xorl %eax,%eax
27968 ASM_CLAC
27969 + ASM_PAX_CLOSE_USERLAND
27970 + pax_force_retaddr
27971 ret
27972
27973 .section .fixup,"ax"
27974 diff --git a/arch/x86/lib/copy_user_nocache_64.S b/arch/x86/lib/copy_user_nocache_64.S
27975 index 6a4f43c..55d26f2 100644
27976 --- a/arch/x86/lib/copy_user_nocache_64.S
27977 +++ b/arch/x86/lib/copy_user_nocache_64.S
27978 @@ -8,6 +8,7 @@
27979
27980 #include <linux/linkage.h>
27981 #include <asm/dwarf2.h>
27982 +#include <asm/alternative-asm.h>
27983
27984 #define FIX_ALIGNMENT 1
27985
27986 @@ -16,6 +17,7 @@
27987 #include <asm/thread_info.h>
27988 #include <asm/asm.h>
27989 #include <asm/smap.h>
27990 +#include <asm/pgtable.h>
27991
27992 .macro ALIGN_DESTINATION
27993 #ifdef FIX_ALIGNMENT
27994 @@ -49,6 +51,16 @@
27995 */
27996 ENTRY(__copy_user_nocache)
27997 CFI_STARTPROC
27998 +
27999 +#ifdef CONFIG_PAX_MEMORY_UDEREF
28000 + mov pax_user_shadow_base,%rcx
28001 + cmp %rcx,%rsi
28002 + jae 1f
28003 + add %rcx,%rsi
28004 +1:
28005 +#endif
28006 +
28007 + ASM_PAX_OPEN_USERLAND
28008 ASM_STAC
28009 cmpl $8,%edx
28010 jb 20f /* less then 8 bytes, go to byte copy loop */
28011 @@ -59,19 +71,19 @@ ENTRY(__copy_user_nocache)
28012 jz 17f
28013 1: movq (%rsi),%r8
28014 2: movq 1*8(%rsi),%r9
28015 -3: movq 2*8(%rsi),%r10
28016 +3: movq 2*8(%rsi),%rax
28017 4: movq 3*8(%rsi),%r11
28018 5: movnti %r8,(%rdi)
28019 6: movnti %r9,1*8(%rdi)
28020 -7: movnti %r10,2*8(%rdi)
28021 +7: movnti %rax,2*8(%rdi)
28022 8: movnti %r11,3*8(%rdi)
28023 9: movq 4*8(%rsi),%r8
28024 10: movq 5*8(%rsi),%r9
28025 -11: movq 6*8(%rsi),%r10
28026 +11: movq 6*8(%rsi),%rax
28027 12: movq 7*8(%rsi),%r11
28028 13: movnti %r8,4*8(%rdi)
28029 14: movnti %r9,5*8(%rdi)
28030 -15: movnti %r10,6*8(%rdi)
28031 +15: movnti %rax,6*8(%rdi)
28032 16: movnti %r11,7*8(%rdi)
28033 leaq 64(%rsi),%rsi
28034 leaq 64(%rdi),%rdi
28035 @@ -98,7 +110,9 @@ ENTRY(__copy_user_nocache)
28036 jnz 21b
28037 23: xorl %eax,%eax
28038 ASM_CLAC
28039 + ASM_PAX_CLOSE_USERLAND
28040 sfence
28041 + pax_force_retaddr
28042 ret
28043
28044 .section .fixup,"ax"
28045 diff --git a/arch/x86/lib/csum-copy_64.S b/arch/x86/lib/csum-copy_64.S
28046 index 2419d5f..953ee51 100644
28047 --- a/arch/x86/lib/csum-copy_64.S
28048 +++ b/arch/x86/lib/csum-copy_64.S
28049 @@ -9,6 +9,7 @@
28050 #include <asm/dwarf2.h>
28051 #include <asm/errno.h>
28052 #include <asm/asm.h>
28053 +#include <asm/alternative-asm.h>
28054
28055 /*
28056 * Checksum copy with exception handling.
28057 @@ -220,6 +221,7 @@ ENTRY(csum_partial_copy_generic)
28058 CFI_RESTORE rbp
28059 addq $7*8, %rsp
28060 CFI_ADJUST_CFA_OFFSET -7*8
28061 + pax_force_retaddr 0, 1
28062 ret
28063 CFI_RESTORE_STATE
28064
28065 diff --git a/arch/x86/lib/csum-wrappers_64.c b/arch/x86/lib/csum-wrappers_64.c
28066 index 7609e0e..b449b98 100644
28067 --- a/arch/x86/lib/csum-wrappers_64.c
28068 +++ b/arch/x86/lib/csum-wrappers_64.c
28069 @@ -53,10 +53,12 @@ csum_partial_copy_from_user(const void __user *src, void *dst,
28070 len -= 2;
28071 }
28072 }
28073 + pax_open_userland();
28074 stac();
28075 - isum = csum_partial_copy_generic((__force const void *)src,
28076 + isum = csum_partial_copy_generic((const void __force_kernel *)____m(src),
28077 dst, len, isum, errp, NULL);
28078 clac();
28079 + pax_close_userland();
28080 if (unlikely(*errp))
28081 goto out_err;
28082
28083 @@ -110,10 +112,12 @@ csum_partial_copy_to_user(const void *src, void __user *dst,
28084 }
28085
28086 *errp = 0;
28087 + pax_open_userland();
28088 stac();
28089 - ret = csum_partial_copy_generic(src, (void __force *)dst,
28090 + ret = csum_partial_copy_generic(src, (void __force_kernel *)____m(dst),
28091 len, isum, NULL, errp);
28092 clac();
28093 + pax_close_userland();
28094 return ret;
28095 }
28096 EXPORT_SYMBOL(csum_partial_copy_to_user);
28097 diff --git a/arch/x86/lib/getuser.S b/arch/x86/lib/getuser.S
28098 index a451235..1daa956 100644
28099 --- a/arch/x86/lib/getuser.S
28100 +++ b/arch/x86/lib/getuser.S
28101 @@ -33,17 +33,40 @@
28102 #include <asm/thread_info.h>
28103 #include <asm/asm.h>
28104 #include <asm/smap.h>
28105 +#include <asm/segment.h>
28106 +#include <asm/pgtable.h>
28107 +#include <asm/alternative-asm.h>
28108 +
28109 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_MEMORY_UDEREF)
28110 +#define __copyuser_seg gs;
28111 +#else
28112 +#define __copyuser_seg
28113 +#endif
28114
28115 .text
28116 ENTRY(__get_user_1)
28117 CFI_STARTPROC
28118 +
28119 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
28120 GET_THREAD_INFO(%_ASM_DX)
28121 cmp TI_addr_limit(%_ASM_DX),%_ASM_AX
28122 jae bad_get_user
28123 ASM_STAC
28124 -1: movzbl (%_ASM_AX),%edx
28125 +
28126 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
28127 + mov pax_user_shadow_base,%_ASM_DX
28128 + cmp %_ASM_DX,%_ASM_AX
28129 + jae 1234f
28130 + add %_ASM_DX,%_ASM_AX
28131 +1234:
28132 +#endif
28133 +
28134 +#endif
28135 +
28136 +1: __copyuser_seg movzbl (%_ASM_AX),%edx
28137 xor %eax,%eax
28138 ASM_CLAC
28139 + pax_force_retaddr
28140 ret
28141 CFI_ENDPROC
28142 ENDPROC(__get_user_1)
28143 @@ -51,14 +74,28 @@ ENDPROC(__get_user_1)
28144 ENTRY(__get_user_2)
28145 CFI_STARTPROC
28146 add $1,%_ASM_AX
28147 +
28148 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
28149 jc bad_get_user
28150 GET_THREAD_INFO(%_ASM_DX)
28151 cmp TI_addr_limit(%_ASM_DX),%_ASM_AX
28152 jae bad_get_user
28153 ASM_STAC
28154 -2: movzwl -1(%_ASM_AX),%edx
28155 +
28156 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
28157 + mov pax_user_shadow_base,%_ASM_DX
28158 + cmp %_ASM_DX,%_ASM_AX
28159 + jae 1234f
28160 + add %_ASM_DX,%_ASM_AX
28161 +1234:
28162 +#endif
28163 +
28164 +#endif
28165 +
28166 +2: __copyuser_seg movzwl -1(%_ASM_AX),%edx
28167 xor %eax,%eax
28168 ASM_CLAC
28169 + pax_force_retaddr
28170 ret
28171 CFI_ENDPROC
28172 ENDPROC(__get_user_2)
28173 @@ -66,14 +103,28 @@ ENDPROC(__get_user_2)
28174 ENTRY(__get_user_4)
28175 CFI_STARTPROC
28176 add $3,%_ASM_AX
28177 +
28178 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
28179 jc bad_get_user
28180 GET_THREAD_INFO(%_ASM_DX)
28181 cmp TI_addr_limit(%_ASM_DX),%_ASM_AX
28182 jae bad_get_user
28183 ASM_STAC
28184 -3: movl -3(%_ASM_AX),%edx
28185 +
28186 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
28187 + mov pax_user_shadow_base,%_ASM_DX
28188 + cmp %_ASM_DX,%_ASM_AX
28189 + jae 1234f
28190 + add %_ASM_DX,%_ASM_AX
28191 +1234:
28192 +#endif
28193 +
28194 +#endif
28195 +
28196 +3: __copyuser_seg movl -3(%_ASM_AX),%edx
28197 xor %eax,%eax
28198 ASM_CLAC
28199 + pax_force_retaddr
28200 ret
28201 CFI_ENDPROC
28202 ENDPROC(__get_user_4)
28203 @@ -86,10 +137,20 @@ ENTRY(__get_user_8)
28204 GET_THREAD_INFO(%_ASM_DX)
28205 cmp TI_addr_limit(%_ASM_DX),%_ASM_AX
28206 jae bad_get_user
28207 +
28208 +#ifdef CONFIG_PAX_MEMORY_UDEREF
28209 + mov pax_user_shadow_base,%_ASM_DX
28210 + cmp %_ASM_DX,%_ASM_AX
28211 + jae 1234f
28212 + add %_ASM_DX,%_ASM_AX
28213 +1234:
28214 +#endif
28215 +
28216 ASM_STAC
28217 4: movq -7(%_ASM_AX),%rdx
28218 xor %eax,%eax
28219 ASM_CLAC
28220 + pax_force_retaddr
28221 ret
28222 #else
28223 add $7,%_ASM_AX
28224 @@ -98,10 +159,11 @@ ENTRY(__get_user_8)
28225 cmp TI_addr_limit(%_ASM_DX),%_ASM_AX
28226 jae bad_get_user_8
28227 ASM_STAC
28228 -4: movl -7(%_ASM_AX),%edx
28229 -5: movl -3(%_ASM_AX),%ecx
28230 +4: __copyuser_seg movl -7(%_ASM_AX),%edx
28231 +5: __copyuser_seg movl -3(%_ASM_AX),%ecx
28232 xor %eax,%eax
28233 ASM_CLAC
28234 + pax_force_retaddr
28235 ret
28236 #endif
28237 CFI_ENDPROC
28238 @@ -113,6 +175,7 @@ bad_get_user:
28239 xor %edx,%edx
28240 mov $(-EFAULT),%_ASM_AX
28241 ASM_CLAC
28242 + pax_force_retaddr
28243 ret
28244 CFI_ENDPROC
28245 END(bad_get_user)
28246 @@ -124,6 +187,7 @@ bad_get_user_8:
28247 xor %ecx,%ecx
28248 mov $(-EFAULT),%_ASM_AX
28249 ASM_CLAC
28250 + pax_force_retaddr
28251 ret
28252 CFI_ENDPROC
28253 END(bad_get_user_8)
28254 diff --git a/arch/x86/lib/insn.c b/arch/x86/lib/insn.c
28255 index 54fcffe..7be149e 100644
28256 --- a/arch/x86/lib/insn.c
28257 +++ b/arch/x86/lib/insn.c
28258 @@ -20,8 +20,10 @@
28259
28260 #ifdef __KERNEL__
28261 #include <linux/string.h>
28262 +#include <asm/pgtable_types.h>
28263 #else
28264 #include <string.h>
28265 +#define ktla_ktva(addr) addr
28266 #endif
28267 #include <asm/inat.h>
28268 #include <asm/insn.h>
28269 @@ -53,8 +55,8 @@
28270 void insn_init(struct insn *insn, const void *kaddr, int x86_64)
28271 {
28272 memset(insn, 0, sizeof(*insn));
28273 - insn->kaddr = kaddr;
28274 - insn->next_byte = kaddr;
28275 + insn->kaddr = ktla_ktva(kaddr);
28276 + insn->next_byte = ktla_ktva(kaddr);
28277 insn->x86_64 = x86_64 ? 1 : 0;
28278 insn->opnd_bytes = 4;
28279 if (x86_64)
28280 diff --git a/arch/x86/lib/iomap_copy_64.S b/arch/x86/lib/iomap_copy_64.S
28281 index 05a95e7..326f2fa 100644
28282 --- a/arch/x86/lib/iomap_copy_64.S
28283 +++ b/arch/x86/lib/iomap_copy_64.S
28284 @@ -17,6 +17,7 @@
28285
28286 #include <linux/linkage.h>
28287 #include <asm/dwarf2.h>
28288 +#include <asm/alternative-asm.h>
28289
28290 /*
28291 * override generic version in lib/iomap_copy.c
28292 @@ -25,6 +26,7 @@ ENTRY(__iowrite32_copy)
28293 CFI_STARTPROC
28294 movl %edx,%ecx
28295 rep movsd
28296 + pax_force_retaddr
28297 ret
28298 CFI_ENDPROC
28299 ENDPROC(__iowrite32_copy)
28300 diff --git a/arch/x86/lib/memcpy_64.S b/arch/x86/lib/memcpy_64.S
28301 index 56313a3..9b59269 100644
28302 --- a/arch/x86/lib/memcpy_64.S
28303 +++ b/arch/x86/lib/memcpy_64.S
28304 @@ -24,7 +24,7 @@
28305 * This gets patched over the unrolled variant (below) via the
28306 * alternative instructions framework:
28307 */
28308 - .section .altinstr_replacement, "ax", @progbits
28309 + .section .altinstr_replacement, "a", @progbits
28310 .Lmemcpy_c:
28311 movq %rdi, %rax
28312 movq %rdx, %rcx
28313 @@ -33,6 +33,7 @@
28314 rep movsq
28315 movl %edx, %ecx
28316 rep movsb
28317 + pax_force_retaddr
28318 ret
28319 .Lmemcpy_e:
28320 .previous
28321 @@ -44,11 +45,12 @@
28322 * This gets patched over the unrolled variant (below) via the
28323 * alternative instructions framework:
28324 */
28325 - .section .altinstr_replacement, "ax", @progbits
28326 + .section .altinstr_replacement, "a", @progbits
28327 .Lmemcpy_c_e:
28328 movq %rdi, %rax
28329 movq %rdx, %rcx
28330 rep movsb
28331 + pax_force_retaddr
28332 ret
28333 .Lmemcpy_e_e:
28334 .previous
28335 @@ -76,13 +78,13 @@ ENTRY(memcpy)
28336 */
28337 movq 0*8(%rsi), %r8
28338 movq 1*8(%rsi), %r9
28339 - movq 2*8(%rsi), %r10
28340 + movq 2*8(%rsi), %rcx
28341 movq 3*8(%rsi), %r11
28342 leaq 4*8(%rsi), %rsi
28343
28344 movq %r8, 0*8(%rdi)
28345 movq %r9, 1*8(%rdi)
28346 - movq %r10, 2*8(%rdi)
28347 + movq %rcx, 2*8(%rdi)
28348 movq %r11, 3*8(%rdi)
28349 leaq 4*8(%rdi), %rdi
28350 jae .Lcopy_forward_loop
28351 @@ -105,12 +107,12 @@ ENTRY(memcpy)
28352 subq $0x20, %rdx
28353 movq -1*8(%rsi), %r8
28354 movq -2*8(%rsi), %r9
28355 - movq -3*8(%rsi), %r10
28356 + movq -3*8(%rsi), %rcx
28357 movq -4*8(%rsi), %r11
28358 leaq -4*8(%rsi), %rsi
28359 movq %r8, -1*8(%rdi)
28360 movq %r9, -2*8(%rdi)
28361 - movq %r10, -3*8(%rdi)
28362 + movq %rcx, -3*8(%rdi)
28363 movq %r11, -4*8(%rdi)
28364 leaq -4*8(%rdi), %rdi
28365 jae .Lcopy_backward_loop
28366 @@ -130,12 +132,13 @@ ENTRY(memcpy)
28367 */
28368 movq 0*8(%rsi), %r8
28369 movq 1*8(%rsi), %r9
28370 - movq -2*8(%rsi, %rdx), %r10
28371 + movq -2*8(%rsi, %rdx), %rcx
28372 movq -1*8(%rsi, %rdx), %r11
28373 movq %r8, 0*8(%rdi)
28374 movq %r9, 1*8(%rdi)
28375 - movq %r10, -2*8(%rdi, %rdx)
28376 + movq %rcx, -2*8(%rdi, %rdx)
28377 movq %r11, -1*8(%rdi, %rdx)
28378 + pax_force_retaddr
28379 retq
28380 .p2align 4
28381 .Lless_16bytes:
28382 @@ -148,6 +151,7 @@ ENTRY(memcpy)
28383 movq -1*8(%rsi, %rdx), %r9
28384 movq %r8, 0*8(%rdi)
28385 movq %r9, -1*8(%rdi, %rdx)
28386 + pax_force_retaddr
28387 retq
28388 .p2align 4
28389 .Lless_8bytes:
28390 @@ -161,6 +165,7 @@ ENTRY(memcpy)
28391 movl -4(%rsi, %rdx), %r8d
28392 movl %ecx, (%rdi)
28393 movl %r8d, -4(%rdi, %rdx)
28394 + pax_force_retaddr
28395 retq
28396 .p2align 4
28397 .Lless_3bytes:
28398 @@ -179,6 +184,7 @@ ENTRY(memcpy)
28399 movb %cl, (%rdi)
28400
28401 .Lend:
28402 + pax_force_retaddr
28403 retq
28404 CFI_ENDPROC
28405 ENDPROC(memcpy)
28406 diff --git a/arch/x86/lib/memmove_64.S b/arch/x86/lib/memmove_64.S
28407 index 65268a6..5aa7815 100644
28408 --- a/arch/x86/lib/memmove_64.S
28409 +++ b/arch/x86/lib/memmove_64.S
28410 @@ -61,13 +61,13 @@ ENTRY(memmove)
28411 5:
28412 sub $0x20, %rdx
28413 movq 0*8(%rsi), %r11
28414 - movq 1*8(%rsi), %r10
28415 + movq 1*8(%rsi), %rcx
28416 movq 2*8(%rsi), %r9
28417 movq 3*8(%rsi), %r8
28418 leaq 4*8(%rsi), %rsi
28419
28420 movq %r11, 0*8(%rdi)
28421 - movq %r10, 1*8(%rdi)
28422 + movq %rcx, 1*8(%rdi)
28423 movq %r9, 2*8(%rdi)
28424 movq %r8, 3*8(%rdi)
28425 leaq 4*8(%rdi), %rdi
28426 @@ -81,10 +81,10 @@ ENTRY(memmove)
28427 4:
28428 movq %rdx, %rcx
28429 movq -8(%rsi, %rdx), %r11
28430 - lea -8(%rdi, %rdx), %r10
28431 + lea -8(%rdi, %rdx), %r9
28432 shrq $3, %rcx
28433 rep movsq
28434 - movq %r11, (%r10)
28435 + movq %r11, (%r9)
28436 jmp 13f
28437 .Lmemmove_end_forward:
28438
28439 @@ -95,14 +95,14 @@ ENTRY(memmove)
28440 7:
28441 movq %rdx, %rcx
28442 movq (%rsi), %r11
28443 - movq %rdi, %r10
28444 + movq %rdi, %r9
28445 leaq -8(%rsi, %rdx), %rsi
28446 leaq -8(%rdi, %rdx), %rdi
28447 shrq $3, %rcx
28448 std
28449 rep movsq
28450 cld
28451 - movq %r11, (%r10)
28452 + movq %r11, (%r9)
28453 jmp 13f
28454
28455 /*
28456 @@ -127,13 +127,13 @@ ENTRY(memmove)
28457 8:
28458 subq $0x20, %rdx
28459 movq -1*8(%rsi), %r11
28460 - movq -2*8(%rsi), %r10
28461 + movq -2*8(%rsi), %rcx
28462 movq -3*8(%rsi), %r9
28463 movq -4*8(%rsi), %r8
28464 leaq -4*8(%rsi), %rsi
28465
28466 movq %r11, -1*8(%rdi)
28467 - movq %r10, -2*8(%rdi)
28468 + movq %rcx, -2*8(%rdi)
28469 movq %r9, -3*8(%rdi)
28470 movq %r8, -4*8(%rdi)
28471 leaq -4*8(%rdi), %rdi
28472 @@ -151,11 +151,11 @@ ENTRY(memmove)
28473 * Move data from 16 bytes to 31 bytes.
28474 */
28475 movq 0*8(%rsi), %r11
28476 - movq 1*8(%rsi), %r10
28477 + movq 1*8(%rsi), %rcx
28478 movq -2*8(%rsi, %rdx), %r9
28479 movq -1*8(%rsi, %rdx), %r8
28480 movq %r11, 0*8(%rdi)
28481 - movq %r10, 1*8(%rdi)
28482 + movq %rcx, 1*8(%rdi)
28483 movq %r9, -2*8(%rdi, %rdx)
28484 movq %r8, -1*8(%rdi, %rdx)
28485 jmp 13f
28486 @@ -167,9 +167,9 @@ ENTRY(memmove)
28487 * Move data from 8 bytes to 15 bytes.
28488 */
28489 movq 0*8(%rsi), %r11
28490 - movq -1*8(%rsi, %rdx), %r10
28491 + movq -1*8(%rsi, %rdx), %r9
28492 movq %r11, 0*8(%rdi)
28493 - movq %r10, -1*8(%rdi, %rdx)
28494 + movq %r9, -1*8(%rdi, %rdx)
28495 jmp 13f
28496 10:
28497 cmpq $4, %rdx
28498 @@ -178,9 +178,9 @@ ENTRY(memmove)
28499 * Move data from 4 bytes to 7 bytes.
28500 */
28501 movl (%rsi), %r11d
28502 - movl -4(%rsi, %rdx), %r10d
28503 + movl -4(%rsi, %rdx), %r9d
28504 movl %r11d, (%rdi)
28505 - movl %r10d, -4(%rdi, %rdx)
28506 + movl %r9d, -4(%rdi, %rdx)
28507 jmp 13f
28508 11:
28509 cmp $2, %rdx
28510 @@ -189,9 +189,9 @@ ENTRY(memmove)
28511 * Move data from 2 bytes to 3 bytes.
28512 */
28513 movw (%rsi), %r11w
28514 - movw -2(%rsi, %rdx), %r10w
28515 + movw -2(%rsi, %rdx), %r9w
28516 movw %r11w, (%rdi)
28517 - movw %r10w, -2(%rdi, %rdx)
28518 + movw %r9w, -2(%rdi, %rdx)
28519 jmp 13f
28520 12:
28521 cmp $1, %rdx
28522 @@ -202,14 +202,16 @@ ENTRY(memmove)
28523 movb (%rsi), %r11b
28524 movb %r11b, (%rdi)
28525 13:
28526 + pax_force_retaddr
28527 retq
28528 CFI_ENDPROC
28529
28530 - .section .altinstr_replacement,"ax"
28531 + .section .altinstr_replacement,"a"
28532 .Lmemmove_begin_forward_efs:
28533 /* Forward moving data. */
28534 movq %rdx, %rcx
28535 rep movsb
28536 + pax_force_retaddr
28537 retq
28538 .Lmemmove_end_forward_efs:
28539 .previous
28540 diff --git a/arch/x86/lib/memset_64.S b/arch/x86/lib/memset_64.S
28541 index 2dcb380..50a78bc 100644
28542 --- a/arch/x86/lib/memset_64.S
28543 +++ b/arch/x86/lib/memset_64.S
28544 @@ -16,7 +16,7 @@
28545 *
28546 * rax original destination
28547 */
28548 - .section .altinstr_replacement, "ax", @progbits
28549 + .section .altinstr_replacement, "a", @progbits
28550 .Lmemset_c:
28551 movq %rdi,%r9
28552 movq %rdx,%rcx
28553 @@ -30,6 +30,7 @@
28554 movl %edx,%ecx
28555 rep stosb
28556 movq %r9,%rax
28557 + pax_force_retaddr
28558 ret
28559 .Lmemset_e:
28560 .previous
28561 @@ -45,13 +46,14 @@
28562 *
28563 * rax original destination
28564 */
28565 - .section .altinstr_replacement, "ax", @progbits
28566 + .section .altinstr_replacement, "a", @progbits
28567 .Lmemset_c_e:
28568 movq %rdi,%r9
28569 movb %sil,%al
28570 movq %rdx,%rcx
28571 rep stosb
28572 movq %r9,%rax
28573 + pax_force_retaddr
28574 ret
28575 .Lmemset_e_e:
28576 .previous
28577 @@ -59,7 +61,7 @@
28578 ENTRY(memset)
28579 ENTRY(__memset)
28580 CFI_STARTPROC
28581 - movq %rdi,%r10
28582 + movq %rdi,%r11
28583
28584 /* expand byte value */
28585 movzbl %sil,%ecx
28586 @@ -117,7 +119,8 @@ ENTRY(__memset)
28587 jnz .Lloop_1
28588
28589 .Lende:
28590 - movq %r10,%rax
28591 + movq %r11,%rax
28592 + pax_force_retaddr
28593 ret
28594
28595 CFI_RESTORE_STATE
28596 diff --git a/arch/x86/lib/mmx_32.c b/arch/x86/lib/mmx_32.c
28597 index c9f2d9b..e7fd2c0 100644
28598 --- a/arch/x86/lib/mmx_32.c
28599 +++ b/arch/x86/lib/mmx_32.c
28600 @@ -29,6 +29,7 @@ void *_mmx_memcpy(void *to, const void *from, size_t len)
28601 {
28602 void *p;
28603 int i;
28604 + unsigned long cr0;
28605
28606 if (unlikely(in_interrupt()))
28607 return __memcpy(to, from, len);
28608 @@ -39,44 +40,72 @@ void *_mmx_memcpy(void *to, const void *from, size_t len)
28609 kernel_fpu_begin();
28610
28611 __asm__ __volatile__ (
28612 - "1: prefetch (%0)\n" /* This set is 28 bytes */
28613 - " prefetch 64(%0)\n"
28614 - " prefetch 128(%0)\n"
28615 - " prefetch 192(%0)\n"
28616 - " prefetch 256(%0)\n"
28617 + "1: prefetch (%1)\n" /* This set is 28 bytes */
28618 + " prefetch 64(%1)\n"
28619 + " prefetch 128(%1)\n"
28620 + " prefetch 192(%1)\n"
28621 + " prefetch 256(%1)\n"
28622 "2: \n"
28623 ".section .fixup, \"ax\"\n"
28624 - "3: movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
28625 + "3: \n"
28626 +
28627 +#ifdef CONFIG_PAX_KERNEXEC
28628 + " movl %%cr0, %0\n"
28629 + " movl %0, %%eax\n"
28630 + " andl $0xFFFEFFFF, %%eax\n"
28631 + " movl %%eax, %%cr0\n"
28632 +#endif
28633 +
28634 + " movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
28635 +
28636 +#ifdef CONFIG_PAX_KERNEXEC
28637 + " movl %0, %%cr0\n"
28638 +#endif
28639 +
28640 " jmp 2b\n"
28641 ".previous\n"
28642 _ASM_EXTABLE(1b, 3b)
28643 - : : "r" (from));
28644 + : "=&r" (cr0) : "r" (from) : "ax");
28645
28646 for ( ; i > 5; i--) {
28647 __asm__ __volatile__ (
28648 - "1: prefetch 320(%0)\n"
28649 - "2: movq (%0), %%mm0\n"
28650 - " movq 8(%0), %%mm1\n"
28651 - " movq 16(%0), %%mm2\n"
28652 - " movq 24(%0), %%mm3\n"
28653 - " movq %%mm0, (%1)\n"
28654 - " movq %%mm1, 8(%1)\n"
28655 - " movq %%mm2, 16(%1)\n"
28656 - " movq %%mm3, 24(%1)\n"
28657 - " movq 32(%0), %%mm0\n"
28658 - " movq 40(%0), %%mm1\n"
28659 - " movq 48(%0), %%mm2\n"
28660 - " movq 56(%0), %%mm3\n"
28661 - " movq %%mm0, 32(%1)\n"
28662 - " movq %%mm1, 40(%1)\n"
28663 - " movq %%mm2, 48(%1)\n"
28664 - " movq %%mm3, 56(%1)\n"
28665 + "1: prefetch 320(%1)\n"
28666 + "2: movq (%1), %%mm0\n"
28667 + " movq 8(%1), %%mm1\n"
28668 + " movq 16(%1), %%mm2\n"
28669 + " movq 24(%1), %%mm3\n"
28670 + " movq %%mm0, (%2)\n"
28671 + " movq %%mm1, 8(%2)\n"
28672 + " movq %%mm2, 16(%2)\n"
28673 + " movq %%mm3, 24(%2)\n"
28674 + " movq 32(%1), %%mm0\n"
28675 + " movq 40(%1), %%mm1\n"
28676 + " movq 48(%1), %%mm2\n"
28677 + " movq 56(%1), %%mm3\n"
28678 + " movq %%mm0, 32(%2)\n"
28679 + " movq %%mm1, 40(%2)\n"
28680 + " movq %%mm2, 48(%2)\n"
28681 + " movq %%mm3, 56(%2)\n"
28682 ".section .fixup, \"ax\"\n"
28683 - "3: movw $0x05EB, 1b\n" /* jmp on 5 bytes */
28684 + "3:\n"
28685 +
28686 +#ifdef CONFIG_PAX_KERNEXEC
28687 + " movl %%cr0, %0\n"
28688 + " movl %0, %%eax\n"
28689 + " andl $0xFFFEFFFF, %%eax\n"
28690 + " movl %%eax, %%cr0\n"
28691 +#endif
28692 +
28693 + " movw $0x05EB, 1b\n" /* jmp on 5 bytes */
28694 +
28695 +#ifdef CONFIG_PAX_KERNEXEC
28696 + " movl %0, %%cr0\n"
28697 +#endif
28698 +
28699 " jmp 2b\n"
28700 ".previous\n"
28701 _ASM_EXTABLE(1b, 3b)
28702 - : : "r" (from), "r" (to) : "memory");
28703 + : "=&r" (cr0) : "r" (from), "r" (to) : "memory", "ax");
28704
28705 from += 64;
28706 to += 64;
28707 @@ -158,6 +187,7 @@ static void fast_clear_page(void *page)
28708 static void fast_copy_page(void *to, void *from)
28709 {
28710 int i;
28711 + unsigned long cr0;
28712
28713 kernel_fpu_begin();
28714
28715 @@ -166,42 +196,70 @@ static void fast_copy_page(void *to, void *from)
28716 * but that is for later. -AV
28717 */
28718 __asm__ __volatile__(
28719 - "1: prefetch (%0)\n"
28720 - " prefetch 64(%0)\n"
28721 - " prefetch 128(%0)\n"
28722 - " prefetch 192(%0)\n"
28723 - " prefetch 256(%0)\n"
28724 + "1: prefetch (%1)\n"
28725 + " prefetch 64(%1)\n"
28726 + " prefetch 128(%1)\n"
28727 + " prefetch 192(%1)\n"
28728 + " prefetch 256(%1)\n"
28729 "2: \n"
28730 ".section .fixup, \"ax\"\n"
28731 - "3: movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
28732 + "3: \n"
28733 +
28734 +#ifdef CONFIG_PAX_KERNEXEC
28735 + " movl %%cr0, %0\n"
28736 + " movl %0, %%eax\n"
28737 + " andl $0xFFFEFFFF, %%eax\n"
28738 + " movl %%eax, %%cr0\n"
28739 +#endif
28740 +
28741 + " movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
28742 +
28743 +#ifdef CONFIG_PAX_KERNEXEC
28744 + " movl %0, %%cr0\n"
28745 +#endif
28746 +
28747 " jmp 2b\n"
28748 ".previous\n"
28749 - _ASM_EXTABLE(1b, 3b) : : "r" (from));
28750 + _ASM_EXTABLE(1b, 3b) : "=&r" (cr0) : "r" (from) : "ax");
28751
28752 for (i = 0; i < (4096-320)/64; i++) {
28753 __asm__ __volatile__ (
28754 - "1: prefetch 320(%0)\n"
28755 - "2: movq (%0), %%mm0\n"
28756 - " movntq %%mm0, (%1)\n"
28757 - " movq 8(%0), %%mm1\n"
28758 - " movntq %%mm1, 8(%1)\n"
28759 - " movq 16(%0), %%mm2\n"
28760 - " movntq %%mm2, 16(%1)\n"
28761 - " movq 24(%0), %%mm3\n"
28762 - " movntq %%mm3, 24(%1)\n"
28763 - " movq 32(%0), %%mm4\n"
28764 - " movntq %%mm4, 32(%1)\n"
28765 - " movq 40(%0), %%mm5\n"
28766 - " movntq %%mm5, 40(%1)\n"
28767 - " movq 48(%0), %%mm6\n"
28768 - " movntq %%mm6, 48(%1)\n"
28769 - " movq 56(%0), %%mm7\n"
28770 - " movntq %%mm7, 56(%1)\n"
28771 + "1: prefetch 320(%1)\n"
28772 + "2: movq (%1), %%mm0\n"
28773 + " movntq %%mm0, (%2)\n"
28774 + " movq 8(%1), %%mm1\n"
28775 + " movntq %%mm1, 8(%2)\n"
28776 + " movq 16(%1), %%mm2\n"
28777 + " movntq %%mm2, 16(%2)\n"
28778 + " movq 24(%1), %%mm3\n"
28779 + " movntq %%mm3, 24(%2)\n"
28780 + " movq 32(%1), %%mm4\n"
28781 + " movntq %%mm4, 32(%2)\n"
28782 + " movq 40(%1), %%mm5\n"
28783 + " movntq %%mm5, 40(%2)\n"
28784 + " movq 48(%1), %%mm6\n"
28785 + " movntq %%mm6, 48(%2)\n"
28786 + " movq 56(%1), %%mm7\n"
28787 + " movntq %%mm7, 56(%2)\n"
28788 ".section .fixup, \"ax\"\n"
28789 - "3: movw $0x05EB, 1b\n" /* jmp on 5 bytes */
28790 + "3:\n"
28791 +
28792 +#ifdef CONFIG_PAX_KERNEXEC
28793 + " movl %%cr0, %0\n"
28794 + " movl %0, %%eax\n"
28795 + " andl $0xFFFEFFFF, %%eax\n"
28796 + " movl %%eax, %%cr0\n"
28797 +#endif
28798 +
28799 + " movw $0x05EB, 1b\n" /* jmp on 5 bytes */
28800 +
28801 +#ifdef CONFIG_PAX_KERNEXEC
28802 + " movl %0, %%cr0\n"
28803 +#endif
28804 +
28805 " jmp 2b\n"
28806 ".previous\n"
28807 - _ASM_EXTABLE(1b, 3b) : : "r" (from), "r" (to) : "memory");
28808 + _ASM_EXTABLE(1b, 3b) : "=&r" (cr0) : "r" (from), "r" (to) : "memory", "ax");
28809
28810 from += 64;
28811 to += 64;
28812 @@ -280,47 +338,76 @@ static void fast_clear_page(void *page)
28813 static void fast_copy_page(void *to, void *from)
28814 {
28815 int i;
28816 + unsigned long cr0;
28817
28818 kernel_fpu_begin();
28819
28820 __asm__ __volatile__ (
28821 - "1: prefetch (%0)\n"
28822 - " prefetch 64(%0)\n"
28823 - " prefetch 128(%0)\n"
28824 - " prefetch 192(%0)\n"
28825 - " prefetch 256(%0)\n"
28826 + "1: prefetch (%1)\n"
28827 + " prefetch 64(%1)\n"
28828 + " prefetch 128(%1)\n"
28829 + " prefetch 192(%1)\n"
28830 + " prefetch 256(%1)\n"
28831 "2: \n"
28832 ".section .fixup, \"ax\"\n"
28833 - "3: movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
28834 + "3: \n"
28835 +
28836 +#ifdef CONFIG_PAX_KERNEXEC
28837 + " movl %%cr0, %0\n"
28838 + " movl %0, %%eax\n"
28839 + " andl $0xFFFEFFFF, %%eax\n"
28840 + " movl %%eax, %%cr0\n"
28841 +#endif
28842 +
28843 + " movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
28844 +
28845 +#ifdef CONFIG_PAX_KERNEXEC
28846 + " movl %0, %%cr0\n"
28847 +#endif
28848 +
28849 " jmp 2b\n"
28850 ".previous\n"
28851 - _ASM_EXTABLE(1b, 3b) : : "r" (from));
28852 + _ASM_EXTABLE(1b, 3b) : "=&r" (cr0) : "r" (from) : "ax");
28853
28854 for (i = 0; i < 4096/64; i++) {
28855 __asm__ __volatile__ (
28856 - "1: prefetch 320(%0)\n"
28857 - "2: movq (%0), %%mm0\n"
28858 - " movq 8(%0), %%mm1\n"
28859 - " movq 16(%0), %%mm2\n"
28860 - " movq 24(%0), %%mm3\n"
28861 - " movq %%mm0, (%1)\n"
28862 - " movq %%mm1, 8(%1)\n"
28863 - " movq %%mm2, 16(%1)\n"
28864 - " movq %%mm3, 24(%1)\n"
28865 - " movq 32(%0), %%mm0\n"
28866 - " movq 40(%0), %%mm1\n"
28867 - " movq 48(%0), %%mm2\n"
28868 - " movq 56(%0), %%mm3\n"
28869 - " movq %%mm0, 32(%1)\n"
28870 - " movq %%mm1, 40(%1)\n"
28871 - " movq %%mm2, 48(%1)\n"
28872 - " movq %%mm3, 56(%1)\n"
28873 + "1: prefetch 320(%1)\n"
28874 + "2: movq (%1), %%mm0\n"
28875 + " movq 8(%1), %%mm1\n"
28876 + " movq 16(%1), %%mm2\n"
28877 + " movq 24(%1), %%mm3\n"
28878 + " movq %%mm0, (%2)\n"
28879 + " movq %%mm1, 8(%2)\n"
28880 + " movq %%mm2, 16(%2)\n"
28881 + " movq %%mm3, 24(%2)\n"
28882 + " movq 32(%1), %%mm0\n"
28883 + " movq 40(%1), %%mm1\n"
28884 + " movq 48(%1), %%mm2\n"
28885 + " movq 56(%1), %%mm3\n"
28886 + " movq %%mm0, 32(%2)\n"
28887 + " movq %%mm1, 40(%2)\n"
28888 + " movq %%mm2, 48(%2)\n"
28889 + " movq %%mm3, 56(%2)\n"
28890 ".section .fixup, \"ax\"\n"
28891 - "3: movw $0x05EB, 1b\n" /* jmp on 5 bytes */
28892 + "3:\n"
28893 +
28894 +#ifdef CONFIG_PAX_KERNEXEC
28895 + " movl %%cr0, %0\n"
28896 + " movl %0, %%eax\n"
28897 + " andl $0xFFFEFFFF, %%eax\n"
28898 + " movl %%eax, %%cr0\n"
28899 +#endif
28900 +
28901 + " movw $0x05EB, 1b\n" /* jmp on 5 bytes */
28902 +
28903 +#ifdef CONFIG_PAX_KERNEXEC
28904 + " movl %0, %%cr0\n"
28905 +#endif
28906 +
28907 " jmp 2b\n"
28908 ".previous\n"
28909 _ASM_EXTABLE(1b, 3b)
28910 - : : "r" (from), "r" (to) : "memory");
28911 + : "=&r" (cr0) : "r" (from), "r" (to) : "memory", "ax");
28912
28913 from += 64;
28914 to += 64;
28915 diff --git a/arch/x86/lib/msr-reg.S b/arch/x86/lib/msr-reg.S
28916 index f6d13ee..aca5f0b 100644
28917 --- a/arch/x86/lib/msr-reg.S
28918 +++ b/arch/x86/lib/msr-reg.S
28919 @@ -3,6 +3,7 @@
28920 #include <asm/dwarf2.h>
28921 #include <asm/asm.h>
28922 #include <asm/msr.h>
28923 +#include <asm/alternative-asm.h>
28924
28925 #ifdef CONFIG_X86_64
28926 /*
28927 @@ -16,7 +17,7 @@ ENTRY(\op\()_safe_regs)
28928 CFI_STARTPROC
28929 pushq_cfi %rbx
28930 pushq_cfi %rbp
28931 - movq %rdi, %r10 /* Save pointer */
28932 + movq %rdi, %r9 /* Save pointer */
28933 xorl %r11d, %r11d /* Return value */
28934 movl (%rdi), %eax
28935 movl 4(%rdi), %ecx
28936 @@ -27,16 +28,17 @@ ENTRY(\op\()_safe_regs)
28937 movl 28(%rdi), %edi
28938 CFI_REMEMBER_STATE
28939 1: \op
28940 -2: movl %eax, (%r10)
28941 +2: movl %eax, (%r9)
28942 movl %r11d, %eax /* Return value */
28943 - movl %ecx, 4(%r10)
28944 - movl %edx, 8(%r10)
28945 - movl %ebx, 12(%r10)
28946 - movl %ebp, 20(%r10)
28947 - movl %esi, 24(%r10)
28948 - movl %edi, 28(%r10)
28949 + movl %ecx, 4(%r9)
28950 + movl %edx, 8(%r9)
28951 + movl %ebx, 12(%r9)
28952 + movl %ebp, 20(%r9)
28953 + movl %esi, 24(%r9)
28954 + movl %edi, 28(%r9)
28955 popq_cfi %rbp
28956 popq_cfi %rbx
28957 + pax_force_retaddr
28958 ret
28959 3:
28960 CFI_RESTORE_STATE
28961 diff --git a/arch/x86/lib/putuser.S b/arch/x86/lib/putuser.S
28962 index fc6ba17..d4d989d 100644
28963 --- a/arch/x86/lib/putuser.S
28964 +++ b/arch/x86/lib/putuser.S
28965 @@ -16,7 +16,9 @@
28966 #include <asm/errno.h>
28967 #include <asm/asm.h>
28968 #include <asm/smap.h>
28969 -
28970 +#include <asm/segment.h>
28971 +#include <asm/pgtable.h>
28972 +#include <asm/alternative-asm.h>
28973
28974 /*
28975 * __put_user_X
28976 @@ -30,57 +32,125 @@
28977 * as they get called from within inline assembly.
28978 */
28979
28980 -#define ENTER CFI_STARTPROC ; \
28981 - GET_THREAD_INFO(%_ASM_BX)
28982 -#define EXIT ASM_CLAC ; \
28983 - ret ; \
28984 +#define ENTER CFI_STARTPROC
28985 +#define EXIT ASM_CLAC ; \
28986 + pax_force_retaddr ; \
28987 + ret ; \
28988 CFI_ENDPROC
28989
28990 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
28991 +#define _DEST %_ASM_CX,%_ASM_BX
28992 +#else
28993 +#define _DEST %_ASM_CX
28994 +#endif
28995 +
28996 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_MEMORY_UDEREF)
28997 +#define __copyuser_seg gs;
28998 +#else
28999 +#define __copyuser_seg
29000 +#endif
29001 +
29002 .text
29003 ENTRY(__put_user_1)
29004 ENTER
29005 +
29006 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
29007 + GET_THREAD_INFO(%_ASM_BX)
29008 cmp TI_addr_limit(%_ASM_BX),%_ASM_CX
29009 jae bad_put_user
29010 ASM_STAC
29011 -1: movb %al,(%_ASM_CX)
29012 +
29013 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
29014 + mov pax_user_shadow_base,%_ASM_BX
29015 + cmp %_ASM_BX,%_ASM_CX
29016 + jb 1234f
29017 + xor %ebx,%ebx
29018 +1234:
29019 +#endif
29020 +
29021 +#endif
29022 +
29023 +1: __copyuser_seg movb %al,(_DEST)
29024 xor %eax,%eax
29025 EXIT
29026 ENDPROC(__put_user_1)
29027
29028 ENTRY(__put_user_2)
29029 ENTER
29030 +
29031 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
29032 + GET_THREAD_INFO(%_ASM_BX)
29033 mov TI_addr_limit(%_ASM_BX),%_ASM_BX
29034 sub $1,%_ASM_BX
29035 cmp %_ASM_BX,%_ASM_CX
29036 jae bad_put_user
29037 ASM_STAC
29038 -2: movw %ax,(%_ASM_CX)
29039 +
29040 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
29041 + mov pax_user_shadow_base,%_ASM_BX
29042 + cmp %_ASM_BX,%_ASM_CX
29043 + jb 1234f
29044 + xor %ebx,%ebx
29045 +1234:
29046 +#endif
29047 +
29048 +#endif
29049 +
29050 +2: __copyuser_seg movw %ax,(_DEST)
29051 xor %eax,%eax
29052 EXIT
29053 ENDPROC(__put_user_2)
29054
29055 ENTRY(__put_user_4)
29056 ENTER
29057 +
29058 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
29059 + GET_THREAD_INFO(%_ASM_BX)
29060 mov TI_addr_limit(%_ASM_BX),%_ASM_BX
29061 sub $3,%_ASM_BX
29062 cmp %_ASM_BX,%_ASM_CX
29063 jae bad_put_user
29064 ASM_STAC
29065 -3: movl %eax,(%_ASM_CX)
29066 +
29067 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
29068 + mov pax_user_shadow_base,%_ASM_BX
29069 + cmp %_ASM_BX,%_ASM_CX
29070 + jb 1234f
29071 + xor %ebx,%ebx
29072 +1234:
29073 +#endif
29074 +
29075 +#endif
29076 +
29077 +3: __copyuser_seg movl %eax,(_DEST)
29078 xor %eax,%eax
29079 EXIT
29080 ENDPROC(__put_user_4)
29081
29082 ENTRY(__put_user_8)
29083 ENTER
29084 +
29085 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
29086 + GET_THREAD_INFO(%_ASM_BX)
29087 mov TI_addr_limit(%_ASM_BX),%_ASM_BX
29088 sub $7,%_ASM_BX
29089 cmp %_ASM_BX,%_ASM_CX
29090 jae bad_put_user
29091 ASM_STAC
29092 -4: mov %_ASM_AX,(%_ASM_CX)
29093 +
29094 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
29095 + mov pax_user_shadow_base,%_ASM_BX
29096 + cmp %_ASM_BX,%_ASM_CX
29097 + jb 1234f
29098 + xor %ebx,%ebx
29099 +1234:
29100 +#endif
29101 +
29102 +#endif
29103 +
29104 +4: __copyuser_seg mov %_ASM_AX,(_DEST)
29105 #ifdef CONFIG_X86_32
29106 -5: movl %edx,4(%_ASM_CX)
29107 +5: __copyuser_seg movl %edx,4(_DEST)
29108 #endif
29109 xor %eax,%eax
29110 EXIT
29111 diff --git a/arch/x86/lib/rwlock.S b/arch/x86/lib/rwlock.S
29112 index 1cad221..de671ee 100644
29113 --- a/arch/x86/lib/rwlock.S
29114 +++ b/arch/x86/lib/rwlock.S
29115 @@ -16,13 +16,34 @@ ENTRY(__write_lock_failed)
29116 FRAME
29117 0: LOCK_PREFIX
29118 WRITE_LOCK_ADD($RW_LOCK_BIAS) (%__lock_ptr)
29119 +
29120 +#ifdef CONFIG_PAX_REFCOUNT
29121 + jno 1234f
29122 + LOCK_PREFIX
29123 + WRITE_LOCK_SUB($RW_LOCK_BIAS) (%__lock_ptr)
29124 + int $4
29125 +1234:
29126 + _ASM_EXTABLE(1234b, 1234b)
29127 +#endif
29128 +
29129 1: rep; nop
29130 cmpl $WRITE_LOCK_CMP, (%__lock_ptr)
29131 jne 1b
29132 LOCK_PREFIX
29133 WRITE_LOCK_SUB($RW_LOCK_BIAS) (%__lock_ptr)
29134 +
29135 +#ifdef CONFIG_PAX_REFCOUNT
29136 + jno 1234f
29137 + LOCK_PREFIX
29138 + WRITE_LOCK_ADD($RW_LOCK_BIAS) (%__lock_ptr)
29139 + int $4
29140 +1234:
29141 + _ASM_EXTABLE(1234b, 1234b)
29142 +#endif
29143 +
29144 jnz 0b
29145 ENDFRAME
29146 + pax_force_retaddr
29147 ret
29148 CFI_ENDPROC
29149 END(__write_lock_failed)
29150 @@ -32,13 +53,34 @@ ENTRY(__read_lock_failed)
29151 FRAME
29152 0: LOCK_PREFIX
29153 READ_LOCK_SIZE(inc) (%__lock_ptr)
29154 +
29155 +#ifdef CONFIG_PAX_REFCOUNT
29156 + jno 1234f
29157 + LOCK_PREFIX
29158 + READ_LOCK_SIZE(dec) (%__lock_ptr)
29159 + int $4
29160 +1234:
29161 + _ASM_EXTABLE(1234b, 1234b)
29162 +#endif
29163 +
29164 1: rep; nop
29165 READ_LOCK_SIZE(cmp) $1, (%__lock_ptr)
29166 js 1b
29167 LOCK_PREFIX
29168 READ_LOCK_SIZE(dec) (%__lock_ptr)
29169 +
29170 +#ifdef CONFIG_PAX_REFCOUNT
29171 + jno 1234f
29172 + LOCK_PREFIX
29173 + READ_LOCK_SIZE(inc) (%__lock_ptr)
29174 + int $4
29175 +1234:
29176 + _ASM_EXTABLE(1234b, 1234b)
29177 +#endif
29178 +
29179 js 0b
29180 ENDFRAME
29181 + pax_force_retaddr
29182 ret
29183 CFI_ENDPROC
29184 END(__read_lock_failed)
29185 diff --git a/arch/x86/lib/rwsem.S b/arch/x86/lib/rwsem.S
29186 index 5dff5f0..cadebf4 100644
29187 --- a/arch/x86/lib/rwsem.S
29188 +++ b/arch/x86/lib/rwsem.S
29189 @@ -94,6 +94,7 @@ ENTRY(call_rwsem_down_read_failed)
29190 __ASM_SIZE(pop,_cfi) %__ASM_REG(dx)
29191 CFI_RESTORE __ASM_REG(dx)
29192 restore_common_regs
29193 + pax_force_retaddr
29194 ret
29195 CFI_ENDPROC
29196 ENDPROC(call_rwsem_down_read_failed)
29197 @@ -104,6 +105,7 @@ ENTRY(call_rwsem_down_write_failed)
29198 movq %rax,%rdi
29199 call rwsem_down_write_failed
29200 restore_common_regs
29201 + pax_force_retaddr
29202 ret
29203 CFI_ENDPROC
29204 ENDPROC(call_rwsem_down_write_failed)
29205 @@ -117,7 +119,8 @@ ENTRY(call_rwsem_wake)
29206 movq %rax,%rdi
29207 call rwsem_wake
29208 restore_common_regs
29209 -1: ret
29210 +1: pax_force_retaddr
29211 + ret
29212 CFI_ENDPROC
29213 ENDPROC(call_rwsem_wake)
29214
29215 @@ -131,6 +134,7 @@ ENTRY(call_rwsem_downgrade_wake)
29216 __ASM_SIZE(pop,_cfi) %__ASM_REG(dx)
29217 CFI_RESTORE __ASM_REG(dx)
29218 restore_common_regs
29219 + pax_force_retaddr
29220 ret
29221 CFI_ENDPROC
29222 ENDPROC(call_rwsem_downgrade_wake)
29223 diff --git a/arch/x86/lib/thunk_64.S b/arch/x86/lib/thunk_64.S
29224 index a63efd6..ccecad8 100644
29225 --- a/arch/x86/lib/thunk_64.S
29226 +++ b/arch/x86/lib/thunk_64.S
29227 @@ -8,6 +8,7 @@
29228 #include <linux/linkage.h>
29229 #include <asm/dwarf2.h>
29230 #include <asm/calling.h>
29231 +#include <asm/alternative-asm.h>
29232
29233 /* rdi: arg1 ... normal C conventions. rax is saved/restored. */
29234 .macro THUNK name, func, put_ret_addr_in_rdi=0
29235 @@ -41,5 +42,6 @@
29236 SAVE_ARGS
29237 restore:
29238 RESTORE_ARGS
29239 + pax_force_retaddr
29240 ret
29241 CFI_ENDPROC
29242 diff --git a/arch/x86/lib/usercopy_32.c b/arch/x86/lib/usercopy_32.c
29243 index 3eb18ac..4b22130 100644
29244 --- a/arch/x86/lib/usercopy_32.c
29245 +++ b/arch/x86/lib/usercopy_32.c
29246 @@ -42,11 +42,13 @@ do { \
29247 int __d0; \
29248 might_fault(); \
29249 __asm__ __volatile__( \
29250 + __COPYUSER_SET_ES \
29251 ASM_STAC "\n" \
29252 "0: rep; stosl\n" \
29253 " movl %2,%0\n" \
29254 "1: rep; stosb\n" \
29255 "2: " ASM_CLAC "\n" \
29256 + __COPYUSER_RESTORE_ES \
29257 ".section .fixup,\"ax\"\n" \
29258 "3: lea 0(%2,%0,4),%0\n" \
29259 " jmp 2b\n" \
29260 @@ -98,7 +100,7 @@ EXPORT_SYMBOL(__clear_user);
29261
29262 #ifdef CONFIG_X86_INTEL_USERCOPY
29263 static unsigned long
29264 -__copy_user_intel(void __user *to, const void *from, unsigned long size)
29265 +__generic_copy_to_user_intel(void __user *to, const void *from, unsigned long size)
29266 {
29267 int d0, d1;
29268 __asm__ __volatile__(
29269 @@ -110,36 +112,36 @@ __copy_user_intel(void __user *to, const void *from, unsigned long size)
29270 " .align 2,0x90\n"
29271 "3: movl 0(%4), %%eax\n"
29272 "4: movl 4(%4), %%edx\n"
29273 - "5: movl %%eax, 0(%3)\n"
29274 - "6: movl %%edx, 4(%3)\n"
29275 + "5: "__copyuser_seg" movl %%eax, 0(%3)\n"
29276 + "6: "__copyuser_seg" movl %%edx, 4(%3)\n"
29277 "7: movl 8(%4), %%eax\n"
29278 "8: movl 12(%4),%%edx\n"
29279 - "9: movl %%eax, 8(%3)\n"
29280 - "10: movl %%edx, 12(%3)\n"
29281 + "9: "__copyuser_seg" movl %%eax, 8(%3)\n"
29282 + "10: "__copyuser_seg" movl %%edx, 12(%3)\n"
29283 "11: movl 16(%4), %%eax\n"
29284 "12: movl 20(%4), %%edx\n"
29285 - "13: movl %%eax, 16(%3)\n"
29286 - "14: movl %%edx, 20(%3)\n"
29287 + "13: "__copyuser_seg" movl %%eax, 16(%3)\n"
29288 + "14: "__copyuser_seg" movl %%edx, 20(%3)\n"
29289 "15: movl 24(%4), %%eax\n"
29290 "16: movl 28(%4), %%edx\n"
29291 - "17: movl %%eax, 24(%3)\n"
29292 - "18: movl %%edx, 28(%3)\n"
29293 + "17: "__copyuser_seg" movl %%eax, 24(%3)\n"
29294 + "18: "__copyuser_seg" movl %%edx, 28(%3)\n"
29295 "19: movl 32(%4), %%eax\n"
29296 "20: movl 36(%4), %%edx\n"
29297 - "21: movl %%eax, 32(%3)\n"
29298 - "22: movl %%edx, 36(%3)\n"
29299 + "21: "__copyuser_seg" movl %%eax, 32(%3)\n"
29300 + "22: "__copyuser_seg" movl %%edx, 36(%3)\n"
29301 "23: movl 40(%4), %%eax\n"
29302 "24: movl 44(%4), %%edx\n"
29303 - "25: movl %%eax, 40(%3)\n"
29304 - "26: movl %%edx, 44(%3)\n"
29305 + "25: "__copyuser_seg" movl %%eax, 40(%3)\n"
29306 + "26: "__copyuser_seg" movl %%edx, 44(%3)\n"
29307 "27: movl 48(%4), %%eax\n"
29308 "28: movl 52(%4), %%edx\n"
29309 - "29: movl %%eax, 48(%3)\n"
29310 - "30: movl %%edx, 52(%3)\n"
29311 + "29: "__copyuser_seg" movl %%eax, 48(%3)\n"
29312 + "30: "__copyuser_seg" movl %%edx, 52(%3)\n"
29313 "31: movl 56(%4), %%eax\n"
29314 "32: movl 60(%4), %%edx\n"
29315 - "33: movl %%eax, 56(%3)\n"
29316 - "34: movl %%edx, 60(%3)\n"
29317 + "33: "__copyuser_seg" movl %%eax, 56(%3)\n"
29318 + "34: "__copyuser_seg" movl %%edx, 60(%3)\n"
29319 " addl $-64, %0\n"
29320 " addl $64, %4\n"
29321 " addl $64, %3\n"
29322 @@ -149,10 +151,116 @@ __copy_user_intel(void __user *to, const void *from, unsigned long size)
29323 " shrl $2, %0\n"
29324 " andl $3, %%eax\n"
29325 " cld\n"
29326 + __COPYUSER_SET_ES
29327 "99: rep; movsl\n"
29328 "36: movl %%eax, %0\n"
29329 "37: rep; movsb\n"
29330 "100:\n"
29331 + __COPYUSER_RESTORE_ES
29332 + ".section .fixup,\"ax\"\n"
29333 + "101: lea 0(%%eax,%0,4),%0\n"
29334 + " jmp 100b\n"
29335 + ".previous\n"
29336 + _ASM_EXTABLE(1b,100b)
29337 + _ASM_EXTABLE(2b,100b)
29338 + _ASM_EXTABLE(3b,100b)
29339 + _ASM_EXTABLE(4b,100b)
29340 + _ASM_EXTABLE(5b,100b)
29341 + _ASM_EXTABLE(6b,100b)
29342 + _ASM_EXTABLE(7b,100b)
29343 + _ASM_EXTABLE(8b,100b)
29344 + _ASM_EXTABLE(9b,100b)
29345 + _ASM_EXTABLE(10b,100b)
29346 + _ASM_EXTABLE(11b,100b)
29347 + _ASM_EXTABLE(12b,100b)
29348 + _ASM_EXTABLE(13b,100b)
29349 + _ASM_EXTABLE(14b,100b)
29350 + _ASM_EXTABLE(15b,100b)
29351 + _ASM_EXTABLE(16b,100b)
29352 + _ASM_EXTABLE(17b,100b)
29353 + _ASM_EXTABLE(18b,100b)
29354 + _ASM_EXTABLE(19b,100b)
29355 + _ASM_EXTABLE(20b,100b)
29356 + _ASM_EXTABLE(21b,100b)
29357 + _ASM_EXTABLE(22b,100b)
29358 + _ASM_EXTABLE(23b,100b)
29359 + _ASM_EXTABLE(24b,100b)
29360 + _ASM_EXTABLE(25b,100b)
29361 + _ASM_EXTABLE(26b,100b)
29362 + _ASM_EXTABLE(27b,100b)
29363 + _ASM_EXTABLE(28b,100b)
29364 + _ASM_EXTABLE(29b,100b)
29365 + _ASM_EXTABLE(30b,100b)
29366 + _ASM_EXTABLE(31b,100b)
29367 + _ASM_EXTABLE(32b,100b)
29368 + _ASM_EXTABLE(33b,100b)
29369 + _ASM_EXTABLE(34b,100b)
29370 + _ASM_EXTABLE(35b,100b)
29371 + _ASM_EXTABLE(36b,100b)
29372 + _ASM_EXTABLE(37b,100b)
29373 + _ASM_EXTABLE(99b,101b)
29374 + : "=&c"(size), "=&D" (d0), "=&S" (d1)
29375 + : "1"(to), "2"(from), "0"(size)
29376 + : "eax", "edx", "memory");
29377 + return size;
29378 +}
29379 +
29380 +static unsigned long
29381 +__generic_copy_from_user_intel(void *to, const void __user *from, unsigned long size)
29382 +{
29383 + int d0, d1;
29384 + __asm__ __volatile__(
29385 + " .align 2,0x90\n"
29386 + "1: "__copyuser_seg" movl 32(%4), %%eax\n"
29387 + " cmpl $67, %0\n"
29388 + " jbe 3f\n"
29389 + "2: "__copyuser_seg" movl 64(%4), %%eax\n"
29390 + " .align 2,0x90\n"
29391 + "3: "__copyuser_seg" movl 0(%4), %%eax\n"
29392 + "4: "__copyuser_seg" movl 4(%4), %%edx\n"
29393 + "5: movl %%eax, 0(%3)\n"
29394 + "6: movl %%edx, 4(%3)\n"
29395 + "7: "__copyuser_seg" movl 8(%4), %%eax\n"
29396 + "8: "__copyuser_seg" movl 12(%4),%%edx\n"
29397 + "9: movl %%eax, 8(%3)\n"
29398 + "10: movl %%edx, 12(%3)\n"
29399 + "11: "__copyuser_seg" movl 16(%4), %%eax\n"
29400 + "12: "__copyuser_seg" movl 20(%4), %%edx\n"
29401 + "13: movl %%eax, 16(%3)\n"
29402 + "14: movl %%edx, 20(%3)\n"
29403 + "15: "__copyuser_seg" movl 24(%4), %%eax\n"
29404 + "16: "__copyuser_seg" movl 28(%4), %%edx\n"
29405 + "17: movl %%eax, 24(%3)\n"
29406 + "18: movl %%edx, 28(%3)\n"
29407 + "19: "__copyuser_seg" movl 32(%4), %%eax\n"
29408 + "20: "__copyuser_seg" movl 36(%4), %%edx\n"
29409 + "21: movl %%eax, 32(%3)\n"
29410 + "22: movl %%edx, 36(%3)\n"
29411 + "23: "__copyuser_seg" movl 40(%4), %%eax\n"
29412 + "24: "__copyuser_seg" movl 44(%4), %%edx\n"
29413 + "25: movl %%eax, 40(%3)\n"
29414 + "26: movl %%edx, 44(%3)\n"
29415 + "27: "__copyuser_seg" movl 48(%4), %%eax\n"
29416 + "28: "__copyuser_seg" movl 52(%4), %%edx\n"
29417 + "29: movl %%eax, 48(%3)\n"
29418 + "30: movl %%edx, 52(%3)\n"
29419 + "31: "__copyuser_seg" movl 56(%4), %%eax\n"
29420 + "32: "__copyuser_seg" movl 60(%4), %%edx\n"
29421 + "33: movl %%eax, 56(%3)\n"
29422 + "34: movl %%edx, 60(%3)\n"
29423 + " addl $-64, %0\n"
29424 + " addl $64, %4\n"
29425 + " addl $64, %3\n"
29426 + " cmpl $63, %0\n"
29427 + " ja 1b\n"
29428 + "35: movl %0, %%eax\n"
29429 + " shrl $2, %0\n"
29430 + " andl $3, %%eax\n"
29431 + " cld\n"
29432 + "99: rep; "__copyuser_seg" movsl\n"
29433 + "36: movl %%eax, %0\n"
29434 + "37: rep; "__copyuser_seg" movsb\n"
29435 + "100:\n"
29436 ".section .fixup,\"ax\"\n"
29437 "101: lea 0(%%eax,%0,4),%0\n"
29438 " jmp 100b\n"
29439 @@ -207,41 +315,41 @@ __copy_user_zeroing_intel(void *to, const void __user *from, unsigned long size)
29440 int d0, d1;
29441 __asm__ __volatile__(
29442 " .align 2,0x90\n"
29443 - "0: movl 32(%4), %%eax\n"
29444 + "0: "__copyuser_seg" movl 32(%4), %%eax\n"
29445 " cmpl $67, %0\n"
29446 " jbe 2f\n"
29447 - "1: movl 64(%4), %%eax\n"
29448 + "1: "__copyuser_seg" movl 64(%4), %%eax\n"
29449 " .align 2,0x90\n"
29450 - "2: movl 0(%4), %%eax\n"
29451 - "21: movl 4(%4), %%edx\n"
29452 + "2: "__copyuser_seg" movl 0(%4), %%eax\n"
29453 + "21: "__copyuser_seg" movl 4(%4), %%edx\n"
29454 " movl %%eax, 0(%3)\n"
29455 " movl %%edx, 4(%3)\n"
29456 - "3: movl 8(%4), %%eax\n"
29457 - "31: movl 12(%4),%%edx\n"
29458 + "3: "__copyuser_seg" movl 8(%4), %%eax\n"
29459 + "31: "__copyuser_seg" movl 12(%4),%%edx\n"
29460 " movl %%eax, 8(%3)\n"
29461 " movl %%edx, 12(%3)\n"
29462 - "4: movl 16(%4), %%eax\n"
29463 - "41: movl 20(%4), %%edx\n"
29464 + "4: "__copyuser_seg" movl 16(%4), %%eax\n"
29465 + "41: "__copyuser_seg" movl 20(%4), %%edx\n"
29466 " movl %%eax, 16(%3)\n"
29467 " movl %%edx, 20(%3)\n"
29468 - "10: movl 24(%4), %%eax\n"
29469 - "51: movl 28(%4), %%edx\n"
29470 + "10: "__copyuser_seg" movl 24(%4), %%eax\n"
29471 + "51: "__copyuser_seg" movl 28(%4), %%edx\n"
29472 " movl %%eax, 24(%3)\n"
29473 " movl %%edx, 28(%3)\n"
29474 - "11: movl 32(%4), %%eax\n"
29475 - "61: movl 36(%4), %%edx\n"
29476 + "11: "__copyuser_seg" movl 32(%4), %%eax\n"
29477 + "61: "__copyuser_seg" movl 36(%4), %%edx\n"
29478 " movl %%eax, 32(%3)\n"
29479 " movl %%edx, 36(%3)\n"
29480 - "12: movl 40(%4), %%eax\n"
29481 - "71: movl 44(%4), %%edx\n"
29482 + "12: "__copyuser_seg" movl 40(%4), %%eax\n"
29483 + "71: "__copyuser_seg" movl 44(%4), %%edx\n"
29484 " movl %%eax, 40(%3)\n"
29485 " movl %%edx, 44(%3)\n"
29486 - "13: movl 48(%4), %%eax\n"
29487 - "81: movl 52(%4), %%edx\n"
29488 + "13: "__copyuser_seg" movl 48(%4), %%eax\n"
29489 + "81: "__copyuser_seg" movl 52(%4), %%edx\n"
29490 " movl %%eax, 48(%3)\n"
29491 " movl %%edx, 52(%3)\n"
29492 - "14: movl 56(%4), %%eax\n"
29493 - "91: movl 60(%4), %%edx\n"
29494 + "14: "__copyuser_seg" movl 56(%4), %%eax\n"
29495 + "91: "__copyuser_seg" movl 60(%4), %%edx\n"
29496 " movl %%eax, 56(%3)\n"
29497 " movl %%edx, 60(%3)\n"
29498 " addl $-64, %0\n"
29499 @@ -253,9 +361,9 @@ __copy_user_zeroing_intel(void *to, const void __user *from, unsigned long size)
29500 " shrl $2, %0\n"
29501 " andl $3, %%eax\n"
29502 " cld\n"
29503 - "6: rep; movsl\n"
29504 + "6: rep; "__copyuser_seg" movsl\n"
29505 " movl %%eax,%0\n"
29506 - "7: rep; movsb\n"
29507 + "7: rep; "__copyuser_seg" movsb\n"
29508 "8:\n"
29509 ".section .fixup,\"ax\"\n"
29510 "9: lea 0(%%eax,%0,4),%0\n"
29511 @@ -305,41 +413,41 @@ static unsigned long __copy_user_zeroing_intel_nocache(void *to,
29512
29513 __asm__ __volatile__(
29514 " .align 2,0x90\n"
29515 - "0: movl 32(%4), %%eax\n"
29516 + "0: "__copyuser_seg" movl 32(%4), %%eax\n"
29517 " cmpl $67, %0\n"
29518 " jbe 2f\n"
29519 - "1: movl 64(%4), %%eax\n"
29520 + "1: "__copyuser_seg" movl 64(%4), %%eax\n"
29521 " .align 2,0x90\n"
29522 - "2: movl 0(%4), %%eax\n"
29523 - "21: movl 4(%4), %%edx\n"
29524 + "2: "__copyuser_seg" movl 0(%4), %%eax\n"
29525 + "21: "__copyuser_seg" movl 4(%4), %%edx\n"
29526 " movnti %%eax, 0(%3)\n"
29527 " movnti %%edx, 4(%3)\n"
29528 - "3: movl 8(%4), %%eax\n"
29529 - "31: movl 12(%4),%%edx\n"
29530 + "3: "__copyuser_seg" movl 8(%4), %%eax\n"
29531 + "31: "__copyuser_seg" movl 12(%4),%%edx\n"
29532 " movnti %%eax, 8(%3)\n"
29533 " movnti %%edx, 12(%3)\n"
29534 - "4: movl 16(%4), %%eax\n"
29535 - "41: movl 20(%4), %%edx\n"
29536 + "4: "__copyuser_seg" movl 16(%4), %%eax\n"
29537 + "41: "__copyuser_seg" movl 20(%4), %%edx\n"
29538 " movnti %%eax, 16(%3)\n"
29539 " movnti %%edx, 20(%3)\n"
29540 - "10: movl 24(%4), %%eax\n"
29541 - "51: movl 28(%4), %%edx\n"
29542 + "10: "__copyuser_seg" movl 24(%4), %%eax\n"
29543 + "51: "__copyuser_seg" movl 28(%4), %%edx\n"
29544 " movnti %%eax, 24(%3)\n"
29545 " movnti %%edx, 28(%3)\n"
29546 - "11: movl 32(%4), %%eax\n"
29547 - "61: movl 36(%4), %%edx\n"
29548 + "11: "__copyuser_seg" movl 32(%4), %%eax\n"
29549 + "61: "__copyuser_seg" movl 36(%4), %%edx\n"
29550 " movnti %%eax, 32(%3)\n"
29551 " movnti %%edx, 36(%3)\n"
29552 - "12: movl 40(%4), %%eax\n"
29553 - "71: movl 44(%4), %%edx\n"
29554 + "12: "__copyuser_seg" movl 40(%4), %%eax\n"
29555 + "71: "__copyuser_seg" movl 44(%4), %%edx\n"
29556 " movnti %%eax, 40(%3)\n"
29557 " movnti %%edx, 44(%3)\n"
29558 - "13: movl 48(%4), %%eax\n"
29559 - "81: movl 52(%4), %%edx\n"
29560 + "13: "__copyuser_seg" movl 48(%4), %%eax\n"
29561 + "81: "__copyuser_seg" movl 52(%4), %%edx\n"
29562 " movnti %%eax, 48(%3)\n"
29563 " movnti %%edx, 52(%3)\n"
29564 - "14: movl 56(%4), %%eax\n"
29565 - "91: movl 60(%4), %%edx\n"
29566 + "14: "__copyuser_seg" movl 56(%4), %%eax\n"
29567 + "91: "__copyuser_seg" movl 60(%4), %%edx\n"
29568 " movnti %%eax, 56(%3)\n"
29569 " movnti %%edx, 60(%3)\n"
29570 " addl $-64, %0\n"
29571 @@ -352,9 +460,9 @@ static unsigned long __copy_user_zeroing_intel_nocache(void *to,
29572 " shrl $2, %0\n"
29573 " andl $3, %%eax\n"
29574 " cld\n"
29575 - "6: rep; movsl\n"
29576 + "6: rep; "__copyuser_seg" movsl\n"
29577 " movl %%eax,%0\n"
29578 - "7: rep; movsb\n"
29579 + "7: rep; "__copyuser_seg" movsb\n"
29580 "8:\n"
29581 ".section .fixup,\"ax\"\n"
29582 "9: lea 0(%%eax,%0,4),%0\n"
29583 @@ -399,41 +507,41 @@ static unsigned long __copy_user_intel_nocache(void *to,
29584
29585 __asm__ __volatile__(
29586 " .align 2,0x90\n"
29587 - "0: movl 32(%4), %%eax\n"
29588 + "0: "__copyuser_seg" movl 32(%4), %%eax\n"
29589 " cmpl $67, %0\n"
29590 " jbe 2f\n"
29591 - "1: movl 64(%4), %%eax\n"
29592 + "1: "__copyuser_seg" movl 64(%4), %%eax\n"
29593 " .align 2,0x90\n"
29594 - "2: movl 0(%4), %%eax\n"
29595 - "21: movl 4(%4), %%edx\n"
29596 + "2: "__copyuser_seg" movl 0(%4), %%eax\n"
29597 + "21: "__copyuser_seg" movl 4(%4), %%edx\n"
29598 " movnti %%eax, 0(%3)\n"
29599 " movnti %%edx, 4(%3)\n"
29600 - "3: movl 8(%4), %%eax\n"
29601 - "31: movl 12(%4),%%edx\n"
29602 + "3: "__copyuser_seg" movl 8(%4), %%eax\n"
29603 + "31: "__copyuser_seg" movl 12(%4),%%edx\n"
29604 " movnti %%eax, 8(%3)\n"
29605 " movnti %%edx, 12(%3)\n"
29606 - "4: movl 16(%4), %%eax\n"
29607 - "41: movl 20(%4), %%edx\n"
29608 + "4: "__copyuser_seg" movl 16(%4), %%eax\n"
29609 + "41: "__copyuser_seg" movl 20(%4), %%edx\n"
29610 " movnti %%eax, 16(%3)\n"
29611 " movnti %%edx, 20(%3)\n"
29612 - "10: movl 24(%4), %%eax\n"
29613 - "51: movl 28(%4), %%edx\n"
29614 + "10: "__copyuser_seg" movl 24(%4), %%eax\n"
29615 + "51: "__copyuser_seg" movl 28(%4), %%edx\n"
29616 " movnti %%eax, 24(%3)\n"
29617 " movnti %%edx, 28(%3)\n"
29618 - "11: movl 32(%4), %%eax\n"
29619 - "61: movl 36(%4), %%edx\n"
29620 + "11: "__copyuser_seg" movl 32(%4), %%eax\n"
29621 + "61: "__copyuser_seg" movl 36(%4), %%edx\n"
29622 " movnti %%eax, 32(%3)\n"
29623 " movnti %%edx, 36(%3)\n"
29624 - "12: movl 40(%4), %%eax\n"
29625 - "71: movl 44(%4), %%edx\n"
29626 + "12: "__copyuser_seg" movl 40(%4), %%eax\n"
29627 + "71: "__copyuser_seg" movl 44(%4), %%edx\n"
29628 " movnti %%eax, 40(%3)\n"
29629 " movnti %%edx, 44(%3)\n"
29630 - "13: movl 48(%4), %%eax\n"
29631 - "81: movl 52(%4), %%edx\n"
29632 + "13: "__copyuser_seg" movl 48(%4), %%eax\n"
29633 + "81: "__copyuser_seg" movl 52(%4), %%edx\n"
29634 " movnti %%eax, 48(%3)\n"
29635 " movnti %%edx, 52(%3)\n"
29636 - "14: movl 56(%4), %%eax\n"
29637 - "91: movl 60(%4), %%edx\n"
29638 + "14: "__copyuser_seg" movl 56(%4), %%eax\n"
29639 + "91: "__copyuser_seg" movl 60(%4), %%edx\n"
29640 " movnti %%eax, 56(%3)\n"
29641 " movnti %%edx, 60(%3)\n"
29642 " addl $-64, %0\n"
29643 @@ -446,9 +554,9 @@ static unsigned long __copy_user_intel_nocache(void *to,
29644 " shrl $2, %0\n"
29645 " andl $3, %%eax\n"
29646 " cld\n"
29647 - "6: rep; movsl\n"
29648 + "6: rep; "__copyuser_seg" movsl\n"
29649 " movl %%eax,%0\n"
29650 - "7: rep; movsb\n"
29651 + "7: rep; "__copyuser_seg" movsb\n"
29652 "8:\n"
29653 ".section .fixup,\"ax\"\n"
29654 "9: lea 0(%%eax,%0,4),%0\n"
29655 @@ -488,32 +596,36 @@ static unsigned long __copy_user_intel_nocache(void *to,
29656 */
29657 unsigned long __copy_user_zeroing_intel(void *to, const void __user *from,
29658 unsigned long size);
29659 -unsigned long __copy_user_intel(void __user *to, const void *from,
29660 +unsigned long __generic_copy_to_user_intel(void __user *to, const void *from,
29661 + unsigned long size);
29662 +unsigned long __generic_copy_from_user_intel(void *to, const void __user *from,
29663 unsigned long size);
29664 unsigned long __copy_user_zeroing_intel_nocache(void *to,
29665 const void __user *from, unsigned long size);
29666 #endif /* CONFIG_X86_INTEL_USERCOPY */
29667
29668 /* Generic arbitrary sized copy. */
29669 -#define __copy_user(to, from, size) \
29670 +#define __copy_user(to, from, size, prefix, set, restore) \
29671 do { \
29672 int __d0, __d1, __d2; \
29673 __asm__ __volatile__( \
29674 + set \
29675 " cmp $7,%0\n" \
29676 " jbe 1f\n" \
29677 " movl %1,%0\n" \
29678 " negl %0\n" \
29679 " andl $7,%0\n" \
29680 " subl %0,%3\n" \
29681 - "4: rep; movsb\n" \
29682 + "4: rep; "prefix"movsb\n" \
29683 " movl %3,%0\n" \
29684 " shrl $2,%0\n" \
29685 " andl $3,%3\n" \
29686 " .align 2,0x90\n" \
29687 - "0: rep; movsl\n" \
29688 + "0: rep; "prefix"movsl\n" \
29689 " movl %3,%0\n" \
29690 - "1: rep; movsb\n" \
29691 + "1: rep; "prefix"movsb\n" \
29692 "2:\n" \
29693 + restore \
29694 ".section .fixup,\"ax\"\n" \
29695 "5: addl %3,%0\n" \
29696 " jmp 2b\n" \
29697 @@ -538,14 +650,14 @@ do { \
29698 " negl %0\n" \
29699 " andl $7,%0\n" \
29700 " subl %0,%3\n" \
29701 - "4: rep; movsb\n" \
29702 + "4: rep; "__copyuser_seg"movsb\n" \
29703 " movl %3,%0\n" \
29704 " shrl $2,%0\n" \
29705 " andl $3,%3\n" \
29706 " .align 2,0x90\n" \
29707 - "0: rep; movsl\n" \
29708 + "0: rep; "__copyuser_seg"movsl\n" \
29709 " movl %3,%0\n" \
29710 - "1: rep; movsb\n" \
29711 + "1: rep; "__copyuser_seg"movsb\n" \
29712 "2:\n" \
29713 ".section .fixup,\"ax\"\n" \
29714 "5: addl %3,%0\n" \
29715 @@ -572,9 +684,9 @@ unsigned long __copy_to_user_ll(void __user *to, const void *from,
29716 {
29717 stac();
29718 if (movsl_is_ok(to, from, n))
29719 - __copy_user(to, from, n);
29720 + __copy_user(to, from, n, "", __COPYUSER_SET_ES, __COPYUSER_RESTORE_ES);
29721 else
29722 - n = __copy_user_intel(to, from, n);
29723 + n = __generic_copy_to_user_intel(to, from, n);
29724 clac();
29725 return n;
29726 }
29727 @@ -598,10 +710,9 @@ unsigned long __copy_from_user_ll_nozero(void *to, const void __user *from,
29728 {
29729 stac();
29730 if (movsl_is_ok(to, from, n))
29731 - __copy_user(to, from, n);
29732 + __copy_user(to, from, n, __copyuser_seg, "", "");
29733 else
29734 - n = __copy_user_intel((void __user *)to,
29735 - (const void *)from, n);
29736 + n = __generic_copy_from_user_intel(to, from, n);
29737 clac();
29738 return n;
29739 }
29740 @@ -632,60 +743,38 @@ unsigned long __copy_from_user_ll_nocache_nozero(void *to, const void __user *fr
29741 if (n > 64 && cpu_has_xmm2)
29742 n = __copy_user_intel_nocache(to, from, n);
29743 else
29744 - __copy_user(to, from, n);
29745 + __copy_user(to, from, n, __copyuser_seg, "", "");
29746 #else
29747 - __copy_user(to, from, n);
29748 + __copy_user(to, from, n, __copyuser_seg, "", "");
29749 #endif
29750 clac();
29751 return n;
29752 }
29753 EXPORT_SYMBOL(__copy_from_user_ll_nocache_nozero);
29754
29755 -/**
29756 - * copy_to_user: - Copy a block of data into user space.
29757 - * @to: Destination address, in user space.
29758 - * @from: Source address, in kernel space.
29759 - * @n: Number of bytes to copy.
29760 - *
29761 - * Context: User context only. This function may sleep.
29762 - *
29763 - * Copy data from kernel space to user space.
29764 - *
29765 - * Returns number of bytes that could not be copied.
29766 - * On success, this will be zero.
29767 - */
29768 -unsigned long
29769 -copy_to_user(void __user *to, const void *from, unsigned long n)
29770 +#ifdef CONFIG_PAX_MEMORY_UDEREF
29771 +void __set_fs(mm_segment_t x)
29772 {
29773 - if (access_ok(VERIFY_WRITE, to, n))
29774 - n = __copy_to_user(to, from, n);
29775 - return n;
29776 + switch (x.seg) {
29777 + case 0:
29778 + loadsegment(gs, 0);
29779 + break;
29780 + case TASK_SIZE_MAX:
29781 + loadsegment(gs, __USER_DS);
29782 + break;
29783 + case -1UL:
29784 + loadsegment(gs, __KERNEL_DS);
29785 + break;
29786 + default:
29787 + BUG();
29788 + }
29789 }
29790 -EXPORT_SYMBOL(copy_to_user);
29791 +EXPORT_SYMBOL(__set_fs);
29792
29793 -/**
29794 - * copy_from_user: - Copy a block of data from user space.
29795 - * @to: Destination address, in kernel space.
29796 - * @from: Source address, in user space.
29797 - * @n: Number of bytes to copy.
29798 - *
29799 - * Context: User context only. This function may sleep.
29800 - *
29801 - * Copy data from user space to kernel space.
29802 - *
29803 - * Returns number of bytes that could not be copied.
29804 - * On success, this will be zero.
29805 - *
29806 - * If some data could not be copied, this function will pad the copied
29807 - * data to the requested size using zero bytes.
29808 - */
29809 -unsigned long
29810 -_copy_from_user(void *to, const void __user *from, unsigned long n)
29811 +void set_fs(mm_segment_t x)
29812 {
29813 - if (access_ok(VERIFY_READ, from, n))
29814 - n = __copy_from_user(to, from, n);
29815 - else
29816 - memset(to, 0, n);
29817 - return n;
29818 + current_thread_info()->addr_limit = x;
29819 + __set_fs(x);
29820 }
29821 -EXPORT_SYMBOL(_copy_from_user);
29822 +EXPORT_SYMBOL(set_fs);
29823 +#endif
29824 diff --git a/arch/x86/lib/usercopy_64.c b/arch/x86/lib/usercopy_64.c
29825 index c905e89..01ab928 100644
29826 --- a/arch/x86/lib/usercopy_64.c
29827 +++ b/arch/x86/lib/usercopy_64.c
29828 @@ -18,6 +18,7 @@ unsigned long __clear_user(void __user *addr, unsigned long size)
29829 might_fault();
29830 /* no memory constraint because it doesn't change any memory gcc knows
29831 about */
29832 + pax_open_userland();
29833 stac();
29834 asm volatile(
29835 " testq %[size8],%[size8]\n"
29836 @@ -39,9 +40,10 @@ unsigned long __clear_user(void __user *addr, unsigned long size)
29837 _ASM_EXTABLE(0b,3b)
29838 _ASM_EXTABLE(1b,2b)
29839 : [size8] "=&c"(size), [dst] "=&D" (__d0)
29840 - : [size1] "r"(size & 7), "[size8]" (size / 8), "[dst]"(addr),
29841 + : [size1] "r"(size & 7), "[size8]" (size / 8), "[dst]"(____m(addr)),
29842 [zero] "r" (0UL), [eight] "r" (8UL));
29843 clac();
29844 + pax_close_userland();
29845 return size;
29846 }
29847 EXPORT_SYMBOL(__clear_user);
29848 @@ -54,12 +56,11 @@ unsigned long clear_user(void __user *to, unsigned long n)
29849 }
29850 EXPORT_SYMBOL(clear_user);
29851
29852 -unsigned long copy_in_user(void __user *to, const void __user *from, unsigned len)
29853 +unsigned long copy_in_user(void __user *to, const void __user *from, unsigned long len)
29854 {
29855 - if (access_ok(VERIFY_WRITE, to, len) && access_ok(VERIFY_READ, from, len)) {
29856 - return copy_user_generic((__force void *)to, (__force void *)from, len);
29857 - }
29858 - return len;
29859 + if (access_ok(VERIFY_WRITE, to, len) && access_ok(VERIFY_READ, from, len))
29860 + return copy_user_generic((void __force_kernel *)____m(to), (void __force_kernel *)____m(from), len);
29861 + return len;
29862 }
29863 EXPORT_SYMBOL(copy_in_user);
29864
29865 @@ -69,11 +70,13 @@ EXPORT_SYMBOL(copy_in_user);
29866 * it is not necessary to optimize tail handling.
29867 */
29868 __visible unsigned long
29869 -copy_user_handle_tail(char *to, char *from, unsigned len, unsigned zerorest)
29870 +copy_user_handle_tail(char __user *to, char __user *from, unsigned long len, unsigned zerorest)
29871 {
29872 char c;
29873 unsigned zero_len;
29874
29875 + clac();
29876 + pax_close_userland();
29877 for (; len; --len, to++) {
29878 if (__get_user_nocheck(c, from++, sizeof(char)))
29879 break;
29880 @@ -84,6 +87,5 @@ copy_user_handle_tail(char *to, char *from, unsigned len, unsigned zerorest)
29881 for (c = 0, zero_len = len; zerorest && zero_len; --zero_len)
29882 if (__put_user_nocheck(c, to++, sizeof(char)))
29883 break;
29884 - clac();
29885 return len;
29886 }
29887 diff --git a/arch/x86/mm/Makefile b/arch/x86/mm/Makefile
29888 index 23d8e5f..9ccc13a 100644
29889 --- a/arch/x86/mm/Makefile
29890 +++ b/arch/x86/mm/Makefile
29891 @@ -28,3 +28,7 @@ obj-$(CONFIG_ACPI_NUMA) += srat.o
29892 obj-$(CONFIG_NUMA_EMU) += numa_emulation.o
29893
29894 obj-$(CONFIG_MEMTEST) += memtest.o
29895 +
29896 +quote:="
29897 +obj-$(CONFIG_X86_64) += uderef_64.o
29898 +CFLAGS_uderef_64.o := $(subst $(quote),,$(CONFIG_ARCH_HWEIGHT_CFLAGS))
29899 diff --git a/arch/x86/mm/extable.c b/arch/x86/mm/extable.c
29900 index 903ec1e..c4166b2 100644
29901 --- a/arch/x86/mm/extable.c
29902 +++ b/arch/x86/mm/extable.c
29903 @@ -6,12 +6,24 @@
29904 static inline unsigned long
29905 ex_insn_addr(const struct exception_table_entry *x)
29906 {
29907 - return (unsigned long)&x->insn + x->insn;
29908 + unsigned long reloc = 0;
29909 +
29910 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
29911 + reloc = ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
29912 +#endif
29913 +
29914 + return (unsigned long)&x->insn + x->insn + reloc;
29915 }
29916 static inline unsigned long
29917 ex_fixup_addr(const struct exception_table_entry *x)
29918 {
29919 - return (unsigned long)&x->fixup + x->fixup;
29920 + unsigned long reloc = 0;
29921 +
29922 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
29923 + reloc = ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
29924 +#endif
29925 +
29926 + return (unsigned long)&x->fixup + x->fixup + reloc;
29927 }
29928
29929 int fixup_exception(struct pt_regs *regs)
29930 @@ -20,7 +32,7 @@ int fixup_exception(struct pt_regs *regs)
29931 unsigned long new_ip;
29932
29933 #ifdef CONFIG_PNPBIOS
29934 - if (unlikely(SEGMENT_IS_PNP_CODE(regs->cs))) {
29935 + if (unlikely(!v8086_mode(regs) && SEGMENT_IS_PNP_CODE(regs->cs))) {
29936 extern u32 pnp_bios_fault_eip, pnp_bios_fault_esp;
29937 extern u32 pnp_bios_is_utter_crap;
29938 pnp_bios_is_utter_crap = 1;
29939 @@ -145,6 +157,13 @@ void sort_extable(struct exception_table_entry *start,
29940 i += 4;
29941 p->fixup -= i;
29942 i += 4;
29943 +
29944 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
29945 + BUILD_BUG_ON(!IS_ENABLED(CONFIG_BUILDTIME_EXTABLE_SORT));
29946 + p->insn -= ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
29947 + p->fixup -= ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
29948 +#endif
29949 +
29950 }
29951 }
29952
29953 diff --git a/arch/x86/mm/fault.c b/arch/x86/mm/fault.c
29954 index 3aaeffc..42ea9fb 100644
29955 --- a/arch/x86/mm/fault.c
29956 +++ b/arch/x86/mm/fault.c
29957 @@ -14,11 +14,18 @@
29958 #include <linux/hugetlb.h> /* hstate_index_to_shift */
29959 #include <linux/prefetch.h> /* prefetchw */
29960 #include <linux/context_tracking.h> /* exception_enter(), ... */
29961 +#include <linux/unistd.h>
29962 +#include <linux/compiler.h>
29963
29964 #include <asm/traps.h> /* dotraplinkage, ... */
29965 #include <asm/pgalloc.h> /* pgd_*(), ... */
29966 #include <asm/kmemcheck.h> /* kmemcheck_*(), ... */
29967 #include <asm/fixmap.h> /* VSYSCALL_START */
29968 +#include <asm/tlbflush.h>
29969 +
29970 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
29971 +#include <asm/stacktrace.h>
29972 +#endif
29973
29974 /*
29975 * Page fault error code bits:
29976 @@ -56,7 +63,7 @@ static inline int __kprobes notify_page_fault(struct pt_regs *regs)
29977 int ret = 0;
29978
29979 /* kprobe_running() needs smp_processor_id() */
29980 - if (kprobes_built_in() && !user_mode_vm(regs)) {
29981 + if (kprobes_built_in() && !user_mode(regs)) {
29982 preempt_disable();
29983 if (kprobe_running() && kprobe_fault_handler(regs, 14))
29984 ret = 1;
29985 @@ -117,7 +124,10 @@ check_prefetch_opcode(struct pt_regs *regs, unsigned char *instr,
29986 return !instr_lo || (instr_lo>>1) == 1;
29987 case 0x00:
29988 /* Prefetch instruction is 0x0F0D or 0x0F18 */
29989 - if (probe_kernel_address(instr, opcode))
29990 + if (user_mode(regs)) {
29991 + if (__copy_from_user_inatomic(&opcode, (unsigned char __force_user *)(instr), 1))
29992 + return 0;
29993 + } else if (probe_kernel_address(instr, opcode))
29994 return 0;
29995
29996 *prefetch = (instr_lo == 0xF) &&
29997 @@ -151,7 +161,10 @@ is_prefetch(struct pt_regs *regs, unsigned long error_code, unsigned long addr)
29998 while (instr < max_instr) {
29999 unsigned char opcode;
30000
30001 - if (probe_kernel_address(instr, opcode))
30002 + if (user_mode(regs)) {
30003 + if (__copy_from_user_inatomic(&opcode, (unsigned char __force_user *)(instr), 1))
30004 + break;
30005 + } else if (probe_kernel_address(instr, opcode))
30006 break;
30007
30008 instr++;
30009 @@ -182,6 +195,34 @@ force_sig_info_fault(int si_signo, int si_code, unsigned long address,
30010 force_sig_info(si_signo, &info, tsk);
30011 }
30012
30013 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
30014 +static bool pax_is_fetch_fault(struct pt_regs *regs, unsigned long error_code, unsigned long address);
30015 +#endif
30016 +
30017 +#ifdef CONFIG_PAX_EMUTRAMP
30018 +static int pax_handle_fetch_fault(struct pt_regs *regs);
30019 +#endif
30020 +
30021 +#ifdef CONFIG_PAX_PAGEEXEC
30022 +static inline pmd_t * pax_get_pmd(struct mm_struct *mm, unsigned long address)
30023 +{
30024 + pgd_t *pgd;
30025 + pud_t *pud;
30026 + pmd_t *pmd;
30027 +
30028 + pgd = pgd_offset(mm, address);
30029 + if (!pgd_present(*pgd))
30030 + return NULL;
30031 + pud = pud_offset(pgd, address);
30032 + if (!pud_present(*pud))
30033 + return NULL;
30034 + pmd = pmd_offset(pud, address);
30035 + if (!pmd_present(*pmd))
30036 + return NULL;
30037 + return pmd;
30038 +}
30039 +#endif
30040 +
30041 DEFINE_SPINLOCK(pgd_lock);
30042 LIST_HEAD(pgd_list);
30043
30044 @@ -232,10 +273,27 @@ void vmalloc_sync_all(void)
30045 for (address = VMALLOC_START & PMD_MASK;
30046 address >= TASK_SIZE && address < FIXADDR_TOP;
30047 address += PMD_SIZE) {
30048 +
30049 +#ifdef CONFIG_PAX_PER_CPU_PGD
30050 + unsigned long cpu;
30051 +#else
30052 struct page *page;
30053 +#endif
30054
30055 spin_lock(&pgd_lock);
30056 +
30057 +#ifdef CONFIG_PAX_PER_CPU_PGD
30058 + for (cpu = 0; cpu < nr_cpu_ids; ++cpu) {
30059 + pgd_t *pgd = get_cpu_pgd(cpu, user);
30060 + pmd_t *ret;
30061 +
30062 + ret = vmalloc_sync_one(pgd, address);
30063 + if (!ret)
30064 + break;
30065 + pgd = get_cpu_pgd(cpu, kernel);
30066 +#else
30067 list_for_each_entry(page, &pgd_list, lru) {
30068 + pgd_t *pgd;
30069 spinlock_t *pgt_lock;
30070 pmd_t *ret;
30071
30072 @@ -243,8 +301,14 @@ void vmalloc_sync_all(void)
30073 pgt_lock = &pgd_page_get_mm(page)->page_table_lock;
30074
30075 spin_lock(pgt_lock);
30076 - ret = vmalloc_sync_one(page_address(page), address);
30077 + pgd = page_address(page);
30078 +#endif
30079 +
30080 + ret = vmalloc_sync_one(pgd, address);
30081 +
30082 +#ifndef CONFIG_PAX_PER_CPU_PGD
30083 spin_unlock(pgt_lock);
30084 +#endif
30085
30086 if (!ret)
30087 break;
30088 @@ -278,6 +342,12 @@ static noinline __kprobes int vmalloc_fault(unsigned long address)
30089 * an interrupt in the middle of a task switch..
30090 */
30091 pgd_paddr = read_cr3();
30092 +
30093 +#ifdef CONFIG_PAX_PER_CPU_PGD
30094 + BUG_ON(__pa(get_cpu_pgd(smp_processor_id(), kernel)) != (pgd_paddr & __PHYSICAL_MASK));
30095 + vmalloc_sync_one(__va(pgd_paddr + PAGE_SIZE), address);
30096 +#endif
30097 +
30098 pmd_k = vmalloc_sync_one(__va(pgd_paddr), address);
30099 if (!pmd_k)
30100 return -1;
30101 @@ -373,11 +443,25 @@ static noinline __kprobes int vmalloc_fault(unsigned long address)
30102 * happen within a race in page table update. In the later
30103 * case just flush:
30104 */
30105 - pgd = pgd_offset(current->active_mm, address);
30106 +
30107 pgd_ref = pgd_offset_k(address);
30108 if (pgd_none(*pgd_ref))
30109 return -1;
30110
30111 +#ifdef CONFIG_PAX_PER_CPU_PGD
30112 + BUG_ON(__pa(get_cpu_pgd(smp_processor_id(), kernel)) != (read_cr3() & __PHYSICAL_MASK));
30113 + pgd = pgd_offset_cpu(smp_processor_id(), user, address);
30114 + if (pgd_none(*pgd)) {
30115 + set_pgd(pgd, *pgd_ref);
30116 + arch_flush_lazy_mmu_mode();
30117 + } else {
30118 + BUG_ON(pgd_page_vaddr(*pgd) != pgd_page_vaddr(*pgd_ref));
30119 + }
30120 + pgd = pgd_offset_cpu(smp_processor_id(), kernel, address);
30121 +#else
30122 + pgd = pgd_offset(current->active_mm, address);
30123 +#endif
30124 +
30125 if (pgd_none(*pgd)) {
30126 set_pgd(pgd, *pgd_ref);
30127 arch_flush_lazy_mmu_mode();
30128 @@ -543,7 +627,7 @@ static int is_errata93(struct pt_regs *regs, unsigned long address)
30129 static int is_errata100(struct pt_regs *regs, unsigned long address)
30130 {
30131 #ifdef CONFIG_X86_64
30132 - if ((regs->cs == __USER32_CS || (regs->cs & (1<<2))) && (address >> 32))
30133 + if ((regs->cs == __USER32_CS || (regs->cs & SEGMENT_LDT)) && (address >> 32))
30134 return 1;
30135 #endif
30136 return 0;
30137 @@ -570,7 +654,7 @@ static int is_f00f_bug(struct pt_regs *regs, unsigned long address)
30138 }
30139
30140 static const char nx_warning[] = KERN_CRIT
30141 -"kernel tried to execute NX-protected page - exploit attempt? (uid: %d)\n";
30142 +"kernel tried to execute NX-protected page - exploit attempt? (uid: %d, task: %s, pid: %d)\n";
30143
30144 static void
30145 show_fault_oops(struct pt_regs *regs, unsigned long error_code,
30146 @@ -579,15 +663,27 @@ show_fault_oops(struct pt_regs *regs, unsigned long error_code,
30147 if (!oops_may_print())
30148 return;
30149
30150 - if (error_code & PF_INSTR) {
30151 + if ((__supported_pte_mask & _PAGE_NX) && (error_code & PF_INSTR)) {
30152 unsigned int level;
30153
30154 pte_t *pte = lookup_address(address, &level);
30155
30156 if (pte && pte_present(*pte) && !pte_exec(*pte))
30157 - printk(nx_warning, from_kuid(&init_user_ns, current_uid()));
30158 + printk(nx_warning, from_kuid_munged(&init_user_ns, current_uid()), current->comm, task_pid_nr(current));
30159 }
30160
30161 +#ifdef CONFIG_PAX_KERNEXEC
30162 + if (init_mm.start_code <= address && address < init_mm.end_code) {
30163 + if (current->signal->curr_ip)
30164 + printk(KERN_ERR "PAX: From %pI4: %s:%d, uid/euid: %u/%u, attempted to modify kernel code\n",
30165 + &current->signal->curr_ip, current->comm, task_pid_nr(current),
30166 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()));
30167 + else
30168 + printk(KERN_ERR "PAX: %s:%d, uid/euid: %u/%u, attempted to modify kernel code\n", current->comm, task_pid_nr(current),
30169 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()));
30170 + }
30171 +#endif
30172 +
30173 printk(KERN_ALERT "BUG: unable to handle kernel ");
30174 if (address < PAGE_SIZE)
30175 printk(KERN_CONT "NULL pointer dereference");
30176 @@ -750,6 +846,22 @@ __bad_area_nosemaphore(struct pt_regs *regs, unsigned long error_code,
30177 return;
30178 }
30179 #endif
30180 +
30181 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
30182 + if (pax_is_fetch_fault(regs, error_code, address)) {
30183 +
30184 +#ifdef CONFIG_PAX_EMUTRAMP
30185 + switch (pax_handle_fetch_fault(regs)) {
30186 + case 2:
30187 + return;
30188 + }
30189 +#endif
30190 +
30191 + pax_report_fault(regs, (void *)regs->ip, (void *)regs->sp);
30192 + do_group_exit(SIGKILL);
30193 + }
30194 +#endif
30195 +
30196 /* Kernel addresses are always protection faults: */
30197 if (address >= TASK_SIZE)
30198 error_code |= PF_PROT;
30199 @@ -835,7 +947,7 @@ do_sigbus(struct pt_regs *regs, unsigned long error_code, unsigned long address,
30200 if (fault & (VM_FAULT_HWPOISON|VM_FAULT_HWPOISON_LARGE)) {
30201 printk(KERN_ERR
30202 "MCE: Killing %s:%d due to hardware memory corruption fault at %lx\n",
30203 - tsk->comm, tsk->pid, address);
30204 + tsk->comm, task_pid_nr(tsk), address);
30205 code = BUS_MCEERR_AR;
30206 }
30207 #endif
30208 @@ -889,6 +1001,99 @@ static int spurious_fault_check(unsigned long error_code, pte_t *pte)
30209 return 1;
30210 }
30211
30212 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_PAGEEXEC)
30213 +static int pax_handle_pageexec_fault(struct pt_regs *regs, struct mm_struct *mm, unsigned long address, unsigned long error_code)
30214 +{
30215 + pte_t *pte;
30216 + pmd_t *pmd;
30217 + spinlock_t *ptl;
30218 + unsigned char pte_mask;
30219 +
30220 + if ((__supported_pte_mask & _PAGE_NX) || (error_code & (PF_PROT|PF_USER)) != (PF_PROT|PF_USER) || v8086_mode(regs) ||
30221 + !(mm->pax_flags & MF_PAX_PAGEEXEC))
30222 + return 0;
30223 +
30224 + /* PaX: it's our fault, let's handle it if we can */
30225 +
30226 + /* PaX: take a look at read faults before acquiring any locks */
30227 + if (unlikely(!(error_code & PF_WRITE) && (regs->ip == address))) {
30228 + /* instruction fetch attempt from a protected page in user mode */
30229 + up_read(&mm->mmap_sem);
30230 +
30231 +#ifdef CONFIG_PAX_EMUTRAMP
30232 + switch (pax_handle_fetch_fault(regs)) {
30233 + case 2:
30234 + return 1;
30235 + }
30236 +#endif
30237 +
30238 + pax_report_fault(regs, (void *)regs->ip, (void *)regs->sp);
30239 + do_group_exit(SIGKILL);
30240 + }
30241 +
30242 + pmd = pax_get_pmd(mm, address);
30243 + if (unlikely(!pmd))
30244 + return 0;
30245 +
30246 + pte = pte_offset_map_lock(mm, pmd, address, &ptl);
30247 + if (unlikely(!(pte_val(*pte) & _PAGE_PRESENT) || pte_user(*pte))) {
30248 + pte_unmap_unlock(pte, ptl);
30249 + return 0;
30250 + }
30251 +
30252 + if (unlikely((error_code & PF_WRITE) && !pte_write(*pte))) {
30253 + /* write attempt to a protected page in user mode */
30254 + pte_unmap_unlock(pte, ptl);
30255 + return 0;
30256 + }
30257 +
30258 +#ifdef CONFIG_SMP
30259 + if (likely(address > get_limit(regs->cs) && cpu_isset(smp_processor_id(), mm->context.cpu_user_cs_mask)))
30260 +#else
30261 + if (likely(address > get_limit(regs->cs)))
30262 +#endif
30263 + {
30264 + set_pte(pte, pte_mkread(*pte));
30265 + __flush_tlb_one(address);
30266 + pte_unmap_unlock(pte, ptl);
30267 + up_read(&mm->mmap_sem);
30268 + return 1;
30269 + }
30270 +
30271 + pte_mask = _PAGE_ACCESSED | _PAGE_USER | ((error_code & PF_WRITE) << (_PAGE_BIT_DIRTY-1));
30272 +
30273 + /*
30274 + * PaX: fill DTLB with user rights and retry
30275 + */
30276 + __asm__ __volatile__ (
30277 + "orb %2,(%1)\n"
30278 +#if defined(CONFIG_M586) || defined(CONFIG_M586TSC)
30279 +/*
30280 + * PaX: let this uncommented 'invlpg' remind us on the behaviour of Intel's
30281 + * (and AMD's) TLBs. namely, they do not cache PTEs that would raise *any*
30282 + * page fault when examined during a TLB load attempt. this is true not only
30283 + * for PTEs holding a non-present entry but also present entries that will
30284 + * raise a page fault (such as those set up by PaX, or the copy-on-write
30285 + * mechanism). in effect it means that we do *not* need to flush the TLBs
30286 + * for our target pages since their PTEs are simply not in the TLBs at all.
30287 +
30288 + * the best thing in omitting it is that we gain around 15-20% speed in the
30289 + * fast path of the page fault handler and can get rid of tracing since we
30290 + * can no longer flush unintended entries.
30291 + */
30292 + "invlpg (%0)\n"
30293 +#endif
30294 + __copyuser_seg"testb $0,(%0)\n"
30295 + "xorb %3,(%1)\n"
30296 + :
30297 + : "r" (address), "r" (pte), "q" (pte_mask), "i" (_PAGE_USER)
30298 + : "memory", "cc");
30299 + pte_unmap_unlock(pte, ptl);
30300 + up_read(&mm->mmap_sem);
30301 + return 1;
30302 +}
30303 +#endif
30304 +
30305 /*
30306 * Handle a spurious fault caused by a stale TLB entry.
30307 *
30308 @@ -955,6 +1160,9 @@ int show_unhandled_signals = 1;
30309 static inline int
30310 access_error(unsigned long error_code, struct vm_area_struct *vma)
30311 {
30312 + if ((__supported_pte_mask & _PAGE_NX) && (error_code & PF_INSTR) && !(vma->vm_flags & VM_EXEC))
30313 + return 1;
30314 +
30315 if (error_code & PF_WRITE) {
30316 /* write, present and write, not present: */
30317 if (unlikely(!(vma->vm_flags & VM_WRITE)))
30318 @@ -983,7 +1191,7 @@ static inline bool smap_violation(int error_code, struct pt_regs *regs)
30319 if (error_code & PF_USER)
30320 return false;
30321
30322 - if (!user_mode_vm(regs) && (regs->flags & X86_EFLAGS_AC))
30323 + if (!user_mode(regs) && (regs->flags & X86_EFLAGS_AC))
30324 return false;
30325
30326 return true;
30327 @@ -1010,6 +1218,22 @@ __do_page_fault(struct pt_regs *regs, unsigned long error_code)
30328 /* Get the faulting address: */
30329 address = read_cr2();
30330
30331 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
30332 + if (!user_mode(regs) && address < 2 * pax_user_shadow_base) {
30333 + if (!search_exception_tables(regs->ip)) {
30334 + printk(KERN_ERR "PAX: please report this to pageexec@freemail.hu\n");
30335 + bad_area_nosemaphore(regs, error_code, address);
30336 + return;
30337 + }
30338 + if (address < pax_user_shadow_base) {
30339 + printk(KERN_ERR "PAX: please report this to pageexec@freemail.hu\n");
30340 + printk(KERN_ERR "PAX: faulting IP: %pS\n", (void *)regs->ip);
30341 + show_trace_log_lvl(NULL, NULL, (void *)regs->sp, regs->bp, KERN_ERR);
30342 + } else
30343 + address -= pax_user_shadow_base;
30344 + }
30345 +#endif
30346 +
30347 /*
30348 * Detect and handle instructions that would cause a page fault for
30349 * both a tracked kernel page and a userspace page.
30350 @@ -1069,7 +1293,7 @@ __do_page_fault(struct pt_regs *regs, unsigned long error_code)
30351 * User-mode registers count as a user access even for any
30352 * potential system fault or CPU buglet:
30353 */
30354 - if (user_mode_vm(regs)) {
30355 + if (user_mode(regs)) {
30356 local_irq_enable();
30357 error_code |= PF_USER;
30358 flags |= FAULT_FLAG_USER;
30359 @@ -1135,6 +1359,11 @@ retry:
30360 might_sleep();
30361 }
30362
30363 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_PAGEEXEC)
30364 + if (pax_handle_pageexec_fault(regs, mm, address, error_code))
30365 + return;
30366 +#endif
30367 +
30368 vma = find_vma(mm, address);
30369 if (unlikely(!vma)) {
30370 bad_area(regs, error_code, address);
30371 @@ -1146,18 +1375,24 @@ retry:
30372 bad_area(regs, error_code, address);
30373 return;
30374 }
30375 - if (error_code & PF_USER) {
30376 - /*
30377 - * Accessing the stack below %sp is always a bug.
30378 - * The large cushion allows instructions like enter
30379 - * and pusha to work. ("enter $65535, $31" pushes
30380 - * 32 pointers and then decrements %sp by 65535.)
30381 - */
30382 - if (unlikely(address + 65536 + 32 * sizeof(unsigned long) < regs->sp)) {
30383 - bad_area(regs, error_code, address);
30384 - return;
30385 - }
30386 + /*
30387 + * Accessing the stack below %sp is always a bug.
30388 + * The large cushion allows instructions like enter
30389 + * and pusha to work. ("enter $65535, $31" pushes
30390 + * 32 pointers and then decrements %sp by 65535.)
30391 + */
30392 + if (unlikely(address + 65536 + 32 * sizeof(unsigned long) < task_pt_regs(tsk)->sp)) {
30393 + bad_area(regs, error_code, address);
30394 + return;
30395 }
30396 +
30397 +#ifdef CONFIG_PAX_SEGMEXEC
30398 + if (unlikely((mm->pax_flags & MF_PAX_SEGMEXEC) && vma->vm_end - SEGMEXEC_TASK_SIZE - 1 < address - SEGMEXEC_TASK_SIZE - 1)) {
30399 + bad_area(regs, error_code, address);
30400 + return;
30401 + }
30402 +#endif
30403 +
30404 if (unlikely(expand_stack(vma, address))) {
30405 bad_area(regs, error_code, address);
30406 return;
30407 @@ -1231,3 +1466,292 @@ do_page_fault(struct pt_regs *regs, unsigned long error_code)
30408 __do_page_fault(regs, error_code);
30409 exception_exit(prev_state);
30410 }
30411 +
30412 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
30413 +static bool pax_is_fetch_fault(struct pt_regs *regs, unsigned long error_code, unsigned long address)
30414 +{
30415 + struct mm_struct *mm = current->mm;
30416 + unsigned long ip = regs->ip;
30417 +
30418 + if (v8086_mode(regs))
30419 + ip = ((regs->cs & 0xffff) << 4) + (ip & 0xffff);
30420 +
30421 +#ifdef CONFIG_PAX_PAGEEXEC
30422 + if (mm->pax_flags & MF_PAX_PAGEEXEC) {
30423 + if ((__supported_pte_mask & _PAGE_NX) && (error_code & PF_INSTR))
30424 + return true;
30425 + if (!(error_code & (PF_PROT | PF_WRITE)) && ip == address)
30426 + return true;
30427 + return false;
30428 + }
30429 +#endif
30430 +
30431 +#ifdef CONFIG_PAX_SEGMEXEC
30432 + if (mm->pax_flags & MF_PAX_SEGMEXEC) {
30433 + if (!(error_code & (PF_PROT | PF_WRITE)) && (ip + SEGMEXEC_TASK_SIZE == address))
30434 + return true;
30435 + return false;
30436 + }
30437 +#endif
30438 +
30439 + return false;
30440 +}
30441 +#endif
30442 +
30443 +#ifdef CONFIG_PAX_EMUTRAMP
30444 +static int pax_handle_fetch_fault_32(struct pt_regs *regs)
30445 +{
30446 + int err;
30447 +
30448 + do { /* PaX: libffi trampoline emulation */
30449 + unsigned char mov, jmp;
30450 + unsigned int addr1, addr2;
30451 +
30452 +#ifdef CONFIG_X86_64
30453 + if ((regs->ip + 9) >> 32)
30454 + break;
30455 +#endif
30456 +
30457 + err = get_user(mov, (unsigned char __user *)regs->ip);
30458 + err |= get_user(addr1, (unsigned int __user *)(regs->ip + 1));
30459 + err |= get_user(jmp, (unsigned char __user *)(regs->ip + 5));
30460 + err |= get_user(addr2, (unsigned int __user *)(regs->ip + 6));
30461 +
30462 + if (err)
30463 + break;
30464 +
30465 + if (mov == 0xB8 && jmp == 0xE9) {
30466 + regs->ax = addr1;
30467 + regs->ip = (unsigned int)(regs->ip + addr2 + 10);
30468 + return 2;
30469 + }
30470 + } while (0);
30471 +
30472 + do { /* PaX: gcc trampoline emulation #1 */
30473 + unsigned char mov1, mov2;
30474 + unsigned short jmp;
30475 + unsigned int addr1, addr2;
30476 +
30477 +#ifdef CONFIG_X86_64
30478 + if ((regs->ip + 11) >> 32)
30479 + break;
30480 +#endif
30481 +
30482 + err = get_user(mov1, (unsigned char __user *)regs->ip);
30483 + err |= get_user(addr1, (unsigned int __user *)(regs->ip + 1));
30484 + err |= get_user(mov2, (unsigned char __user *)(regs->ip + 5));
30485 + err |= get_user(addr2, (unsigned int __user *)(regs->ip + 6));
30486 + err |= get_user(jmp, (unsigned short __user *)(regs->ip + 10));
30487 +
30488 + if (err)
30489 + break;
30490 +
30491 + if (mov1 == 0xB9 && mov2 == 0xB8 && jmp == 0xE0FF) {
30492 + regs->cx = addr1;
30493 + regs->ax = addr2;
30494 + regs->ip = addr2;
30495 + return 2;
30496 + }
30497 + } while (0);
30498 +
30499 + do { /* PaX: gcc trampoline emulation #2 */
30500 + unsigned char mov, jmp;
30501 + unsigned int addr1, addr2;
30502 +
30503 +#ifdef CONFIG_X86_64
30504 + if ((regs->ip + 9) >> 32)
30505 + break;
30506 +#endif
30507 +
30508 + err = get_user(mov, (unsigned char __user *)regs->ip);
30509 + err |= get_user(addr1, (unsigned int __user *)(regs->ip + 1));
30510 + err |= get_user(jmp, (unsigned char __user *)(regs->ip + 5));
30511 + err |= get_user(addr2, (unsigned int __user *)(regs->ip + 6));
30512 +
30513 + if (err)
30514 + break;
30515 +
30516 + if (mov == 0xB9 && jmp == 0xE9) {
30517 + regs->cx = addr1;
30518 + regs->ip = (unsigned int)(regs->ip + addr2 + 10);
30519 + return 2;
30520 + }
30521 + } while (0);
30522 +
30523 + return 1; /* PaX in action */
30524 +}
30525 +
30526 +#ifdef CONFIG_X86_64
30527 +static int pax_handle_fetch_fault_64(struct pt_regs *regs)
30528 +{
30529 + int err;
30530 +
30531 + do { /* PaX: libffi trampoline emulation */
30532 + unsigned short mov1, mov2, jmp1;
30533 + unsigned char stcclc, jmp2;
30534 + unsigned long addr1, addr2;
30535 +
30536 + err = get_user(mov1, (unsigned short __user *)regs->ip);
30537 + err |= get_user(addr1, (unsigned long __user *)(regs->ip + 2));
30538 + err |= get_user(mov2, (unsigned short __user *)(regs->ip + 10));
30539 + err |= get_user(addr2, (unsigned long __user *)(regs->ip + 12));
30540 + err |= get_user(stcclc, (unsigned char __user *)(regs->ip + 20));
30541 + err |= get_user(jmp1, (unsigned short __user *)(regs->ip + 21));
30542 + err |= get_user(jmp2, (unsigned char __user *)(regs->ip + 23));
30543 +
30544 + if (err)
30545 + break;
30546 +
30547 + if (mov1 == 0xBB49 && mov2 == 0xBA49 && (stcclc == 0xF8 || stcclc == 0xF9) && jmp1 == 0xFF49 && jmp2 == 0xE3) {
30548 + regs->r11 = addr1;
30549 + regs->r10 = addr2;
30550 + if (stcclc == 0xF8)
30551 + regs->flags &= ~X86_EFLAGS_CF;
30552 + else
30553 + regs->flags |= X86_EFLAGS_CF;
30554 + regs->ip = addr1;
30555 + return 2;
30556 + }
30557 + } while (0);
30558 +
30559 + do { /* PaX: gcc trampoline emulation #1 */
30560 + unsigned short mov1, mov2, jmp1;
30561 + unsigned char jmp2;
30562 + unsigned int addr1;
30563 + unsigned long addr2;
30564 +
30565 + err = get_user(mov1, (unsigned short __user *)regs->ip);
30566 + err |= get_user(addr1, (unsigned int __user *)(regs->ip + 2));
30567 + err |= get_user(mov2, (unsigned short __user *)(regs->ip + 6));
30568 + err |= get_user(addr2, (unsigned long __user *)(regs->ip + 8));
30569 + err |= get_user(jmp1, (unsigned short __user *)(regs->ip + 16));
30570 + err |= get_user(jmp2, (unsigned char __user *)(regs->ip + 18));
30571 +
30572 + if (err)
30573 + break;
30574 +
30575 + if (mov1 == 0xBB41 && mov2 == 0xBA49 && jmp1 == 0xFF49 && jmp2 == 0xE3) {
30576 + regs->r11 = addr1;
30577 + regs->r10 = addr2;
30578 + regs->ip = addr1;
30579 + return 2;
30580 + }
30581 + } while (0);
30582 +
30583 + do { /* PaX: gcc trampoline emulation #2 */
30584 + unsigned short mov1, mov2, jmp1;
30585 + unsigned char jmp2;
30586 + unsigned long addr1, addr2;
30587 +
30588 + err = get_user(mov1, (unsigned short __user *)regs->ip);
30589 + err |= get_user(addr1, (unsigned long __user *)(regs->ip + 2));
30590 + err |= get_user(mov2, (unsigned short __user *)(regs->ip + 10));
30591 + err |= get_user(addr2, (unsigned long __user *)(regs->ip + 12));
30592 + err |= get_user(jmp1, (unsigned short __user *)(regs->ip + 20));
30593 + err |= get_user(jmp2, (unsigned char __user *)(regs->ip + 22));
30594 +
30595 + if (err)
30596 + break;
30597 +
30598 + if (mov1 == 0xBB49 && mov2 == 0xBA49 && jmp1 == 0xFF49 && jmp2 == 0xE3) {
30599 + regs->r11 = addr1;
30600 + regs->r10 = addr2;
30601 + regs->ip = addr1;
30602 + return 2;
30603 + }
30604 + } while (0);
30605 +
30606 + return 1; /* PaX in action */
30607 +}
30608 +#endif
30609 +
30610 +/*
30611 + * PaX: decide what to do with offenders (regs->ip = fault address)
30612 + *
30613 + * returns 1 when task should be killed
30614 + * 2 when gcc trampoline was detected
30615 + */
30616 +static int pax_handle_fetch_fault(struct pt_regs *regs)
30617 +{
30618 + if (v8086_mode(regs))
30619 + return 1;
30620 +
30621 + if (!(current->mm->pax_flags & MF_PAX_EMUTRAMP))
30622 + return 1;
30623 +
30624 +#ifdef CONFIG_X86_32
30625 + return pax_handle_fetch_fault_32(regs);
30626 +#else
30627 + if (regs->cs == __USER32_CS || (regs->cs & SEGMENT_LDT))
30628 + return pax_handle_fetch_fault_32(regs);
30629 + else
30630 + return pax_handle_fetch_fault_64(regs);
30631 +#endif
30632 +}
30633 +#endif
30634 +
30635 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
30636 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
30637 +{
30638 + long i;
30639 +
30640 + printk(KERN_ERR "PAX: bytes at PC: ");
30641 + for (i = 0; i < 20; i++) {
30642 + unsigned char c;
30643 + if (get_user(c, (unsigned char __force_user *)pc+i))
30644 + printk(KERN_CONT "?? ");
30645 + else
30646 + printk(KERN_CONT "%02x ", c);
30647 + }
30648 + printk("\n");
30649 +
30650 + printk(KERN_ERR "PAX: bytes at SP-%lu: ", (unsigned long)sizeof(long));
30651 + for (i = -1; i < 80 / (long)sizeof(long); i++) {
30652 + unsigned long c;
30653 + if (get_user(c, (unsigned long __force_user *)sp+i)) {
30654 +#ifdef CONFIG_X86_32
30655 + printk(KERN_CONT "???????? ");
30656 +#else
30657 + if ((regs->cs == __USER32_CS || (regs->cs & SEGMENT_LDT)))
30658 + printk(KERN_CONT "???????? ???????? ");
30659 + else
30660 + printk(KERN_CONT "???????????????? ");
30661 +#endif
30662 + } else {
30663 +#ifdef CONFIG_X86_64
30664 + if ((regs->cs == __USER32_CS || (regs->cs & SEGMENT_LDT))) {
30665 + printk(KERN_CONT "%08x ", (unsigned int)c);
30666 + printk(KERN_CONT "%08x ", (unsigned int)(c >> 32));
30667 + } else
30668 +#endif
30669 + printk(KERN_CONT "%0*lx ", 2 * (int)sizeof(long), c);
30670 + }
30671 + }
30672 + printk("\n");
30673 +}
30674 +#endif
30675 +
30676 +/**
30677 + * probe_kernel_write(): safely attempt to write to a location
30678 + * @dst: address to write to
30679 + * @src: pointer to the data that shall be written
30680 + * @size: size of the data chunk
30681 + *
30682 + * Safely write to address @dst from the buffer at @src. If a kernel fault
30683 + * happens, handle that and return -EFAULT.
30684 + */
30685 +long notrace probe_kernel_write(void *dst, const void *src, size_t size)
30686 +{
30687 + long ret;
30688 + mm_segment_t old_fs = get_fs();
30689 +
30690 + set_fs(KERNEL_DS);
30691 + pagefault_disable();
30692 + pax_open_kernel();
30693 + ret = __copy_to_user_inatomic((void __force_user *)dst, src, size);
30694 + pax_close_kernel();
30695 + pagefault_enable();
30696 + set_fs(old_fs);
30697 +
30698 + return ret ? -EFAULT : 0;
30699 +}
30700 diff --git a/arch/x86/mm/gup.c b/arch/x86/mm/gup.c
30701 index dd74e46..7d26398 100644
30702 --- a/arch/x86/mm/gup.c
30703 +++ b/arch/x86/mm/gup.c
30704 @@ -255,7 +255,7 @@ int __get_user_pages_fast(unsigned long start, int nr_pages, int write,
30705 addr = start;
30706 len = (unsigned long) nr_pages << PAGE_SHIFT;
30707 end = start + len;
30708 - if (unlikely(!access_ok(write ? VERIFY_WRITE : VERIFY_READ,
30709 + if (unlikely(!__access_ok(write ? VERIFY_WRITE : VERIFY_READ,
30710 (void __user *)start, len)))
30711 return 0;
30712
30713 diff --git a/arch/x86/mm/highmem_32.c b/arch/x86/mm/highmem_32.c
30714 index 4500142..53a363c 100644
30715 --- a/arch/x86/mm/highmem_32.c
30716 +++ b/arch/x86/mm/highmem_32.c
30717 @@ -45,7 +45,11 @@ void *kmap_atomic_prot(struct page *page, pgprot_t prot)
30718 idx = type + KM_TYPE_NR*smp_processor_id();
30719 vaddr = __fix_to_virt(FIX_KMAP_BEGIN + idx);
30720 BUG_ON(!pte_none(*(kmap_pte-idx)));
30721 +
30722 + pax_open_kernel();
30723 set_pte(kmap_pte-idx, mk_pte(page, prot));
30724 + pax_close_kernel();
30725 +
30726 arch_flush_lazy_mmu_mode();
30727
30728 return (void *)vaddr;
30729 diff --git a/arch/x86/mm/hugetlbpage.c b/arch/x86/mm/hugetlbpage.c
30730 index 9d980d8..6bbfacb 100644
30731 --- a/arch/x86/mm/hugetlbpage.c
30732 +++ b/arch/x86/mm/hugetlbpage.c
30733 @@ -92,23 +92,30 @@ int pmd_huge_support(void)
30734 #ifdef HAVE_ARCH_HUGETLB_UNMAPPED_AREA
30735 static unsigned long hugetlb_get_unmapped_area_bottomup(struct file *file,
30736 unsigned long addr, unsigned long len,
30737 - unsigned long pgoff, unsigned long flags)
30738 + unsigned long pgoff, unsigned long flags, unsigned long offset)
30739 {
30740 struct hstate *h = hstate_file(file);
30741 struct vm_unmapped_area_info info;
30742 -
30743 +
30744 info.flags = 0;
30745 info.length = len;
30746 info.low_limit = TASK_UNMAPPED_BASE;
30747 +
30748 +#ifdef CONFIG_PAX_RANDMMAP
30749 + if (current->mm->pax_flags & MF_PAX_RANDMMAP)
30750 + info.low_limit += current->mm->delta_mmap;
30751 +#endif
30752 +
30753 info.high_limit = TASK_SIZE;
30754 info.align_mask = PAGE_MASK & ~huge_page_mask(h);
30755 info.align_offset = 0;
30756 + info.threadstack_offset = offset;
30757 return vm_unmapped_area(&info);
30758 }
30759
30760 static unsigned long hugetlb_get_unmapped_area_topdown(struct file *file,
30761 unsigned long addr0, unsigned long len,
30762 - unsigned long pgoff, unsigned long flags)
30763 + unsigned long pgoff, unsigned long flags, unsigned long offset)
30764 {
30765 struct hstate *h = hstate_file(file);
30766 struct vm_unmapped_area_info info;
30767 @@ -120,6 +127,7 @@ static unsigned long hugetlb_get_unmapped_area_topdown(struct file *file,
30768 info.high_limit = current->mm->mmap_base;
30769 info.align_mask = PAGE_MASK & ~huge_page_mask(h);
30770 info.align_offset = 0;
30771 + info.threadstack_offset = offset;
30772 addr = vm_unmapped_area(&info);
30773
30774 /*
30775 @@ -132,6 +140,12 @@ static unsigned long hugetlb_get_unmapped_area_topdown(struct file *file,
30776 VM_BUG_ON(addr != -ENOMEM);
30777 info.flags = 0;
30778 info.low_limit = TASK_UNMAPPED_BASE;
30779 +
30780 +#ifdef CONFIG_PAX_RANDMMAP
30781 + if (current->mm->pax_flags & MF_PAX_RANDMMAP)
30782 + info.low_limit += current->mm->delta_mmap;
30783 +#endif
30784 +
30785 info.high_limit = TASK_SIZE;
30786 addr = vm_unmapped_area(&info);
30787 }
30788 @@ -146,10 +160,20 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
30789 struct hstate *h = hstate_file(file);
30790 struct mm_struct *mm = current->mm;
30791 struct vm_area_struct *vma;
30792 + unsigned long pax_task_size = TASK_SIZE;
30793 + unsigned long offset = gr_rand_threadstack_offset(mm, file, flags);
30794
30795 if (len & ~huge_page_mask(h))
30796 return -EINVAL;
30797 - if (len > TASK_SIZE)
30798 +
30799 +#ifdef CONFIG_PAX_SEGMEXEC
30800 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
30801 + pax_task_size = SEGMEXEC_TASK_SIZE;
30802 +#endif
30803 +
30804 + pax_task_size -= PAGE_SIZE;
30805 +
30806 + if (len > pax_task_size)
30807 return -ENOMEM;
30808
30809 if (flags & MAP_FIXED) {
30810 @@ -158,19 +182,22 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
30811 return addr;
30812 }
30813
30814 +#ifdef CONFIG_PAX_RANDMMAP
30815 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
30816 +#endif
30817 +
30818 if (addr) {
30819 addr = ALIGN(addr, huge_page_size(h));
30820 vma = find_vma(mm, addr);
30821 - if (TASK_SIZE - len >= addr &&
30822 - (!vma || addr + len <= vma->vm_start))
30823 + if (pax_task_size - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
30824 return addr;
30825 }
30826 if (mm->get_unmapped_area == arch_get_unmapped_area)
30827 return hugetlb_get_unmapped_area_bottomup(file, addr, len,
30828 - pgoff, flags);
30829 + pgoff, flags, offset);
30830 else
30831 return hugetlb_get_unmapped_area_topdown(file, addr, len,
30832 - pgoff, flags);
30833 + pgoff, flags, offset);
30834 }
30835
30836 #endif /*HAVE_ARCH_HUGETLB_UNMAPPED_AREA*/
30837 diff --git a/arch/x86/mm/init.c b/arch/x86/mm/init.c
30838 index 04664cd..dae6e5d 100644
30839 --- a/arch/x86/mm/init.c
30840 +++ b/arch/x86/mm/init.c
30841 @@ -4,6 +4,7 @@
30842 #include <linux/swap.h>
30843 #include <linux/memblock.h>
30844 #include <linux/bootmem.h> /* for max_low_pfn */
30845 +#include <linux/tboot.h>
30846
30847 #include <asm/cacheflush.h>
30848 #include <asm/e820.h>
30849 @@ -17,6 +18,8 @@
30850 #include <asm/proto.h>
30851 #include <asm/dma.h> /* for MAX_DMA_PFN */
30852 #include <asm/microcode.h>
30853 +#include <asm/desc.h>
30854 +#include <asm/bios_ebda.h>
30855
30856 #include "mm_internal.h"
30857
30858 @@ -465,7 +468,18 @@ void __init init_mem_mapping(void)
30859 early_ioremap_page_table_range_init();
30860 #endif
30861
30862 +#ifdef CONFIG_PAX_PER_CPU_PGD
30863 + clone_pgd_range(get_cpu_pgd(0, kernel) + KERNEL_PGD_BOUNDARY,
30864 + swapper_pg_dir + KERNEL_PGD_BOUNDARY,
30865 + KERNEL_PGD_PTRS);
30866 + clone_pgd_range(get_cpu_pgd(0, user) + KERNEL_PGD_BOUNDARY,
30867 + swapper_pg_dir + KERNEL_PGD_BOUNDARY,
30868 + KERNEL_PGD_PTRS);
30869 + load_cr3(get_cpu_pgd(0, kernel));
30870 +#else
30871 load_cr3(swapper_pg_dir);
30872 +#endif
30873 +
30874 __flush_tlb_all();
30875
30876 early_memtest(0, max_pfn_mapped << PAGE_SHIFT);
30877 @@ -481,10 +495,40 @@ void __init init_mem_mapping(void)
30878 * Access has to be given to non-kernel-ram areas as well, these contain the PCI
30879 * mmio resources as well as potential bios/acpi data regions.
30880 */
30881 +
30882 +#ifdef CONFIG_GRKERNSEC_KMEM
30883 +static unsigned int ebda_start __read_only;
30884 +static unsigned int ebda_end __read_only;
30885 +#endif
30886 +
30887 int devmem_is_allowed(unsigned long pagenr)
30888 {
30889 - if (pagenr < 256)
30890 +#ifdef CONFIG_GRKERNSEC_KMEM
30891 + /* allow BDA */
30892 + if (!pagenr)
30893 return 1;
30894 + /* allow EBDA */
30895 + if (pagenr >= ebda_start && pagenr < ebda_end)
30896 + return 1;
30897 + /* if tboot is in use, allow access to its hardcoded serial log range */
30898 + if (tboot_enabled() && ((0x60000 >> PAGE_SHIFT) <= pagenr) && (pagenr < (0x68000 >> PAGE_SHIFT)))
30899 + return 1;
30900 +#else
30901 + if (!pagenr)
30902 + return 1;
30903 +#ifdef CONFIG_VM86
30904 + if (pagenr < (ISA_START_ADDRESS >> PAGE_SHIFT))
30905 + return 1;
30906 +#endif
30907 +#endif
30908 +
30909 + if ((ISA_START_ADDRESS >> PAGE_SHIFT) <= pagenr && pagenr < (ISA_END_ADDRESS >> PAGE_SHIFT))
30910 + return 1;
30911 +#ifdef CONFIG_GRKERNSEC_KMEM
30912 + /* throw out everything else below 1MB */
30913 + if (pagenr <= 256)
30914 + return 0;
30915 +#endif
30916 if (iomem_is_exclusive(pagenr << PAGE_SHIFT))
30917 return 0;
30918 if (!page_is_ram(pagenr))
30919 @@ -530,8 +574,117 @@ void free_init_pages(char *what, unsigned long begin, unsigned long end)
30920 #endif
30921 }
30922
30923 +#ifdef CONFIG_GRKERNSEC_KMEM
30924 +static inline void gr_init_ebda(void)
30925 +{
30926 + unsigned int ebda_addr;
30927 + unsigned int ebda_size = 0;
30928 +
30929 + ebda_addr = get_bios_ebda();
30930 + if (ebda_addr) {
30931 + ebda_size = *(unsigned char *)phys_to_virt(ebda_addr);
30932 + ebda_size <<= 10;
30933 + }
30934 + if (ebda_addr && ebda_size) {
30935 + ebda_start = ebda_addr >> PAGE_SHIFT;
30936 + ebda_end = min((unsigned int)PAGE_ALIGN(ebda_addr + ebda_size), (unsigned int)0xa0000) >> PAGE_SHIFT;
30937 + } else {
30938 + ebda_start = 0x9f000 >> PAGE_SHIFT;
30939 + ebda_end = 0xa0000 >> PAGE_SHIFT;
30940 + }
30941 +}
30942 +#else
30943 +static inline void gr_init_ebda(void) { }
30944 +#endif
30945 +
30946 void free_initmem(void)
30947 {
30948 +#ifdef CONFIG_PAX_KERNEXEC
30949 +#ifdef CONFIG_X86_32
30950 + /* PaX: limit KERNEL_CS to actual size */
30951 + unsigned long addr, limit;
30952 + struct desc_struct d;
30953 + int cpu;
30954 +#else
30955 + pgd_t *pgd;
30956 + pud_t *pud;
30957 + pmd_t *pmd;
30958 + unsigned long addr, end;
30959 +#endif
30960 +#endif
30961 +
30962 + gr_init_ebda();
30963 +
30964 +#ifdef CONFIG_PAX_KERNEXEC
30965 +#ifdef CONFIG_X86_32
30966 + limit = paravirt_enabled() ? ktva_ktla(0xffffffff) : (unsigned long)&_etext;
30967 + limit = (limit - 1UL) >> PAGE_SHIFT;
30968 +
30969 + memset(__LOAD_PHYSICAL_ADDR + PAGE_OFFSET, POISON_FREE_INITMEM, PAGE_SIZE);
30970 + for (cpu = 0; cpu < nr_cpu_ids; cpu++) {
30971 + pack_descriptor(&d, get_desc_base(&get_cpu_gdt_table(cpu)[GDT_ENTRY_KERNEL_CS]), limit, 0x9B, 0xC);
30972 + write_gdt_entry(get_cpu_gdt_table(cpu), GDT_ENTRY_KERNEL_CS, &d, DESCTYPE_S);
30973 + write_gdt_entry(get_cpu_gdt_table(cpu), GDT_ENTRY_KERNEXEC_KERNEL_CS, &d, DESCTYPE_S);
30974 + }
30975 +
30976 + /* PaX: make KERNEL_CS read-only */
30977 + addr = PFN_ALIGN(ktla_ktva((unsigned long)&_text));
30978 + if (!paravirt_enabled())
30979 + set_memory_ro(addr, (PFN_ALIGN(_sdata) - addr) >> PAGE_SHIFT);
30980 +/*
30981 + for (addr = ktla_ktva((unsigned long)&_text); addr < (unsigned long)&_sdata; addr += PMD_SIZE) {
30982 + pgd = pgd_offset_k(addr);
30983 + pud = pud_offset(pgd, addr);
30984 + pmd = pmd_offset(pud, addr);
30985 + set_pmd(pmd, __pmd(pmd_val(*pmd) & ~_PAGE_RW));
30986 + }
30987 +*/
30988 +#ifdef CONFIG_X86_PAE
30989 + set_memory_nx(PFN_ALIGN(__init_begin), (PFN_ALIGN(__init_end) - PFN_ALIGN(__init_begin)) >> PAGE_SHIFT);
30990 +/*
30991 + for (addr = (unsigned long)&__init_begin; addr < (unsigned long)&__init_end; addr += PMD_SIZE) {
30992 + pgd = pgd_offset_k(addr);
30993 + pud = pud_offset(pgd, addr);
30994 + pmd = pmd_offset(pud, addr);
30995 + set_pmd(pmd, __pmd(pmd_val(*pmd) | (_PAGE_NX & __supported_pte_mask)));
30996 + }
30997 +*/
30998 +#endif
30999 +
31000 +#ifdef CONFIG_MODULES
31001 + set_memory_4k((unsigned long)MODULES_EXEC_VADDR, (MODULES_EXEC_END - MODULES_EXEC_VADDR) >> PAGE_SHIFT);
31002 +#endif
31003 +
31004 +#else
31005 + /* PaX: make kernel code/rodata read-only, rest non-executable */
31006 + for (addr = __START_KERNEL_map; addr < __START_KERNEL_map + KERNEL_IMAGE_SIZE; addr += PMD_SIZE) {
31007 + pgd = pgd_offset_k(addr);
31008 + pud = pud_offset(pgd, addr);
31009 + pmd = pmd_offset(pud, addr);
31010 + if (!pmd_present(*pmd))
31011 + continue;
31012 + if ((unsigned long)_text <= addr && addr < (unsigned long)_sdata)
31013 + set_pmd(pmd, __pmd(pmd_val(*pmd) & ~_PAGE_RW));
31014 + else
31015 + set_pmd(pmd, __pmd(pmd_val(*pmd) | (_PAGE_NX & __supported_pte_mask)));
31016 + }
31017 +
31018 + addr = (unsigned long)__va(__pa(__START_KERNEL_map));
31019 + end = addr + KERNEL_IMAGE_SIZE;
31020 + for (; addr < end; addr += PMD_SIZE) {
31021 + pgd = pgd_offset_k(addr);
31022 + pud = pud_offset(pgd, addr);
31023 + pmd = pmd_offset(pud, addr);
31024 + if (!pmd_present(*pmd))
31025 + continue;
31026 + if ((unsigned long)__va(__pa(_text)) <= addr && addr < (unsigned long)__va(__pa(_sdata)))
31027 + set_pmd(pmd, __pmd(pmd_val(*pmd) & ~_PAGE_RW));
31028 + }
31029 +#endif
31030 +
31031 + flush_tlb_all();
31032 +#endif
31033 +
31034 free_init_pages("unused kernel",
31035 (unsigned long)(&__init_begin),
31036 (unsigned long)(&__init_end));
31037 diff --git a/arch/x86/mm/init_32.c b/arch/x86/mm/init_32.c
31038 index 4287f1f..3b99c71 100644
31039 --- a/arch/x86/mm/init_32.c
31040 +++ b/arch/x86/mm/init_32.c
31041 @@ -62,33 +62,6 @@ static noinline int do_test_wp_bit(void);
31042 bool __read_mostly __vmalloc_start_set = false;
31043
31044 /*
31045 - * Creates a middle page table and puts a pointer to it in the
31046 - * given global directory entry. This only returns the gd entry
31047 - * in non-PAE compilation mode, since the middle layer is folded.
31048 - */
31049 -static pmd_t * __init one_md_table_init(pgd_t *pgd)
31050 -{
31051 - pud_t *pud;
31052 - pmd_t *pmd_table;
31053 -
31054 -#ifdef CONFIG_X86_PAE
31055 - if (!(pgd_val(*pgd) & _PAGE_PRESENT)) {
31056 - pmd_table = (pmd_t *)alloc_low_page();
31057 - paravirt_alloc_pmd(&init_mm, __pa(pmd_table) >> PAGE_SHIFT);
31058 - set_pgd(pgd, __pgd(__pa(pmd_table) | _PAGE_PRESENT));
31059 - pud = pud_offset(pgd, 0);
31060 - BUG_ON(pmd_table != pmd_offset(pud, 0));
31061 -
31062 - return pmd_table;
31063 - }
31064 -#endif
31065 - pud = pud_offset(pgd, 0);
31066 - pmd_table = pmd_offset(pud, 0);
31067 -
31068 - return pmd_table;
31069 -}
31070 -
31071 -/*
31072 * Create a page table and place a pointer to it in a middle page
31073 * directory entry:
31074 */
31075 @@ -98,13 +71,28 @@ static pte_t * __init one_page_table_init(pmd_t *pmd)
31076 pte_t *page_table = (pte_t *)alloc_low_page();
31077
31078 paravirt_alloc_pte(&init_mm, __pa(page_table) >> PAGE_SHIFT);
31079 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
31080 + set_pmd(pmd, __pmd(__pa(page_table) | _KERNPG_TABLE));
31081 +#else
31082 set_pmd(pmd, __pmd(__pa(page_table) | _PAGE_TABLE));
31083 +#endif
31084 BUG_ON(page_table != pte_offset_kernel(pmd, 0));
31085 }
31086
31087 return pte_offset_kernel(pmd, 0);
31088 }
31089
31090 +static pmd_t * __init one_md_table_init(pgd_t *pgd)
31091 +{
31092 + pud_t *pud;
31093 + pmd_t *pmd_table;
31094 +
31095 + pud = pud_offset(pgd, 0);
31096 + pmd_table = pmd_offset(pud, 0);
31097 +
31098 + return pmd_table;
31099 +}
31100 +
31101 pmd_t * __init populate_extra_pmd(unsigned long vaddr)
31102 {
31103 int pgd_idx = pgd_index(vaddr);
31104 @@ -208,6 +196,7 @@ page_table_range_init(unsigned long start, unsigned long end, pgd_t *pgd_base)
31105 int pgd_idx, pmd_idx;
31106 unsigned long vaddr;
31107 pgd_t *pgd;
31108 + pud_t *pud;
31109 pmd_t *pmd;
31110 pte_t *pte = NULL;
31111 unsigned long count = page_table_range_init_count(start, end);
31112 @@ -222,8 +211,13 @@ page_table_range_init(unsigned long start, unsigned long end, pgd_t *pgd_base)
31113 pgd = pgd_base + pgd_idx;
31114
31115 for ( ; (pgd_idx < PTRS_PER_PGD) && (vaddr != end); pgd++, pgd_idx++) {
31116 - pmd = one_md_table_init(pgd);
31117 - pmd = pmd + pmd_index(vaddr);
31118 + pud = pud_offset(pgd, vaddr);
31119 + pmd = pmd_offset(pud, vaddr);
31120 +
31121 +#ifdef CONFIG_X86_PAE
31122 + paravirt_alloc_pmd(&init_mm, __pa(pmd) >> PAGE_SHIFT);
31123 +#endif
31124 +
31125 for (; (pmd_idx < PTRS_PER_PMD) && (vaddr != end);
31126 pmd++, pmd_idx++) {
31127 pte = page_table_kmap_check(one_page_table_init(pmd),
31128 @@ -235,11 +229,20 @@ page_table_range_init(unsigned long start, unsigned long end, pgd_t *pgd_base)
31129 }
31130 }
31131
31132 -static inline int is_kernel_text(unsigned long addr)
31133 +static inline int is_kernel_text(unsigned long start, unsigned long end)
31134 {
31135 - if (addr >= (unsigned long)_text && addr <= (unsigned long)__init_end)
31136 - return 1;
31137 - return 0;
31138 + if ((start > ktla_ktva((unsigned long)_etext) ||
31139 + end <= ktla_ktva((unsigned long)_stext)) &&
31140 + (start > ktla_ktva((unsigned long)_einittext) ||
31141 + end <= ktla_ktva((unsigned long)_sinittext)) &&
31142 +
31143 +#ifdef CONFIG_ACPI_SLEEP
31144 + (start > (unsigned long)__va(acpi_wakeup_address) + 0x4000 || end <= (unsigned long)__va(acpi_wakeup_address)) &&
31145 +#endif
31146 +
31147 + (start > (unsigned long)__va(0xfffff) || end <= (unsigned long)__va(0xc0000)))
31148 + return 0;
31149 + return 1;
31150 }
31151
31152 /*
31153 @@ -256,9 +259,10 @@ kernel_physical_mapping_init(unsigned long start,
31154 unsigned long last_map_addr = end;
31155 unsigned long start_pfn, end_pfn;
31156 pgd_t *pgd_base = swapper_pg_dir;
31157 - int pgd_idx, pmd_idx, pte_ofs;
31158 + unsigned int pgd_idx, pmd_idx, pte_ofs;
31159 unsigned long pfn;
31160 pgd_t *pgd;
31161 + pud_t *pud;
31162 pmd_t *pmd;
31163 pte_t *pte;
31164 unsigned pages_2m, pages_4k;
31165 @@ -291,8 +295,13 @@ repeat:
31166 pfn = start_pfn;
31167 pgd_idx = pgd_index((pfn<<PAGE_SHIFT) + PAGE_OFFSET);
31168 pgd = pgd_base + pgd_idx;
31169 - for (; pgd_idx < PTRS_PER_PGD; pgd++, pgd_idx++) {
31170 - pmd = one_md_table_init(pgd);
31171 + for (; pgd_idx < PTRS_PER_PGD && pfn < max_low_pfn; pgd++, pgd_idx++) {
31172 + pud = pud_offset(pgd, 0);
31173 + pmd = pmd_offset(pud, 0);
31174 +
31175 +#ifdef CONFIG_X86_PAE
31176 + paravirt_alloc_pmd(&init_mm, __pa(pmd) >> PAGE_SHIFT);
31177 +#endif
31178
31179 if (pfn >= end_pfn)
31180 continue;
31181 @@ -304,14 +313,13 @@ repeat:
31182 #endif
31183 for (; pmd_idx < PTRS_PER_PMD && pfn < end_pfn;
31184 pmd++, pmd_idx++) {
31185 - unsigned int addr = pfn * PAGE_SIZE + PAGE_OFFSET;
31186 + unsigned long address = pfn * PAGE_SIZE + PAGE_OFFSET;
31187
31188 /*
31189 * Map with big pages if possible, otherwise
31190 * create normal page tables:
31191 */
31192 if (use_pse) {
31193 - unsigned int addr2;
31194 pgprot_t prot = PAGE_KERNEL_LARGE;
31195 /*
31196 * first pass will use the same initial
31197 @@ -322,11 +330,7 @@ repeat:
31198 _PAGE_PSE);
31199
31200 pfn &= PMD_MASK >> PAGE_SHIFT;
31201 - addr2 = (pfn + PTRS_PER_PTE-1) * PAGE_SIZE +
31202 - PAGE_OFFSET + PAGE_SIZE-1;
31203 -
31204 - if (is_kernel_text(addr) ||
31205 - is_kernel_text(addr2))
31206 + if (is_kernel_text(address, address + PMD_SIZE))
31207 prot = PAGE_KERNEL_LARGE_EXEC;
31208
31209 pages_2m++;
31210 @@ -343,7 +347,7 @@ repeat:
31211 pte_ofs = pte_index((pfn<<PAGE_SHIFT) + PAGE_OFFSET);
31212 pte += pte_ofs;
31213 for (; pte_ofs < PTRS_PER_PTE && pfn < end_pfn;
31214 - pte++, pfn++, pte_ofs++, addr += PAGE_SIZE) {
31215 + pte++, pfn++, pte_ofs++, address += PAGE_SIZE) {
31216 pgprot_t prot = PAGE_KERNEL;
31217 /*
31218 * first pass will use the same initial
31219 @@ -351,7 +355,7 @@ repeat:
31220 */
31221 pgprot_t init_prot = __pgprot(PTE_IDENT_ATTR);
31222
31223 - if (is_kernel_text(addr))
31224 + if (is_kernel_text(address, address + PAGE_SIZE))
31225 prot = PAGE_KERNEL_EXEC;
31226
31227 pages_4k++;
31228 @@ -474,7 +478,7 @@ void __init native_pagetable_init(void)
31229
31230 pud = pud_offset(pgd, va);
31231 pmd = pmd_offset(pud, va);
31232 - if (!pmd_present(*pmd))
31233 + if (!pmd_present(*pmd)) // PAX TODO || pmd_large(*pmd))
31234 break;
31235
31236 /* should not be large page here */
31237 @@ -532,12 +536,10 @@ void __init early_ioremap_page_table_range_init(void)
31238
31239 static void __init pagetable_init(void)
31240 {
31241 - pgd_t *pgd_base = swapper_pg_dir;
31242 -
31243 - permanent_kmaps_init(pgd_base);
31244 + permanent_kmaps_init(swapper_pg_dir);
31245 }
31246
31247 -pteval_t __supported_pte_mask __read_mostly = ~(_PAGE_NX | _PAGE_GLOBAL | _PAGE_IOMAP);
31248 +pteval_t __supported_pte_mask __read_only = ~(_PAGE_NX | _PAGE_GLOBAL | _PAGE_IOMAP);
31249 EXPORT_SYMBOL_GPL(__supported_pte_mask);
31250
31251 /* user-defined highmem size */
31252 @@ -787,10 +789,10 @@ void __init mem_init(void)
31253 ((unsigned long)&__init_end -
31254 (unsigned long)&__init_begin) >> 10,
31255
31256 - (unsigned long)&_etext, (unsigned long)&_edata,
31257 - ((unsigned long)&_edata - (unsigned long)&_etext) >> 10,
31258 + (unsigned long)&_sdata, (unsigned long)&_edata,
31259 + ((unsigned long)&_edata - (unsigned long)&_sdata) >> 10,
31260
31261 - (unsigned long)&_text, (unsigned long)&_etext,
31262 + ktla_ktva((unsigned long)&_text), ktla_ktva((unsigned long)&_etext),
31263 ((unsigned long)&_etext - (unsigned long)&_text) >> 10);
31264
31265 /*
31266 @@ -880,6 +882,7 @@ void set_kernel_text_rw(void)
31267 if (!kernel_set_to_readonly)
31268 return;
31269
31270 + start = ktla_ktva(start);
31271 pr_debug("Set kernel text: %lx - %lx for read write\n",
31272 start, start+size);
31273
31274 @@ -894,6 +897,7 @@ void set_kernel_text_ro(void)
31275 if (!kernel_set_to_readonly)
31276 return;
31277
31278 + start = ktla_ktva(start);
31279 pr_debug("Set kernel text: %lx - %lx for read only\n",
31280 start, start+size);
31281
31282 @@ -922,6 +926,7 @@ void mark_rodata_ro(void)
31283 unsigned long start = PFN_ALIGN(_text);
31284 unsigned long size = PFN_ALIGN(_etext) - start;
31285
31286 + start = ktla_ktva(start);
31287 set_pages_ro(virt_to_page(start), size >> PAGE_SHIFT);
31288 printk(KERN_INFO "Write protecting the kernel text: %luk\n",
31289 size >> 10);
31290 diff --git a/arch/x86/mm/init_64.c b/arch/x86/mm/init_64.c
31291 index 104d56a..62ba13f1 100644
31292 --- a/arch/x86/mm/init_64.c
31293 +++ b/arch/x86/mm/init_64.c
31294 @@ -151,7 +151,7 @@ early_param("gbpages", parse_direct_gbpages_on);
31295 * around without checking the pgd every time.
31296 */
31297
31298 -pteval_t __supported_pte_mask __read_mostly = ~_PAGE_IOMAP;
31299 +pteval_t __supported_pte_mask __read_only = ~(_PAGE_NX | _PAGE_IOMAP);
31300 EXPORT_SYMBOL_GPL(__supported_pte_mask);
31301
31302 int force_personality32;
31303 @@ -184,12 +184,29 @@ void sync_global_pgds(unsigned long start, unsigned long end)
31304
31305 for (address = start; address <= end; address += PGDIR_SIZE) {
31306 const pgd_t *pgd_ref = pgd_offset_k(address);
31307 +
31308 +#ifdef CONFIG_PAX_PER_CPU_PGD
31309 + unsigned long cpu;
31310 +#else
31311 struct page *page;
31312 +#endif
31313
31314 if (pgd_none(*pgd_ref))
31315 continue;
31316
31317 spin_lock(&pgd_lock);
31318 +
31319 +#ifdef CONFIG_PAX_PER_CPU_PGD
31320 + for (cpu = 0; cpu < nr_cpu_ids; ++cpu) {
31321 + pgd_t *pgd = pgd_offset_cpu(cpu, user, address);
31322 +
31323 + if (pgd_none(*pgd))
31324 + set_pgd(pgd, *pgd_ref);
31325 + else
31326 + BUG_ON(pgd_page_vaddr(*pgd)
31327 + != pgd_page_vaddr(*pgd_ref));
31328 + pgd = pgd_offset_cpu(cpu, kernel, address);
31329 +#else
31330 list_for_each_entry(page, &pgd_list, lru) {
31331 pgd_t *pgd;
31332 spinlock_t *pgt_lock;
31333 @@ -198,6 +215,7 @@ void sync_global_pgds(unsigned long start, unsigned long end)
31334 /* the pgt_lock only for Xen */
31335 pgt_lock = &pgd_page_get_mm(page)->page_table_lock;
31336 spin_lock(pgt_lock);
31337 +#endif
31338
31339 if (pgd_none(*pgd))
31340 set_pgd(pgd, *pgd_ref);
31341 @@ -205,7 +223,10 @@ void sync_global_pgds(unsigned long start, unsigned long end)
31342 BUG_ON(pgd_page_vaddr(*pgd)
31343 != pgd_page_vaddr(*pgd_ref));
31344
31345 +#ifndef CONFIG_PAX_PER_CPU_PGD
31346 spin_unlock(pgt_lock);
31347 +#endif
31348 +
31349 }
31350 spin_unlock(&pgd_lock);
31351 }
31352 @@ -238,7 +259,7 @@ static pud_t *fill_pud(pgd_t *pgd, unsigned long vaddr)
31353 {
31354 if (pgd_none(*pgd)) {
31355 pud_t *pud = (pud_t *)spp_getpage();
31356 - pgd_populate(&init_mm, pgd, pud);
31357 + pgd_populate_kernel(&init_mm, pgd, pud);
31358 if (pud != pud_offset(pgd, 0))
31359 printk(KERN_ERR "PAGETABLE BUG #00! %p <-> %p\n",
31360 pud, pud_offset(pgd, 0));
31361 @@ -250,7 +271,7 @@ static pmd_t *fill_pmd(pud_t *pud, unsigned long vaddr)
31362 {
31363 if (pud_none(*pud)) {
31364 pmd_t *pmd = (pmd_t *) spp_getpage();
31365 - pud_populate(&init_mm, pud, pmd);
31366 + pud_populate_kernel(&init_mm, pud, pmd);
31367 if (pmd != pmd_offset(pud, 0))
31368 printk(KERN_ERR "PAGETABLE BUG #01! %p <-> %p\n",
31369 pmd, pmd_offset(pud, 0));
31370 @@ -279,7 +300,9 @@ void set_pte_vaddr_pud(pud_t *pud_page, unsigned long vaddr, pte_t new_pte)
31371 pmd = fill_pmd(pud, vaddr);
31372 pte = fill_pte(pmd, vaddr);
31373
31374 + pax_open_kernel();
31375 set_pte(pte, new_pte);
31376 + pax_close_kernel();
31377
31378 /*
31379 * It's enough to flush this one mapping.
31380 @@ -338,14 +361,12 @@ static void __init __init_extra_mapping(unsigned long phys, unsigned long size,
31381 pgd = pgd_offset_k((unsigned long)__va(phys));
31382 if (pgd_none(*pgd)) {
31383 pud = (pud_t *) spp_getpage();
31384 - set_pgd(pgd, __pgd(__pa(pud) | _KERNPG_TABLE |
31385 - _PAGE_USER));
31386 + set_pgd(pgd, __pgd(__pa(pud) | _PAGE_TABLE));
31387 }
31388 pud = pud_offset(pgd, (unsigned long)__va(phys));
31389 if (pud_none(*pud)) {
31390 pmd = (pmd_t *) spp_getpage();
31391 - set_pud(pud, __pud(__pa(pmd) | _KERNPG_TABLE |
31392 - _PAGE_USER));
31393 + set_pud(pud, __pud(__pa(pmd) | _PAGE_TABLE));
31394 }
31395 pmd = pmd_offset(pud, phys);
31396 BUG_ON(!pmd_none(*pmd));
31397 @@ -586,7 +607,7 @@ phys_pud_init(pud_t *pud_page, unsigned long addr, unsigned long end,
31398 prot);
31399
31400 spin_lock(&init_mm.page_table_lock);
31401 - pud_populate(&init_mm, pud, pmd);
31402 + pud_populate_kernel(&init_mm, pud, pmd);
31403 spin_unlock(&init_mm.page_table_lock);
31404 }
31405 __flush_tlb_all();
31406 @@ -627,7 +648,7 @@ kernel_physical_mapping_init(unsigned long start,
31407 page_size_mask);
31408
31409 spin_lock(&init_mm.page_table_lock);
31410 - pgd_populate(&init_mm, pgd, pud);
31411 + pgd_populate_kernel(&init_mm, pgd, pud);
31412 spin_unlock(&init_mm.page_table_lock);
31413 pgd_changed = true;
31414 }
31415 @@ -1188,8 +1209,8 @@ int kern_addr_valid(unsigned long addr)
31416 static struct vm_area_struct gate_vma = {
31417 .vm_start = VSYSCALL_START,
31418 .vm_end = VSYSCALL_START + (VSYSCALL_MAPPED_PAGES * PAGE_SIZE),
31419 - .vm_page_prot = PAGE_READONLY_EXEC,
31420 - .vm_flags = VM_READ | VM_EXEC
31421 + .vm_page_prot = PAGE_READONLY,
31422 + .vm_flags = VM_READ
31423 };
31424
31425 struct vm_area_struct *get_gate_vma(struct mm_struct *mm)
31426 @@ -1223,7 +1244,7 @@ int in_gate_area_no_mm(unsigned long addr)
31427
31428 const char *arch_vma_name(struct vm_area_struct *vma)
31429 {
31430 - if (vma->vm_mm && vma->vm_start == (long)vma->vm_mm->context.vdso)
31431 + if (vma->vm_mm && vma->vm_start == vma->vm_mm->context.vdso)
31432 return "[vdso]";
31433 if (vma == &gate_vma)
31434 return "[vsyscall]";
31435 diff --git a/arch/x86/mm/iomap_32.c b/arch/x86/mm/iomap_32.c
31436 index 7b179b4..6bd17777 100644
31437 --- a/arch/x86/mm/iomap_32.c
31438 +++ b/arch/x86/mm/iomap_32.c
31439 @@ -64,7 +64,11 @@ void *kmap_atomic_prot_pfn(unsigned long pfn, pgprot_t prot)
31440 type = kmap_atomic_idx_push();
31441 idx = type + KM_TYPE_NR * smp_processor_id();
31442 vaddr = __fix_to_virt(FIX_KMAP_BEGIN + idx);
31443 +
31444 + pax_open_kernel();
31445 set_pte(kmap_pte - idx, pfn_pte(pfn, prot));
31446 + pax_close_kernel();
31447 +
31448 arch_flush_lazy_mmu_mode();
31449
31450 return (void *)vaddr;
31451 diff --git a/arch/x86/mm/ioremap.c b/arch/x86/mm/ioremap.c
31452 index 799580c..72f9fe0 100644
31453 --- a/arch/x86/mm/ioremap.c
31454 +++ b/arch/x86/mm/ioremap.c
31455 @@ -97,7 +97,7 @@ static void __iomem *__ioremap_caller(resource_size_t phys_addr,
31456 for (pfn = phys_addr >> PAGE_SHIFT; pfn <= last_pfn; pfn++) {
31457 int is_ram = page_is_ram(pfn);
31458
31459 - if (is_ram && pfn_valid(pfn) && !PageReserved(pfn_to_page(pfn)))
31460 + if (is_ram && pfn_valid(pfn) && (pfn >= 0x100 || !PageReserved(pfn_to_page(pfn))))
31461 return NULL;
31462 WARN_ON_ONCE(is_ram);
31463 }
31464 @@ -256,7 +256,7 @@ EXPORT_SYMBOL(ioremap_prot);
31465 *
31466 * Caller must ensure there is only one unmapping for the same pointer.
31467 */
31468 -void iounmap(volatile void __iomem *addr)
31469 +void iounmap(const volatile void __iomem *addr)
31470 {
31471 struct vm_struct *p, *o;
31472
31473 @@ -310,6 +310,9 @@ void *xlate_dev_mem_ptr(unsigned long phys)
31474
31475 /* If page is RAM, we can use __va. Otherwise ioremap and unmap. */
31476 if (page_is_ram(start >> PAGE_SHIFT))
31477 +#ifdef CONFIG_HIGHMEM
31478 + if ((start >> PAGE_SHIFT) < max_low_pfn)
31479 +#endif
31480 return __va(phys);
31481
31482 addr = (void __force *)ioremap_cache(start, PAGE_SIZE);
31483 @@ -322,6 +325,9 @@ void *xlate_dev_mem_ptr(unsigned long phys)
31484 void unxlate_dev_mem_ptr(unsigned long phys, void *addr)
31485 {
31486 if (page_is_ram(phys >> PAGE_SHIFT))
31487 +#ifdef CONFIG_HIGHMEM
31488 + if ((phys >> PAGE_SHIFT) < max_low_pfn)
31489 +#endif
31490 return;
31491
31492 iounmap((void __iomem *)((unsigned long)addr & PAGE_MASK));
31493 @@ -339,7 +345,7 @@ static int __init early_ioremap_debug_setup(char *str)
31494 early_param("early_ioremap_debug", early_ioremap_debug_setup);
31495
31496 static __initdata int after_paging_init;
31497 -static pte_t bm_pte[PAGE_SIZE/sizeof(pte_t)] __page_aligned_bss;
31498 +static pte_t bm_pte[PAGE_SIZE/sizeof(pte_t)] __read_only __aligned(PAGE_SIZE);
31499
31500 static inline pmd_t * __init early_ioremap_pmd(unsigned long addr)
31501 {
31502 @@ -376,8 +382,7 @@ void __init early_ioremap_init(void)
31503 slot_virt[i] = __fix_to_virt(FIX_BTMAP_BEGIN - NR_FIX_BTMAPS*i);
31504
31505 pmd = early_ioremap_pmd(fix_to_virt(FIX_BTMAP_BEGIN));
31506 - memset(bm_pte, 0, sizeof(bm_pte));
31507 - pmd_populate_kernel(&init_mm, pmd, bm_pte);
31508 + pmd_populate_user(&init_mm, pmd, bm_pte);
31509
31510 /*
31511 * The boot-ioremap range spans multiple pmds, for which
31512 diff --git a/arch/x86/mm/kmemcheck/kmemcheck.c b/arch/x86/mm/kmemcheck/kmemcheck.c
31513 index d87dd6d..bf3fa66 100644
31514 --- a/arch/x86/mm/kmemcheck/kmemcheck.c
31515 +++ b/arch/x86/mm/kmemcheck/kmemcheck.c
31516 @@ -622,9 +622,9 @@ bool kmemcheck_fault(struct pt_regs *regs, unsigned long address,
31517 * memory (e.g. tracked pages)? For now, we need this to avoid
31518 * invoking kmemcheck for PnP BIOS calls.
31519 */
31520 - if (regs->flags & X86_VM_MASK)
31521 + if (v8086_mode(regs))
31522 return false;
31523 - if (regs->cs != __KERNEL_CS)
31524 + if (regs->cs != __KERNEL_CS && regs->cs != __KERNEXEC_KERNEL_CS)
31525 return false;
31526
31527 pte = kmemcheck_pte_lookup(address);
31528 diff --git a/arch/x86/mm/mmap.c b/arch/x86/mm/mmap.c
31529 index 25e7e13..1964579 100644
31530 --- a/arch/x86/mm/mmap.c
31531 +++ b/arch/x86/mm/mmap.c
31532 @@ -52,7 +52,7 @@ static unsigned int stack_maxrandom_size(void)
31533 * Leave an at least ~128 MB hole with possible stack randomization.
31534 */
31535 #define MIN_GAP (128*1024*1024UL + stack_maxrandom_size())
31536 -#define MAX_GAP (TASK_SIZE/6*5)
31537 +#define MAX_GAP (pax_task_size/6*5)
31538
31539 static int mmap_is_legacy(void)
31540 {
31541 @@ -82,27 +82,40 @@ static unsigned long mmap_rnd(void)
31542 return rnd << PAGE_SHIFT;
31543 }
31544
31545 -static unsigned long mmap_base(void)
31546 +static unsigned long mmap_base(struct mm_struct *mm)
31547 {
31548 unsigned long gap = rlimit(RLIMIT_STACK);
31549 + unsigned long pax_task_size = TASK_SIZE;
31550 +
31551 +#ifdef CONFIG_PAX_SEGMEXEC
31552 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
31553 + pax_task_size = SEGMEXEC_TASK_SIZE;
31554 +#endif
31555
31556 if (gap < MIN_GAP)
31557 gap = MIN_GAP;
31558 else if (gap > MAX_GAP)
31559 gap = MAX_GAP;
31560
31561 - return PAGE_ALIGN(TASK_SIZE - gap - mmap_rnd());
31562 + return PAGE_ALIGN(pax_task_size - gap - mmap_rnd());
31563 }
31564
31565 /*
31566 * Bottom-up (legacy) layout on X86_32 did not support randomization, X86_64
31567 * does, but not when emulating X86_32
31568 */
31569 -static unsigned long mmap_legacy_base(void)
31570 +static unsigned long mmap_legacy_base(struct mm_struct *mm)
31571 {
31572 - if (mmap_is_ia32())
31573 + if (mmap_is_ia32()) {
31574 +
31575 +#ifdef CONFIG_PAX_SEGMEXEC
31576 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
31577 + return SEGMEXEC_TASK_UNMAPPED_BASE;
31578 + else
31579 +#endif
31580 +
31581 return TASK_UNMAPPED_BASE;
31582 - else
31583 + } else
31584 return TASK_UNMAPPED_BASE + mmap_rnd();
31585 }
31586
31587 @@ -112,8 +125,15 @@ static unsigned long mmap_legacy_base(void)
31588 */
31589 void arch_pick_mmap_layout(struct mm_struct *mm)
31590 {
31591 - mm->mmap_legacy_base = mmap_legacy_base();
31592 - mm->mmap_base = mmap_base();
31593 + mm->mmap_legacy_base = mmap_legacy_base(mm);
31594 + mm->mmap_base = mmap_base(mm);
31595 +
31596 +#ifdef CONFIG_PAX_RANDMMAP
31597 + if (mm->pax_flags & MF_PAX_RANDMMAP) {
31598 + mm->mmap_legacy_base += mm->delta_mmap;
31599 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
31600 + }
31601 +#endif
31602
31603 if (mmap_is_legacy()) {
31604 mm->mmap_base = mm->mmap_legacy_base;
31605 diff --git a/arch/x86/mm/mmio-mod.c b/arch/x86/mm/mmio-mod.c
31606 index 0057a7a..95c7edd 100644
31607 --- a/arch/x86/mm/mmio-mod.c
31608 +++ b/arch/x86/mm/mmio-mod.c
31609 @@ -194,7 +194,7 @@ static void pre(struct kmmio_probe *p, struct pt_regs *regs,
31610 break;
31611 default:
31612 {
31613 - unsigned char *ip = (unsigned char *)instptr;
31614 + unsigned char *ip = (unsigned char *)ktla_ktva(instptr);
31615 my_trace->opcode = MMIO_UNKNOWN_OP;
31616 my_trace->width = 0;
31617 my_trace->value = (*ip) << 16 | *(ip + 1) << 8 |
31618 @@ -234,7 +234,7 @@ static void post(struct kmmio_probe *p, unsigned long condition,
31619 static void ioremap_trace_core(resource_size_t offset, unsigned long size,
31620 void __iomem *addr)
31621 {
31622 - static atomic_t next_id;
31623 + static atomic_unchecked_t next_id;
31624 struct remap_trace *trace = kmalloc(sizeof(*trace), GFP_KERNEL);
31625 /* These are page-unaligned. */
31626 struct mmiotrace_map map = {
31627 @@ -258,7 +258,7 @@ static void ioremap_trace_core(resource_size_t offset, unsigned long size,
31628 .private = trace
31629 },
31630 .phys = offset,
31631 - .id = atomic_inc_return(&next_id)
31632 + .id = atomic_inc_return_unchecked(&next_id)
31633 };
31634 map.map_id = trace->id;
31635
31636 @@ -290,7 +290,7 @@ void mmiotrace_ioremap(resource_size_t offset, unsigned long size,
31637 ioremap_trace_core(offset, size, addr);
31638 }
31639
31640 -static void iounmap_trace_core(volatile void __iomem *addr)
31641 +static void iounmap_trace_core(const volatile void __iomem *addr)
31642 {
31643 struct mmiotrace_map map = {
31644 .phys = 0,
31645 @@ -328,7 +328,7 @@ not_enabled:
31646 }
31647 }
31648
31649 -void mmiotrace_iounmap(volatile void __iomem *addr)
31650 +void mmiotrace_iounmap(const volatile void __iomem *addr)
31651 {
31652 might_sleep();
31653 if (is_enabled()) /* recheck and proper locking in *_core() */
31654 diff --git a/arch/x86/mm/numa.c b/arch/x86/mm/numa.c
31655 index 8bf93ba..dbcd670 100644
31656 --- a/arch/x86/mm/numa.c
31657 +++ b/arch/x86/mm/numa.c
31658 @@ -474,7 +474,7 @@ static bool __init numa_meminfo_cover_memory(const struct numa_meminfo *mi)
31659 return true;
31660 }
31661
31662 -static int __init numa_register_memblks(struct numa_meminfo *mi)
31663 +static int __init __intentional_overflow(-1) numa_register_memblks(struct numa_meminfo *mi)
31664 {
31665 unsigned long uninitialized_var(pfn_align);
31666 int i, nid;
31667 diff --git a/arch/x86/mm/pageattr-test.c b/arch/x86/mm/pageattr-test.c
31668 index d0b1773..4c3327c 100644
31669 --- a/arch/x86/mm/pageattr-test.c
31670 +++ b/arch/x86/mm/pageattr-test.c
31671 @@ -36,7 +36,7 @@ enum {
31672
31673 static int pte_testbit(pte_t pte)
31674 {
31675 - return pte_flags(pte) & _PAGE_UNUSED1;
31676 + return pte_flags(pte) & _PAGE_CPA_TEST;
31677 }
31678
31679 struct split_state {
31680 diff --git a/arch/x86/mm/pageattr.c b/arch/x86/mm/pageattr.c
31681 index bb32480..75f2f5e 100644
31682 --- a/arch/x86/mm/pageattr.c
31683 +++ b/arch/x86/mm/pageattr.c
31684 @@ -261,7 +261,7 @@ static inline pgprot_t static_protections(pgprot_t prot, unsigned long address,
31685 */
31686 #ifdef CONFIG_PCI_BIOS
31687 if (pcibios_enabled && within(pfn, BIOS_BEGIN >> PAGE_SHIFT, BIOS_END >> PAGE_SHIFT))
31688 - pgprot_val(forbidden) |= _PAGE_NX;
31689 + pgprot_val(forbidden) |= _PAGE_NX & __supported_pte_mask;
31690 #endif
31691
31692 /*
31693 @@ -269,9 +269,10 @@ static inline pgprot_t static_protections(pgprot_t prot, unsigned long address,
31694 * Does not cover __inittext since that is gone later on. On
31695 * 64bit we do not enforce !NX on the low mapping
31696 */
31697 - if (within(address, (unsigned long)_text, (unsigned long)_etext))
31698 - pgprot_val(forbidden) |= _PAGE_NX;
31699 + if (within(address, ktla_ktva((unsigned long)_text), ktla_ktva((unsigned long)_etext)))
31700 + pgprot_val(forbidden) |= _PAGE_NX & __supported_pte_mask;
31701
31702 +#ifdef CONFIG_DEBUG_RODATA
31703 /*
31704 * The .rodata section needs to be read-only. Using the pfn
31705 * catches all aliases.
31706 @@ -279,6 +280,7 @@ static inline pgprot_t static_protections(pgprot_t prot, unsigned long address,
31707 if (within(pfn, __pa_symbol(__start_rodata) >> PAGE_SHIFT,
31708 __pa_symbol(__end_rodata) >> PAGE_SHIFT))
31709 pgprot_val(forbidden) |= _PAGE_RW;
31710 +#endif
31711
31712 #if defined(CONFIG_X86_64) && defined(CONFIG_DEBUG_RODATA)
31713 /*
31714 @@ -317,6 +319,13 @@ static inline pgprot_t static_protections(pgprot_t prot, unsigned long address,
31715 }
31716 #endif
31717
31718 +#ifdef CONFIG_PAX_KERNEXEC
31719 + if (within(pfn, __pa(ktla_ktva((unsigned long)&_text)), __pa((unsigned long)&_sdata))) {
31720 + pgprot_val(forbidden) |= _PAGE_RW;
31721 + pgprot_val(forbidden) |= _PAGE_NX & __supported_pte_mask;
31722 + }
31723 +#endif
31724 +
31725 prot = __pgprot(pgprot_val(prot) & ~pgprot_val(forbidden));
31726
31727 return prot;
31728 @@ -400,23 +409,37 @@ EXPORT_SYMBOL_GPL(slow_virt_to_phys);
31729 static void __set_pmd_pte(pte_t *kpte, unsigned long address, pte_t pte)
31730 {
31731 /* change init_mm */
31732 + pax_open_kernel();
31733 set_pte_atomic(kpte, pte);
31734 +
31735 #ifdef CONFIG_X86_32
31736 if (!SHARED_KERNEL_PMD) {
31737 +
31738 +#ifdef CONFIG_PAX_PER_CPU_PGD
31739 + unsigned long cpu;
31740 +#else
31741 struct page *page;
31742 +#endif
31743
31744 +#ifdef CONFIG_PAX_PER_CPU_PGD
31745 + for (cpu = 0; cpu < nr_cpu_ids; ++cpu) {
31746 + pgd_t *pgd = get_cpu_pgd(cpu, kernel);
31747 +#else
31748 list_for_each_entry(page, &pgd_list, lru) {
31749 - pgd_t *pgd;
31750 + pgd_t *pgd = (pgd_t *)page_address(page);
31751 +#endif
31752 +
31753 pud_t *pud;
31754 pmd_t *pmd;
31755
31756 - pgd = (pgd_t *)page_address(page) + pgd_index(address);
31757 + pgd += pgd_index(address);
31758 pud = pud_offset(pgd, address);
31759 pmd = pmd_offset(pud, address);
31760 set_pte_atomic((pte_t *)pmd, pte);
31761 }
31762 }
31763 #endif
31764 + pax_close_kernel();
31765 }
31766
31767 static int
31768 diff --git a/arch/x86/mm/pat.c b/arch/x86/mm/pat.c
31769 index 6574388..87e9bef 100644
31770 --- a/arch/x86/mm/pat.c
31771 +++ b/arch/x86/mm/pat.c
31772 @@ -376,7 +376,7 @@ int free_memtype(u64 start, u64 end)
31773
31774 if (!entry) {
31775 printk(KERN_INFO "%s:%d freeing invalid memtype [mem %#010Lx-%#010Lx]\n",
31776 - current->comm, current->pid, start, end - 1);
31777 + current->comm, task_pid_nr(current), start, end - 1);
31778 return -EINVAL;
31779 }
31780
31781 @@ -506,8 +506,8 @@ static inline int range_is_allowed(unsigned long pfn, unsigned long size)
31782
31783 while (cursor < to) {
31784 if (!devmem_is_allowed(pfn)) {
31785 - printk(KERN_INFO "Program %s tried to access /dev/mem between [mem %#010Lx-%#010Lx]\n",
31786 - current->comm, from, to - 1);
31787 + printk(KERN_INFO "Program %s tried to access /dev/mem between [mem %#010Lx-%#010Lx] (%#010Lx)\n",
31788 + current->comm, from, to - 1, cursor);
31789 return 0;
31790 }
31791 cursor += PAGE_SIZE;
31792 @@ -577,7 +577,7 @@ int kernel_map_sync_memtype(u64 base, unsigned long size, unsigned long flags)
31793 if (ioremap_change_attr((unsigned long)__va(base), id_sz, flags) < 0) {
31794 printk(KERN_INFO "%s:%d ioremap_change_attr failed %s "
31795 "for [mem %#010Lx-%#010Lx]\n",
31796 - current->comm, current->pid,
31797 + current->comm, task_pid_nr(current),
31798 cattr_name(flags),
31799 base, (unsigned long long)(base + size-1));
31800 return -EINVAL;
31801 @@ -612,7 +612,7 @@ static int reserve_pfn_range(u64 paddr, unsigned long size, pgprot_t *vma_prot,
31802 flags = lookup_memtype(paddr);
31803 if (want_flags != flags) {
31804 printk(KERN_WARNING "%s:%d map pfn RAM range req %s for [mem %#010Lx-%#010Lx], got %s\n",
31805 - current->comm, current->pid,
31806 + current->comm, task_pid_nr(current),
31807 cattr_name(want_flags),
31808 (unsigned long long)paddr,
31809 (unsigned long long)(paddr + size - 1),
31810 @@ -634,7 +634,7 @@ static int reserve_pfn_range(u64 paddr, unsigned long size, pgprot_t *vma_prot,
31811 free_memtype(paddr, paddr + size);
31812 printk(KERN_ERR "%s:%d map pfn expected mapping type %s"
31813 " for [mem %#010Lx-%#010Lx], got %s\n",
31814 - current->comm, current->pid,
31815 + current->comm, task_pid_nr(current),
31816 cattr_name(want_flags),
31817 (unsigned long long)paddr,
31818 (unsigned long long)(paddr + size - 1),
31819 diff --git a/arch/x86/mm/pat_rbtree.c b/arch/x86/mm/pat_rbtree.c
31820 index 415f6c4..d319983 100644
31821 --- a/arch/x86/mm/pat_rbtree.c
31822 +++ b/arch/x86/mm/pat_rbtree.c
31823 @@ -160,7 +160,7 @@ success:
31824
31825 failure:
31826 printk(KERN_INFO "%s:%d conflicting memory types "
31827 - "%Lx-%Lx %s<->%s\n", current->comm, current->pid, start,
31828 + "%Lx-%Lx %s<->%s\n", current->comm, task_pid_nr(current), start,
31829 end, cattr_name(found_type), cattr_name(match->type));
31830 return -EBUSY;
31831 }
31832 diff --git a/arch/x86/mm/pf_in.c b/arch/x86/mm/pf_in.c
31833 index 9f0614d..92ae64a 100644
31834 --- a/arch/x86/mm/pf_in.c
31835 +++ b/arch/x86/mm/pf_in.c
31836 @@ -148,7 +148,7 @@ enum reason_type get_ins_type(unsigned long ins_addr)
31837 int i;
31838 enum reason_type rv = OTHERS;
31839
31840 - p = (unsigned char *)ins_addr;
31841 + p = (unsigned char *)ktla_ktva(ins_addr);
31842 p += skip_prefix(p, &prf);
31843 p += get_opcode(p, &opcode);
31844
31845 @@ -168,7 +168,7 @@ static unsigned int get_ins_reg_width(unsigned long ins_addr)
31846 struct prefix_bits prf;
31847 int i;
31848
31849 - p = (unsigned char *)ins_addr;
31850 + p = (unsigned char *)ktla_ktva(ins_addr);
31851 p += skip_prefix(p, &prf);
31852 p += get_opcode(p, &opcode);
31853
31854 @@ -191,7 +191,7 @@ unsigned int get_ins_mem_width(unsigned long ins_addr)
31855 struct prefix_bits prf;
31856 int i;
31857
31858 - p = (unsigned char *)ins_addr;
31859 + p = (unsigned char *)ktla_ktva(ins_addr);
31860 p += skip_prefix(p, &prf);
31861 p += get_opcode(p, &opcode);
31862
31863 @@ -415,7 +415,7 @@ unsigned long get_ins_reg_val(unsigned long ins_addr, struct pt_regs *regs)
31864 struct prefix_bits prf;
31865 int i;
31866
31867 - p = (unsigned char *)ins_addr;
31868 + p = (unsigned char *)ktla_ktva(ins_addr);
31869 p += skip_prefix(p, &prf);
31870 p += get_opcode(p, &opcode);
31871 for (i = 0; i < ARRAY_SIZE(reg_rop); i++)
31872 @@ -470,7 +470,7 @@ unsigned long get_ins_imm_val(unsigned long ins_addr)
31873 struct prefix_bits prf;
31874 int i;
31875
31876 - p = (unsigned char *)ins_addr;
31877 + p = (unsigned char *)ktla_ktva(ins_addr);
31878 p += skip_prefix(p, &prf);
31879 p += get_opcode(p, &opcode);
31880 for (i = 0; i < ARRAY_SIZE(imm_wop); i++)
31881 diff --git a/arch/x86/mm/pgtable.c b/arch/x86/mm/pgtable.c
31882 index dfa537a..fd45c64 100644
31883 --- a/arch/x86/mm/pgtable.c
31884 +++ b/arch/x86/mm/pgtable.c
31885 @@ -91,10 +91,67 @@ static inline void pgd_list_del(pgd_t *pgd)
31886 list_del(&page->lru);
31887 }
31888
31889 -#define UNSHARED_PTRS_PER_PGD \
31890 - (SHARED_KERNEL_PMD ? KERNEL_PGD_BOUNDARY : PTRS_PER_PGD)
31891 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
31892 +pgdval_t clone_pgd_mask __read_only = ~_PAGE_PRESENT;
31893
31894 +void __shadow_user_pgds(pgd_t *dst, const pgd_t *src)
31895 +{
31896 + unsigned int count = USER_PGD_PTRS;
31897
31898 + if (!pax_user_shadow_base)
31899 + return;
31900 +
31901 + while (count--)
31902 + *dst++ = __pgd((pgd_val(*src++) | (_PAGE_NX & __supported_pte_mask)) & ~_PAGE_USER);
31903 +}
31904 +#endif
31905 +
31906 +#ifdef CONFIG_PAX_PER_CPU_PGD
31907 +void __clone_user_pgds(pgd_t *dst, const pgd_t *src)
31908 +{
31909 + unsigned int count = USER_PGD_PTRS;
31910 +
31911 + while (count--) {
31912 + pgd_t pgd;
31913 +
31914 +#ifdef CONFIG_X86_64
31915 + pgd = __pgd(pgd_val(*src++) | _PAGE_USER);
31916 +#else
31917 + pgd = *src++;
31918 +#endif
31919 +
31920 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
31921 + pgd = __pgd(pgd_val(pgd) & clone_pgd_mask);
31922 +#endif
31923 +
31924 + *dst++ = pgd;
31925 + }
31926 +
31927 +}
31928 +#endif
31929 +
31930 +#ifdef CONFIG_X86_64
31931 +#define pxd_t pud_t
31932 +#define pyd_t pgd_t
31933 +#define paravirt_release_pxd(pfn) paravirt_release_pud(pfn)
31934 +#define pxd_free(mm, pud) pud_free((mm), (pud))
31935 +#define pyd_populate(mm, pgd, pud) pgd_populate((mm), (pgd), (pud))
31936 +#define pyd_offset(mm, address) pgd_offset((mm), (address))
31937 +#define PYD_SIZE PGDIR_SIZE
31938 +#else
31939 +#define pxd_t pmd_t
31940 +#define pyd_t pud_t
31941 +#define paravirt_release_pxd(pfn) paravirt_release_pmd(pfn)
31942 +#define pxd_free(mm, pud) pmd_free((mm), (pud))
31943 +#define pyd_populate(mm, pgd, pud) pud_populate((mm), (pgd), (pud))
31944 +#define pyd_offset(mm, address) pud_offset((mm), (address))
31945 +#define PYD_SIZE PUD_SIZE
31946 +#endif
31947 +
31948 +#ifdef CONFIG_PAX_PER_CPU_PGD
31949 +static inline void pgd_ctor(struct mm_struct *mm, pgd_t *pgd) {}
31950 +static inline void pgd_dtor(pgd_t *pgd) {}
31951 +#else
31952 static void pgd_set_mm(pgd_t *pgd, struct mm_struct *mm)
31953 {
31954 BUILD_BUG_ON(sizeof(virt_to_page(pgd)->index) < sizeof(mm));
31955 @@ -135,6 +192,7 @@ static void pgd_dtor(pgd_t *pgd)
31956 pgd_list_del(pgd);
31957 spin_unlock(&pgd_lock);
31958 }
31959 +#endif
31960
31961 /*
31962 * List of all pgd's needed for non-PAE so it can invalidate entries
31963 @@ -147,7 +205,7 @@ static void pgd_dtor(pgd_t *pgd)
31964 * -- nyc
31965 */
31966
31967 -#ifdef CONFIG_X86_PAE
31968 +#if defined(CONFIG_X86_32) && defined(CONFIG_X86_PAE)
31969 /*
31970 * In PAE mode, we need to do a cr3 reload (=tlb flush) when
31971 * updating the top-level pagetable entries to guarantee the
31972 @@ -159,7 +217,7 @@ static void pgd_dtor(pgd_t *pgd)
31973 * not shared between pagetables (!SHARED_KERNEL_PMDS), we allocate
31974 * and initialize the kernel pmds here.
31975 */
31976 -#define PREALLOCATED_PMDS UNSHARED_PTRS_PER_PGD
31977 +#define PREALLOCATED_PXDS (SHARED_KERNEL_PMD ? KERNEL_PGD_BOUNDARY : PTRS_PER_PGD)
31978
31979 void pud_populate(struct mm_struct *mm, pud_t *pudp, pmd_t *pmd)
31980 {
31981 @@ -177,36 +235,38 @@ void pud_populate(struct mm_struct *mm, pud_t *pudp, pmd_t *pmd)
31982 */
31983 flush_tlb_mm(mm);
31984 }
31985 +#elif defined(CONFIG_X86_64) && defined(CONFIG_PAX_PER_CPU_PGD)
31986 +#define PREALLOCATED_PXDS USER_PGD_PTRS
31987 #else /* !CONFIG_X86_PAE */
31988
31989 /* No need to prepopulate any pagetable entries in non-PAE modes. */
31990 -#define PREALLOCATED_PMDS 0
31991 +#define PREALLOCATED_PXDS 0
31992
31993 #endif /* CONFIG_X86_PAE */
31994
31995 -static void free_pmds(pmd_t *pmds[])
31996 +static void free_pxds(pxd_t *pxds[])
31997 {
31998 int i;
31999
32000 - for(i = 0; i < PREALLOCATED_PMDS; i++)
32001 - if (pmds[i])
32002 - free_page((unsigned long)pmds[i]);
32003 + for(i = 0; i < PREALLOCATED_PXDS; i++)
32004 + if (pxds[i])
32005 + free_page((unsigned long)pxds[i]);
32006 }
32007
32008 -static int preallocate_pmds(pmd_t *pmds[])
32009 +static int preallocate_pxds(pxd_t *pxds[])
32010 {
32011 int i;
32012 bool failed = false;
32013
32014 - for(i = 0; i < PREALLOCATED_PMDS; i++) {
32015 - pmd_t *pmd = (pmd_t *)__get_free_page(PGALLOC_GFP);
32016 - if (pmd == NULL)
32017 + for(i = 0; i < PREALLOCATED_PXDS; i++) {
32018 + pxd_t *pxd = (pxd_t *)__get_free_page(PGALLOC_GFP);
32019 + if (pxd == NULL)
32020 failed = true;
32021 - pmds[i] = pmd;
32022 + pxds[i] = pxd;
32023 }
32024
32025 if (failed) {
32026 - free_pmds(pmds);
32027 + free_pxds(pxds);
32028 return -ENOMEM;
32029 }
32030
32031 @@ -219,49 +279,52 @@ static int preallocate_pmds(pmd_t *pmds[])
32032 * preallocate which never got a corresponding vma will need to be
32033 * freed manually.
32034 */
32035 -static void pgd_mop_up_pmds(struct mm_struct *mm, pgd_t *pgdp)
32036 +static void pgd_mop_up_pxds(struct mm_struct *mm, pgd_t *pgdp)
32037 {
32038 int i;
32039
32040 - for(i = 0; i < PREALLOCATED_PMDS; i++) {
32041 + for(i = 0; i < PREALLOCATED_PXDS; i++) {
32042 pgd_t pgd = pgdp[i];
32043
32044 if (pgd_val(pgd) != 0) {
32045 - pmd_t *pmd = (pmd_t *)pgd_page_vaddr(pgd);
32046 + pxd_t *pxd = (pxd_t *)pgd_page_vaddr(pgd);
32047
32048 - pgdp[i] = native_make_pgd(0);
32049 + set_pgd(pgdp + i, native_make_pgd(0));
32050
32051 - paravirt_release_pmd(pgd_val(pgd) >> PAGE_SHIFT);
32052 - pmd_free(mm, pmd);
32053 + paravirt_release_pxd(pgd_val(pgd) >> PAGE_SHIFT);
32054 + pxd_free(mm, pxd);
32055 }
32056 }
32057 }
32058
32059 -static void pgd_prepopulate_pmd(struct mm_struct *mm, pgd_t *pgd, pmd_t *pmds[])
32060 +static void pgd_prepopulate_pxd(struct mm_struct *mm, pgd_t *pgd, pxd_t *pxds[])
32061 {
32062 - pud_t *pud;
32063 + pyd_t *pyd;
32064 int i;
32065
32066 - if (PREALLOCATED_PMDS == 0) /* Work around gcc-3.4.x bug */
32067 + if (PREALLOCATED_PXDS == 0) /* Work around gcc-3.4.x bug */
32068 return;
32069
32070 - pud = pud_offset(pgd, 0);
32071 -
32072 - for (i = 0; i < PREALLOCATED_PMDS; i++, pud++) {
32073 - pmd_t *pmd = pmds[i];
32074 +#ifdef CONFIG_X86_64
32075 + pyd = pyd_offset(mm, 0L);
32076 +#else
32077 + pyd = pyd_offset(pgd, 0L);
32078 +#endif
32079
32080 + for (i = 0; i < PREALLOCATED_PXDS; i++, pyd++) {
32081 + pxd_t *pxd = pxds[i];
32082 if (i >= KERNEL_PGD_BOUNDARY)
32083 - memcpy(pmd, (pmd_t *)pgd_page_vaddr(swapper_pg_dir[i]),
32084 - sizeof(pmd_t) * PTRS_PER_PMD);
32085 + memcpy(pxd, (pxd_t *)pgd_page_vaddr(swapper_pg_dir[i]),
32086 + sizeof(pxd_t) * PTRS_PER_PMD);
32087
32088 - pud_populate(mm, pud, pmd);
32089 + pyd_populate(mm, pyd, pxd);
32090 }
32091 }
32092
32093 pgd_t *pgd_alloc(struct mm_struct *mm)
32094 {
32095 pgd_t *pgd;
32096 - pmd_t *pmds[PREALLOCATED_PMDS];
32097 + pxd_t *pxds[PREALLOCATED_PXDS];
32098
32099 pgd = (pgd_t *)__get_free_page(PGALLOC_GFP);
32100
32101 @@ -270,11 +333,11 @@ pgd_t *pgd_alloc(struct mm_struct *mm)
32102
32103 mm->pgd = pgd;
32104
32105 - if (preallocate_pmds(pmds) != 0)
32106 + if (preallocate_pxds(pxds) != 0)
32107 goto out_free_pgd;
32108
32109 if (paravirt_pgd_alloc(mm) != 0)
32110 - goto out_free_pmds;
32111 + goto out_free_pxds;
32112
32113 /*
32114 * Make sure that pre-populating the pmds is atomic with
32115 @@ -284,14 +347,14 @@ pgd_t *pgd_alloc(struct mm_struct *mm)
32116 spin_lock(&pgd_lock);
32117
32118 pgd_ctor(mm, pgd);
32119 - pgd_prepopulate_pmd(mm, pgd, pmds);
32120 + pgd_prepopulate_pxd(mm, pgd, pxds);
32121
32122 spin_unlock(&pgd_lock);
32123
32124 return pgd;
32125
32126 -out_free_pmds:
32127 - free_pmds(pmds);
32128 +out_free_pxds:
32129 + free_pxds(pxds);
32130 out_free_pgd:
32131 free_page((unsigned long)pgd);
32132 out:
32133 @@ -300,7 +363,7 @@ out:
32134
32135 void pgd_free(struct mm_struct *mm, pgd_t *pgd)
32136 {
32137 - pgd_mop_up_pmds(mm, pgd);
32138 + pgd_mop_up_pxds(mm, pgd);
32139 pgd_dtor(pgd);
32140 paravirt_pgd_free(mm, pgd);
32141 free_page((unsigned long)pgd);
32142 diff --git a/arch/x86/mm/pgtable_32.c b/arch/x86/mm/pgtable_32.c
32143 index a69bcb8..19068ab 100644
32144 --- a/arch/x86/mm/pgtable_32.c
32145 +++ b/arch/x86/mm/pgtable_32.c
32146 @@ -47,10 +47,13 @@ void set_pte_vaddr(unsigned long vaddr, pte_t pteval)
32147 return;
32148 }
32149 pte = pte_offset_kernel(pmd, vaddr);
32150 +
32151 + pax_open_kernel();
32152 if (pte_val(pteval))
32153 set_pte_at(&init_mm, vaddr, pte, pteval);
32154 else
32155 pte_clear(&init_mm, vaddr, pte);
32156 + pax_close_kernel();
32157
32158 /*
32159 * It's enough to flush this one mapping.
32160 diff --git a/arch/x86/mm/physaddr.c b/arch/x86/mm/physaddr.c
32161 index e666cbb..61788c45 100644
32162 --- a/arch/x86/mm/physaddr.c
32163 +++ b/arch/x86/mm/physaddr.c
32164 @@ -10,7 +10,7 @@
32165 #ifdef CONFIG_X86_64
32166
32167 #ifdef CONFIG_DEBUG_VIRTUAL
32168 -unsigned long __phys_addr(unsigned long x)
32169 +unsigned long __intentional_overflow(-1) __phys_addr(unsigned long x)
32170 {
32171 unsigned long y = x - __START_KERNEL_map;
32172
32173 @@ -67,7 +67,7 @@ EXPORT_SYMBOL(__virt_addr_valid);
32174 #else
32175
32176 #ifdef CONFIG_DEBUG_VIRTUAL
32177 -unsigned long __phys_addr(unsigned long x)
32178 +unsigned long __intentional_overflow(-1) __phys_addr(unsigned long x)
32179 {
32180 unsigned long phys_addr = x - PAGE_OFFSET;
32181 /* VMALLOC_* aren't constants */
32182 diff --git a/arch/x86/mm/setup_nx.c b/arch/x86/mm/setup_nx.c
32183 index 90555bf..f5f1828 100644
32184 --- a/arch/x86/mm/setup_nx.c
32185 +++ b/arch/x86/mm/setup_nx.c
32186 @@ -5,8 +5,10 @@
32187 #include <asm/pgtable.h>
32188 #include <asm/proto.h>
32189
32190 +#if defined(CONFIG_X86_64) || defined(CONFIG_X86_PAE)
32191 static int disable_nx;
32192
32193 +#ifndef CONFIG_PAX_PAGEEXEC
32194 /*
32195 * noexec = on|off
32196 *
32197 @@ -28,12 +30,17 @@ static int __init noexec_setup(char *str)
32198 return 0;
32199 }
32200 early_param("noexec", noexec_setup);
32201 +#endif
32202 +
32203 +#endif
32204
32205 void x86_configure_nx(void)
32206 {
32207 +#if defined(CONFIG_X86_64) || defined(CONFIG_X86_PAE)
32208 if (cpu_has_nx && !disable_nx)
32209 __supported_pte_mask |= _PAGE_NX;
32210 else
32211 +#endif
32212 __supported_pte_mask &= ~_PAGE_NX;
32213 }
32214
32215 diff --git a/arch/x86/mm/tlb.c b/arch/x86/mm/tlb.c
32216 index ae699b3..f1b2ad2 100644
32217 --- a/arch/x86/mm/tlb.c
32218 +++ b/arch/x86/mm/tlb.c
32219 @@ -48,7 +48,11 @@ void leave_mm(int cpu)
32220 BUG();
32221 if (cpumask_test_cpu(cpu, mm_cpumask(active_mm))) {
32222 cpumask_clear_cpu(cpu, mm_cpumask(active_mm));
32223 +
32224 +#ifndef CONFIG_PAX_PER_CPU_PGD
32225 load_cr3(swapper_pg_dir);
32226 +#endif
32227 +
32228 }
32229 }
32230 EXPORT_SYMBOL_GPL(leave_mm);
32231 diff --git a/arch/x86/mm/uderef_64.c b/arch/x86/mm/uderef_64.c
32232 new file mode 100644
32233 index 0000000..dace51c
32234 --- /dev/null
32235 +++ b/arch/x86/mm/uderef_64.c
32236 @@ -0,0 +1,37 @@
32237 +#include <linux/mm.h>
32238 +#include <asm/pgtable.h>
32239 +#include <asm/uaccess.h>
32240 +
32241 +#ifdef CONFIG_PAX_MEMORY_UDEREF
32242 +/* PaX: due to the special call convention these functions must
32243 + * - remain leaf functions under all configurations,
32244 + * - never be called directly, only dereferenced from the wrappers.
32245 + */
32246 +void __pax_open_userland(void)
32247 +{
32248 + unsigned int cpu;
32249 +
32250 + if (unlikely(!segment_eq(get_fs(), USER_DS)))
32251 + return;
32252 +
32253 + cpu = raw_get_cpu();
32254 + BUG_ON((read_cr3() & ~PAGE_MASK) != PCID_KERNEL);
32255 + write_cr3(__pa(get_cpu_pgd(cpu, user)) | PCID_USER | PCID_NOFLUSH);
32256 + raw_put_cpu_no_resched();
32257 +}
32258 +EXPORT_SYMBOL(__pax_open_userland);
32259 +
32260 +void __pax_close_userland(void)
32261 +{
32262 + unsigned int cpu;
32263 +
32264 + if (unlikely(!segment_eq(get_fs(), USER_DS)))
32265 + return;
32266 +
32267 + cpu = raw_get_cpu();
32268 + BUG_ON((read_cr3() & ~PAGE_MASK) != PCID_USER);
32269 + write_cr3(__pa(get_cpu_pgd(cpu, kernel)) | PCID_KERNEL | PCID_NOFLUSH);
32270 + raw_put_cpu_no_resched();
32271 +}
32272 +EXPORT_SYMBOL(__pax_close_userland);
32273 +#endif
32274 diff --git a/arch/x86/net/bpf_jit.S b/arch/x86/net/bpf_jit.S
32275 index 877b9a1..a8ecf42 100644
32276 --- a/arch/x86/net/bpf_jit.S
32277 +++ b/arch/x86/net/bpf_jit.S
32278 @@ -9,6 +9,7 @@
32279 */
32280 #include <linux/linkage.h>
32281 #include <asm/dwarf2.h>
32282 +#include <asm/alternative-asm.h>
32283
32284 /*
32285 * Calling convention :
32286 @@ -35,6 +36,7 @@ sk_load_word_positive_offset:
32287 jle bpf_slow_path_word
32288 mov (SKBDATA,%rsi),%eax
32289 bswap %eax /* ntohl() */
32290 + pax_force_retaddr
32291 ret
32292
32293 sk_load_half:
32294 @@ -52,6 +54,7 @@ sk_load_half_positive_offset:
32295 jle bpf_slow_path_half
32296 movzwl (SKBDATA,%rsi),%eax
32297 rol $8,%ax # ntohs()
32298 + pax_force_retaddr
32299 ret
32300
32301 sk_load_byte:
32302 @@ -66,6 +69,7 @@ sk_load_byte_positive_offset:
32303 cmp %esi,%r9d /* if (offset >= hlen) goto bpf_slow_path_byte */
32304 jle bpf_slow_path_byte
32305 movzbl (SKBDATA,%rsi),%eax
32306 + pax_force_retaddr
32307 ret
32308
32309 /**
32310 @@ -87,6 +91,7 @@ sk_load_byte_msh_positive_offset:
32311 movzbl (SKBDATA,%rsi),%ebx
32312 and $15,%bl
32313 shl $2,%bl
32314 + pax_force_retaddr
32315 ret
32316
32317 /* rsi contains offset and can be scratched */
32318 @@ -109,6 +114,7 @@ bpf_slow_path_word:
32319 js bpf_error
32320 mov -12(%rbp),%eax
32321 bswap %eax
32322 + pax_force_retaddr
32323 ret
32324
32325 bpf_slow_path_half:
32326 @@ -117,12 +123,14 @@ bpf_slow_path_half:
32327 mov -12(%rbp),%ax
32328 rol $8,%ax
32329 movzwl %ax,%eax
32330 + pax_force_retaddr
32331 ret
32332
32333 bpf_slow_path_byte:
32334 bpf_slow_path_common(1)
32335 js bpf_error
32336 movzbl -12(%rbp),%eax
32337 + pax_force_retaddr
32338 ret
32339
32340 bpf_slow_path_byte_msh:
32341 @@ -133,6 +141,7 @@ bpf_slow_path_byte_msh:
32342 and $15,%al
32343 shl $2,%al
32344 xchg %eax,%ebx
32345 + pax_force_retaddr
32346 ret
32347
32348 #define sk_negative_common(SIZE) \
32349 @@ -157,6 +166,7 @@ sk_load_word_negative_offset:
32350 sk_negative_common(4)
32351 mov (%rax), %eax
32352 bswap %eax
32353 + pax_force_retaddr
32354 ret
32355
32356 bpf_slow_path_half_neg:
32357 @@ -168,6 +178,7 @@ sk_load_half_negative_offset:
32358 mov (%rax),%ax
32359 rol $8,%ax
32360 movzwl %ax,%eax
32361 + pax_force_retaddr
32362 ret
32363
32364 bpf_slow_path_byte_neg:
32365 @@ -177,6 +188,7 @@ sk_load_byte_negative_offset:
32366 .globl sk_load_byte_negative_offset
32367 sk_negative_common(1)
32368 movzbl (%rax), %eax
32369 + pax_force_retaddr
32370 ret
32371
32372 bpf_slow_path_byte_msh_neg:
32373 @@ -190,6 +202,7 @@ sk_load_byte_msh_negative_offset:
32374 and $15,%al
32375 shl $2,%al
32376 xchg %eax,%ebx
32377 + pax_force_retaddr
32378 ret
32379
32380 bpf_error:
32381 @@ -197,4 +210,5 @@ bpf_error:
32382 xor %eax,%eax
32383 mov -8(%rbp),%rbx
32384 leaveq
32385 + pax_force_retaddr
32386 ret
32387 diff --git a/arch/x86/net/bpf_jit_comp.c b/arch/x86/net/bpf_jit_comp.c
32388 index 26328e8..5f96c25 100644
32389 --- a/arch/x86/net/bpf_jit_comp.c
32390 +++ b/arch/x86/net/bpf_jit_comp.c
32391 @@ -50,13 +50,90 @@ static inline u8 *emit_code(u8 *ptr, u32 bytes, unsigned int len)
32392 return ptr + len;
32393 }
32394
32395 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
32396 +#define MAX_INSTR_CODE_SIZE 96
32397 +#else
32398 +#define MAX_INSTR_CODE_SIZE 64
32399 +#endif
32400 +
32401 #define EMIT(bytes, len) do { prog = emit_code(prog, bytes, len); } while (0)
32402
32403 #define EMIT1(b1) EMIT(b1, 1)
32404 #define EMIT2(b1, b2) EMIT((b1) + ((b2) << 8), 2)
32405 #define EMIT3(b1, b2, b3) EMIT((b1) + ((b2) << 8) + ((b3) << 16), 3)
32406 #define EMIT4(b1, b2, b3, b4) EMIT((b1) + ((b2) << 8) + ((b3) << 16) + ((b4) << 24), 4)
32407 +
32408 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
32409 +/* original constant will appear in ecx */
32410 +#define DILUTE_CONST_SEQUENCE(_off, _key) \
32411 +do { \
32412 + /* mov ecx, randkey */ \
32413 + EMIT1(0xb9); \
32414 + EMIT(_key, 4); \
32415 + /* xor ecx, randkey ^ off */ \
32416 + EMIT2(0x81, 0xf1); \
32417 + EMIT((_key) ^ (_off), 4); \
32418 +} while (0)
32419 +
32420 +#define EMIT1_off32(b1, _off) \
32421 +do { \
32422 + switch (b1) { \
32423 + case 0x05: /* add eax, imm32 */ \
32424 + case 0x2d: /* sub eax, imm32 */ \
32425 + case 0x25: /* and eax, imm32 */ \
32426 + case 0x0d: /* or eax, imm32 */ \
32427 + case 0xb8: /* mov eax, imm32 */ \
32428 + case 0x35: /* xor eax, imm32 */ \
32429 + case 0x3d: /* cmp eax, imm32 */ \
32430 + case 0xa9: /* test eax, imm32 */ \
32431 + DILUTE_CONST_SEQUENCE(_off, randkey); \
32432 + EMIT2((b1) - 4, 0xc8); /* convert imm instruction to eax, ecx */\
32433 + break; \
32434 + case 0xbb: /* mov ebx, imm32 */ \
32435 + DILUTE_CONST_SEQUENCE(_off, randkey); \
32436 + /* mov ebx, ecx */ \
32437 + EMIT2(0x89, 0xcb); \
32438 + break; \
32439 + case 0xbe: /* mov esi, imm32 */ \
32440 + DILUTE_CONST_SEQUENCE(_off, randkey); \
32441 + /* mov esi, ecx */ \
32442 + EMIT2(0x89, 0xce); \
32443 + break; \
32444 + case 0xe8: /* call rel imm32, always to known funcs */ \
32445 + EMIT1(b1); \
32446 + EMIT(_off, 4); \
32447 + break; \
32448 + case 0xe9: /* jmp rel imm32 */ \
32449 + EMIT1(b1); \
32450 + EMIT(_off, 4); \
32451 + /* prevent fall-through, we're not called if off = 0 */ \
32452 + EMIT(0xcccccccc, 4); \
32453 + EMIT(0xcccccccc, 4); \
32454 + break; \
32455 + default: \
32456 + BUILD_BUG(); \
32457 + } \
32458 +} while (0)
32459 +
32460 +#define EMIT2_off32(b1, b2, _off) \
32461 +do { \
32462 + if ((b1) == 0x8d && (b2) == 0xb3) { /* lea esi, [rbx+imm32] */ \
32463 + EMIT2(0x8d, 0xb3); /* lea esi, [rbx+randkey] */ \
32464 + EMIT(randkey, 4); \
32465 + EMIT2(0x8d, 0xb6); /* lea esi, [esi+off-randkey] */ \
32466 + EMIT((_off) - randkey, 4); \
32467 + } else if ((b1) == 0x69 && (b2) == 0xc0) { /* imul eax, imm32 */\
32468 + DILUTE_CONST_SEQUENCE(_off, randkey); \
32469 + /* imul eax, ecx */ \
32470 + EMIT3(0x0f, 0xaf, 0xc1); \
32471 + } else { \
32472 + BUILD_BUG(); \
32473 + } \
32474 +} while (0)
32475 +#else
32476 #define EMIT1_off32(b1, off) do { EMIT1(b1); EMIT(off, 4);} while (0)
32477 +#define EMIT2_off32(b1, b2, off) do { EMIT2(b1, b2); EMIT(off, 4);} while (0)
32478 +#endif
32479
32480 #define CLEAR_A() EMIT2(0x31, 0xc0) /* xor %eax,%eax */
32481 #define CLEAR_X() EMIT2(0x31, 0xdb) /* xor %ebx,%ebx */
32482 @@ -91,6 +168,24 @@ do { \
32483 #define X86_JBE 0x76
32484 #define X86_JA 0x77
32485
32486 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
32487 +#define APPEND_FLOW_VERIFY() \
32488 +do { \
32489 + /* mov ecx, randkey */ \
32490 + EMIT1(0xb9); \
32491 + EMIT(randkey, 4); \
32492 + /* cmp ecx, randkey */ \
32493 + EMIT2(0x81, 0xf9); \
32494 + EMIT(randkey, 4); \
32495 + /* jz after 8 int 3s */ \
32496 + EMIT2(0x74, 0x08); \
32497 + EMIT(0xcccccccc, 4); \
32498 + EMIT(0xcccccccc, 4); \
32499 +} while (0)
32500 +#else
32501 +#define APPEND_FLOW_VERIFY() do { } while (0)
32502 +#endif
32503 +
32504 #define EMIT_COND_JMP(op, offset) \
32505 do { \
32506 if (is_near(offset)) \
32507 @@ -98,6 +193,7 @@ do { \
32508 else { \
32509 EMIT2(0x0f, op + 0x10); \
32510 EMIT(offset, 4); /* jxx .+off32 */ \
32511 + APPEND_FLOW_VERIFY(); \
32512 } \
32513 } while (0)
32514
32515 @@ -145,55 +241,54 @@ static int pkt_type_offset(void)
32516 return -1;
32517 }
32518
32519 -struct bpf_binary_header {
32520 - unsigned int pages;
32521 - /* Note : for security reasons, bpf code will follow a randomly
32522 - * sized amount of int3 instructions
32523 - */
32524 - u8 image[];
32525 -};
32526 -
32527 -static struct bpf_binary_header *bpf_alloc_binary(unsigned int proglen,
32528 +/* Note : for security reasons, bpf code will follow a randomly
32529 + * sized amount of int3 instructions
32530 + */
32531 +static u8 *bpf_alloc_binary(unsigned int proglen,
32532 u8 **image_ptr)
32533 {
32534 unsigned int sz, hole;
32535 - struct bpf_binary_header *header;
32536 + u8 *header;
32537
32538 /* Most of BPF filters are really small,
32539 * but if some of them fill a page, allow at least
32540 * 128 extra bytes to insert a random section of int3
32541 */
32542 - sz = round_up(proglen + sizeof(*header) + 128, PAGE_SIZE);
32543 - header = module_alloc(sz);
32544 + sz = round_up(proglen + 128, PAGE_SIZE);
32545 + header = module_alloc_exec(sz);
32546 if (!header)
32547 return NULL;
32548
32549 + pax_open_kernel();
32550 memset(header, 0xcc, sz); /* fill whole space with int3 instructions */
32551 + pax_close_kernel();
32552
32553 - header->pages = sz / PAGE_SIZE;
32554 - hole = sz - (proglen + sizeof(*header));
32555 + hole = PAGE_SIZE - (proglen & ~PAGE_MASK);
32556
32557 /* insert a random number of int3 instructions before BPF code */
32558 - *image_ptr = &header->image[prandom_u32() % hole];
32559 + *image_ptr = &header[prandom_u32() % hole];
32560 return header;
32561 }
32562
32563 void bpf_jit_compile(struct sk_filter *fp)
32564 {
32565 - u8 temp[64];
32566 + u8 temp[MAX_INSTR_CODE_SIZE];
32567 u8 *prog;
32568 unsigned int proglen, oldproglen = 0;
32569 int ilen, i;
32570 int t_offset, f_offset;
32571 u8 t_op, f_op, seen = 0, pass;
32572 u8 *image = NULL;
32573 - struct bpf_binary_header *header = NULL;
32574 + u8 *header = NULL;
32575 u8 *func;
32576 int pc_ret0 = -1; /* bpf index of first RET #0 instruction (if any) */
32577 unsigned int cleanup_addr; /* epilogue code offset */
32578 unsigned int *addrs;
32579 const struct sock_filter *filter = fp->insns;
32580 int flen = fp->len;
32581 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
32582 + unsigned int randkey;
32583 +#endif
32584
32585 if (!bpf_jit_enable)
32586 return;
32587 @@ -202,11 +297,15 @@ void bpf_jit_compile(struct sk_filter *fp)
32588 if (addrs == NULL)
32589 return;
32590
32591 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
32592 + randkey = get_random_int();
32593 +#endif
32594 +
32595 /* Before first pass, make a rough estimation of addrs[]
32596 - * each bpf instruction is translated to less than 64 bytes
32597 + * each bpf instruction is translated to less than MAX_INSTR_CODE_SIZE bytes
32598 */
32599 for (proglen = 0, i = 0; i < flen; i++) {
32600 - proglen += 64;
32601 + proglen += MAX_INSTR_CODE_SIZE;
32602 addrs[i] = proglen;
32603 }
32604 cleanup_addr = proglen; /* epilogue address */
32605 @@ -317,10 +416,8 @@ void bpf_jit_compile(struct sk_filter *fp)
32606 case BPF_S_ALU_MUL_K: /* A *= K */
32607 if (is_imm8(K))
32608 EMIT3(0x6b, 0xc0, K); /* imul imm8,%eax,%eax */
32609 - else {
32610 - EMIT2(0x69, 0xc0); /* imul imm32,%eax */
32611 - EMIT(K, 4);
32612 - }
32613 + else
32614 + EMIT2_off32(0x69, 0xc0, K); /* imul imm32,%eax */
32615 break;
32616 case BPF_S_ALU_DIV_X: /* A /= X; */
32617 seen |= SEEN_XREG;
32618 @@ -360,13 +457,23 @@ void bpf_jit_compile(struct sk_filter *fp)
32619 break;
32620 case BPF_S_ALU_MOD_K: /* A %= K; */
32621 EMIT2(0x31, 0xd2); /* xor %edx,%edx */
32622 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
32623 + DILUTE_CONST_SEQUENCE(K, randkey);
32624 +#else
32625 EMIT1(0xb9);EMIT(K, 4); /* mov imm32,%ecx */
32626 +#endif
32627 EMIT2(0xf7, 0xf1); /* div %ecx */
32628 EMIT2(0x89, 0xd0); /* mov %edx,%eax */
32629 break;
32630 case BPF_S_ALU_DIV_K: /* A = reciprocal_divide(A, K); */
32631 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
32632 + DILUTE_CONST_SEQUENCE(K, randkey);
32633 + // imul rax, rcx
32634 + EMIT4(0x48, 0x0f, 0xaf, 0xc1);
32635 +#else
32636 EMIT3(0x48, 0x69, 0xc0); /* imul imm32,%rax,%rax */
32637 EMIT(K, 4);
32638 +#endif
32639 EMIT4(0x48, 0xc1, 0xe8, 0x20); /* shr $0x20,%rax */
32640 break;
32641 case BPF_S_ALU_AND_X:
32642 @@ -637,8 +744,7 @@ common_load_ind: seen |= SEEN_DATAREF | SEEN_XREG;
32643 if (is_imm8(K)) {
32644 EMIT3(0x8d, 0x73, K); /* lea imm8(%rbx), %esi */
32645 } else {
32646 - EMIT2(0x8d, 0xb3); /* lea imm32(%rbx),%esi */
32647 - EMIT(K, 4);
32648 + EMIT2_off32(0x8d, 0xb3, K); /* lea imm32(%rbx),%esi */
32649 }
32650 } else {
32651 EMIT2(0x89,0xde); /* mov %ebx,%esi */
32652 @@ -728,10 +834,12 @@ cond_branch: f_offset = addrs[i + filter[i].jf] - addrs[i];
32653 if (unlikely(proglen + ilen > oldproglen)) {
32654 pr_err("bpb_jit_compile fatal error\n");
32655 kfree(addrs);
32656 - module_free(NULL, header);
32657 + module_free_exec(NULL, image);
32658 return;
32659 }
32660 + pax_open_kernel();
32661 memcpy(image + proglen, temp, ilen);
32662 + pax_close_kernel();
32663 }
32664 proglen += ilen;
32665 addrs[i] = proglen;
32666 @@ -764,7 +872,6 @@ cond_branch: f_offset = addrs[i + filter[i].jf] - addrs[i];
32667
32668 if (image) {
32669 bpf_flush_icache(header, image + proglen);
32670 - set_memory_ro((unsigned long)header, header->pages);
32671 fp->bpf_func = (void *)image;
32672 }
32673 out:
32674 @@ -776,10 +883,9 @@ static void bpf_jit_free_deferred(struct work_struct *work)
32675 {
32676 struct sk_filter *fp = container_of(work, struct sk_filter, work);
32677 unsigned long addr = (unsigned long)fp->bpf_func & PAGE_MASK;
32678 - struct bpf_binary_header *header = (void *)addr;
32679
32680 - set_memory_rw(addr, header->pages);
32681 - module_free(NULL, header);
32682 + set_memory_rw(addr, 1);
32683 + module_free_exec(NULL, (void *)addr);
32684 kfree(fp);
32685 }
32686
32687 diff --git a/arch/x86/oprofile/backtrace.c b/arch/x86/oprofile/backtrace.c
32688 index d6aa6e8..266395a 100644
32689 --- a/arch/x86/oprofile/backtrace.c
32690 +++ b/arch/x86/oprofile/backtrace.c
32691 @@ -46,11 +46,11 @@ dump_user_backtrace_32(struct stack_frame_ia32 *head)
32692 struct stack_frame_ia32 *fp;
32693 unsigned long bytes;
32694
32695 - bytes = copy_from_user_nmi(bufhead, head, sizeof(bufhead));
32696 + bytes = copy_from_user_nmi(bufhead, (const char __force_user *)head, sizeof(bufhead));
32697 if (bytes != sizeof(bufhead))
32698 return NULL;
32699
32700 - fp = (struct stack_frame_ia32 *) compat_ptr(bufhead[0].next_frame);
32701 + fp = (struct stack_frame_ia32 __force_kernel *) compat_ptr(bufhead[0].next_frame);
32702
32703 oprofile_add_trace(bufhead[0].return_address);
32704
32705 @@ -92,7 +92,7 @@ static struct stack_frame *dump_user_backtrace(struct stack_frame *head)
32706 struct stack_frame bufhead[2];
32707 unsigned long bytes;
32708
32709 - bytes = copy_from_user_nmi(bufhead, head, sizeof(bufhead));
32710 + bytes = copy_from_user_nmi(bufhead, (const char __force_user *)head, sizeof(bufhead));
32711 if (bytes != sizeof(bufhead))
32712 return NULL;
32713
32714 @@ -111,7 +111,7 @@ x86_backtrace(struct pt_regs * const regs, unsigned int depth)
32715 {
32716 struct stack_frame *head = (struct stack_frame *)frame_pointer(regs);
32717
32718 - if (!user_mode_vm(regs)) {
32719 + if (!user_mode(regs)) {
32720 unsigned long stack = kernel_stack_pointer(regs);
32721 if (depth)
32722 dump_trace(NULL, regs, (unsigned long *)stack, 0,
32723 diff --git a/arch/x86/oprofile/nmi_int.c b/arch/x86/oprofile/nmi_int.c
32724 index 6890d84..1dad1f1 100644
32725 --- a/arch/x86/oprofile/nmi_int.c
32726 +++ b/arch/x86/oprofile/nmi_int.c
32727 @@ -23,6 +23,7 @@
32728 #include <asm/nmi.h>
32729 #include <asm/msr.h>
32730 #include <asm/apic.h>
32731 +#include <asm/pgtable.h>
32732
32733 #include "op_counter.h"
32734 #include "op_x86_model.h"
32735 @@ -774,8 +775,11 @@ int __init op_nmi_init(struct oprofile_operations *ops)
32736 if (ret)
32737 return ret;
32738
32739 - if (!model->num_virt_counters)
32740 - model->num_virt_counters = model->num_counters;
32741 + if (!model->num_virt_counters) {
32742 + pax_open_kernel();
32743 + *(unsigned int *)&model->num_virt_counters = model->num_counters;
32744 + pax_close_kernel();
32745 + }
32746
32747 mux_init(ops);
32748
32749 diff --git a/arch/x86/oprofile/op_model_amd.c b/arch/x86/oprofile/op_model_amd.c
32750 index 50d86c0..7985318 100644
32751 --- a/arch/x86/oprofile/op_model_amd.c
32752 +++ b/arch/x86/oprofile/op_model_amd.c
32753 @@ -519,9 +519,11 @@ static int op_amd_init(struct oprofile_operations *ops)
32754 num_counters = AMD64_NUM_COUNTERS;
32755 }
32756
32757 - op_amd_spec.num_counters = num_counters;
32758 - op_amd_spec.num_controls = num_counters;
32759 - op_amd_spec.num_virt_counters = max(num_counters, NUM_VIRT_COUNTERS);
32760 + pax_open_kernel();
32761 + *(unsigned int *)&op_amd_spec.num_counters = num_counters;
32762 + *(unsigned int *)&op_amd_spec.num_controls = num_counters;
32763 + *(unsigned int *)&op_amd_spec.num_virt_counters = max(num_counters, NUM_VIRT_COUNTERS);
32764 + pax_close_kernel();
32765
32766 return 0;
32767 }
32768 diff --git a/arch/x86/oprofile/op_model_ppro.c b/arch/x86/oprofile/op_model_ppro.c
32769 index d90528e..0127e2b 100644
32770 --- a/arch/x86/oprofile/op_model_ppro.c
32771 +++ b/arch/x86/oprofile/op_model_ppro.c
32772 @@ -19,6 +19,7 @@
32773 #include <asm/msr.h>
32774 #include <asm/apic.h>
32775 #include <asm/nmi.h>
32776 +#include <asm/pgtable.h>
32777
32778 #include "op_x86_model.h"
32779 #include "op_counter.h"
32780 @@ -221,8 +222,10 @@ static void arch_perfmon_setup_counters(void)
32781
32782 num_counters = min((int)eax.split.num_counters, OP_MAX_COUNTER);
32783
32784 - op_arch_perfmon_spec.num_counters = num_counters;
32785 - op_arch_perfmon_spec.num_controls = num_counters;
32786 + pax_open_kernel();
32787 + *(unsigned int *)&op_arch_perfmon_spec.num_counters = num_counters;
32788 + *(unsigned int *)&op_arch_perfmon_spec.num_controls = num_counters;
32789 + pax_close_kernel();
32790 }
32791
32792 static int arch_perfmon_init(struct oprofile_operations *ignore)
32793 diff --git a/arch/x86/oprofile/op_x86_model.h b/arch/x86/oprofile/op_x86_model.h
32794 index 71e8a67..6a313bb 100644
32795 --- a/arch/x86/oprofile/op_x86_model.h
32796 +++ b/arch/x86/oprofile/op_x86_model.h
32797 @@ -52,7 +52,7 @@ struct op_x86_model_spec {
32798 void (*switch_ctrl)(struct op_x86_model_spec const *model,
32799 struct op_msrs const * const msrs);
32800 #endif
32801 -};
32802 +} __do_const;
32803
32804 struct op_counter_config;
32805
32806 diff --git a/arch/x86/pci/irq.c b/arch/x86/pci/irq.c
32807 index 372e9b8..e775a6c 100644
32808 --- a/arch/x86/pci/irq.c
32809 +++ b/arch/x86/pci/irq.c
32810 @@ -50,7 +50,7 @@ struct irq_router {
32811 struct irq_router_handler {
32812 u16 vendor;
32813 int (*probe)(struct irq_router *r, struct pci_dev *router, u16 device);
32814 -};
32815 +} __do_const;
32816
32817 int (*pcibios_enable_irq)(struct pci_dev *dev) = pirq_enable_irq;
32818 void (*pcibios_disable_irq)(struct pci_dev *dev) = NULL;
32819 @@ -794,7 +794,7 @@ static __init int pico_router_probe(struct irq_router *r, struct pci_dev *router
32820 return 0;
32821 }
32822
32823 -static __initdata struct irq_router_handler pirq_routers[] = {
32824 +static __initconst const struct irq_router_handler pirq_routers[] = {
32825 { PCI_VENDOR_ID_INTEL, intel_router_probe },
32826 { PCI_VENDOR_ID_AL, ali_router_probe },
32827 { PCI_VENDOR_ID_ITE, ite_router_probe },
32828 @@ -821,7 +821,7 @@ static struct pci_dev *pirq_router_dev;
32829 static void __init pirq_find_router(struct irq_router *r)
32830 {
32831 struct irq_routing_table *rt = pirq_table;
32832 - struct irq_router_handler *h;
32833 + const struct irq_router_handler *h;
32834
32835 #ifdef CONFIG_PCI_BIOS
32836 if (!rt->signature) {
32837 @@ -1094,7 +1094,7 @@ static int __init fix_acer_tm360_irqrouting(const struct dmi_system_id *d)
32838 return 0;
32839 }
32840
32841 -static struct dmi_system_id __initdata pciirq_dmi_table[] = {
32842 +static const struct dmi_system_id __initconst pciirq_dmi_table[] = {
32843 {
32844 .callback = fix_broken_hp_bios_irq9,
32845 .ident = "HP Pavilion N5400 Series Laptop",
32846 diff --git a/arch/x86/pci/mrst.c b/arch/x86/pci/mrst.c
32847 index 903fded..94b0d88 100644
32848 --- a/arch/x86/pci/mrst.c
32849 +++ b/arch/x86/pci/mrst.c
32850 @@ -241,7 +241,9 @@ int __init pci_mrst_init(void)
32851 pr_info("Intel MID platform detected, using MID PCI ops\n");
32852 pci_mmcfg_late_init();
32853 pcibios_enable_irq = mrst_pci_irq_enable;
32854 - pci_root_ops = pci_mrst_ops;
32855 + pax_open_kernel();
32856 + memcpy((void *)&pci_root_ops, &pci_mrst_ops, sizeof(pci_mrst_ops));
32857 + pax_close_kernel();
32858 pci_soc_mode = 1;
32859 /* Continue with standard init */
32860 return 1;
32861 diff --git a/arch/x86/pci/pcbios.c b/arch/x86/pci/pcbios.c
32862 index c77b24a..c979855 100644
32863 --- a/arch/x86/pci/pcbios.c
32864 +++ b/arch/x86/pci/pcbios.c
32865 @@ -79,7 +79,7 @@ union bios32 {
32866 static struct {
32867 unsigned long address;
32868 unsigned short segment;
32869 -} bios32_indirect = { 0, __KERNEL_CS };
32870 +} bios32_indirect __read_only = { 0, __PCIBIOS_CS };
32871
32872 /*
32873 * Returns the entry point for the given service, NULL on error
32874 @@ -92,37 +92,80 @@ static unsigned long bios32_service(unsigned long service)
32875 unsigned long length; /* %ecx */
32876 unsigned long entry; /* %edx */
32877 unsigned long flags;
32878 + struct desc_struct d, *gdt;
32879
32880 local_irq_save(flags);
32881 - __asm__("lcall *(%%edi); cld"
32882 +
32883 + gdt = get_cpu_gdt_table(smp_processor_id());
32884 +
32885 + pack_descriptor(&d, 0UL, 0xFFFFFUL, 0x9B, 0xC);
32886 + write_gdt_entry(gdt, GDT_ENTRY_PCIBIOS_CS, &d, DESCTYPE_S);
32887 + pack_descriptor(&d, 0UL, 0xFFFFFUL, 0x93, 0xC);
32888 + write_gdt_entry(gdt, GDT_ENTRY_PCIBIOS_DS, &d, DESCTYPE_S);
32889 +
32890 + __asm__("movw %w7, %%ds; lcall *(%%edi); push %%ss; pop %%ds; cld"
32891 : "=a" (return_code),
32892 "=b" (address),
32893 "=c" (length),
32894 "=d" (entry)
32895 : "0" (service),
32896 "1" (0),
32897 - "D" (&bios32_indirect));
32898 + "D" (&bios32_indirect),
32899 + "r"(__PCIBIOS_DS)
32900 + : "memory");
32901 +
32902 + pax_open_kernel();
32903 + gdt[GDT_ENTRY_PCIBIOS_CS].a = 0;
32904 + gdt[GDT_ENTRY_PCIBIOS_CS].b = 0;
32905 + gdt[GDT_ENTRY_PCIBIOS_DS].a = 0;
32906 + gdt[GDT_ENTRY_PCIBIOS_DS].b = 0;
32907 + pax_close_kernel();
32908 +
32909 local_irq_restore(flags);
32910
32911 switch (return_code) {
32912 - case 0:
32913 - return address + entry;
32914 - case 0x80: /* Not present */
32915 - printk(KERN_WARNING "bios32_service(0x%lx): not present\n", service);
32916 - return 0;
32917 - default: /* Shouldn't happen */
32918 - printk(KERN_WARNING "bios32_service(0x%lx): returned 0x%x -- BIOS bug!\n",
32919 - service, return_code);
32920 + case 0: {
32921 + int cpu;
32922 + unsigned char flags;
32923 +
32924 + printk(KERN_INFO "bios32_service: base:%08lx length:%08lx entry:%08lx\n", address, length, entry);
32925 + if (address >= 0xFFFF0 || length > 0x100000 - address || length <= entry) {
32926 + printk(KERN_WARNING "bios32_service: not valid\n");
32927 return 0;
32928 + }
32929 + address = address + PAGE_OFFSET;
32930 + length += 16UL; /* some BIOSs underreport this... */
32931 + flags = 4;
32932 + if (length >= 64*1024*1024) {
32933 + length >>= PAGE_SHIFT;
32934 + flags |= 8;
32935 + }
32936 +
32937 + for (cpu = 0; cpu < nr_cpu_ids; cpu++) {
32938 + gdt = get_cpu_gdt_table(cpu);
32939 + pack_descriptor(&d, address, length, 0x9b, flags);
32940 + write_gdt_entry(gdt, GDT_ENTRY_PCIBIOS_CS, &d, DESCTYPE_S);
32941 + pack_descriptor(&d, address, length, 0x93, flags);
32942 + write_gdt_entry(gdt, GDT_ENTRY_PCIBIOS_DS, &d, DESCTYPE_S);
32943 + }
32944 + return entry;
32945 + }
32946 + case 0x80: /* Not present */
32947 + printk(KERN_WARNING "bios32_service(0x%lx): not present\n", service);
32948 + return 0;
32949 + default: /* Shouldn't happen */
32950 + printk(KERN_WARNING "bios32_service(0x%lx): returned 0x%x -- BIOS bug!\n",
32951 + service, return_code);
32952 + return 0;
32953 }
32954 }
32955
32956 static struct {
32957 unsigned long address;
32958 unsigned short segment;
32959 -} pci_indirect = { 0, __KERNEL_CS };
32960 +} pci_indirect __read_only = { 0, __PCIBIOS_CS };
32961
32962 -static int pci_bios_present;
32963 +static int pci_bios_present __read_only;
32964
32965 static int check_pcibios(void)
32966 {
32967 @@ -131,11 +174,13 @@ static int check_pcibios(void)
32968 unsigned long flags, pcibios_entry;
32969
32970 if ((pcibios_entry = bios32_service(PCI_SERVICE))) {
32971 - pci_indirect.address = pcibios_entry + PAGE_OFFSET;
32972 + pci_indirect.address = pcibios_entry;
32973
32974 local_irq_save(flags);
32975 - __asm__(
32976 - "lcall *(%%edi); cld\n\t"
32977 + __asm__("movw %w6, %%ds\n\t"
32978 + "lcall *%%ss:(%%edi); cld\n\t"
32979 + "push %%ss\n\t"
32980 + "pop %%ds\n\t"
32981 "jc 1f\n\t"
32982 "xor %%ah, %%ah\n"
32983 "1:"
32984 @@ -144,7 +189,8 @@ static int check_pcibios(void)
32985 "=b" (ebx),
32986 "=c" (ecx)
32987 : "1" (PCIBIOS_PCI_BIOS_PRESENT),
32988 - "D" (&pci_indirect)
32989 + "D" (&pci_indirect),
32990 + "r" (__PCIBIOS_DS)
32991 : "memory");
32992 local_irq_restore(flags);
32993
32994 @@ -189,7 +235,10 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
32995
32996 switch (len) {
32997 case 1:
32998 - __asm__("lcall *(%%esi); cld\n\t"
32999 + __asm__("movw %w6, %%ds\n\t"
33000 + "lcall *%%ss:(%%esi); cld\n\t"
33001 + "push %%ss\n\t"
33002 + "pop %%ds\n\t"
33003 "jc 1f\n\t"
33004 "xor %%ah, %%ah\n"
33005 "1:"
33006 @@ -198,7 +247,8 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
33007 : "1" (PCIBIOS_READ_CONFIG_BYTE),
33008 "b" (bx),
33009 "D" ((long)reg),
33010 - "S" (&pci_indirect));
33011 + "S" (&pci_indirect),
33012 + "r" (__PCIBIOS_DS));
33013 /*
33014 * Zero-extend the result beyond 8 bits, do not trust the
33015 * BIOS having done it:
33016 @@ -206,7 +256,10 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
33017 *value &= 0xff;
33018 break;
33019 case 2:
33020 - __asm__("lcall *(%%esi); cld\n\t"
33021 + __asm__("movw %w6, %%ds\n\t"
33022 + "lcall *%%ss:(%%esi); cld\n\t"
33023 + "push %%ss\n\t"
33024 + "pop %%ds\n\t"
33025 "jc 1f\n\t"
33026 "xor %%ah, %%ah\n"
33027 "1:"
33028 @@ -215,7 +268,8 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
33029 : "1" (PCIBIOS_READ_CONFIG_WORD),
33030 "b" (bx),
33031 "D" ((long)reg),
33032 - "S" (&pci_indirect));
33033 + "S" (&pci_indirect),
33034 + "r" (__PCIBIOS_DS));
33035 /*
33036 * Zero-extend the result beyond 16 bits, do not trust the
33037 * BIOS having done it:
33038 @@ -223,7 +277,10 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
33039 *value &= 0xffff;
33040 break;
33041 case 4:
33042 - __asm__("lcall *(%%esi); cld\n\t"
33043 + __asm__("movw %w6, %%ds\n\t"
33044 + "lcall *%%ss:(%%esi); cld\n\t"
33045 + "push %%ss\n\t"
33046 + "pop %%ds\n\t"
33047 "jc 1f\n\t"
33048 "xor %%ah, %%ah\n"
33049 "1:"
33050 @@ -232,7 +289,8 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
33051 : "1" (PCIBIOS_READ_CONFIG_DWORD),
33052 "b" (bx),
33053 "D" ((long)reg),
33054 - "S" (&pci_indirect));
33055 + "S" (&pci_indirect),
33056 + "r" (__PCIBIOS_DS));
33057 break;
33058 }
33059
33060 @@ -256,7 +314,10 @@ static int pci_bios_write(unsigned int seg, unsigned int bus,
33061
33062 switch (len) {
33063 case 1:
33064 - __asm__("lcall *(%%esi); cld\n\t"
33065 + __asm__("movw %w6, %%ds\n\t"
33066 + "lcall *%%ss:(%%esi); cld\n\t"
33067 + "push %%ss\n\t"
33068 + "pop %%ds\n\t"
33069 "jc 1f\n\t"
33070 "xor %%ah, %%ah\n"
33071 "1:"
33072 @@ -265,10 +326,14 @@ static int pci_bios_write(unsigned int seg, unsigned int bus,
33073 "c" (value),
33074 "b" (bx),
33075 "D" ((long)reg),
33076 - "S" (&pci_indirect));
33077 + "S" (&pci_indirect),
33078 + "r" (__PCIBIOS_DS));
33079 break;
33080 case 2:
33081 - __asm__("lcall *(%%esi); cld\n\t"
33082 + __asm__("movw %w6, %%ds\n\t"
33083 + "lcall *%%ss:(%%esi); cld\n\t"
33084 + "push %%ss\n\t"
33085 + "pop %%ds\n\t"
33086 "jc 1f\n\t"
33087 "xor %%ah, %%ah\n"
33088 "1:"
33089 @@ -277,10 +342,14 @@ static int pci_bios_write(unsigned int seg, unsigned int bus,
33090 "c" (value),
33091 "b" (bx),
33092 "D" ((long)reg),
33093 - "S" (&pci_indirect));
33094 + "S" (&pci_indirect),
33095 + "r" (__PCIBIOS_DS));
33096 break;
33097 case 4:
33098 - __asm__("lcall *(%%esi); cld\n\t"
33099 + __asm__("movw %w6, %%ds\n\t"
33100 + "lcall *%%ss:(%%esi); cld\n\t"
33101 + "push %%ss\n\t"
33102 + "pop %%ds\n\t"
33103 "jc 1f\n\t"
33104 "xor %%ah, %%ah\n"
33105 "1:"
33106 @@ -289,7 +358,8 @@ static int pci_bios_write(unsigned int seg, unsigned int bus,
33107 "c" (value),
33108 "b" (bx),
33109 "D" ((long)reg),
33110 - "S" (&pci_indirect));
33111 + "S" (&pci_indirect),
33112 + "r" (__PCIBIOS_DS));
33113 break;
33114 }
33115
33116 @@ -394,10 +464,13 @@ struct irq_routing_table * pcibios_get_irq_routing_table(void)
33117
33118 DBG("PCI: Fetching IRQ routing table... ");
33119 __asm__("push %%es\n\t"
33120 + "movw %w8, %%ds\n\t"
33121 "push %%ds\n\t"
33122 "pop %%es\n\t"
33123 - "lcall *(%%esi); cld\n\t"
33124 + "lcall *%%ss:(%%esi); cld\n\t"
33125 "pop %%es\n\t"
33126 + "push %%ss\n\t"
33127 + "pop %%ds\n"
33128 "jc 1f\n\t"
33129 "xor %%ah, %%ah\n"
33130 "1:"
33131 @@ -408,7 +481,8 @@ struct irq_routing_table * pcibios_get_irq_routing_table(void)
33132 "1" (0),
33133 "D" ((long) &opt),
33134 "S" (&pci_indirect),
33135 - "m" (opt)
33136 + "m" (opt),
33137 + "r" (__PCIBIOS_DS)
33138 : "memory");
33139 DBG("OK ret=%d, size=%d, map=%x\n", ret, opt.size, map);
33140 if (ret & 0xff00)
33141 @@ -432,7 +506,10 @@ int pcibios_set_irq_routing(struct pci_dev *dev, int pin, int irq)
33142 {
33143 int ret;
33144
33145 - __asm__("lcall *(%%esi); cld\n\t"
33146 + __asm__("movw %w5, %%ds\n\t"
33147 + "lcall *%%ss:(%%esi); cld\n\t"
33148 + "push %%ss\n\t"
33149 + "pop %%ds\n"
33150 "jc 1f\n\t"
33151 "xor %%ah, %%ah\n"
33152 "1:"
33153 @@ -440,7 +517,8 @@ int pcibios_set_irq_routing(struct pci_dev *dev, int pin, int irq)
33154 : "0" (PCIBIOS_SET_PCI_HW_INT),
33155 "b" ((dev->bus->number << 8) | dev->devfn),
33156 "c" ((irq << 8) | (pin + 10)),
33157 - "S" (&pci_indirect));
33158 + "S" (&pci_indirect),
33159 + "r" (__PCIBIOS_DS));
33160 return !(ret & 0xff00);
33161 }
33162 EXPORT_SYMBOL(pcibios_set_irq_routing);
33163 diff --git a/arch/x86/platform/efi/efi_32.c b/arch/x86/platform/efi/efi_32.c
33164 index 40e4469..d915bf9 100644
33165 --- a/arch/x86/platform/efi/efi_32.c
33166 +++ b/arch/x86/platform/efi/efi_32.c
33167 @@ -44,11 +44,22 @@ void efi_call_phys_prelog(void)
33168 {
33169 struct desc_ptr gdt_descr;
33170
33171 +#ifdef CONFIG_PAX_KERNEXEC
33172 + struct desc_struct d;
33173 +#endif
33174 +
33175 local_irq_save(efi_rt_eflags);
33176
33177 load_cr3(initial_page_table);
33178 __flush_tlb_all();
33179
33180 +#ifdef CONFIG_PAX_KERNEXEC
33181 + pack_descriptor(&d, 0, 0xFFFFF, 0x9B, 0xC);
33182 + write_gdt_entry(get_cpu_gdt_table(0), GDT_ENTRY_KERNEXEC_EFI_CS, &d, DESCTYPE_S);
33183 + pack_descriptor(&d, 0, 0xFFFFF, 0x93, 0xC);
33184 + write_gdt_entry(get_cpu_gdt_table(0), GDT_ENTRY_KERNEXEC_EFI_DS, &d, DESCTYPE_S);
33185 +#endif
33186 +
33187 gdt_descr.address = __pa(get_cpu_gdt_table(0));
33188 gdt_descr.size = GDT_SIZE - 1;
33189 load_gdt(&gdt_descr);
33190 @@ -58,11 +69,24 @@ void efi_call_phys_epilog(void)
33191 {
33192 struct desc_ptr gdt_descr;
33193
33194 +#ifdef CONFIG_PAX_KERNEXEC
33195 + struct desc_struct d;
33196 +
33197 + memset(&d, 0, sizeof d);
33198 + write_gdt_entry(get_cpu_gdt_table(0), GDT_ENTRY_KERNEXEC_EFI_CS, &d, DESCTYPE_S);
33199 + write_gdt_entry(get_cpu_gdt_table(0), GDT_ENTRY_KERNEXEC_EFI_DS, &d, DESCTYPE_S);
33200 +#endif
33201 +
33202 gdt_descr.address = (unsigned long)get_cpu_gdt_table(0);
33203 gdt_descr.size = GDT_SIZE - 1;
33204 load_gdt(&gdt_descr);
33205
33206 +#ifdef CONFIG_PAX_PER_CPU_PGD
33207 + load_cr3(get_cpu_pgd(smp_processor_id(), kernel));
33208 +#else
33209 load_cr3(swapper_pg_dir);
33210 +#endif
33211 +
33212 __flush_tlb_all();
33213
33214 local_irq_restore(efi_rt_eflags);
33215 diff --git a/arch/x86/platform/efi/efi_64.c b/arch/x86/platform/efi/efi_64.c
33216 index 39a0e7f1..872396e 100644
33217 --- a/arch/x86/platform/efi/efi_64.c
33218 +++ b/arch/x86/platform/efi/efi_64.c
33219 @@ -76,6 +76,11 @@ void __init efi_call_phys_prelog(void)
33220 vaddress = (unsigned long)__va(pgd * PGDIR_SIZE);
33221 set_pgd(pgd_offset_k(pgd * PGDIR_SIZE), *pgd_offset_k(vaddress));
33222 }
33223 +
33224 +#ifdef CONFIG_PAX_PER_CPU_PGD
33225 + load_cr3(swapper_pg_dir);
33226 +#endif
33227 +
33228 __flush_tlb_all();
33229 }
33230
33231 @@ -89,6 +94,11 @@ void __init efi_call_phys_epilog(void)
33232 for (pgd = 0; pgd < n_pgds; pgd++)
33233 set_pgd(pgd_offset_k(pgd * PGDIR_SIZE), save_pgd[pgd]);
33234 kfree(save_pgd);
33235 +
33236 +#ifdef CONFIG_PAX_PER_CPU_PGD
33237 + load_cr3(get_cpu_pgd(smp_processor_id(), kernel));
33238 +#endif
33239 +
33240 __flush_tlb_all();
33241 local_irq_restore(efi_flags);
33242 early_code_mapping_set_exec(0);
33243 diff --git a/arch/x86/platform/efi/efi_stub_32.S b/arch/x86/platform/efi/efi_stub_32.S
33244 index fbe66e6..eae5e38 100644
33245 --- a/arch/x86/platform/efi/efi_stub_32.S
33246 +++ b/arch/x86/platform/efi/efi_stub_32.S
33247 @@ -6,7 +6,9 @@
33248 */
33249
33250 #include <linux/linkage.h>
33251 +#include <linux/init.h>
33252 #include <asm/page_types.h>
33253 +#include <asm/segment.h>
33254
33255 /*
33256 * efi_call_phys(void *, ...) is a function with variable parameters.
33257 @@ -20,7 +22,7 @@
33258 * service functions will comply with gcc calling convention, too.
33259 */
33260
33261 -.text
33262 +__INIT
33263 ENTRY(efi_call_phys)
33264 /*
33265 * 0. The function can only be called in Linux kernel. So CS has been
33266 @@ -36,10 +38,24 @@ ENTRY(efi_call_phys)
33267 * The mapping of lower virtual memory has been created in prelog and
33268 * epilog.
33269 */
33270 - movl $1f, %edx
33271 - subl $__PAGE_OFFSET, %edx
33272 - jmp *%edx
33273 +#ifdef CONFIG_PAX_KERNEXEC
33274 + movl $(__KERNEXEC_EFI_DS), %edx
33275 + mov %edx, %ds
33276 + mov %edx, %es
33277 + mov %edx, %ss
33278 + addl $2f,(1f)
33279 + ljmp *(1f)
33280 +
33281 +__INITDATA
33282 +1: .long __LOAD_PHYSICAL_ADDR, __KERNEXEC_EFI_CS
33283 +.previous
33284 +
33285 +2:
33286 + subl $2b,(1b)
33287 +#else
33288 + jmp 1f-__PAGE_OFFSET
33289 1:
33290 +#endif
33291
33292 /*
33293 * 2. Now on the top of stack is the return
33294 @@ -47,14 +63,8 @@ ENTRY(efi_call_phys)
33295 * parameter 2, ..., param n. To make things easy, we save the return
33296 * address of efi_call_phys in a global variable.
33297 */
33298 - popl %edx
33299 - movl %edx, saved_return_addr
33300 - /* get the function pointer into ECX*/
33301 - popl %ecx
33302 - movl %ecx, efi_rt_function_ptr
33303 - movl $2f, %edx
33304 - subl $__PAGE_OFFSET, %edx
33305 - pushl %edx
33306 + popl (saved_return_addr)
33307 + popl (efi_rt_function_ptr)
33308
33309 /*
33310 * 3. Clear PG bit in %CR0.
33311 @@ -73,9 +83,8 @@ ENTRY(efi_call_phys)
33312 /*
33313 * 5. Call the physical function.
33314 */
33315 - jmp *%ecx
33316 + call *(efi_rt_function_ptr-__PAGE_OFFSET)
33317
33318 -2:
33319 /*
33320 * 6. After EFI runtime service returns, control will return to
33321 * following instruction. We'd better readjust stack pointer first.
33322 @@ -88,35 +97,36 @@ ENTRY(efi_call_phys)
33323 movl %cr0, %edx
33324 orl $0x80000000, %edx
33325 movl %edx, %cr0
33326 - jmp 1f
33327 -1:
33328 +
33329 /*
33330 * 8. Now restore the virtual mode from flat mode by
33331 * adding EIP with PAGE_OFFSET.
33332 */
33333 - movl $1f, %edx
33334 - jmp *%edx
33335 +#ifdef CONFIG_PAX_KERNEXEC
33336 + movl $(__KERNEL_DS), %edx
33337 + mov %edx, %ds
33338 + mov %edx, %es
33339 + mov %edx, %ss
33340 + ljmp $(__KERNEL_CS),$1f
33341 +#else
33342 + jmp 1f+__PAGE_OFFSET
33343 +#endif
33344 1:
33345
33346 /*
33347 * 9. Balance the stack. And because EAX contain the return value,
33348 * we'd better not clobber it.
33349 */
33350 - leal efi_rt_function_ptr, %edx
33351 - movl (%edx), %ecx
33352 - pushl %ecx
33353 + pushl (efi_rt_function_ptr)
33354
33355 /*
33356 - * 10. Push the saved return address onto the stack and return.
33357 + * 10. Return to the saved return address.
33358 */
33359 - leal saved_return_addr, %edx
33360 - movl (%edx), %ecx
33361 - pushl %ecx
33362 - ret
33363 + jmpl *(saved_return_addr)
33364 ENDPROC(efi_call_phys)
33365 .previous
33366
33367 -.data
33368 +__INITDATA
33369 saved_return_addr:
33370 .long 0
33371 efi_rt_function_ptr:
33372 diff --git a/arch/x86/platform/efi/efi_stub_64.S b/arch/x86/platform/efi/efi_stub_64.S
33373 index 4c07cca..2c8427d 100644
33374 --- a/arch/x86/platform/efi/efi_stub_64.S
33375 +++ b/arch/x86/platform/efi/efi_stub_64.S
33376 @@ -7,6 +7,7 @@
33377 */
33378
33379 #include <linux/linkage.h>
33380 +#include <asm/alternative-asm.h>
33381
33382 #define SAVE_XMM \
33383 mov %rsp, %rax; \
33384 @@ -40,6 +41,7 @@ ENTRY(efi_call0)
33385 call *%rdi
33386 addq $32, %rsp
33387 RESTORE_XMM
33388 + pax_force_retaddr 0, 1
33389 ret
33390 ENDPROC(efi_call0)
33391
33392 @@ -50,6 +52,7 @@ ENTRY(efi_call1)
33393 call *%rdi
33394 addq $32, %rsp
33395 RESTORE_XMM
33396 + pax_force_retaddr 0, 1
33397 ret
33398 ENDPROC(efi_call1)
33399
33400 @@ -60,6 +63,7 @@ ENTRY(efi_call2)
33401 call *%rdi
33402 addq $32, %rsp
33403 RESTORE_XMM
33404 + pax_force_retaddr 0, 1
33405 ret
33406 ENDPROC(efi_call2)
33407
33408 @@ -71,6 +75,7 @@ ENTRY(efi_call3)
33409 call *%rdi
33410 addq $32, %rsp
33411 RESTORE_XMM
33412 + pax_force_retaddr 0, 1
33413 ret
33414 ENDPROC(efi_call3)
33415
33416 @@ -83,6 +88,7 @@ ENTRY(efi_call4)
33417 call *%rdi
33418 addq $32, %rsp
33419 RESTORE_XMM
33420 + pax_force_retaddr 0, 1
33421 ret
33422 ENDPROC(efi_call4)
33423
33424 @@ -96,6 +102,7 @@ ENTRY(efi_call5)
33425 call *%rdi
33426 addq $48, %rsp
33427 RESTORE_XMM
33428 + pax_force_retaddr 0, 1
33429 ret
33430 ENDPROC(efi_call5)
33431
33432 @@ -112,5 +119,6 @@ ENTRY(efi_call6)
33433 call *%rdi
33434 addq $48, %rsp
33435 RESTORE_XMM
33436 + pax_force_retaddr 0, 1
33437 ret
33438 ENDPROC(efi_call6)
33439 diff --git a/arch/x86/platform/mrst/mrst.c b/arch/x86/platform/mrst/mrst.c
33440 index 3ca5957..7909c18 100644
33441 --- a/arch/x86/platform/mrst/mrst.c
33442 +++ b/arch/x86/platform/mrst/mrst.c
33443 @@ -78,13 +78,15 @@ struct sfi_rtc_table_entry sfi_mrtc_array[SFI_MRTC_MAX];
33444 EXPORT_SYMBOL_GPL(sfi_mrtc_array);
33445 int sfi_mrtc_num;
33446
33447 -static void mrst_power_off(void)
33448 +static __noreturn void mrst_power_off(void)
33449 {
33450 + BUG();
33451 }
33452
33453 -static void mrst_reboot(void)
33454 +static __noreturn void mrst_reboot(void)
33455 {
33456 intel_scu_ipc_simple_command(IPCMSG_COLD_BOOT, 0);
33457 + BUG();
33458 }
33459
33460 /* parse all the mtimer info to a static mtimer array */
33461 diff --git a/arch/x86/platform/olpc/olpc_dt.c b/arch/x86/platform/olpc/olpc_dt.c
33462 index d6ee929..3637cb5 100644
33463 --- a/arch/x86/platform/olpc/olpc_dt.c
33464 +++ b/arch/x86/platform/olpc/olpc_dt.c
33465 @@ -156,7 +156,7 @@ void * __init prom_early_alloc(unsigned long size)
33466 return res;
33467 }
33468
33469 -static struct of_pdt_ops prom_olpc_ops __initdata = {
33470 +static struct of_pdt_ops prom_olpc_ops __initconst = {
33471 .nextprop = olpc_dt_nextprop,
33472 .getproplen = olpc_dt_getproplen,
33473 .getproperty = olpc_dt_getproperty,
33474 diff --git a/arch/x86/power/cpu.c b/arch/x86/power/cpu.c
33475 index 424f4c9..f2a2988 100644
33476 --- a/arch/x86/power/cpu.c
33477 +++ b/arch/x86/power/cpu.c
33478 @@ -137,11 +137,8 @@ static void do_fpu_end(void)
33479 static void fix_processor_context(void)
33480 {
33481 int cpu = smp_processor_id();
33482 - struct tss_struct *t = &per_cpu(init_tss, cpu);
33483 -#ifdef CONFIG_X86_64
33484 - struct desc_struct *desc = get_cpu_gdt_table(cpu);
33485 - tss_desc tss;
33486 -#endif
33487 + struct tss_struct *t = init_tss + cpu;
33488 +
33489 set_tss_desc(cpu, t); /*
33490 * This just modifies memory; should not be
33491 * necessary. But... This is necessary, because
33492 @@ -150,10 +147,6 @@ static void fix_processor_context(void)
33493 */
33494
33495 #ifdef CONFIG_X86_64
33496 - memcpy(&tss, &desc[GDT_ENTRY_TSS], sizeof(tss_desc));
33497 - tss.type = 0x9; /* The available 64-bit TSS (see AMD vol 2, pg 91 */
33498 - write_gdt_entry(desc, GDT_ENTRY_TSS, &tss, DESC_TSS);
33499 -
33500 syscall_init(); /* This sets MSR_*STAR and related */
33501 #endif
33502 load_TR_desc(); /* This does ltr */
33503 diff --git a/arch/x86/realmode/init.c b/arch/x86/realmode/init.c
33504 index a44f457..9140171 100644
33505 --- a/arch/x86/realmode/init.c
33506 +++ b/arch/x86/realmode/init.c
33507 @@ -70,7 +70,13 @@ void __init setup_real_mode(void)
33508 __va(real_mode_header->trampoline_header);
33509
33510 #ifdef CONFIG_X86_32
33511 - trampoline_header->start = __pa_symbol(startup_32_smp);
33512 + trampoline_header->start = __pa_symbol(ktla_ktva(startup_32_smp));
33513 +
33514 +#ifdef CONFIG_PAX_KERNEXEC
33515 + trampoline_header->start -= LOAD_PHYSICAL_ADDR;
33516 +#endif
33517 +
33518 + trampoline_header->boot_cs = __BOOT_CS;
33519 trampoline_header->gdt_limit = __BOOT_DS + 7;
33520 trampoline_header->gdt_base = __pa_symbol(boot_gdt);
33521 #else
33522 @@ -86,7 +92,7 @@ void __init setup_real_mode(void)
33523 *trampoline_cr4_features = read_cr4();
33524
33525 trampoline_pgd = (u64 *) __va(real_mode_header->trampoline_pgd);
33526 - trampoline_pgd[0] = init_level4_pgt[pgd_index(__PAGE_OFFSET)].pgd;
33527 + trampoline_pgd[0] = init_level4_pgt[pgd_index(__PAGE_OFFSET)].pgd & ~_PAGE_NX;
33528 trampoline_pgd[511] = init_level4_pgt[511].pgd;
33529 #endif
33530 }
33531 diff --git a/arch/x86/realmode/rm/Makefile b/arch/x86/realmode/rm/Makefile
33532 index 8869287..d577672 100644
33533 --- a/arch/x86/realmode/rm/Makefile
33534 +++ b/arch/x86/realmode/rm/Makefile
33535 @@ -78,5 +78,8 @@ KBUILD_CFLAGS := $(LINUXINCLUDE) -m32 -g -Os -D_SETUP -D__KERNEL__ -D_WAKEUP \
33536 $(call cc-option, -fno-unit-at-a-time)) \
33537 $(call cc-option, -fno-stack-protector) \
33538 $(call cc-option, -mpreferred-stack-boundary=2)
33539 +ifdef CONSTIFY_PLUGIN
33540 +KBUILD_CFLAGS += -fplugin-arg-constify_plugin-no-constify
33541 +endif
33542 KBUILD_AFLAGS := $(KBUILD_CFLAGS) -D__ASSEMBLY__
33543 GCOV_PROFILE := n
33544 diff --git a/arch/x86/realmode/rm/header.S b/arch/x86/realmode/rm/header.S
33545 index a28221d..93c40f1 100644
33546 --- a/arch/x86/realmode/rm/header.S
33547 +++ b/arch/x86/realmode/rm/header.S
33548 @@ -30,7 +30,9 @@ GLOBAL(real_mode_header)
33549 #endif
33550 /* APM/BIOS reboot */
33551 .long pa_machine_real_restart_asm
33552 -#ifdef CONFIG_X86_64
33553 +#ifdef CONFIG_X86_32
33554 + .long __KERNEL_CS
33555 +#else
33556 .long __KERNEL32_CS
33557 #endif
33558 END(real_mode_header)
33559 diff --git a/arch/x86/realmode/rm/trampoline_32.S b/arch/x86/realmode/rm/trampoline_32.S
33560 index c1b2791..f9e31c7 100644
33561 --- a/arch/x86/realmode/rm/trampoline_32.S
33562 +++ b/arch/x86/realmode/rm/trampoline_32.S
33563 @@ -25,6 +25,12 @@
33564 #include <asm/page_types.h>
33565 #include "realmode.h"
33566
33567 +#ifdef CONFIG_PAX_KERNEXEC
33568 +#define ta(X) (X)
33569 +#else
33570 +#define ta(X) (pa_ ## X)
33571 +#endif
33572 +
33573 .text
33574 .code16
33575
33576 @@ -39,8 +45,6 @@ ENTRY(trampoline_start)
33577
33578 cli # We should be safe anyway
33579
33580 - movl tr_start, %eax # where we need to go
33581 -
33582 movl $0xA5A5A5A5, trampoline_status
33583 # write marker for master knows we're running
33584
33585 @@ -56,7 +60,7 @@ ENTRY(trampoline_start)
33586 movw $1, %dx # protected mode (PE) bit
33587 lmsw %dx # into protected mode
33588
33589 - ljmpl $__BOOT_CS, $pa_startup_32
33590 + ljmpl *(trampoline_header)
33591
33592 .section ".text32","ax"
33593 .code32
33594 @@ -67,7 +71,7 @@ ENTRY(startup_32) # note: also used from wakeup_asm.S
33595 .balign 8
33596 GLOBAL(trampoline_header)
33597 tr_start: .space 4
33598 - tr_gdt_pad: .space 2
33599 + tr_boot_cs: .space 2
33600 tr_gdt: .space 6
33601 END(trampoline_header)
33602
33603 diff --git a/arch/x86/realmode/rm/trampoline_64.S b/arch/x86/realmode/rm/trampoline_64.S
33604 index bb360dc..d0fd8f8 100644
33605 --- a/arch/x86/realmode/rm/trampoline_64.S
33606 +++ b/arch/x86/realmode/rm/trampoline_64.S
33607 @@ -94,6 +94,7 @@ ENTRY(startup_32)
33608 movl %edx, %gs
33609
33610 movl pa_tr_cr4, %eax
33611 + andl $~X86_CR4_PCIDE, %eax
33612 movl %eax, %cr4 # Enable PAE mode
33613
33614 # Setup trampoline 4 level pagetables
33615 @@ -107,7 +108,7 @@ ENTRY(startup_32)
33616 wrmsr
33617
33618 # Enable paging and in turn activate Long Mode
33619 - movl $(X86_CR0_PG | X86_CR0_WP | X86_CR0_PE), %eax
33620 + movl $(X86_CR0_PG | X86_CR0_PE), %eax
33621 movl %eax, %cr0
33622
33623 /*
33624 diff --git a/arch/x86/tools/Makefile b/arch/x86/tools/Makefile
33625 index e812034..c747134 100644
33626 --- a/arch/x86/tools/Makefile
33627 +++ b/arch/x86/tools/Makefile
33628 @@ -37,7 +37,7 @@ $(obj)/test_get_len.o: $(srctree)/arch/x86/lib/insn.c $(srctree)/arch/x86/lib/in
33629
33630 $(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
33631
33632 -HOST_EXTRACFLAGS += -I$(srctree)/tools/include
33633 +HOST_EXTRACFLAGS += -I$(srctree)/tools/include -ggdb
33634 hostprogs-y += relocs
33635 relocs-objs := relocs_32.o relocs_64.o relocs_common.o
33636 relocs: $(obj)/relocs
33637 diff --git a/arch/x86/tools/relocs.c b/arch/x86/tools/relocs.c
33638 index f7bab68..b6d9886 100644
33639 --- a/arch/x86/tools/relocs.c
33640 +++ b/arch/x86/tools/relocs.c
33641 @@ -1,5 +1,7 @@
33642 /* This is included from relocs_32/64.c */
33643
33644 +#include "../../../include/generated/autoconf.h"
33645 +
33646 #define ElfW(type) _ElfW(ELF_BITS, type)
33647 #define _ElfW(bits, type) __ElfW(bits, type)
33648 #define __ElfW(bits, type) Elf##bits##_##type
33649 @@ -11,6 +13,7 @@
33650 #define Elf_Sym ElfW(Sym)
33651
33652 static Elf_Ehdr ehdr;
33653 +static Elf_Phdr *phdr;
33654
33655 struct relocs {
33656 uint32_t *offset;
33657 @@ -383,9 +386,39 @@ static void read_ehdr(FILE *fp)
33658 }
33659 }
33660
33661 +static void read_phdrs(FILE *fp)
33662 +{
33663 + unsigned int i;
33664 +
33665 + phdr = calloc(ehdr.e_phnum, sizeof(Elf_Phdr));
33666 + if (!phdr) {
33667 + die("Unable to allocate %d program headers\n",
33668 + ehdr.e_phnum);
33669 + }
33670 + if (fseek(fp, ehdr.e_phoff, SEEK_SET) < 0) {
33671 + die("Seek to %d failed: %s\n",
33672 + ehdr.e_phoff, strerror(errno));
33673 + }
33674 + if (fread(phdr, sizeof(*phdr), ehdr.e_phnum, fp) != ehdr.e_phnum) {
33675 + die("Cannot read ELF program headers: %s\n",
33676 + strerror(errno));
33677 + }
33678 + for(i = 0; i < ehdr.e_phnum; i++) {
33679 + phdr[i].p_type = elf_word_to_cpu(phdr[i].p_type);
33680 + phdr[i].p_offset = elf_off_to_cpu(phdr[i].p_offset);
33681 + phdr[i].p_vaddr = elf_addr_to_cpu(phdr[i].p_vaddr);
33682 + phdr[i].p_paddr = elf_addr_to_cpu(phdr[i].p_paddr);
33683 + phdr[i].p_filesz = elf_word_to_cpu(phdr[i].p_filesz);
33684 + phdr[i].p_memsz = elf_word_to_cpu(phdr[i].p_memsz);
33685 + phdr[i].p_flags = elf_word_to_cpu(phdr[i].p_flags);
33686 + phdr[i].p_align = elf_word_to_cpu(phdr[i].p_align);
33687 + }
33688 +
33689 +}
33690 +
33691 static void read_shdrs(FILE *fp)
33692 {
33693 - int i;
33694 + unsigned int i;
33695 Elf_Shdr shdr;
33696
33697 secs = calloc(ehdr.e_shnum, sizeof(struct section));
33698 @@ -420,7 +453,7 @@ static void read_shdrs(FILE *fp)
33699
33700 static void read_strtabs(FILE *fp)
33701 {
33702 - int i;
33703 + unsigned int i;
33704 for (i = 0; i < ehdr.e_shnum; i++) {
33705 struct section *sec = &secs[i];
33706 if (sec->shdr.sh_type != SHT_STRTAB) {
33707 @@ -445,7 +478,7 @@ static void read_strtabs(FILE *fp)
33708
33709 static void read_symtabs(FILE *fp)
33710 {
33711 - int i,j;
33712 + unsigned int i,j;
33713 for (i = 0; i < ehdr.e_shnum; i++) {
33714 struct section *sec = &secs[i];
33715 if (sec->shdr.sh_type != SHT_SYMTAB) {
33716 @@ -476,9 +509,11 @@ static void read_symtabs(FILE *fp)
33717 }
33718
33719
33720 -static void read_relocs(FILE *fp)
33721 +static void read_relocs(FILE *fp, int use_real_mode)
33722 {
33723 - int i,j;
33724 + unsigned int i,j;
33725 + uint32_t base;
33726 +
33727 for (i = 0; i < ehdr.e_shnum; i++) {
33728 struct section *sec = &secs[i];
33729 if (sec->shdr.sh_type != SHT_REL_TYPE) {
33730 @@ -498,9 +533,22 @@ static void read_relocs(FILE *fp)
33731 die("Cannot read symbol table: %s\n",
33732 strerror(errno));
33733 }
33734 + base = 0;
33735 +
33736 +#ifdef CONFIG_X86_32
33737 + for (j = 0; !use_real_mode && j < ehdr.e_phnum; j++) {
33738 + if (phdr[j].p_type != PT_LOAD )
33739 + continue;
33740 + 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)
33741 + continue;
33742 + base = CONFIG_PAGE_OFFSET + phdr[j].p_paddr - phdr[j].p_vaddr;
33743 + break;
33744 + }
33745 +#endif
33746 +
33747 for (j = 0; j < sec->shdr.sh_size/sizeof(Elf_Rel); j++) {
33748 Elf_Rel *rel = &sec->reltab[j];
33749 - rel->r_offset = elf_addr_to_cpu(rel->r_offset);
33750 + rel->r_offset = elf_addr_to_cpu(rel->r_offset) + base;
33751 rel->r_info = elf_xword_to_cpu(rel->r_info);
33752 #if (SHT_REL_TYPE == SHT_RELA)
33753 rel->r_addend = elf_xword_to_cpu(rel->r_addend);
33754 @@ -512,7 +560,7 @@ static void read_relocs(FILE *fp)
33755
33756 static void print_absolute_symbols(void)
33757 {
33758 - int i;
33759 + unsigned int i;
33760 const char *format;
33761
33762 if (ELF_BITS == 64)
33763 @@ -525,7 +573,7 @@ static void print_absolute_symbols(void)
33764 for (i = 0; i < ehdr.e_shnum; i++) {
33765 struct section *sec = &secs[i];
33766 char *sym_strtab;
33767 - int j;
33768 + unsigned int j;
33769
33770 if (sec->shdr.sh_type != SHT_SYMTAB) {
33771 continue;
33772 @@ -552,7 +600,7 @@ static void print_absolute_symbols(void)
33773
33774 static void print_absolute_relocs(void)
33775 {
33776 - int i, printed = 0;
33777 + unsigned int i, printed = 0;
33778 const char *format;
33779
33780 if (ELF_BITS == 64)
33781 @@ -565,7 +613,7 @@ static void print_absolute_relocs(void)
33782 struct section *sec_applies, *sec_symtab;
33783 char *sym_strtab;
33784 Elf_Sym *sh_symtab;
33785 - int j;
33786 + unsigned int j;
33787 if (sec->shdr.sh_type != SHT_REL_TYPE) {
33788 continue;
33789 }
33790 @@ -642,13 +690,13 @@ static void add_reloc(struct relocs *r, uint32_t offset)
33791 static void walk_relocs(int (*process)(struct section *sec, Elf_Rel *rel,
33792 Elf_Sym *sym, const char *symname))
33793 {
33794 - int i;
33795 + unsigned int i;
33796 /* Walk through the relocations */
33797 for (i = 0; i < ehdr.e_shnum; i++) {
33798 char *sym_strtab;
33799 Elf_Sym *sh_symtab;
33800 struct section *sec_applies, *sec_symtab;
33801 - int j;
33802 + unsigned int j;
33803 struct section *sec = &secs[i];
33804
33805 if (sec->shdr.sh_type != SHT_REL_TYPE) {
33806 @@ -812,6 +860,23 @@ static int do_reloc32(struct section *sec, Elf_Rel *rel, Elf_Sym *sym,
33807 {
33808 unsigned r_type = ELF32_R_TYPE(rel->r_info);
33809 int shn_abs = (sym->st_shndx == SHN_ABS) && !is_reloc(S_REL, symname);
33810 + char *sym_strtab = sec->link->link->strtab;
33811 +
33812 + /* Don't relocate actual per-cpu variables, they are absolute indices, not addresses */
33813 + if (!strcmp(sec_name(sym->st_shndx), ".data..percpu") && strcmp(sym_name(sym_strtab, sym), "__per_cpu_load"))
33814 + return 0;
33815 +
33816 +#ifdef CONFIG_PAX_KERNEXEC
33817 + /* Don't relocate actual code, they are relocated implicitly by the base address of KERNEL_CS */
33818 + if (!strcmp(sec_name(sym->st_shndx), ".text.end") && !strcmp(sym_name(sym_strtab, sym), "_etext"))
33819 + return 0;
33820 + if (!strcmp(sec_name(sym->st_shndx), ".init.text"))
33821 + return 0;
33822 + if (!strcmp(sec_name(sym->st_shndx), ".exit.text"))
33823 + return 0;
33824 + if (!strcmp(sec_name(sym->st_shndx), ".text") && strcmp(sym_name(sym_strtab, sym), "__LOAD_PHYSICAL_ADDR"))
33825 + return 0;
33826 +#endif
33827
33828 switch (r_type) {
33829 case R_386_NONE:
33830 @@ -950,7 +1015,7 @@ static int write32_as_text(uint32_t v, FILE *f)
33831
33832 static void emit_relocs(int as_text, int use_real_mode)
33833 {
33834 - int i;
33835 + unsigned int i;
33836 int (*write_reloc)(uint32_t, FILE *) = write32;
33837 int (*do_reloc)(struct section *sec, Elf_Rel *rel, Elf_Sym *sym,
33838 const char *symname);
33839 @@ -1026,10 +1091,11 @@ void process(FILE *fp, int use_real_mode, int as_text,
33840 {
33841 regex_init(use_real_mode);
33842 read_ehdr(fp);
33843 + read_phdrs(fp);
33844 read_shdrs(fp);
33845 read_strtabs(fp);
33846 read_symtabs(fp);
33847 - read_relocs(fp);
33848 + read_relocs(fp, use_real_mode);
33849 if (ELF_BITS == 64)
33850 percpu_init();
33851 if (show_absolute_syms) {
33852 diff --git a/arch/x86/um/tls_32.c b/arch/x86/um/tls_32.c
33853 index 80ffa5b..a33bd15 100644
33854 --- a/arch/x86/um/tls_32.c
33855 +++ b/arch/x86/um/tls_32.c
33856 @@ -260,7 +260,7 @@ out:
33857 if (unlikely(task == current &&
33858 !t->arch.tls_array[idx - GDT_ENTRY_TLS_MIN].flushed)) {
33859 printk(KERN_ERR "get_tls_entry: task with pid %d got here "
33860 - "without flushed TLS.", current->pid);
33861 + "without flushed TLS.", task_pid_nr(current));
33862 }
33863
33864 return 0;
33865 diff --git a/arch/x86/vdso/Makefile b/arch/x86/vdso/Makefile
33866 index fd14be1..e3c79c0 100644
33867 --- a/arch/x86/vdso/Makefile
33868 +++ b/arch/x86/vdso/Makefile
33869 @@ -181,7 +181,7 @@ quiet_cmd_vdso = VDSO $@
33870 -Wl,-T,$(filter %.lds,$^) $(filter %.o,$^) && \
33871 sh $(srctree)/$(src)/checkundef.sh '$(NM)' '$@'
33872
33873 -VDSO_LDFLAGS = -fPIC -shared $(call cc-ldoption, -Wl$(comma)--hash-style=sysv)
33874 +VDSO_LDFLAGS = -fPIC -shared -Wl,--no-undefined $(call cc-ldoption, -Wl$(comma)--hash-style=sysv)
33875 GCOV_PROFILE := n
33876
33877 #
33878 diff --git a/arch/x86/vdso/vdso32-setup.c b/arch/x86/vdso/vdso32-setup.c
33879 index d6bfb87..876ee18 100644
33880 --- a/arch/x86/vdso/vdso32-setup.c
33881 +++ b/arch/x86/vdso/vdso32-setup.c
33882 @@ -25,6 +25,7 @@
33883 #include <asm/tlbflush.h>
33884 #include <asm/vdso.h>
33885 #include <asm/proto.h>
33886 +#include <asm/mman.h>
33887
33888 enum {
33889 VDSO_DISABLED = 0,
33890 @@ -226,7 +227,7 @@ static inline void map_compat_vdso(int map)
33891 void enable_sep_cpu(void)
33892 {
33893 int cpu = get_cpu();
33894 - struct tss_struct *tss = &per_cpu(init_tss, cpu);
33895 + struct tss_struct *tss = init_tss + cpu;
33896
33897 if (!boot_cpu_has(X86_FEATURE_SEP)) {
33898 put_cpu();
33899 @@ -249,7 +250,7 @@ static int __init gate_vma_init(void)
33900 gate_vma.vm_start = FIXADDR_USER_START;
33901 gate_vma.vm_end = FIXADDR_USER_END;
33902 gate_vma.vm_flags = VM_READ | VM_MAYREAD | VM_EXEC | VM_MAYEXEC;
33903 - gate_vma.vm_page_prot = __P101;
33904 + gate_vma.vm_page_prot = vm_get_page_prot(gate_vma.vm_flags);
33905
33906 return 0;
33907 }
33908 @@ -330,14 +331,14 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
33909 if (compat)
33910 addr = VDSO_HIGH_BASE;
33911 else {
33912 - addr = get_unmapped_area(NULL, 0, PAGE_SIZE, 0, 0);
33913 + addr = get_unmapped_area(NULL, 0, PAGE_SIZE, 0, MAP_EXECUTABLE);
33914 if (IS_ERR_VALUE(addr)) {
33915 ret = addr;
33916 goto up_fail;
33917 }
33918 }
33919
33920 - current->mm->context.vdso = (void *)addr;
33921 + current->mm->context.vdso = addr;
33922
33923 if (compat_uses_vma || !compat) {
33924 /*
33925 @@ -353,11 +354,11 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
33926 }
33927
33928 current_thread_info()->sysenter_return =
33929 - VDSO32_SYMBOL(addr, SYSENTER_RETURN);
33930 + (__force void __user *)VDSO32_SYMBOL(addr, SYSENTER_RETURN);
33931
33932 up_fail:
33933 if (ret)
33934 - current->mm->context.vdso = NULL;
33935 + current->mm->context.vdso = 0;
33936
33937 up_write(&mm->mmap_sem);
33938
33939 @@ -404,8 +405,14 @@ __initcall(ia32_binfmt_init);
33940
33941 const char *arch_vma_name(struct vm_area_struct *vma)
33942 {
33943 - if (vma->vm_mm && vma->vm_start == (long)vma->vm_mm->context.vdso)
33944 + if (vma->vm_mm && vma->vm_start == vma->vm_mm->context.vdso)
33945 return "[vdso]";
33946 +
33947 +#ifdef CONFIG_PAX_SEGMEXEC
33948 + if (vma->vm_mm && vma->vm_mirror && vma->vm_mirror->vm_start == vma->vm_mm->context.vdso)
33949 + return "[vdso]";
33950 +#endif
33951 +
33952 return NULL;
33953 }
33954
33955 @@ -415,7 +422,7 @@ struct vm_area_struct *get_gate_vma(struct mm_struct *mm)
33956 * Check to see if the corresponding task was created in compat vdso
33957 * mode.
33958 */
33959 - if (mm && mm->context.vdso == (void *)VDSO_HIGH_BASE)
33960 + if (mm && mm->context.vdso == VDSO_HIGH_BASE)
33961 return &gate_vma;
33962 return NULL;
33963 }
33964 diff --git a/arch/x86/vdso/vma.c b/arch/x86/vdso/vma.c
33965 index 431e875..cbb23f3 100644
33966 --- a/arch/x86/vdso/vma.c
33967 +++ b/arch/x86/vdso/vma.c
33968 @@ -16,8 +16,6 @@
33969 #include <asm/vdso.h>
33970 #include <asm/page.h>
33971
33972 -unsigned int __read_mostly vdso_enabled = 1;
33973 -
33974 extern char vdso_start[], vdso_end[];
33975 extern unsigned short vdso_sync_cpuid;
33976
33977 @@ -141,7 +139,6 @@ static unsigned long vdso_addr(unsigned long start, unsigned len)
33978 * unaligned here as a result of stack start randomization.
33979 */
33980 addr = PAGE_ALIGN(addr);
33981 - addr = align_vdso_addr(addr);
33982
33983 return addr;
33984 }
33985 @@ -154,30 +151,31 @@ static int setup_additional_pages(struct linux_binprm *bprm,
33986 unsigned size)
33987 {
33988 struct mm_struct *mm = current->mm;
33989 - unsigned long addr;
33990 + unsigned long addr = 0;
33991 int ret;
33992
33993 - if (!vdso_enabled)
33994 - return 0;
33995 -
33996 down_write(&mm->mmap_sem);
33997 +
33998 +#ifdef CONFIG_PAX_RANDMMAP
33999 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
34000 +#endif
34001 +
34002 addr = vdso_addr(mm->start_stack, size);
34003 + addr = align_vdso_addr(addr);
34004 addr = get_unmapped_area(NULL, addr, size, 0, 0);
34005 if (IS_ERR_VALUE(addr)) {
34006 ret = addr;
34007 goto up_fail;
34008 }
34009
34010 - current->mm->context.vdso = (void *)addr;
34011 + mm->context.vdso = addr;
34012
34013 ret = install_special_mapping(mm, addr, size,
34014 VM_READ|VM_EXEC|
34015 VM_MAYREAD|VM_MAYWRITE|VM_MAYEXEC,
34016 pages);
34017 - if (ret) {
34018 - current->mm->context.vdso = NULL;
34019 - goto up_fail;
34020 - }
34021 + if (ret)
34022 + mm->context.vdso = 0;
34023
34024 up_fail:
34025 up_write(&mm->mmap_sem);
34026 @@ -197,10 +195,3 @@ int x32_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
34027 vdsox32_size);
34028 }
34029 #endif
34030 -
34031 -static __init int vdso_setup(char *s)
34032 -{
34033 - vdso_enabled = simple_strtoul(s, NULL, 0);
34034 - return 0;
34035 -}
34036 -__setup("vdso=", vdso_setup);
34037 diff --git a/arch/x86/xen/enlighten.c b/arch/x86/xen/enlighten.c
34038 index fa6ade7..73da73a5 100644
34039 --- a/arch/x86/xen/enlighten.c
34040 +++ b/arch/x86/xen/enlighten.c
34041 @@ -123,8 +123,6 @@ EXPORT_SYMBOL_GPL(xen_start_info);
34042
34043 struct shared_info xen_dummy_shared_info;
34044
34045 -void *xen_initial_gdt;
34046 -
34047 RESERVE_BRK(shared_info_page_brk, PAGE_SIZE);
34048 __read_mostly int xen_have_vector_callback;
34049 EXPORT_SYMBOL_GPL(xen_have_vector_callback);
34050 @@ -541,8 +539,7 @@ static void xen_load_gdt(const struct desc_ptr *dtr)
34051 {
34052 unsigned long va = dtr->address;
34053 unsigned int size = dtr->size + 1;
34054 - unsigned pages = (size + PAGE_SIZE - 1) / PAGE_SIZE;
34055 - unsigned long frames[pages];
34056 + unsigned long frames[65536 / PAGE_SIZE];
34057 int f;
34058
34059 /*
34060 @@ -590,8 +587,7 @@ static void __init xen_load_gdt_boot(const struct desc_ptr *dtr)
34061 {
34062 unsigned long va = dtr->address;
34063 unsigned int size = dtr->size + 1;
34064 - unsigned pages = (size + PAGE_SIZE - 1) / PAGE_SIZE;
34065 - unsigned long frames[pages];
34066 + unsigned long frames[(GDT_SIZE + PAGE_SIZE - 1) / PAGE_SIZE];
34067 int f;
34068
34069 /*
34070 @@ -599,7 +595,7 @@ static void __init xen_load_gdt_boot(const struct desc_ptr *dtr)
34071 * 8-byte entries, or 16 4k pages..
34072 */
34073
34074 - BUG_ON(size > 65536);
34075 + BUG_ON(size > GDT_SIZE);
34076 BUG_ON(va & ~PAGE_MASK);
34077
34078 for (f = 0; va < dtr->address + size; va += PAGE_SIZE, f++) {
34079 @@ -988,7 +984,7 @@ static u32 xen_safe_apic_wait_icr_idle(void)
34080 return 0;
34081 }
34082
34083 -static void set_xen_basic_apic_ops(void)
34084 +static void __init set_xen_basic_apic_ops(void)
34085 {
34086 apic->read = xen_apic_read;
34087 apic->write = xen_apic_write;
34088 @@ -1293,30 +1289,30 @@ static const struct pv_apic_ops xen_apic_ops __initconst = {
34089 #endif
34090 };
34091
34092 -static void xen_reboot(int reason)
34093 +static __noreturn void xen_reboot(int reason)
34094 {
34095 struct sched_shutdown r = { .reason = reason };
34096
34097 - if (HYPERVISOR_sched_op(SCHEDOP_shutdown, &r))
34098 - BUG();
34099 + HYPERVISOR_sched_op(SCHEDOP_shutdown, &r);
34100 + BUG();
34101 }
34102
34103 -static void xen_restart(char *msg)
34104 +static __noreturn void xen_restart(char *msg)
34105 {
34106 xen_reboot(SHUTDOWN_reboot);
34107 }
34108
34109 -static void xen_emergency_restart(void)
34110 +static __noreturn void xen_emergency_restart(void)
34111 {
34112 xen_reboot(SHUTDOWN_reboot);
34113 }
34114
34115 -static void xen_machine_halt(void)
34116 +static __noreturn void xen_machine_halt(void)
34117 {
34118 xen_reboot(SHUTDOWN_poweroff);
34119 }
34120
34121 -static void xen_machine_power_off(void)
34122 +static __noreturn void xen_machine_power_off(void)
34123 {
34124 if (pm_power_off)
34125 pm_power_off();
34126 @@ -1467,7 +1463,17 @@ asmlinkage void __init xen_start_kernel(void)
34127 __userpte_alloc_gfp &= ~__GFP_HIGHMEM;
34128
34129 /* Work out if we support NX */
34130 - x86_configure_nx();
34131 +#if defined(CONFIG_X86_64) || defined(CONFIG_X86_PAE)
34132 + if ((cpuid_eax(0x80000000) & 0xffff0000) == 0x80000000 &&
34133 + (cpuid_edx(0x80000001) & (1U << (X86_FEATURE_NX & 31)))) {
34134 + unsigned l, h;
34135 +
34136 + __supported_pte_mask |= _PAGE_NX;
34137 + rdmsr(MSR_EFER, l, h);
34138 + l |= EFER_NX;
34139 + wrmsr(MSR_EFER, l, h);
34140 + }
34141 +#endif
34142
34143 xen_setup_features();
34144
34145 @@ -1498,13 +1504,6 @@ asmlinkage void __init xen_start_kernel(void)
34146
34147 machine_ops = xen_machine_ops;
34148
34149 - /*
34150 - * The only reliable way to retain the initial address of the
34151 - * percpu gdt_page is to remember it here, so we can go and
34152 - * mark it RW later, when the initial percpu area is freed.
34153 - */
34154 - xen_initial_gdt = &per_cpu(gdt_page, 0);
34155 -
34156 xen_smp_init();
34157
34158 #ifdef CONFIG_ACPI_NUMA
34159 diff --git a/arch/x86/xen/mmu.c b/arch/x86/xen/mmu.c
34160 index fdc3ba2..23cae00 100644
34161 --- a/arch/x86/xen/mmu.c
34162 +++ b/arch/x86/xen/mmu.c
34163 @@ -379,7 +379,7 @@ static pteval_t pte_mfn_to_pfn(pteval_t val)
34164 return val;
34165 }
34166
34167 -static pteval_t pte_pfn_to_mfn(pteval_t val)
34168 +static pteval_t __intentional_overflow(-1) pte_pfn_to_mfn(pteval_t val)
34169 {
34170 if (val & _PAGE_PRESENT) {
34171 unsigned long pfn = (val & PTE_PFN_MASK) >> PAGE_SHIFT;
34172 @@ -1894,6 +1894,9 @@ void __init xen_setup_kernel_pagetable(pgd_t *pgd, unsigned long max_pfn)
34173 /* L3_k[510] -> level2_kernel_pgt
34174 * L3_i[511] -> level2_fixmap_pgt */
34175 convert_pfn_mfn(level3_kernel_pgt);
34176 + convert_pfn_mfn(level3_vmalloc_start_pgt);
34177 + convert_pfn_mfn(level3_vmalloc_end_pgt);
34178 + convert_pfn_mfn(level3_vmemmap_pgt);
34179
34180 /* We get [511][511] and have Xen's version of level2_kernel_pgt */
34181 l3 = m2v(pgd[pgd_index(__START_KERNEL_map)].pgd);
34182 @@ -1923,8 +1926,12 @@ void __init xen_setup_kernel_pagetable(pgd_t *pgd, unsigned long max_pfn)
34183 set_page_prot(init_level4_pgt, PAGE_KERNEL_RO);
34184 set_page_prot(level3_ident_pgt, PAGE_KERNEL_RO);
34185 set_page_prot(level3_kernel_pgt, PAGE_KERNEL_RO);
34186 + set_page_prot(level3_vmalloc_start_pgt, PAGE_KERNEL_RO);
34187 + set_page_prot(level3_vmalloc_end_pgt, PAGE_KERNEL_RO);
34188 + set_page_prot(level3_vmemmap_pgt, PAGE_KERNEL_RO);
34189 set_page_prot(level3_user_vsyscall, PAGE_KERNEL_RO);
34190 set_page_prot(level2_ident_pgt, PAGE_KERNEL_RO);
34191 + set_page_prot(level2_vmemmap_pgt, PAGE_KERNEL_RO);
34192 set_page_prot(level2_kernel_pgt, PAGE_KERNEL_RO);
34193 set_page_prot(level2_fixmap_pgt, PAGE_KERNEL_RO);
34194
34195 @@ -2108,6 +2115,7 @@ static void __init xen_post_allocator_init(void)
34196 pv_mmu_ops.set_pud = xen_set_pud;
34197 #if PAGETABLE_LEVELS == 4
34198 pv_mmu_ops.set_pgd = xen_set_pgd;
34199 + pv_mmu_ops.set_pgd_batched = xen_set_pgd;
34200 #endif
34201
34202 /* This will work as long as patching hasn't happened yet
34203 @@ -2186,6 +2194,7 @@ static const struct pv_mmu_ops xen_mmu_ops __initconst = {
34204 .pud_val = PV_CALLEE_SAVE(xen_pud_val),
34205 .make_pud = PV_CALLEE_SAVE(xen_make_pud),
34206 .set_pgd = xen_set_pgd_hyper,
34207 + .set_pgd_batched = xen_set_pgd_hyper,
34208
34209 .alloc_pud = xen_alloc_pmd_init,
34210 .release_pud = xen_release_pmd_init,
34211 diff --git a/arch/x86/xen/smp.c b/arch/x86/xen/smp.c
34212 index 31d0475..51af671 100644
34213 --- a/arch/x86/xen/smp.c
34214 +++ b/arch/x86/xen/smp.c
34215 @@ -274,17 +274,13 @@ static void __init xen_smp_prepare_boot_cpu(void)
34216 native_smp_prepare_boot_cpu();
34217
34218 if (xen_pv_domain()) {
34219 - /* We've switched to the "real" per-cpu gdt, so make sure the
34220 - old memory can be recycled */
34221 - make_lowmem_page_readwrite(xen_initial_gdt);
34222 -
34223 #ifdef CONFIG_X86_32
34224 /*
34225 * Xen starts us with XEN_FLAT_RING1_DS, but linux code
34226 * expects __USER_DS
34227 */
34228 - loadsegment(ds, __USER_DS);
34229 - loadsegment(es, __USER_DS);
34230 + loadsegment(ds, __KERNEL_DS);
34231 + loadsegment(es, __KERNEL_DS);
34232 #endif
34233
34234 xen_filter_cpu_maps();
34235 @@ -364,7 +360,7 @@ cpu_initialize_context(unsigned int cpu, struct task_struct *idle)
34236 ctxt->user_regs.ss = __KERNEL_DS;
34237 #ifdef CONFIG_X86_32
34238 ctxt->user_regs.fs = __KERNEL_PERCPU;
34239 - ctxt->user_regs.gs = __KERNEL_STACK_CANARY;
34240 + savesegment(gs, ctxt->user_regs.gs);
34241 #else
34242 ctxt->gs_base_kernel = per_cpu_offset(cpu);
34243 #endif
34244 @@ -374,8 +370,8 @@ cpu_initialize_context(unsigned int cpu, struct task_struct *idle)
34245
34246 {
34247 ctxt->user_regs.eflags = 0x1000; /* IOPL_RING1 */
34248 - ctxt->user_regs.ds = __USER_DS;
34249 - ctxt->user_regs.es = __USER_DS;
34250 + ctxt->user_regs.ds = __KERNEL_DS;
34251 + ctxt->user_regs.es = __KERNEL_DS;
34252
34253 xen_copy_trap_info(ctxt->trap_ctxt);
34254
34255 @@ -420,13 +416,12 @@ static int xen_cpu_up(unsigned int cpu, struct task_struct *idle)
34256 int rc;
34257
34258 per_cpu(current_task, cpu) = idle;
34259 + per_cpu(current_tinfo, cpu) = &idle->tinfo;
34260 #ifdef CONFIG_X86_32
34261 irq_ctx_init(cpu);
34262 #else
34263 clear_tsk_thread_flag(idle, TIF_FORK);
34264 - per_cpu(kernel_stack, cpu) =
34265 - (unsigned long)task_stack_page(idle) -
34266 - KERNEL_STACK_OFFSET + THREAD_SIZE;
34267 + per_cpu(kernel_stack, cpu) = (unsigned long)task_stack_page(idle) - 16 + THREAD_SIZE;
34268 #endif
34269 xen_setup_runstate_info(cpu);
34270 xen_setup_timer(cpu);
34271 @@ -702,7 +697,7 @@ static const struct smp_ops xen_smp_ops __initconst = {
34272
34273 void __init xen_smp_init(void)
34274 {
34275 - smp_ops = xen_smp_ops;
34276 + memcpy((void *)&smp_ops, &xen_smp_ops, sizeof smp_ops);
34277 xen_fill_possible_map();
34278 }
34279
34280 diff --git a/arch/x86/xen/xen-asm_32.S b/arch/x86/xen/xen-asm_32.S
34281 index 33ca6e4..0ded929 100644
34282 --- a/arch/x86/xen/xen-asm_32.S
34283 +++ b/arch/x86/xen/xen-asm_32.S
34284 @@ -84,14 +84,14 @@ ENTRY(xen_iret)
34285 ESP_OFFSET=4 # bytes pushed onto stack
34286
34287 /*
34288 - * Store vcpu_info pointer for easy access. Do it this way to
34289 - * avoid having to reload %fs
34290 + * Store vcpu_info pointer for easy access.
34291 */
34292 #ifdef CONFIG_SMP
34293 - GET_THREAD_INFO(%eax)
34294 - movl %ss:TI_cpu(%eax), %eax
34295 - movl %ss:__per_cpu_offset(,%eax,4), %eax
34296 - mov %ss:xen_vcpu(%eax), %eax
34297 + push %fs
34298 + mov $(__KERNEL_PERCPU), %eax
34299 + mov %eax, %fs
34300 + mov PER_CPU_VAR(xen_vcpu), %eax
34301 + pop %fs
34302 #else
34303 movl %ss:xen_vcpu, %eax
34304 #endif
34305 diff --git a/arch/x86/xen/xen-head.S b/arch/x86/xen/xen-head.S
34306 index 7faed58..ba4427c 100644
34307 --- a/arch/x86/xen/xen-head.S
34308 +++ b/arch/x86/xen/xen-head.S
34309 @@ -19,6 +19,17 @@ ENTRY(startup_xen)
34310 #ifdef CONFIG_X86_32
34311 mov %esi,xen_start_info
34312 mov $init_thread_union+THREAD_SIZE,%esp
34313 +#ifdef CONFIG_SMP
34314 + movl $cpu_gdt_table,%edi
34315 + movl $__per_cpu_load,%eax
34316 + movw %ax,__KERNEL_PERCPU + 2(%edi)
34317 + rorl $16,%eax
34318 + movb %al,__KERNEL_PERCPU + 4(%edi)
34319 + movb %ah,__KERNEL_PERCPU + 7(%edi)
34320 + movl $__per_cpu_end - 1,%eax
34321 + subl $__per_cpu_start,%eax
34322 + movw %ax,__KERNEL_PERCPU + 0(%edi)
34323 +#endif
34324 #else
34325 mov %rsi,xen_start_info
34326 mov $init_thread_union+THREAD_SIZE,%rsp
34327 diff --git a/arch/x86/xen/xen-ops.h b/arch/x86/xen/xen-ops.h
34328 index 95f8c61..611d6e8 100644
34329 --- a/arch/x86/xen/xen-ops.h
34330 +++ b/arch/x86/xen/xen-ops.h
34331 @@ -10,8 +10,6 @@
34332 extern const char xen_hypervisor_callback[];
34333 extern const char xen_failsafe_callback[];
34334
34335 -extern void *xen_initial_gdt;
34336 -
34337 struct trap_info;
34338 void xen_copy_trap_info(struct trap_info *traps);
34339
34340 diff --git a/arch/xtensa/variants/dc232b/include/variant/core.h b/arch/xtensa/variants/dc232b/include/variant/core.h
34341 index 525bd3d..ef888b1 100644
34342 --- a/arch/xtensa/variants/dc232b/include/variant/core.h
34343 +++ b/arch/xtensa/variants/dc232b/include/variant/core.h
34344 @@ -119,9 +119,9 @@
34345 ----------------------------------------------------------------------*/
34346
34347 #define XCHAL_ICACHE_LINESIZE 32 /* I-cache line size in bytes */
34348 -#define XCHAL_DCACHE_LINESIZE 32 /* D-cache line size in bytes */
34349 #define XCHAL_ICACHE_LINEWIDTH 5 /* log2(I line size in bytes) */
34350 #define XCHAL_DCACHE_LINEWIDTH 5 /* log2(D line size in bytes) */
34351 +#define XCHAL_DCACHE_LINESIZE (_AC(1,UL) << XCHAL_DCACHE_LINEWIDTH) /* D-cache line size in bytes */
34352
34353 #define XCHAL_ICACHE_SIZE 16384 /* I-cache size in bytes or 0 */
34354 #define XCHAL_DCACHE_SIZE 16384 /* D-cache size in bytes or 0 */
34355 diff --git a/arch/xtensa/variants/fsf/include/variant/core.h b/arch/xtensa/variants/fsf/include/variant/core.h
34356 index 2f33760..835e50a 100644
34357 --- a/arch/xtensa/variants/fsf/include/variant/core.h
34358 +++ b/arch/xtensa/variants/fsf/include/variant/core.h
34359 @@ -11,6 +11,7 @@
34360 #ifndef _XTENSA_CORE_H
34361 #define _XTENSA_CORE_H
34362
34363 +#include <linux/const.h>
34364
34365 /****************************************************************************
34366 Parameters Useful for Any Code, USER or PRIVILEGED
34367 @@ -112,9 +113,9 @@
34368 ----------------------------------------------------------------------*/
34369
34370 #define XCHAL_ICACHE_LINESIZE 16 /* I-cache line size in bytes */
34371 -#define XCHAL_DCACHE_LINESIZE 16 /* D-cache line size in bytes */
34372 #define XCHAL_ICACHE_LINEWIDTH 4 /* log2(I line size in bytes) */
34373 #define XCHAL_DCACHE_LINEWIDTH 4 /* log2(D line size in bytes) */
34374 +#define XCHAL_DCACHE_LINESIZE (_AC(1,UL) << XCHAL_DCACHE_LINEWIDTH) /* D-cache line size in bytes */
34375
34376 #define XCHAL_ICACHE_SIZE 8192 /* I-cache size in bytes or 0 */
34377 #define XCHAL_DCACHE_SIZE 8192 /* D-cache size in bytes or 0 */
34378 diff --git a/arch/xtensa/variants/s6000/include/variant/core.h b/arch/xtensa/variants/s6000/include/variant/core.h
34379 index af00795..2bb8105 100644
34380 --- a/arch/xtensa/variants/s6000/include/variant/core.h
34381 +++ b/arch/xtensa/variants/s6000/include/variant/core.h
34382 @@ -11,6 +11,7 @@
34383 #ifndef _XTENSA_CORE_CONFIGURATION_H
34384 #define _XTENSA_CORE_CONFIGURATION_H
34385
34386 +#include <linux/const.h>
34387
34388 /****************************************************************************
34389 Parameters Useful for Any Code, USER or PRIVILEGED
34390 @@ -118,9 +119,9 @@
34391 ----------------------------------------------------------------------*/
34392
34393 #define XCHAL_ICACHE_LINESIZE 16 /* I-cache line size in bytes */
34394 -#define XCHAL_DCACHE_LINESIZE 16 /* D-cache line size in bytes */
34395 #define XCHAL_ICACHE_LINEWIDTH 4 /* log2(I line size in bytes) */
34396 #define XCHAL_DCACHE_LINEWIDTH 4 /* log2(D line size in bytes) */
34397 +#define XCHAL_DCACHE_LINESIZE (_AC(1,UL) << XCHAL_DCACHE_LINEWIDTH) /* D-cache line size in bytes */
34398
34399 #define XCHAL_ICACHE_SIZE 32768 /* I-cache size in bytes or 0 */
34400 #define XCHAL_DCACHE_SIZE 32768 /* D-cache size in bytes or 0 */
34401 diff --git a/block/blk-cgroup.c b/block/blk-cgroup.c
34402 index 4e491d9..c8e18e4 100644
34403 --- a/block/blk-cgroup.c
34404 +++ b/block/blk-cgroup.c
34405 @@ -812,7 +812,7 @@ static void blkcg_css_free(struct cgroup_subsys_state *css)
34406 static struct cgroup_subsys_state *
34407 blkcg_css_alloc(struct cgroup_subsys_state *parent_css)
34408 {
34409 - static atomic64_t id_seq = ATOMIC64_INIT(0);
34410 + static atomic64_unchecked_t id_seq = ATOMIC64_INIT(0);
34411 struct blkcg *blkcg;
34412
34413 if (!parent_css) {
34414 @@ -826,7 +826,7 @@ blkcg_css_alloc(struct cgroup_subsys_state *parent_css)
34415
34416 blkcg->cfq_weight = CFQ_WEIGHT_DEFAULT;
34417 blkcg->cfq_leaf_weight = CFQ_WEIGHT_DEFAULT;
34418 - blkcg->id = atomic64_inc_return(&id_seq); /* root is 0, start from 1 */
34419 + blkcg->id = atomic64_inc_return_unchecked(&id_seq); /* root is 0, start from 1 */
34420 done:
34421 spin_lock_init(&blkcg->lock);
34422 INIT_RADIX_TREE(&blkcg->blkg_tree, GFP_ATOMIC);
34423 diff --git a/block/blk-iopoll.c b/block/blk-iopoll.c
34424 index 4b8d9b54..a7178c0 100644
34425 --- a/block/blk-iopoll.c
34426 +++ b/block/blk-iopoll.c
34427 @@ -77,7 +77,7 @@ void blk_iopoll_complete(struct blk_iopoll *iopoll)
34428 }
34429 EXPORT_SYMBOL(blk_iopoll_complete);
34430
34431 -static void blk_iopoll_softirq(struct softirq_action *h)
34432 +static __latent_entropy void blk_iopoll_softirq(void)
34433 {
34434 struct list_head *list = &__get_cpu_var(blk_cpu_iopoll);
34435 int rearm = 0, budget = blk_iopoll_budget;
34436 diff --git a/block/blk-map.c b/block/blk-map.c
34437 index 623e1cd..ca1e109 100644
34438 --- a/block/blk-map.c
34439 +++ b/block/blk-map.c
34440 @@ -302,7 +302,7 @@ int blk_rq_map_kern(struct request_queue *q, struct request *rq, void *kbuf,
34441 if (!len || !kbuf)
34442 return -EINVAL;
34443
34444 - do_copy = !blk_rq_aligned(q, addr, len) || object_is_on_stack(kbuf);
34445 + do_copy = !blk_rq_aligned(q, addr, len) || object_starts_on_stack(kbuf);
34446 if (do_copy)
34447 bio = bio_copy_kern(q, kbuf, len, gfp_mask, reading);
34448 else
34449 diff --git a/block/blk-softirq.c b/block/blk-softirq.c
34450 index ec9e606..3f38839 100644
34451 --- a/block/blk-softirq.c
34452 +++ b/block/blk-softirq.c
34453 @@ -18,7 +18,7 @@ static DEFINE_PER_CPU(struct list_head, blk_cpu_done);
34454 * Softirq action handler - move entries to local list and loop over them
34455 * while passing them to the queue registered handler.
34456 */
34457 -static void blk_done_softirq(struct softirq_action *h)
34458 +static __latent_entropy void blk_done_softirq(void)
34459 {
34460 struct list_head *cpu_list, local_list;
34461
34462 diff --git a/block/bsg.c b/block/bsg.c
34463 index 420a5a9..23834aa 100644
34464 --- a/block/bsg.c
34465 +++ b/block/bsg.c
34466 @@ -176,16 +176,24 @@ static int blk_fill_sgv4_hdr_rq(struct request_queue *q, struct request *rq,
34467 struct sg_io_v4 *hdr, struct bsg_device *bd,
34468 fmode_t has_write_perm)
34469 {
34470 + unsigned char tmpcmd[sizeof(rq->__cmd)];
34471 + unsigned char *cmdptr;
34472 +
34473 if (hdr->request_len > BLK_MAX_CDB) {
34474 rq->cmd = kzalloc(hdr->request_len, GFP_KERNEL);
34475 if (!rq->cmd)
34476 return -ENOMEM;
34477 - }
34478 + cmdptr = rq->cmd;
34479 + } else
34480 + cmdptr = tmpcmd;
34481
34482 - if (copy_from_user(rq->cmd, (void __user *)(unsigned long)hdr->request,
34483 + if (copy_from_user(cmdptr, (void __user *)(unsigned long)hdr->request,
34484 hdr->request_len))
34485 return -EFAULT;
34486
34487 + if (cmdptr != rq->cmd)
34488 + memcpy(rq->cmd, cmdptr, hdr->request_len);
34489 +
34490 if (hdr->subprotocol == BSG_SUB_PROTOCOL_SCSI_CMD) {
34491 if (blk_verify_command(rq->cmd, has_write_perm))
34492 return -EPERM;
34493 diff --git a/block/compat_ioctl.c b/block/compat_ioctl.c
34494 index fbd5a67..5d631b5 100644
34495 --- a/block/compat_ioctl.c
34496 +++ b/block/compat_ioctl.c
34497 @@ -341,7 +341,7 @@ static int compat_fd_ioctl(struct block_device *bdev, fmode_t mode,
34498 err |= __get_user(f->spec1, &uf->spec1);
34499 err |= __get_user(f->fmt_gap, &uf->fmt_gap);
34500 err |= __get_user(name, &uf->name);
34501 - f->name = compat_ptr(name);
34502 + f->name = (void __force_kernel *)compat_ptr(name);
34503 if (err) {
34504 err = -EFAULT;
34505 goto out;
34506 diff --git a/block/genhd.c b/block/genhd.c
34507 index 791f419..89f21c4 100644
34508 --- a/block/genhd.c
34509 +++ b/block/genhd.c
34510 @@ -467,21 +467,24 @@ static char *bdevt_str(dev_t devt, char *buf)
34511
34512 /*
34513 * Register device numbers dev..(dev+range-1)
34514 - * range must be nonzero
34515 + * Noop if @range is zero.
34516 * The hash chain is sorted on range, so that subranges can override.
34517 */
34518 void blk_register_region(dev_t devt, unsigned long range, struct module *module,
34519 struct kobject *(*probe)(dev_t, int *, void *),
34520 int (*lock)(dev_t, void *), void *data)
34521 {
34522 - kobj_map(bdev_map, devt, range, module, probe, lock, data);
34523 + if (range)
34524 + kobj_map(bdev_map, devt, range, module, probe, lock, data);
34525 }
34526
34527 EXPORT_SYMBOL(blk_register_region);
34528
34529 +/* undo blk_register_region(), noop if @range is zero */
34530 void blk_unregister_region(dev_t devt, unsigned long range)
34531 {
34532 - kobj_unmap(bdev_map, devt, range);
34533 + if (range)
34534 + kobj_unmap(bdev_map, devt, range);
34535 }
34536
34537 EXPORT_SYMBOL(blk_unregister_region);
34538 diff --git a/block/partitions/efi.c b/block/partitions/efi.c
34539 index a8287b4..241a48e 100644
34540 --- a/block/partitions/efi.c
34541 +++ b/block/partitions/efi.c
34542 @@ -292,14 +292,14 @@ static gpt_entry *alloc_read_gpt_entries(struct parsed_partitions *state,
34543 if (!gpt)
34544 return NULL;
34545
34546 + if (!le32_to_cpu(gpt->num_partition_entries))
34547 + return NULL;
34548 + pte = kcalloc(le32_to_cpu(gpt->num_partition_entries), le32_to_cpu(gpt->sizeof_partition_entry), GFP_KERNEL);
34549 + if (!pte)
34550 + return NULL;
34551 +
34552 count = le32_to_cpu(gpt->num_partition_entries) *
34553 le32_to_cpu(gpt->sizeof_partition_entry);
34554 - if (!count)
34555 - return NULL;
34556 - pte = kmalloc(count, GFP_KERNEL);
34557 - if (!pte)
34558 - return NULL;
34559 -
34560 if (read_lba(state, le64_to_cpu(gpt->partition_entry_lba),
34561 (u8 *) pte, count) < count) {
34562 kfree(pte);
34563 diff --git a/block/scsi_ioctl.c b/block/scsi_ioctl.c
34564 index a5ffcc9..e057498 100644
34565 --- a/block/scsi_ioctl.c
34566 +++ b/block/scsi_ioctl.c
34567 @@ -67,7 +67,7 @@ static int scsi_get_bus(struct request_queue *q, int __user *p)
34568 return put_user(0, p);
34569 }
34570
34571 -static int sg_get_timeout(struct request_queue *q)
34572 +static int __intentional_overflow(-1) sg_get_timeout(struct request_queue *q)
34573 {
34574 return jiffies_to_clock_t(q->sg_timeout);
34575 }
34576 @@ -224,8 +224,20 @@ EXPORT_SYMBOL(blk_verify_command);
34577 static int blk_fill_sghdr_rq(struct request_queue *q, struct request *rq,
34578 struct sg_io_hdr *hdr, fmode_t mode)
34579 {
34580 - if (copy_from_user(rq->cmd, hdr->cmdp, hdr->cmd_len))
34581 + unsigned char tmpcmd[sizeof(rq->__cmd)];
34582 + unsigned char *cmdptr;
34583 +
34584 + if (rq->cmd != rq->__cmd)
34585 + cmdptr = rq->cmd;
34586 + else
34587 + cmdptr = tmpcmd;
34588 +
34589 + if (copy_from_user(cmdptr, hdr->cmdp, hdr->cmd_len))
34590 return -EFAULT;
34591 +
34592 + if (cmdptr != rq->cmd)
34593 + memcpy(rq->cmd, cmdptr, hdr->cmd_len);
34594 +
34595 if (blk_verify_command(rq->cmd, mode & FMODE_WRITE))
34596 return -EPERM;
34597
34598 @@ -434,6 +446,8 @@ int sg_scsi_ioctl(struct request_queue *q, struct gendisk *disk, fmode_t mode,
34599 int err;
34600 unsigned int in_len, out_len, bytes, opcode, cmdlen;
34601 char *buffer = NULL, sense[SCSI_SENSE_BUFFERSIZE];
34602 + unsigned char tmpcmd[sizeof(rq->__cmd)];
34603 + unsigned char *cmdptr;
34604
34605 if (!sic)
34606 return -EINVAL;
34607 @@ -467,9 +481,18 @@ int sg_scsi_ioctl(struct request_queue *q, struct gendisk *disk, fmode_t mode,
34608 */
34609 err = -EFAULT;
34610 rq->cmd_len = cmdlen;
34611 - if (copy_from_user(rq->cmd, sic->data, cmdlen))
34612 +
34613 + if (rq->cmd != rq->__cmd)
34614 + cmdptr = rq->cmd;
34615 + else
34616 + cmdptr = tmpcmd;
34617 +
34618 + if (copy_from_user(cmdptr, sic->data, cmdlen))
34619 goto error;
34620
34621 + if (rq->cmd != cmdptr)
34622 + memcpy(rq->cmd, cmdptr, cmdlen);
34623 +
34624 if (in_len && copy_from_user(buffer, sic->data + cmdlen, in_len))
34625 goto error;
34626
34627 diff --git a/crypto/cryptd.c b/crypto/cryptd.c
34628 index 7bdd61b..afec999 100644
34629 --- a/crypto/cryptd.c
34630 +++ b/crypto/cryptd.c
34631 @@ -63,7 +63,7 @@ struct cryptd_blkcipher_ctx {
34632
34633 struct cryptd_blkcipher_request_ctx {
34634 crypto_completion_t complete;
34635 -};
34636 +} __no_const;
34637
34638 struct cryptd_hash_ctx {
34639 struct crypto_shash *child;
34640 @@ -80,7 +80,7 @@ struct cryptd_aead_ctx {
34641
34642 struct cryptd_aead_request_ctx {
34643 crypto_completion_t complete;
34644 -};
34645 +} __no_const;
34646
34647 static void cryptd_queue_worker(struct work_struct *work);
34648
34649 diff --git a/crypto/pcrypt.c b/crypto/pcrypt.c
34650 index f8c920c..ab2cb5a 100644
34651 --- a/crypto/pcrypt.c
34652 +++ b/crypto/pcrypt.c
34653 @@ -440,7 +440,7 @@ static int pcrypt_sysfs_add(struct padata_instance *pinst, const char *name)
34654 int ret;
34655
34656 pinst->kobj.kset = pcrypt_kset;
34657 - ret = kobject_add(&pinst->kobj, NULL, name);
34658 + ret = kobject_add(&pinst->kobj, NULL, "%s", name);
34659 if (!ret)
34660 kobject_uevent(&pinst->kobj, KOBJ_ADD);
34661
34662 diff --git a/drivers/acpi/apei/apei-internal.h b/drivers/acpi/apei/apei-internal.h
34663 index f220d64..d359ad6 100644
34664 --- a/drivers/acpi/apei/apei-internal.h
34665 +++ b/drivers/acpi/apei/apei-internal.h
34666 @@ -20,7 +20,7 @@ typedef int (*apei_exec_ins_func_t)(struct apei_exec_context *ctx,
34667 struct apei_exec_ins_type {
34668 u32 flags;
34669 apei_exec_ins_func_t run;
34670 -};
34671 +} __do_const;
34672
34673 struct apei_exec_context {
34674 u32 ip;
34675 diff --git a/drivers/acpi/apei/cper.c b/drivers/acpi/apei/cper.c
34676 index 33dc6a0..4b24b47 100644
34677 --- a/drivers/acpi/apei/cper.c
34678 +++ b/drivers/acpi/apei/cper.c
34679 @@ -39,12 +39,12 @@
34680 */
34681 u64 cper_next_record_id(void)
34682 {
34683 - static atomic64_t seq;
34684 + static atomic64_unchecked_t seq;
34685
34686 - if (!atomic64_read(&seq))
34687 - atomic64_set(&seq, ((u64)get_seconds()) << 32);
34688 + if (!atomic64_read_unchecked(&seq))
34689 + atomic64_set_unchecked(&seq, ((u64)get_seconds()) << 32);
34690
34691 - return atomic64_inc_return(&seq);
34692 + return atomic64_inc_return_unchecked(&seq);
34693 }
34694 EXPORT_SYMBOL_GPL(cper_next_record_id);
34695
34696 diff --git a/drivers/acpi/apei/ghes.c b/drivers/acpi/apei/ghes.c
34697 index 8ec37bb..b0716e5 100644
34698 --- a/drivers/acpi/apei/ghes.c
34699 +++ b/drivers/acpi/apei/ghes.c
34700 @@ -498,7 +498,7 @@ static void __ghes_print_estatus(const char *pfx,
34701 const struct acpi_hest_generic *generic,
34702 const struct acpi_hest_generic_status *estatus)
34703 {
34704 - static atomic_t seqno;
34705 + static atomic_unchecked_t seqno;
34706 unsigned int curr_seqno;
34707 char pfx_seq[64];
34708
34709 @@ -509,7 +509,7 @@ static void __ghes_print_estatus(const char *pfx,
34710 else
34711 pfx = KERN_ERR;
34712 }
34713 - curr_seqno = atomic_inc_return(&seqno);
34714 + curr_seqno = atomic_inc_return_unchecked(&seqno);
34715 snprintf(pfx_seq, sizeof(pfx_seq), "%s{%u}" HW_ERR, pfx, curr_seqno);
34716 printk("%s""Hardware error from APEI Generic Hardware Error Source: %d\n",
34717 pfx_seq, generic->header.source_id);
34718 diff --git a/drivers/acpi/bgrt.c b/drivers/acpi/bgrt.c
34719 index a83e3c6..c3d617f 100644
34720 --- a/drivers/acpi/bgrt.c
34721 +++ b/drivers/acpi/bgrt.c
34722 @@ -86,8 +86,10 @@ static int __init bgrt_init(void)
34723 if (!bgrt_image)
34724 return -ENODEV;
34725
34726 - bin_attr_image.private = bgrt_image;
34727 - bin_attr_image.size = bgrt_image_size;
34728 + pax_open_kernel();
34729 + *(void **)&bin_attr_image.private = bgrt_image;
34730 + *(size_t *)&bin_attr_image.size = bgrt_image_size;
34731 + pax_close_kernel();
34732
34733 bgrt_kobj = kobject_create_and_add("bgrt", acpi_kobj);
34734 if (!bgrt_kobj)
34735 diff --git a/drivers/acpi/blacklist.c b/drivers/acpi/blacklist.c
34736 index 9515f18..4b149c9 100644
34737 --- a/drivers/acpi/blacklist.c
34738 +++ b/drivers/acpi/blacklist.c
34739 @@ -52,7 +52,7 @@ struct acpi_blacklist_item {
34740 u32 is_critical_error;
34741 };
34742
34743 -static struct dmi_system_id acpi_osi_dmi_table[] __initdata;
34744 +static const struct dmi_system_id acpi_osi_dmi_table[] __initconst;
34745
34746 /*
34747 * POLICY: If *anything* doesn't work, put it on the blacklist.
34748 @@ -199,7 +199,7 @@ static int __init dmi_disable_osi_win8(const struct dmi_system_id *d)
34749 return 0;
34750 }
34751
34752 -static struct dmi_system_id acpi_osi_dmi_table[] __initdata = {
34753 +static const struct dmi_system_id acpi_osi_dmi_table[] __initconst = {
34754 {
34755 .callback = dmi_disable_osi_vista,
34756 .ident = "Fujitsu Siemens",
34757 diff --git a/drivers/acpi/processor_idle.c b/drivers/acpi/processor_idle.c
34758 index c7414a5..d5afd71 100644
34759 --- a/drivers/acpi/processor_idle.c
34760 +++ b/drivers/acpi/processor_idle.c
34761 @@ -966,7 +966,7 @@ static int acpi_processor_setup_cpuidle_states(struct acpi_processor *pr)
34762 {
34763 int i, count = CPUIDLE_DRIVER_STATE_START;
34764 struct acpi_processor_cx *cx;
34765 - struct cpuidle_state *state;
34766 + cpuidle_state_no_const *state;
34767 struct cpuidle_driver *drv = &acpi_idle_driver;
34768
34769 if (!pr->flags.power_setup_done)
34770 diff --git a/drivers/acpi/sysfs.c b/drivers/acpi/sysfs.c
34771 index 05306a5..733d1f0 100644
34772 --- a/drivers/acpi/sysfs.c
34773 +++ b/drivers/acpi/sysfs.c
34774 @@ -423,11 +423,11 @@ static u32 num_counters;
34775 static struct attribute **all_attrs;
34776 static u32 acpi_gpe_count;
34777
34778 -static struct attribute_group interrupt_stats_attr_group = {
34779 +static attribute_group_no_const interrupt_stats_attr_group = {
34780 .name = "interrupts",
34781 };
34782
34783 -static struct kobj_attribute *counter_attrs;
34784 +static kobj_attribute_no_const *counter_attrs;
34785
34786 static void delete_gpe_attr_array(void)
34787 {
34788 diff --git a/drivers/ata/libahci.c b/drivers/ata/libahci.c
34789 index cfb7447..98f2149 100644
34790 --- a/drivers/ata/libahci.c
34791 +++ b/drivers/ata/libahci.c
34792 @@ -1239,7 +1239,7 @@ int ahci_kick_engine(struct ata_port *ap)
34793 }
34794 EXPORT_SYMBOL_GPL(ahci_kick_engine);
34795
34796 -static int ahci_exec_polled_cmd(struct ata_port *ap, int pmp,
34797 +static int __intentional_overflow(-1) ahci_exec_polled_cmd(struct ata_port *ap, int pmp,
34798 struct ata_taskfile *tf, int is_cmd, u16 flags,
34799 unsigned long timeout_msec)
34800 {
34801 diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c
34802 index 81a94a3..b711c74 100644
34803 --- a/drivers/ata/libata-core.c
34804 +++ b/drivers/ata/libata-core.c
34805 @@ -98,7 +98,7 @@ static unsigned int ata_dev_set_xfermode(struct ata_device *dev);
34806 static void ata_dev_xfermask(struct ata_device *dev);
34807 static unsigned long ata_dev_blacklisted(const struct ata_device *dev);
34808
34809 -atomic_t ata_print_id = ATOMIC_INIT(0);
34810 +atomic_unchecked_t ata_print_id = ATOMIC_INIT(0);
34811
34812 struct ata_force_param {
34813 const char *name;
34814 @@ -4809,7 +4809,7 @@ void ata_qc_free(struct ata_queued_cmd *qc)
34815 struct ata_port *ap;
34816 unsigned int tag;
34817
34818 - WARN_ON_ONCE(qc == NULL); /* ata_qc_from_tag _might_ return NULL */
34819 + BUG_ON(qc == NULL); /* ata_qc_from_tag _might_ return NULL */
34820 ap = qc->ap;
34821
34822 qc->flags = 0;
34823 @@ -4825,7 +4825,7 @@ void __ata_qc_complete(struct ata_queued_cmd *qc)
34824 struct ata_port *ap;
34825 struct ata_link *link;
34826
34827 - WARN_ON_ONCE(qc == NULL); /* ata_qc_from_tag _might_ return NULL */
34828 + BUG_ON(qc == NULL); /* ata_qc_from_tag _might_ return NULL */
34829 WARN_ON_ONCE(!(qc->flags & ATA_QCFLAG_ACTIVE));
34830 ap = qc->ap;
34831 link = qc->dev->link;
34832 @@ -5944,6 +5944,7 @@ static void ata_finalize_port_ops(struct ata_port_operations *ops)
34833 return;
34834
34835 spin_lock(&lock);
34836 + pax_open_kernel();
34837
34838 for (cur = ops->inherits; cur; cur = cur->inherits) {
34839 void **inherit = (void **)cur;
34840 @@ -5957,8 +5958,9 @@ static void ata_finalize_port_ops(struct ata_port_operations *ops)
34841 if (IS_ERR(*pp))
34842 *pp = NULL;
34843
34844 - ops->inherits = NULL;
34845 + *(struct ata_port_operations **)&ops->inherits = NULL;
34846
34847 + pax_close_kernel();
34848 spin_unlock(&lock);
34849 }
34850
34851 @@ -6151,7 +6153,7 @@ int ata_host_register(struct ata_host *host, struct scsi_host_template *sht)
34852
34853 /* give ports names and add SCSI hosts */
34854 for (i = 0; i < host->n_ports; i++) {
34855 - host->ports[i]->print_id = atomic_inc_return(&ata_print_id);
34856 + host->ports[i]->print_id = atomic_inc_return_unchecked(&ata_print_id);
34857 host->ports[i]->local_port_no = i + 1;
34858 }
34859
34860 diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c
34861 index db6dfcf..770d1f0 100644
34862 --- a/drivers/ata/libata-scsi.c
34863 +++ b/drivers/ata/libata-scsi.c
34864 @@ -4113,7 +4113,7 @@ int ata_sas_port_init(struct ata_port *ap)
34865
34866 if (rc)
34867 return rc;
34868 - ap->print_id = atomic_inc_return(&ata_print_id);
34869 + ap->print_id = atomic_inc_return_unchecked(&ata_print_id);
34870 return 0;
34871 }
34872 EXPORT_SYMBOL_GPL(ata_sas_port_init);
34873 diff --git a/drivers/ata/libata.h b/drivers/ata/libata.h
34874 index 45b5ab3..98446b8 100644
34875 --- a/drivers/ata/libata.h
34876 +++ b/drivers/ata/libata.h
34877 @@ -53,7 +53,7 @@ enum {
34878 ATA_DNXFER_QUIET = (1 << 31),
34879 };
34880
34881 -extern atomic_t ata_print_id;
34882 +extern atomic_unchecked_t ata_print_id;
34883 extern int atapi_passthru16;
34884 extern int libata_fua;
34885 extern int libata_noacpi;
34886 diff --git a/drivers/ata/pata_arasan_cf.c b/drivers/ata/pata_arasan_cf.c
34887 index 853f610..97d24da 100644
34888 --- a/drivers/ata/pata_arasan_cf.c
34889 +++ b/drivers/ata/pata_arasan_cf.c
34890 @@ -865,7 +865,9 @@ static int arasan_cf_probe(struct platform_device *pdev)
34891 /* Handle platform specific quirks */
34892 if (quirk) {
34893 if (quirk & CF_BROKEN_PIO) {
34894 - ap->ops->set_piomode = NULL;
34895 + pax_open_kernel();
34896 + *(void **)&ap->ops->set_piomode = NULL;
34897 + pax_close_kernel();
34898 ap->pio_mask = 0;
34899 }
34900 if (quirk & CF_BROKEN_MWDMA)
34901 diff --git a/drivers/atm/adummy.c b/drivers/atm/adummy.c
34902 index f9b983a..887b9d8 100644
34903 --- a/drivers/atm/adummy.c
34904 +++ b/drivers/atm/adummy.c
34905 @@ -114,7 +114,7 @@ adummy_send(struct atm_vcc *vcc, struct sk_buff *skb)
34906 vcc->pop(vcc, skb);
34907 else
34908 dev_kfree_skb_any(skb);
34909 - atomic_inc(&vcc->stats->tx);
34910 + atomic_inc_unchecked(&vcc->stats->tx);
34911
34912 return 0;
34913 }
34914 diff --git a/drivers/atm/ambassador.c b/drivers/atm/ambassador.c
34915 index 62a7607..cc4be104 100644
34916 --- a/drivers/atm/ambassador.c
34917 +++ b/drivers/atm/ambassador.c
34918 @@ -454,7 +454,7 @@ static void tx_complete (amb_dev * dev, tx_out * tx) {
34919 PRINTD (DBG_FLOW|DBG_TX, "tx_complete %p %p", dev, tx);
34920
34921 // VC layer stats
34922 - atomic_inc(&ATM_SKB(skb)->vcc->stats->tx);
34923 + atomic_inc_unchecked(&ATM_SKB(skb)->vcc->stats->tx);
34924
34925 // free the descriptor
34926 kfree (tx_descr);
34927 @@ -495,7 +495,7 @@ static void rx_complete (amb_dev * dev, rx_out * rx) {
34928 dump_skb ("<<<", vc, skb);
34929
34930 // VC layer stats
34931 - atomic_inc(&atm_vcc->stats->rx);
34932 + atomic_inc_unchecked(&atm_vcc->stats->rx);
34933 __net_timestamp(skb);
34934 // end of our responsibility
34935 atm_vcc->push (atm_vcc, skb);
34936 @@ -510,7 +510,7 @@ static void rx_complete (amb_dev * dev, rx_out * rx) {
34937 } else {
34938 PRINTK (KERN_INFO, "dropped over-size frame");
34939 // should we count this?
34940 - atomic_inc(&atm_vcc->stats->rx_drop);
34941 + atomic_inc_unchecked(&atm_vcc->stats->rx_drop);
34942 }
34943
34944 } else {
34945 @@ -1338,7 +1338,7 @@ static int amb_send (struct atm_vcc * atm_vcc, struct sk_buff * skb) {
34946 }
34947
34948 if (check_area (skb->data, skb->len)) {
34949 - atomic_inc(&atm_vcc->stats->tx_err);
34950 + atomic_inc_unchecked(&atm_vcc->stats->tx_err);
34951 return -ENOMEM; // ?
34952 }
34953
34954 diff --git a/drivers/atm/atmtcp.c b/drivers/atm/atmtcp.c
34955 index 0e3f8f9..765a7a5 100644
34956 --- a/drivers/atm/atmtcp.c
34957 +++ b/drivers/atm/atmtcp.c
34958 @@ -206,7 +206,7 @@ static int atmtcp_v_send(struct atm_vcc *vcc,struct sk_buff *skb)
34959 if (vcc->pop) vcc->pop(vcc,skb);
34960 else dev_kfree_skb(skb);
34961 if (dev_data) return 0;
34962 - atomic_inc(&vcc->stats->tx_err);
34963 + atomic_inc_unchecked(&vcc->stats->tx_err);
34964 return -ENOLINK;
34965 }
34966 size = skb->len+sizeof(struct atmtcp_hdr);
34967 @@ -214,7 +214,7 @@ static int atmtcp_v_send(struct atm_vcc *vcc,struct sk_buff *skb)
34968 if (!new_skb) {
34969 if (vcc->pop) vcc->pop(vcc,skb);
34970 else dev_kfree_skb(skb);
34971 - atomic_inc(&vcc->stats->tx_err);
34972 + atomic_inc_unchecked(&vcc->stats->tx_err);
34973 return -ENOBUFS;
34974 }
34975 hdr = (void *) skb_put(new_skb,sizeof(struct atmtcp_hdr));
34976 @@ -225,8 +225,8 @@ static int atmtcp_v_send(struct atm_vcc *vcc,struct sk_buff *skb)
34977 if (vcc->pop) vcc->pop(vcc,skb);
34978 else dev_kfree_skb(skb);
34979 out_vcc->push(out_vcc,new_skb);
34980 - atomic_inc(&vcc->stats->tx);
34981 - atomic_inc(&out_vcc->stats->rx);
34982 + atomic_inc_unchecked(&vcc->stats->tx);
34983 + atomic_inc_unchecked(&out_vcc->stats->rx);
34984 return 0;
34985 }
34986
34987 @@ -299,7 +299,7 @@ static int atmtcp_c_send(struct atm_vcc *vcc,struct sk_buff *skb)
34988 out_vcc = find_vcc(dev, ntohs(hdr->vpi), ntohs(hdr->vci));
34989 read_unlock(&vcc_sklist_lock);
34990 if (!out_vcc) {
34991 - atomic_inc(&vcc->stats->tx_err);
34992 + atomic_inc_unchecked(&vcc->stats->tx_err);
34993 goto done;
34994 }
34995 skb_pull(skb,sizeof(struct atmtcp_hdr));
34996 @@ -311,8 +311,8 @@ static int atmtcp_c_send(struct atm_vcc *vcc,struct sk_buff *skb)
34997 __net_timestamp(new_skb);
34998 skb_copy_from_linear_data(skb, skb_put(new_skb, skb->len), skb->len);
34999 out_vcc->push(out_vcc,new_skb);
35000 - atomic_inc(&vcc->stats->tx);
35001 - atomic_inc(&out_vcc->stats->rx);
35002 + atomic_inc_unchecked(&vcc->stats->tx);
35003 + atomic_inc_unchecked(&out_vcc->stats->rx);
35004 done:
35005 if (vcc->pop) vcc->pop(vcc,skb);
35006 else dev_kfree_skb(skb);
35007 diff --git a/drivers/atm/eni.c b/drivers/atm/eni.c
35008 index b1955ba..b179940 100644
35009 --- a/drivers/atm/eni.c
35010 +++ b/drivers/atm/eni.c
35011 @@ -522,7 +522,7 @@ static int rx_aal0(struct atm_vcc *vcc)
35012 DPRINTK(DEV_LABEL "(itf %d): trashing empty cell\n",
35013 vcc->dev->number);
35014 length = 0;
35015 - atomic_inc(&vcc->stats->rx_err);
35016 + atomic_inc_unchecked(&vcc->stats->rx_err);
35017 }
35018 else {
35019 length = ATM_CELL_SIZE-1; /* no HEC */
35020 @@ -577,7 +577,7 @@ static int rx_aal5(struct atm_vcc *vcc)
35021 size);
35022 }
35023 eff = length = 0;
35024 - atomic_inc(&vcc->stats->rx_err);
35025 + atomic_inc_unchecked(&vcc->stats->rx_err);
35026 }
35027 else {
35028 size = (descr & MID_RED_COUNT)*(ATM_CELL_PAYLOAD >> 2);
35029 @@ -594,7 +594,7 @@ static int rx_aal5(struct atm_vcc *vcc)
35030 "(VCI=%d,length=%ld,size=%ld (descr 0x%lx))\n",
35031 vcc->dev->number,vcc->vci,length,size << 2,descr);
35032 length = eff = 0;
35033 - atomic_inc(&vcc->stats->rx_err);
35034 + atomic_inc_unchecked(&vcc->stats->rx_err);
35035 }
35036 }
35037 skb = eff ? atm_alloc_charge(vcc,eff << 2,GFP_ATOMIC) : NULL;
35038 @@ -767,7 +767,7 @@ rx_dequeued++;
35039 vcc->push(vcc,skb);
35040 pushed++;
35041 }
35042 - atomic_inc(&vcc->stats->rx);
35043 + atomic_inc_unchecked(&vcc->stats->rx);
35044 }
35045 wake_up(&eni_dev->rx_wait);
35046 }
35047 @@ -1227,7 +1227,7 @@ static void dequeue_tx(struct atm_dev *dev)
35048 PCI_DMA_TODEVICE);
35049 if (vcc->pop) vcc->pop(vcc,skb);
35050 else dev_kfree_skb_irq(skb);
35051 - atomic_inc(&vcc->stats->tx);
35052 + atomic_inc_unchecked(&vcc->stats->tx);
35053 wake_up(&eni_dev->tx_wait);
35054 dma_complete++;
35055 }
35056 diff --git a/drivers/atm/firestream.c b/drivers/atm/firestream.c
35057 index b41c948..a002b17 100644
35058 --- a/drivers/atm/firestream.c
35059 +++ b/drivers/atm/firestream.c
35060 @@ -749,7 +749,7 @@ static void process_txdone_queue (struct fs_dev *dev, struct queue *q)
35061 }
35062 }
35063
35064 - atomic_inc(&ATM_SKB(skb)->vcc->stats->tx);
35065 + atomic_inc_unchecked(&ATM_SKB(skb)->vcc->stats->tx);
35066
35067 fs_dprintk (FS_DEBUG_TXMEM, "i");
35068 fs_dprintk (FS_DEBUG_ALLOC, "Free t-skb: %p\n", skb);
35069 @@ -816,7 +816,7 @@ static void process_incoming (struct fs_dev *dev, struct queue *q)
35070 #endif
35071 skb_put (skb, qe->p1 & 0xffff);
35072 ATM_SKB(skb)->vcc = atm_vcc;
35073 - atomic_inc(&atm_vcc->stats->rx);
35074 + atomic_inc_unchecked(&atm_vcc->stats->rx);
35075 __net_timestamp(skb);
35076 fs_dprintk (FS_DEBUG_ALLOC, "Free rec-skb: %p (pushed)\n", skb);
35077 atm_vcc->push (atm_vcc, skb);
35078 @@ -837,12 +837,12 @@ static void process_incoming (struct fs_dev *dev, struct queue *q)
35079 kfree (pe);
35080 }
35081 if (atm_vcc)
35082 - atomic_inc(&atm_vcc->stats->rx_drop);
35083 + atomic_inc_unchecked(&atm_vcc->stats->rx_drop);
35084 break;
35085 case 0x1f: /* Reassembly abort: no buffers. */
35086 /* Silently increment error counter. */
35087 if (atm_vcc)
35088 - atomic_inc(&atm_vcc->stats->rx_drop);
35089 + atomic_inc_unchecked(&atm_vcc->stats->rx_drop);
35090 break;
35091 default: /* Hmm. Haven't written the code to handle the others yet... -- REW */
35092 printk (KERN_WARNING "Don't know what to do with RX status %x: %s.\n",
35093 diff --git a/drivers/atm/fore200e.c b/drivers/atm/fore200e.c
35094 index 204814e..cede831 100644
35095 --- a/drivers/atm/fore200e.c
35096 +++ b/drivers/atm/fore200e.c
35097 @@ -931,9 +931,9 @@ fore200e_tx_irq(struct fore200e* fore200e)
35098 #endif
35099 /* check error condition */
35100 if (*entry->status & STATUS_ERROR)
35101 - atomic_inc(&vcc->stats->tx_err);
35102 + atomic_inc_unchecked(&vcc->stats->tx_err);
35103 else
35104 - atomic_inc(&vcc->stats->tx);
35105 + atomic_inc_unchecked(&vcc->stats->tx);
35106 }
35107 }
35108
35109 @@ -1082,7 +1082,7 @@ fore200e_push_rpd(struct fore200e* fore200e, struct atm_vcc* vcc, struct rpd* rp
35110 if (skb == NULL) {
35111 DPRINTK(2, "unable to alloc new skb, rx PDU length = %d\n", pdu_len);
35112
35113 - atomic_inc(&vcc->stats->rx_drop);
35114 + atomic_inc_unchecked(&vcc->stats->rx_drop);
35115 return -ENOMEM;
35116 }
35117
35118 @@ -1125,14 +1125,14 @@ fore200e_push_rpd(struct fore200e* fore200e, struct atm_vcc* vcc, struct rpd* rp
35119
35120 dev_kfree_skb_any(skb);
35121
35122 - atomic_inc(&vcc->stats->rx_drop);
35123 + atomic_inc_unchecked(&vcc->stats->rx_drop);
35124 return -ENOMEM;
35125 }
35126
35127 ASSERT(atomic_read(&sk_atm(vcc)->sk_wmem_alloc) >= 0);
35128
35129 vcc->push(vcc, skb);
35130 - atomic_inc(&vcc->stats->rx);
35131 + atomic_inc_unchecked(&vcc->stats->rx);
35132
35133 ASSERT(atomic_read(&sk_atm(vcc)->sk_wmem_alloc) >= 0);
35134
35135 @@ -1210,7 +1210,7 @@ fore200e_rx_irq(struct fore200e* fore200e)
35136 DPRINTK(2, "damaged PDU on %d.%d.%d\n",
35137 fore200e->atm_dev->number,
35138 entry->rpd->atm_header.vpi, entry->rpd->atm_header.vci);
35139 - atomic_inc(&vcc->stats->rx_err);
35140 + atomic_inc_unchecked(&vcc->stats->rx_err);
35141 }
35142 }
35143
35144 @@ -1655,7 +1655,7 @@ fore200e_send(struct atm_vcc *vcc, struct sk_buff *skb)
35145 goto retry_here;
35146 }
35147
35148 - atomic_inc(&vcc->stats->tx_err);
35149 + atomic_inc_unchecked(&vcc->stats->tx_err);
35150
35151 fore200e->tx_sat++;
35152 DPRINTK(2, "tx queue of device %s is saturated, PDU dropped - heartbeat is %08x\n",
35153 diff --git a/drivers/atm/he.c b/drivers/atm/he.c
35154 index 8557adc..3fb5d55 100644
35155 --- a/drivers/atm/he.c
35156 +++ b/drivers/atm/he.c
35157 @@ -1691,7 +1691,7 @@ he_service_rbrq(struct he_dev *he_dev, int group)
35158
35159 if (RBRQ_HBUF_ERR(he_dev->rbrq_head)) {
35160 hprintk("HBUF_ERR! (cid 0x%x)\n", cid);
35161 - atomic_inc(&vcc->stats->rx_drop);
35162 + atomic_inc_unchecked(&vcc->stats->rx_drop);
35163 goto return_host_buffers;
35164 }
35165
35166 @@ -1718,7 +1718,7 @@ he_service_rbrq(struct he_dev *he_dev, int group)
35167 RBRQ_LEN_ERR(he_dev->rbrq_head)
35168 ? "LEN_ERR" : "",
35169 vcc->vpi, vcc->vci);
35170 - atomic_inc(&vcc->stats->rx_err);
35171 + atomic_inc_unchecked(&vcc->stats->rx_err);
35172 goto return_host_buffers;
35173 }
35174
35175 @@ -1770,7 +1770,7 @@ he_service_rbrq(struct he_dev *he_dev, int group)
35176 vcc->push(vcc, skb);
35177 spin_lock(&he_dev->global_lock);
35178
35179 - atomic_inc(&vcc->stats->rx);
35180 + atomic_inc_unchecked(&vcc->stats->rx);
35181
35182 return_host_buffers:
35183 ++pdus_assembled;
35184 @@ -2096,7 +2096,7 @@ __enqueue_tpd(struct he_dev *he_dev, struct he_tpd *tpd, unsigned cid)
35185 tpd->vcc->pop(tpd->vcc, tpd->skb);
35186 else
35187 dev_kfree_skb_any(tpd->skb);
35188 - atomic_inc(&tpd->vcc->stats->tx_err);
35189 + atomic_inc_unchecked(&tpd->vcc->stats->tx_err);
35190 }
35191 pci_pool_free(he_dev->tpd_pool, tpd, TPD_ADDR(tpd->status));
35192 return;
35193 @@ -2508,7 +2508,7 @@ he_send(struct atm_vcc *vcc, struct sk_buff *skb)
35194 vcc->pop(vcc, skb);
35195 else
35196 dev_kfree_skb_any(skb);
35197 - atomic_inc(&vcc->stats->tx_err);
35198 + atomic_inc_unchecked(&vcc->stats->tx_err);
35199 return -EINVAL;
35200 }
35201
35202 @@ -2519,7 +2519,7 @@ he_send(struct atm_vcc *vcc, struct sk_buff *skb)
35203 vcc->pop(vcc, skb);
35204 else
35205 dev_kfree_skb_any(skb);
35206 - atomic_inc(&vcc->stats->tx_err);
35207 + atomic_inc_unchecked(&vcc->stats->tx_err);
35208 return -EINVAL;
35209 }
35210 #endif
35211 @@ -2531,7 +2531,7 @@ he_send(struct atm_vcc *vcc, struct sk_buff *skb)
35212 vcc->pop(vcc, skb);
35213 else
35214 dev_kfree_skb_any(skb);
35215 - atomic_inc(&vcc->stats->tx_err);
35216 + atomic_inc_unchecked(&vcc->stats->tx_err);
35217 spin_unlock_irqrestore(&he_dev->global_lock, flags);
35218 return -ENOMEM;
35219 }
35220 @@ -2573,7 +2573,7 @@ he_send(struct atm_vcc *vcc, struct sk_buff *skb)
35221 vcc->pop(vcc, skb);
35222 else
35223 dev_kfree_skb_any(skb);
35224 - atomic_inc(&vcc->stats->tx_err);
35225 + atomic_inc_unchecked(&vcc->stats->tx_err);
35226 spin_unlock_irqrestore(&he_dev->global_lock, flags);
35227 return -ENOMEM;
35228 }
35229 @@ -2604,7 +2604,7 @@ he_send(struct atm_vcc *vcc, struct sk_buff *skb)
35230 __enqueue_tpd(he_dev, tpd, cid);
35231 spin_unlock_irqrestore(&he_dev->global_lock, flags);
35232
35233 - atomic_inc(&vcc->stats->tx);
35234 + atomic_inc_unchecked(&vcc->stats->tx);
35235
35236 return 0;
35237 }
35238 diff --git a/drivers/atm/horizon.c b/drivers/atm/horizon.c
35239 index 1dc0519..1aadaf7 100644
35240 --- a/drivers/atm/horizon.c
35241 +++ b/drivers/atm/horizon.c
35242 @@ -1034,7 +1034,7 @@ static void rx_schedule (hrz_dev * dev, int irq) {
35243 {
35244 struct atm_vcc * vcc = ATM_SKB(skb)->vcc;
35245 // VC layer stats
35246 - atomic_inc(&vcc->stats->rx);
35247 + atomic_inc_unchecked(&vcc->stats->rx);
35248 __net_timestamp(skb);
35249 // end of our responsibility
35250 vcc->push (vcc, skb);
35251 @@ -1186,7 +1186,7 @@ static void tx_schedule (hrz_dev * const dev, int irq) {
35252 dev->tx_iovec = NULL;
35253
35254 // VC layer stats
35255 - atomic_inc(&ATM_SKB(skb)->vcc->stats->tx);
35256 + atomic_inc_unchecked(&ATM_SKB(skb)->vcc->stats->tx);
35257
35258 // free the skb
35259 hrz_kfree_skb (skb);
35260 diff --git a/drivers/atm/idt77252.c b/drivers/atm/idt77252.c
35261 index 1bdf104..9dc44b1 100644
35262 --- a/drivers/atm/idt77252.c
35263 +++ b/drivers/atm/idt77252.c
35264 @@ -812,7 +812,7 @@ drain_scq(struct idt77252_dev *card, struct vc_map *vc)
35265 else
35266 dev_kfree_skb(skb);
35267
35268 - atomic_inc(&vcc->stats->tx);
35269 + atomic_inc_unchecked(&vcc->stats->tx);
35270 }
35271
35272 atomic_dec(&scq->used);
35273 @@ -1075,13 +1075,13 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
35274 if ((sb = dev_alloc_skb(64)) == NULL) {
35275 printk("%s: Can't allocate buffers for aal0.\n",
35276 card->name);
35277 - atomic_add(i, &vcc->stats->rx_drop);
35278 + atomic_add_unchecked(i, &vcc->stats->rx_drop);
35279 break;
35280 }
35281 if (!atm_charge(vcc, sb->truesize)) {
35282 RXPRINTK("%s: atm_charge() dropped aal0 packets.\n",
35283 card->name);
35284 - atomic_add(i - 1, &vcc->stats->rx_drop);
35285 + atomic_add_unchecked(i - 1, &vcc->stats->rx_drop);
35286 dev_kfree_skb(sb);
35287 break;
35288 }
35289 @@ -1098,7 +1098,7 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
35290 ATM_SKB(sb)->vcc = vcc;
35291 __net_timestamp(sb);
35292 vcc->push(vcc, sb);
35293 - atomic_inc(&vcc->stats->rx);
35294 + atomic_inc_unchecked(&vcc->stats->rx);
35295
35296 cell += ATM_CELL_PAYLOAD;
35297 }
35298 @@ -1135,13 +1135,13 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
35299 "(CDC: %08x)\n",
35300 card->name, len, rpp->len, readl(SAR_REG_CDC));
35301 recycle_rx_pool_skb(card, rpp);
35302 - atomic_inc(&vcc->stats->rx_err);
35303 + atomic_inc_unchecked(&vcc->stats->rx_err);
35304 return;
35305 }
35306 if (stat & SAR_RSQE_CRC) {
35307 RXPRINTK("%s: AAL5 CRC error.\n", card->name);
35308 recycle_rx_pool_skb(card, rpp);
35309 - atomic_inc(&vcc->stats->rx_err);
35310 + atomic_inc_unchecked(&vcc->stats->rx_err);
35311 return;
35312 }
35313 if (skb_queue_len(&rpp->queue) > 1) {
35314 @@ -1152,7 +1152,7 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
35315 RXPRINTK("%s: Can't alloc RX skb.\n",
35316 card->name);
35317 recycle_rx_pool_skb(card, rpp);
35318 - atomic_inc(&vcc->stats->rx_err);
35319 + atomic_inc_unchecked(&vcc->stats->rx_err);
35320 return;
35321 }
35322 if (!atm_charge(vcc, skb->truesize)) {
35323 @@ -1171,7 +1171,7 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
35324 __net_timestamp(skb);
35325
35326 vcc->push(vcc, skb);
35327 - atomic_inc(&vcc->stats->rx);
35328 + atomic_inc_unchecked(&vcc->stats->rx);
35329
35330 return;
35331 }
35332 @@ -1193,7 +1193,7 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
35333 __net_timestamp(skb);
35334
35335 vcc->push(vcc, skb);
35336 - atomic_inc(&vcc->stats->rx);
35337 + atomic_inc_unchecked(&vcc->stats->rx);
35338
35339 if (skb->truesize > SAR_FB_SIZE_3)
35340 add_rx_skb(card, 3, SAR_FB_SIZE_3, 1);
35341 @@ -1304,14 +1304,14 @@ idt77252_rx_raw(struct idt77252_dev *card)
35342 if (vcc->qos.aal != ATM_AAL0) {
35343 RPRINTK("%s: raw cell for non AAL0 vc %u.%u\n",
35344 card->name, vpi, vci);
35345 - atomic_inc(&vcc->stats->rx_drop);
35346 + atomic_inc_unchecked(&vcc->stats->rx_drop);
35347 goto drop;
35348 }
35349
35350 if ((sb = dev_alloc_skb(64)) == NULL) {
35351 printk("%s: Can't allocate buffers for AAL0.\n",
35352 card->name);
35353 - atomic_inc(&vcc->stats->rx_err);
35354 + atomic_inc_unchecked(&vcc->stats->rx_err);
35355 goto drop;
35356 }
35357
35358 @@ -1330,7 +1330,7 @@ idt77252_rx_raw(struct idt77252_dev *card)
35359 ATM_SKB(sb)->vcc = vcc;
35360 __net_timestamp(sb);
35361 vcc->push(vcc, sb);
35362 - atomic_inc(&vcc->stats->rx);
35363 + atomic_inc_unchecked(&vcc->stats->rx);
35364
35365 drop:
35366 skb_pull(queue, 64);
35367 @@ -1955,13 +1955,13 @@ idt77252_send_skb(struct atm_vcc *vcc, struct sk_buff *skb, int oam)
35368
35369 if (vc == NULL) {
35370 printk("%s: NULL connection in send().\n", card->name);
35371 - atomic_inc(&vcc->stats->tx_err);
35372 + atomic_inc_unchecked(&vcc->stats->tx_err);
35373 dev_kfree_skb(skb);
35374 return -EINVAL;
35375 }
35376 if (!test_bit(VCF_TX, &vc->flags)) {
35377 printk("%s: Trying to transmit on a non-tx VC.\n", card->name);
35378 - atomic_inc(&vcc->stats->tx_err);
35379 + atomic_inc_unchecked(&vcc->stats->tx_err);
35380 dev_kfree_skb(skb);
35381 return -EINVAL;
35382 }
35383 @@ -1973,14 +1973,14 @@ idt77252_send_skb(struct atm_vcc *vcc, struct sk_buff *skb, int oam)
35384 break;
35385 default:
35386 printk("%s: Unsupported AAL: %d\n", card->name, vcc->qos.aal);
35387 - atomic_inc(&vcc->stats->tx_err);
35388 + atomic_inc_unchecked(&vcc->stats->tx_err);
35389 dev_kfree_skb(skb);
35390 return -EINVAL;
35391 }
35392
35393 if (skb_shinfo(skb)->nr_frags != 0) {
35394 printk("%s: No scatter-gather yet.\n", card->name);
35395 - atomic_inc(&vcc->stats->tx_err);
35396 + atomic_inc_unchecked(&vcc->stats->tx_err);
35397 dev_kfree_skb(skb);
35398 return -EINVAL;
35399 }
35400 @@ -1988,7 +1988,7 @@ idt77252_send_skb(struct atm_vcc *vcc, struct sk_buff *skb, int oam)
35401
35402 err = queue_skb(card, vc, skb, oam);
35403 if (err) {
35404 - atomic_inc(&vcc->stats->tx_err);
35405 + atomic_inc_unchecked(&vcc->stats->tx_err);
35406 dev_kfree_skb(skb);
35407 return err;
35408 }
35409 @@ -2011,7 +2011,7 @@ idt77252_send_oam(struct atm_vcc *vcc, void *cell, int flags)
35410 skb = dev_alloc_skb(64);
35411 if (!skb) {
35412 printk("%s: Out of memory in send_oam().\n", card->name);
35413 - atomic_inc(&vcc->stats->tx_err);
35414 + atomic_inc_unchecked(&vcc->stats->tx_err);
35415 return -ENOMEM;
35416 }
35417 atomic_add(skb->truesize, &sk_atm(vcc)->sk_wmem_alloc);
35418 diff --git a/drivers/atm/iphase.c b/drivers/atm/iphase.c
35419 index 4217f29..88f547a 100644
35420 --- a/drivers/atm/iphase.c
35421 +++ b/drivers/atm/iphase.c
35422 @@ -1145,7 +1145,7 @@ static int rx_pkt(struct atm_dev *dev)
35423 status = (u_short) (buf_desc_ptr->desc_mode);
35424 if (status & (RX_CER | RX_PTE | RX_OFL))
35425 {
35426 - atomic_inc(&vcc->stats->rx_err);
35427 + atomic_inc_unchecked(&vcc->stats->rx_err);
35428 IF_ERR(printk("IA: bad packet, dropping it");)
35429 if (status & RX_CER) {
35430 IF_ERR(printk(" cause: packet CRC error\n");)
35431 @@ -1168,7 +1168,7 @@ static int rx_pkt(struct atm_dev *dev)
35432 len = dma_addr - buf_addr;
35433 if (len > iadev->rx_buf_sz) {
35434 printk("Over %d bytes sdu received, dropped!!!\n", iadev->rx_buf_sz);
35435 - atomic_inc(&vcc->stats->rx_err);
35436 + atomic_inc_unchecked(&vcc->stats->rx_err);
35437 goto out_free_desc;
35438 }
35439
35440 @@ -1318,7 +1318,7 @@ static void rx_dle_intr(struct atm_dev *dev)
35441 ia_vcc = INPH_IA_VCC(vcc);
35442 if (ia_vcc == NULL)
35443 {
35444 - atomic_inc(&vcc->stats->rx_err);
35445 + atomic_inc_unchecked(&vcc->stats->rx_err);
35446 atm_return(vcc, skb->truesize);
35447 dev_kfree_skb_any(skb);
35448 goto INCR_DLE;
35449 @@ -1330,7 +1330,7 @@ static void rx_dle_intr(struct atm_dev *dev)
35450 if ((length > iadev->rx_buf_sz) || (length >
35451 (skb->len - sizeof(struct cpcs_trailer))))
35452 {
35453 - atomic_inc(&vcc->stats->rx_err);
35454 + atomic_inc_unchecked(&vcc->stats->rx_err);
35455 IF_ERR(printk("rx_dle_intr: Bad AAL5 trailer %d (skb len %d)",
35456 length, skb->len);)
35457 atm_return(vcc, skb->truesize);
35458 @@ -1346,7 +1346,7 @@ static void rx_dle_intr(struct atm_dev *dev)
35459
35460 IF_RX(printk("rx_dle_intr: skb push");)
35461 vcc->push(vcc,skb);
35462 - atomic_inc(&vcc->stats->rx);
35463 + atomic_inc_unchecked(&vcc->stats->rx);
35464 iadev->rx_pkt_cnt++;
35465 }
35466 INCR_DLE:
35467 @@ -2826,15 +2826,15 @@ static int ia_ioctl(struct atm_dev *dev, unsigned int cmd, void __user *arg)
35468 {
35469 struct k_sonet_stats *stats;
35470 stats = &PRIV(_ia_dev[board])->sonet_stats;
35471 - printk("section_bip: %d\n", atomic_read(&stats->section_bip));
35472 - printk("line_bip : %d\n", atomic_read(&stats->line_bip));
35473 - printk("path_bip : %d\n", atomic_read(&stats->path_bip));
35474 - printk("line_febe : %d\n", atomic_read(&stats->line_febe));
35475 - printk("path_febe : %d\n", atomic_read(&stats->path_febe));
35476 - printk("corr_hcs : %d\n", atomic_read(&stats->corr_hcs));
35477 - printk("uncorr_hcs : %d\n", atomic_read(&stats->uncorr_hcs));
35478 - printk("tx_cells : %d\n", atomic_read(&stats->tx_cells));
35479 - printk("rx_cells : %d\n", atomic_read(&stats->rx_cells));
35480 + printk("section_bip: %d\n", atomic_read_unchecked(&stats->section_bip));
35481 + printk("line_bip : %d\n", atomic_read_unchecked(&stats->line_bip));
35482 + printk("path_bip : %d\n", atomic_read_unchecked(&stats->path_bip));
35483 + printk("line_febe : %d\n", atomic_read_unchecked(&stats->line_febe));
35484 + printk("path_febe : %d\n", atomic_read_unchecked(&stats->path_febe));
35485 + printk("corr_hcs : %d\n", atomic_read_unchecked(&stats->corr_hcs));
35486 + printk("uncorr_hcs : %d\n", atomic_read_unchecked(&stats->uncorr_hcs));
35487 + printk("tx_cells : %d\n", atomic_read_unchecked(&stats->tx_cells));
35488 + printk("rx_cells : %d\n", atomic_read_unchecked(&stats->rx_cells));
35489 }
35490 ia_cmds.status = 0;
35491 break;
35492 @@ -2939,7 +2939,7 @@ static int ia_pkt_tx (struct atm_vcc *vcc, struct sk_buff *skb) {
35493 if ((desc == 0) || (desc > iadev->num_tx_desc))
35494 {
35495 IF_ERR(printk(DEV_LABEL "invalid desc for send: %d\n", desc);)
35496 - atomic_inc(&vcc->stats->tx);
35497 + atomic_inc_unchecked(&vcc->stats->tx);
35498 if (vcc->pop)
35499 vcc->pop(vcc, skb);
35500 else
35501 @@ -3044,14 +3044,14 @@ static int ia_pkt_tx (struct atm_vcc *vcc, struct sk_buff *skb) {
35502 ATM_DESC(skb) = vcc->vci;
35503 skb_queue_tail(&iadev->tx_dma_q, skb);
35504
35505 - atomic_inc(&vcc->stats->tx);
35506 + atomic_inc_unchecked(&vcc->stats->tx);
35507 iadev->tx_pkt_cnt++;
35508 /* Increment transaction counter */
35509 writel(2, iadev->dma+IPHASE5575_TX_COUNTER);
35510
35511 #if 0
35512 /* add flow control logic */
35513 - if (atomic_read(&vcc->stats->tx) % 20 == 0) {
35514 + if (atomic_read_unchecked(&vcc->stats->tx) % 20 == 0) {
35515 if (iavcc->vc_desc_cnt > 10) {
35516 vcc->tx_quota = vcc->tx_quota * 3 / 4;
35517 printk("Tx1: vcc->tx_quota = %d \n", (u32)vcc->tx_quota );
35518 diff --git a/drivers/atm/lanai.c b/drivers/atm/lanai.c
35519 index fa7d701..1e404c7 100644
35520 --- a/drivers/atm/lanai.c
35521 +++ b/drivers/atm/lanai.c
35522 @@ -1303,7 +1303,7 @@ static void lanai_send_one_aal5(struct lanai_dev *lanai,
35523 vcc_tx_add_aal5_trailer(lvcc, skb->len, 0, 0);
35524 lanai_endtx(lanai, lvcc);
35525 lanai_free_skb(lvcc->tx.atmvcc, skb);
35526 - atomic_inc(&lvcc->tx.atmvcc->stats->tx);
35527 + atomic_inc_unchecked(&lvcc->tx.atmvcc->stats->tx);
35528 }
35529
35530 /* Try to fill the buffer - don't call unless there is backlog */
35531 @@ -1426,7 +1426,7 @@ static void vcc_rx_aal5(struct lanai_vcc *lvcc, int endptr)
35532 ATM_SKB(skb)->vcc = lvcc->rx.atmvcc;
35533 __net_timestamp(skb);
35534 lvcc->rx.atmvcc->push(lvcc->rx.atmvcc, skb);
35535 - atomic_inc(&lvcc->rx.atmvcc->stats->rx);
35536 + atomic_inc_unchecked(&lvcc->rx.atmvcc->stats->rx);
35537 out:
35538 lvcc->rx.buf.ptr = end;
35539 cardvcc_write(lvcc, endptr, vcc_rxreadptr);
35540 @@ -1667,7 +1667,7 @@ static int handle_service(struct lanai_dev *lanai, u32 s)
35541 DPRINTK("(itf %d) got RX service entry 0x%X for non-AAL5 "
35542 "vcc %d\n", lanai->number, (unsigned int) s, vci);
35543 lanai->stats.service_rxnotaal5++;
35544 - atomic_inc(&lvcc->rx.atmvcc->stats->rx_err);
35545 + atomic_inc_unchecked(&lvcc->rx.atmvcc->stats->rx_err);
35546 return 0;
35547 }
35548 if (likely(!(s & (SERVICE_TRASH | SERVICE_STREAM | SERVICE_CRCERR)))) {
35549 @@ -1679,7 +1679,7 @@ static int handle_service(struct lanai_dev *lanai, u32 s)
35550 int bytes;
35551 read_unlock(&vcc_sklist_lock);
35552 DPRINTK("got trashed rx pdu on vci %d\n", vci);
35553 - atomic_inc(&lvcc->rx.atmvcc->stats->rx_err);
35554 + atomic_inc_unchecked(&lvcc->rx.atmvcc->stats->rx_err);
35555 lvcc->stats.x.aal5.service_trash++;
35556 bytes = (SERVICE_GET_END(s) * 16) -
35557 (((unsigned long) lvcc->rx.buf.ptr) -
35558 @@ -1691,7 +1691,7 @@ static int handle_service(struct lanai_dev *lanai, u32 s)
35559 }
35560 if (s & SERVICE_STREAM) {
35561 read_unlock(&vcc_sklist_lock);
35562 - atomic_inc(&lvcc->rx.atmvcc->stats->rx_err);
35563 + atomic_inc_unchecked(&lvcc->rx.atmvcc->stats->rx_err);
35564 lvcc->stats.x.aal5.service_stream++;
35565 printk(KERN_ERR DEV_LABEL "(itf %d): Got AAL5 stream "
35566 "PDU on VCI %d!\n", lanai->number, vci);
35567 @@ -1699,7 +1699,7 @@ static int handle_service(struct lanai_dev *lanai, u32 s)
35568 return 0;
35569 }
35570 DPRINTK("got rx crc error on vci %d\n", vci);
35571 - atomic_inc(&lvcc->rx.atmvcc->stats->rx_err);
35572 + atomic_inc_unchecked(&lvcc->rx.atmvcc->stats->rx_err);
35573 lvcc->stats.x.aal5.service_rxcrc++;
35574 lvcc->rx.buf.ptr = &lvcc->rx.buf.start[SERVICE_GET_END(s) * 4];
35575 cardvcc_write(lvcc, SERVICE_GET_END(s), vcc_rxreadptr);
35576 diff --git a/drivers/atm/nicstar.c b/drivers/atm/nicstar.c
35577 index 5aca5f4..ce3a6b0 100644
35578 --- a/drivers/atm/nicstar.c
35579 +++ b/drivers/atm/nicstar.c
35580 @@ -1640,7 +1640,7 @@ static int ns_send(struct atm_vcc *vcc, struct sk_buff *skb)
35581 if ((vc = (vc_map *) vcc->dev_data) == NULL) {
35582 printk("nicstar%d: vcc->dev_data == NULL on ns_send().\n",
35583 card->index);
35584 - atomic_inc(&vcc->stats->tx_err);
35585 + atomic_inc_unchecked(&vcc->stats->tx_err);
35586 dev_kfree_skb_any(skb);
35587 return -EINVAL;
35588 }
35589 @@ -1648,7 +1648,7 @@ static int ns_send(struct atm_vcc *vcc, struct sk_buff *skb)
35590 if (!vc->tx) {
35591 printk("nicstar%d: Trying to transmit on a non-tx VC.\n",
35592 card->index);
35593 - atomic_inc(&vcc->stats->tx_err);
35594 + atomic_inc_unchecked(&vcc->stats->tx_err);
35595 dev_kfree_skb_any(skb);
35596 return -EINVAL;
35597 }
35598 @@ -1656,14 +1656,14 @@ static int ns_send(struct atm_vcc *vcc, struct sk_buff *skb)
35599 if (vcc->qos.aal != ATM_AAL5 && vcc->qos.aal != ATM_AAL0) {
35600 printk("nicstar%d: Only AAL0 and AAL5 are supported.\n",
35601 card->index);
35602 - atomic_inc(&vcc->stats->tx_err);
35603 + atomic_inc_unchecked(&vcc->stats->tx_err);
35604 dev_kfree_skb_any(skb);
35605 return -EINVAL;
35606 }
35607
35608 if (skb_shinfo(skb)->nr_frags != 0) {
35609 printk("nicstar%d: No scatter-gather yet.\n", card->index);
35610 - atomic_inc(&vcc->stats->tx_err);
35611 + atomic_inc_unchecked(&vcc->stats->tx_err);
35612 dev_kfree_skb_any(skb);
35613 return -EINVAL;
35614 }
35615 @@ -1711,11 +1711,11 @@ static int ns_send(struct atm_vcc *vcc, struct sk_buff *skb)
35616 }
35617
35618 if (push_scqe(card, vc, scq, &scqe, skb) != 0) {
35619 - atomic_inc(&vcc->stats->tx_err);
35620 + atomic_inc_unchecked(&vcc->stats->tx_err);
35621 dev_kfree_skb_any(skb);
35622 return -EIO;
35623 }
35624 - atomic_inc(&vcc->stats->tx);
35625 + atomic_inc_unchecked(&vcc->stats->tx);
35626
35627 return 0;
35628 }
35629 @@ -2032,14 +2032,14 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
35630 printk
35631 ("nicstar%d: Can't allocate buffers for aal0.\n",
35632 card->index);
35633 - atomic_add(i, &vcc->stats->rx_drop);
35634 + atomic_add_unchecked(i, &vcc->stats->rx_drop);
35635 break;
35636 }
35637 if (!atm_charge(vcc, sb->truesize)) {
35638 RXPRINTK
35639 ("nicstar%d: atm_charge() dropped aal0 packets.\n",
35640 card->index);
35641 - atomic_add(i - 1, &vcc->stats->rx_drop); /* already increased by 1 */
35642 + atomic_add_unchecked(i - 1, &vcc->stats->rx_drop); /* already increased by 1 */
35643 dev_kfree_skb_any(sb);
35644 break;
35645 }
35646 @@ -2054,7 +2054,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
35647 ATM_SKB(sb)->vcc = vcc;
35648 __net_timestamp(sb);
35649 vcc->push(vcc, sb);
35650 - atomic_inc(&vcc->stats->rx);
35651 + atomic_inc_unchecked(&vcc->stats->rx);
35652 cell += ATM_CELL_PAYLOAD;
35653 }
35654
35655 @@ -2071,7 +2071,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
35656 if (iovb == NULL) {
35657 printk("nicstar%d: Out of iovec buffers.\n",
35658 card->index);
35659 - atomic_inc(&vcc->stats->rx_drop);
35660 + atomic_inc_unchecked(&vcc->stats->rx_drop);
35661 recycle_rx_buf(card, skb);
35662 return;
35663 }
35664 @@ -2095,7 +2095,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
35665 small or large buffer itself. */
35666 } else if (NS_PRV_IOVCNT(iovb) >= NS_MAX_IOVECS) {
35667 printk("nicstar%d: received too big AAL5 SDU.\n", card->index);
35668 - atomic_inc(&vcc->stats->rx_err);
35669 + atomic_inc_unchecked(&vcc->stats->rx_err);
35670 recycle_iovec_rx_bufs(card, (struct iovec *)iovb->data,
35671 NS_MAX_IOVECS);
35672 NS_PRV_IOVCNT(iovb) = 0;
35673 @@ -2115,7 +2115,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
35674 ("nicstar%d: Expected a small buffer, and this is not one.\n",
35675 card->index);
35676 which_list(card, skb);
35677 - atomic_inc(&vcc->stats->rx_err);
35678 + atomic_inc_unchecked(&vcc->stats->rx_err);
35679 recycle_rx_buf(card, skb);
35680 vc->rx_iov = NULL;
35681 recycle_iov_buf(card, iovb);
35682 @@ -2128,7 +2128,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
35683 ("nicstar%d: Expected a large buffer, and this is not one.\n",
35684 card->index);
35685 which_list(card, skb);
35686 - atomic_inc(&vcc->stats->rx_err);
35687 + atomic_inc_unchecked(&vcc->stats->rx_err);
35688 recycle_iovec_rx_bufs(card, (struct iovec *)iovb->data,
35689 NS_PRV_IOVCNT(iovb));
35690 vc->rx_iov = NULL;
35691 @@ -2151,7 +2151,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
35692 printk(" - PDU size mismatch.\n");
35693 else
35694 printk(".\n");
35695 - atomic_inc(&vcc->stats->rx_err);
35696 + atomic_inc_unchecked(&vcc->stats->rx_err);
35697 recycle_iovec_rx_bufs(card, (struct iovec *)iovb->data,
35698 NS_PRV_IOVCNT(iovb));
35699 vc->rx_iov = NULL;
35700 @@ -2165,7 +2165,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
35701 /* skb points to a small buffer */
35702 if (!atm_charge(vcc, skb->truesize)) {
35703 push_rxbufs(card, skb);
35704 - atomic_inc(&vcc->stats->rx_drop);
35705 + atomic_inc_unchecked(&vcc->stats->rx_drop);
35706 } else {
35707 skb_put(skb, len);
35708 dequeue_sm_buf(card, skb);
35709 @@ -2175,7 +2175,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
35710 ATM_SKB(skb)->vcc = vcc;
35711 __net_timestamp(skb);
35712 vcc->push(vcc, skb);
35713 - atomic_inc(&vcc->stats->rx);
35714 + atomic_inc_unchecked(&vcc->stats->rx);
35715 }
35716 } else if (NS_PRV_IOVCNT(iovb) == 2) { /* One small plus one large buffer */
35717 struct sk_buff *sb;
35718 @@ -2186,7 +2186,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
35719 if (len <= NS_SMBUFSIZE) {
35720 if (!atm_charge(vcc, sb->truesize)) {
35721 push_rxbufs(card, sb);
35722 - atomic_inc(&vcc->stats->rx_drop);
35723 + atomic_inc_unchecked(&vcc->stats->rx_drop);
35724 } else {
35725 skb_put(sb, len);
35726 dequeue_sm_buf(card, sb);
35727 @@ -2196,7 +2196,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
35728 ATM_SKB(sb)->vcc = vcc;
35729 __net_timestamp(sb);
35730 vcc->push(vcc, sb);
35731 - atomic_inc(&vcc->stats->rx);
35732 + atomic_inc_unchecked(&vcc->stats->rx);
35733 }
35734
35735 push_rxbufs(card, skb);
35736 @@ -2205,7 +2205,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
35737
35738 if (!atm_charge(vcc, skb->truesize)) {
35739 push_rxbufs(card, skb);
35740 - atomic_inc(&vcc->stats->rx_drop);
35741 + atomic_inc_unchecked(&vcc->stats->rx_drop);
35742 } else {
35743 dequeue_lg_buf(card, skb);
35744 #ifdef NS_USE_DESTRUCTORS
35745 @@ -2218,7 +2218,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
35746 ATM_SKB(skb)->vcc = vcc;
35747 __net_timestamp(skb);
35748 vcc->push(vcc, skb);
35749 - atomic_inc(&vcc->stats->rx);
35750 + atomic_inc_unchecked(&vcc->stats->rx);
35751 }
35752
35753 push_rxbufs(card, sb);
35754 @@ -2239,7 +2239,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
35755 printk
35756 ("nicstar%d: Out of huge buffers.\n",
35757 card->index);
35758 - atomic_inc(&vcc->stats->rx_drop);
35759 + atomic_inc_unchecked(&vcc->stats->rx_drop);
35760 recycle_iovec_rx_bufs(card,
35761 (struct iovec *)
35762 iovb->data,
35763 @@ -2290,7 +2290,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
35764 card->hbpool.count++;
35765 } else
35766 dev_kfree_skb_any(hb);
35767 - atomic_inc(&vcc->stats->rx_drop);
35768 + atomic_inc_unchecked(&vcc->stats->rx_drop);
35769 } else {
35770 /* Copy the small buffer to the huge buffer */
35771 sb = (struct sk_buff *)iov->iov_base;
35772 @@ -2327,7 +2327,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
35773 #endif /* NS_USE_DESTRUCTORS */
35774 __net_timestamp(hb);
35775 vcc->push(vcc, hb);
35776 - atomic_inc(&vcc->stats->rx);
35777 + atomic_inc_unchecked(&vcc->stats->rx);
35778 }
35779 }
35780
35781 diff --git a/drivers/atm/solos-pci.c b/drivers/atm/solos-pci.c
35782 index 32784d1..4a8434a 100644
35783 --- a/drivers/atm/solos-pci.c
35784 +++ b/drivers/atm/solos-pci.c
35785 @@ -838,7 +838,7 @@ void solos_bh(unsigned long card_arg)
35786 }
35787 atm_charge(vcc, skb->truesize);
35788 vcc->push(vcc, skb);
35789 - atomic_inc(&vcc->stats->rx);
35790 + atomic_inc_unchecked(&vcc->stats->rx);
35791 break;
35792
35793 case PKT_STATUS:
35794 @@ -1116,7 +1116,7 @@ static uint32_t fpga_tx(struct solos_card *card)
35795 vcc = SKB_CB(oldskb)->vcc;
35796
35797 if (vcc) {
35798 - atomic_inc(&vcc->stats->tx);
35799 + atomic_inc_unchecked(&vcc->stats->tx);
35800 solos_pop(vcc, oldskb);
35801 } else {
35802 dev_kfree_skb_irq(oldskb);
35803 diff --git a/drivers/atm/suni.c b/drivers/atm/suni.c
35804 index 0215934..ce9f5b1 100644
35805 --- a/drivers/atm/suni.c
35806 +++ b/drivers/atm/suni.c
35807 @@ -49,8 +49,8 @@ static DEFINE_SPINLOCK(sunis_lock);
35808
35809
35810 #define ADD_LIMITED(s,v) \
35811 - atomic_add((v),&stats->s); \
35812 - if (atomic_read(&stats->s) < 0) atomic_set(&stats->s,INT_MAX);
35813 + atomic_add_unchecked((v),&stats->s); \
35814 + if (atomic_read_unchecked(&stats->s) < 0) atomic_set_unchecked(&stats->s,INT_MAX);
35815
35816
35817 static void suni_hz(unsigned long from_timer)
35818 diff --git a/drivers/atm/uPD98402.c b/drivers/atm/uPD98402.c
35819 index 5120a96..e2572bd 100644
35820 --- a/drivers/atm/uPD98402.c
35821 +++ b/drivers/atm/uPD98402.c
35822 @@ -42,7 +42,7 @@ static int fetch_stats(struct atm_dev *dev,struct sonet_stats __user *arg,int ze
35823 struct sonet_stats tmp;
35824 int error = 0;
35825
35826 - atomic_add(GET(HECCT),&PRIV(dev)->sonet_stats.uncorr_hcs);
35827 + atomic_add_unchecked(GET(HECCT),&PRIV(dev)->sonet_stats.uncorr_hcs);
35828 sonet_copy_stats(&PRIV(dev)->sonet_stats,&tmp);
35829 if (arg) error = copy_to_user(arg,&tmp,sizeof(tmp));
35830 if (zero && !error) {
35831 @@ -161,9 +161,9 @@ static int uPD98402_ioctl(struct atm_dev *dev,unsigned int cmd,void __user *arg)
35832
35833
35834 #define ADD_LIMITED(s,v) \
35835 - { atomic_add(GET(v),&PRIV(dev)->sonet_stats.s); \
35836 - if (atomic_read(&PRIV(dev)->sonet_stats.s) < 0) \
35837 - atomic_set(&PRIV(dev)->sonet_stats.s,INT_MAX); }
35838 + { atomic_add_unchecked(GET(v),&PRIV(dev)->sonet_stats.s); \
35839 + if (atomic_read_unchecked(&PRIV(dev)->sonet_stats.s) < 0) \
35840 + atomic_set_unchecked(&PRIV(dev)->sonet_stats.s,INT_MAX); }
35841
35842
35843 static void stat_event(struct atm_dev *dev)
35844 @@ -194,7 +194,7 @@ static void uPD98402_int(struct atm_dev *dev)
35845 if (reason & uPD98402_INT_PFM) stat_event(dev);
35846 if (reason & uPD98402_INT_PCO) {
35847 (void) GET(PCOCR); /* clear interrupt cause */
35848 - atomic_add(GET(HECCT),
35849 + atomic_add_unchecked(GET(HECCT),
35850 &PRIV(dev)->sonet_stats.uncorr_hcs);
35851 }
35852 if ((reason & uPD98402_INT_RFO) &&
35853 @@ -222,9 +222,9 @@ static int uPD98402_start(struct atm_dev *dev)
35854 PUT(~(uPD98402_INT_PFM | uPD98402_INT_ALM | uPD98402_INT_RFO |
35855 uPD98402_INT_LOS),PIMR); /* enable them */
35856 (void) fetch_stats(dev,NULL,1); /* clear kernel counters */
35857 - atomic_set(&PRIV(dev)->sonet_stats.corr_hcs,-1);
35858 - atomic_set(&PRIV(dev)->sonet_stats.tx_cells,-1);
35859 - atomic_set(&PRIV(dev)->sonet_stats.rx_cells,-1);
35860 + atomic_set_unchecked(&PRIV(dev)->sonet_stats.corr_hcs,-1);
35861 + atomic_set_unchecked(&PRIV(dev)->sonet_stats.tx_cells,-1);
35862 + atomic_set_unchecked(&PRIV(dev)->sonet_stats.rx_cells,-1);
35863 return 0;
35864 }
35865
35866 diff --git a/drivers/atm/zatm.c b/drivers/atm/zatm.c
35867 index 969c3c2..9b72956 100644
35868 --- a/drivers/atm/zatm.c
35869 +++ b/drivers/atm/zatm.c
35870 @@ -459,7 +459,7 @@ printk("dummy: 0x%08lx, 0x%08lx\n",dummy[0],dummy[1]);
35871 }
35872 if (!size) {
35873 dev_kfree_skb_irq(skb);
35874 - if (vcc) atomic_inc(&vcc->stats->rx_err);
35875 + if (vcc) atomic_inc_unchecked(&vcc->stats->rx_err);
35876 continue;
35877 }
35878 if (!atm_charge(vcc,skb->truesize)) {
35879 @@ -469,7 +469,7 @@ printk("dummy: 0x%08lx, 0x%08lx\n",dummy[0],dummy[1]);
35880 skb->len = size;
35881 ATM_SKB(skb)->vcc = vcc;
35882 vcc->push(vcc,skb);
35883 - atomic_inc(&vcc->stats->rx);
35884 + atomic_inc_unchecked(&vcc->stats->rx);
35885 }
35886 zout(pos & 0xffff,MTA(mbx));
35887 #if 0 /* probably a stupid idea */
35888 @@ -733,7 +733,7 @@ if (*ZATM_PRV_DSC(skb) != (uPD98401_TXPD_V | uPD98401_TXPD_DP |
35889 skb_queue_head(&zatm_vcc->backlog,skb);
35890 break;
35891 }
35892 - atomic_inc(&vcc->stats->tx);
35893 + atomic_inc_unchecked(&vcc->stats->tx);
35894 wake_up(&zatm_vcc->tx_wait);
35895 }
35896
35897 diff --git a/drivers/base/bus.c b/drivers/base/bus.c
35898 index 4c289ab..de1c333 100644
35899 --- a/drivers/base/bus.c
35900 +++ b/drivers/base/bus.c
35901 @@ -1193,7 +1193,7 @@ int subsys_interface_register(struct subsys_interface *sif)
35902 return -EINVAL;
35903
35904 mutex_lock(&subsys->p->mutex);
35905 - list_add_tail(&sif->node, &subsys->p->interfaces);
35906 + pax_list_add_tail((struct list_head *)&sif->node, &subsys->p->interfaces);
35907 if (sif->add_dev) {
35908 subsys_dev_iter_init(&iter, subsys, NULL, NULL);
35909 while ((dev = subsys_dev_iter_next(&iter)))
35910 @@ -1218,7 +1218,7 @@ void subsys_interface_unregister(struct subsys_interface *sif)
35911 subsys = sif->subsys;
35912
35913 mutex_lock(&subsys->p->mutex);
35914 - list_del_init(&sif->node);
35915 + pax_list_del_init((struct list_head *)&sif->node);
35916 if (sif->remove_dev) {
35917 subsys_dev_iter_init(&iter, subsys, NULL, NULL);
35918 while ((dev = subsys_dev_iter_next(&iter)))
35919 diff --git a/drivers/base/devtmpfs.c b/drivers/base/devtmpfs.c
35920 index 7413d06..79155fa 100644
35921 --- a/drivers/base/devtmpfs.c
35922 +++ b/drivers/base/devtmpfs.c
35923 @@ -354,7 +354,7 @@ int devtmpfs_mount(const char *mntdir)
35924 if (!thread)
35925 return 0;
35926
35927 - err = sys_mount("devtmpfs", (char *)mntdir, "devtmpfs", MS_SILENT, NULL);
35928 + err = sys_mount((char __force_user *)"devtmpfs", (char __force_user *)mntdir, (char __force_user *)"devtmpfs", MS_SILENT, NULL);
35929 if (err)
35930 printk(KERN_INFO "devtmpfs: error mounting %i\n", err);
35931 else
35932 @@ -380,11 +380,11 @@ static int devtmpfsd(void *p)
35933 *err = sys_unshare(CLONE_NEWNS);
35934 if (*err)
35935 goto out;
35936 - *err = sys_mount("devtmpfs", "/", "devtmpfs", MS_SILENT, options);
35937 + *err = sys_mount((char __force_user *)"devtmpfs", (char __force_user *)"/", (char __force_user *)"devtmpfs", MS_SILENT, (char __force_user *)options);
35938 if (*err)
35939 goto out;
35940 - sys_chdir("/.."); /* will traverse into overmounted root */
35941 - sys_chroot(".");
35942 + sys_chdir((char __force_user *)"/.."); /* will traverse into overmounted root */
35943 + sys_chroot((char __force_user *)".");
35944 complete(&setup_done);
35945 while (1) {
35946 spin_lock(&req_lock);
35947 diff --git a/drivers/base/node.c b/drivers/base/node.c
35948 index bc9f43b..29703b8 100644
35949 --- a/drivers/base/node.c
35950 +++ b/drivers/base/node.c
35951 @@ -620,7 +620,7 @@ static ssize_t print_nodes_state(enum node_states state, char *buf)
35952 struct node_attr {
35953 struct device_attribute attr;
35954 enum node_states state;
35955 -};
35956 +} __do_const;
35957
35958 static ssize_t show_node_state(struct device *dev,
35959 struct device_attribute *attr, char *buf)
35960 diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c
35961 index bfb8955..42c9b9a 100644
35962 --- a/drivers/base/power/domain.c
35963 +++ b/drivers/base/power/domain.c
35964 @@ -1850,7 +1850,7 @@ int pm_genpd_attach_cpuidle(struct generic_pm_domain *genpd, int state)
35965 {
35966 struct cpuidle_driver *cpuidle_drv;
35967 struct gpd_cpu_data *cpu_data;
35968 - struct cpuidle_state *idle_state;
35969 + cpuidle_state_no_const *idle_state;
35970 int ret = 0;
35971
35972 if (IS_ERR_OR_NULL(genpd) || state < 0)
35973 @@ -1918,7 +1918,7 @@ int pm_genpd_name_attach_cpuidle(const char *name, int state)
35974 int pm_genpd_detach_cpuidle(struct generic_pm_domain *genpd)
35975 {
35976 struct gpd_cpu_data *cpu_data;
35977 - struct cpuidle_state *idle_state;
35978 + cpuidle_state_no_const *idle_state;
35979 int ret = 0;
35980
35981 if (IS_ERR_OR_NULL(genpd))
35982 diff --git a/drivers/base/power/sysfs.c b/drivers/base/power/sysfs.c
35983 index 03e089a..0e9560c 100644
35984 --- a/drivers/base/power/sysfs.c
35985 +++ b/drivers/base/power/sysfs.c
35986 @@ -185,7 +185,7 @@ static ssize_t rtpm_status_show(struct device *dev,
35987 return -EIO;
35988 }
35989 }
35990 - return sprintf(buf, p);
35991 + return sprintf(buf, "%s", p);
35992 }
35993
35994 static DEVICE_ATTR(runtime_status, 0444, rtpm_status_show, NULL);
35995 diff --git a/drivers/base/power/wakeup.c b/drivers/base/power/wakeup.c
35996 index 2d56f41..8830f19 100644
35997 --- a/drivers/base/power/wakeup.c
35998 +++ b/drivers/base/power/wakeup.c
35999 @@ -29,14 +29,14 @@ bool events_check_enabled __read_mostly;
36000 * They need to be modified together atomically, so it's better to use one
36001 * atomic variable to hold them both.
36002 */
36003 -static atomic_t combined_event_count = ATOMIC_INIT(0);
36004 +static atomic_unchecked_t combined_event_count = ATOMIC_INIT(0);
36005
36006 #define IN_PROGRESS_BITS (sizeof(int) * 4)
36007 #define MAX_IN_PROGRESS ((1 << IN_PROGRESS_BITS) - 1)
36008
36009 static void split_counters(unsigned int *cnt, unsigned int *inpr)
36010 {
36011 - unsigned int comb = atomic_read(&combined_event_count);
36012 + unsigned int comb = atomic_read_unchecked(&combined_event_count);
36013
36014 *cnt = (comb >> IN_PROGRESS_BITS);
36015 *inpr = comb & MAX_IN_PROGRESS;
36016 @@ -395,7 +395,7 @@ static void wakeup_source_activate(struct wakeup_source *ws)
36017 ws->start_prevent_time = ws->last_time;
36018
36019 /* Increment the counter of events in progress. */
36020 - cec = atomic_inc_return(&combined_event_count);
36021 + cec = atomic_inc_return_unchecked(&combined_event_count);
36022
36023 trace_wakeup_source_activate(ws->name, cec);
36024 }
36025 @@ -521,7 +521,7 @@ static void wakeup_source_deactivate(struct wakeup_source *ws)
36026 * Increment the counter of registered wakeup events and decrement the
36027 * couter of wakeup events in progress simultaneously.
36028 */
36029 - cec = atomic_add_return(MAX_IN_PROGRESS, &combined_event_count);
36030 + cec = atomic_add_return_unchecked(MAX_IN_PROGRESS, &combined_event_count);
36031 trace_wakeup_source_deactivate(ws->name, cec);
36032
36033 split_counters(&cnt, &inpr);
36034 diff --git a/drivers/base/syscore.c b/drivers/base/syscore.c
36035 index e8d11b6..7b1b36f 100644
36036 --- a/drivers/base/syscore.c
36037 +++ b/drivers/base/syscore.c
36038 @@ -21,7 +21,7 @@ static DEFINE_MUTEX(syscore_ops_lock);
36039 void register_syscore_ops(struct syscore_ops *ops)
36040 {
36041 mutex_lock(&syscore_ops_lock);
36042 - list_add_tail(&ops->node, &syscore_ops_list);
36043 + pax_list_add_tail((struct list_head *)&ops->node, &syscore_ops_list);
36044 mutex_unlock(&syscore_ops_lock);
36045 }
36046 EXPORT_SYMBOL_GPL(register_syscore_ops);
36047 @@ -33,7 +33,7 @@ EXPORT_SYMBOL_GPL(register_syscore_ops);
36048 void unregister_syscore_ops(struct syscore_ops *ops)
36049 {
36050 mutex_lock(&syscore_ops_lock);
36051 - list_del(&ops->node);
36052 + pax_list_del((struct list_head *)&ops->node);
36053 mutex_unlock(&syscore_ops_lock);
36054 }
36055 EXPORT_SYMBOL_GPL(unregister_syscore_ops);
36056 diff --git a/drivers/block/cciss.c b/drivers/block/cciss.c
36057 index edfa251..1734d4d 100644
36058 --- a/drivers/block/cciss.c
36059 +++ b/drivers/block/cciss.c
36060 @@ -3011,7 +3011,7 @@ static void start_io(ctlr_info_t *h)
36061 while (!list_empty(&h->reqQ)) {
36062 c = list_entry(h->reqQ.next, CommandList_struct, list);
36063 /* can't do anything if fifo is full */
36064 - if ((h->access.fifo_full(h))) {
36065 + if ((h->access->fifo_full(h))) {
36066 dev_warn(&h->pdev->dev, "fifo full\n");
36067 break;
36068 }
36069 @@ -3021,7 +3021,7 @@ static void start_io(ctlr_info_t *h)
36070 h->Qdepth--;
36071
36072 /* Tell the controller execute command */
36073 - h->access.submit_command(h, c);
36074 + h->access->submit_command(h, c);
36075
36076 /* Put job onto the completed Q */
36077 addQ(&h->cmpQ, c);
36078 @@ -3447,17 +3447,17 @@ startio:
36079
36080 static inline unsigned long get_next_completion(ctlr_info_t *h)
36081 {
36082 - return h->access.command_completed(h);
36083 + return h->access->command_completed(h);
36084 }
36085
36086 static inline int interrupt_pending(ctlr_info_t *h)
36087 {
36088 - return h->access.intr_pending(h);
36089 + return h->access->intr_pending(h);
36090 }
36091
36092 static inline long interrupt_not_for_us(ctlr_info_t *h)
36093 {
36094 - return ((h->access.intr_pending(h) == 0) ||
36095 + return ((h->access->intr_pending(h) == 0) ||
36096 (h->interrupts_enabled == 0));
36097 }
36098
36099 @@ -3490,7 +3490,7 @@ static inline u32 next_command(ctlr_info_t *h)
36100 u32 a;
36101
36102 if (unlikely(!(h->transMethod & CFGTBL_Trans_Performant)))
36103 - return h->access.command_completed(h);
36104 + return h->access->command_completed(h);
36105
36106 if ((*(h->reply_pool_head) & 1) == (h->reply_pool_wraparound)) {
36107 a = *(h->reply_pool_head); /* Next cmd in ring buffer */
36108 @@ -4047,7 +4047,7 @@ static void cciss_put_controller_into_performant_mode(ctlr_info_t *h)
36109 trans_support & CFGTBL_Trans_use_short_tags);
36110
36111 /* Change the access methods to the performant access methods */
36112 - h->access = SA5_performant_access;
36113 + h->access = &SA5_performant_access;
36114 h->transMethod = CFGTBL_Trans_Performant;
36115
36116 return;
36117 @@ -4327,7 +4327,7 @@ static int cciss_pci_init(ctlr_info_t *h)
36118 if (prod_index < 0)
36119 return -ENODEV;
36120 h->product_name = products[prod_index].product_name;
36121 - h->access = *(products[prod_index].access);
36122 + h->access = products[prod_index].access;
36123
36124 if (cciss_board_disabled(h)) {
36125 dev_warn(&h->pdev->dev, "controller appears to be disabled\n");
36126 @@ -5059,7 +5059,7 @@ reinit_after_soft_reset:
36127 }
36128
36129 /* make sure the board interrupts are off */
36130 - h->access.set_intr_mask(h, CCISS_INTR_OFF);
36131 + h->access->set_intr_mask(h, CCISS_INTR_OFF);
36132 rc = cciss_request_irq(h, do_cciss_msix_intr, do_cciss_intx);
36133 if (rc)
36134 goto clean2;
36135 @@ -5109,7 +5109,7 @@ reinit_after_soft_reset:
36136 * fake ones to scoop up any residual completions.
36137 */
36138 spin_lock_irqsave(&h->lock, flags);
36139 - h->access.set_intr_mask(h, CCISS_INTR_OFF);
36140 + h->access->set_intr_mask(h, CCISS_INTR_OFF);
36141 spin_unlock_irqrestore(&h->lock, flags);
36142 free_irq(h->intr[h->intr_mode], h);
36143 rc = cciss_request_irq(h, cciss_msix_discard_completions,
36144 @@ -5129,9 +5129,9 @@ reinit_after_soft_reset:
36145 dev_info(&h->pdev->dev, "Board READY.\n");
36146 dev_info(&h->pdev->dev,
36147 "Waiting for stale completions to drain.\n");
36148 - h->access.set_intr_mask(h, CCISS_INTR_ON);
36149 + h->access->set_intr_mask(h, CCISS_INTR_ON);
36150 msleep(10000);
36151 - h->access.set_intr_mask(h, CCISS_INTR_OFF);
36152 + h->access->set_intr_mask(h, CCISS_INTR_OFF);
36153
36154 rc = controller_reset_failed(h->cfgtable);
36155 if (rc)
36156 @@ -5154,7 +5154,7 @@ reinit_after_soft_reset:
36157 cciss_scsi_setup(h);
36158
36159 /* Turn the interrupts on so we can service requests */
36160 - h->access.set_intr_mask(h, CCISS_INTR_ON);
36161 + h->access->set_intr_mask(h, CCISS_INTR_ON);
36162
36163 /* Get the firmware version */
36164 inq_buff = kzalloc(sizeof(InquiryData_struct), GFP_KERNEL);
36165 @@ -5226,7 +5226,7 @@ static void cciss_shutdown(struct pci_dev *pdev)
36166 kfree(flush_buf);
36167 if (return_code != IO_OK)
36168 dev_warn(&h->pdev->dev, "Error flushing cache\n");
36169 - h->access.set_intr_mask(h, CCISS_INTR_OFF);
36170 + h->access->set_intr_mask(h, CCISS_INTR_OFF);
36171 free_irq(h->intr[h->intr_mode], h);
36172 }
36173
36174 diff --git a/drivers/block/cciss.h b/drivers/block/cciss.h
36175 index 7fda30e..eb5dfe0 100644
36176 --- a/drivers/block/cciss.h
36177 +++ b/drivers/block/cciss.h
36178 @@ -101,7 +101,7 @@ struct ctlr_info
36179 /* information about each logical volume */
36180 drive_info_struct *drv[CISS_MAX_LUN];
36181
36182 - struct access_method access;
36183 + struct access_method *access;
36184
36185 /* queue and queue Info */
36186 struct list_head reqQ;
36187 diff --git a/drivers/block/cpqarray.c b/drivers/block/cpqarray.c
36188 index 2b94403..fd6ad1f 100644
36189 --- a/drivers/block/cpqarray.c
36190 +++ b/drivers/block/cpqarray.c
36191 @@ -404,7 +404,7 @@ static int cpqarray_register_ctlr(int i, struct pci_dev *pdev)
36192 if (register_blkdev(COMPAQ_SMART2_MAJOR+i, hba[i]->devname)) {
36193 goto Enomem4;
36194 }
36195 - hba[i]->access.set_intr_mask(hba[i], 0);
36196 + hba[i]->access->set_intr_mask(hba[i], 0);
36197 if (request_irq(hba[i]->intr, do_ida_intr,
36198 IRQF_DISABLED|IRQF_SHARED, hba[i]->devname, hba[i]))
36199 {
36200 @@ -459,7 +459,7 @@ static int cpqarray_register_ctlr(int i, struct pci_dev *pdev)
36201 add_timer(&hba[i]->timer);
36202
36203 /* Enable IRQ now that spinlock and rate limit timer are set up */
36204 - hba[i]->access.set_intr_mask(hba[i], FIFO_NOT_EMPTY);
36205 + hba[i]->access->set_intr_mask(hba[i], FIFO_NOT_EMPTY);
36206
36207 for(j=0; j<NWD; j++) {
36208 struct gendisk *disk = ida_gendisk[i][j];
36209 @@ -694,7 +694,7 @@ DBGINFO(
36210 for(i=0; i<NR_PRODUCTS; i++) {
36211 if (board_id == products[i].board_id) {
36212 c->product_name = products[i].product_name;
36213 - c->access = *(products[i].access);
36214 + c->access = products[i].access;
36215 break;
36216 }
36217 }
36218 @@ -792,7 +792,7 @@ static int cpqarray_eisa_detect(void)
36219 hba[ctlr]->intr = intr;
36220 sprintf(hba[ctlr]->devname, "ida%d", nr_ctlr);
36221 hba[ctlr]->product_name = products[j].product_name;
36222 - hba[ctlr]->access = *(products[j].access);
36223 + hba[ctlr]->access = products[j].access;
36224 hba[ctlr]->ctlr = ctlr;
36225 hba[ctlr]->board_id = board_id;
36226 hba[ctlr]->pci_dev = NULL; /* not PCI */
36227 @@ -978,7 +978,7 @@ static void start_io(ctlr_info_t *h)
36228
36229 while((c = h->reqQ) != NULL) {
36230 /* Can't do anything if we're busy */
36231 - if (h->access.fifo_full(h) == 0)
36232 + if (h->access->fifo_full(h) == 0)
36233 return;
36234
36235 /* Get the first entry from the request Q */
36236 @@ -986,7 +986,7 @@ static void start_io(ctlr_info_t *h)
36237 h->Qdepth--;
36238
36239 /* Tell the controller to do our bidding */
36240 - h->access.submit_command(h, c);
36241 + h->access->submit_command(h, c);
36242
36243 /* Get onto the completion Q */
36244 addQ(&h->cmpQ, c);
36245 @@ -1048,7 +1048,7 @@ static irqreturn_t do_ida_intr(int irq, void *dev_id)
36246 unsigned long flags;
36247 __u32 a,a1;
36248
36249 - istat = h->access.intr_pending(h);
36250 + istat = h->access->intr_pending(h);
36251 /* Is this interrupt for us? */
36252 if (istat == 0)
36253 return IRQ_NONE;
36254 @@ -1059,7 +1059,7 @@ static irqreturn_t do_ida_intr(int irq, void *dev_id)
36255 */
36256 spin_lock_irqsave(IDA_LOCK(h->ctlr), flags);
36257 if (istat & FIFO_NOT_EMPTY) {
36258 - while((a = h->access.command_completed(h))) {
36259 + while((a = h->access->command_completed(h))) {
36260 a1 = a; a &= ~3;
36261 if ((c = h->cmpQ) == NULL)
36262 {
36263 @@ -1448,11 +1448,11 @@ static int sendcmd(
36264 /*
36265 * Disable interrupt
36266 */
36267 - info_p->access.set_intr_mask(info_p, 0);
36268 + info_p->access->set_intr_mask(info_p, 0);
36269 /* Make sure there is room in the command FIFO */
36270 /* Actually it should be completely empty at this time. */
36271 for (i = 200000; i > 0; i--) {
36272 - temp = info_p->access.fifo_full(info_p);
36273 + temp = info_p->access->fifo_full(info_p);
36274 if (temp != 0) {
36275 break;
36276 }
36277 @@ -1465,7 +1465,7 @@ DBG(
36278 /*
36279 * Send the cmd
36280 */
36281 - info_p->access.submit_command(info_p, c);
36282 + info_p->access->submit_command(info_p, c);
36283 complete = pollcomplete(ctlr);
36284
36285 pci_unmap_single(info_p->pci_dev, (dma_addr_t) c->req.sg[0].addr,
36286 @@ -1548,9 +1548,9 @@ static int revalidate_allvol(ctlr_info_t *host)
36287 * we check the new geometry. Then turn interrupts back on when
36288 * we're done.
36289 */
36290 - host->access.set_intr_mask(host, 0);
36291 + host->access->set_intr_mask(host, 0);
36292 getgeometry(ctlr);
36293 - host->access.set_intr_mask(host, FIFO_NOT_EMPTY);
36294 + host->access->set_intr_mask(host, FIFO_NOT_EMPTY);
36295
36296 for(i=0; i<NWD; i++) {
36297 struct gendisk *disk = ida_gendisk[ctlr][i];
36298 @@ -1590,7 +1590,7 @@ static int pollcomplete(int ctlr)
36299 /* Wait (up to 2 seconds) for a command to complete */
36300
36301 for (i = 200000; i > 0; i--) {
36302 - done = hba[ctlr]->access.command_completed(hba[ctlr]);
36303 + done = hba[ctlr]->access->command_completed(hba[ctlr]);
36304 if (done == 0) {
36305 udelay(10); /* a short fixed delay */
36306 } else
36307 diff --git a/drivers/block/cpqarray.h b/drivers/block/cpqarray.h
36308 index be73e9d..7fbf140 100644
36309 --- a/drivers/block/cpqarray.h
36310 +++ b/drivers/block/cpqarray.h
36311 @@ -99,7 +99,7 @@ struct ctlr_info {
36312 drv_info_t drv[NWD];
36313 struct proc_dir_entry *proc;
36314
36315 - struct access_method access;
36316 + struct access_method *access;
36317
36318 cmdlist_t *reqQ;
36319 cmdlist_t *cmpQ;
36320 diff --git a/drivers/block/drbd/drbd_int.h b/drivers/block/drbd/drbd_int.h
36321 index 2d7f608..11245fe 100644
36322 --- a/drivers/block/drbd/drbd_int.h
36323 +++ b/drivers/block/drbd/drbd_int.h
36324 @@ -582,7 +582,7 @@ struct drbd_epoch {
36325 struct drbd_tconn *tconn;
36326 struct list_head list;
36327 unsigned int barrier_nr;
36328 - atomic_t epoch_size; /* increased on every request added. */
36329 + atomic_unchecked_t epoch_size; /* increased on every request added. */
36330 atomic_t active; /* increased on every req. added, and dec on every finished. */
36331 unsigned long flags;
36332 };
36333 @@ -1022,7 +1022,7 @@ struct drbd_conf {
36334 unsigned int al_tr_number;
36335 int al_tr_cycle;
36336 wait_queue_head_t seq_wait;
36337 - atomic_t packet_seq;
36338 + atomic_unchecked_t packet_seq;
36339 unsigned int peer_seq;
36340 spinlock_t peer_seq_lock;
36341 unsigned int minor;
36342 @@ -1572,7 +1572,7 @@ static inline int drbd_setsockopt(struct socket *sock, int level, int optname,
36343 char __user *uoptval;
36344 int err;
36345
36346 - uoptval = (char __user __force *)optval;
36347 + uoptval = (char __force_user *)optval;
36348
36349 set_fs(KERNEL_DS);
36350 if (level == SOL_SOCKET)
36351 diff --git a/drivers/block/drbd/drbd_main.c b/drivers/block/drbd/drbd_main.c
36352 index 55635ed..40e837c 100644
36353 --- a/drivers/block/drbd/drbd_main.c
36354 +++ b/drivers/block/drbd/drbd_main.c
36355 @@ -1317,7 +1317,7 @@ static int _drbd_send_ack(struct drbd_conf *mdev, enum drbd_packet cmd,
36356 p->sector = sector;
36357 p->block_id = block_id;
36358 p->blksize = blksize;
36359 - p->seq_num = cpu_to_be32(atomic_inc_return(&mdev->packet_seq));
36360 + p->seq_num = cpu_to_be32(atomic_inc_return_unchecked(&mdev->packet_seq));
36361 return drbd_send_command(mdev, sock, cmd, sizeof(*p), NULL, 0);
36362 }
36363
36364 @@ -1619,7 +1619,7 @@ int drbd_send_dblock(struct drbd_conf *mdev, struct drbd_request *req)
36365 return -EIO;
36366 p->sector = cpu_to_be64(req->i.sector);
36367 p->block_id = (unsigned long)req;
36368 - p->seq_num = cpu_to_be32(atomic_inc_return(&mdev->packet_seq));
36369 + p->seq_num = cpu_to_be32(atomic_inc_return_unchecked(&mdev->packet_seq));
36370 dp_flags = bio_flags_to_wire(mdev, req->master_bio->bi_rw);
36371 if (mdev->state.conn >= C_SYNC_SOURCE &&
36372 mdev->state.conn <= C_PAUSED_SYNC_T)
36373 @@ -2574,8 +2574,8 @@ void conn_destroy(struct kref *kref)
36374 {
36375 struct drbd_tconn *tconn = container_of(kref, struct drbd_tconn, kref);
36376
36377 - if (atomic_read(&tconn->current_epoch->epoch_size) != 0)
36378 - conn_err(tconn, "epoch_size:%d\n", atomic_read(&tconn->current_epoch->epoch_size));
36379 + if (atomic_read_unchecked(&tconn->current_epoch->epoch_size) != 0)
36380 + conn_err(tconn, "epoch_size:%d\n", atomic_read_unchecked(&tconn->current_epoch->epoch_size));
36381 kfree(tconn->current_epoch);
36382
36383 idr_destroy(&tconn->volumes);
36384 diff --git a/drivers/block/drbd/drbd_nl.c b/drivers/block/drbd/drbd_nl.c
36385 index 8cc1e64..ba7ffa9 100644
36386 --- a/drivers/block/drbd/drbd_nl.c
36387 +++ b/drivers/block/drbd/drbd_nl.c
36388 @@ -3440,7 +3440,7 @@ out:
36389
36390 void drbd_bcast_event(struct drbd_conf *mdev, const struct sib_info *sib)
36391 {
36392 - static atomic_t drbd_genl_seq = ATOMIC_INIT(2); /* two. */
36393 + static atomic_unchecked_t drbd_genl_seq = ATOMIC_INIT(2); /* two. */
36394 struct sk_buff *msg;
36395 struct drbd_genlmsghdr *d_out;
36396 unsigned seq;
36397 @@ -3453,7 +3453,7 @@ void drbd_bcast_event(struct drbd_conf *mdev, const struct sib_info *sib)
36398 return;
36399 }
36400
36401 - seq = atomic_inc_return(&drbd_genl_seq);
36402 + seq = atomic_inc_return_unchecked(&drbd_genl_seq);
36403 msg = genlmsg_new(NLMSG_GOODSIZE, GFP_NOIO);
36404 if (!msg)
36405 goto failed;
36406 diff --git a/drivers/block/drbd/drbd_receiver.c b/drivers/block/drbd/drbd_receiver.c
36407 index cc29cd3..d4b058b 100644
36408 --- a/drivers/block/drbd/drbd_receiver.c
36409 +++ b/drivers/block/drbd/drbd_receiver.c
36410 @@ -834,7 +834,7 @@ int drbd_connected(struct drbd_conf *mdev)
36411 {
36412 int err;
36413
36414 - atomic_set(&mdev->packet_seq, 0);
36415 + atomic_set_unchecked(&mdev->packet_seq, 0);
36416 mdev->peer_seq = 0;
36417
36418 mdev->state_mutex = mdev->tconn->agreed_pro_version < 100 ?
36419 @@ -1193,7 +1193,7 @@ static enum finish_epoch drbd_may_finish_epoch(struct drbd_tconn *tconn,
36420 do {
36421 next_epoch = NULL;
36422
36423 - epoch_size = atomic_read(&epoch->epoch_size);
36424 + epoch_size = atomic_read_unchecked(&epoch->epoch_size);
36425
36426 switch (ev & ~EV_CLEANUP) {
36427 case EV_PUT:
36428 @@ -1233,7 +1233,7 @@ static enum finish_epoch drbd_may_finish_epoch(struct drbd_tconn *tconn,
36429 rv = FE_DESTROYED;
36430 } else {
36431 epoch->flags = 0;
36432 - atomic_set(&epoch->epoch_size, 0);
36433 + atomic_set_unchecked(&epoch->epoch_size, 0);
36434 /* atomic_set(&epoch->active, 0); is already zero */
36435 if (rv == FE_STILL_LIVE)
36436 rv = FE_RECYCLED;
36437 @@ -1451,7 +1451,7 @@ static int receive_Barrier(struct drbd_tconn *tconn, struct packet_info *pi)
36438 conn_wait_active_ee_empty(tconn);
36439 drbd_flush(tconn);
36440
36441 - if (atomic_read(&tconn->current_epoch->epoch_size)) {
36442 + if (atomic_read_unchecked(&tconn->current_epoch->epoch_size)) {
36443 epoch = kmalloc(sizeof(struct drbd_epoch), GFP_NOIO);
36444 if (epoch)
36445 break;
36446 @@ -1464,11 +1464,11 @@ static int receive_Barrier(struct drbd_tconn *tconn, struct packet_info *pi)
36447 }
36448
36449 epoch->flags = 0;
36450 - atomic_set(&epoch->epoch_size, 0);
36451 + atomic_set_unchecked(&epoch->epoch_size, 0);
36452 atomic_set(&epoch->active, 0);
36453
36454 spin_lock(&tconn->epoch_lock);
36455 - if (atomic_read(&tconn->current_epoch->epoch_size)) {
36456 + if (atomic_read_unchecked(&tconn->current_epoch->epoch_size)) {
36457 list_add(&epoch->list, &tconn->current_epoch->list);
36458 tconn->current_epoch = epoch;
36459 tconn->epochs++;
36460 @@ -2172,7 +2172,7 @@ static int receive_Data(struct drbd_tconn *tconn, struct packet_info *pi)
36461
36462 err = wait_for_and_update_peer_seq(mdev, peer_seq);
36463 drbd_send_ack_dp(mdev, P_NEG_ACK, p, pi->size);
36464 - atomic_inc(&tconn->current_epoch->epoch_size);
36465 + atomic_inc_unchecked(&tconn->current_epoch->epoch_size);
36466 err2 = drbd_drain_block(mdev, pi->size);
36467 if (!err)
36468 err = err2;
36469 @@ -2206,7 +2206,7 @@ static int receive_Data(struct drbd_tconn *tconn, struct packet_info *pi)
36470
36471 spin_lock(&tconn->epoch_lock);
36472 peer_req->epoch = tconn->current_epoch;
36473 - atomic_inc(&peer_req->epoch->epoch_size);
36474 + atomic_inc_unchecked(&peer_req->epoch->epoch_size);
36475 atomic_inc(&peer_req->epoch->active);
36476 spin_unlock(&tconn->epoch_lock);
36477
36478 @@ -4347,7 +4347,7 @@ struct data_cmd {
36479 int expect_payload;
36480 size_t pkt_size;
36481 int (*fn)(struct drbd_tconn *, struct packet_info *);
36482 -};
36483 +} __do_const;
36484
36485 static struct data_cmd drbd_cmd_handler[] = {
36486 [P_DATA] = { 1, sizeof(struct p_data), receive_Data },
36487 @@ -4467,7 +4467,7 @@ static void conn_disconnect(struct drbd_tconn *tconn)
36488 if (!list_empty(&tconn->current_epoch->list))
36489 conn_err(tconn, "ASSERTION FAILED: tconn->current_epoch->list not empty\n");
36490 /* ok, no more ee's on the fly, it is safe to reset the epoch_size */
36491 - atomic_set(&tconn->current_epoch->epoch_size, 0);
36492 + atomic_set_unchecked(&tconn->current_epoch->epoch_size, 0);
36493 tconn->send.seen_any_write_yet = false;
36494
36495 conn_info(tconn, "Connection closed\n");
36496 @@ -5223,7 +5223,7 @@ static int tconn_finish_peer_reqs(struct drbd_tconn *tconn)
36497 struct asender_cmd {
36498 size_t pkt_size;
36499 int (*fn)(struct drbd_tconn *tconn, struct packet_info *);
36500 -};
36501 +} __do_const;
36502
36503 static struct asender_cmd asender_tbl[] = {
36504 [P_PING] = { 0, got_Ping },
36505 diff --git a/drivers/block/loop.c b/drivers/block/loop.c
36506 index c8dac73..1800093 100644
36507 --- a/drivers/block/loop.c
36508 +++ b/drivers/block/loop.c
36509 @@ -232,7 +232,7 @@ static int __do_lo_send_write(struct file *file,
36510
36511 file_start_write(file);
36512 set_fs(get_ds());
36513 - bw = file->f_op->write(file, buf, len, &pos);
36514 + bw = file->f_op->write(file, (const char __force_user *)buf, len, &pos);
36515 set_fs(old_fs);
36516 file_end_write(file);
36517 if (likely(bw == len))
36518 diff --git a/drivers/block/pktcdvd.c b/drivers/block/pktcdvd.c
36519 index 5618847..5a46f3b 100644
36520 --- a/drivers/block/pktcdvd.c
36521 +++ b/drivers/block/pktcdvd.c
36522 @@ -108,7 +108,7 @@ static int pkt_seq_show(struct seq_file *m, void *p);
36523
36524 static sector_t get_zone(sector_t sector, struct pktcdvd_device *pd)
36525 {
36526 - return (sector + pd->offset) & ~(sector_t)(pd->settings.size - 1);
36527 + return (sector + pd->offset) & ~(sector_t)(pd->settings.size - 1UL);
36528 }
36529
36530 /*
36531 @@ -1897,7 +1897,7 @@ static noinline_for_stack int pkt_probe_settings(struct pktcdvd_device *pd)
36532 return -EROFS;
36533 }
36534 pd->settings.fp = ti.fp;
36535 - pd->offset = (be32_to_cpu(ti.track_start) << 2) & (pd->settings.size - 1);
36536 + pd->offset = (be32_to_cpu(ti.track_start) << 2) & (pd->settings.size - 1UL);
36537
36538 if (ti.nwa_v) {
36539 pd->nwa = be32_to_cpu(ti.next_writable);
36540 diff --git a/drivers/bluetooth/btwilink.c b/drivers/bluetooth/btwilink.c
36541 index 60abf59..80789e1 100644
36542 --- a/drivers/bluetooth/btwilink.c
36543 +++ b/drivers/bluetooth/btwilink.c
36544 @@ -293,7 +293,7 @@ static int ti_st_send_frame(struct sk_buff *skb)
36545
36546 static int bt_ti_probe(struct platform_device *pdev)
36547 {
36548 - static struct ti_st *hst;
36549 + struct ti_st *hst;
36550 struct hci_dev *hdev;
36551 int err;
36552
36553 diff --git a/drivers/bus/arm-cci.c b/drivers/bus/arm-cci.c
36554 index 2009266..7be9ca2 100644
36555 --- a/drivers/bus/arm-cci.c
36556 +++ b/drivers/bus/arm-cci.c
36557 @@ -405,7 +405,7 @@ static int __init cci_probe(void)
36558
36559 nb_cci_ports = cci_config->nb_ace + cci_config->nb_ace_lite;
36560
36561 - ports = kcalloc(sizeof(*ports), nb_cci_ports, GFP_KERNEL);
36562 + ports = kcalloc(nb_cci_ports, sizeof(*ports), GFP_KERNEL);
36563 if (!ports)
36564 return -ENOMEM;
36565
36566 diff --git a/drivers/cdrom/cdrom.c b/drivers/cdrom/cdrom.c
36567 index 8a3aff7..d7538c2 100644
36568 --- a/drivers/cdrom/cdrom.c
36569 +++ b/drivers/cdrom/cdrom.c
36570 @@ -416,7 +416,6 @@ int register_cdrom(struct cdrom_device_info *cdi)
36571 ENSURE(reset, CDC_RESET);
36572 ENSURE(generic_packet, CDC_GENERIC_PACKET);
36573 cdi->mc_flags = 0;
36574 - cdo->n_minors = 0;
36575 cdi->options = CDO_USE_FFLAGS;
36576
36577 if (autoclose==1 && CDROM_CAN(CDC_CLOSE_TRAY))
36578 @@ -436,8 +435,11 @@ int register_cdrom(struct cdrom_device_info *cdi)
36579 else
36580 cdi->cdda_method = CDDA_OLD;
36581
36582 - if (!cdo->generic_packet)
36583 - cdo->generic_packet = cdrom_dummy_generic_packet;
36584 + if (!cdo->generic_packet) {
36585 + pax_open_kernel();
36586 + *(void **)&cdo->generic_packet = cdrom_dummy_generic_packet;
36587 + pax_close_kernel();
36588 + }
36589
36590 cdinfo(CD_REG_UNREG, "drive \"/dev/%s\" registered\n", cdi->name);
36591 mutex_lock(&cdrom_mutex);
36592 @@ -458,7 +460,6 @@ void unregister_cdrom(struct cdrom_device_info *cdi)
36593 if (cdi->exit)
36594 cdi->exit(cdi);
36595
36596 - cdi->ops->n_minors--;
36597 cdinfo(CD_REG_UNREG, "drive \"/dev/%s\" unregistered\n", cdi->name);
36598 }
36599
36600 @@ -2107,7 +2108,7 @@ static int cdrom_read_cdda_old(struct cdrom_device_info *cdi, __u8 __user *ubuf,
36601 */
36602 nr = nframes;
36603 do {
36604 - cgc.buffer = kmalloc(CD_FRAMESIZE_RAW * nr, GFP_KERNEL);
36605 + cgc.buffer = kzalloc(CD_FRAMESIZE_RAW * nr, GFP_KERNEL);
36606 if (cgc.buffer)
36607 break;
36608
36609 @@ -3429,7 +3430,7 @@ static int cdrom_print_info(const char *header, int val, char *info,
36610 struct cdrom_device_info *cdi;
36611 int ret;
36612
36613 - ret = scnprintf(info + *pos, max_size - *pos, header);
36614 + ret = scnprintf(info + *pos, max_size - *pos, "%s", header);
36615 if (!ret)
36616 return 1;
36617
36618 diff --git a/drivers/cdrom/gdrom.c b/drivers/cdrom/gdrom.c
36619 index 5980cb9..6d7bd7e 100644
36620 --- a/drivers/cdrom/gdrom.c
36621 +++ b/drivers/cdrom/gdrom.c
36622 @@ -491,7 +491,6 @@ static struct cdrom_device_ops gdrom_ops = {
36623 .audio_ioctl = gdrom_audio_ioctl,
36624 .capability = CDC_MULTI_SESSION | CDC_MEDIA_CHANGED |
36625 CDC_RESET | CDC_DRIVE_STATUS | CDC_CD_R,
36626 - .n_minors = 1,
36627 };
36628
36629 static int gdrom_bdops_open(struct block_device *bdev, fmode_t mode)
36630 diff --git a/drivers/char/Kconfig b/drivers/char/Kconfig
36631 index 1421997..33f5d6d 100644
36632 --- a/drivers/char/Kconfig
36633 +++ b/drivers/char/Kconfig
36634 @@ -8,7 +8,8 @@ source "drivers/tty/Kconfig"
36635
36636 config DEVKMEM
36637 bool "/dev/kmem virtual device support"
36638 - default y
36639 + default n
36640 + depends on !GRKERNSEC_KMEM
36641 help
36642 Say Y here if you want to support the /dev/kmem device. The
36643 /dev/kmem device is rarely used, but can be used for certain
36644 @@ -570,6 +571,7 @@ config DEVPORT
36645 bool
36646 depends on !M68K
36647 depends on ISA || PCI
36648 + depends on !GRKERNSEC_KMEM
36649 default y
36650
36651 source "drivers/s390/char/Kconfig"
36652 diff --git a/drivers/char/agp/compat_ioctl.c b/drivers/char/agp/compat_ioctl.c
36653 index a48e05b..6bac831 100644
36654 --- a/drivers/char/agp/compat_ioctl.c
36655 +++ b/drivers/char/agp/compat_ioctl.c
36656 @@ -108,7 +108,7 @@ static int compat_agpioc_reserve_wrap(struct agp_file_private *priv, void __user
36657 return -ENOMEM;
36658 }
36659
36660 - if (copy_from_user(usegment, (void __user *) ureserve.seg_list,
36661 + if (copy_from_user(usegment, (void __force_user *) ureserve.seg_list,
36662 sizeof(*usegment) * ureserve.seg_count)) {
36663 kfree(usegment);
36664 kfree(ksegment);
36665 diff --git a/drivers/char/agp/frontend.c b/drivers/char/agp/frontend.c
36666 index 1b19239..b87b143 100644
36667 --- a/drivers/char/agp/frontend.c
36668 +++ b/drivers/char/agp/frontend.c
36669 @@ -819,7 +819,7 @@ static int agpioc_reserve_wrap(struct agp_file_private *priv, void __user *arg)
36670 if (copy_from_user(&reserve, arg, sizeof(struct agp_region)))
36671 return -EFAULT;
36672
36673 - if ((unsigned) reserve.seg_count >= ~0U/sizeof(struct agp_segment))
36674 + if ((unsigned) reserve.seg_count >= ~0U/sizeof(struct agp_segment_priv))
36675 return -EFAULT;
36676
36677 client = agp_find_client_by_pid(reserve.pid);
36678 @@ -849,7 +849,7 @@ static int agpioc_reserve_wrap(struct agp_file_private *priv, void __user *arg)
36679 if (segment == NULL)
36680 return -ENOMEM;
36681
36682 - if (copy_from_user(segment, (void __user *) reserve.seg_list,
36683 + if (copy_from_user(segment, (void __force_user *) reserve.seg_list,
36684 sizeof(struct agp_segment) * reserve.seg_count)) {
36685 kfree(segment);
36686 return -EFAULT;
36687 diff --git a/drivers/char/genrtc.c b/drivers/char/genrtc.c
36688 index 4f94375..413694e 100644
36689 --- a/drivers/char/genrtc.c
36690 +++ b/drivers/char/genrtc.c
36691 @@ -273,6 +273,7 @@ static int gen_rtc_ioctl(struct file *file,
36692 switch (cmd) {
36693
36694 case RTC_PLL_GET:
36695 + memset(&pll, 0, sizeof(pll));
36696 if (get_rtc_pll(&pll))
36697 return -EINVAL;
36698 else
36699 diff --git a/drivers/char/hpet.c b/drivers/char/hpet.c
36700 index 448ce5e..3a76625 100644
36701 --- a/drivers/char/hpet.c
36702 +++ b/drivers/char/hpet.c
36703 @@ -559,7 +559,7 @@ static inline unsigned long hpet_time_div(struct hpets *hpets,
36704 }
36705
36706 static int
36707 -hpet_ioctl_common(struct hpet_dev *devp, int cmd, unsigned long arg,
36708 +hpet_ioctl_common(struct hpet_dev *devp, unsigned int cmd, unsigned long arg,
36709 struct hpet_info *info)
36710 {
36711 struct hpet_timer __iomem *timer;
36712 diff --git a/drivers/char/hw_random/intel-rng.c b/drivers/char/hw_random/intel-rng.c
36713 index 86fe45c..c0ea948 100644
36714 --- a/drivers/char/hw_random/intel-rng.c
36715 +++ b/drivers/char/hw_random/intel-rng.c
36716 @@ -314,7 +314,7 @@ PFX "RNG, try using the 'no_fwh_detect' option.\n";
36717
36718 if (no_fwh_detect)
36719 return -ENODEV;
36720 - printk(warning);
36721 + printk("%s", warning);
36722 return -EBUSY;
36723 }
36724
36725 diff --git a/drivers/char/ipmi/ipmi_msghandler.c b/drivers/char/ipmi/ipmi_msghandler.c
36726 index ec4e10f..f2a763b 100644
36727 --- a/drivers/char/ipmi/ipmi_msghandler.c
36728 +++ b/drivers/char/ipmi/ipmi_msghandler.c
36729 @@ -420,7 +420,7 @@ struct ipmi_smi {
36730 struct proc_dir_entry *proc_dir;
36731 char proc_dir_name[10];
36732
36733 - atomic_t stats[IPMI_NUM_STATS];
36734 + atomic_unchecked_t stats[IPMI_NUM_STATS];
36735
36736 /*
36737 * run_to_completion duplicate of smb_info, smi_info
36738 @@ -453,9 +453,9 @@ static DEFINE_MUTEX(smi_watchers_mutex);
36739
36740
36741 #define ipmi_inc_stat(intf, stat) \
36742 - atomic_inc(&(intf)->stats[IPMI_STAT_ ## stat])
36743 + atomic_inc_unchecked(&(intf)->stats[IPMI_STAT_ ## stat])
36744 #define ipmi_get_stat(intf, stat) \
36745 - ((unsigned int) atomic_read(&(intf)->stats[IPMI_STAT_ ## stat]))
36746 + ((unsigned int) atomic_read_unchecked(&(intf)->stats[IPMI_STAT_ ## stat]))
36747
36748 static int is_lan_addr(struct ipmi_addr *addr)
36749 {
36750 @@ -2883,7 +2883,7 @@ int ipmi_register_smi(struct ipmi_smi_handlers *handlers,
36751 INIT_LIST_HEAD(&intf->cmd_rcvrs);
36752 init_waitqueue_head(&intf->waitq);
36753 for (i = 0; i < IPMI_NUM_STATS; i++)
36754 - atomic_set(&intf->stats[i], 0);
36755 + atomic_set_unchecked(&intf->stats[i], 0);
36756
36757 intf->proc_dir = NULL;
36758
36759 diff --git a/drivers/char/ipmi/ipmi_si_intf.c b/drivers/char/ipmi/ipmi_si_intf.c
36760 index 15e4a60..b046093 100644
36761 --- a/drivers/char/ipmi/ipmi_si_intf.c
36762 +++ b/drivers/char/ipmi/ipmi_si_intf.c
36763 @@ -280,7 +280,7 @@ struct smi_info {
36764 unsigned char slave_addr;
36765
36766 /* Counters and things for the proc filesystem. */
36767 - atomic_t stats[SI_NUM_STATS];
36768 + atomic_unchecked_t stats[SI_NUM_STATS];
36769
36770 struct task_struct *thread;
36771
36772 @@ -289,9 +289,9 @@ struct smi_info {
36773 };
36774
36775 #define smi_inc_stat(smi, stat) \
36776 - atomic_inc(&(smi)->stats[SI_STAT_ ## stat])
36777 + atomic_inc_unchecked(&(smi)->stats[SI_STAT_ ## stat])
36778 #define smi_get_stat(smi, stat) \
36779 - ((unsigned int) atomic_read(&(smi)->stats[SI_STAT_ ## stat]))
36780 + ((unsigned int) atomic_read_unchecked(&(smi)->stats[SI_STAT_ ## stat]))
36781
36782 #define SI_MAX_PARMS 4
36783
36784 @@ -3324,7 +3324,7 @@ static int try_smi_init(struct smi_info *new_smi)
36785 atomic_set(&new_smi->req_events, 0);
36786 new_smi->run_to_completion = 0;
36787 for (i = 0; i < SI_NUM_STATS; i++)
36788 - atomic_set(&new_smi->stats[i], 0);
36789 + atomic_set_unchecked(&new_smi->stats[i], 0);
36790
36791 new_smi->interrupt_disabled = 1;
36792 atomic_set(&new_smi->stop_operation, 0);
36793 diff --git a/drivers/char/mem.c b/drivers/char/mem.c
36794 index f895a8c..2bc9147 100644
36795 --- a/drivers/char/mem.c
36796 +++ b/drivers/char/mem.c
36797 @@ -18,6 +18,7 @@
36798 #include <linux/raw.h>
36799 #include <linux/tty.h>
36800 #include <linux/capability.h>
36801 +#include <linux/security.h>
36802 #include <linux/ptrace.h>
36803 #include <linux/device.h>
36804 #include <linux/highmem.h>
36805 @@ -37,6 +38,10 @@
36806
36807 #define DEVPORT_MINOR 4
36808
36809 +#if defined(CONFIG_GRKERNSEC) && !defined(CONFIG_GRKERNSEC_NO_RBAC)
36810 +extern const struct file_operations grsec_fops;
36811 +#endif
36812 +
36813 static inline unsigned long size_inside_page(unsigned long start,
36814 unsigned long size)
36815 {
36816 @@ -68,9 +73,13 @@ static inline int range_is_allowed(unsigned long pfn, unsigned long size)
36817
36818 while (cursor < to) {
36819 if (!devmem_is_allowed(pfn)) {
36820 +#ifdef CONFIG_GRKERNSEC_KMEM
36821 + gr_handle_mem_readwrite(from, to);
36822 +#else
36823 printk(KERN_INFO
36824 "Program %s tried to access /dev/mem between %Lx->%Lx.\n",
36825 current->comm, from, to);
36826 +#endif
36827 return 0;
36828 }
36829 cursor += PAGE_SIZE;
36830 @@ -78,6 +87,11 @@ static inline int range_is_allowed(unsigned long pfn, unsigned long size)
36831 }
36832 return 1;
36833 }
36834 +#elif defined(CONFIG_GRKERNSEC_KMEM)
36835 +static inline int range_is_allowed(unsigned long pfn, unsigned long size)
36836 +{
36837 + return 0;
36838 +}
36839 #else
36840 static inline int range_is_allowed(unsigned long pfn, unsigned long size)
36841 {
36842 @@ -120,6 +134,7 @@ static ssize_t read_mem(struct file *file, char __user *buf,
36843
36844 while (count > 0) {
36845 unsigned long remaining;
36846 + char *temp;
36847
36848 sz = size_inside_page(p, count);
36849
36850 @@ -135,7 +150,23 @@ static ssize_t read_mem(struct file *file, char __user *buf,
36851 if (!ptr)
36852 return -EFAULT;
36853
36854 - remaining = copy_to_user(buf, ptr, sz);
36855 +#ifdef CONFIG_PAX_USERCOPY
36856 + temp = kmalloc(sz, GFP_KERNEL|GFP_USERCOPY);
36857 + if (!temp) {
36858 + unxlate_dev_mem_ptr(p, ptr);
36859 + return -ENOMEM;
36860 + }
36861 + memcpy(temp, ptr, sz);
36862 +#else
36863 + temp = ptr;
36864 +#endif
36865 +
36866 + remaining = copy_to_user(buf, temp, sz);
36867 +
36868 +#ifdef CONFIG_PAX_USERCOPY
36869 + kfree(temp);
36870 +#endif
36871 +
36872 unxlate_dev_mem_ptr(p, ptr);
36873 if (remaining)
36874 return -EFAULT;
36875 @@ -364,9 +395,8 @@ static ssize_t read_kmem(struct file *file, char __user *buf,
36876 size_t count, loff_t *ppos)
36877 {
36878 unsigned long p = *ppos;
36879 - ssize_t low_count, read, sz;
36880 + ssize_t low_count, read, sz, err = 0;
36881 char *kbuf; /* k-addr because vread() takes vmlist_lock rwlock */
36882 - int err = 0;
36883
36884 read = 0;
36885 if (p < (unsigned long) high_memory) {
36886 @@ -388,6 +418,8 @@ static ssize_t read_kmem(struct file *file, char __user *buf,
36887 }
36888 #endif
36889 while (low_count > 0) {
36890 + char *temp;
36891 +
36892 sz = size_inside_page(p, low_count);
36893
36894 /*
36895 @@ -397,7 +429,22 @@ static ssize_t read_kmem(struct file *file, char __user *buf,
36896 */
36897 kbuf = xlate_dev_kmem_ptr((char *)p);
36898
36899 - if (copy_to_user(buf, kbuf, sz))
36900 +#ifdef CONFIG_PAX_USERCOPY
36901 + temp = kmalloc(sz, GFP_KERNEL|GFP_USERCOPY);
36902 + if (!temp)
36903 + return -ENOMEM;
36904 + memcpy(temp, kbuf, sz);
36905 +#else
36906 + temp = kbuf;
36907 +#endif
36908 +
36909 + err = copy_to_user(buf, temp, sz);
36910 +
36911 +#ifdef CONFIG_PAX_USERCOPY
36912 + kfree(temp);
36913 +#endif
36914 +
36915 + if (err)
36916 return -EFAULT;
36917 buf += sz;
36918 p += sz;
36919 @@ -822,6 +869,9 @@ static const struct memdev {
36920 #ifdef CONFIG_PRINTK
36921 [11] = { "kmsg", 0644, &kmsg_fops, NULL },
36922 #endif
36923 +#if defined(CONFIG_GRKERNSEC) && !defined(CONFIG_GRKERNSEC_NO_RBAC)
36924 + [13] = { "grsec",S_IRUSR | S_IWUGO, &grsec_fops, NULL },
36925 +#endif
36926 };
36927
36928 static int memory_open(struct inode *inode, struct file *filp)
36929 @@ -893,7 +943,7 @@ static int __init chr_dev_init(void)
36930 continue;
36931
36932 device_create(mem_class, NULL, MKDEV(MEM_MAJOR, minor),
36933 - NULL, devlist[minor].name);
36934 + NULL, "%s", devlist[minor].name);
36935 }
36936
36937 return tty_init();
36938 diff --git a/drivers/char/nvram.c b/drivers/char/nvram.c
36939 index 9df78e2..01ba9ae 100644
36940 --- a/drivers/char/nvram.c
36941 +++ b/drivers/char/nvram.c
36942 @@ -247,7 +247,7 @@ static ssize_t nvram_read(struct file *file, char __user *buf,
36943
36944 spin_unlock_irq(&rtc_lock);
36945
36946 - if (copy_to_user(buf, contents, tmp - contents))
36947 + if (tmp - contents > sizeof(contents) || copy_to_user(buf, contents, tmp - contents))
36948 return -EFAULT;
36949
36950 *ppos = i;
36951 diff --git a/drivers/char/pcmcia/synclink_cs.c b/drivers/char/pcmcia/synclink_cs.c
36952 index d39cca6..8c1e269 100644
36953 --- a/drivers/char/pcmcia/synclink_cs.c
36954 +++ b/drivers/char/pcmcia/synclink_cs.c
36955 @@ -2345,9 +2345,9 @@ static void mgslpc_close(struct tty_struct *tty, struct file * filp)
36956
36957 if (debug_level >= DEBUG_LEVEL_INFO)
36958 printk("%s(%d):mgslpc_close(%s) entry, count=%d\n",
36959 - __FILE__, __LINE__, info->device_name, port->count);
36960 + __FILE__, __LINE__, info->device_name, atomic_read(&port->count));
36961
36962 - WARN_ON(!port->count);
36963 + WARN_ON(!atomic_read(&port->count));
36964
36965 if (tty_port_close_start(port, tty, filp) == 0)
36966 goto cleanup;
36967 @@ -2365,7 +2365,7 @@ static void mgslpc_close(struct tty_struct *tty, struct file * filp)
36968 cleanup:
36969 if (debug_level >= DEBUG_LEVEL_INFO)
36970 printk("%s(%d):mgslpc_close(%s) exit, count=%d\n", __FILE__, __LINE__,
36971 - tty->driver->name, port->count);
36972 + tty->driver->name, atomic_read(&port->count));
36973 }
36974
36975 /* Wait until the transmitter is empty.
36976 @@ -2507,7 +2507,7 @@ static int mgslpc_open(struct tty_struct *tty, struct file * filp)
36977
36978 if (debug_level >= DEBUG_LEVEL_INFO)
36979 printk("%s(%d):mgslpc_open(%s), old ref count = %d\n",
36980 - __FILE__, __LINE__, tty->driver->name, port->count);
36981 + __FILE__, __LINE__, tty->driver->name, atomic_read(&port->count));
36982
36983 /* If port is closing, signal caller to try again */
36984 if (tty_hung_up_p(filp) || port->flags & ASYNC_CLOSING){
36985 @@ -2527,11 +2527,11 @@ static int mgslpc_open(struct tty_struct *tty, struct file * filp)
36986 goto cleanup;
36987 }
36988 spin_lock(&port->lock);
36989 - port->count++;
36990 + atomic_inc(&port->count);
36991 spin_unlock(&port->lock);
36992 spin_unlock_irqrestore(&info->netlock, flags);
36993
36994 - if (port->count == 1) {
36995 + if (atomic_read(&port->count) == 1) {
36996 /* 1st open on this device, init hardware */
36997 retval = startup(info, tty);
36998 if (retval < 0)
36999 @@ -3920,7 +3920,7 @@ static int hdlcdev_attach(struct net_device *dev, unsigned short encoding,
37000 unsigned short new_crctype;
37001
37002 /* return error if TTY interface open */
37003 - if (info->port.count)
37004 + if (atomic_read(&info->port.count))
37005 return -EBUSY;
37006
37007 switch (encoding)
37008 @@ -4024,7 +4024,7 @@ static int hdlcdev_open(struct net_device *dev)
37009
37010 /* arbitrate between network and tty opens */
37011 spin_lock_irqsave(&info->netlock, flags);
37012 - if (info->port.count != 0 || info->netcount != 0) {
37013 + if (atomic_read(&info->port.count) != 0 || info->netcount != 0) {
37014 printk(KERN_WARNING "%s: hdlc_open returning busy\n", dev->name);
37015 spin_unlock_irqrestore(&info->netlock, flags);
37016 return -EBUSY;
37017 @@ -4114,7 +4114,7 @@ static int hdlcdev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
37018 printk("%s:hdlcdev_ioctl(%s)\n", __FILE__, dev->name);
37019
37020 /* return error if TTY interface open */
37021 - if (info->port.count)
37022 + if (atomic_read(&info->port.count))
37023 return -EBUSY;
37024
37025 if (cmd != SIOCWANDEV)
37026 diff --git a/drivers/char/random.c b/drivers/char/random.c
37027 index 7a744d3..35a177ee 100644
37028 --- a/drivers/char/random.c
37029 +++ b/drivers/char/random.c
37030 @@ -269,8 +269,13 @@
37031 /*
37032 * Configuration information
37033 */
37034 +#ifdef CONFIG_GRKERNSEC_RANDNET
37035 +#define INPUT_POOL_WORDS 512
37036 +#define OUTPUT_POOL_WORDS 128
37037 +#else
37038 #define INPUT_POOL_WORDS 128
37039 #define OUTPUT_POOL_WORDS 32
37040 +#endif
37041 #define SEC_XFER_SIZE 512
37042 #define EXTRACT_SIZE 10
37043
37044 @@ -310,10 +315,17 @@ static struct poolinfo {
37045 int poolwords;
37046 int tap1, tap2, tap3, tap4, tap5;
37047 } poolinfo_table[] = {
37048 +#ifdef CONFIG_GRKERNSEC_RANDNET
37049 + /* x^512 + x^411 + x^308 + x^208 +x^104 + x + 1 -- 225 */
37050 + { 512, 411, 308, 208, 104, 1 },
37051 + /* x^128 + x^103 + x^76 + x^51 + x^25 + x + 1 -- 105 */
37052 + { 128, 103, 76, 51, 25, 1 },
37053 +#else
37054 /* x^128 + x^103 + x^76 + x^51 +x^25 + x + 1 -- 105 */
37055 { 128, 103, 76, 51, 25, 1 },
37056 /* x^32 + x^26 + x^20 + x^14 + x^7 + x + 1 -- 15 */
37057 { 32, 26, 20, 14, 7, 1 },
37058 +#endif
37059 #if 0
37060 /* x^2048 + x^1638 + x^1231 + x^819 + x^411 + x + 1 -- 115 */
37061 { 2048, 1638, 1231, 819, 411, 1 },
37062 @@ -521,8 +533,8 @@ static void _mix_pool_bytes(struct entropy_store *r, const void *in,
37063 input_rotate += i ? 7 : 14;
37064 }
37065
37066 - ACCESS_ONCE(r->input_rotate) = input_rotate;
37067 - ACCESS_ONCE(r->add_ptr) = i;
37068 + ACCESS_ONCE_RW(r->input_rotate) = input_rotate;
37069 + ACCESS_ONCE_RW(r->add_ptr) = i;
37070 smp_wmb();
37071
37072 if (out)
37073 @@ -1029,7 +1041,7 @@ static ssize_t extract_entropy_user(struct entropy_store *r, void __user *buf,
37074
37075 extract_buf(r, tmp);
37076 i = min_t(int, nbytes, EXTRACT_SIZE);
37077 - if (copy_to_user(buf, tmp, i)) {
37078 + if (i > sizeof(tmp) || copy_to_user(buf, tmp, i)) {
37079 ret = -EFAULT;
37080 break;
37081 }
37082 @@ -1365,7 +1377,7 @@ EXPORT_SYMBOL(generate_random_uuid);
37083 #include <linux/sysctl.h>
37084
37085 static int min_read_thresh = 8, min_write_thresh;
37086 -static int max_read_thresh = INPUT_POOL_WORDS * 32;
37087 +static int max_read_thresh = OUTPUT_POOL_WORDS * 32;
37088 static int max_write_thresh = INPUT_POOL_WORDS * 32;
37089 static char sysctl_bootid[16];
37090
37091 @@ -1381,7 +1393,7 @@ static char sysctl_bootid[16];
37092 static int proc_do_uuid(struct ctl_table *table, int write,
37093 void __user *buffer, size_t *lenp, loff_t *ppos)
37094 {
37095 - struct ctl_table fake_table;
37096 + ctl_table_no_const fake_table;
37097 unsigned char buf[64], tmp_uuid[16], *uuid;
37098
37099 uuid = table->data;
37100 diff --git a/drivers/char/sonypi.c b/drivers/char/sonypi.c
37101 index 7cc1fe22..b602d6b 100644
37102 --- a/drivers/char/sonypi.c
37103 +++ b/drivers/char/sonypi.c
37104 @@ -54,6 +54,7 @@
37105
37106 #include <asm/uaccess.h>
37107 #include <asm/io.h>
37108 +#include <asm/local.h>
37109
37110 #include <linux/sonypi.h>
37111
37112 @@ -490,7 +491,7 @@ static struct sonypi_device {
37113 spinlock_t fifo_lock;
37114 wait_queue_head_t fifo_proc_list;
37115 struct fasync_struct *fifo_async;
37116 - int open_count;
37117 + local_t open_count;
37118 int model;
37119 struct input_dev *input_jog_dev;
37120 struct input_dev *input_key_dev;
37121 @@ -892,7 +893,7 @@ static int sonypi_misc_fasync(int fd, struct file *filp, int on)
37122 static int sonypi_misc_release(struct inode *inode, struct file *file)
37123 {
37124 mutex_lock(&sonypi_device.lock);
37125 - sonypi_device.open_count--;
37126 + local_dec(&sonypi_device.open_count);
37127 mutex_unlock(&sonypi_device.lock);
37128 return 0;
37129 }
37130 @@ -901,9 +902,9 @@ static int sonypi_misc_open(struct inode *inode, struct file *file)
37131 {
37132 mutex_lock(&sonypi_device.lock);
37133 /* Flush input queue on first open */
37134 - if (!sonypi_device.open_count)
37135 + if (!local_read(&sonypi_device.open_count))
37136 kfifo_reset(&sonypi_device.fifo);
37137 - sonypi_device.open_count++;
37138 + local_inc(&sonypi_device.open_count);
37139 mutex_unlock(&sonypi_device.lock);
37140
37141 return 0;
37142 diff --git a/drivers/char/tpm/tpm_acpi.c b/drivers/char/tpm/tpm_acpi.c
37143 index 64420b3..5c40b56 100644
37144 --- a/drivers/char/tpm/tpm_acpi.c
37145 +++ b/drivers/char/tpm/tpm_acpi.c
37146 @@ -98,11 +98,12 @@ int read_log(struct tpm_bios_log *log)
37147 virt = acpi_os_map_memory(start, len);
37148 if (!virt) {
37149 kfree(log->bios_event_log);
37150 + log->bios_event_log = NULL;
37151 printk("%s: ERROR - Unable to map memory\n", __func__);
37152 return -EIO;
37153 }
37154
37155 - memcpy_fromio(log->bios_event_log, virt, len);
37156 + memcpy_fromio(log->bios_event_log, (const char __force_kernel *)virt, len);
37157
37158 acpi_os_unmap_memory(virt, len);
37159 return 0;
37160 diff --git a/drivers/char/tpm/tpm_eventlog.c b/drivers/char/tpm/tpm_eventlog.c
37161 index 84ddc55..1d32f1e 100644
37162 --- a/drivers/char/tpm/tpm_eventlog.c
37163 +++ b/drivers/char/tpm/tpm_eventlog.c
37164 @@ -95,7 +95,7 @@ static void *tpm_bios_measurements_start(struct seq_file *m, loff_t *pos)
37165 event = addr;
37166
37167 if ((event->event_type == 0 && event->event_size == 0) ||
37168 - ((addr + sizeof(struct tcpa_event) + event->event_size) >= limit))
37169 + (event->event_size >= limit - addr - sizeof(struct tcpa_event)))
37170 return NULL;
37171
37172 return addr;
37173 @@ -120,7 +120,7 @@ static void *tpm_bios_measurements_next(struct seq_file *m, void *v,
37174 return NULL;
37175
37176 if ((event->event_type == 0 && event->event_size == 0) ||
37177 - ((v + sizeof(struct tcpa_event) + event->event_size) >= limit))
37178 + (event->event_size >= limit - v - sizeof(struct tcpa_event)))
37179 return NULL;
37180
37181 (*pos)++;
37182 @@ -213,7 +213,8 @@ static int tpm_binary_bios_measurements_show(struct seq_file *m, void *v)
37183 int i;
37184
37185 for (i = 0; i < sizeof(struct tcpa_event) + event->event_size; i++)
37186 - seq_putc(m, data[i]);
37187 + if (!seq_putc(m, data[i]))
37188 + return -EFAULT;
37189
37190 return 0;
37191 }
37192 diff --git a/drivers/char/virtio_console.c b/drivers/char/virtio_console.c
37193 index b79cf3e..de172d64f 100644
37194 --- a/drivers/char/virtio_console.c
37195 +++ b/drivers/char/virtio_console.c
37196 @@ -682,7 +682,7 @@ static ssize_t fill_readbuf(struct port *port, char *out_buf, size_t out_count,
37197 if (to_user) {
37198 ssize_t ret;
37199
37200 - ret = copy_to_user(out_buf, buf->buf + buf->offset, out_count);
37201 + ret = copy_to_user((char __force_user *)out_buf, buf->buf + buf->offset, out_count);
37202 if (ret)
37203 return -EFAULT;
37204 } else {
37205 @@ -785,7 +785,7 @@ static ssize_t port_fops_read(struct file *filp, char __user *ubuf,
37206 if (!port_has_data(port) && !port->host_connected)
37207 return 0;
37208
37209 - return fill_readbuf(port, ubuf, count, true);
37210 + return fill_readbuf(port, (char __force_kernel *)ubuf, count, true);
37211 }
37212
37213 static int wait_port_writable(struct port *port, bool nonblock)
37214 diff --git a/drivers/clk/clk-composite.c b/drivers/clk/clk-composite.c
37215 index a33f46f..a720eed 100644
37216 --- a/drivers/clk/clk-composite.c
37217 +++ b/drivers/clk/clk-composite.c
37218 @@ -122,7 +122,7 @@ struct clk *clk_register_composite(struct device *dev, const char *name,
37219 struct clk *clk;
37220 struct clk_init_data init;
37221 struct clk_composite *composite;
37222 - struct clk_ops *clk_composite_ops;
37223 + clk_ops_no_const *clk_composite_ops;
37224
37225 composite = kzalloc(sizeof(*composite), GFP_KERNEL);
37226 if (!composite) {
37227 diff --git a/drivers/clk/socfpga/clk.c b/drivers/clk/socfpga/clk.c
37228 index 81dd31a..ef5c542 100644
37229 --- a/drivers/clk/socfpga/clk.c
37230 +++ b/drivers/clk/socfpga/clk.c
37231 @@ -22,6 +22,7 @@
37232 #include <linux/clk-provider.h>
37233 #include <linux/io.h>
37234 #include <linux/of.h>
37235 +#include <asm/pgtable.h>
37236
37237 /* Clock Manager offsets */
37238 #define CLKMGR_CTRL 0x0
37239 @@ -152,8 +153,10 @@ static __init struct clk *socfpga_clk_init(struct device_node *node,
37240 streq(clk_name, "periph_pll") ||
37241 streq(clk_name, "sdram_pll")) {
37242 socfpga_clk->hw.bit_idx = SOCFPGA_PLL_EXT_ENA;
37243 - clk_pll_ops.enable = clk_gate_ops.enable;
37244 - clk_pll_ops.disable = clk_gate_ops.disable;
37245 + pax_open_kernel();
37246 + *(void **)&clk_pll_ops.enable = clk_gate_ops.enable;
37247 + *(void **)&clk_pll_ops.disable = clk_gate_ops.disable;
37248 + pax_close_kernel();
37249 }
37250
37251 clk = clk_register(NULL, &socfpga_clk->hw.hw);
37252 @@ -244,7 +247,7 @@ static unsigned long socfpga_clk_recalc_rate(struct clk_hw *hwclk,
37253 return parent_rate / div;
37254 }
37255
37256 -static struct clk_ops gateclk_ops = {
37257 +static clk_ops_no_const gateclk_ops __read_only = {
37258 .recalc_rate = socfpga_clk_recalc_rate,
37259 .get_parent = socfpga_clk_get_parent,
37260 .set_parent = socfpga_clk_set_parent,
37261 diff --git a/drivers/cpufreq/acpi-cpufreq.c b/drivers/cpufreq/acpi-cpufreq.c
37262 index 506fd23..01a593f 100644
37263 --- a/drivers/cpufreq/acpi-cpufreq.c
37264 +++ b/drivers/cpufreq/acpi-cpufreq.c
37265 @@ -172,7 +172,7 @@ static ssize_t show_global_boost(struct kobject *kobj,
37266 return sprintf(buf, "%u\n", boost_enabled);
37267 }
37268
37269 -static struct global_attr global_boost = __ATTR(boost, 0644,
37270 +static global_attr_no_const global_boost = __ATTR(boost, 0644,
37271 show_global_boost,
37272 store_global_boost);
37273
37274 @@ -721,8 +721,11 @@ static int acpi_cpufreq_cpu_init(struct cpufreq_policy *policy)
37275 data->acpi_data = per_cpu_ptr(acpi_perf_data, cpu);
37276 per_cpu(acfreq_data, cpu) = data;
37277
37278 - if (cpu_has(c, X86_FEATURE_CONSTANT_TSC))
37279 - acpi_cpufreq_driver.flags |= CPUFREQ_CONST_LOOPS;
37280 + if (cpu_has(c, X86_FEATURE_CONSTANT_TSC)) {
37281 + pax_open_kernel();
37282 + *(u8 *)&acpi_cpufreq_driver.flags |= CPUFREQ_CONST_LOOPS;
37283 + pax_close_kernel();
37284 + }
37285
37286 result = acpi_processor_register_performance(data->acpi_data, cpu);
37287 if (result)
37288 @@ -850,7 +853,9 @@ static int acpi_cpufreq_cpu_init(struct cpufreq_policy *policy)
37289 policy->cur = acpi_cpufreq_guess_freq(data, policy->cpu);
37290 break;
37291 case ACPI_ADR_SPACE_FIXED_HARDWARE:
37292 - acpi_cpufreq_driver.get = get_cur_freq_on_cpu;
37293 + pax_open_kernel();
37294 + *(void **)&acpi_cpufreq_driver.get = get_cur_freq_on_cpu;
37295 + pax_close_kernel();
37296 policy->cur = get_cur_freq_on_cpu(cpu);
37297 break;
37298 default:
37299 diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
37300 index 04548f7..457a342 100644
37301 --- a/drivers/cpufreq/cpufreq.c
37302 +++ b/drivers/cpufreq/cpufreq.c
37303 @@ -2069,7 +2069,7 @@ static int cpufreq_cpu_callback(struct notifier_block *nfb,
37304 return NOTIFY_OK;
37305 }
37306
37307 -static struct notifier_block __refdata cpufreq_cpu_notifier = {
37308 +static struct notifier_block cpufreq_cpu_notifier = {
37309 .notifier_call = cpufreq_cpu_callback,
37310 };
37311
37312 @@ -2101,8 +2101,11 @@ int cpufreq_register_driver(struct cpufreq_driver *driver_data)
37313
37314 pr_debug("trying to register driver %s\n", driver_data->name);
37315
37316 - if (driver_data->setpolicy)
37317 - driver_data->flags |= CPUFREQ_CONST_LOOPS;
37318 + if (driver_data->setpolicy) {
37319 + pax_open_kernel();
37320 + *(u8 *)&driver_data->flags |= CPUFREQ_CONST_LOOPS;
37321 + pax_close_kernel();
37322 + }
37323
37324 write_lock_irqsave(&cpufreq_driver_lock, flags);
37325 if (cpufreq_driver) {
37326 diff --git a/drivers/cpufreq/cpufreq_governor.c b/drivers/cpufreq/cpufreq_governor.c
37327 index 0806c31..6a73276 100644
37328 --- a/drivers/cpufreq/cpufreq_governor.c
37329 +++ b/drivers/cpufreq/cpufreq_governor.c
37330 @@ -187,7 +187,7 @@ int cpufreq_governor_dbs(struct cpufreq_policy *policy,
37331 struct dbs_data *dbs_data;
37332 struct od_cpu_dbs_info_s *od_dbs_info = NULL;
37333 struct cs_cpu_dbs_info_s *cs_dbs_info = NULL;
37334 - struct od_ops *od_ops = NULL;
37335 + const struct od_ops *od_ops = NULL;
37336 struct od_dbs_tuners *od_tuners = NULL;
37337 struct cs_dbs_tuners *cs_tuners = NULL;
37338 struct cpu_dbs_common_info *cpu_cdbs;
37339 @@ -253,7 +253,7 @@ int cpufreq_governor_dbs(struct cpufreq_policy *policy,
37340
37341 if ((cdata->governor == GOV_CONSERVATIVE) &&
37342 (!policy->governor->initialized)) {
37343 - struct cs_ops *cs_ops = dbs_data->cdata->gov_ops;
37344 + const struct cs_ops *cs_ops = dbs_data->cdata->gov_ops;
37345
37346 cpufreq_register_notifier(cs_ops->notifier_block,
37347 CPUFREQ_TRANSITION_NOTIFIER);
37348 @@ -273,7 +273,7 @@ int cpufreq_governor_dbs(struct cpufreq_policy *policy,
37349
37350 if ((dbs_data->cdata->governor == GOV_CONSERVATIVE) &&
37351 (policy->governor->initialized == 1)) {
37352 - struct cs_ops *cs_ops = dbs_data->cdata->gov_ops;
37353 + const struct cs_ops *cs_ops = dbs_data->cdata->gov_ops;
37354
37355 cpufreq_unregister_notifier(cs_ops->notifier_block,
37356 CPUFREQ_TRANSITION_NOTIFIER);
37357 diff --git a/drivers/cpufreq/cpufreq_governor.h b/drivers/cpufreq/cpufreq_governor.h
37358 index 88cd39f..87f0393 100644
37359 --- a/drivers/cpufreq/cpufreq_governor.h
37360 +++ b/drivers/cpufreq/cpufreq_governor.h
37361 @@ -202,7 +202,7 @@ struct common_dbs_data {
37362 void (*exit)(struct dbs_data *dbs_data);
37363
37364 /* Governor specific ops, see below */
37365 - void *gov_ops;
37366 + const void *gov_ops;
37367 };
37368
37369 /* Governor Per policy data */
37370 @@ -222,7 +222,7 @@ struct od_ops {
37371 unsigned int (*powersave_bias_target)(struct cpufreq_policy *policy,
37372 unsigned int freq_next, unsigned int relation);
37373 void (*freq_increase)(struct cpufreq_policy *policy, unsigned int freq);
37374 -};
37375 +} __no_const;
37376
37377 struct cs_ops {
37378 struct notifier_block *notifier_block;
37379 diff --git a/drivers/cpufreq/cpufreq_ondemand.c b/drivers/cpufreq/cpufreq_ondemand.c
37380 index 32f26f6..feb657b 100644
37381 --- a/drivers/cpufreq/cpufreq_ondemand.c
37382 +++ b/drivers/cpufreq/cpufreq_ondemand.c
37383 @@ -522,7 +522,7 @@ static void od_exit(struct dbs_data *dbs_data)
37384
37385 define_get_cpu_dbs_routines(od_cpu_dbs_info);
37386
37387 -static struct od_ops od_ops = {
37388 +static struct od_ops od_ops __read_only = {
37389 .powersave_bias_init_cpu = ondemand_powersave_bias_init_cpu,
37390 .powersave_bias_target = generic_powersave_bias_target,
37391 .freq_increase = dbs_freq_increase,
37392 @@ -577,14 +577,18 @@ void od_register_powersave_bias_handler(unsigned int (*f)
37393 (struct cpufreq_policy *, unsigned int, unsigned int),
37394 unsigned int powersave_bias)
37395 {
37396 - od_ops.powersave_bias_target = f;
37397 + pax_open_kernel();
37398 + *(void **)&od_ops.powersave_bias_target = f;
37399 + pax_close_kernel();
37400 od_set_powersave_bias(powersave_bias);
37401 }
37402 EXPORT_SYMBOL_GPL(od_register_powersave_bias_handler);
37403
37404 void od_unregister_powersave_bias_handler(void)
37405 {
37406 - od_ops.powersave_bias_target = generic_powersave_bias_target;
37407 + pax_open_kernel();
37408 + *(void **)&od_ops.powersave_bias_target = generic_powersave_bias_target;
37409 + pax_close_kernel();
37410 od_set_powersave_bias(0);
37411 }
37412 EXPORT_SYMBOL_GPL(od_unregister_powersave_bias_handler);
37413 diff --git a/drivers/cpufreq/cpufreq_stats.c b/drivers/cpufreq/cpufreq_stats.c
37414 index 4cf0d28..5830372 100644
37415 --- a/drivers/cpufreq/cpufreq_stats.c
37416 +++ b/drivers/cpufreq/cpufreq_stats.c
37417 @@ -352,7 +352,7 @@ static int cpufreq_stat_cpu_callback(struct notifier_block *nfb,
37418 }
37419
37420 /* priority=1 so this will get called before cpufreq_remove_dev */
37421 -static struct notifier_block cpufreq_stat_cpu_notifier __refdata = {
37422 +static struct notifier_block cpufreq_stat_cpu_notifier = {
37423 .notifier_call = cpufreq_stat_cpu_callback,
37424 .priority = 1,
37425 };
37426 diff --git a/drivers/cpufreq/p4-clockmod.c b/drivers/cpufreq/p4-clockmod.c
37427 index 2f0a2a6..93d728e 100644
37428 --- a/drivers/cpufreq/p4-clockmod.c
37429 +++ b/drivers/cpufreq/p4-clockmod.c
37430 @@ -160,10 +160,14 @@ static unsigned int cpufreq_p4_get_frequency(struct cpuinfo_x86 *c)
37431 case 0x0F: /* Core Duo */
37432 case 0x16: /* Celeron Core */
37433 case 0x1C: /* Atom */
37434 - p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
37435 + pax_open_kernel();
37436 + *(u8 *)&p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
37437 + pax_close_kernel();
37438 return speedstep_get_frequency(SPEEDSTEP_CPU_PCORE);
37439 case 0x0D: /* Pentium M (Dothan) */
37440 - p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
37441 + pax_open_kernel();
37442 + *(u8 *)&p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
37443 + pax_close_kernel();
37444 /* fall through */
37445 case 0x09: /* Pentium M (Banias) */
37446 return speedstep_get_frequency(SPEEDSTEP_CPU_PM);
37447 @@ -175,7 +179,9 @@ static unsigned int cpufreq_p4_get_frequency(struct cpuinfo_x86 *c)
37448
37449 /* on P-4s, the TSC runs with constant frequency independent whether
37450 * throttling is active or not. */
37451 - p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
37452 + pax_open_kernel();
37453 + *(u8 *)&p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
37454 + pax_close_kernel();
37455
37456 if (speedstep_detect_processor() == SPEEDSTEP_CPU_P4M) {
37457 printk(KERN_WARNING PFX "Warning: Pentium 4-M detected. "
37458 diff --git a/drivers/cpufreq/sparc-us3-cpufreq.c b/drivers/cpufreq/sparc-us3-cpufreq.c
37459 index ac76b48..2445bc6 100644
37460 --- a/drivers/cpufreq/sparc-us3-cpufreq.c
37461 +++ b/drivers/cpufreq/sparc-us3-cpufreq.c
37462 @@ -18,14 +18,12 @@
37463 #include <asm/head.h>
37464 #include <asm/timer.h>
37465
37466 -static struct cpufreq_driver *cpufreq_us3_driver;
37467 -
37468 struct us3_freq_percpu_info {
37469 struct cpufreq_frequency_table table[4];
37470 };
37471
37472 /* Indexed by cpu number. */
37473 -static struct us3_freq_percpu_info *us3_freq_table;
37474 +static struct us3_freq_percpu_info us3_freq_table[NR_CPUS];
37475
37476 /* UltraSPARC-III has three dividers: 1, 2, and 32. These are controlled
37477 * in the Safari config register.
37478 @@ -186,12 +184,25 @@ static int __init us3_freq_cpu_init(struct cpufreq_policy *policy)
37479
37480 static int us3_freq_cpu_exit(struct cpufreq_policy *policy)
37481 {
37482 - if (cpufreq_us3_driver)
37483 - us3_set_cpu_divider_index(policy, 0);
37484 + us3_set_cpu_divider_index(policy->cpu, 0);
37485
37486 return 0;
37487 }
37488
37489 +static int __init us3_freq_init(void);
37490 +static void __exit us3_freq_exit(void);
37491 +
37492 +static struct cpufreq_driver cpufreq_us3_driver = {
37493 + .init = us3_freq_cpu_init,
37494 + .verify = us3_freq_verify,
37495 + .target = us3_freq_target,
37496 + .get = us3_freq_get,
37497 + .exit = us3_freq_cpu_exit,
37498 + .owner = THIS_MODULE,
37499 + .name = "UltraSPARC-III",
37500 +
37501 +};
37502 +
37503 static int __init us3_freq_init(void)
37504 {
37505 unsigned long manuf, impl, ver;
37506 @@ -208,55 +219,15 @@ static int __init us3_freq_init(void)
37507 (impl == CHEETAH_IMPL ||
37508 impl == CHEETAH_PLUS_IMPL ||
37509 impl == JAGUAR_IMPL ||
37510 - impl == PANTHER_IMPL)) {
37511 - struct cpufreq_driver *driver;
37512 -
37513 - ret = -ENOMEM;
37514 - driver = kzalloc(sizeof(*driver), GFP_KERNEL);
37515 - if (!driver)
37516 - goto err_out;
37517 -
37518 - us3_freq_table = kzalloc((NR_CPUS * sizeof(*us3_freq_table)),
37519 - GFP_KERNEL);
37520 - if (!us3_freq_table)
37521 - goto err_out;
37522 -
37523 - driver->init = us3_freq_cpu_init;
37524 - driver->verify = us3_freq_verify;
37525 - driver->target = us3_freq_target;
37526 - driver->get = us3_freq_get;
37527 - driver->exit = us3_freq_cpu_exit;
37528 - strcpy(driver->name, "UltraSPARC-III");
37529 -
37530 - cpufreq_us3_driver = driver;
37531 - ret = cpufreq_register_driver(driver);
37532 - if (ret)
37533 - goto err_out;
37534 -
37535 - return 0;
37536 -
37537 -err_out:
37538 - if (driver) {
37539 - kfree(driver);
37540 - cpufreq_us3_driver = NULL;
37541 - }
37542 - kfree(us3_freq_table);
37543 - us3_freq_table = NULL;
37544 - return ret;
37545 - }
37546 + impl == PANTHER_IMPL))
37547 + return cpufreq_register_driver(&cpufreq_us3_driver);
37548
37549 return -ENODEV;
37550 }
37551
37552 static void __exit us3_freq_exit(void)
37553 {
37554 - if (cpufreq_us3_driver) {
37555 - cpufreq_unregister_driver(cpufreq_us3_driver);
37556 - kfree(cpufreq_us3_driver);
37557 - cpufreq_us3_driver = NULL;
37558 - kfree(us3_freq_table);
37559 - us3_freq_table = NULL;
37560 - }
37561 + cpufreq_unregister_driver(&cpufreq_us3_driver);
37562 }
37563
37564 MODULE_AUTHOR("David S. Miller <davem@redhat.com>");
37565 diff --git a/drivers/cpufreq/speedstep-centrino.c b/drivers/cpufreq/speedstep-centrino.c
37566 index f897d51..15da295 100644
37567 --- a/drivers/cpufreq/speedstep-centrino.c
37568 +++ b/drivers/cpufreq/speedstep-centrino.c
37569 @@ -353,8 +353,11 @@ static int centrino_cpu_init(struct cpufreq_policy *policy)
37570 !cpu_has(cpu, X86_FEATURE_EST))
37571 return -ENODEV;
37572
37573 - if (cpu_has(cpu, X86_FEATURE_CONSTANT_TSC))
37574 - centrino_driver.flags |= CPUFREQ_CONST_LOOPS;
37575 + if (cpu_has(cpu, X86_FEATURE_CONSTANT_TSC)) {
37576 + pax_open_kernel();
37577 + *(u8 *)&centrino_driver.flags |= CPUFREQ_CONST_LOOPS;
37578 + pax_close_kernel();
37579 + }
37580
37581 if (policy->cpu != 0)
37582 return -ENODEV;
37583 diff --git a/drivers/cpuidle/cpuidle.c b/drivers/cpuidle/cpuidle.c
37584 index d75040d..4738ca5 100644
37585 --- a/drivers/cpuidle/cpuidle.c
37586 +++ b/drivers/cpuidle/cpuidle.c
37587 @@ -252,7 +252,7 @@ static int poll_idle(struct cpuidle_device *dev,
37588
37589 static void poll_idle_init(struct cpuidle_driver *drv)
37590 {
37591 - struct cpuidle_state *state = &drv->states[0];
37592 + cpuidle_state_no_const *state = &drv->states[0];
37593
37594 snprintf(state->name, CPUIDLE_NAME_LEN, "POLL");
37595 snprintf(state->desc, CPUIDLE_DESC_LEN, "CPUIDLE CORE POLL IDLE");
37596 diff --git a/drivers/cpuidle/governor.c b/drivers/cpuidle/governor.c
37597 index ea2f8e7..70ac501 100644
37598 --- a/drivers/cpuidle/governor.c
37599 +++ b/drivers/cpuidle/governor.c
37600 @@ -87,7 +87,7 @@ int cpuidle_register_governor(struct cpuidle_governor *gov)
37601 mutex_lock(&cpuidle_lock);
37602 if (__cpuidle_find_governor(gov->name) == NULL) {
37603 ret = 0;
37604 - list_add_tail(&gov->governor_list, &cpuidle_governors);
37605 + pax_list_add_tail((struct list_head *)&gov->governor_list, &cpuidle_governors);
37606 if (!cpuidle_curr_governor ||
37607 cpuidle_curr_governor->rating < gov->rating)
37608 cpuidle_switch_governor(gov);
37609 @@ -135,7 +135,7 @@ void cpuidle_unregister_governor(struct cpuidle_governor *gov)
37610 new_gov = cpuidle_replace_governor(gov->rating);
37611 cpuidle_switch_governor(new_gov);
37612 }
37613 - list_del(&gov->governor_list);
37614 + pax_list_del((struct list_head *)&gov->governor_list);
37615 mutex_unlock(&cpuidle_lock);
37616 }
37617
37618 diff --git a/drivers/cpuidle/sysfs.c b/drivers/cpuidle/sysfs.c
37619 index 8739cc0..dc859d0 100644
37620 --- a/drivers/cpuidle/sysfs.c
37621 +++ b/drivers/cpuidle/sysfs.c
37622 @@ -134,7 +134,7 @@ static struct attribute *cpuidle_switch_attrs[] = {
37623 NULL
37624 };
37625
37626 -static struct attribute_group cpuidle_attr_group = {
37627 +static attribute_group_no_const cpuidle_attr_group = {
37628 .attrs = cpuidle_default_attrs,
37629 .name = "cpuidle",
37630 };
37631 diff --git a/drivers/crypto/hifn_795x.c b/drivers/crypto/hifn_795x.c
37632 index 12fea3e..1e28f47 100644
37633 --- a/drivers/crypto/hifn_795x.c
37634 +++ b/drivers/crypto/hifn_795x.c
37635 @@ -51,7 +51,7 @@ module_param_string(hifn_pll_ref, hifn_pll_ref, sizeof(hifn_pll_ref), 0444);
37636 MODULE_PARM_DESC(hifn_pll_ref,
37637 "PLL reference clock (pci[freq] or ext[freq], default ext)");
37638
37639 -static atomic_t hifn_dev_number;
37640 +static atomic_unchecked_t hifn_dev_number;
37641
37642 #define ACRYPTO_OP_DECRYPT 0
37643 #define ACRYPTO_OP_ENCRYPT 1
37644 @@ -2577,7 +2577,7 @@ static int hifn_probe(struct pci_dev *pdev, const struct pci_device_id *id)
37645 goto err_out_disable_pci_device;
37646
37647 snprintf(name, sizeof(name), "hifn%d",
37648 - atomic_inc_return(&hifn_dev_number)-1);
37649 + atomic_inc_return_unchecked(&hifn_dev_number)-1);
37650
37651 err = pci_request_regions(pdev, name);
37652 if (err)
37653 diff --git a/drivers/devfreq/devfreq.c b/drivers/devfreq/devfreq.c
37654 index c99c00d..990a4b2 100644
37655 --- a/drivers/devfreq/devfreq.c
37656 +++ b/drivers/devfreq/devfreq.c
37657 @@ -607,7 +607,7 @@ int devfreq_add_governor(struct devfreq_governor *governor)
37658 goto err_out;
37659 }
37660
37661 - list_add(&governor->node, &devfreq_governor_list);
37662 + pax_list_add((struct list_head *)&governor->node, &devfreq_governor_list);
37663
37664 list_for_each_entry(devfreq, &devfreq_list, node) {
37665 int ret = 0;
37666 @@ -695,7 +695,7 @@ int devfreq_remove_governor(struct devfreq_governor *governor)
37667 }
37668 }
37669
37670 - list_del(&governor->node);
37671 + pax_list_del((struct list_head *)&governor->node);
37672 err_out:
37673 mutex_unlock(&devfreq_list_lock);
37674
37675 diff --git a/drivers/dma/sh/shdmac.c b/drivers/dma/sh/shdmac.c
37676 index 1069e88..dfcd642 100644
37677 --- a/drivers/dma/sh/shdmac.c
37678 +++ b/drivers/dma/sh/shdmac.c
37679 @@ -511,7 +511,7 @@ static int sh_dmae_nmi_handler(struct notifier_block *self,
37680 return ret;
37681 }
37682
37683 -static struct notifier_block sh_dmae_nmi_notifier __read_mostly = {
37684 +static struct notifier_block sh_dmae_nmi_notifier = {
37685 .notifier_call = sh_dmae_nmi_handler,
37686
37687 /* Run before NMI debug handler and KGDB */
37688 diff --git a/drivers/edac/edac_device.c b/drivers/edac/edac_device.c
37689 index 211021d..201d47f 100644
37690 --- a/drivers/edac/edac_device.c
37691 +++ b/drivers/edac/edac_device.c
37692 @@ -474,9 +474,9 @@ void edac_device_reset_delay_period(struct edac_device_ctl_info *edac_dev,
37693 */
37694 int edac_device_alloc_index(void)
37695 {
37696 - static atomic_t device_indexes = ATOMIC_INIT(0);
37697 + static atomic_unchecked_t device_indexes = ATOMIC_INIT(0);
37698
37699 - return atomic_inc_return(&device_indexes) - 1;
37700 + return atomic_inc_return_unchecked(&device_indexes) - 1;
37701 }
37702 EXPORT_SYMBOL_GPL(edac_device_alloc_index);
37703
37704 diff --git a/drivers/edac/edac_mc_sysfs.c b/drivers/edac/edac_mc_sysfs.c
37705 index 9f7e0e60..348c875 100644
37706 --- a/drivers/edac/edac_mc_sysfs.c
37707 +++ b/drivers/edac/edac_mc_sysfs.c
37708 @@ -150,7 +150,7 @@ static const char * const edac_caps[] = {
37709 struct dev_ch_attribute {
37710 struct device_attribute attr;
37711 int channel;
37712 -};
37713 +} __do_const;
37714
37715 #define DEVICE_CHANNEL(_name, _mode, _show, _store, _var) \
37716 struct dev_ch_attribute dev_attr_legacy_##_name = \
37717 @@ -1007,14 +1007,16 @@ int edac_create_sysfs_mci_device(struct mem_ctl_info *mci)
37718 }
37719
37720 if (mci->set_sdram_scrub_rate || mci->get_sdram_scrub_rate) {
37721 + pax_open_kernel();
37722 if (mci->get_sdram_scrub_rate) {
37723 - dev_attr_sdram_scrub_rate.attr.mode |= S_IRUGO;
37724 - dev_attr_sdram_scrub_rate.show = &mci_sdram_scrub_rate_show;
37725 + *(umode_t *)&dev_attr_sdram_scrub_rate.attr.mode |= S_IRUGO;
37726 + *(void **)&dev_attr_sdram_scrub_rate.show = &mci_sdram_scrub_rate_show;
37727 }
37728 if (mci->set_sdram_scrub_rate) {
37729 - dev_attr_sdram_scrub_rate.attr.mode |= S_IWUSR;
37730 - dev_attr_sdram_scrub_rate.store = &mci_sdram_scrub_rate_store;
37731 + *(umode_t *)&dev_attr_sdram_scrub_rate.attr.mode |= S_IWUSR;
37732 + *(void **)&dev_attr_sdram_scrub_rate.store = &mci_sdram_scrub_rate_store;
37733 }
37734 + pax_close_kernel();
37735 err = device_create_file(&mci->dev,
37736 &dev_attr_sdram_scrub_rate);
37737 if (err) {
37738 diff --git a/drivers/edac/edac_pci.c b/drivers/edac/edac_pci.c
37739 index dd370f9..0281629 100644
37740 --- a/drivers/edac/edac_pci.c
37741 +++ b/drivers/edac/edac_pci.c
37742 @@ -29,7 +29,7 @@
37743
37744 static DEFINE_MUTEX(edac_pci_ctls_mutex);
37745 static LIST_HEAD(edac_pci_list);
37746 -static atomic_t pci_indexes = ATOMIC_INIT(0);
37747 +static atomic_unchecked_t pci_indexes = ATOMIC_INIT(0);
37748
37749 /*
37750 * edac_pci_alloc_ctl_info
37751 @@ -315,7 +315,7 @@ EXPORT_SYMBOL_GPL(edac_pci_reset_delay_period);
37752 */
37753 int edac_pci_alloc_index(void)
37754 {
37755 - return atomic_inc_return(&pci_indexes) - 1;
37756 + return atomic_inc_return_unchecked(&pci_indexes) - 1;
37757 }
37758 EXPORT_SYMBOL_GPL(edac_pci_alloc_index);
37759
37760 diff --git a/drivers/edac/edac_pci_sysfs.c b/drivers/edac/edac_pci_sysfs.c
37761 index e8658e4..22746d6 100644
37762 --- a/drivers/edac/edac_pci_sysfs.c
37763 +++ b/drivers/edac/edac_pci_sysfs.c
37764 @@ -26,8 +26,8 @@ static int edac_pci_log_pe = 1; /* log PCI parity errors */
37765 static int edac_pci_log_npe = 1; /* log PCI non-parity error errors */
37766 static int edac_pci_poll_msec = 1000; /* one second workq period */
37767
37768 -static atomic_t pci_parity_count = ATOMIC_INIT(0);
37769 -static atomic_t pci_nonparity_count = ATOMIC_INIT(0);
37770 +static atomic_unchecked_t pci_parity_count = ATOMIC_INIT(0);
37771 +static atomic_unchecked_t pci_nonparity_count = ATOMIC_INIT(0);
37772
37773 static struct kobject *edac_pci_top_main_kobj;
37774 static atomic_t edac_pci_sysfs_refcount = ATOMIC_INIT(0);
37775 @@ -235,7 +235,7 @@ struct edac_pci_dev_attribute {
37776 void *value;
37777 ssize_t(*show) (void *, char *);
37778 ssize_t(*store) (void *, const char *, size_t);
37779 -};
37780 +} __do_const;
37781
37782 /* Set of show/store abstract level functions for PCI Parity object */
37783 static ssize_t edac_pci_dev_show(struct kobject *kobj, struct attribute *attr,
37784 @@ -579,7 +579,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
37785 edac_printk(KERN_CRIT, EDAC_PCI,
37786 "Signaled System Error on %s\n",
37787 pci_name(dev));
37788 - atomic_inc(&pci_nonparity_count);
37789 + atomic_inc_unchecked(&pci_nonparity_count);
37790 }
37791
37792 if (status & (PCI_STATUS_PARITY)) {
37793 @@ -587,7 +587,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
37794 "Master Data Parity Error on %s\n",
37795 pci_name(dev));
37796
37797 - atomic_inc(&pci_parity_count);
37798 + atomic_inc_unchecked(&pci_parity_count);
37799 }
37800
37801 if (status & (PCI_STATUS_DETECTED_PARITY)) {
37802 @@ -595,7 +595,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
37803 "Detected Parity Error on %s\n",
37804 pci_name(dev));
37805
37806 - atomic_inc(&pci_parity_count);
37807 + atomic_inc_unchecked(&pci_parity_count);
37808 }
37809 }
37810
37811 @@ -618,7 +618,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
37812 edac_printk(KERN_CRIT, EDAC_PCI, "Bridge "
37813 "Signaled System Error on %s\n",
37814 pci_name(dev));
37815 - atomic_inc(&pci_nonparity_count);
37816 + atomic_inc_unchecked(&pci_nonparity_count);
37817 }
37818
37819 if (status & (PCI_STATUS_PARITY)) {
37820 @@ -626,7 +626,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
37821 "Master Data Parity Error on "
37822 "%s\n", pci_name(dev));
37823
37824 - atomic_inc(&pci_parity_count);
37825 + atomic_inc_unchecked(&pci_parity_count);
37826 }
37827
37828 if (status & (PCI_STATUS_DETECTED_PARITY)) {
37829 @@ -634,7 +634,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
37830 "Detected Parity Error on %s\n",
37831 pci_name(dev));
37832
37833 - atomic_inc(&pci_parity_count);
37834 + atomic_inc_unchecked(&pci_parity_count);
37835 }
37836 }
37837 }
37838 @@ -672,7 +672,7 @@ void edac_pci_do_parity_check(void)
37839 if (!check_pci_errors)
37840 return;
37841
37842 - before_count = atomic_read(&pci_parity_count);
37843 + before_count = atomic_read_unchecked(&pci_parity_count);
37844
37845 /* scan all PCI devices looking for a Parity Error on devices and
37846 * bridges.
37847 @@ -684,7 +684,7 @@ void edac_pci_do_parity_check(void)
37848 /* Only if operator has selected panic on PCI Error */
37849 if (edac_pci_get_panic_on_pe()) {
37850 /* If the count is different 'after' from 'before' */
37851 - if (before_count != atomic_read(&pci_parity_count))
37852 + if (before_count != atomic_read_unchecked(&pci_parity_count))
37853 panic("EDAC: PCI Parity Error");
37854 }
37855 }
37856 diff --git a/drivers/edac/mce_amd.h b/drivers/edac/mce_amd.h
37857 index 51b7e3a..aa8a3e8 100644
37858 --- a/drivers/edac/mce_amd.h
37859 +++ b/drivers/edac/mce_amd.h
37860 @@ -77,7 +77,7 @@ struct amd_decoder_ops {
37861 bool (*mc0_mce)(u16, u8);
37862 bool (*mc1_mce)(u16, u8);
37863 bool (*mc2_mce)(u16, u8);
37864 -};
37865 +} __no_const;
37866
37867 void amd_report_gart_errors(bool);
37868 void amd_register_ecc_decoder(void (*f)(int, struct mce *));
37869 diff --git a/drivers/firewire/core-card.c b/drivers/firewire/core-card.c
37870 index 57ea7f4..af06b76 100644
37871 --- a/drivers/firewire/core-card.c
37872 +++ b/drivers/firewire/core-card.c
37873 @@ -528,9 +528,9 @@ void fw_card_initialize(struct fw_card *card,
37874 const struct fw_card_driver *driver,
37875 struct device *device)
37876 {
37877 - static atomic_t index = ATOMIC_INIT(-1);
37878 + static atomic_unchecked_t index = ATOMIC_INIT(-1);
37879
37880 - card->index = atomic_inc_return(&index);
37881 + card->index = atomic_inc_return_unchecked(&index);
37882 card->driver = driver;
37883 card->device = device;
37884 card->current_tlabel = 0;
37885 @@ -680,7 +680,7 @@ EXPORT_SYMBOL_GPL(fw_card_release);
37886
37887 void fw_core_remove_card(struct fw_card *card)
37888 {
37889 - struct fw_card_driver dummy_driver = dummy_driver_template;
37890 + fw_card_driver_no_const dummy_driver = dummy_driver_template;
37891
37892 card->driver->update_phy_reg(card, 4,
37893 PHY_LINK_ACTIVE | PHY_CONTENDER, 0);
37894 diff --git a/drivers/firewire/core-device.c b/drivers/firewire/core-device.c
37895 index de4aa40..49ab1f2 100644
37896 --- a/drivers/firewire/core-device.c
37897 +++ b/drivers/firewire/core-device.c
37898 @@ -253,7 +253,7 @@ EXPORT_SYMBOL(fw_device_enable_phys_dma);
37899 struct config_rom_attribute {
37900 struct device_attribute attr;
37901 u32 key;
37902 -};
37903 +} __do_const;
37904
37905 static ssize_t show_immediate(struct device *dev,
37906 struct device_attribute *dattr, char *buf)
37907 diff --git a/drivers/firewire/core-transaction.c b/drivers/firewire/core-transaction.c
37908 index e5af0e3..d318058 100644
37909 --- a/drivers/firewire/core-transaction.c
37910 +++ b/drivers/firewire/core-transaction.c
37911 @@ -38,6 +38,7 @@
37912 #include <linux/timer.h>
37913 #include <linux/types.h>
37914 #include <linux/workqueue.h>
37915 +#include <linux/sched.h>
37916
37917 #include <asm/byteorder.h>
37918
37919 diff --git a/drivers/firewire/core.h b/drivers/firewire/core.h
37920 index 515a42c..5ecf3ba 100644
37921 --- a/drivers/firewire/core.h
37922 +++ b/drivers/firewire/core.h
37923 @@ -111,6 +111,7 @@ struct fw_card_driver {
37924
37925 int (*stop_iso)(struct fw_iso_context *ctx);
37926 };
37927 +typedef struct fw_card_driver __no_const fw_card_driver_no_const;
37928
37929 void fw_card_initialize(struct fw_card *card,
37930 const struct fw_card_driver *driver, struct device *device);
37931 diff --git a/drivers/firmware/dmi-id.c b/drivers/firmware/dmi-id.c
37932 index 94a58a0..f5eba42 100644
37933 --- a/drivers/firmware/dmi-id.c
37934 +++ b/drivers/firmware/dmi-id.c
37935 @@ -16,7 +16,7 @@
37936 struct dmi_device_attribute{
37937 struct device_attribute dev_attr;
37938 int field;
37939 -};
37940 +} __do_const;
37941 #define to_dmi_dev_attr(_dev_attr) \
37942 container_of(_dev_attr, struct dmi_device_attribute, dev_attr)
37943
37944 diff --git a/drivers/firmware/dmi_scan.c b/drivers/firmware/dmi_scan.c
37945 index fa0affb..aa448eb 100644
37946 --- a/drivers/firmware/dmi_scan.c
37947 +++ b/drivers/firmware/dmi_scan.c
37948 @@ -791,7 +791,7 @@ int dmi_walk(void (*decode)(const struct dmi_header *, void *),
37949 if (buf == NULL)
37950 return -1;
37951
37952 - dmi_table(buf, dmi_len, dmi_num, decode, private_data);
37953 + dmi_table((char __force_kernel *)buf, dmi_len, dmi_num, decode, private_data);
37954
37955 iounmap(buf);
37956 return 0;
37957 diff --git a/drivers/firmware/efi/efi.c b/drivers/firmware/efi/efi.c
37958 index 5145fa3..0d3babd 100644
37959 --- a/drivers/firmware/efi/efi.c
37960 +++ b/drivers/firmware/efi/efi.c
37961 @@ -65,14 +65,16 @@ static struct attribute_group efi_subsys_attr_group = {
37962 };
37963
37964 static struct efivars generic_efivars;
37965 -static struct efivar_operations generic_ops;
37966 +static efivar_operations_no_const generic_ops __read_only;
37967
37968 static int generic_ops_register(void)
37969 {
37970 - generic_ops.get_variable = efi.get_variable;
37971 - generic_ops.set_variable = efi.set_variable;
37972 - generic_ops.get_next_variable = efi.get_next_variable;
37973 - generic_ops.query_variable_store = efi_query_variable_store;
37974 + pax_open_kernel();
37975 + *(void **)&generic_ops.get_variable = efi.get_variable;
37976 + *(void **)&generic_ops.set_variable = efi.set_variable;
37977 + *(void **)&generic_ops.get_next_variable = efi.get_next_variable;
37978 + *(void **)&generic_ops.query_variable_store = efi_query_variable_store;
37979 + pax_close_kernel();
37980
37981 return efivars_register(&generic_efivars, &generic_ops, efi_kobj);
37982 }
37983 diff --git a/drivers/firmware/efi/efivars.c b/drivers/firmware/efi/efivars.c
37984 index 8a7432a..28fb839 100644
37985 --- a/drivers/firmware/efi/efivars.c
37986 +++ b/drivers/firmware/efi/efivars.c
37987 @@ -452,7 +452,7 @@ efivar_create_sysfs_entry(struct efivar_entry *new_var)
37988 static int
37989 create_efivars_bin_attributes(void)
37990 {
37991 - struct bin_attribute *attr;
37992 + bin_attribute_no_const *attr;
37993 int error;
37994
37995 /* new_var */
37996 diff --git a/drivers/firmware/google/memconsole.c b/drivers/firmware/google/memconsole.c
37997 index 2a90ba6..07f3733 100644
37998 --- a/drivers/firmware/google/memconsole.c
37999 +++ b/drivers/firmware/google/memconsole.c
38000 @@ -147,7 +147,9 @@ static int __init memconsole_init(void)
38001 if (!found_memconsole())
38002 return -ENODEV;
38003
38004 - memconsole_bin_attr.size = memconsole_length;
38005 + pax_open_kernel();
38006 + *(size_t *)&memconsole_bin_attr.size = memconsole_length;
38007 + pax_close_kernel();
38008
38009 ret = sysfs_create_bin_file(firmware_kobj, &memconsole_bin_attr);
38010
38011 diff --git a/drivers/gpio/gpio-ich.c b/drivers/gpio/gpio-ich.c
38012 index 814addb..0937d7f 100644
38013 --- a/drivers/gpio/gpio-ich.c
38014 +++ b/drivers/gpio/gpio-ich.c
38015 @@ -71,7 +71,7 @@ struct ichx_desc {
38016 /* Some chipsets have quirks, let these use their own request/get */
38017 int (*request)(struct gpio_chip *chip, unsigned offset);
38018 int (*get)(struct gpio_chip *chip, unsigned offset);
38019 -};
38020 +} __do_const;
38021
38022 static struct {
38023 spinlock_t lock;
38024 diff --git a/drivers/gpio/gpio-vr41xx.c b/drivers/gpio/gpio-vr41xx.c
38025 index 9902732..64b62dd 100644
38026 --- a/drivers/gpio/gpio-vr41xx.c
38027 +++ b/drivers/gpio/gpio-vr41xx.c
38028 @@ -204,7 +204,7 @@ static int giu_get_irq(unsigned int irq)
38029 printk(KERN_ERR "spurious GIU interrupt: %04x(%04x),%04x(%04x)\n",
38030 maskl, pendl, maskh, pendh);
38031
38032 - atomic_inc(&irq_err_count);
38033 + atomic_inc_unchecked(&irq_err_count);
38034
38035 return -EINVAL;
38036 }
38037 diff --git a/drivers/gpu/drm/drm_crtc_helper.c b/drivers/gpu/drm/drm_crtc_helper.c
38038 index c722c3b..2ec6040 100644
38039 --- a/drivers/gpu/drm/drm_crtc_helper.c
38040 +++ b/drivers/gpu/drm/drm_crtc_helper.c
38041 @@ -328,7 +328,7 @@ static bool drm_encoder_crtc_ok(struct drm_encoder *encoder,
38042 struct drm_crtc *tmp;
38043 int crtc_mask = 1;
38044
38045 - WARN(!crtc, "checking null crtc?\n");
38046 + BUG_ON(!crtc);
38047
38048 dev = crtc->dev;
38049
38050 diff --git a/drivers/gpu/drm/drm_drv.c b/drivers/gpu/drm/drm_drv.c
38051 index fe58d08..07bc38e 100644
38052 --- a/drivers/gpu/drm/drm_drv.c
38053 +++ b/drivers/gpu/drm/drm_drv.c
38054 @@ -186,7 +186,7 @@ static void drm_legacy_dev_reinit(struct drm_device *dev)
38055 atomic_set(&dev->vma_count, 0);
38056
38057 for (i = 0; i < ARRAY_SIZE(dev->counts); i++)
38058 - atomic_set(&dev->counts[i], 0);
38059 + atomic_set_unchecked(&dev->counts[i], 0);
38060
38061 dev->sigdata.lock = NULL;
38062
38063 @@ -302,7 +302,7 @@ module_exit(drm_core_exit);
38064 /**
38065 * Copy and IOCTL return string to user space
38066 */
38067 -static int drm_copy_field(char *buf, size_t *buf_len, const char *value)
38068 +static int drm_copy_field(char __user *buf, size_t *buf_len, const char *value)
38069 {
38070 int len;
38071
38072 @@ -372,7 +372,7 @@ long drm_ioctl(struct file *filp,
38073 struct drm_file *file_priv = filp->private_data;
38074 struct drm_device *dev;
38075 const struct drm_ioctl_desc *ioctl = NULL;
38076 - drm_ioctl_t *func;
38077 + drm_ioctl_no_const_t func;
38078 unsigned int nr = DRM_IOCTL_NR(cmd);
38079 int retcode = -EINVAL;
38080 char stack_kdata[128];
38081 @@ -385,7 +385,7 @@ long drm_ioctl(struct file *filp,
38082 return -ENODEV;
38083
38084 atomic_inc(&dev->ioctl_count);
38085 - atomic_inc(&dev->counts[_DRM_STAT_IOCTLS]);
38086 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_IOCTLS]);
38087 ++file_priv->ioctl_count;
38088
38089 if ((nr >= DRM_CORE_IOCTL_COUNT) &&
38090 diff --git a/drivers/gpu/drm/drm_fops.c b/drivers/gpu/drm/drm_fops.c
38091 index 3f84277..c627c54 100644
38092 --- a/drivers/gpu/drm/drm_fops.c
38093 +++ b/drivers/gpu/drm/drm_fops.c
38094 @@ -97,7 +97,7 @@ int drm_open(struct inode *inode, struct file *filp)
38095 if (drm_device_is_unplugged(dev))
38096 return -ENODEV;
38097
38098 - if (!dev->open_count++)
38099 + if (local_inc_return(&dev->open_count) == 1)
38100 need_setup = 1;
38101 mutex_lock(&dev->struct_mutex);
38102 old_imapping = inode->i_mapping;
38103 @@ -113,7 +113,7 @@ int drm_open(struct inode *inode, struct file *filp)
38104 retcode = drm_open_helper(inode, filp, dev);
38105 if (retcode)
38106 goto err_undo;
38107 - atomic_inc(&dev->counts[_DRM_STAT_OPENS]);
38108 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_OPENS]);
38109 if (need_setup) {
38110 retcode = drm_setup(dev);
38111 if (retcode)
38112 @@ -128,7 +128,7 @@ err_undo:
38113 iput(container_of(dev->dev_mapping, struct inode, i_data));
38114 dev->dev_mapping = old_mapping;
38115 mutex_unlock(&dev->struct_mutex);
38116 - dev->open_count--;
38117 + local_dec(&dev->open_count);
38118 return retcode;
38119 }
38120 EXPORT_SYMBOL(drm_open);
38121 @@ -405,7 +405,7 @@ int drm_release(struct inode *inode, struct file *filp)
38122
38123 mutex_lock(&drm_global_mutex);
38124
38125 - DRM_DEBUG("open_count = %d\n", dev->open_count);
38126 + DRM_DEBUG("open_count = %ld\n", local_read(&dev->open_count));
38127
38128 if (dev->driver->preclose)
38129 dev->driver->preclose(dev, file_priv);
38130 @@ -414,10 +414,10 @@ int drm_release(struct inode *inode, struct file *filp)
38131 * Begin inline drm_release
38132 */
38133
38134 - DRM_DEBUG("pid = %d, device = 0x%lx, open_count = %d\n",
38135 + DRM_DEBUG("pid = %d, device = 0x%lx, open_count = %ld\n",
38136 task_pid_nr(current),
38137 (long)old_encode_dev(file_priv->minor->device),
38138 - dev->open_count);
38139 + local_read(&dev->open_count));
38140
38141 /* Release any auth tokens that might point to this file_priv,
38142 (do that under the drm_global_mutex) */
38143 @@ -516,8 +516,8 @@ int drm_release(struct inode *inode, struct file *filp)
38144 * End inline drm_release
38145 */
38146
38147 - atomic_inc(&dev->counts[_DRM_STAT_CLOSES]);
38148 - if (!--dev->open_count) {
38149 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_CLOSES]);
38150 + if (local_dec_and_test(&dev->open_count)) {
38151 if (atomic_read(&dev->ioctl_count)) {
38152 DRM_ERROR("Device busy: %d\n",
38153 atomic_read(&dev->ioctl_count));
38154 diff --git a/drivers/gpu/drm/drm_global.c b/drivers/gpu/drm/drm_global.c
38155 index f731116..629842c 100644
38156 --- a/drivers/gpu/drm/drm_global.c
38157 +++ b/drivers/gpu/drm/drm_global.c
38158 @@ -36,7 +36,7 @@
38159 struct drm_global_item {
38160 struct mutex mutex;
38161 void *object;
38162 - int refcount;
38163 + atomic_t refcount;
38164 };
38165
38166 static struct drm_global_item glob[DRM_GLOBAL_NUM];
38167 @@ -49,7 +49,7 @@ void drm_global_init(void)
38168 struct drm_global_item *item = &glob[i];
38169 mutex_init(&item->mutex);
38170 item->object = NULL;
38171 - item->refcount = 0;
38172 + atomic_set(&item->refcount, 0);
38173 }
38174 }
38175
38176 @@ -59,7 +59,7 @@ void drm_global_release(void)
38177 for (i = 0; i < DRM_GLOBAL_NUM; ++i) {
38178 struct drm_global_item *item = &glob[i];
38179 BUG_ON(item->object != NULL);
38180 - BUG_ON(item->refcount != 0);
38181 + BUG_ON(atomic_read(&item->refcount) != 0);
38182 }
38183 }
38184
38185 @@ -70,7 +70,7 @@ int drm_global_item_ref(struct drm_global_reference *ref)
38186 void *object;
38187
38188 mutex_lock(&item->mutex);
38189 - if (item->refcount == 0) {
38190 + if (atomic_read(&item->refcount) == 0) {
38191 item->object = kzalloc(ref->size, GFP_KERNEL);
38192 if (unlikely(item->object == NULL)) {
38193 ret = -ENOMEM;
38194 @@ -83,7 +83,7 @@ int drm_global_item_ref(struct drm_global_reference *ref)
38195 goto out_err;
38196
38197 }
38198 - ++item->refcount;
38199 + atomic_inc(&item->refcount);
38200 ref->object = item->object;
38201 object = item->object;
38202 mutex_unlock(&item->mutex);
38203 @@ -100,9 +100,9 @@ void drm_global_item_unref(struct drm_global_reference *ref)
38204 struct drm_global_item *item = &glob[ref->global_type];
38205
38206 mutex_lock(&item->mutex);
38207 - BUG_ON(item->refcount == 0);
38208 + BUG_ON(atomic_read(&item->refcount) == 0);
38209 BUG_ON(ref->object != item->object);
38210 - if (--item->refcount == 0) {
38211 + if (atomic_dec_and_test(&item->refcount)) {
38212 ref->release(ref);
38213 item->object = NULL;
38214 }
38215 diff --git a/drivers/gpu/drm/drm_info.c b/drivers/gpu/drm/drm_info.c
38216 index 5329832..b503f49 100644
38217 --- a/drivers/gpu/drm/drm_info.c
38218 +++ b/drivers/gpu/drm/drm_info.c
38219 @@ -75,10 +75,14 @@ int drm_vm_info(struct seq_file *m, void *data)
38220 struct drm_local_map *map;
38221 struct drm_map_list *r_list;
38222
38223 - /* Hardcoded from _DRM_FRAME_BUFFER,
38224 - _DRM_REGISTERS, _DRM_SHM, _DRM_AGP, and
38225 - _DRM_SCATTER_GATHER and _DRM_CONSISTENT */
38226 - const char *types[] = { "FB", "REG", "SHM", "AGP", "SG", "PCI" };
38227 + static const char * const types[] = {
38228 + [_DRM_FRAME_BUFFER] = "FB",
38229 + [_DRM_REGISTERS] = "REG",
38230 + [_DRM_SHM] = "SHM",
38231 + [_DRM_AGP] = "AGP",
38232 + [_DRM_SCATTER_GATHER] = "SG",
38233 + [_DRM_CONSISTENT] = "PCI",
38234 + [_DRM_GEM] = "GEM" };
38235 const char *type;
38236 int i;
38237
38238 @@ -89,7 +93,7 @@ int drm_vm_info(struct seq_file *m, void *data)
38239 map = r_list->map;
38240 if (!map)
38241 continue;
38242 - if (map->type < 0 || map->type > 5)
38243 + if (map->type >= ARRAY_SIZE(types))
38244 type = "??";
38245 else
38246 type = types[map->type];
38247 @@ -257,7 +261,11 @@ int drm_vma_info(struct seq_file *m, void *data)
38248 vma->vm_flags & VM_MAYSHARE ? 's' : 'p',
38249 vma->vm_flags & VM_LOCKED ? 'l' : '-',
38250 vma->vm_flags & VM_IO ? 'i' : '-',
38251 +#ifdef CONFIG_GRKERNSEC_HIDESYM
38252 + 0);
38253 +#else
38254 vma->vm_pgoff);
38255 +#endif
38256
38257 #if defined(__i386__)
38258 pgprot = pgprot_val(vma->vm_page_prot);
38259 diff --git a/drivers/gpu/drm/drm_ioc32.c b/drivers/gpu/drm/drm_ioc32.c
38260 index 2f4c434..dd12cd2 100644
38261 --- a/drivers/gpu/drm/drm_ioc32.c
38262 +++ b/drivers/gpu/drm/drm_ioc32.c
38263 @@ -457,7 +457,7 @@ static int compat_drm_infobufs(struct file *file, unsigned int cmd,
38264 request = compat_alloc_user_space(nbytes);
38265 if (!access_ok(VERIFY_WRITE, request, nbytes))
38266 return -EFAULT;
38267 - list = (struct drm_buf_desc *) (request + 1);
38268 + list = (struct drm_buf_desc __user *) (request + 1);
38269
38270 if (__put_user(count, &request->count)
38271 || __put_user(list, &request->list))
38272 @@ -518,7 +518,7 @@ static int compat_drm_mapbufs(struct file *file, unsigned int cmd,
38273 request = compat_alloc_user_space(nbytes);
38274 if (!access_ok(VERIFY_WRITE, request, nbytes))
38275 return -EFAULT;
38276 - list = (struct drm_buf_pub *) (request + 1);
38277 + list = (struct drm_buf_pub __user *) (request + 1);
38278
38279 if (__put_user(count, &request->count)
38280 || __put_user(list, &request->list))
38281 @@ -1016,7 +1016,7 @@ static int compat_drm_wait_vblank(struct file *file, unsigned int cmd,
38282 return 0;
38283 }
38284
38285 -drm_ioctl_compat_t *drm_compat_ioctls[] = {
38286 +drm_ioctl_compat_t drm_compat_ioctls[] = {
38287 [DRM_IOCTL_NR(DRM_IOCTL_VERSION32)] = compat_drm_version,
38288 [DRM_IOCTL_NR(DRM_IOCTL_GET_UNIQUE32)] = compat_drm_getunique,
38289 [DRM_IOCTL_NR(DRM_IOCTL_GET_MAP32)] = compat_drm_getmap,
38290 @@ -1062,7 +1062,6 @@ drm_ioctl_compat_t *drm_compat_ioctls[] = {
38291 long drm_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
38292 {
38293 unsigned int nr = DRM_IOCTL_NR(cmd);
38294 - drm_ioctl_compat_t *fn;
38295 int ret;
38296
38297 /* Assume that ioctls without an explicit compat routine will just
38298 @@ -1072,10 +1071,8 @@ long drm_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
38299 if (nr >= ARRAY_SIZE(drm_compat_ioctls))
38300 return drm_ioctl(filp, cmd, arg);
38301
38302 - fn = drm_compat_ioctls[nr];
38303 -
38304 - if (fn != NULL)
38305 - ret = (*fn) (filp, cmd, arg);
38306 + if (drm_compat_ioctls[nr] != NULL)
38307 + ret = (*drm_compat_ioctls[nr]) (filp, cmd, arg);
38308 else
38309 ret = drm_ioctl(filp, cmd, arg);
38310
38311 diff --git a/drivers/gpu/drm/drm_lock.c b/drivers/gpu/drm/drm_lock.c
38312 index d752c96..fe08455 100644
38313 --- a/drivers/gpu/drm/drm_lock.c
38314 +++ b/drivers/gpu/drm/drm_lock.c
38315 @@ -86,7 +86,7 @@ int drm_lock(struct drm_device *dev, void *data, struct drm_file *file_priv)
38316 if (drm_lock_take(&master->lock, lock->context)) {
38317 master->lock.file_priv = file_priv;
38318 master->lock.lock_time = jiffies;
38319 - atomic_inc(&dev->counts[_DRM_STAT_LOCKS]);
38320 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_LOCKS]);
38321 break; /* Got lock */
38322 }
38323
38324 @@ -157,7 +157,7 @@ int drm_unlock(struct drm_device *dev, void *data, struct drm_file *file_priv)
38325 return -EINVAL;
38326 }
38327
38328 - atomic_inc(&dev->counts[_DRM_STAT_UNLOCKS]);
38329 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_UNLOCKS]);
38330
38331 if (drm_lock_free(&master->lock, lock->context)) {
38332 /* FIXME: Should really bail out here. */
38333 diff --git a/drivers/gpu/drm/drm_stub.c b/drivers/gpu/drm/drm_stub.c
38334 index 39d8645..59e06fa 100644
38335 --- a/drivers/gpu/drm/drm_stub.c
38336 +++ b/drivers/gpu/drm/drm_stub.c
38337 @@ -484,7 +484,7 @@ void drm_unplug_dev(struct drm_device *dev)
38338
38339 drm_device_set_unplugged(dev);
38340
38341 - if (dev->open_count == 0) {
38342 + if (local_read(&dev->open_count) == 0) {
38343 drm_put_dev(dev);
38344 }
38345 mutex_unlock(&drm_global_mutex);
38346 diff --git a/drivers/gpu/drm/drm_sysfs.c b/drivers/gpu/drm/drm_sysfs.c
38347 index 2290b3b..22056a1 100644
38348 --- a/drivers/gpu/drm/drm_sysfs.c
38349 +++ b/drivers/gpu/drm/drm_sysfs.c
38350 @@ -524,7 +524,7 @@ EXPORT_SYMBOL(drm_sysfs_hotplug_event);
38351 int drm_sysfs_device_add(struct drm_minor *minor)
38352 {
38353 int err;
38354 - char *minor_str;
38355 + const char *minor_str;
38356
38357 minor->kdev.parent = minor->dev->dev;
38358
38359 diff --git a/drivers/gpu/drm/i810/i810_dma.c b/drivers/gpu/drm/i810/i810_dma.c
38360 index ab1892eb..d7009ca 100644
38361 --- a/drivers/gpu/drm/i810/i810_dma.c
38362 +++ b/drivers/gpu/drm/i810/i810_dma.c
38363 @@ -944,8 +944,8 @@ static int i810_dma_vertex(struct drm_device *dev, void *data,
38364 dma->buflist[vertex->idx],
38365 vertex->discard, vertex->used);
38366
38367 - atomic_add(vertex->used, &dev->counts[_DRM_STAT_SECONDARY]);
38368 - atomic_inc(&dev->counts[_DRM_STAT_DMA]);
38369 + atomic_add_unchecked(vertex->used, &dev->counts[_DRM_STAT_SECONDARY]);
38370 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_DMA]);
38371 sarea_priv->last_enqueue = dev_priv->counter - 1;
38372 sarea_priv->last_dispatch = (int)hw_status[5];
38373
38374 @@ -1105,8 +1105,8 @@ static int i810_dma_mc(struct drm_device *dev, void *data,
38375 i810_dma_dispatch_mc(dev, dma->buflist[mc->idx], mc->used,
38376 mc->last_render);
38377
38378 - atomic_add(mc->used, &dev->counts[_DRM_STAT_SECONDARY]);
38379 - atomic_inc(&dev->counts[_DRM_STAT_DMA]);
38380 + atomic_add_unchecked(mc->used, &dev->counts[_DRM_STAT_SECONDARY]);
38381 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_DMA]);
38382 sarea_priv->last_enqueue = dev_priv->counter - 1;
38383 sarea_priv->last_dispatch = (int)hw_status[5];
38384
38385 diff --git a/drivers/gpu/drm/i810/i810_drv.h b/drivers/gpu/drm/i810/i810_drv.h
38386 index d4d16ed..8fb0b51 100644
38387 --- a/drivers/gpu/drm/i810/i810_drv.h
38388 +++ b/drivers/gpu/drm/i810/i810_drv.h
38389 @@ -108,8 +108,8 @@ typedef struct drm_i810_private {
38390 int page_flipping;
38391
38392 wait_queue_head_t irq_queue;
38393 - atomic_t irq_received;
38394 - atomic_t irq_emitted;
38395 + atomic_unchecked_t irq_received;
38396 + atomic_unchecked_t irq_emitted;
38397
38398 int front_offset;
38399 } drm_i810_private_t;
38400 diff --git a/drivers/gpu/drm/i915/i915_debugfs.c b/drivers/gpu/drm/i915/i915_debugfs.c
38401 index a6f4cb5..6b2beb2 100644
38402 --- a/drivers/gpu/drm/i915/i915_debugfs.c
38403 +++ b/drivers/gpu/drm/i915/i915_debugfs.c
38404 @@ -624,7 +624,7 @@ static int i915_interrupt_info(struct seq_file *m, void *data)
38405 I915_READ(GTIMR));
38406 }
38407 seq_printf(m, "Interrupts received: %d\n",
38408 - atomic_read(&dev_priv->irq_received));
38409 + atomic_read_unchecked(&dev_priv->irq_received));
38410 for_each_ring(ring, dev_priv, i) {
38411 if (IS_GEN6(dev) || IS_GEN7(dev)) {
38412 seq_printf(m,
38413 diff --git a/drivers/gpu/drm/i915/i915_dma.c b/drivers/gpu/drm/i915/i915_dma.c
38414 index d5c784d..06e5c36 100644
38415 --- a/drivers/gpu/drm/i915/i915_dma.c
38416 +++ b/drivers/gpu/drm/i915/i915_dma.c
38417 @@ -1263,7 +1263,7 @@ static bool i915_switcheroo_can_switch(struct pci_dev *pdev)
38418 bool can_switch;
38419
38420 spin_lock(&dev->count_lock);
38421 - can_switch = (dev->open_count == 0);
38422 + can_switch = (local_read(&dev->open_count) == 0);
38423 spin_unlock(&dev->count_lock);
38424 return can_switch;
38425 }
38426 diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
38427 index ab0f2c0..53c1bda 100644
38428 --- a/drivers/gpu/drm/i915/i915_drv.h
38429 +++ b/drivers/gpu/drm/i915/i915_drv.h
38430 @@ -1181,7 +1181,7 @@ typedef struct drm_i915_private {
38431 drm_dma_handle_t *status_page_dmah;
38432 struct resource mch_res;
38433
38434 - atomic_t irq_received;
38435 + atomic_unchecked_t irq_received;
38436
38437 /* protects the irq masks */
38438 spinlock_t irq_lock;
38439 diff --git a/drivers/gpu/drm/i915/i915_gem_execbuffer.c b/drivers/gpu/drm/i915/i915_gem_execbuffer.c
38440 index bf34577..3fd2ffa 100644
38441 --- a/drivers/gpu/drm/i915/i915_gem_execbuffer.c
38442 +++ b/drivers/gpu/drm/i915/i915_gem_execbuffer.c
38443 @@ -768,9 +768,9 @@ i915_gem_check_execbuffer(struct drm_i915_gem_execbuffer2 *exec)
38444
38445 static int
38446 validate_exec_list(struct drm_i915_gem_exec_object2 *exec,
38447 - int count)
38448 + unsigned int count)
38449 {
38450 - int i;
38451 + unsigned int i;
38452 int relocs_total = 0;
38453 int relocs_max = INT_MAX / sizeof(struct drm_i915_gem_relocation_entry);
38454
38455 diff --git a/drivers/gpu/drm/i915/i915_ioc32.c b/drivers/gpu/drm/i915/i915_ioc32.c
38456 index 3c59584..500f2e9 100644
38457 --- a/drivers/gpu/drm/i915/i915_ioc32.c
38458 +++ b/drivers/gpu/drm/i915/i915_ioc32.c
38459 @@ -181,7 +181,7 @@ static int compat_i915_alloc(struct file *file, unsigned int cmd,
38460 (unsigned long)request);
38461 }
38462
38463 -static drm_ioctl_compat_t *i915_compat_ioctls[] = {
38464 +static drm_ioctl_compat_t i915_compat_ioctls[] = {
38465 [DRM_I915_BATCHBUFFER] = compat_i915_batchbuffer,
38466 [DRM_I915_CMDBUFFER] = compat_i915_cmdbuffer,
38467 [DRM_I915_GETPARAM] = compat_i915_getparam,
38468 @@ -202,18 +202,15 @@ static drm_ioctl_compat_t *i915_compat_ioctls[] = {
38469 long i915_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
38470 {
38471 unsigned int nr = DRM_IOCTL_NR(cmd);
38472 - drm_ioctl_compat_t *fn = NULL;
38473 int ret;
38474
38475 if (nr < DRM_COMMAND_BASE)
38476 return drm_compat_ioctl(filp, cmd, arg);
38477
38478 - if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(i915_compat_ioctls))
38479 - fn = i915_compat_ioctls[nr - DRM_COMMAND_BASE];
38480 -
38481 - if (fn != NULL)
38482 + if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(i915_compat_ioctls)) {
38483 + drm_ioctl_compat_t fn = i915_compat_ioctls[nr - DRM_COMMAND_BASE];
38484 ret = (*fn) (filp, cmd, arg);
38485 - else
38486 + } else
38487 ret = drm_ioctl(filp, cmd, arg);
38488
38489 return ret;
38490 diff --git a/drivers/gpu/drm/i915/i915_irq.c b/drivers/gpu/drm/i915/i915_irq.c
38491 index 4b91228..590c643 100644
38492 --- a/drivers/gpu/drm/i915/i915_irq.c
38493 +++ b/drivers/gpu/drm/i915/i915_irq.c
38494 @@ -1085,7 +1085,7 @@ static irqreturn_t valleyview_irq_handler(int irq, void *arg)
38495 int pipe;
38496 u32 pipe_stats[I915_MAX_PIPES];
38497
38498 - atomic_inc(&dev_priv->irq_received);
38499 + atomic_inc_unchecked(&dev_priv->irq_received);
38500
38501 while (true) {
38502 iir = I915_READ(VLV_IIR);
38503 @@ -1390,7 +1390,7 @@ static irqreturn_t ironlake_irq_handler(int irq, void *arg)
38504 irqreturn_t ret = IRQ_NONE;
38505 bool err_int_reenable = false;
38506
38507 - atomic_inc(&dev_priv->irq_received);
38508 + atomic_inc_unchecked(&dev_priv->irq_received);
38509
38510 /* We get interrupts on unclaimed registers, so check for this before we
38511 * do any I915_{READ,WRITE}. */
38512 @@ -2146,7 +2146,7 @@ static void ironlake_irq_preinstall(struct drm_device *dev)
38513 {
38514 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
38515
38516 - atomic_set(&dev_priv->irq_received, 0);
38517 + atomic_set_unchecked(&dev_priv->irq_received, 0);
38518
38519 I915_WRITE(HWSTAM, 0xeffe);
38520
38521 @@ -2164,7 +2164,7 @@ static void valleyview_irq_preinstall(struct drm_device *dev)
38522 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
38523 int pipe;
38524
38525 - atomic_set(&dev_priv->irq_received, 0);
38526 + atomic_set_unchecked(&dev_priv->irq_received, 0);
38527
38528 /* VLV magic */
38529 I915_WRITE(VLV_IMR, 0);
38530 @@ -2452,7 +2452,7 @@ static void i8xx_irq_preinstall(struct drm_device * dev)
38531 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
38532 int pipe;
38533
38534 - atomic_set(&dev_priv->irq_received, 0);
38535 + atomic_set_unchecked(&dev_priv->irq_received, 0);
38536
38537 for_each_pipe(pipe)
38538 I915_WRITE(PIPESTAT(pipe), 0);
38539 @@ -2530,7 +2530,7 @@ static irqreturn_t i8xx_irq_handler(int irq, void *arg)
38540 I915_DISPLAY_PLANE_A_FLIP_PENDING_INTERRUPT |
38541 I915_DISPLAY_PLANE_B_FLIP_PENDING_INTERRUPT;
38542
38543 - atomic_inc(&dev_priv->irq_received);
38544 + atomic_inc_unchecked(&dev_priv->irq_received);
38545
38546 iir = I915_READ16(IIR);
38547 if (iir == 0)
38548 @@ -2604,7 +2604,7 @@ static void i915_irq_preinstall(struct drm_device * dev)
38549 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
38550 int pipe;
38551
38552 - atomic_set(&dev_priv->irq_received, 0);
38553 + atomic_set_unchecked(&dev_priv->irq_received, 0);
38554
38555 if (I915_HAS_HOTPLUG(dev)) {
38556 I915_WRITE(PORT_HOTPLUG_EN, 0);
38557 @@ -2703,7 +2703,7 @@ static irqreturn_t i915_irq_handler(int irq, void *arg)
38558 I915_DISPLAY_PLANE_B_FLIP_PENDING_INTERRUPT;
38559 int pipe, ret = IRQ_NONE;
38560
38561 - atomic_inc(&dev_priv->irq_received);
38562 + atomic_inc_unchecked(&dev_priv->irq_received);
38563
38564 iir = I915_READ(IIR);
38565 do {
38566 @@ -2827,7 +2827,7 @@ static void i965_irq_preinstall(struct drm_device * dev)
38567 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
38568 int pipe;
38569
38570 - atomic_set(&dev_priv->irq_received, 0);
38571 + atomic_set_unchecked(&dev_priv->irq_received, 0);
38572
38573 I915_WRITE(PORT_HOTPLUG_EN, 0);
38574 I915_WRITE(PORT_HOTPLUG_STAT, I915_READ(PORT_HOTPLUG_STAT));
38575 @@ -2941,7 +2941,7 @@ static irqreturn_t i965_irq_handler(int irq, void *arg)
38576 I915_DISPLAY_PLANE_A_FLIP_PENDING_INTERRUPT |
38577 I915_DISPLAY_PLANE_B_FLIP_PENDING_INTERRUPT;
38578
38579 - atomic_inc(&dev_priv->irq_received);
38580 + atomic_inc_unchecked(&dev_priv->irq_received);
38581
38582 iir = I915_READ(IIR);
38583
38584 diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
38585 index 333aa1b..0183e38 100644
38586 --- a/drivers/gpu/drm/i915/intel_display.c
38587 +++ b/drivers/gpu/drm/i915/intel_display.c
38588 @@ -9976,13 +9976,13 @@ struct intel_quirk {
38589 int subsystem_vendor;
38590 int subsystem_device;
38591 void (*hook)(struct drm_device *dev);
38592 -};
38593 +} __do_const;
38594
38595 /* For systems that don't have a meaningful PCI subdevice/subvendor ID */
38596 struct intel_dmi_quirk {
38597 void (*hook)(struct drm_device *dev);
38598 const struct dmi_system_id (*dmi_id_list)[];
38599 -};
38600 +} __do_const;
38601
38602 static int intel_dmi_reverse_brightness(const struct dmi_system_id *id)
38603 {
38604 @@ -9990,18 +9990,20 @@ static int intel_dmi_reverse_brightness(const struct dmi_system_id *id)
38605 return 1;
38606 }
38607
38608 -static const struct intel_dmi_quirk intel_dmi_quirks[] = {
38609 +static const struct dmi_system_id intel_dmi_quirks_table[] = {
38610 {
38611 - .dmi_id_list = &(const struct dmi_system_id[]) {
38612 - {
38613 - .callback = intel_dmi_reverse_brightness,
38614 - .ident = "NCR Corporation",
38615 - .matches = {DMI_MATCH(DMI_SYS_VENDOR, "NCR Corporation"),
38616 - DMI_MATCH(DMI_PRODUCT_NAME, ""),
38617 - },
38618 - },
38619 - { } /* terminating entry */
38620 + .callback = intel_dmi_reverse_brightness,
38621 + .ident = "NCR Corporation",
38622 + .matches = {DMI_MATCH(DMI_SYS_VENDOR, "NCR Corporation"),
38623 + DMI_MATCH(DMI_PRODUCT_NAME, ""),
38624 },
38625 + },
38626 + { } /* terminating entry */
38627 +};
38628 +
38629 +static const struct intel_dmi_quirk intel_dmi_quirks[] = {
38630 + {
38631 + .dmi_id_list = &intel_dmi_quirks_table,
38632 .hook = quirk_invert_brightness,
38633 },
38634 };
38635 diff --git a/drivers/gpu/drm/mga/mga_drv.h b/drivers/gpu/drm/mga/mga_drv.h
38636 index ca4bc54..ee598a2 100644
38637 --- a/drivers/gpu/drm/mga/mga_drv.h
38638 +++ b/drivers/gpu/drm/mga/mga_drv.h
38639 @@ -120,9 +120,9 @@ typedef struct drm_mga_private {
38640 u32 clear_cmd;
38641 u32 maccess;
38642
38643 - atomic_t vbl_received; /**< Number of vblanks received. */
38644 + atomic_unchecked_t vbl_received; /**< Number of vblanks received. */
38645 wait_queue_head_t fence_queue;
38646 - atomic_t last_fence_retired;
38647 + atomic_unchecked_t last_fence_retired;
38648 u32 next_fence_to_post;
38649
38650 unsigned int fb_cpp;
38651 diff --git a/drivers/gpu/drm/mga/mga_ioc32.c b/drivers/gpu/drm/mga/mga_ioc32.c
38652 index 709e90d..89a1c0d 100644
38653 --- a/drivers/gpu/drm/mga/mga_ioc32.c
38654 +++ b/drivers/gpu/drm/mga/mga_ioc32.c
38655 @@ -189,7 +189,7 @@ static int compat_mga_dma_bootstrap(struct file *file, unsigned int cmd,
38656 return 0;
38657 }
38658
38659 -drm_ioctl_compat_t *mga_compat_ioctls[] = {
38660 +drm_ioctl_compat_t mga_compat_ioctls[] = {
38661 [DRM_MGA_INIT] = compat_mga_init,
38662 [DRM_MGA_GETPARAM] = compat_mga_getparam,
38663 [DRM_MGA_DMA_BOOTSTRAP] = compat_mga_dma_bootstrap,
38664 @@ -207,18 +207,15 @@ drm_ioctl_compat_t *mga_compat_ioctls[] = {
38665 long mga_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
38666 {
38667 unsigned int nr = DRM_IOCTL_NR(cmd);
38668 - drm_ioctl_compat_t *fn = NULL;
38669 int ret;
38670
38671 if (nr < DRM_COMMAND_BASE)
38672 return drm_compat_ioctl(filp, cmd, arg);
38673
38674 - if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(mga_compat_ioctls))
38675 - fn = mga_compat_ioctls[nr - DRM_COMMAND_BASE];
38676 -
38677 - if (fn != NULL)
38678 + if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(mga_compat_ioctls)) {
38679 + drm_ioctl_compat_t fn = mga_compat_ioctls[nr - DRM_COMMAND_BASE];
38680 ret = (*fn) (filp, cmd, arg);
38681 - else
38682 + } else
38683 ret = drm_ioctl(filp, cmd, arg);
38684
38685 return ret;
38686 diff --git a/drivers/gpu/drm/mga/mga_irq.c b/drivers/gpu/drm/mga/mga_irq.c
38687 index 598c281..60d590e 100644
38688 --- a/drivers/gpu/drm/mga/mga_irq.c
38689 +++ b/drivers/gpu/drm/mga/mga_irq.c
38690 @@ -43,7 +43,7 @@ u32 mga_get_vblank_counter(struct drm_device *dev, int crtc)
38691 if (crtc != 0)
38692 return 0;
38693
38694 - return atomic_read(&dev_priv->vbl_received);
38695 + return atomic_read_unchecked(&dev_priv->vbl_received);
38696 }
38697
38698
38699 @@ -59,7 +59,7 @@ irqreturn_t mga_driver_irq_handler(DRM_IRQ_ARGS)
38700 /* VBLANK interrupt */
38701 if (status & MGA_VLINEPEN) {
38702 MGA_WRITE(MGA_ICLEAR, MGA_VLINEICLR);
38703 - atomic_inc(&dev_priv->vbl_received);
38704 + atomic_inc_unchecked(&dev_priv->vbl_received);
38705 drm_handle_vblank(dev, 0);
38706 handled = 1;
38707 }
38708 @@ -78,7 +78,7 @@ irqreturn_t mga_driver_irq_handler(DRM_IRQ_ARGS)
38709 if ((prim_start & ~0x03) != (prim_end & ~0x03))
38710 MGA_WRITE(MGA_PRIMEND, prim_end);
38711
38712 - atomic_inc(&dev_priv->last_fence_retired);
38713 + atomic_inc_unchecked(&dev_priv->last_fence_retired);
38714 DRM_WAKEUP(&dev_priv->fence_queue);
38715 handled = 1;
38716 }
38717 @@ -129,7 +129,7 @@ int mga_driver_fence_wait(struct drm_device *dev, unsigned int *sequence)
38718 * using fences.
38719 */
38720 DRM_WAIT_ON(ret, dev_priv->fence_queue, 3 * DRM_HZ,
38721 - (((cur_fence = atomic_read(&dev_priv->last_fence_retired))
38722 + (((cur_fence = atomic_read_unchecked(&dev_priv->last_fence_retired))
38723 - *sequence) <= (1 << 23)));
38724
38725 *sequence = cur_fence;
38726 diff --git a/drivers/gpu/drm/nouveau/nouveau_bios.c b/drivers/gpu/drm/nouveau/nouveau_bios.c
38727 index 3e72876..d1c15ad 100644
38728 --- a/drivers/gpu/drm/nouveau/nouveau_bios.c
38729 +++ b/drivers/gpu/drm/nouveau/nouveau_bios.c
38730 @@ -965,7 +965,7 @@ static int parse_bit_tmds_tbl_entry(struct drm_device *dev, struct nvbios *bios,
38731 struct bit_table {
38732 const char id;
38733 int (* const parse_fn)(struct drm_device *, struct nvbios *, struct bit_entry *);
38734 -};
38735 +} __no_const;
38736
38737 #define BIT_TABLE(id, funcid) ((struct bit_table){ id, parse_bit_##funcid##_tbl_entry })
38738
38739 diff --git a/drivers/gpu/drm/nouveau/nouveau_drm.h b/drivers/gpu/drm/nouveau/nouveau_drm.h
38740 index 994fd6e..6e12565 100644
38741 --- a/drivers/gpu/drm/nouveau/nouveau_drm.h
38742 +++ b/drivers/gpu/drm/nouveau/nouveau_drm.h
38743 @@ -94,7 +94,6 @@ struct nouveau_drm {
38744 struct drm_global_reference mem_global_ref;
38745 struct ttm_bo_global_ref bo_global_ref;
38746 struct ttm_bo_device bdev;
38747 - atomic_t validate_sequence;
38748 int (*move)(struct nouveau_channel *,
38749 struct ttm_buffer_object *,
38750 struct ttm_mem_reg *, struct ttm_mem_reg *);
38751 diff --git a/drivers/gpu/drm/nouveau/nouveau_ioc32.c b/drivers/gpu/drm/nouveau/nouveau_ioc32.c
38752 index c1a7e5a..38b8539 100644
38753 --- a/drivers/gpu/drm/nouveau/nouveau_ioc32.c
38754 +++ b/drivers/gpu/drm/nouveau/nouveau_ioc32.c
38755 @@ -50,7 +50,7 @@ long nouveau_compat_ioctl(struct file *filp, unsigned int cmd,
38756 unsigned long arg)
38757 {
38758 unsigned int nr = DRM_IOCTL_NR(cmd);
38759 - drm_ioctl_compat_t *fn = NULL;
38760 + drm_ioctl_compat_t fn = NULL;
38761 int ret;
38762
38763 if (nr < DRM_COMMAND_BASE)
38764 diff --git a/drivers/gpu/drm/nouveau/nouveau_vga.c b/drivers/gpu/drm/nouveau/nouveau_vga.c
38765 index 81638d7..2e45854 100644
38766 --- a/drivers/gpu/drm/nouveau/nouveau_vga.c
38767 +++ b/drivers/gpu/drm/nouveau/nouveau_vga.c
38768 @@ -65,7 +65,7 @@ nouveau_switcheroo_can_switch(struct pci_dev *pdev)
38769 bool can_switch;
38770
38771 spin_lock(&dev->count_lock);
38772 - can_switch = (dev->open_count == 0);
38773 + can_switch = (local_read(&dev->open_count) == 0);
38774 spin_unlock(&dev->count_lock);
38775 return can_switch;
38776 }
38777 diff --git a/drivers/gpu/drm/qxl/qxl_cmd.c b/drivers/gpu/drm/qxl/qxl_cmd.c
38778 index eb89653..613cf71 100644
38779 --- a/drivers/gpu/drm/qxl/qxl_cmd.c
38780 +++ b/drivers/gpu/drm/qxl/qxl_cmd.c
38781 @@ -285,27 +285,27 @@ static int wait_for_io_cmd_user(struct qxl_device *qdev, uint8_t val, long port,
38782 int ret;
38783
38784 mutex_lock(&qdev->async_io_mutex);
38785 - irq_num = atomic_read(&qdev->irq_received_io_cmd);
38786 + irq_num = atomic_read_unchecked(&qdev->irq_received_io_cmd);
38787 if (qdev->last_sent_io_cmd > irq_num) {
38788 if (intr)
38789 ret = wait_event_interruptible_timeout(qdev->io_cmd_event,
38790 - atomic_read(&qdev->irq_received_io_cmd) > irq_num, 5*HZ);
38791 + atomic_read_unchecked(&qdev->irq_received_io_cmd) > irq_num, 5*HZ);
38792 else
38793 ret = wait_event_timeout(qdev->io_cmd_event,
38794 - atomic_read(&qdev->irq_received_io_cmd) > irq_num, 5*HZ);
38795 + atomic_read_unchecked(&qdev->irq_received_io_cmd) > irq_num, 5*HZ);
38796 /* 0 is timeout, just bail the "hw" has gone away */
38797 if (ret <= 0)
38798 goto out;
38799 - irq_num = atomic_read(&qdev->irq_received_io_cmd);
38800 + irq_num = atomic_read_unchecked(&qdev->irq_received_io_cmd);
38801 }
38802 outb(val, addr);
38803 qdev->last_sent_io_cmd = irq_num + 1;
38804 if (intr)
38805 ret = wait_event_interruptible_timeout(qdev->io_cmd_event,
38806 - atomic_read(&qdev->irq_received_io_cmd) > irq_num, 5*HZ);
38807 + atomic_read_unchecked(&qdev->irq_received_io_cmd) > irq_num, 5*HZ);
38808 else
38809 ret = wait_event_timeout(qdev->io_cmd_event,
38810 - atomic_read(&qdev->irq_received_io_cmd) > irq_num, 5*HZ);
38811 + atomic_read_unchecked(&qdev->irq_received_io_cmd) > irq_num, 5*HZ);
38812 out:
38813 if (ret > 0)
38814 ret = 0;
38815 diff --git a/drivers/gpu/drm/qxl/qxl_debugfs.c b/drivers/gpu/drm/qxl/qxl_debugfs.c
38816 index c3c2bbd..bc3c0fb 100644
38817 --- a/drivers/gpu/drm/qxl/qxl_debugfs.c
38818 +++ b/drivers/gpu/drm/qxl/qxl_debugfs.c
38819 @@ -42,10 +42,10 @@ qxl_debugfs_irq_received(struct seq_file *m, void *data)
38820 struct drm_info_node *node = (struct drm_info_node *) m->private;
38821 struct qxl_device *qdev = node->minor->dev->dev_private;
38822
38823 - seq_printf(m, "%d\n", atomic_read(&qdev->irq_received));
38824 - seq_printf(m, "%d\n", atomic_read(&qdev->irq_received_display));
38825 - seq_printf(m, "%d\n", atomic_read(&qdev->irq_received_cursor));
38826 - seq_printf(m, "%d\n", atomic_read(&qdev->irq_received_io_cmd));
38827 + seq_printf(m, "%d\n", atomic_read_unchecked(&qdev->irq_received));
38828 + seq_printf(m, "%d\n", atomic_read_unchecked(&qdev->irq_received_display));
38829 + seq_printf(m, "%d\n", atomic_read_unchecked(&qdev->irq_received_cursor));
38830 + seq_printf(m, "%d\n", atomic_read_unchecked(&qdev->irq_received_io_cmd));
38831 seq_printf(m, "%d\n", qdev->irq_received_error);
38832 return 0;
38833 }
38834 diff --git a/drivers/gpu/drm/qxl/qxl_drv.h b/drivers/gpu/drm/qxl/qxl_drv.h
38835 index f7c9add..fb971d2 100644
38836 --- a/drivers/gpu/drm/qxl/qxl_drv.h
38837 +++ b/drivers/gpu/drm/qxl/qxl_drv.h
38838 @@ -290,10 +290,10 @@ struct qxl_device {
38839 unsigned int last_sent_io_cmd;
38840
38841 /* interrupt handling */
38842 - atomic_t irq_received;
38843 - atomic_t irq_received_display;
38844 - atomic_t irq_received_cursor;
38845 - atomic_t irq_received_io_cmd;
38846 + atomic_unchecked_t irq_received;
38847 + atomic_unchecked_t irq_received_display;
38848 + atomic_unchecked_t irq_received_cursor;
38849 + atomic_unchecked_t irq_received_io_cmd;
38850 unsigned irq_received_error;
38851 wait_queue_head_t display_event;
38852 wait_queue_head_t cursor_event;
38853 diff --git a/drivers/gpu/drm/qxl/qxl_irq.c b/drivers/gpu/drm/qxl/qxl_irq.c
38854 index 21393dc..329f3a9 100644
38855 --- a/drivers/gpu/drm/qxl/qxl_irq.c
38856 +++ b/drivers/gpu/drm/qxl/qxl_irq.c
38857 @@ -33,19 +33,19 @@ irqreturn_t qxl_irq_handler(DRM_IRQ_ARGS)
38858
38859 pending = xchg(&qdev->ram_header->int_pending, 0);
38860
38861 - atomic_inc(&qdev->irq_received);
38862 + atomic_inc_unchecked(&qdev->irq_received);
38863
38864 if (pending & QXL_INTERRUPT_DISPLAY) {
38865 - atomic_inc(&qdev->irq_received_display);
38866 + atomic_inc_unchecked(&qdev->irq_received_display);
38867 wake_up_all(&qdev->display_event);
38868 qxl_queue_garbage_collect(qdev, false);
38869 }
38870 if (pending & QXL_INTERRUPT_CURSOR) {
38871 - atomic_inc(&qdev->irq_received_cursor);
38872 + atomic_inc_unchecked(&qdev->irq_received_cursor);
38873 wake_up_all(&qdev->cursor_event);
38874 }
38875 if (pending & QXL_INTERRUPT_IO_CMD) {
38876 - atomic_inc(&qdev->irq_received_io_cmd);
38877 + atomic_inc_unchecked(&qdev->irq_received_io_cmd);
38878 wake_up_all(&qdev->io_cmd_event);
38879 }
38880 if (pending & QXL_INTERRUPT_ERROR) {
38881 @@ -82,10 +82,10 @@ int qxl_irq_init(struct qxl_device *qdev)
38882 init_waitqueue_head(&qdev->io_cmd_event);
38883 INIT_WORK(&qdev->client_monitors_config_work,
38884 qxl_client_monitors_config_work_func);
38885 - atomic_set(&qdev->irq_received, 0);
38886 - atomic_set(&qdev->irq_received_display, 0);
38887 - atomic_set(&qdev->irq_received_cursor, 0);
38888 - atomic_set(&qdev->irq_received_io_cmd, 0);
38889 + atomic_set_unchecked(&qdev->irq_received, 0);
38890 + atomic_set_unchecked(&qdev->irq_received_display, 0);
38891 + atomic_set_unchecked(&qdev->irq_received_cursor, 0);
38892 + atomic_set_unchecked(&qdev->irq_received_io_cmd, 0);
38893 qdev->irq_received_error = 0;
38894 ret = drm_irq_install(qdev->ddev);
38895 qdev->ram_header->int_mask = QXL_INTERRUPT_MASK;
38896 diff --git a/drivers/gpu/drm/qxl/qxl_ttm.c b/drivers/gpu/drm/qxl/qxl_ttm.c
38897 index 037786d..2a95e33 100644
38898 --- a/drivers/gpu/drm/qxl/qxl_ttm.c
38899 +++ b/drivers/gpu/drm/qxl/qxl_ttm.c
38900 @@ -103,7 +103,7 @@ static void qxl_ttm_global_fini(struct qxl_device *qdev)
38901 }
38902 }
38903
38904 -static struct vm_operations_struct qxl_ttm_vm_ops;
38905 +static vm_operations_struct_no_const qxl_ttm_vm_ops __read_only;
38906 static const struct vm_operations_struct *ttm_vm_ops;
38907
38908 static int qxl_ttm_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
38909 @@ -147,8 +147,10 @@ int qxl_mmap(struct file *filp, struct vm_area_struct *vma)
38910 return r;
38911 if (unlikely(ttm_vm_ops == NULL)) {
38912 ttm_vm_ops = vma->vm_ops;
38913 + pax_open_kernel();
38914 qxl_ttm_vm_ops = *ttm_vm_ops;
38915 qxl_ttm_vm_ops.fault = &qxl_ttm_fault;
38916 + pax_close_kernel();
38917 }
38918 vma->vm_ops = &qxl_ttm_vm_ops;
38919 return 0;
38920 @@ -558,25 +560,23 @@ static int qxl_mm_dump_table(struct seq_file *m, void *data)
38921 static int qxl_ttm_debugfs_init(struct qxl_device *qdev)
38922 {
38923 #if defined(CONFIG_DEBUG_FS)
38924 - static struct drm_info_list qxl_mem_types_list[QXL_DEBUGFS_MEM_TYPES];
38925 - static char qxl_mem_types_names[QXL_DEBUGFS_MEM_TYPES][32];
38926 - unsigned i;
38927 + static struct drm_info_list qxl_mem_types_list[QXL_DEBUGFS_MEM_TYPES] = {
38928 + {
38929 + .name = "qxl_mem_mm",
38930 + .show = &qxl_mm_dump_table,
38931 + },
38932 + {
38933 + .name = "qxl_surf_mm",
38934 + .show = &qxl_mm_dump_table,
38935 + }
38936 + };
38937
38938 - for (i = 0; i < QXL_DEBUGFS_MEM_TYPES; i++) {
38939 - if (i == 0)
38940 - sprintf(qxl_mem_types_names[i], "qxl_mem_mm");
38941 - else
38942 - sprintf(qxl_mem_types_names[i], "qxl_surf_mm");
38943 - qxl_mem_types_list[i].name = qxl_mem_types_names[i];
38944 - qxl_mem_types_list[i].show = &qxl_mm_dump_table;
38945 - qxl_mem_types_list[i].driver_features = 0;
38946 - if (i == 0)
38947 - qxl_mem_types_list[i].data = qdev->mman.bdev.man[TTM_PL_VRAM].priv;
38948 - else
38949 - qxl_mem_types_list[i].data = qdev->mman.bdev.man[TTM_PL_PRIV0].priv;
38950 + pax_open_kernel();
38951 + *(void **)&qxl_mem_types_list[0].data = qdev->mman.bdev.man[TTM_PL_VRAM].priv;
38952 + *(void **)&qxl_mem_types_list[1].data = qdev->mman.bdev.man[TTM_PL_PRIV0].priv;
38953 + pax_close_kernel();
38954
38955 - }
38956 - return qxl_debugfs_add_files(qdev, qxl_mem_types_list, i);
38957 + return qxl_debugfs_add_files(qdev, qxl_mem_types_list, QXL_DEBUGFS_MEM_TYPES);
38958 #else
38959 return 0;
38960 #endif
38961 diff --git a/drivers/gpu/drm/r128/r128_cce.c b/drivers/gpu/drm/r128/r128_cce.c
38962 index c451257..0ad2134 100644
38963 --- a/drivers/gpu/drm/r128/r128_cce.c
38964 +++ b/drivers/gpu/drm/r128/r128_cce.c
38965 @@ -377,7 +377,7 @@ static int r128_do_init_cce(struct drm_device *dev, drm_r128_init_t *init)
38966
38967 /* GH: Simple idle check.
38968 */
38969 - atomic_set(&dev_priv->idle_count, 0);
38970 + atomic_set_unchecked(&dev_priv->idle_count, 0);
38971
38972 /* We don't support anything other than bus-mastering ring mode,
38973 * but the ring can be in either AGP or PCI space for the ring
38974 diff --git a/drivers/gpu/drm/r128/r128_drv.h b/drivers/gpu/drm/r128/r128_drv.h
38975 index 56eb5e3..c4ec43d 100644
38976 --- a/drivers/gpu/drm/r128/r128_drv.h
38977 +++ b/drivers/gpu/drm/r128/r128_drv.h
38978 @@ -90,14 +90,14 @@ typedef struct drm_r128_private {
38979 int is_pci;
38980 unsigned long cce_buffers_offset;
38981
38982 - atomic_t idle_count;
38983 + atomic_unchecked_t idle_count;
38984
38985 int page_flipping;
38986 int current_page;
38987 u32 crtc_offset;
38988 u32 crtc_offset_cntl;
38989
38990 - atomic_t vbl_received;
38991 + atomic_unchecked_t vbl_received;
38992
38993 u32 color_fmt;
38994 unsigned int front_offset;
38995 diff --git a/drivers/gpu/drm/r128/r128_ioc32.c b/drivers/gpu/drm/r128/r128_ioc32.c
38996 index a954c54..9cc595c 100644
38997 --- a/drivers/gpu/drm/r128/r128_ioc32.c
38998 +++ b/drivers/gpu/drm/r128/r128_ioc32.c
38999 @@ -177,7 +177,7 @@ static int compat_r128_getparam(struct file *file, unsigned int cmd,
39000 return drm_ioctl(file, DRM_IOCTL_R128_GETPARAM, (unsigned long)getparam);
39001 }
39002
39003 -drm_ioctl_compat_t *r128_compat_ioctls[] = {
39004 +drm_ioctl_compat_t r128_compat_ioctls[] = {
39005 [DRM_R128_INIT] = compat_r128_init,
39006 [DRM_R128_DEPTH] = compat_r128_depth,
39007 [DRM_R128_STIPPLE] = compat_r128_stipple,
39008 @@ -196,18 +196,15 @@ drm_ioctl_compat_t *r128_compat_ioctls[] = {
39009 long r128_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
39010 {
39011 unsigned int nr = DRM_IOCTL_NR(cmd);
39012 - drm_ioctl_compat_t *fn = NULL;
39013 int ret;
39014
39015 if (nr < DRM_COMMAND_BASE)
39016 return drm_compat_ioctl(filp, cmd, arg);
39017
39018 - if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(r128_compat_ioctls))
39019 - fn = r128_compat_ioctls[nr - DRM_COMMAND_BASE];
39020 -
39021 - if (fn != NULL)
39022 + if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(r128_compat_ioctls)) {
39023 + drm_ioctl_compat_t fn = r128_compat_ioctls[nr - DRM_COMMAND_BASE];
39024 ret = (*fn) (filp, cmd, arg);
39025 - else
39026 + } else
39027 ret = drm_ioctl(filp, cmd, arg);
39028
39029 return ret;
39030 diff --git a/drivers/gpu/drm/r128/r128_irq.c b/drivers/gpu/drm/r128/r128_irq.c
39031 index 2ea4f09..d391371 100644
39032 --- a/drivers/gpu/drm/r128/r128_irq.c
39033 +++ b/drivers/gpu/drm/r128/r128_irq.c
39034 @@ -41,7 +41,7 @@ u32 r128_get_vblank_counter(struct drm_device *dev, int crtc)
39035 if (crtc != 0)
39036 return 0;
39037
39038 - return atomic_read(&dev_priv->vbl_received);
39039 + return atomic_read_unchecked(&dev_priv->vbl_received);
39040 }
39041
39042 irqreturn_t r128_driver_irq_handler(DRM_IRQ_ARGS)
39043 @@ -55,7 +55,7 @@ irqreturn_t r128_driver_irq_handler(DRM_IRQ_ARGS)
39044 /* VBLANK interrupt */
39045 if (status & R128_CRTC_VBLANK_INT) {
39046 R128_WRITE(R128_GEN_INT_STATUS, R128_CRTC_VBLANK_INT_AK);
39047 - atomic_inc(&dev_priv->vbl_received);
39048 + atomic_inc_unchecked(&dev_priv->vbl_received);
39049 drm_handle_vblank(dev, 0);
39050 return IRQ_HANDLED;
39051 }
39052 diff --git a/drivers/gpu/drm/r128/r128_state.c b/drivers/gpu/drm/r128/r128_state.c
39053 index 01dd9ae..6352f04 100644
39054 --- a/drivers/gpu/drm/r128/r128_state.c
39055 +++ b/drivers/gpu/drm/r128/r128_state.c
39056 @@ -320,10 +320,10 @@ static void r128_clear_box(drm_r128_private_t *dev_priv,
39057
39058 static void r128_cce_performance_boxes(drm_r128_private_t *dev_priv)
39059 {
39060 - if (atomic_read(&dev_priv->idle_count) == 0)
39061 + if (atomic_read_unchecked(&dev_priv->idle_count) == 0)
39062 r128_clear_box(dev_priv, 64, 4, 8, 8, 0, 255, 0);
39063 else
39064 - atomic_set(&dev_priv->idle_count, 0);
39065 + atomic_set_unchecked(&dev_priv->idle_count, 0);
39066 }
39067
39068 #endif
39069 diff --git a/drivers/gpu/drm/radeon/mkregtable.c b/drivers/gpu/drm/radeon/mkregtable.c
39070 index af85299..ed9ac8d 100644
39071 --- a/drivers/gpu/drm/radeon/mkregtable.c
39072 +++ b/drivers/gpu/drm/radeon/mkregtable.c
39073 @@ -624,14 +624,14 @@ static int parser_auth(struct table *t, const char *filename)
39074 regex_t mask_rex;
39075 regmatch_t match[4];
39076 char buf[1024];
39077 - size_t end;
39078 + long end;
39079 int len;
39080 int done = 0;
39081 int r;
39082 unsigned o;
39083 struct offset *offset;
39084 char last_reg_s[10];
39085 - int last_reg;
39086 + unsigned long last_reg;
39087
39088 if (regcomp
39089 (&mask_rex, "(0x[0-9a-fA-F]*) *([_a-zA-Z0-9]*)", REG_EXTENDED)) {
39090 diff --git a/drivers/gpu/drm/radeon/radeon_device.c b/drivers/gpu/drm/radeon/radeon_device.c
39091 index 841d0e0..9eaa268 100644
39092 --- a/drivers/gpu/drm/radeon/radeon_device.c
39093 +++ b/drivers/gpu/drm/radeon/radeon_device.c
39094 @@ -1117,7 +1117,7 @@ static bool radeon_switcheroo_can_switch(struct pci_dev *pdev)
39095 bool can_switch;
39096
39097 spin_lock(&dev->count_lock);
39098 - can_switch = (dev->open_count == 0);
39099 + can_switch = (local_read(&dev->open_count) == 0);
39100 spin_unlock(&dev->count_lock);
39101 return can_switch;
39102 }
39103 diff --git a/drivers/gpu/drm/radeon/radeon_drv.h b/drivers/gpu/drm/radeon/radeon_drv.h
39104 index b369d42..8dd04eb 100644
39105 --- a/drivers/gpu/drm/radeon/radeon_drv.h
39106 +++ b/drivers/gpu/drm/radeon/radeon_drv.h
39107 @@ -258,7 +258,7 @@ typedef struct drm_radeon_private {
39108
39109 /* SW interrupt */
39110 wait_queue_head_t swi_queue;
39111 - atomic_t swi_emitted;
39112 + atomic_unchecked_t swi_emitted;
39113 int vblank_crtc;
39114 uint32_t irq_enable_reg;
39115 uint32_t r500_disp_irq_reg;
39116 diff --git a/drivers/gpu/drm/radeon/radeon_ioc32.c b/drivers/gpu/drm/radeon/radeon_ioc32.c
39117 index c180df8..5fd8186 100644
39118 --- a/drivers/gpu/drm/radeon/radeon_ioc32.c
39119 +++ b/drivers/gpu/drm/radeon/radeon_ioc32.c
39120 @@ -358,7 +358,7 @@ static int compat_radeon_cp_setparam(struct file *file, unsigned int cmd,
39121 request = compat_alloc_user_space(sizeof(*request));
39122 if (!access_ok(VERIFY_WRITE, request, sizeof(*request))
39123 || __put_user(req32.param, &request->param)
39124 - || __put_user((void __user *)(unsigned long)req32.value,
39125 + || __put_user((unsigned long)req32.value,
39126 &request->value))
39127 return -EFAULT;
39128
39129 @@ -368,7 +368,7 @@ static int compat_radeon_cp_setparam(struct file *file, unsigned int cmd,
39130 #define compat_radeon_cp_setparam NULL
39131 #endif /* X86_64 || IA64 */
39132
39133 -static drm_ioctl_compat_t *radeon_compat_ioctls[] = {
39134 +static drm_ioctl_compat_t radeon_compat_ioctls[] = {
39135 [DRM_RADEON_CP_INIT] = compat_radeon_cp_init,
39136 [DRM_RADEON_CLEAR] = compat_radeon_cp_clear,
39137 [DRM_RADEON_STIPPLE] = compat_radeon_cp_stipple,
39138 @@ -393,18 +393,15 @@ static drm_ioctl_compat_t *radeon_compat_ioctls[] = {
39139 long radeon_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
39140 {
39141 unsigned int nr = DRM_IOCTL_NR(cmd);
39142 - drm_ioctl_compat_t *fn = NULL;
39143 int ret;
39144
39145 if (nr < DRM_COMMAND_BASE)
39146 return drm_compat_ioctl(filp, cmd, arg);
39147
39148 - if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(radeon_compat_ioctls))
39149 - fn = radeon_compat_ioctls[nr - DRM_COMMAND_BASE];
39150 -
39151 - if (fn != NULL)
39152 + if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(radeon_compat_ioctls)) {
39153 + drm_ioctl_compat_t fn = radeon_compat_ioctls[nr - DRM_COMMAND_BASE];
39154 ret = (*fn) (filp, cmd, arg);
39155 - else
39156 + } else
39157 ret = drm_ioctl(filp, cmd, arg);
39158
39159 return ret;
39160 diff --git a/drivers/gpu/drm/radeon/radeon_irq.c b/drivers/gpu/drm/radeon/radeon_irq.c
39161 index 8d68e97..9dcfed8 100644
39162 --- a/drivers/gpu/drm/radeon/radeon_irq.c
39163 +++ b/drivers/gpu/drm/radeon/radeon_irq.c
39164 @@ -226,8 +226,8 @@ static int radeon_emit_irq(struct drm_device * dev)
39165 unsigned int ret;
39166 RING_LOCALS;
39167
39168 - atomic_inc(&dev_priv->swi_emitted);
39169 - ret = atomic_read(&dev_priv->swi_emitted);
39170 + atomic_inc_unchecked(&dev_priv->swi_emitted);
39171 + ret = atomic_read_unchecked(&dev_priv->swi_emitted);
39172
39173 BEGIN_RING(4);
39174 OUT_RING_REG(RADEON_LAST_SWI_REG, ret);
39175 @@ -353,7 +353,7 @@ int radeon_driver_irq_postinstall(struct drm_device *dev)
39176 drm_radeon_private_t *dev_priv =
39177 (drm_radeon_private_t *) dev->dev_private;
39178
39179 - atomic_set(&dev_priv->swi_emitted, 0);
39180 + atomic_set_unchecked(&dev_priv->swi_emitted, 0);
39181 DRM_INIT_WAITQUEUE(&dev_priv->swi_queue);
39182
39183 dev->max_vblank_count = 0x001fffff;
39184 diff --git a/drivers/gpu/drm/radeon/radeon_state.c b/drivers/gpu/drm/radeon/radeon_state.c
39185 index 4d20910..6726b6d 100644
39186 --- a/drivers/gpu/drm/radeon/radeon_state.c
39187 +++ b/drivers/gpu/drm/radeon/radeon_state.c
39188 @@ -2168,7 +2168,7 @@ static int radeon_cp_clear(struct drm_device *dev, void *data, struct drm_file *
39189 if (sarea_priv->nbox > RADEON_NR_SAREA_CLIPRECTS)
39190 sarea_priv->nbox = RADEON_NR_SAREA_CLIPRECTS;
39191
39192 - if (DRM_COPY_FROM_USER(&depth_boxes, clear->depth_boxes,
39193 + if (sarea_priv->nbox > RADEON_NR_SAREA_CLIPRECTS || DRM_COPY_FROM_USER(&depth_boxes, clear->depth_boxes,
39194 sarea_priv->nbox * sizeof(depth_boxes[0])))
39195 return -EFAULT;
39196
39197 @@ -3031,7 +3031,7 @@ static int radeon_cp_getparam(struct drm_device *dev, void *data, struct drm_fil
39198 {
39199 drm_radeon_private_t *dev_priv = dev->dev_private;
39200 drm_radeon_getparam_t *param = data;
39201 - int value;
39202 + int value = 0;
39203
39204 DRM_DEBUG("pid=%d\n", DRM_CURRENTPID);
39205
39206 diff --git a/drivers/gpu/drm/radeon/radeon_ttm.c b/drivers/gpu/drm/radeon/radeon_ttm.c
39207 index 71245d6..94c556d 100644
39208 --- a/drivers/gpu/drm/radeon/radeon_ttm.c
39209 +++ b/drivers/gpu/drm/radeon/radeon_ttm.c
39210 @@ -784,7 +784,7 @@ void radeon_ttm_set_active_vram_size(struct radeon_device *rdev, u64 size)
39211 man->size = size >> PAGE_SHIFT;
39212 }
39213
39214 -static struct vm_operations_struct radeon_ttm_vm_ops;
39215 +static vm_operations_struct_no_const radeon_ttm_vm_ops __read_only;
39216 static const struct vm_operations_struct *ttm_vm_ops = NULL;
39217
39218 static int radeon_ttm_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
39219 @@ -825,8 +825,10 @@ int radeon_mmap(struct file *filp, struct vm_area_struct *vma)
39220 }
39221 if (unlikely(ttm_vm_ops == NULL)) {
39222 ttm_vm_ops = vma->vm_ops;
39223 + pax_open_kernel();
39224 radeon_ttm_vm_ops = *ttm_vm_ops;
39225 radeon_ttm_vm_ops.fault = &radeon_ttm_fault;
39226 + pax_close_kernel();
39227 }
39228 vma->vm_ops = &radeon_ttm_vm_ops;
39229 return 0;
39230 @@ -855,38 +857,33 @@ static int radeon_mm_dump_table(struct seq_file *m, void *data)
39231 static int radeon_ttm_debugfs_init(struct radeon_device *rdev)
39232 {
39233 #if defined(CONFIG_DEBUG_FS)
39234 - static struct drm_info_list radeon_mem_types_list[RADEON_DEBUGFS_MEM_TYPES+2];
39235 - static char radeon_mem_types_names[RADEON_DEBUGFS_MEM_TYPES+2][32];
39236 - unsigned i;
39237 + static struct drm_info_list radeon_mem_types_list[RADEON_DEBUGFS_MEM_TYPES+2] = {
39238 + {
39239 + .name = "radeon_vram_mm",
39240 + .show = &radeon_mm_dump_table,
39241 + },
39242 + {
39243 + .name = "radeon_gtt_mm",
39244 + .show = &radeon_mm_dump_table,
39245 + },
39246 + {
39247 + .name = "ttm_page_pool",
39248 + .show = &ttm_page_alloc_debugfs,
39249 + },
39250 + {
39251 + .name = "ttm_dma_page_pool",
39252 + .show = &ttm_dma_page_alloc_debugfs,
39253 + },
39254 + };
39255 + unsigned i = RADEON_DEBUGFS_MEM_TYPES + 1;
39256
39257 - for (i = 0; i < RADEON_DEBUGFS_MEM_TYPES; i++) {
39258 - if (i == 0)
39259 - sprintf(radeon_mem_types_names[i], "radeon_vram_mm");
39260 - else
39261 - sprintf(radeon_mem_types_names[i], "radeon_gtt_mm");
39262 - radeon_mem_types_list[i].name = radeon_mem_types_names[i];
39263 - radeon_mem_types_list[i].show = &radeon_mm_dump_table;
39264 - radeon_mem_types_list[i].driver_features = 0;
39265 - if (i == 0)
39266 - radeon_mem_types_list[i].data = rdev->mman.bdev.man[TTM_PL_VRAM].priv;
39267 - else
39268 - radeon_mem_types_list[i].data = rdev->mman.bdev.man[TTM_PL_TT].priv;
39269 -
39270 - }
39271 - /* Add ttm page pool to debugfs */
39272 - sprintf(radeon_mem_types_names[i], "ttm_page_pool");
39273 - radeon_mem_types_list[i].name = radeon_mem_types_names[i];
39274 - radeon_mem_types_list[i].show = &ttm_page_alloc_debugfs;
39275 - radeon_mem_types_list[i].driver_features = 0;
39276 - radeon_mem_types_list[i++].data = NULL;
39277 + pax_open_kernel();
39278 + *(void **)&radeon_mem_types_list[0].data = rdev->mman.bdev.man[TTM_PL_VRAM].priv;
39279 + *(void **)&radeon_mem_types_list[1].data = rdev->mman.bdev.man[TTM_PL_TT].priv;
39280 + pax_close_kernel();
39281 #ifdef CONFIG_SWIOTLB
39282 - if (swiotlb_nr_tbl()) {
39283 - sprintf(radeon_mem_types_names[i], "ttm_dma_page_pool");
39284 - radeon_mem_types_list[i].name = radeon_mem_types_names[i];
39285 - radeon_mem_types_list[i].show = &ttm_dma_page_alloc_debugfs;
39286 - radeon_mem_types_list[i].driver_features = 0;
39287 - radeon_mem_types_list[i++].data = NULL;
39288 - }
39289 + if (swiotlb_nr_tbl())
39290 + i++;
39291 #endif
39292 return radeon_debugfs_add_files(rdev, radeon_mem_types_list, i);
39293
39294 diff --git a/drivers/gpu/drm/radeon/rs690.c b/drivers/gpu/drm/radeon/rs690.c
39295 index 1447d79..40b2a5b 100644
39296 --- a/drivers/gpu/drm/radeon/rs690.c
39297 +++ b/drivers/gpu/drm/radeon/rs690.c
39298 @@ -345,9 +345,11 @@ static void rs690_crtc_bandwidth_compute(struct radeon_device *rdev,
39299 if (max_bandwidth.full > rdev->pm.sideport_bandwidth.full &&
39300 rdev->pm.sideport_bandwidth.full)
39301 max_bandwidth = rdev->pm.sideport_bandwidth;
39302 - read_delay_latency.full = dfixed_const(370 * 800 * 1000);
39303 + read_delay_latency.full = dfixed_const(800 * 1000);
39304 read_delay_latency.full = dfixed_div(read_delay_latency,
39305 rdev->pm.igp_sideport_mclk);
39306 + a.full = dfixed_const(370);
39307 + read_delay_latency.full = dfixed_mul(read_delay_latency, a);
39308 } else {
39309 if (max_bandwidth.full > rdev->pm.k8_bandwidth.full &&
39310 rdev->pm.k8_bandwidth.full)
39311 diff --git a/drivers/gpu/drm/ttm/ttm_memory.c b/drivers/gpu/drm/ttm/ttm_memory.c
39312 index dbc2def..0a9f710 100644
39313 --- a/drivers/gpu/drm/ttm/ttm_memory.c
39314 +++ b/drivers/gpu/drm/ttm/ttm_memory.c
39315 @@ -264,7 +264,7 @@ static int ttm_mem_init_kernel_zone(struct ttm_mem_global *glob,
39316 zone->glob = glob;
39317 glob->zone_kernel = zone;
39318 ret = kobject_init_and_add(
39319 - &zone->kobj, &ttm_mem_zone_kobj_type, &glob->kobj, zone->name);
39320 + &zone->kobj, &ttm_mem_zone_kobj_type, &glob->kobj, "%s", zone->name);
39321 if (unlikely(ret != 0)) {
39322 kobject_put(&zone->kobj);
39323 return ret;
39324 @@ -347,7 +347,7 @@ static int ttm_mem_init_dma32_zone(struct ttm_mem_global *glob,
39325 zone->glob = glob;
39326 glob->zone_dma32 = zone;
39327 ret = kobject_init_and_add(
39328 - &zone->kobj, &ttm_mem_zone_kobj_type, &glob->kobj, zone->name);
39329 + &zone->kobj, &ttm_mem_zone_kobj_type, &glob->kobj, "%s", zone->name);
39330 if (unlikely(ret != 0)) {
39331 kobject_put(&zone->kobj);
39332 return ret;
39333 diff --git a/drivers/gpu/drm/ttm/ttm_page_alloc.c b/drivers/gpu/drm/ttm/ttm_page_alloc.c
39334 index 863bef9..cba15cf 100644
39335 --- a/drivers/gpu/drm/ttm/ttm_page_alloc.c
39336 +++ b/drivers/gpu/drm/ttm/ttm_page_alloc.c
39337 @@ -391,9 +391,9 @@ out:
39338 static unsigned long
39339 ttm_pool_shrink_scan(struct shrinker *shrink, struct shrink_control *sc)
39340 {
39341 - static atomic_t start_pool = ATOMIC_INIT(0);
39342 + static atomic_unchecked_t start_pool = ATOMIC_INIT(0);
39343 unsigned i;
39344 - unsigned pool_offset = atomic_add_return(1, &start_pool);
39345 + unsigned pool_offset = atomic_add_return_unchecked(1, &start_pool);
39346 struct ttm_page_pool *pool;
39347 int shrink_pages = sc->nr_to_scan;
39348 unsigned long freed = 0;
39349 diff --git a/drivers/gpu/drm/udl/udl_fb.c b/drivers/gpu/drm/udl/udl_fb.c
39350 index 97e9d61..bf23c461 100644
39351 --- a/drivers/gpu/drm/udl/udl_fb.c
39352 +++ b/drivers/gpu/drm/udl/udl_fb.c
39353 @@ -367,7 +367,6 @@ static int udl_fb_release(struct fb_info *info, int user)
39354 fb_deferred_io_cleanup(info);
39355 kfree(info->fbdefio);
39356 info->fbdefio = NULL;
39357 - info->fbops->fb_mmap = udl_fb_mmap;
39358 }
39359
39360 pr_warn("released /dev/fb%d user=%d count=%d\n",
39361 diff --git a/drivers/gpu/drm/via/via_drv.h b/drivers/gpu/drm/via/via_drv.h
39362 index a811ef2..ff99b05 100644
39363 --- a/drivers/gpu/drm/via/via_drv.h
39364 +++ b/drivers/gpu/drm/via/via_drv.h
39365 @@ -51,7 +51,7 @@ typedef struct drm_via_ring_buffer {
39366 typedef uint32_t maskarray_t[5];
39367
39368 typedef struct drm_via_irq {
39369 - atomic_t irq_received;
39370 + atomic_unchecked_t irq_received;
39371 uint32_t pending_mask;
39372 uint32_t enable_mask;
39373 wait_queue_head_t irq_queue;
39374 @@ -75,7 +75,7 @@ typedef struct drm_via_private {
39375 struct timeval last_vblank;
39376 int last_vblank_valid;
39377 unsigned usec_per_vblank;
39378 - atomic_t vbl_received;
39379 + atomic_unchecked_t vbl_received;
39380 drm_via_state_t hc_state;
39381 char pci_buf[VIA_PCI_BUF_SIZE];
39382 const uint32_t *fire_offsets[VIA_FIRE_BUF_SIZE];
39383 diff --git a/drivers/gpu/drm/via/via_irq.c b/drivers/gpu/drm/via/via_irq.c
39384 index ac98964..5dbf512 100644
39385 --- a/drivers/gpu/drm/via/via_irq.c
39386 +++ b/drivers/gpu/drm/via/via_irq.c
39387 @@ -101,7 +101,7 @@ u32 via_get_vblank_counter(struct drm_device *dev, int crtc)
39388 if (crtc != 0)
39389 return 0;
39390
39391 - return atomic_read(&dev_priv->vbl_received);
39392 + return atomic_read_unchecked(&dev_priv->vbl_received);
39393 }
39394
39395 irqreturn_t via_driver_irq_handler(DRM_IRQ_ARGS)
39396 @@ -116,8 +116,8 @@ irqreturn_t via_driver_irq_handler(DRM_IRQ_ARGS)
39397
39398 status = VIA_READ(VIA_REG_INTERRUPT);
39399 if (status & VIA_IRQ_VBLANK_PENDING) {
39400 - atomic_inc(&dev_priv->vbl_received);
39401 - if (!(atomic_read(&dev_priv->vbl_received) & 0x0F)) {
39402 + atomic_inc_unchecked(&dev_priv->vbl_received);
39403 + if (!(atomic_read_unchecked(&dev_priv->vbl_received) & 0x0F)) {
39404 do_gettimeofday(&cur_vblank);
39405 if (dev_priv->last_vblank_valid) {
39406 dev_priv->usec_per_vblank =
39407 @@ -127,7 +127,7 @@ irqreturn_t via_driver_irq_handler(DRM_IRQ_ARGS)
39408 dev_priv->last_vblank = cur_vblank;
39409 dev_priv->last_vblank_valid = 1;
39410 }
39411 - if (!(atomic_read(&dev_priv->vbl_received) & 0xFF)) {
39412 + if (!(atomic_read_unchecked(&dev_priv->vbl_received) & 0xFF)) {
39413 DRM_DEBUG("US per vblank is: %u\n",
39414 dev_priv->usec_per_vblank);
39415 }
39416 @@ -137,7 +137,7 @@ irqreturn_t via_driver_irq_handler(DRM_IRQ_ARGS)
39417
39418 for (i = 0; i < dev_priv->num_irqs; ++i) {
39419 if (status & cur_irq->pending_mask) {
39420 - atomic_inc(&cur_irq->irq_received);
39421 + atomic_inc_unchecked(&cur_irq->irq_received);
39422 DRM_WAKEUP(&cur_irq->irq_queue);
39423 handled = 1;
39424 if (dev_priv->irq_map[drm_via_irq_dma0_td] == i)
39425 @@ -242,11 +242,11 @@ via_driver_irq_wait(struct drm_device *dev, unsigned int irq, int force_sequence
39426 DRM_WAIT_ON(ret, cur_irq->irq_queue, 3 * DRM_HZ,
39427 ((VIA_READ(masks[irq][2]) & masks[irq][3]) ==
39428 masks[irq][4]));
39429 - cur_irq_sequence = atomic_read(&cur_irq->irq_received);
39430 + cur_irq_sequence = atomic_read_unchecked(&cur_irq->irq_received);
39431 } else {
39432 DRM_WAIT_ON(ret, cur_irq->irq_queue, 3 * DRM_HZ,
39433 (((cur_irq_sequence =
39434 - atomic_read(&cur_irq->irq_received)) -
39435 + atomic_read_unchecked(&cur_irq->irq_received)) -
39436 *sequence) <= (1 << 23)));
39437 }
39438 *sequence = cur_irq_sequence;
39439 @@ -284,7 +284,7 @@ void via_driver_irq_preinstall(struct drm_device *dev)
39440 }
39441
39442 for (i = 0; i < dev_priv->num_irqs; ++i) {
39443 - atomic_set(&cur_irq->irq_received, 0);
39444 + atomic_set_unchecked(&cur_irq->irq_received, 0);
39445 cur_irq->enable_mask = dev_priv->irq_masks[i][0];
39446 cur_irq->pending_mask = dev_priv->irq_masks[i][1];
39447 DRM_INIT_WAITQUEUE(&cur_irq->irq_queue);
39448 @@ -366,7 +366,7 @@ int via_wait_irq(struct drm_device *dev, void *data, struct drm_file *file_priv)
39449 switch (irqwait->request.type & ~VIA_IRQ_FLAGS_MASK) {
39450 case VIA_IRQ_RELATIVE:
39451 irqwait->request.sequence +=
39452 - atomic_read(&cur_irq->irq_received);
39453 + atomic_read_unchecked(&cur_irq->irq_received);
39454 irqwait->request.type &= ~_DRM_VBLANK_RELATIVE;
39455 case VIA_IRQ_ABSOLUTE:
39456 break;
39457 diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
39458 index 150ec64..f5165f2 100644
39459 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
39460 +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
39461 @@ -290,7 +290,7 @@ struct vmw_private {
39462 * Fencing and IRQs.
39463 */
39464
39465 - atomic_t marker_seq;
39466 + atomic_unchecked_t marker_seq;
39467 wait_queue_head_t fence_queue;
39468 wait_queue_head_t fifo_queue;
39469 int fence_queue_waiters; /* Protected by hw_mutex */
39470 diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_fifo.c b/drivers/gpu/drm/vmwgfx/vmwgfx_fifo.c
39471 index 3eb1486..0a47ee9 100644
39472 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_fifo.c
39473 +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_fifo.c
39474 @@ -137,7 +137,7 @@ int vmw_fifo_init(struct vmw_private *dev_priv, struct vmw_fifo_state *fifo)
39475 (unsigned int) min,
39476 (unsigned int) fifo->capabilities);
39477
39478 - atomic_set(&dev_priv->marker_seq, dev_priv->last_read_seqno);
39479 + atomic_set_unchecked(&dev_priv->marker_seq, dev_priv->last_read_seqno);
39480 iowrite32(dev_priv->last_read_seqno, fifo_mem + SVGA_FIFO_FENCE);
39481 vmw_marker_queue_init(&fifo->marker_queue);
39482 return vmw_fifo_send_fence(dev_priv, &dummy);
39483 @@ -355,7 +355,7 @@ void *vmw_fifo_reserve(struct vmw_private *dev_priv, uint32_t bytes)
39484 if (reserveable)
39485 iowrite32(bytes, fifo_mem +
39486 SVGA_FIFO_RESERVED);
39487 - return fifo_mem + (next_cmd >> 2);
39488 + return (__le32 __force_kernel *)fifo_mem + (next_cmd >> 2);
39489 } else {
39490 need_bounce = true;
39491 }
39492 @@ -475,7 +475,7 @@ int vmw_fifo_send_fence(struct vmw_private *dev_priv, uint32_t *seqno)
39493
39494 fm = vmw_fifo_reserve(dev_priv, bytes);
39495 if (unlikely(fm == NULL)) {
39496 - *seqno = atomic_read(&dev_priv->marker_seq);
39497 + *seqno = atomic_read_unchecked(&dev_priv->marker_seq);
39498 ret = -ENOMEM;
39499 (void)vmw_fallback_wait(dev_priv, false, true, *seqno,
39500 false, 3*HZ);
39501 @@ -483,7 +483,7 @@ int vmw_fifo_send_fence(struct vmw_private *dev_priv, uint32_t *seqno)
39502 }
39503
39504 do {
39505 - *seqno = atomic_add_return(1, &dev_priv->marker_seq);
39506 + *seqno = atomic_add_return_unchecked(1, &dev_priv->marker_seq);
39507 } while (*seqno == 0);
39508
39509 if (!(fifo_state->capabilities & SVGA_FIFO_CAP_FENCE)) {
39510 diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_ioctl.c b/drivers/gpu/drm/vmwgfx/vmwgfx_ioctl.c
39511 index c509d40..3b640c3 100644
39512 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_ioctl.c
39513 +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_ioctl.c
39514 @@ -138,7 +138,7 @@ int vmw_present_ioctl(struct drm_device *dev, void *data,
39515 int ret;
39516
39517 num_clips = arg->num_clips;
39518 - clips_ptr = (struct drm_vmw_rect *)(unsigned long)arg->clips_ptr;
39519 + clips_ptr = (struct drm_vmw_rect __user *)(unsigned long)arg->clips_ptr;
39520
39521 if (unlikely(num_clips == 0))
39522 return 0;
39523 @@ -222,7 +222,7 @@ int vmw_present_readback_ioctl(struct drm_device *dev, void *data,
39524 int ret;
39525
39526 num_clips = arg->num_clips;
39527 - clips_ptr = (struct drm_vmw_rect *)(unsigned long)arg->clips_ptr;
39528 + clips_ptr = (struct drm_vmw_rect __user *)(unsigned long)arg->clips_ptr;
39529
39530 if (unlikely(num_clips == 0))
39531 return 0;
39532 diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_irq.c b/drivers/gpu/drm/vmwgfx/vmwgfx_irq.c
39533 index 4640adb..e1384ed 100644
39534 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_irq.c
39535 +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_irq.c
39536 @@ -107,7 +107,7 @@ bool vmw_seqno_passed(struct vmw_private *dev_priv,
39537 * emitted. Then the fence is stale and signaled.
39538 */
39539
39540 - ret = ((atomic_read(&dev_priv->marker_seq) - seqno)
39541 + ret = ((atomic_read_unchecked(&dev_priv->marker_seq) - seqno)
39542 > VMW_FENCE_WRAP);
39543
39544 return ret;
39545 @@ -138,7 +138,7 @@ int vmw_fallback_wait(struct vmw_private *dev_priv,
39546
39547 if (fifo_idle)
39548 down_read(&fifo_state->rwsem);
39549 - signal_seq = atomic_read(&dev_priv->marker_seq);
39550 + signal_seq = atomic_read_unchecked(&dev_priv->marker_seq);
39551 ret = 0;
39552
39553 for (;;) {
39554 diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_marker.c b/drivers/gpu/drm/vmwgfx/vmwgfx_marker.c
39555 index 8a8725c2..afed796 100644
39556 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_marker.c
39557 +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_marker.c
39558 @@ -151,7 +151,7 @@ int vmw_wait_lag(struct vmw_private *dev_priv,
39559 while (!vmw_lag_lt(queue, us)) {
39560 spin_lock(&queue->lock);
39561 if (list_empty(&queue->head))
39562 - seqno = atomic_read(&dev_priv->marker_seq);
39563 + seqno = atomic_read_unchecked(&dev_priv->marker_seq);
39564 else {
39565 marker = list_first_entry(&queue->head,
39566 struct vmw_marker, head);
39567 diff --git a/drivers/gpu/host1x/drm/dc.c b/drivers/gpu/host1x/drm/dc.c
39568 index b1a05ad..1c9d899 100644
39569 --- a/drivers/gpu/host1x/drm/dc.c
39570 +++ b/drivers/gpu/host1x/drm/dc.c
39571 @@ -1004,7 +1004,7 @@ static int tegra_dc_debugfs_init(struct tegra_dc *dc, struct drm_minor *minor)
39572 }
39573
39574 for (i = 0; i < ARRAY_SIZE(debugfs_files); i++)
39575 - dc->debugfs_files[i].data = dc;
39576 + *(void **)&dc->debugfs_files[i].data = dc;
39577
39578 err = drm_debugfs_create_files(dc->debugfs_files,
39579 ARRAY_SIZE(debugfs_files),
39580 diff --git a/drivers/gpu/vga/vga_switcheroo.c b/drivers/gpu/vga/vga_switcheroo.c
39581 index ec0ae2d..dc0780b 100644
39582 --- a/drivers/gpu/vga/vga_switcheroo.c
39583 +++ b/drivers/gpu/vga/vga_switcheroo.c
39584 @@ -643,7 +643,7 @@ static int vga_switcheroo_runtime_resume(struct device *dev)
39585
39586 /* this version is for the case where the power switch is separate
39587 to the device being powered down. */
39588 -int vga_switcheroo_init_domain_pm_ops(struct device *dev, struct dev_pm_domain *domain)
39589 +int vga_switcheroo_init_domain_pm_ops(struct device *dev, dev_pm_domain_no_const *domain)
39590 {
39591 /* copy over all the bus versions */
39592 if (dev->bus && dev->bus->pm) {
39593 @@ -688,7 +688,7 @@ static int vga_switcheroo_runtime_resume_hdmi_audio(struct device *dev)
39594 return ret;
39595 }
39596
39597 -int vga_switcheroo_init_domain_pm_optimus_hdmi_audio(struct device *dev, struct dev_pm_domain *domain)
39598 +int vga_switcheroo_init_domain_pm_optimus_hdmi_audio(struct device *dev, dev_pm_domain_no_const *domain)
39599 {
39600 /* copy over all the bus versions */
39601 if (dev->bus && dev->bus->pm) {
39602 diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c
39603 index c08b5c1..6c3d50b 100644
39604 --- a/drivers/hid/hid-core.c
39605 +++ b/drivers/hid/hid-core.c
39606 @@ -2415,7 +2415,7 @@ EXPORT_SYMBOL_GPL(hid_ignore);
39607
39608 int hid_add_device(struct hid_device *hdev)
39609 {
39610 - static atomic_t id = ATOMIC_INIT(0);
39611 + static atomic_unchecked_t id = ATOMIC_INIT(0);
39612 int ret;
39613
39614 if (WARN_ON(hdev->status & HID_STAT_ADDED))
39615 @@ -2449,7 +2449,7 @@ int hid_add_device(struct hid_device *hdev)
39616 /* XXX hack, any other cleaner solution after the driver core
39617 * is converted to allow more than 20 bytes as the device name? */
39618 dev_set_name(&hdev->dev, "%04X:%04X:%04X.%04X", hdev->bus,
39619 - hdev->vendor, hdev->product, atomic_inc_return(&id));
39620 + hdev->vendor, hdev->product, atomic_inc_return_unchecked(&id));
39621
39622 hid_debug_register(hdev, dev_name(&hdev->dev));
39623 ret = device_add(&hdev->dev);
39624 diff --git a/drivers/hid/hid-wiimote-debug.c b/drivers/hid/hid-wiimote-debug.c
39625 index c13fb5b..55a3802 100644
39626 --- a/drivers/hid/hid-wiimote-debug.c
39627 +++ b/drivers/hid/hid-wiimote-debug.c
39628 @@ -66,7 +66,7 @@ static ssize_t wiidebug_eeprom_read(struct file *f, char __user *u, size_t s,
39629 else if (size == 0)
39630 return -EIO;
39631
39632 - if (copy_to_user(u, buf, size))
39633 + if (size > sizeof(buf) || copy_to_user(u, buf, size))
39634 return -EFAULT;
39635
39636 *off += size;
39637 diff --git a/drivers/hid/uhid.c b/drivers/hid/uhid.c
39638 index cedc6da..2c3da2a 100644
39639 --- a/drivers/hid/uhid.c
39640 +++ b/drivers/hid/uhid.c
39641 @@ -47,7 +47,7 @@ struct uhid_device {
39642 struct mutex report_lock;
39643 wait_queue_head_t report_wait;
39644 atomic_t report_done;
39645 - atomic_t report_id;
39646 + atomic_unchecked_t report_id;
39647 struct uhid_event report_buf;
39648 };
39649
39650 @@ -163,7 +163,7 @@ static int uhid_hid_get_raw(struct hid_device *hid, unsigned char rnum,
39651
39652 spin_lock_irqsave(&uhid->qlock, flags);
39653 ev->type = UHID_FEATURE;
39654 - ev->u.feature.id = atomic_inc_return(&uhid->report_id);
39655 + ev->u.feature.id = atomic_inc_return_unchecked(&uhid->report_id);
39656 ev->u.feature.rnum = rnum;
39657 ev->u.feature.rtype = report_type;
39658
39659 @@ -446,7 +446,7 @@ static int uhid_dev_feature_answer(struct uhid_device *uhid,
39660 spin_lock_irqsave(&uhid->qlock, flags);
39661
39662 /* id for old report; drop it silently */
39663 - if (atomic_read(&uhid->report_id) != ev->u.feature_answer.id)
39664 + if (atomic_read_unchecked(&uhid->report_id) != ev->u.feature_answer.id)
39665 goto unlock;
39666 if (atomic_read(&uhid->report_done))
39667 goto unlock;
39668 diff --git a/drivers/hv/channel.c b/drivers/hv/channel.c
39669 index 6de6c98..18319e9 100644
39670 --- a/drivers/hv/channel.c
39671 +++ b/drivers/hv/channel.c
39672 @@ -406,8 +406,8 @@ int vmbus_establish_gpadl(struct vmbus_channel *channel, void *kbuffer,
39673 int ret = 0;
39674 int t;
39675
39676 - next_gpadl_handle = atomic_read(&vmbus_connection.next_gpadl_handle);
39677 - atomic_inc(&vmbus_connection.next_gpadl_handle);
39678 + next_gpadl_handle = atomic_read_unchecked(&vmbus_connection.next_gpadl_handle);
39679 + atomic_inc_unchecked(&vmbus_connection.next_gpadl_handle);
39680
39681 ret = create_gpadl_header(kbuffer, size, &msginfo, &msgcount);
39682 if (ret)
39683 diff --git a/drivers/hv/hv.c b/drivers/hv/hv.c
39684 index 88f4096..e50452e 100644
39685 --- a/drivers/hv/hv.c
39686 +++ b/drivers/hv/hv.c
39687 @@ -112,7 +112,7 @@ static u64 do_hypercall(u64 control, void *input, void *output)
39688 u64 output_address = (output) ? virt_to_phys(output) : 0;
39689 u32 output_address_hi = output_address >> 32;
39690 u32 output_address_lo = output_address & 0xFFFFFFFF;
39691 - void *hypercall_page = hv_context.hypercall_page;
39692 + void *hypercall_page = ktva_ktla(hv_context.hypercall_page);
39693
39694 __asm__ __volatile__ ("call *%8" : "=d"(hv_status_hi),
39695 "=a"(hv_status_lo) : "d" (control_hi),
39696 diff --git a/drivers/hv/hv_balloon.c b/drivers/hv/hv_balloon.c
39697 index 7e17a54..a50a33d 100644
39698 --- a/drivers/hv/hv_balloon.c
39699 +++ b/drivers/hv/hv_balloon.c
39700 @@ -464,7 +464,7 @@ MODULE_PARM_DESC(hot_add, "If set attempt memory hot_add");
39701
39702 module_param(pressure_report_delay, uint, (S_IRUGO | S_IWUSR));
39703 MODULE_PARM_DESC(pressure_report_delay, "Delay in secs in reporting pressure");
39704 -static atomic_t trans_id = ATOMIC_INIT(0);
39705 +static atomic_unchecked_t trans_id = ATOMIC_INIT(0);
39706
39707 static int dm_ring_size = (5 * PAGE_SIZE);
39708
39709 @@ -886,7 +886,7 @@ static void hot_add_req(struct work_struct *dummy)
39710 pr_info("Memory hot add failed\n");
39711
39712 dm->state = DM_INITIALIZED;
39713 - resp.hdr.trans_id = atomic_inc_return(&trans_id);
39714 + resp.hdr.trans_id = atomic_inc_return_unchecked(&trans_id);
39715 vmbus_sendpacket(dm->dev->channel, &resp,
39716 sizeof(struct dm_hot_add_response),
39717 (unsigned long)NULL,
39718 @@ -960,7 +960,7 @@ static void post_status(struct hv_dynmem_device *dm)
39719 memset(&status, 0, sizeof(struct dm_status));
39720 status.hdr.type = DM_STATUS_REPORT;
39721 status.hdr.size = sizeof(struct dm_status);
39722 - status.hdr.trans_id = atomic_inc_return(&trans_id);
39723 + status.hdr.trans_id = atomic_inc_return_unchecked(&trans_id);
39724
39725 /*
39726 * The host expects the guest to report free memory.
39727 @@ -980,7 +980,7 @@ static void post_status(struct hv_dynmem_device *dm)
39728 * send the status. This can happen if we were interrupted
39729 * after we picked our transaction ID.
39730 */
39731 - if (status.hdr.trans_id != atomic_read(&trans_id))
39732 + if (status.hdr.trans_id != atomic_read_unchecked(&trans_id))
39733 return;
39734
39735 vmbus_sendpacket(dm->dev->channel, &status,
39736 @@ -1108,7 +1108,7 @@ static void balloon_up(struct work_struct *dummy)
39737 */
39738
39739 do {
39740 - bl_resp->hdr.trans_id = atomic_inc_return(&trans_id);
39741 + bl_resp->hdr.trans_id = atomic_inc_return_unchecked(&trans_id);
39742 ret = vmbus_sendpacket(dm_device.dev->channel,
39743 bl_resp,
39744 bl_resp->hdr.size,
39745 @@ -1152,7 +1152,7 @@ static void balloon_down(struct hv_dynmem_device *dm,
39746
39747 memset(&resp, 0, sizeof(struct dm_unballoon_response));
39748 resp.hdr.type = DM_UNBALLOON_RESPONSE;
39749 - resp.hdr.trans_id = atomic_inc_return(&trans_id);
39750 + resp.hdr.trans_id = atomic_inc_return_unchecked(&trans_id);
39751 resp.hdr.size = sizeof(struct dm_unballoon_response);
39752
39753 vmbus_sendpacket(dm_device.dev->channel, &resp,
39754 @@ -1215,7 +1215,7 @@ static void version_resp(struct hv_dynmem_device *dm,
39755 memset(&version_req, 0, sizeof(struct dm_version_request));
39756 version_req.hdr.type = DM_VERSION_REQUEST;
39757 version_req.hdr.size = sizeof(struct dm_version_request);
39758 - version_req.hdr.trans_id = atomic_inc_return(&trans_id);
39759 + version_req.hdr.trans_id = atomic_inc_return_unchecked(&trans_id);
39760 version_req.version.version = DYNMEM_PROTOCOL_VERSION_WIN7;
39761 version_req.is_last_attempt = 1;
39762
39763 @@ -1385,7 +1385,7 @@ static int balloon_probe(struct hv_device *dev,
39764 memset(&version_req, 0, sizeof(struct dm_version_request));
39765 version_req.hdr.type = DM_VERSION_REQUEST;
39766 version_req.hdr.size = sizeof(struct dm_version_request);
39767 - version_req.hdr.trans_id = atomic_inc_return(&trans_id);
39768 + version_req.hdr.trans_id = atomic_inc_return_unchecked(&trans_id);
39769 version_req.version.version = DYNMEM_PROTOCOL_VERSION_WIN8;
39770 version_req.is_last_attempt = 0;
39771
39772 @@ -1416,7 +1416,7 @@ static int balloon_probe(struct hv_device *dev,
39773 memset(&cap_msg, 0, sizeof(struct dm_capabilities));
39774 cap_msg.hdr.type = DM_CAPABILITIES_REPORT;
39775 cap_msg.hdr.size = sizeof(struct dm_capabilities);
39776 - cap_msg.hdr.trans_id = atomic_inc_return(&trans_id);
39777 + cap_msg.hdr.trans_id = atomic_inc_return_unchecked(&trans_id);
39778
39779 cap_msg.caps.cap_bits.balloon = 1;
39780 cap_msg.caps.cap_bits.hot_add = 1;
39781 diff --git a/drivers/hv/hyperv_vmbus.h b/drivers/hv/hyperv_vmbus.h
39782 index d84918f..7f38f9f 100644
39783 --- a/drivers/hv/hyperv_vmbus.h
39784 +++ b/drivers/hv/hyperv_vmbus.h
39785 @@ -595,7 +595,7 @@ enum vmbus_connect_state {
39786 struct vmbus_connection {
39787 enum vmbus_connect_state conn_state;
39788
39789 - atomic_t next_gpadl_handle;
39790 + atomic_unchecked_t next_gpadl_handle;
39791
39792 /*
39793 * Represents channel interrupts. Each bit position represents a
39794 diff --git a/drivers/hv/vmbus_drv.c b/drivers/hv/vmbus_drv.c
39795 index f9fe46f..356b119 100644
39796 --- a/drivers/hv/vmbus_drv.c
39797 +++ b/drivers/hv/vmbus_drv.c
39798 @@ -672,10 +672,10 @@ int vmbus_device_register(struct hv_device *child_device_obj)
39799 {
39800 int ret = 0;
39801
39802 - static atomic_t device_num = ATOMIC_INIT(0);
39803 + static atomic_unchecked_t device_num = ATOMIC_INIT(0);
39804
39805 dev_set_name(&child_device_obj->device, "vmbus_0_%d",
39806 - atomic_inc_return(&device_num));
39807 + atomic_inc_return_unchecked(&device_num));
39808
39809 child_device_obj->device.bus = &hv_bus;
39810 child_device_obj->device.parent = &hv_acpi_dev->dev;
39811 diff --git a/drivers/hwmon/acpi_power_meter.c b/drivers/hwmon/acpi_power_meter.c
39812 index a9e3d01..9dd246e 100644
39813 --- a/drivers/hwmon/acpi_power_meter.c
39814 +++ b/drivers/hwmon/acpi_power_meter.c
39815 @@ -117,7 +117,7 @@ struct sensor_template {
39816 struct device_attribute *devattr,
39817 const char *buf, size_t count);
39818 int index;
39819 -};
39820 +} __do_const;
39821
39822 /* Averaging interval */
39823 static int update_avg_interval(struct acpi_power_meter_resource *resource)
39824 @@ -629,7 +629,7 @@ static int register_attrs(struct acpi_power_meter_resource *resource,
39825 struct sensor_template *attrs)
39826 {
39827 struct device *dev = &resource->acpi_dev->dev;
39828 - struct sensor_device_attribute *sensors =
39829 + sensor_device_attribute_no_const *sensors =
39830 &resource->sensors[resource->num_sensors];
39831 int res = 0;
39832
39833 diff --git a/drivers/hwmon/applesmc.c b/drivers/hwmon/applesmc.c
39834 index 3288f13..71cfb4e 100644
39835 --- a/drivers/hwmon/applesmc.c
39836 +++ b/drivers/hwmon/applesmc.c
39837 @@ -1106,7 +1106,7 @@ static int applesmc_create_nodes(struct applesmc_node_group *groups, int num)
39838 {
39839 struct applesmc_node_group *grp;
39840 struct applesmc_dev_attr *node;
39841 - struct attribute *attr;
39842 + attribute_no_const *attr;
39843 int ret, i;
39844
39845 for (grp = groups; grp->format; grp++) {
39846 diff --git a/drivers/hwmon/asus_atk0110.c b/drivers/hwmon/asus_atk0110.c
39847 index b25c643..a13460d 100644
39848 --- a/drivers/hwmon/asus_atk0110.c
39849 +++ b/drivers/hwmon/asus_atk0110.c
39850 @@ -152,10 +152,10 @@ MODULE_DEVICE_TABLE(acpi, atk_ids);
39851 struct atk_sensor_data {
39852 struct list_head list;
39853 struct atk_data *data;
39854 - struct device_attribute label_attr;
39855 - struct device_attribute input_attr;
39856 - struct device_attribute limit1_attr;
39857 - struct device_attribute limit2_attr;
39858 + device_attribute_no_const label_attr;
39859 + device_attribute_no_const input_attr;
39860 + device_attribute_no_const limit1_attr;
39861 + device_attribute_no_const limit2_attr;
39862 char label_attr_name[ATTR_NAME_SIZE];
39863 char input_attr_name[ATTR_NAME_SIZE];
39864 char limit1_attr_name[ATTR_NAME_SIZE];
39865 @@ -275,7 +275,7 @@ static ssize_t atk_name_show(struct device *dev,
39866 static struct device_attribute atk_name_attr =
39867 __ATTR(name, 0444, atk_name_show, NULL);
39868
39869 -static void atk_init_attribute(struct device_attribute *attr, char *name,
39870 +static void atk_init_attribute(device_attribute_no_const *attr, char *name,
39871 sysfs_show_func show)
39872 {
39873 sysfs_attr_init(&attr->attr);
39874 diff --git a/drivers/hwmon/coretemp.c b/drivers/hwmon/coretemp.c
39875 index 78be661..4dd032f 100644
39876 --- a/drivers/hwmon/coretemp.c
39877 +++ b/drivers/hwmon/coretemp.c
39878 @@ -797,7 +797,7 @@ static int coretemp_cpu_callback(struct notifier_block *nfb,
39879 return NOTIFY_OK;
39880 }
39881
39882 -static struct notifier_block coretemp_cpu_notifier __refdata = {
39883 +static struct notifier_block coretemp_cpu_notifier = {
39884 .notifier_call = coretemp_cpu_callback,
39885 };
39886
39887 diff --git a/drivers/hwmon/ibmaem.c b/drivers/hwmon/ibmaem.c
39888 index 632f1dc..57e6a58 100644
39889 --- a/drivers/hwmon/ibmaem.c
39890 +++ b/drivers/hwmon/ibmaem.c
39891 @@ -926,7 +926,7 @@ static int aem_register_sensors(struct aem_data *data,
39892 struct aem_rw_sensor_template *rw)
39893 {
39894 struct device *dev = &data->pdev->dev;
39895 - struct sensor_device_attribute *sensors = data->sensors;
39896 + sensor_device_attribute_no_const *sensors = data->sensors;
39897 int err;
39898
39899 /* Set up read-only sensors */
39900 diff --git a/drivers/hwmon/iio_hwmon.c b/drivers/hwmon/iio_hwmon.c
39901 index 708081b..fe2d4ab 100644
39902 --- a/drivers/hwmon/iio_hwmon.c
39903 +++ b/drivers/hwmon/iio_hwmon.c
39904 @@ -73,7 +73,7 @@ static int iio_hwmon_probe(struct platform_device *pdev)
39905 {
39906 struct device *dev = &pdev->dev;
39907 struct iio_hwmon_state *st;
39908 - struct sensor_device_attribute *a;
39909 + sensor_device_attribute_no_const *a;
39910 int ret, i;
39911 int in_i = 1, temp_i = 1, curr_i = 1;
39912 enum iio_chan_type type;
39913 diff --git a/drivers/hwmon/nct6775.c b/drivers/hwmon/nct6775.c
39914 index 6eb03ce..bea7e3e 100644
39915 --- a/drivers/hwmon/nct6775.c
39916 +++ b/drivers/hwmon/nct6775.c
39917 @@ -936,10 +936,10 @@ static struct attribute_group *
39918 nct6775_create_attr_group(struct device *dev, struct sensor_template_group *tg,
39919 int repeat)
39920 {
39921 - struct attribute_group *group;
39922 + attribute_group_no_const *group;
39923 struct sensor_device_attr_u *su;
39924 - struct sensor_device_attribute *a;
39925 - struct sensor_device_attribute_2 *a2;
39926 + sensor_device_attribute_no_const *a;
39927 + sensor_device_attribute_2_no_const *a2;
39928 struct attribute **attrs;
39929 struct sensor_device_template **t;
39930 int err, i, j, count;
39931 diff --git a/drivers/hwmon/pmbus/pmbus_core.c b/drivers/hwmon/pmbus/pmbus_core.c
39932 index 9319fcf..189ff45 100644
39933 --- a/drivers/hwmon/pmbus/pmbus_core.c
39934 +++ b/drivers/hwmon/pmbus/pmbus_core.c
39935 @@ -781,7 +781,7 @@ static int pmbus_add_attribute(struct pmbus_data *data, struct attribute *attr)
39936 return 0;
39937 }
39938
39939 -static void pmbus_dev_attr_init(struct device_attribute *dev_attr,
39940 +static void pmbus_dev_attr_init(device_attribute_no_const *dev_attr,
39941 const char *name,
39942 umode_t mode,
39943 ssize_t (*show)(struct device *dev,
39944 @@ -798,7 +798,7 @@ static void pmbus_dev_attr_init(struct device_attribute *dev_attr,
39945 dev_attr->store = store;
39946 }
39947
39948 -static void pmbus_attr_init(struct sensor_device_attribute *a,
39949 +static void pmbus_attr_init(sensor_device_attribute_no_const *a,
39950 const char *name,
39951 umode_t mode,
39952 ssize_t (*show)(struct device *dev,
39953 @@ -820,7 +820,7 @@ static int pmbus_add_boolean(struct pmbus_data *data,
39954 u16 reg, u8 mask)
39955 {
39956 struct pmbus_boolean *boolean;
39957 - struct sensor_device_attribute *a;
39958 + sensor_device_attribute_no_const *a;
39959
39960 boolean = devm_kzalloc(data->dev, sizeof(*boolean), GFP_KERNEL);
39961 if (!boolean)
39962 @@ -845,7 +845,7 @@ static struct pmbus_sensor *pmbus_add_sensor(struct pmbus_data *data,
39963 bool update, bool readonly)
39964 {
39965 struct pmbus_sensor *sensor;
39966 - struct device_attribute *a;
39967 + device_attribute_no_const *a;
39968
39969 sensor = devm_kzalloc(data->dev, sizeof(*sensor), GFP_KERNEL);
39970 if (!sensor)
39971 @@ -876,7 +876,7 @@ static int pmbus_add_label(struct pmbus_data *data,
39972 const char *lstring, int index)
39973 {
39974 struct pmbus_label *label;
39975 - struct device_attribute *a;
39976 + device_attribute_no_const *a;
39977
39978 label = devm_kzalloc(data->dev, sizeof(*label), GFP_KERNEL);
39979 if (!label)
39980 diff --git a/drivers/hwmon/sht15.c b/drivers/hwmon/sht15.c
39981 index 97cd45a..ac54d8b 100644
39982 --- a/drivers/hwmon/sht15.c
39983 +++ b/drivers/hwmon/sht15.c
39984 @@ -169,7 +169,7 @@ struct sht15_data {
39985 int supply_uv;
39986 bool supply_uv_valid;
39987 struct work_struct update_supply_work;
39988 - atomic_t interrupt_handled;
39989 + atomic_unchecked_t interrupt_handled;
39990 };
39991
39992 /**
39993 @@ -542,13 +542,13 @@ static int sht15_measurement(struct sht15_data *data,
39994 ret = gpio_direction_input(data->pdata->gpio_data);
39995 if (ret)
39996 return ret;
39997 - atomic_set(&data->interrupt_handled, 0);
39998 + atomic_set_unchecked(&data->interrupt_handled, 0);
39999
40000 enable_irq(gpio_to_irq(data->pdata->gpio_data));
40001 if (gpio_get_value(data->pdata->gpio_data) == 0) {
40002 disable_irq_nosync(gpio_to_irq(data->pdata->gpio_data));
40003 /* Only relevant if the interrupt hasn't occurred. */
40004 - if (!atomic_read(&data->interrupt_handled))
40005 + if (!atomic_read_unchecked(&data->interrupt_handled))
40006 schedule_work(&data->read_work);
40007 }
40008 ret = wait_event_timeout(data->wait_queue,
40009 @@ -820,7 +820,7 @@ static irqreturn_t sht15_interrupt_fired(int irq, void *d)
40010
40011 /* First disable the interrupt */
40012 disable_irq_nosync(irq);
40013 - atomic_inc(&data->interrupt_handled);
40014 + atomic_inc_unchecked(&data->interrupt_handled);
40015 /* Then schedule a reading work struct */
40016 if (data->state != SHT15_READING_NOTHING)
40017 schedule_work(&data->read_work);
40018 @@ -842,11 +842,11 @@ static void sht15_bh_read_data(struct work_struct *work_s)
40019 * If not, then start the interrupt again - care here as could
40020 * have gone low in meantime so verify it hasn't!
40021 */
40022 - atomic_set(&data->interrupt_handled, 0);
40023 + atomic_set_unchecked(&data->interrupt_handled, 0);
40024 enable_irq(gpio_to_irq(data->pdata->gpio_data));
40025 /* If still not occurred or another handler was scheduled */
40026 if (gpio_get_value(data->pdata->gpio_data)
40027 - || atomic_read(&data->interrupt_handled))
40028 + || atomic_read_unchecked(&data->interrupt_handled))
40029 return;
40030 }
40031
40032 diff --git a/drivers/hwmon/via-cputemp.c b/drivers/hwmon/via-cputemp.c
40033 index 38944e9..ae9e5ed 100644
40034 --- a/drivers/hwmon/via-cputemp.c
40035 +++ b/drivers/hwmon/via-cputemp.c
40036 @@ -296,7 +296,7 @@ static int via_cputemp_cpu_callback(struct notifier_block *nfb,
40037 return NOTIFY_OK;
40038 }
40039
40040 -static struct notifier_block via_cputemp_cpu_notifier __refdata = {
40041 +static struct notifier_block via_cputemp_cpu_notifier = {
40042 .notifier_call = via_cputemp_cpu_callback,
40043 };
40044
40045 diff --git a/drivers/i2c/busses/i2c-amd756-s4882.c b/drivers/i2c/busses/i2c-amd756-s4882.c
40046 index 07f01ac..d79ad3d 100644
40047 --- a/drivers/i2c/busses/i2c-amd756-s4882.c
40048 +++ b/drivers/i2c/busses/i2c-amd756-s4882.c
40049 @@ -43,7 +43,7 @@
40050 extern struct i2c_adapter amd756_smbus;
40051
40052 static struct i2c_adapter *s4882_adapter;
40053 -static struct i2c_algorithm *s4882_algo;
40054 +static i2c_algorithm_no_const *s4882_algo;
40055
40056 /* Wrapper access functions for multiplexed SMBus */
40057 static DEFINE_MUTEX(amd756_lock);
40058 diff --git a/drivers/i2c/busses/i2c-diolan-u2c.c b/drivers/i2c/busses/i2c-diolan-u2c.c
40059 index dae3ddf..26e21d1 100644
40060 --- a/drivers/i2c/busses/i2c-diolan-u2c.c
40061 +++ b/drivers/i2c/busses/i2c-diolan-u2c.c
40062 @@ -99,7 +99,7 @@ MODULE_PARM_DESC(frequency, "I2C clock frequency in hertz");
40063 /* usb layer */
40064
40065 /* Send command to device, and get response. */
40066 -static int diolan_usb_transfer(struct i2c_diolan_u2c *dev)
40067 +static int __intentional_overflow(-1) diolan_usb_transfer(struct i2c_diolan_u2c *dev)
40068 {
40069 int ret = 0;
40070 int actual;
40071 diff --git a/drivers/i2c/busses/i2c-nforce2-s4985.c b/drivers/i2c/busses/i2c-nforce2-s4985.c
40072 index 2ca268d..c6acbdf 100644
40073 --- a/drivers/i2c/busses/i2c-nforce2-s4985.c
40074 +++ b/drivers/i2c/busses/i2c-nforce2-s4985.c
40075 @@ -41,7 +41,7 @@
40076 extern struct i2c_adapter *nforce2_smbus;
40077
40078 static struct i2c_adapter *s4985_adapter;
40079 -static struct i2c_algorithm *s4985_algo;
40080 +static i2c_algorithm_no_const *s4985_algo;
40081
40082 /* Wrapper access functions for multiplexed SMBus */
40083 static DEFINE_MUTEX(nforce2_lock);
40084 diff --git a/drivers/i2c/i2c-dev.c b/drivers/i2c/i2c-dev.c
40085 index c3ccdea..5b3dc1a 100644
40086 --- a/drivers/i2c/i2c-dev.c
40087 +++ b/drivers/i2c/i2c-dev.c
40088 @@ -271,7 +271,7 @@ static noinline int i2cdev_ioctl_rdrw(struct i2c_client *client,
40089 break;
40090 }
40091
40092 - data_ptrs[i] = (u8 __user *)rdwr_pa[i].buf;
40093 + data_ptrs[i] = (u8 __force_user *)rdwr_pa[i].buf;
40094 rdwr_pa[i].buf = memdup_user(data_ptrs[i], rdwr_pa[i].len);
40095 if (IS_ERR(rdwr_pa[i].buf)) {
40096 res = PTR_ERR(rdwr_pa[i].buf);
40097 diff --git a/drivers/ide/ide-cd.c b/drivers/ide/ide-cd.c
40098 index 0b510ba..4fbb5085 100644
40099 --- a/drivers/ide/ide-cd.c
40100 +++ b/drivers/ide/ide-cd.c
40101 @@ -768,7 +768,7 @@ static void cdrom_do_block_pc(ide_drive_t *drive, struct request *rq)
40102 alignment = queue_dma_alignment(q) | q->dma_pad_mask;
40103 if ((unsigned long)buf & alignment
40104 || blk_rq_bytes(rq) & q->dma_pad_mask
40105 - || object_is_on_stack(buf))
40106 + || object_starts_on_stack(buf))
40107 drive->dma = 0;
40108 }
40109 }
40110 diff --git a/drivers/iio/industrialio-core.c b/drivers/iio/industrialio-core.c
40111 index f95c697..0a1b05c 100644
40112 --- a/drivers/iio/industrialio-core.c
40113 +++ b/drivers/iio/industrialio-core.c
40114 @@ -506,7 +506,7 @@ static ssize_t iio_write_channel_info(struct device *dev,
40115 }
40116
40117 static
40118 -int __iio_device_attr_init(struct device_attribute *dev_attr,
40119 +int __iio_device_attr_init(device_attribute_no_const *dev_attr,
40120 const char *postfix,
40121 struct iio_chan_spec const *chan,
40122 ssize_t (*readfunc)(struct device *dev,
40123 diff --git a/drivers/infiniband/core/cm.c b/drivers/infiniband/core/cm.c
40124 index 784b97c..c9ceadf 100644
40125 --- a/drivers/infiniband/core/cm.c
40126 +++ b/drivers/infiniband/core/cm.c
40127 @@ -114,7 +114,7 @@ static char const counter_group_names[CM_COUNTER_GROUPS]
40128
40129 struct cm_counter_group {
40130 struct kobject obj;
40131 - atomic_long_t counter[CM_ATTR_COUNT];
40132 + atomic_long_unchecked_t counter[CM_ATTR_COUNT];
40133 };
40134
40135 struct cm_counter_attribute {
40136 @@ -1395,7 +1395,7 @@ static void cm_dup_req_handler(struct cm_work *work,
40137 struct ib_mad_send_buf *msg = NULL;
40138 int ret;
40139
40140 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
40141 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
40142 counter[CM_REQ_COUNTER]);
40143
40144 /* Quick state check to discard duplicate REQs. */
40145 @@ -1779,7 +1779,7 @@ static void cm_dup_rep_handler(struct cm_work *work)
40146 if (!cm_id_priv)
40147 return;
40148
40149 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
40150 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
40151 counter[CM_REP_COUNTER]);
40152 ret = cm_alloc_response_msg(work->port, work->mad_recv_wc, &msg);
40153 if (ret)
40154 @@ -1946,7 +1946,7 @@ static int cm_rtu_handler(struct cm_work *work)
40155 if (cm_id_priv->id.state != IB_CM_REP_SENT &&
40156 cm_id_priv->id.state != IB_CM_MRA_REP_RCVD) {
40157 spin_unlock_irq(&cm_id_priv->lock);
40158 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
40159 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
40160 counter[CM_RTU_COUNTER]);
40161 goto out;
40162 }
40163 @@ -2129,7 +2129,7 @@ static int cm_dreq_handler(struct cm_work *work)
40164 cm_id_priv = cm_acquire_id(dreq_msg->remote_comm_id,
40165 dreq_msg->local_comm_id);
40166 if (!cm_id_priv) {
40167 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
40168 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
40169 counter[CM_DREQ_COUNTER]);
40170 cm_issue_drep(work->port, work->mad_recv_wc);
40171 return -EINVAL;
40172 @@ -2154,7 +2154,7 @@ static int cm_dreq_handler(struct cm_work *work)
40173 case IB_CM_MRA_REP_RCVD:
40174 break;
40175 case IB_CM_TIMEWAIT:
40176 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
40177 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
40178 counter[CM_DREQ_COUNTER]);
40179 if (cm_alloc_response_msg(work->port, work->mad_recv_wc, &msg))
40180 goto unlock;
40181 @@ -2168,7 +2168,7 @@ static int cm_dreq_handler(struct cm_work *work)
40182 cm_free_msg(msg);
40183 goto deref;
40184 case IB_CM_DREQ_RCVD:
40185 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
40186 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
40187 counter[CM_DREQ_COUNTER]);
40188 goto unlock;
40189 default:
40190 @@ -2535,7 +2535,7 @@ static int cm_mra_handler(struct cm_work *work)
40191 ib_modify_mad(cm_id_priv->av.port->mad_agent,
40192 cm_id_priv->msg, timeout)) {
40193 if (cm_id_priv->id.lap_state == IB_CM_MRA_LAP_RCVD)
40194 - atomic_long_inc(&work->port->
40195 + atomic_long_inc_unchecked(&work->port->
40196 counter_group[CM_RECV_DUPLICATES].
40197 counter[CM_MRA_COUNTER]);
40198 goto out;
40199 @@ -2544,7 +2544,7 @@ static int cm_mra_handler(struct cm_work *work)
40200 break;
40201 case IB_CM_MRA_REQ_RCVD:
40202 case IB_CM_MRA_REP_RCVD:
40203 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
40204 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
40205 counter[CM_MRA_COUNTER]);
40206 /* fall through */
40207 default:
40208 @@ -2706,7 +2706,7 @@ static int cm_lap_handler(struct cm_work *work)
40209 case IB_CM_LAP_IDLE:
40210 break;
40211 case IB_CM_MRA_LAP_SENT:
40212 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
40213 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
40214 counter[CM_LAP_COUNTER]);
40215 if (cm_alloc_response_msg(work->port, work->mad_recv_wc, &msg))
40216 goto unlock;
40217 @@ -2722,7 +2722,7 @@ static int cm_lap_handler(struct cm_work *work)
40218 cm_free_msg(msg);
40219 goto deref;
40220 case IB_CM_LAP_RCVD:
40221 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
40222 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
40223 counter[CM_LAP_COUNTER]);
40224 goto unlock;
40225 default:
40226 @@ -3006,7 +3006,7 @@ static int cm_sidr_req_handler(struct cm_work *work)
40227 cur_cm_id_priv = cm_insert_remote_sidr(cm_id_priv);
40228 if (cur_cm_id_priv) {
40229 spin_unlock_irq(&cm.lock);
40230 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
40231 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
40232 counter[CM_SIDR_REQ_COUNTER]);
40233 goto out; /* Duplicate message. */
40234 }
40235 @@ -3218,10 +3218,10 @@ static void cm_send_handler(struct ib_mad_agent *mad_agent,
40236 if (!msg->context[0] && (attr_index != CM_REJ_COUNTER))
40237 msg->retries = 1;
40238
40239 - atomic_long_add(1 + msg->retries,
40240 + atomic_long_add_unchecked(1 + msg->retries,
40241 &port->counter_group[CM_XMIT].counter[attr_index]);
40242 if (msg->retries)
40243 - atomic_long_add(msg->retries,
40244 + atomic_long_add_unchecked(msg->retries,
40245 &port->counter_group[CM_XMIT_RETRIES].
40246 counter[attr_index]);
40247
40248 @@ -3431,7 +3431,7 @@ static void cm_recv_handler(struct ib_mad_agent *mad_agent,
40249 }
40250
40251 attr_id = be16_to_cpu(mad_recv_wc->recv_buf.mad->mad_hdr.attr_id);
40252 - atomic_long_inc(&port->counter_group[CM_RECV].
40253 + atomic_long_inc_unchecked(&port->counter_group[CM_RECV].
40254 counter[attr_id - CM_ATTR_ID_OFFSET]);
40255
40256 work = kmalloc(sizeof *work + sizeof(struct ib_sa_path_rec) * paths,
40257 @@ -3636,7 +3636,7 @@ static ssize_t cm_show_counter(struct kobject *obj, struct attribute *attr,
40258 cm_attr = container_of(attr, struct cm_counter_attribute, attr);
40259
40260 return sprintf(buf, "%ld\n",
40261 - atomic_long_read(&group->counter[cm_attr->index]));
40262 + atomic_long_read_unchecked(&group->counter[cm_attr->index]));
40263 }
40264
40265 static const struct sysfs_ops cm_counter_ops = {
40266 diff --git a/drivers/infiniband/core/fmr_pool.c b/drivers/infiniband/core/fmr_pool.c
40267 index 9f5ad7c..588cd84 100644
40268 --- a/drivers/infiniband/core/fmr_pool.c
40269 +++ b/drivers/infiniband/core/fmr_pool.c
40270 @@ -98,8 +98,8 @@ struct ib_fmr_pool {
40271
40272 struct task_struct *thread;
40273
40274 - atomic_t req_ser;
40275 - atomic_t flush_ser;
40276 + atomic_unchecked_t req_ser;
40277 + atomic_unchecked_t flush_ser;
40278
40279 wait_queue_head_t force_wait;
40280 };
40281 @@ -179,10 +179,10 @@ static int ib_fmr_cleanup_thread(void *pool_ptr)
40282 struct ib_fmr_pool *pool = pool_ptr;
40283
40284 do {
40285 - if (atomic_read(&pool->flush_ser) - atomic_read(&pool->req_ser) < 0) {
40286 + if (atomic_read_unchecked(&pool->flush_ser) - atomic_read_unchecked(&pool->req_ser) < 0) {
40287 ib_fmr_batch_release(pool);
40288
40289 - atomic_inc(&pool->flush_ser);
40290 + atomic_inc_unchecked(&pool->flush_ser);
40291 wake_up_interruptible(&pool->force_wait);
40292
40293 if (pool->flush_function)
40294 @@ -190,7 +190,7 @@ static int ib_fmr_cleanup_thread(void *pool_ptr)
40295 }
40296
40297 set_current_state(TASK_INTERRUPTIBLE);
40298 - if (atomic_read(&pool->flush_ser) - atomic_read(&pool->req_ser) >= 0 &&
40299 + if (atomic_read_unchecked(&pool->flush_ser) - atomic_read_unchecked(&pool->req_ser) >= 0 &&
40300 !kthread_should_stop())
40301 schedule();
40302 __set_current_state(TASK_RUNNING);
40303 @@ -282,8 +282,8 @@ struct ib_fmr_pool *ib_create_fmr_pool(struct ib_pd *pd,
40304 pool->dirty_watermark = params->dirty_watermark;
40305 pool->dirty_len = 0;
40306 spin_lock_init(&pool->pool_lock);
40307 - atomic_set(&pool->req_ser, 0);
40308 - atomic_set(&pool->flush_ser, 0);
40309 + atomic_set_unchecked(&pool->req_ser, 0);
40310 + atomic_set_unchecked(&pool->flush_ser, 0);
40311 init_waitqueue_head(&pool->force_wait);
40312
40313 pool->thread = kthread_run(ib_fmr_cleanup_thread,
40314 @@ -411,11 +411,11 @@ int ib_flush_fmr_pool(struct ib_fmr_pool *pool)
40315 }
40316 spin_unlock_irq(&pool->pool_lock);
40317
40318 - serial = atomic_inc_return(&pool->req_ser);
40319 + serial = atomic_inc_return_unchecked(&pool->req_ser);
40320 wake_up_process(pool->thread);
40321
40322 if (wait_event_interruptible(pool->force_wait,
40323 - atomic_read(&pool->flush_ser) - serial >= 0))
40324 + atomic_read_unchecked(&pool->flush_ser) - serial >= 0))
40325 return -EINTR;
40326
40327 return 0;
40328 @@ -525,7 +525,7 @@ int ib_fmr_pool_unmap(struct ib_pool_fmr *fmr)
40329 } else {
40330 list_add_tail(&fmr->list, &pool->dirty_list);
40331 if (++pool->dirty_len >= pool->dirty_watermark) {
40332 - atomic_inc(&pool->req_ser);
40333 + atomic_inc_unchecked(&pool->req_ser);
40334 wake_up_process(pool->thread);
40335 }
40336 }
40337 diff --git a/drivers/infiniband/hw/cxgb4/mem.c b/drivers/infiniband/hw/cxgb4/mem.c
40338 index 4cb8eb2..146bf60 100644
40339 --- a/drivers/infiniband/hw/cxgb4/mem.c
40340 +++ b/drivers/infiniband/hw/cxgb4/mem.c
40341 @@ -249,7 +249,7 @@ static int write_tpt_entry(struct c4iw_rdev *rdev, u32 reset_tpt_entry,
40342 int err;
40343 struct fw_ri_tpte tpt;
40344 u32 stag_idx;
40345 - static atomic_t key;
40346 + static atomic_unchecked_t key;
40347
40348 if (c4iw_fatal_error(rdev))
40349 return -EIO;
40350 @@ -266,7 +266,7 @@ static int write_tpt_entry(struct c4iw_rdev *rdev, u32 reset_tpt_entry,
40351 if (rdev->stats.stag.cur > rdev->stats.stag.max)
40352 rdev->stats.stag.max = rdev->stats.stag.cur;
40353 mutex_unlock(&rdev->stats.lock);
40354 - *stag = (stag_idx << 8) | (atomic_inc_return(&key) & 0xff);
40355 + *stag = (stag_idx << 8) | (atomic_inc_return_unchecked(&key) & 0xff);
40356 }
40357 PDBG("%s stag_state 0x%0x type 0x%0x pdid 0x%0x, stag_idx 0x%x\n",
40358 __func__, stag_state, type, pdid, stag_idx);
40359 diff --git a/drivers/infiniband/hw/ipath/ipath_rc.c b/drivers/infiniband/hw/ipath/ipath_rc.c
40360 index 79b3dbc..96e5fcc 100644
40361 --- a/drivers/infiniband/hw/ipath/ipath_rc.c
40362 +++ b/drivers/infiniband/hw/ipath/ipath_rc.c
40363 @@ -1868,7 +1868,7 @@ void ipath_rc_rcv(struct ipath_ibdev *dev, struct ipath_ib_header *hdr,
40364 struct ib_atomic_eth *ateth;
40365 struct ipath_ack_entry *e;
40366 u64 vaddr;
40367 - atomic64_t *maddr;
40368 + atomic64_unchecked_t *maddr;
40369 u64 sdata;
40370 u32 rkey;
40371 u8 next;
40372 @@ -1903,11 +1903,11 @@ void ipath_rc_rcv(struct ipath_ibdev *dev, struct ipath_ib_header *hdr,
40373 IB_ACCESS_REMOTE_ATOMIC)))
40374 goto nack_acc_unlck;
40375 /* Perform atomic OP and save result. */
40376 - maddr = (atomic64_t *) qp->r_sge.sge.vaddr;
40377 + maddr = (atomic64_unchecked_t *) qp->r_sge.sge.vaddr;
40378 sdata = be64_to_cpu(ateth->swap_data);
40379 e = &qp->s_ack_queue[qp->r_head_ack_queue];
40380 e->atomic_data = (opcode == OP(FETCH_ADD)) ?
40381 - (u64) atomic64_add_return(sdata, maddr) - sdata :
40382 + (u64) atomic64_add_return_unchecked(sdata, maddr) - sdata :
40383 (u64) cmpxchg((u64 *) qp->r_sge.sge.vaddr,
40384 be64_to_cpu(ateth->compare_data),
40385 sdata);
40386 diff --git a/drivers/infiniband/hw/ipath/ipath_ruc.c b/drivers/infiniband/hw/ipath/ipath_ruc.c
40387 index 1f95bba..9530f87 100644
40388 --- a/drivers/infiniband/hw/ipath/ipath_ruc.c
40389 +++ b/drivers/infiniband/hw/ipath/ipath_ruc.c
40390 @@ -266,7 +266,7 @@ static void ipath_ruc_loopback(struct ipath_qp *sqp)
40391 unsigned long flags;
40392 struct ib_wc wc;
40393 u64 sdata;
40394 - atomic64_t *maddr;
40395 + atomic64_unchecked_t *maddr;
40396 enum ib_wc_status send_status;
40397
40398 /*
40399 @@ -382,11 +382,11 @@ again:
40400 IB_ACCESS_REMOTE_ATOMIC)))
40401 goto acc_err;
40402 /* Perform atomic OP and save result. */
40403 - maddr = (atomic64_t *) qp->r_sge.sge.vaddr;
40404 + maddr = (atomic64_unchecked_t *) qp->r_sge.sge.vaddr;
40405 sdata = wqe->wr.wr.atomic.compare_add;
40406 *(u64 *) sqp->s_sge.sge.vaddr =
40407 (wqe->wr.opcode == IB_WR_ATOMIC_FETCH_AND_ADD) ?
40408 - (u64) atomic64_add_return(sdata, maddr) - sdata :
40409 + (u64) atomic64_add_return_unchecked(sdata, maddr) - sdata :
40410 (u64) cmpxchg((u64 *) qp->r_sge.sge.vaddr,
40411 sdata, wqe->wr.wr.atomic.swap);
40412 goto send_comp;
40413 diff --git a/drivers/infiniband/hw/mlx4/mad.c b/drivers/infiniband/hw/mlx4/mad.c
40414 index f2a3f48..673ec79 100644
40415 --- a/drivers/infiniband/hw/mlx4/mad.c
40416 +++ b/drivers/infiniband/hw/mlx4/mad.c
40417 @@ -98,7 +98,7 @@ __be64 mlx4_ib_gen_node_guid(void)
40418
40419 __be64 mlx4_ib_get_new_demux_tid(struct mlx4_ib_demux_ctx *ctx)
40420 {
40421 - return cpu_to_be64(atomic_inc_return(&ctx->tid)) |
40422 + return cpu_to_be64(atomic_inc_return_unchecked(&ctx->tid)) |
40423 cpu_to_be64(0xff00000000000000LL);
40424 }
40425
40426 diff --git a/drivers/infiniband/hw/mlx4/mcg.c b/drivers/infiniband/hw/mlx4/mcg.c
40427 index 25b2cdf..099ff97 100644
40428 --- a/drivers/infiniband/hw/mlx4/mcg.c
40429 +++ b/drivers/infiniband/hw/mlx4/mcg.c
40430 @@ -1040,7 +1040,7 @@ int mlx4_ib_mcg_port_init(struct mlx4_ib_demux_ctx *ctx)
40431 {
40432 char name[20];
40433
40434 - atomic_set(&ctx->tid, 0);
40435 + atomic_set_unchecked(&ctx->tid, 0);
40436 sprintf(name, "mlx4_ib_mcg%d", ctx->port);
40437 ctx->mcg_wq = create_singlethread_workqueue(name);
40438 if (!ctx->mcg_wq)
40439 diff --git a/drivers/infiniband/hw/mlx4/mlx4_ib.h b/drivers/infiniband/hw/mlx4/mlx4_ib.h
40440 index 036b663..c9a8c73 100644
40441 --- a/drivers/infiniband/hw/mlx4/mlx4_ib.h
40442 +++ b/drivers/infiniband/hw/mlx4/mlx4_ib.h
40443 @@ -404,7 +404,7 @@ struct mlx4_ib_demux_ctx {
40444 struct list_head mcg_mgid0_list;
40445 struct workqueue_struct *mcg_wq;
40446 struct mlx4_ib_demux_pv_ctx **tun;
40447 - atomic_t tid;
40448 + atomic_unchecked_t tid;
40449 int flushing; /* flushing the work queue */
40450 };
40451
40452 diff --git a/drivers/infiniband/hw/mthca/mthca_cmd.c b/drivers/infiniband/hw/mthca/mthca_cmd.c
40453 index 9d3e5c1..6f166df 100644
40454 --- a/drivers/infiniband/hw/mthca/mthca_cmd.c
40455 +++ b/drivers/infiniband/hw/mthca/mthca_cmd.c
40456 @@ -772,7 +772,7 @@ static void mthca_setup_cmd_doorbells(struct mthca_dev *dev, u64 base)
40457 mthca_dbg(dev, "Mapped doorbell page for posting FW commands\n");
40458 }
40459
40460 -int mthca_QUERY_FW(struct mthca_dev *dev)
40461 +int __intentional_overflow(-1) mthca_QUERY_FW(struct mthca_dev *dev)
40462 {
40463 struct mthca_mailbox *mailbox;
40464 u32 *outbox;
40465 @@ -1612,7 +1612,7 @@ int mthca_HW2SW_MPT(struct mthca_dev *dev, struct mthca_mailbox *mailbox,
40466 CMD_TIME_CLASS_B);
40467 }
40468
40469 -int mthca_WRITE_MTT(struct mthca_dev *dev, struct mthca_mailbox *mailbox,
40470 +int __intentional_overflow(-1) mthca_WRITE_MTT(struct mthca_dev *dev, struct mthca_mailbox *mailbox,
40471 int num_mtt)
40472 {
40473 return mthca_cmd(dev, mailbox->dma, num_mtt, 0, CMD_WRITE_MTT,
40474 @@ -1634,7 +1634,7 @@ int mthca_MAP_EQ(struct mthca_dev *dev, u64 event_mask, int unmap,
40475 0, CMD_MAP_EQ, CMD_TIME_CLASS_B);
40476 }
40477
40478 -int mthca_SW2HW_EQ(struct mthca_dev *dev, struct mthca_mailbox *mailbox,
40479 +int __intentional_overflow(-1) mthca_SW2HW_EQ(struct mthca_dev *dev, struct mthca_mailbox *mailbox,
40480 int eq_num)
40481 {
40482 return mthca_cmd(dev, mailbox->dma, eq_num, 0, CMD_SW2HW_EQ,
40483 @@ -1857,7 +1857,7 @@ int mthca_CONF_SPECIAL_QP(struct mthca_dev *dev, int type, u32 qpn)
40484 CMD_TIME_CLASS_B);
40485 }
40486
40487 -int mthca_MAD_IFC(struct mthca_dev *dev, int ignore_mkey, int ignore_bkey,
40488 +int __intentional_overflow(-1) mthca_MAD_IFC(struct mthca_dev *dev, int ignore_mkey, int ignore_bkey,
40489 int port, struct ib_wc *in_wc, struct ib_grh *in_grh,
40490 void *in_mad, void *response_mad)
40491 {
40492 diff --git a/drivers/infiniband/hw/mthca/mthca_main.c b/drivers/infiniband/hw/mthca/mthca_main.c
40493 index 87897b9..7e79542 100644
40494 --- a/drivers/infiniband/hw/mthca/mthca_main.c
40495 +++ b/drivers/infiniband/hw/mthca/mthca_main.c
40496 @@ -692,7 +692,7 @@ err_close:
40497 return err;
40498 }
40499
40500 -static int mthca_setup_hca(struct mthca_dev *dev)
40501 +static int __intentional_overflow(-1) mthca_setup_hca(struct mthca_dev *dev)
40502 {
40503 int err;
40504
40505 diff --git a/drivers/infiniband/hw/mthca/mthca_mr.c b/drivers/infiniband/hw/mthca/mthca_mr.c
40506 index ed9a989..6aa5dc2 100644
40507 --- a/drivers/infiniband/hw/mthca/mthca_mr.c
40508 +++ b/drivers/infiniband/hw/mthca/mthca_mr.c
40509 @@ -81,7 +81,7 @@ struct mthca_mpt_entry {
40510 * through the bitmaps)
40511 */
40512
40513 -static u32 mthca_buddy_alloc(struct mthca_buddy *buddy, int order)
40514 +static u32 __intentional_overflow(-1) mthca_buddy_alloc(struct mthca_buddy *buddy, int order)
40515 {
40516 int o;
40517 int m;
40518 @@ -426,7 +426,7 @@ static inline u32 adjust_key(struct mthca_dev *dev, u32 key)
40519 return key;
40520 }
40521
40522 -int mthca_mr_alloc(struct mthca_dev *dev, u32 pd, int buffer_size_shift,
40523 +int __intentional_overflow(-1) mthca_mr_alloc(struct mthca_dev *dev, u32 pd, int buffer_size_shift,
40524 u64 iova, u64 total_size, u32 access, struct mthca_mr *mr)
40525 {
40526 struct mthca_mailbox *mailbox;
40527 @@ -516,7 +516,7 @@ int mthca_mr_alloc_notrans(struct mthca_dev *dev, u32 pd,
40528 return mthca_mr_alloc(dev, pd, 12, 0, ~0ULL, access, mr);
40529 }
40530
40531 -int mthca_mr_alloc_phys(struct mthca_dev *dev, u32 pd,
40532 +int __intentional_overflow(-1) mthca_mr_alloc_phys(struct mthca_dev *dev, u32 pd,
40533 u64 *buffer_list, int buffer_size_shift,
40534 int list_len, u64 iova, u64 total_size,
40535 u32 access, struct mthca_mr *mr)
40536 diff --git a/drivers/infiniband/hw/mthca/mthca_provider.c b/drivers/infiniband/hw/mthca/mthca_provider.c
40537 index 5b71d43..35a9e14 100644
40538 --- a/drivers/infiniband/hw/mthca/mthca_provider.c
40539 +++ b/drivers/infiniband/hw/mthca/mthca_provider.c
40540 @@ -763,7 +763,7 @@ unlock:
40541 return 0;
40542 }
40543
40544 -static int mthca_resize_cq(struct ib_cq *ibcq, int entries, struct ib_udata *udata)
40545 +static int __intentional_overflow(-1) mthca_resize_cq(struct ib_cq *ibcq, int entries, struct ib_udata *udata)
40546 {
40547 struct mthca_dev *dev = to_mdev(ibcq->device);
40548 struct mthca_cq *cq = to_mcq(ibcq);
40549 diff --git a/drivers/infiniband/hw/nes/nes.c b/drivers/infiniband/hw/nes/nes.c
40550 index 4291410..d2ab1fb 100644
40551 --- a/drivers/infiniband/hw/nes/nes.c
40552 +++ b/drivers/infiniband/hw/nes/nes.c
40553 @@ -98,7 +98,7 @@ MODULE_PARM_DESC(limit_maxrdreqsz, "Limit max read request size to 256 Bytes");
40554 LIST_HEAD(nes_adapter_list);
40555 static LIST_HEAD(nes_dev_list);
40556
40557 -atomic_t qps_destroyed;
40558 +atomic_unchecked_t qps_destroyed;
40559
40560 static unsigned int ee_flsh_adapter;
40561 static unsigned int sysfs_nonidx_addr;
40562 @@ -269,7 +269,7 @@ static void nes_cqp_rem_ref_callback(struct nes_device *nesdev, struct nes_cqp_r
40563 struct nes_qp *nesqp = cqp_request->cqp_callback_pointer;
40564 struct nes_adapter *nesadapter = nesdev->nesadapter;
40565
40566 - atomic_inc(&qps_destroyed);
40567 + atomic_inc_unchecked(&qps_destroyed);
40568
40569 /* Free the control structures */
40570
40571 diff --git a/drivers/infiniband/hw/nes/nes.h b/drivers/infiniband/hw/nes/nes.h
40572 index 33cc589..3bd6538 100644
40573 --- a/drivers/infiniband/hw/nes/nes.h
40574 +++ b/drivers/infiniband/hw/nes/nes.h
40575 @@ -177,17 +177,17 @@ extern unsigned int nes_debug_level;
40576 extern unsigned int wqm_quanta;
40577 extern struct list_head nes_adapter_list;
40578
40579 -extern atomic_t cm_connects;
40580 -extern atomic_t cm_accepts;
40581 -extern atomic_t cm_disconnects;
40582 -extern atomic_t cm_closes;
40583 -extern atomic_t cm_connecteds;
40584 -extern atomic_t cm_connect_reqs;
40585 -extern atomic_t cm_rejects;
40586 -extern atomic_t mod_qp_timouts;
40587 -extern atomic_t qps_created;
40588 -extern atomic_t qps_destroyed;
40589 -extern atomic_t sw_qps_destroyed;
40590 +extern atomic_unchecked_t cm_connects;
40591 +extern atomic_unchecked_t cm_accepts;
40592 +extern atomic_unchecked_t cm_disconnects;
40593 +extern atomic_unchecked_t cm_closes;
40594 +extern atomic_unchecked_t cm_connecteds;
40595 +extern atomic_unchecked_t cm_connect_reqs;
40596 +extern atomic_unchecked_t cm_rejects;
40597 +extern atomic_unchecked_t mod_qp_timouts;
40598 +extern atomic_unchecked_t qps_created;
40599 +extern atomic_unchecked_t qps_destroyed;
40600 +extern atomic_unchecked_t sw_qps_destroyed;
40601 extern u32 mh_detected;
40602 extern u32 mh_pauses_sent;
40603 extern u32 cm_packets_sent;
40604 @@ -196,16 +196,16 @@ extern u32 cm_packets_created;
40605 extern u32 cm_packets_received;
40606 extern u32 cm_packets_dropped;
40607 extern u32 cm_packets_retrans;
40608 -extern atomic_t cm_listens_created;
40609 -extern atomic_t cm_listens_destroyed;
40610 +extern atomic_unchecked_t cm_listens_created;
40611 +extern atomic_unchecked_t cm_listens_destroyed;
40612 extern u32 cm_backlog_drops;
40613 -extern atomic_t cm_loopbacks;
40614 -extern atomic_t cm_nodes_created;
40615 -extern atomic_t cm_nodes_destroyed;
40616 -extern atomic_t cm_accel_dropped_pkts;
40617 -extern atomic_t cm_resets_recvd;
40618 -extern atomic_t pau_qps_created;
40619 -extern atomic_t pau_qps_destroyed;
40620 +extern atomic_unchecked_t cm_loopbacks;
40621 +extern atomic_unchecked_t cm_nodes_created;
40622 +extern atomic_unchecked_t cm_nodes_destroyed;
40623 +extern atomic_unchecked_t cm_accel_dropped_pkts;
40624 +extern atomic_unchecked_t cm_resets_recvd;
40625 +extern atomic_unchecked_t pau_qps_created;
40626 +extern atomic_unchecked_t pau_qps_destroyed;
40627
40628 extern u32 int_mod_timer_init;
40629 extern u32 int_mod_cq_depth_256;
40630 diff --git a/drivers/infiniband/hw/nes/nes_cm.c b/drivers/infiniband/hw/nes/nes_cm.c
40631 index 6b29249..57081dd 100644
40632 --- a/drivers/infiniband/hw/nes/nes_cm.c
40633 +++ b/drivers/infiniband/hw/nes/nes_cm.c
40634 @@ -68,14 +68,14 @@ u32 cm_packets_dropped;
40635 u32 cm_packets_retrans;
40636 u32 cm_packets_created;
40637 u32 cm_packets_received;
40638 -atomic_t cm_listens_created;
40639 -atomic_t cm_listens_destroyed;
40640 +atomic_unchecked_t cm_listens_created;
40641 +atomic_unchecked_t cm_listens_destroyed;
40642 u32 cm_backlog_drops;
40643 -atomic_t cm_loopbacks;
40644 -atomic_t cm_nodes_created;
40645 -atomic_t cm_nodes_destroyed;
40646 -atomic_t cm_accel_dropped_pkts;
40647 -atomic_t cm_resets_recvd;
40648 +atomic_unchecked_t cm_loopbacks;
40649 +atomic_unchecked_t cm_nodes_created;
40650 +atomic_unchecked_t cm_nodes_destroyed;
40651 +atomic_unchecked_t cm_accel_dropped_pkts;
40652 +atomic_unchecked_t cm_resets_recvd;
40653
40654 static inline int mini_cm_accelerated(struct nes_cm_core *, struct nes_cm_node *);
40655 static struct nes_cm_listener *mini_cm_listen(struct nes_cm_core *, struct nes_vnic *, struct nes_cm_info *);
40656 @@ -148,13 +148,13 @@ static struct nes_cm_ops nes_cm_api = {
40657
40658 static struct nes_cm_core *g_cm_core;
40659
40660 -atomic_t cm_connects;
40661 -atomic_t cm_accepts;
40662 -atomic_t cm_disconnects;
40663 -atomic_t cm_closes;
40664 -atomic_t cm_connecteds;
40665 -atomic_t cm_connect_reqs;
40666 -atomic_t cm_rejects;
40667 +atomic_unchecked_t cm_connects;
40668 +atomic_unchecked_t cm_accepts;
40669 +atomic_unchecked_t cm_disconnects;
40670 +atomic_unchecked_t cm_closes;
40671 +atomic_unchecked_t cm_connecteds;
40672 +atomic_unchecked_t cm_connect_reqs;
40673 +atomic_unchecked_t cm_rejects;
40674
40675 int nes_add_ref_cm_node(struct nes_cm_node *cm_node)
40676 {
40677 @@ -1272,7 +1272,7 @@ static int mini_cm_dec_refcnt_listen(struct nes_cm_core *cm_core,
40678 kfree(listener);
40679 listener = NULL;
40680 ret = 0;
40681 - atomic_inc(&cm_listens_destroyed);
40682 + atomic_inc_unchecked(&cm_listens_destroyed);
40683 } else {
40684 spin_unlock_irqrestore(&cm_core->listen_list_lock, flags);
40685 }
40686 @@ -1466,7 +1466,7 @@ static struct nes_cm_node *make_cm_node(struct nes_cm_core *cm_core,
40687 cm_node->rem_mac);
40688
40689 add_hte_node(cm_core, cm_node);
40690 - atomic_inc(&cm_nodes_created);
40691 + atomic_inc_unchecked(&cm_nodes_created);
40692
40693 return cm_node;
40694 }
40695 @@ -1524,7 +1524,7 @@ static int rem_ref_cm_node(struct nes_cm_core *cm_core,
40696 }
40697
40698 atomic_dec(&cm_core->node_cnt);
40699 - atomic_inc(&cm_nodes_destroyed);
40700 + atomic_inc_unchecked(&cm_nodes_destroyed);
40701 nesqp = cm_node->nesqp;
40702 if (nesqp) {
40703 nesqp->cm_node = NULL;
40704 @@ -1588,7 +1588,7 @@ static int process_options(struct nes_cm_node *cm_node, u8 *optionsloc,
40705
40706 static void drop_packet(struct sk_buff *skb)
40707 {
40708 - atomic_inc(&cm_accel_dropped_pkts);
40709 + atomic_inc_unchecked(&cm_accel_dropped_pkts);
40710 dev_kfree_skb_any(skb);
40711 }
40712
40713 @@ -1651,7 +1651,7 @@ static void handle_rst_pkt(struct nes_cm_node *cm_node, struct sk_buff *skb,
40714 {
40715
40716 int reset = 0; /* whether to send reset in case of err.. */
40717 - atomic_inc(&cm_resets_recvd);
40718 + atomic_inc_unchecked(&cm_resets_recvd);
40719 nes_debug(NES_DBG_CM, "Received Reset, cm_node = %p, state = %u."
40720 " refcnt=%d\n", cm_node, cm_node->state,
40721 atomic_read(&cm_node->ref_count));
40722 @@ -2292,7 +2292,7 @@ static struct nes_cm_node *mini_cm_connect(struct nes_cm_core *cm_core,
40723 rem_ref_cm_node(cm_node->cm_core, cm_node);
40724 return NULL;
40725 }
40726 - atomic_inc(&cm_loopbacks);
40727 + atomic_inc_unchecked(&cm_loopbacks);
40728 loopbackremotenode->loopbackpartner = cm_node;
40729 loopbackremotenode->tcp_cntxt.rcv_wscale =
40730 NES_CM_DEFAULT_RCV_WND_SCALE;
40731 @@ -2567,7 +2567,7 @@ static int mini_cm_recv_pkt(struct nes_cm_core *cm_core,
40732 nes_queue_mgt_skbs(skb, nesvnic, cm_node->nesqp);
40733 else {
40734 rem_ref_cm_node(cm_core, cm_node);
40735 - atomic_inc(&cm_accel_dropped_pkts);
40736 + atomic_inc_unchecked(&cm_accel_dropped_pkts);
40737 dev_kfree_skb_any(skb);
40738 }
40739 break;
40740 @@ -2875,7 +2875,7 @@ static int nes_cm_disconn_true(struct nes_qp *nesqp)
40741
40742 if ((cm_id) && (cm_id->event_handler)) {
40743 if (issue_disconn) {
40744 - atomic_inc(&cm_disconnects);
40745 + atomic_inc_unchecked(&cm_disconnects);
40746 cm_event.event = IW_CM_EVENT_DISCONNECT;
40747 cm_event.status = disconn_status;
40748 cm_event.local_addr = cm_id->local_addr;
40749 @@ -2897,7 +2897,7 @@ static int nes_cm_disconn_true(struct nes_qp *nesqp)
40750 }
40751
40752 if (issue_close) {
40753 - atomic_inc(&cm_closes);
40754 + atomic_inc_unchecked(&cm_closes);
40755 nes_disconnect(nesqp, 1);
40756
40757 cm_id->provider_data = nesqp;
40758 @@ -3035,7 +3035,7 @@ int nes_accept(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param)
40759
40760 nes_debug(NES_DBG_CM, "QP%u, cm_node=%p, jiffies = %lu listener = %p\n",
40761 nesqp->hwqp.qp_id, cm_node, jiffies, cm_node->listener);
40762 - atomic_inc(&cm_accepts);
40763 + atomic_inc_unchecked(&cm_accepts);
40764
40765 nes_debug(NES_DBG_CM, "netdev refcnt = %u.\n",
40766 netdev_refcnt_read(nesvnic->netdev));
40767 @@ -3224,7 +3224,7 @@ int nes_reject(struct iw_cm_id *cm_id, const void *pdata, u8 pdata_len)
40768 struct nes_cm_core *cm_core;
40769 u8 *start_buff;
40770
40771 - atomic_inc(&cm_rejects);
40772 + atomic_inc_unchecked(&cm_rejects);
40773 cm_node = (struct nes_cm_node *)cm_id->provider_data;
40774 loopback = cm_node->loopbackpartner;
40775 cm_core = cm_node->cm_core;
40776 @@ -3286,7 +3286,7 @@ int nes_connect(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param)
40777 ntohs(raddr->sin_port), ntohl(laddr->sin_addr.s_addr),
40778 ntohs(laddr->sin_port));
40779
40780 - atomic_inc(&cm_connects);
40781 + atomic_inc_unchecked(&cm_connects);
40782 nesqp->active_conn = 1;
40783
40784 /* cache the cm_id in the qp */
40785 @@ -3398,7 +3398,7 @@ int nes_create_listen(struct iw_cm_id *cm_id, int backlog)
40786 g_cm_core->api->stop_listener(g_cm_core, (void *)cm_node);
40787 return err;
40788 }
40789 - atomic_inc(&cm_listens_created);
40790 + atomic_inc_unchecked(&cm_listens_created);
40791 }
40792
40793 cm_id->add_ref(cm_id);
40794 @@ -3505,7 +3505,7 @@ static void cm_event_connected(struct nes_cm_event *event)
40795
40796 if (nesqp->destroyed)
40797 return;
40798 - atomic_inc(&cm_connecteds);
40799 + atomic_inc_unchecked(&cm_connecteds);
40800 nes_debug(NES_DBG_CM, "QP%u attempting to connect to 0x%08X:0x%04X on"
40801 " local port 0x%04X. jiffies = %lu.\n",
40802 nesqp->hwqp.qp_id, ntohl(raddr->sin_addr.s_addr),
40803 @@ -3686,7 +3686,7 @@ static void cm_event_reset(struct nes_cm_event *event)
40804
40805 cm_id->add_ref(cm_id);
40806 ret = cm_id->event_handler(cm_id, &cm_event);
40807 - atomic_inc(&cm_closes);
40808 + atomic_inc_unchecked(&cm_closes);
40809 cm_event.event = IW_CM_EVENT_CLOSE;
40810 cm_event.status = 0;
40811 cm_event.provider_data = cm_id->provider_data;
40812 @@ -3726,7 +3726,7 @@ static void cm_event_mpa_req(struct nes_cm_event *event)
40813 return;
40814 cm_id = cm_node->cm_id;
40815
40816 - atomic_inc(&cm_connect_reqs);
40817 + atomic_inc_unchecked(&cm_connect_reqs);
40818 nes_debug(NES_DBG_CM, "cm_node = %p - cm_id = %p, jiffies = %lu\n",
40819 cm_node, cm_id, jiffies);
40820
40821 @@ -3770,7 +3770,7 @@ static void cm_event_mpa_reject(struct nes_cm_event *event)
40822 return;
40823 cm_id = cm_node->cm_id;
40824
40825 - atomic_inc(&cm_connect_reqs);
40826 + atomic_inc_unchecked(&cm_connect_reqs);
40827 nes_debug(NES_DBG_CM, "cm_node = %p - cm_id = %p, jiffies = %lu\n",
40828 cm_node, cm_id, jiffies);
40829
40830 diff --git a/drivers/infiniband/hw/nes/nes_mgt.c b/drivers/infiniband/hw/nes/nes_mgt.c
40831 index 4166452..fc952c3 100644
40832 --- a/drivers/infiniband/hw/nes/nes_mgt.c
40833 +++ b/drivers/infiniband/hw/nes/nes_mgt.c
40834 @@ -40,8 +40,8 @@
40835 #include "nes.h"
40836 #include "nes_mgt.h"
40837
40838 -atomic_t pau_qps_created;
40839 -atomic_t pau_qps_destroyed;
40840 +atomic_unchecked_t pau_qps_created;
40841 +atomic_unchecked_t pau_qps_destroyed;
40842
40843 static void nes_replenish_mgt_rq(struct nes_vnic_mgt *mgtvnic)
40844 {
40845 @@ -621,7 +621,7 @@ void nes_destroy_pau_qp(struct nes_device *nesdev, struct nes_qp *nesqp)
40846 {
40847 struct sk_buff *skb;
40848 unsigned long flags;
40849 - atomic_inc(&pau_qps_destroyed);
40850 + atomic_inc_unchecked(&pau_qps_destroyed);
40851
40852 /* Free packets that have not yet been forwarded */
40853 /* Lock is acquired by skb_dequeue when removing the skb */
40854 @@ -810,7 +810,7 @@ static void nes_mgt_ce_handler(struct nes_device *nesdev, struct nes_hw_nic_cq *
40855 cq->cq_vbase[head].cqe_words[NES_NIC_CQE_HASH_RCVNXT]);
40856 skb_queue_head_init(&nesqp->pau_list);
40857 spin_lock_init(&nesqp->pau_lock);
40858 - atomic_inc(&pau_qps_created);
40859 + atomic_inc_unchecked(&pau_qps_created);
40860 nes_change_quad_hash(nesdev, mgtvnic->nesvnic, nesqp);
40861 }
40862
40863 diff --git a/drivers/infiniband/hw/nes/nes_nic.c b/drivers/infiniband/hw/nes/nes_nic.c
40864 index 49eb511..a774366 100644
40865 --- a/drivers/infiniband/hw/nes/nes_nic.c
40866 +++ b/drivers/infiniband/hw/nes/nes_nic.c
40867 @@ -1273,39 +1273,39 @@ static void nes_netdev_get_ethtool_stats(struct net_device *netdev,
40868 target_stat_values[++index] = mh_detected;
40869 target_stat_values[++index] = mh_pauses_sent;
40870 target_stat_values[++index] = nesvnic->endnode_ipv4_tcp_retransmits;
40871 - target_stat_values[++index] = atomic_read(&cm_connects);
40872 - target_stat_values[++index] = atomic_read(&cm_accepts);
40873 - target_stat_values[++index] = atomic_read(&cm_disconnects);
40874 - target_stat_values[++index] = atomic_read(&cm_connecteds);
40875 - target_stat_values[++index] = atomic_read(&cm_connect_reqs);
40876 - target_stat_values[++index] = atomic_read(&cm_rejects);
40877 - target_stat_values[++index] = atomic_read(&mod_qp_timouts);
40878 - target_stat_values[++index] = atomic_read(&qps_created);
40879 - target_stat_values[++index] = atomic_read(&sw_qps_destroyed);
40880 - target_stat_values[++index] = atomic_read(&qps_destroyed);
40881 - target_stat_values[++index] = atomic_read(&cm_closes);
40882 + target_stat_values[++index] = atomic_read_unchecked(&cm_connects);
40883 + target_stat_values[++index] = atomic_read_unchecked(&cm_accepts);
40884 + target_stat_values[++index] = atomic_read_unchecked(&cm_disconnects);
40885 + target_stat_values[++index] = atomic_read_unchecked(&cm_connecteds);
40886 + target_stat_values[++index] = atomic_read_unchecked(&cm_connect_reqs);
40887 + target_stat_values[++index] = atomic_read_unchecked(&cm_rejects);
40888 + target_stat_values[++index] = atomic_read_unchecked(&mod_qp_timouts);
40889 + target_stat_values[++index] = atomic_read_unchecked(&qps_created);
40890 + target_stat_values[++index] = atomic_read_unchecked(&sw_qps_destroyed);
40891 + target_stat_values[++index] = atomic_read_unchecked(&qps_destroyed);
40892 + target_stat_values[++index] = atomic_read_unchecked(&cm_closes);
40893 target_stat_values[++index] = cm_packets_sent;
40894 target_stat_values[++index] = cm_packets_bounced;
40895 target_stat_values[++index] = cm_packets_created;
40896 target_stat_values[++index] = cm_packets_received;
40897 target_stat_values[++index] = cm_packets_dropped;
40898 target_stat_values[++index] = cm_packets_retrans;
40899 - target_stat_values[++index] = atomic_read(&cm_listens_created);
40900 - target_stat_values[++index] = atomic_read(&cm_listens_destroyed);
40901 + target_stat_values[++index] = atomic_read_unchecked(&cm_listens_created);
40902 + target_stat_values[++index] = atomic_read_unchecked(&cm_listens_destroyed);
40903 target_stat_values[++index] = cm_backlog_drops;
40904 - target_stat_values[++index] = atomic_read(&cm_loopbacks);
40905 - target_stat_values[++index] = atomic_read(&cm_nodes_created);
40906 - target_stat_values[++index] = atomic_read(&cm_nodes_destroyed);
40907 - target_stat_values[++index] = atomic_read(&cm_accel_dropped_pkts);
40908 - target_stat_values[++index] = atomic_read(&cm_resets_recvd);
40909 + target_stat_values[++index] = atomic_read_unchecked(&cm_loopbacks);
40910 + target_stat_values[++index] = atomic_read_unchecked(&cm_nodes_created);
40911 + target_stat_values[++index] = atomic_read_unchecked(&cm_nodes_destroyed);
40912 + target_stat_values[++index] = atomic_read_unchecked(&cm_accel_dropped_pkts);
40913 + target_stat_values[++index] = atomic_read_unchecked(&cm_resets_recvd);
40914 target_stat_values[++index] = nesadapter->free_4kpbl;
40915 target_stat_values[++index] = nesadapter->free_256pbl;
40916 target_stat_values[++index] = int_mod_timer_init;
40917 target_stat_values[++index] = nesvnic->lro_mgr.stats.aggregated;
40918 target_stat_values[++index] = nesvnic->lro_mgr.stats.flushed;
40919 target_stat_values[++index] = nesvnic->lro_mgr.stats.no_desc;
40920 - target_stat_values[++index] = atomic_read(&pau_qps_created);
40921 - target_stat_values[++index] = atomic_read(&pau_qps_destroyed);
40922 + target_stat_values[++index] = atomic_read_unchecked(&pau_qps_created);
40923 + target_stat_values[++index] = atomic_read_unchecked(&pau_qps_destroyed);
40924 }
40925
40926 /**
40927 diff --git a/drivers/infiniband/hw/nes/nes_verbs.c b/drivers/infiniband/hw/nes/nes_verbs.c
40928 index 5b53ca5..443da3c 100644
40929 --- a/drivers/infiniband/hw/nes/nes_verbs.c
40930 +++ b/drivers/infiniband/hw/nes/nes_verbs.c
40931 @@ -46,9 +46,9 @@
40932
40933 #include <rdma/ib_umem.h>
40934
40935 -atomic_t mod_qp_timouts;
40936 -atomic_t qps_created;
40937 -atomic_t sw_qps_destroyed;
40938 +atomic_unchecked_t mod_qp_timouts;
40939 +atomic_unchecked_t qps_created;
40940 +atomic_unchecked_t sw_qps_destroyed;
40941
40942 static void nes_unregister_ofa_device(struct nes_ib_device *nesibdev);
40943
40944 @@ -1134,7 +1134,7 @@ static struct ib_qp *nes_create_qp(struct ib_pd *ibpd,
40945 if (init_attr->create_flags)
40946 return ERR_PTR(-EINVAL);
40947
40948 - atomic_inc(&qps_created);
40949 + atomic_inc_unchecked(&qps_created);
40950 switch (init_attr->qp_type) {
40951 case IB_QPT_RC:
40952 if (nes_drv_opt & NES_DRV_OPT_NO_INLINE_DATA) {
40953 @@ -1466,7 +1466,7 @@ static int nes_destroy_qp(struct ib_qp *ibqp)
40954 struct iw_cm_event cm_event;
40955 int ret = 0;
40956
40957 - atomic_inc(&sw_qps_destroyed);
40958 + atomic_inc_unchecked(&sw_qps_destroyed);
40959 nesqp->destroyed = 1;
40960
40961 /* Blow away the connection if it exists. */
40962 diff --git a/drivers/infiniband/hw/qib/qib.h b/drivers/infiniband/hw/qib/qib.h
40963 index 1946101..09766d2 100644
40964 --- a/drivers/infiniband/hw/qib/qib.h
40965 +++ b/drivers/infiniband/hw/qib/qib.h
40966 @@ -52,6 +52,7 @@
40967 #include <linux/kref.h>
40968 #include <linux/sched.h>
40969 #include <linux/kthread.h>
40970 +#include <linux/slab.h>
40971
40972 #include "qib_common.h"
40973 #include "qib_verbs.h"
40974 diff --git a/drivers/input/gameport/gameport.c b/drivers/input/gameport/gameport.c
40975 index 922a7fe..bb035db 100644
40976 --- a/drivers/input/gameport/gameport.c
40977 +++ b/drivers/input/gameport/gameport.c
40978 @@ -487,14 +487,14 @@ EXPORT_SYMBOL(gameport_set_phys);
40979 */
40980 static void gameport_init_port(struct gameport *gameport)
40981 {
40982 - static atomic_t gameport_no = ATOMIC_INIT(0);
40983 + static atomic_unchecked_t gameport_no = ATOMIC_INIT(0);
40984
40985 __module_get(THIS_MODULE);
40986
40987 mutex_init(&gameport->drv_mutex);
40988 device_initialize(&gameport->dev);
40989 dev_set_name(&gameport->dev, "gameport%lu",
40990 - (unsigned long)atomic_inc_return(&gameport_no) - 1);
40991 + (unsigned long)atomic_inc_return_unchecked(&gameport_no) - 1);
40992 gameport->dev.bus = &gameport_bus;
40993 gameport->dev.release = gameport_release_port;
40994 if (gameport->parent)
40995 diff --git a/drivers/input/input.c b/drivers/input/input.c
40996 index e75d015..57d1c28 100644
40997 --- a/drivers/input/input.c
40998 +++ b/drivers/input/input.c
40999 @@ -1734,7 +1734,7 @@ EXPORT_SYMBOL_GPL(input_class);
41000 */
41001 struct input_dev *input_allocate_device(void)
41002 {
41003 - static atomic_t input_no = ATOMIC_INIT(0);
41004 + static atomic_unchecked_t input_no = ATOMIC_INIT(0);
41005 struct input_dev *dev;
41006
41007 dev = kzalloc(sizeof(struct input_dev), GFP_KERNEL);
41008 @@ -1749,7 +1749,7 @@ struct input_dev *input_allocate_device(void)
41009 INIT_LIST_HEAD(&dev->node);
41010
41011 dev_set_name(&dev->dev, "input%ld",
41012 - (unsigned long) atomic_inc_return(&input_no) - 1);
41013 + (unsigned long) atomic_inc_return_unchecked(&input_no) - 1);
41014
41015 __module_get(THIS_MODULE);
41016 }
41017 diff --git a/drivers/input/joystick/sidewinder.c b/drivers/input/joystick/sidewinder.c
41018 index 04c69af..5f92d00 100644
41019 --- a/drivers/input/joystick/sidewinder.c
41020 +++ b/drivers/input/joystick/sidewinder.c
41021 @@ -30,6 +30,7 @@
41022 #include <linux/kernel.h>
41023 #include <linux/module.h>
41024 #include <linux/slab.h>
41025 +#include <linux/sched.h>
41026 #include <linux/init.h>
41027 #include <linux/input.h>
41028 #include <linux/gameport.h>
41029 diff --git a/drivers/input/joystick/xpad.c b/drivers/input/joystick/xpad.c
41030 index 75e3b10..fb390fd 100644
41031 --- a/drivers/input/joystick/xpad.c
41032 +++ b/drivers/input/joystick/xpad.c
41033 @@ -736,7 +736,7 @@ static void xpad_led_set(struct led_classdev *led_cdev,
41034
41035 static int xpad_led_probe(struct usb_xpad *xpad)
41036 {
41037 - static atomic_t led_seq = ATOMIC_INIT(0);
41038 + static atomic_unchecked_t led_seq = ATOMIC_INIT(0);
41039 long led_no;
41040 struct xpad_led *led;
41041 struct led_classdev *led_cdev;
41042 @@ -749,7 +749,7 @@ static int xpad_led_probe(struct usb_xpad *xpad)
41043 if (!led)
41044 return -ENOMEM;
41045
41046 - led_no = (long)atomic_inc_return(&led_seq) - 1;
41047 + led_no = (long)atomic_inc_return_unchecked(&led_seq) - 1;
41048
41049 snprintf(led->name, sizeof(led->name), "xpad%ld", led_no);
41050 led->xpad = xpad;
41051 diff --git a/drivers/input/misc/ims-pcu.c b/drivers/input/misc/ims-pcu.c
41052 index e204f26..8459f15 100644
41053 --- a/drivers/input/misc/ims-pcu.c
41054 +++ b/drivers/input/misc/ims-pcu.c
41055 @@ -1621,7 +1621,7 @@ static int ims_pcu_identify_type(struct ims_pcu *pcu, u8 *device_id)
41056
41057 static int ims_pcu_init_application_mode(struct ims_pcu *pcu)
41058 {
41059 - static atomic_t device_no = ATOMIC_INIT(0);
41060 + static atomic_unchecked_t device_no = ATOMIC_INIT(0);
41061
41062 const struct ims_pcu_device_info *info;
41063 u8 device_id;
41064 @@ -1653,7 +1653,7 @@ static int ims_pcu_init_application_mode(struct ims_pcu *pcu)
41065 }
41066
41067 /* Device appears to be operable, complete initialization */
41068 - pcu->device_no = atomic_inc_return(&device_no) - 1;
41069 + pcu->device_no = atomic_inc_return_unchecked(&device_no) - 1;
41070
41071 error = ims_pcu_setup_backlight(pcu);
41072 if (error)
41073 diff --git a/drivers/input/mouse/psmouse.h b/drivers/input/mouse/psmouse.h
41074 index 2f0b39d..7370f13 100644
41075 --- a/drivers/input/mouse/psmouse.h
41076 +++ b/drivers/input/mouse/psmouse.h
41077 @@ -116,7 +116,7 @@ struct psmouse_attribute {
41078 ssize_t (*set)(struct psmouse *psmouse, void *data,
41079 const char *buf, size_t count);
41080 bool protect;
41081 -};
41082 +} __do_const;
41083 #define to_psmouse_attr(a) container_of((a), struct psmouse_attribute, dattr)
41084
41085 ssize_t psmouse_attr_show_helper(struct device *dev, struct device_attribute *attr,
41086 diff --git a/drivers/input/mousedev.c b/drivers/input/mousedev.c
41087 index 4c842c3..590b0bf 100644
41088 --- a/drivers/input/mousedev.c
41089 +++ b/drivers/input/mousedev.c
41090 @@ -738,7 +738,7 @@ static ssize_t mousedev_read(struct file *file, char __user *buffer,
41091
41092 spin_unlock_irq(&client->packet_lock);
41093
41094 - if (copy_to_user(buffer, data, count))
41095 + if (count > sizeof(data) || copy_to_user(buffer, data, count))
41096 return -EFAULT;
41097
41098 return count;
41099 diff --git a/drivers/input/serio/serio.c b/drivers/input/serio/serio.c
41100 index 2b56855..5a55837 100644
41101 --- a/drivers/input/serio/serio.c
41102 +++ b/drivers/input/serio/serio.c
41103 @@ -496,7 +496,7 @@ static void serio_release_port(struct device *dev)
41104 */
41105 static void serio_init_port(struct serio *serio)
41106 {
41107 - static atomic_t serio_no = ATOMIC_INIT(0);
41108 + static atomic_unchecked_t serio_no = ATOMIC_INIT(0);
41109
41110 __module_get(THIS_MODULE);
41111
41112 @@ -507,7 +507,7 @@ static void serio_init_port(struct serio *serio)
41113 mutex_init(&serio->drv_mutex);
41114 device_initialize(&serio->dev);
41115 dev_set_name(&serio->dev, "serio%ld",
41116 - (long)atomic_inc_return(&serio_no) - 1);
41117 + (long)atomic_inc_return_unchecked(&serio_no) - 1);
41118 serio->dev.bus = &serio_bus;
41119 serio->dev.release = serio_release_port;
41120 serio->dev.groups = serio_device_attr_groups;
41121 diff --git a/drivers/input/serio/serio_raw.c b/drivers/input/serio/serio_raw.c
41122 index 59df2e7..8f1cafb 100644
41123 --- a/drivers/input/serio/serio_raw.c
41124 +++ b/drivers/input/serio/serio_raw.c
41125 @@ -293,7 +293,7 @@ static irqreturn_t serio_raw_interrupt(struct serio *serio, unsigned char data,
41126
41127 static int serio_raw_connect(struct serio *serio, struct serio_driver *drv)
41128 {
41129 - static atomic_t serio_raw_no = ATOMIC_INIT(0);
41130 + static atomic_unchecked_t serio_raw_no = ATOMIC_INIT(0);
41131 struct serio_raw *serio_raw;
41132 int err;
41133
41134 @@ -304,7 +304,7 @@ static int serio_raw_connect(struct serio *serio, struct serio_driver *drv)
41135 }
41136
41137 snprintf(serio_raw->name, sizeof(serio_raw->name),
41138 - "serio_raw%ld", (long)atomic_inc_return(&serio_raw_no) - 1);
41139 + "serio_raw%ld", (long)atomic_inc_return_unchecked(&serio_raw_no) - 1);
41140 kref_init(&serio_raw->kref);
41141 INIT_LIST_HEAD(&serio_raw->client_list);
41142 init_waitqueue_head(&serio_raw->wait);
41143 diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c
41144 index fbe9ca7..dbee61d 100644
41145 --- a/drivers/iommu/iommu.c
41146 +++ b/drivers/iommu/iommu.c
41147 @@ -583,7 +583,7 @@ static struct notifier_block iommu_bus_nb = {
41148 static void iommu_bus_init(struct bus_type *bus, struct iommu_ops *ops)
41149 {
41150 bus_register_notifier(bus, &iommu_bus_nb);
41151 - bus_for_each_dev(bus, NULL, ops, add_iommu_group);
41152 + bus_for_each_dev(bus, NULL, (void *)ops, add_iommu_group);
41153 }
41154
41155 /**
41156 diff --git a/drivers/iommu/irq_remapping.c b/drivers/iommu/irq_remapping.c
41157 index 39f81ae..2660096 100644
41158 --- a/drivers/iommu/irq_remapping.c
41159 +++ b/drivers/iommu/irq_remapping.c
41160 @@ -356,7 +356,7 @@ int setup_hpet_msi_remapped(unsigned int irq, unsigned int id)
41161 void panic_if_irq_remap(const char *msg)
41162 {
41163 if (irq_remapping_enabled)
41164 - panic(msg);
41165 + panic("%s", msg);
41166 }
41167
41168 static void ir_ack_apic_edge(struct irq_data *data)
41169 @@ -377,10 +377,12 @@ static void ir_print_prefix(struct irq_data *data, struct seq_file *p)
41170
41171 void irq_remap_modify_chip_defaults(struct irq_chip *chip)
41172 {
41173 - chip->irq_print_chip = ir_print_prefix;
41174 - chip->irq_ack = ir_ack_apic_edge;
41175 - chip->irq_eoi = ir_ack_apic_level;
41176 - chip->irq_set_affinity = x86_io_apic_ops.set_affinity;
41177 + pax_open_kernel();
41178 + *(void **)&chip->irq_print_chip = ir_print_prefix;
41179 + *(void **)&chip->irq_ack = ir_ack_apic_edge;
41180 + *(void **)&chip->irq_eoi = ir_ack_apic_level;
41181 + *(void **)&chip->irq_set_affinity = x86_io_apic_ops.set_affinity;
41182 + pax_close_kernel();
41183 }
41184
41185 bool setup_remapped_irq(int irq, struct irq_cfg *cfg, struct irq_chip *chip)
41186 diff --git a/drivers/irqchip/irq-gic.c b/drivers/irqchip/irq-gic.c
41187 index d0e9480..d2b6340 100644
41188 --- a/drivers/irqchip/irq-gic.c
41189 +++ b/drivers/irqchip/irq-gic.c
41190 @@ -84,7 +84,7 @@ static u8 gic_cpu_map[NR_GIC_CPU_IF] __read_mostly;
41191 * Supported arch specific GIC irq extension.
41192 * Default make them NULL.
41193 */
41194 -struct irq_chip gic_arch_extn = {
41195 +irq_chip_no_const gic_arch_extn = {
41196 .irq_eoi = NULL,
41197 .irq_mask = NULL,
41198 .irq_unmask = NULL,
41199 @@ -333,7 +333,7 @@ static void gic_handle_cascade_irq(unsigned int irq, struct irq_desc *desc)
41200 chained_irq_exit(chip, desc);
41201 }
41202
41203 -static struct irq_chip gic_chip = {
41204 +static irq_chip_no_const gic_chip __read_only = {
41205 .name = "GIC",
41206 .irq_mask = gic_mask_irq,
41207 .irq_unmask = gic_unmask_irq,
41208 diff --git a/drivers/isdn/capi/capi.c b/drivers/isdn/capi/capi.c
41209 index ac6f72b..81150f2 100644
41210 --- a/drivers/isdn/capi/capi.c
41211 +++ b/drivers/isdn/capi/capi.c
41212 @@ -81,8 +81,8 @@ struct capiminor {
41213
41214 struct capi20_appl *ap;
41215 u32 ncci;
41216 - atomic_t datahandle;
41217 - atomic_t msgid;
41218 + atomic_unchecked_t datahandle;
41219 + atomic_unchecked_t msgid;
41220
41221 struct tty_port port;
41222 int ttyinstop;
41223 @@ -391,7 +391,7 @@ gen_data_b3_resp_for(struct capiminor *mp, struct sk_buff *skb)
41224 capimsg_setu16(s, 2, mp->ap->applid);
41225 capimsg_setu8 (s, 4, CAPI_DATA_B3);
41226 capimsg_setu8 (s, 5, CAPI_RESP);
41227 - capimsg_setu16(s, 6, atomic_inc_return(&mp->msgid));
41228 + capimsg_setu16(s, 6, atomic_inc_return_unchecked(&mp->msgid));
41229 capimsg_setu32(s, 8, mp->ncci);
41230 capimsg_setu16(s, 12, datahandle);
41231 }
41232 @@ -512,14 +512,14 @@ static void handle_minor_send(struct capiminor *mp)
41233 mp->outbytes -= len;
41234 spin_unlock_bh(&mp->outlock);
41235
41236 - datahandle = atomic_inc_return(&mp->datahandle);
41237 + datahandle = atomic_inc_return_unchecked(&mp->datahandle);
41238 skb_push(skb, CAPI_DATA_B3_REQ_LEN);
41239 memset(skb->data, 0, CAPI_DATA_B3_REQ_LEN);
41240 capimsg_setu16(skb->data, 0, CAPI_DATA_B3_REQ_LEN);
41241 capimsg_setu16(skb->data, 2, mp->ap->applid);
41242 capimsg_setu8 (skb->data, 4, CAPI_DATA_B3);
41243 capimsg_setu8 (skb->data, 5, CAPI_REQ);
41244 - capimsg_setu16(skb->data, 6, atomic_inc_return(&mp->msgid));
41245 + capimsg_setu16(skb->data, 6, atomic_inc_return_unchecked(&mp->msgid));
41246 capimsg_setu32(skb->data, 8, mp->ncci); /* NCCI */
41247 capimsg_setu32(skb->data, 12, (u32)(long)skb->data);/* Data32 */
41248 capimsg_setu16(skb->data, 16, len); /* Data length */
41249 diff --git a/drivers/isdn/gigaset/interface.c b/drivers/isdn/gigaset/interface.c
41250 index 600c79b..3752bab 100644
41251 --- a/drivers/isdn/gigaset/interface.c
41252 +++ b/drivers/isdn/gigaset/interface.c
41253 @@ -130,9 +130,9 @@ static int if_open(struct tty_struct *tty, struct file *filp)
41254 }
41255 tty->driver_data = cs;
41256
41257 - ++cs->port.count;
41258 + atomic_inc(&cs->port.count);
41259
41260 - if (cs->port.count == 1) {
41261 + if (atomic_read(&cs->port.count) == 1) {
41262 tty_port_tty_set(&cs->port, tty);
41263 cs->port.low_latency = 1;
41264 }
41265 @@ -156,9 +156,9 @@ static void if_close(struct tty_struct *tty, struct file *filp)
41266
41267 if (!cs->connected)
41268 gig_dbg(DEBUG_IF, "not connected"); /* nothing to do */
41269 - else if (!cs->port.count)
41270 + else if (!atomic_read(&cs->port.count))
41271 dev_warn(cs->dev, "%s: device not opened\n", __func__);
41272 - else if (!--cs->port.count)
41273 + else if (!atomic_dec_return(&cs->port.count))
41274 tty_port_tty_set(&cs->port, NULL);
41275
41276 mutex_unlock(&cs->mutex);
41277 diff --git a/drivers/isdn/gigaset/usb-gigaset.c b/drivers/isdn/gigaset/usb-gigaset.c
41278 index d0a41cb..f0cdb8c 100644
41279 --- a/drivers/isdn/gigaset/usb-gigaset.c
41280 +++ b/drivers/isdn/gigaset/usb-gigaset.c
41281 @@ -547,7 +547,7 @@ static int gigaset_brkchars(struct cardstate *cs, const unsigned char buf[6])
41282 gigaset_dbg_buffer(DEBUG_USBREQ, "brkchars", 6, buf);
41283 memcpy(cs->hw.usb->bchars, buf, 6);
41284 return usb_control_msg(udev, usb_sndctrlpipe(udev, 0), 0x19, 0x41,
41285 - 0, 0, &buf, 6, 2000);
41286 + 0, 0, buf, 6, 2000);
41287 }
41288
41289 static void gigaset_freebcshw(struct bc_state *bcs)
41290 diff --git a/drivers/isdn/hardware/avm/b1.c b/drivers/isdn/hardware/avm/b1.c
41291 index 4d9b195..455075c 100644
41292 --- a/drivers/isdn/hardware/avm/b1.c
41293 +++ b/drivers/isdn/hardware/avm/b1.c
41294 @@ -176,7 +176,7 @@ int b1_load_t4file(avmcard *card, capiloaddatapart *t4file)
41295 }
41296 if (left) {
41297 if (t4file->user) {
41298 - if (copy_from_user(buf, dp, left))
41299 + if (left > sizeof buf || copy_from_user(buf, dp, left))
41300 return -EFAULT;
41301 } else {
41302 memcpy(buf, dp, left);
41303 @@ -224,7 +224,7 @@ int b1_load_config(avmcard *card, capiloaddatapart *config)
41304 }
41305 if (left) {
41306 if (config->user) {
41307 - if (copy_from_user(buf, dp, left))
41308 + if (left > sizeof buf || copy_from_user(buf, dp, left))
41309 return -EFAULT;
41310 } else {
41311 memcpy(buf, dp, left);
41312 diff --git a/drivers/isdn/i4l/isdn_common.c b/drivers/isdn/i4l/isdn_common.c
41313 index 9bb12ba..d4262f7 100644
41314 --- a/drivers/isdn/i4l/isdn_common.c
41315 +++ b/drivers/isdn/i4l/isdn_common.c
41316 @@ -1651,6 +1651,8 @@ isdn_ioctl(struct file *file, uint cmd, ulong arg)
41317 } else
41318 return -EINVAL;
41319 case IIOCDBGVAR:
41320 + if (!capable(CAP_SYS_RAWIO))
41321 + return -EPERM;
41322 if (arg) {
41323 if (copy_to_user(argp, &dev, sizeof(ulong)))
41324 return -EFAULT;
41325 diff --git a/drivers/isdn/i4l/isdn_tty.c b/drivers/isdn/i4l/isdn_tty.c
41326 index 3c5f249..5fac4d0 100644
41327 --- a/drivers/isdn/i4l/isdn_tty.c
41328 +++ b/drivers/isdn/i4l/isdn_tty.c
41329 @@ -1508,9 +1508,9 @@ isdn_tty_open(struct tty_struct *tty, struct file *filp)
41330
41331 #ifdef ISDN_DEBUG_MODEM_OPEN
41332 printk(KERN_DEBUG "isdn_tty_open %s, count = %d\n", tty->name,
41333 - port->count);
41334 + atomic_read(&port->count));
41335 #endif
41336 - port->count++;
41337 + atomic_inc(&port->count);
41338 port->tty = tty;
41339 /*
41340 * Start up serial port
41341 @@ -1554,7 +1554,7 @@ isdn_tty_close(struct tty_struct *tty, struct file *filp)
41342 #endif
41343 return;
41344 }
41345 - if ((tty->count == 1) && (port->count != 1)) {
41346 + if ((tty->count == 1) && (atomic_read(&port->count) != 1)) {
41347 /*
41348 * Uh, oh. tty->count is 1, which means that the tty
41349 * structure will be freed. Info->count should always
41350 @@ -1563,15 +1563,15 @@ isdn_tty_close(struct tty_struct *tty, struct file *filp)
41351 * serial port won't be shutdown.
41352 */
41353 printk(KERN_ERR "isdn_tty_close: bad port count; tty->count is 1, "
41354 - "info->count is %d\n", port->count);
41355 - port->count = 1;
41356 + "info->count is %d\n", atomic_read(&port->count));
41357 + atomic_set(&port->count, 1);
41358 }
41359 - if (--port->count < 0) {
41360 + if (atomic_dec_return(&port->count) < 0) {
41361 printk(KERN_ERR "isdn_tty_close: bad port count for ttyi%d: %d\n",
41362 - info->line, port->count);
41363 - port->count = 0;
41364 + info->line, atomic_read(&port->count));
41365 + atomic_set(&port->count, 0);
41366 }
41367 - if (port->count) {
41368 + if (atomic_read(&port->count)) {
41369 #ifdef ISDN_DEBUG_MODEM_OPEN
41370 printk(KERN_DEBUG "isdn_tty_close after info->count != 0\n");
41371 #endif
41372 @@ -1625,7 +1625,7 @@ isdn_tty_hangup(struct tty_struct *tty)
41373 if (isdn_tty_paranoia_check(info, tty->name, "isdn_tty_hangup"))
41374 return;
41375 isdn_tty_shutdown(info);
41376 - port->count = 0;
41377 + atomic_set(&port->count, 0);
41378 port->flags &= ~ASYNC_NORMAL_ACTIVE;
41379 port->tty = NULL;
41380 wake_up_interruptible(&port->open_wait);
41381 @@ -1970,7 +1970,7 @@ isdn_tty_find_icall(int di, int ch, setup_parm *setup)
41382 for (i = 0; i < ISDN_MAX_CHANNELS; i++) {
41383 modem_info *info = &dev->mdm.info[i];
41384
41385 - if (info->port.count == 0)
41386 + if (atomic_read(&info->port.count) == 0)
41387 continue;
41388 if ((info->emu.mdmreg[REG_SI1] & si2bit[si1]) && /* SI1 is matching */
41389 (info->emu.mdmreg[REG_SI2] == si2)) { /* SI2 is matching */
41390 diff --git a/drivers/isdn/icn/icn.c b/drivers/isdn/icn/icn.c
41391 index e74df7c..03a03ba 100644
41392 --- a/drivers/isdn/icn/icn.c
41393 +++ b/drivers/isdn/icn/icn.c
41394 @@ -1045,7 +1045,7 @@ icn_writecmd(const u_char *buf, int len, int user, icn_card *card)
41395 if (count > len)
41396 count = len;
41397 if (user) {
41398 - if (copy_from_user(msg, buf, count))
41399 + if (count > sizeof msg || copy_from_user(msg, buf, count))
41400 return -EFAULT;
41401 } else
41402 memcpy(msg, buf, count);
41403 diff --git a/drivers/isdn/mISDN/dsp_cmx.c b/drivers/isdn/mISDN/dsp_cmx.c
41404 index a4f05c5..1433bc5 100644
41405 --- a/drivers/isdn/mISDN/dsp_cmx.c
41406 +++ b/drivers/isdn/mISDN/dsp_cmx.c
41407 @@ -1628,7 +1628,7 @@ unsigned long dsp_spl_jiffies; /* calculate the next time to fire */
41408 static u16 dsp_count; /* last sample count */
41409 static int dsp_count_valid; /* if we have last sample count */
41410
41411 -void
41412 +void __intentional_overflow(-1)
41413 dsp_cmx_send(void *arg)
41414 {
41415 struct dsp_conf *conf;
41416 diff --git a/drivers/leds/leds-clevo-mail.c b/drivers/leds/leds-clevo-mail.c
41417 index d93e245..e7ece6b 100644
41418 --- a/drivers/leds/leds-clevo-mail.c
41419 +++ b/drivers/leds/leds-clevo-mail.c
41420 @@ -40,7 +40,7 @@ static int __init clevo_mail_led_dmi_callback(const struct dmi_system_id *id)
41421 * detected as working, but in reality it is not) as low as
41422 * possible.
41423 */
41424 -static struct dmi_system_id clevo_mail_led_dmi_table[] __initdata = {
41425 +static struct dmi_system_id clevo_mail_led_dmi_table[] __initconst = {
41426 {
41427 .callback = clevo_mail_led_dmi_callback,
41428 .ident = "Clevo D410J",
41429 diff --git a/drivers/leds/leds-ss4200.c b/drivers/leds/leds-ss4200.c
41430 index 5b8f938..b73d657 100644
41431 --- a/drivers/leds/leds-ss4200.c
41432 +++ b/drivers/leds/leds-ss4200.c
41433 @@ -91,7 +91,7 @@ MODULE_PARM_DESC(nodetect, "Skip DMI-based hardware detection");
41434 * detected as working, but in reality it is not) as low as
41435 * possible.
41436 */
41437 -static struct dmi_system_id nas_led_whitelist[] __initdata = {
41438 +static struct dmi_system_id nas_led_whitelist[] __initconst = {
41439 {
41440 .callback = ss4200_led_dmi_callback,
41441 .ident = "Intel SS4200-E",
41442 diff --git a/drivers/lguest/core.c b/drivers/lguest/core.c
41443 index 0bf1e4e..b4bf44e 100644
41444 --- a/drivers/lguest/core.c
41445 +++ b/drivers/lguest/core.c
41446 @@ -97,9 +97,17 @@ static __init int map_switcher(void)
41447 * The end address needs +1 because __get_vm_area allocates an
41448 * extra guard page, so we need space for that.
41449 */
41450 +
41451 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
41452 + switcher_vma = __get_vm_area(TOTAL_SWITCHER_PAGES * PAGE_SIZE,
41453 + VM_ALLOC | VM_KERNEXEC, switcher_addr, switcher_addr
41454 + + (TOTAL_SWITCHER_PAGES+1) * PAGE_SIZE);
41455 +#else
41456 switcher_vma = __get_vm_area(TOTAL_SWITCHER_PAGES * PAGE_SIZE,
41457 VM_ALLOC, switcher_addr, switcher_addr
41458 + (TOTAL_SWITCHER_PAGES+1) * PAGE_SIZE);
41459 +#endif
41460 +
41461 if (!switcher_vma) {
41462 err = -ENOMEM;
41463 printk("lguest: could not map switcher pages high\n");
41464 @@ -124,7 +132,7 @@ static __init int map_switcher(void)
41465 * Now the Switcher is mapped at the right address, we can't fail!
41466 * Copy in the compiled-in Switcher code (from x86/switcher_32.S).
41467 */
41468 - memcpy(switcher_vma->addr, start_switcher_text,
41469 + memcpy(switcher_vma->addr, ktla_ktva(start_switcher_text),
41470 end_switcher_text - start_switcher_text);
41471
41472 printk(KERN_INFO "lguest: mapped switcher at %p\n",
41473 diff --git a/drivers/lguest/page_tables.c b/drivers/lguest/page_tables.c
41474 index bfb39bb..08a603b 100644
41475 --- a/drivers/lguest/page_tables.c
41476 +++ b/drivers/lguest/page_tables.c
41477 @@ -559,7 +559,7 @@ void pin_page(struct lg_cpu *cpu, unsigned long vaddr)
41478 /*:*/
41479
41480 #ifdef CONFIG_X86_PAE
41481 -static void release_pmd(pmd_t *spmd)
41482 +static void __intentional_overflow(-1) release_pmd(pmd_t *spmd)
41483 {
41484 /* If the entry's not present, there's nothing to release. */
41485 if (pmd_flags(*spmd) & _PAGE_PRESENT) {
41486 diff --git a/drivers/lguest/x86/core.c b/drivers/lguest/x86/core.c
41487 index 5169239..47cb4db 100644
41488 --- a/drivers/lguest/x86/core.c
41489 +++ b/drivers/lguest/x86/core.c
41490 @@ -59,7 +59,7 @@ static struct {
41491 /* Offset from where switcher.S was compiled to where we've copied it */
41492 static unsigned long switcher_offset(void)
41493 {
41494 - return switcher_addr - (unsigned long)start_switcher_text;
41495 + return switcher_addr - (unsigned long)ktla_ktva(start_switcher_text);
41496 }
41497
41498 /* This cpu's struct lguest_pages (after the Switcher text page) */
41499 @@ -99,7 +99,13 @@ static void copy_in_guest_info(struct lg_cpu *cpu, struct lguest_pages *pages)
41500 * These copies are pretty cheap, so we do them unconditionally: */
41501 /* Save the current Host top-level page directory.
41502 */
41503 +
41504 +#ifdef CONFIG_PAX_PER_CPU_PGD
41505 + pages->state.host_cr3 = read_cr3();
41506 +#else
41507 pages->state.host_cr3 = __pa(current->mm->pgd);
41508 +#endif
41509 +
41510 /*
41511 * Set up the Guest's page tables to see this CPU's pages (and no
41512 * other CPU's pages).
41513 @@ -475,7 +481,7 @@ void __init lguest_arch_host_init(void)
41514 * compiled-in switcher code and the high-mapped copy we just made.
41515 */
41516 for (i = 0; i < IDT_ENTRIES; i++)
41517 - default_idt_entries[i] += switcher_offset();
41518 + default_idt_entries[i] = ktla_ktva(default_idt_entries[i]) + switcher_offset();
41519
41520 /*
41521 * Set up the Switcher's per-cpu areas.
41522 @@ -558,7 +564,7 @@ void __init lguest_arch_host_init(void)
41523 * it will be undisturbed when we switch. To change %cs and jump we
41524 * need this structure to feed to Intel's "lcall" instruction.
41525 */
41526 - lguest_entry.offset = (long)switch_to_guest + switcher_offset();
41527 + lguest_entry.offset = (long)ktla_ktva(switch_to_guest) + switcher_offset();
41528 lguest_entry.segment = LGUEST_CS;
41529
41530 /*
41531 diff --git a/drivers/lguest/x86/switcher_32.S b/drivers/lguest/x86/switcher_32.S
41532 index 40634b0..4f5855e 100644
41533 --- a/drivers/lguest/x86/switcher_32.S
41534 +++ b/drivers/lguest/x86/switcher_32.S
41535 @@ -87,6 +87,7 @@
41536 #include <asm/page.h>
41537 #include <asm/segment.h>
41538 #include <asm/lguest.h>
41539 +#include <asm/processor-flags.h>
41540
41541 // We mark the start of the code to copy
41542 // It's placed in .text tho it's never run here
41543 @@ -149,6 +150,13 @@ ENTRY(switch_to_guest)
41544 // Changes type when we load it: damn Intel!
41545 // For after we switch over our page tables
41546 // That entry will be read-only: we'd crash.
41547 +
41548 +#ifdef CONFIG_PAX_KERNEXEC
41549 + mov %cr0, %edx
41550 + xor $X86_CR0_WP, %edx
41551 + mov %edx, %cr0
41552 +#endif
41553 +
41554 movl $(GDT_ENTRY_TSS*8), %edx
41555 ltr %dx
41556
41557 @@ -157,9 +165,15 @@ ENTRY(switch_to_guest)
41558 // Let's clear it again for our return.
41559 // The GDT descriptor of the Host
41560 // Points to the table after two "size" bytes
41561 - movl (LGUEST_PAGES_host_gdt_desc+2)(%eax), %edx
41562 + movl (LGUEST_PAGES_host_gdt_desc+2)(%eax), %eax
41563 // Clear "used" from type field (byte 5, bit 2)
41564 - andb $0xFD, (GDT_ENTRY_TSS*8 + 5)(%edx)
41565 + andb $0xFD, (GDT_ENTRY_TSS*8 + 5)(%eax)
41566 +
41567 +#ifdef CONFIG_PAX_KERNEXEC
41568 + mov %cr0, %eax
41569 + xor $X86_CR0_WP, %eax
41570 + mov %eax, %cr0
41571 +#endif
41572
41573 // Once our page table's switched, the Guest is live!
41574 // The Host fades as we run this final step.
41575 @@ -295,13 +309,12 @@ deliver_to_host:
41576 // I consulted gcc, and it gave
41577 // These instructions, which I gladly credit:
41578 leal (%edx,%ebx,8), %eax
41579 - movzwl (%eax),%edx
41580 - movl 4(%eax), %eax
41581 - xorw %ax, %ax
41582 - orl %eax, %edx
41583 + movl 4(%eax), %edx
41584 + movw (%eax), %dx
41585 // Now the address of the handler's in %edx
41586 // We call it now: its "iret" drops us home.
41587 - jmp *%edx
41588 + ljmp $__KERNEL_CS, $1f
41589 +1: jmp *%edx
41590
41591 // Every interrupt can come to us here
41592 // But we must truly tell each apart.
41593 diff --git a/drivers/md/bcache/closure.h b/drivers/md/bcache/closure.h
41594 index 0003992..854bbce 100644
41595 --- a/drivers/md/bcache/closure.h
41596 +++ b/drivers/md/bcache/closure.h
41597 @@ -622,7 +622,7 @@ static inline void closure_wake_up(struct closure_waitlist *list)
41598 static inline void set_closure_fn(struct closure *cl, closure_fn *fn,
41599 struct workqueue_struct *wq)
41600 {
41601 - BUG_ON(object_is_on_stack(cl));
41602 + BUG_ON(object_starts_on_stack(cl));
41603 closure_set_ip(cl);
41604 cl->fn = fn;
41605 cl->wq = wq;
41606 diff --git a/drivers/md/bcache/super.c b/drivers/md/bcache/super.c
41607 index 547c4c5..5be1de4 100644
41608 --- a/drivers/md/bcache/super.c
41609 +++ b/drivers/md/bcache/super.c
41610 @@ -1644,7 +1644,7 @@ err_unlock_gc:
41611 err:
41612 closure_sync(&op.cl);
41613 /* XXX: test this, it's broken */
41614 - bch_cache_set_error(c, err);
41615 + bch_cache_set_error(c, "%s", err);
41616 }
41617
41618 static bool can_attach_cache(struct cache *ca, struct cache_set *c)
41619 diff --git a/drivers/md/bitmap.c b/drivers/md/bitmap.c
41620 index a7fd821..9dcf6c3 100644
41621 --- a/drivers/md/bitmap.c
41622 +++ b/drivers/md/bitmap.c
41623 @@ -1779,7 +1779,7 @@ void bitmap_status(struct seq_file *seq, struct bitmap *bitmap)
41624 chunk_kb ? "KB" : "B");
41625 if (bitmap->storage.file) {
41626 seq_printf(seq, ", file: ");
41627 - seq_path(seq, &bitmap->storage.file->f_path, " \t\n");
41628 + seq_path(seq, &bitmap->storage.file->f_path, " \t\n\\");
41629 }
41630
41631 seq_printf(seq, "\n");
41632 diff --git a/drivers/md/dm-ioctl.c b/drivers/md/dm-ioctl.c
41633 index afe0814..8cf3794 100644
41634 --- a/drivers/md/dm-ioctl.c
41635 +++ b/drivers/md/dm-ioctl.c
41636 @@ -1745,7 +1745,7 @@ static int validate_params(uint cmd, struct dm_ioctl *param)
41637 cmd == DM_LIST_VERSIONS_CMD)
41638 return 0;
41639
41640 - if ((cmd == DM_DEV_CREATE_CMD)) {
41641 + if (cmd == DM_DEV_CREATE_CMD) {
41642 if (!*param->name) {
41643 DMWARN("name not supplied when creating device");
41644 return -EINVAL;
41645 diff --git a/drivers/md/dm-raid1.c b/drivers/md/dm-raid1.c
41646 index 9584443..9fc9ac9 100644
41647 --- a/drivers/md/dm-raid1.c
41648 +++ b/drivers/md/dm-raid1.c
41649 @@ -40,7 +40,7 @@ enum dm_raid1_error {
41650
41651 struct mirror {
41652 struct mirror_set *ms;
41653 - atomic_t error_count;
41654 + atomic_unchecked_t error_count;
41655 unsigned long error_type;
41656 struct dm_dev *dev;
41657 sector_t offset;
41658 @@ -186,7 +186,7 @@ static struct mirror *get_valid_mirror(struct mirror_set *ms)
41659 struct mirror *m;
41660
41661 for (m = ms->mirror; m < ms->mirror + ms->nr_mirrors; m++)
41662 - if (!atomic_read(&m->error_count))
41663 + if (!atomic_read_unchecked(&m->error_count))
41664 return m;
41665
41666 return NULL;
41667 @@ -218,7 +218,7 @@ static void fail_mirror(struct mirror *m, enum dm_raid1_error error_type)
41668 * simple way to tell if a device has encountered
41669 * errors.
41670 */
41671 - atomic_inc(&m->error_count);
41672 + atomic_inc_unchecked(&m->error_count);
41673
41674 if (test_and_set_bit(error_type, &m->error_type))
41675 return;
41676 @@ -409,7 +409,7 @@ static struct mirror *choose_mirror(struct mirror_set *ms, sector_t sector)
41677 struct mirror *m = get_default_mirror(ms);
41678
41679 do {
41680 - if (likely(!atomic_read(&m->error_count)))
41681 + if (likely(!atomic_read_unchecked(&m->error_count)))
41682 return m;
41683
41684 if (m-- == ms->mirror)
41685 @@ -423,7 +423,7 @@ static int default_ok(struct mirror *m)
41686 {
41687 struct mirror *default_mirror = get_default_mirror(m->ms);
41688
41689 - return !atomic_read(&default_mirror->error_count);
41690 + return !atomic_read_unchecked(&default_mirror->error_count);
41691 }
41692
41693 static int mirror_available(struct mirror_set *ms, struct bio *bio)
41694 @@ -560,7 +560,7 @@ static void do_reads(struct mirror_set *ms, struct bio_list *reads)
41695 */
41696 if (likely(region_in_sync(ms, region, 1)))
41697 m = choose_mirror(ms, bio->bi_sector);
41698 - else if (m && atomic_read(&m->error_count))
41699 + else if (m && atomic_read_unchecked(&m->error_count))
41700 m = NULL;
41701
41702 if (likely(m))
41703 @@ -927,7 +927,7 @@ static int get_mirror(struct mirror_set *ms, struct dm_target *ti,
41704 }
41705
41706 ms->mirror[mirror].ms = ms;
41707 - atomic_set(&(ms->mirror[mirror].error_count), 0);
41708 + atomic_set_unchecked(&(ms->mirror[mirror].error_count), 0);
41709 ms->mirror[mirror].error_type = 0;
41710 ms->mirror[mirror].offset = offset;
41711
41712 @@ -1339,7 +1339,7 @@ static void mirror_resume(struct dm_target *ti)
41713 */
41714 static char device_status_char(struct mirror *m)
41715 {
41716 - if (!atomic_read(&(m->error_count)))
41717 + if (!atomic_read_unchecked(&(m->error_count)))
41718 return 'A';
41719
41720 return (test_bit(DM_RAID1_FLUSH_ERROR, &(m->error_type))) ? 'F' :
41721 diff --git a/drivers/md/dm-stats.c b/drivers/md/dm-stats.c
41722 index 3d404c1..b62af0e 100644
41723 --- a/drivers/md/dm-stats.c
41724 +++ b/drivers/md/dm-stats.c
41725 @@ -382,7 +382,7 @@ do_sync_free:
41726 synchronize_rcu_expedited();
41727 dm_stat_free(&s->rcu_head);
41728 } else {
41729 - ACCESS_ONCE(dm_stat_need_rcu_barrier) = 1;
41730 + ACCESS_ONCE_RW(dm_stat_need_rcu_barrier) = 1;
41731 call_rcu(&s->rcu_head, dm_stat_free);
41732 }
41733 return 0;
41734 @@ -554,8 +554,8 @@ void dm_stats_account_io(struct dm_stats *stats, unsigned long bi_rw,
41735 ((bi_rw & (REQ_WRITE | REQ_DISCARD)) ==
41736 (ACCESS_ONCE(last->last_rw) & (REQ_WRITE | REQ_DISCARD)))
41737 ));
41738 - ACCESS_ONCE(last->last_sector) = end_sector;
41739 - ACCESS_ONCE(last->last_rw) = bi_rw;
41740 + ACCESS_ONCE_RW(last->last_sector) = end_sector;
41741 + ACCESS_ONCE_RW(last->last_rw) = bi_rw;
41742 }
41743
41744 rcu_read_lock();
41745 diff --git a/drivers/md/dm-stripe.c b/drivers/md/dm-stripe.c
41746 index 73c1712..7347292 100644
41747 --- a/drivers/md/dm-stripe.c
41748 +++ b/drivers/md/dm-stripe.c
41749 @@ -21,7 +21,7 @@ struct stripe {
41750 struct dm_dev *dev;
41751 sector_t physical_start;
41752
41753 - atomic_t error_count;
41754 + atomic_unchecked_t error_count;
41755 };
41756
41757 struct stripe_c {
41758 @@ -186,7 +186,7 @@ static int stripe_ctr(struct dm_target *ti, unsigned int argc, char **argv)
41759 kfree(sc);
41760 return r;
41761 }
41762 - atomic_set(&(sc->stripe[i].error_count), 0);
41763 + atomic_set_unchecked(&(sc->stripe[i].error_count), 0);
41764 }
41765
41766 ti->private = sc;
41767 @@ -327,7 +327,7 @@ static void stripe_status(struct dm_target *ti, status_type_t type,
41768 DMEMIT("%d ", sc->stripes);
41769 for (i = 0; i < sc->stripes; i++) {
41770 DMEMIT("%s ", sc->stripe[i].dev->name);
41771 - buffer[i] = atomic_read(&(sc->stripe[i].error_count)) ?
41772 + buffer[i] = atomic_read_unchecked(&(sc->stripe[i].error_count)) ?
41773 'D' : 'A';
41774 }
41775 buffer[i] = '\0';
41776 @@ -372,8 +372,8 @@ static int stripe_end_io(struct dm_target *ti, struct bio *bio, int error)
41777 */
41778 for (i = 0; i < sc->stripes; i++)
41779 if (!strcmp(sc->stripe[i].dev->name, major_minor)) {
41780 - atomic_inc(&(sc->stripe[i].error_count));
41781 - if (atomic_read(&(sc->stripe[i].error_count)) <
41782 + atomic_inc_unchecked(&(sc->stripe[i].error_count));
41783 + if (atomic_read_unchecked(&(sc->stripe[i].error_count)) <
41784 DM_IO_ERROR_THRESHOLD)
41785 schedule_work(&sc->trigger_event);
41786 }
41787 diff --git a/drivers/md/dm-table.c b/drivers/md/dm-table.c
41788 index 41d907b..34b87ee 100644
41789 --- a/drivers/md/dm-table.c
41790 +++ b/drivers/md/dm-table.c
41791 @@ -286,7 +286,7 @@ static struct dm_dev_internal *find_device(struct list_head *l, dev_t dev)
41792 static int open_dev(struct dm_dev_internal *d, dev_t dev,
41793 struct mapped_device *md)
41794 {
41795 - static char *_claim_ptr = "I belong to device-mapper";
41796 + static char _claim_ptr[] = "I belong to device-mapper";
41797 struct block_device *bdev;
41798
41799 int r;
41800 @@ -354,7 +354,7 @@ static int device_area_is_invalid(struct dm_target *ti, struct dm_dev *dev,
41801 if (!dev_size)
41802 return 0;
41803
41804 - if ((start >= dev_size) || (start + len > dev_size)) {
41805 + if ((start >= dev_size) || (len > dev_size - start)) {
41806 DMWARN("%s: %s too small for target: "
41807 "start=%llu, len=%llu, dev_size=%llu",
41808 dm_device_name(ti->table->md), bdevname(bdev, b),
41809 diff --git a/drivers/md/dm-thin-metadata.c b/drivers/md/dm-thin-metadata.c
41810 index 60bce43..9b997d0 100644
41811 --- a/drivers/md/dm-thin-metadata.c
41812 +++ b/drivers/md/dm-thin-metadata.c
41813 @@ -397,7 +397,7 @@ static void __setup_btree_details(struct dm_pool_metadata *pmd)
41814 {
41815 pmd->info.tm = pmd->tm;
41816 pmd->info.levels = 2;
41817 - pmd->info.value_type.context = pmd->data_sm;
41818 + pmd->info.value_type.context = (dm_space_map_no_const *)pmd->data_sm;
41819 pmd->info.value_type.size = sizeof(__le64);
41820 pmd->info.value_type.inc = data_block_inc;
41821 pmd->info.value_type.dec = data_block_dec;
41822 @@ -416,7 +416,7 @@ static void __setup_btree_details(struct dm_pool_metadata *pmd)
41823
41824 pmd->bl_info.tm = pmd->tm;
41825 pmd->bl_info.levels = 1;
41826 - pmd->bl_info.value_type.context = pmd->data_sm;
41827 + pmd->bl_info.value_type.context = (dm_space_map_no_const *)pmd->data_sm;
41828 pmd->bl_info.value_type.size = sizeof(__le64);
41829 pmd->bl_info.value_type.inc = data_block_inc;
41830 pmd->bl_info.value_type.dec = data_block_dec;
41831 diff --git a/drivers/md/dm.c b/drivers/md/dm.c
41832 index b3e26c7..1efca94 100644
41833 --- a/drivers/md/dm.c
41834 +++ b/drivers/md/dm.c
41835 @@ -179,9 +179,9 @@ struct mapped_device {
41836 /*
41837 * Event handling.
41838 */
41839 - atomic_t event_nr;
41840 + atomic_unchecked_t event_nr;
41841 wait_queue_head_t eventq;
41842 - atomic_t uevent_seq;
41843 + atomic_unchecked_t uevent_seq;
41844 struct list_head uevent_list;
41845 spinlock_t uevent_lock; /* Protect access to uevent_list */
41846
41847 @@ -1985,8 +1985,8 @@ static struct mapped_device *alloc_dev(int minor)
41848 spin_lock_init(&md->deferred_lock);
41849 atomic_set(&md->holders, 1);
41850 atomic_set(&md->open_count, 0);
41851 - atomic_set(&md->event_nr, 0);
41852 - atomic_set(&md->uevent_seq, 0);
41853 + atomic_set_unchecked(&md->event_nr, 0);
41854 + atomic_set_unchecked(&md->uevent_seq, 0);
41855 INIT_LIST_HEAD(&md->uevent_list);
41856 spin_lock_init(&md->uevent_lock);
41857
41858 @@ -2139,7 +2139,7 @@ static void event_callback(void *context)
41859
41860 dm_send_uevents(&uevents, &disk_to_dev(md->disk)->kobj);
41861
41862 - atomic_inc(&md->event_nr);
41863 + atomic_inc_unchecked(&md->event_nr);
41864 wake_up(&md->eventq);
41865 }
41866
41867 @@ -2832,18 +2832,18 @@ int dm_kobject_uevent(struct mapped_device *md, enum kobject_action action,
41868
41869 uint32_t dm_next_uevent_seq(struct mapped_device *md)
41870 {
41871 - return atomic_add_return(1, &md->uevent_seq);
41872 + return atomic_add_return_unchecked(1, &md->uevent_seq);
41873 }
41874
41875 uint32_t dm_get_event_nr(struct mapped_device *md)
41876 {
41877 - return atomic_read(&md->event_nr);
41878 + return atomic_read_unchecked(&md->event_nr);
41879 }
41880
41881 int dm_wait_event(struct mapped_device *md, int event_nr)
41882 {
41883 return wait_event_interruptible(md->eventq,
41884 - (event_nr != atomic_read(&md->event_nr)));
41885 + (event_nr != atomic_read_unchecked(&md->event_nr)));
41886 }
41887
41888 void dm_uevent_add(struct mapped_device *md, struct list_head *elist)
41889 diff --git a/drivers/md/md.c b/drivers/md/md.c
41890 index ba46d97..f8f5019 100644
41891 --- a/drivers/md/md.c
41892 +++ b/drivers/md/md.c
41893 @@ -234,10 +234,10 @@ EXPORT_SYMBOL_GPL(md_trim_bio);
41894 * start build, activate spare
41895 */
41896 static DECLARE_WAIT_QUEUE_HEAD(md_event_waiters);
41897 -static atomic_t md_event_count;
41898 +static atomic_unchecked_t md_event_count;
41899 void md_new_event(struct mddev *mddev)
41900 {
41901 - atomic_inc(&md_event_count);
41902 + atomic_inc_unchecked(&md_event_count);
41903 wake_up(&md_event_waiters);
41904 }
41905 EXPORT_SYMBOL_GPL(md_new_event);
41906 @@ -247,7 +247,7 @@ EXPORT_SYMBOL_GPL(md_new_event);
41907 */
41908 static void md_new_event_inintr(struct mddev *mddev)
41909 {
41910 - atomic_inc(&md_event_count);
41911 + atomic_inc_unchecked(&md_event_count);
41912 wake_up(&md_event_waiters);
41913 }
41914
41915 @@ -1502,7 +1502,7 @@ static int super_1_load(struct md_rdev *rdev, struct md_rdev *refdev, int minor_
41916 if ((le32_to_cpu(sb->feature_map) & MD_FEATURE_RESHAPE_ACTIVE) &&
41917 (le32_to_cpu(sb->feature_map) & MD_FEATURE_NEW_OFFSET))
41918 rdev->new_data_offset += (s32)le32_to_cpu(sb->new_offset);
41919 - atomic_set(&rdev->corrected_errors, le32_to_cpu(sb->cnt_corrected_read));
41920 + atomic_set_unchecked(&rdev->corrected_errors, le32_to_cpu(sb->cnt_corrected_read));
41921
41922 rdev->sb_size = le32_to_cpu(sb->max_dev) * 2 + 256;
41923 bmask = queue_logical_block_size(rdev->bdev->bd_disk->queue)-1;
41924 @@ -1746,7 +1746,7 @@ static void super_1_sync(struct mddev *mddev, struct md_rdev *rdev)
41925 else
41926 sb->resync_offset = cpu_to_le64(0);
41927
41928 - sb->cnt_corrected_read = cpu_to_le32(atomic_read(&rdev->corrected_errors));
41929 + sb->cnt_corrected_read = cpu_to_le32(atomic_read_unchecked(&rdev->corrected_errors));
41930
41931 sb->raid_disks = cpu_to_le32(mddev->raid_disks);
41932 sb->size = cpu_to_le64(mddev->dev_sectors);
41933 @@ -2751,7 +2751,7 @@ __ATTR(state, S_IRUGO|S_IWUSR, state_show, state_store);
41934 static ssize_t
41935 errors_show(struct md_rdev *rdev, char *page)
41936 {
41937 - return sprintf(page, "%d\n", atomic_read(&rdev->corrected_errors));
41938 + return sprintf(page, "%d\n", atomic_read_unchecked(&rdev->corrected_errors));
41939 }
41940
41941 static ssize_t
41942 @@ -2760,7 +2760,7 @@ errors_store(struct md_rdev *rdev, const char *buf, size_t len)
41943 char *e;
41944 unsigned long n = simple_strtoul(buf, &e, 10);
41945 if (*buf && (*e == 0 || *e == '\n')) {
41946 - atomic_set(&rdev->corrected_errors, n);
41947 + atomic_set_unchecked(&rdev->corrected_errors, n);
41948 return len;
41949 }
41950 return -EINVAL;
41951 @@ -3208,8 +3208,8 @@ int md_rdev_init(struct md_rdev *rdev)
41952 rdev->sb_loaded = 0;
41953 rdev->bb_page = NULL;
41954 atomic_set(&rdev->nr_pending, 0);
41955 - atomic_set(&rdev->read_errors, 0);
41956 - atomic_set(&rdev->corrected_errors, 0);
41957 + atomic_set_unchecked(&rdev->read_errors, 0);
41958 + atomic_set_unchecked(&rdev->corrected_errors, 0);
41959
41960 INIT_LIST_HEAD(&rdev->same_set);
41961 init_waitqueue_head(&rdev->blocked_wait);
41962 @@ -7043,7 +7043,7 @@ static int md_seq_show(struct seq_file *seq, void *v)
41963
41964 spin_unlock(&pers_lock);
41965 seq_printf(seq, "\n");
41966 - seq->poll_event = atomic_read(&md_event_count);
41967 + seq->poll_event = atomic_read_unchecked(&md_event_count);
41968 return 0;
41969 }
41970 if (v == (void*)2) {
41971 @@ -7146,7 +7146,7 @@ static int md_seq_open(struct inode *inode, struct file *file)
41972 return error;
41973
41974 seq = file->private_data;
41975 - seq->poll_event = atomic_read(&md_event_count);
41976 + seq->poll_event = atomic_read_unchecked(&md_event_count);
41977 return error;
41978 }
41979
41980 @@ -7160,7 +7160,7 @@ static unsigned int mdstat_poll(struct file *filp, poll_table *wait)
41981 /* always allow read */
41982 mask = POLLIN | POLLRDNORM;
41983
41984 - if (seq->poll_event != atomic_read(&md_event_count))
41985 + if (seq->poll_event != atomic_read_unchecked(&md_event_count))
41986 mask |= POLLERR | POLLPRI;
41987 return mask;
41988 }
41989 @@ -7204,7 +7204,7 @@ static int is_mddev_idle(struct mddev *mddev, int init)
41990 struct gendisk *disk = rdev->bdev->bd_contains->bd_disk;
41991 curr_events = (int)part_stat_read(&disk->part0, sectors[0]) +
41992 (int)part_stat_read(&disk->part0, sectors[1]) -
41993 - atomic_read(&disk->sync_io);
41994 + atomic_read_unchecked(&disk->sync_io);
41995 /* sync IO will cause sync_io to increase before the disk_stats
41996 * as sync_io is counted when a request starts, and
41997 * disk_stats is counted when it completes.
41998 diff --git a/drivers/md/md.h b/drivers/md/md.h
41999 index 608050c..6e77db5d 100644
42000 --- a/drivers/md/md.h
42001 +++ b/drivers/md/md.h
42002 @@ -94,13 +94,13 @@ struct md_rdev {
42003 * only maintained for arrays that
42004 * support hot removal
42005 */
42006 - atomic_t read_errors; /* number of consecutive read errors that
42007 + atomic_unchecked_t read_errors; /* number of consecutive read errors that
42008 * we have tried to ignore.
42009 */
42010 struct timespec last_read_error; /* monotonic time since our
42011 * last read error
42012 */
42013 - atomic_t corrected_errors; /* number of corrected read errors,
42014 + atomic_unchecked_t corrected_errors; /* number of corrected read errors,
42015 * for reporting to userspace and storing
42016 * in superblock.
42017 */
42018 @@ -446,7 +446,7 @@ static inline void rdev_dec_pending(struct md_rdev *rdev, struct mddev *mddev)
42019
42020 static inline void md_sync_acct(struct block_device *bdev, unsigned long nr_sectors)
42021 {
42022 - atomic_add(nr_sectors, &bdev->bd_contains->bd_disk->sync_io);
42023 + atomic_add_unchecked(nr_sectors, &bdev->bd_contains->bd_disk->sync_io);
42024 }
42025
42026 struct md_personality
42027 diff --git a/drivers/md/persistent-data/dm-space-map.h b/drivers/md/persistent-data/dm-space-map.h
42028 index 3e6d115..ffecdeb 100644
42029 --- a/drivers/md/persistent-data/dm-space-map.h
42030 +++ b/drivers/md/persistent-data/dm-space-map.h
42031 @@ -71,6 +71,7 @@ struct dm_space_map {
42032 dm_sm_threshold_fn fn,
42033 void *context);
42034 };
42035 +typedef struct dm_space_map __no_const dm_space_map_no_const;
42036
42037 /*----------------------------------------------------------------*/
42038
42039 diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c
42040 index aacf6bf..67d63f2 100644
42041 --- a/drivers/md/raid1.c
42042 +++ b/drivers/md/raid1.c
42043 @@ -1824,7 +1824,7 @@ static int fix_sync_read_error(struct r1bio *r1_bio)
42044 if (r1_sync_page_io(rdev, sect, s,
42045 bio->bi_io_vec[idx].bv_page,
42046 READ) != 0)
42047 - atomic_add(s, &rdev->corrected_errors);
42048 + atomic_add_unchecked(s, &rdev->corrected_errors);
42049 }
42050 sectors -= s;
42051 sect += s;
42052 @@ -2051,7 +2051,7 @@ static void fix_read_error(struct r1conf *conf, int read_disk,
42053 test_bit(In_sync, &rdev->flags)) {
42054 if (r1_sync_page_io(rdev, sect, s,
42055 conf->tmppage, READ)) {
42056 - atomic_add(s, &rdev->corrected_errors);
42057 + atomic_add_unchecked(s, &rdev->corrected_errors);
42058 printk(KERN_INFO
42059 "md/raid1:%s: read error corrected "
42060 "(%d sectors at %llu on %s)\n",
42061 diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c
42062 index 73dc8a3..bdd515a 100644
42063 --- a/drivers/md/raid10.c
42064 +++ b/drivers/md/raid10.c
42065 @@ -1963,7 +1963,7 @@ static void end_sync_read(struct bio *bio, int error)
42066 /* The write handler will notice the lack of
42067 * R10BIO_Uptodate and record any errors etc
42068 */
42069 - atomic_add(r10_bio->sectors,
42070 + atomic_add_unchecked(r10_bio->sectors,
42071 &conf->mirrors[d].rdev->corrected_errors);
42072
42073 /* for reconstruct, we always reschedule after a read.
42074 @@ -2321,7 +2321,7 @@ static void check_decay_read_errors(struct mddev *mddev, struct md_rdev *rdev)
42075 {
42076 struct timespec cur_time_mon;
42077 unsigned long hours_since_last;
42078 - unsigned int read_errors = atomic_read(&rdev->read_errors);
42079 + unsigned int read_errors = atomic_read_unchecked(&rdev->read_errors);
42080
42081 ktime_get_ts(&cur_time_mon);
42082
42083 @@ -2343,9 +2343,9 @@ static void check_decay_read_errors(struct mddev *mddev, struct md_rdev *rdev)
42084 * overflowing the shift of read_errors by hours_since_last.
42085 */
42086 if (hours_since_last >= 8 * sizeof(read_errors))
42087 - atomic_set(&rdev->read_errors, 0);
42088 + atomic_set_unchecked(&rdev->read_errors, 0);
42089 else
42090 - atomic_set(&rdev->read_errors, read_errors >> hours_since_last);
42091 + atomic_set_unchecked(&rdev->read_errors, read_errors >> hours_since_last);
42092 }
42093
42094 static int r10_sync_page_io(struct md_rdev *rdev, sector_t sector,
42095 @@ -2399,8 +2399,8 @@ static void fix_read_error(struct r10conf *conf, struct mddev *mddev, struct r10
42096 return;
42097
42098 check_decay_read_errors(mddev, rdev);
42099 - atomic_inc(&rdev->read_errors);
42100 - if (atomic_read(&rdev->read_errors) > max_read_errors) {
42101 + atomic_inc_unchecked(&rdev->read_errors);
42102 + if (atomic_read_unchecked(&rdev->read_errors) > max_read_errors) {
42103 char b[BDEVNAME_SIZE];
42104 bdevname(rdev->bdev, b);
42105
42106 @@ -2408,7 +2408,7 @@ static void fix_read_error(struct r10conf *conf, struct mddev *mddev, struct r10
42107 "md/raid10:%s: %s: Raid device exceeded "
42108 "read_error threshold [cur %d:max %d]\n",
42109 mdname(mddev), b,
42110 - atomic_read(&rdev->read_errors), max_read_errors);
42111 + atomic_read_unchecked(&rdev->read_errors), max_read_errors);
42112 printk(KERN_NOTICE
42113 "md/raid10:%s: %s: Failing raid device\n",
42114 mdname(mddev), b);
42115 @@ -2563,7 +2563,7 @@ static void fix_read_error(struct r10conf *conf, struct mddev *mddev, struct r10
42116 sect +
42117 choose_data_offset(r10_bio, rdev)),
42118 bdevname(rdev->bdev, b));
42119 - atomic_add(s, &rdev->corrected_errors);
42120 + atomic_add_unchecked(s, &rdev->corrected_errors);
42121 }
42122
42123 rdev_dec_pending(rdev, mddev);
42124 diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c
42125 index 8a0665d..984c46d 100644
42126 --- a/drivers/md/raid5.c
42127 +++ b/drivers/md/raid5.c
42128 @@ -1887,21 +1887,21 @@ static void raid5_end_read_request(struct bio * bi, int error)
42129 mdname(conf->mddev), STRIPE_SECTORS,
42130 (unsigned long long)s,
42131 bdevname(rdev->bdev, b));
42132 - atomic_add(STRIPE_SECTORS, &rdev->corrected_errors);
42133 + atomic_add_unchecked(STRIPE_SECTORS, &rdev->corrected_errors);
42134 clear_bit(R5_ReadError, &sh->dev[i].flags);
42135 clear_bit(R5_ReWrite, &sh->dev[i].flags);
42136 } else if (test_bit(R5_ReadNoMerge, &sh->dev[i].flags))
42137 clear_bit(R5_ReadNoMerge, &sh->dev[i].flags);
42138
42139 - if (atomic_read(&rdev->read_errors))
42140 - atomic_set(&rdev->read_errors, 0);
42141 + if (atomic_read_unchecked(&rdev->read_errors))
42142 + atomic_set_unchecked(&rdev->read_errors, 0);
42143 } else {
42144 const char *bdn = bdevname(rdev->bdev, b);
42145 int retry = 0;
42146 int set_bad = 0;
42147
42148 clear_bit(R5_UPTODATE, &sh->dev[i].flags);
42149 - atomic_inc(&rdev->read_errors);
42150 + atomic_inc_unchecked(&rdev->read_errors);
42151 if (test_bit(R5_ReadRepl, &sh->dev[i].flags))
42152 printk_ratelimited(
42153 KERN_WARNING
42154 @@ -1929,7 +1929,7 @@ static void raid5_end_read_request(struct bio * bi, int error)
42155 mdname(conf->mddev),
42156 (unsigned long long)s,
42157 bdn);
42158 - } else if (atomic_read(&rdev->read_errors)
42159 + } else if (atomic_read_unchecked(&rdev->read_errors)
42160 > conf->max_nr_stripes)
42161 printk(KERN_WARNING
42162 "md/raid:%s: Too many read errors, failing device %s.\n",
42163 diff --git a/drivers/media/dvb-core/dvbdev.c b/drivers/media/dvb-core/dvbdev.c
42164 index 401ef64..836e563 100644
42165 --- a/drivers/media/dvb-core/dvbdev.c
42166 +++ b/drivers/media/dvb-core/dvbdev.c
42167 @@ -192,7 +192,7 @@ int dvb_register_device(struct dvb_adapter *adap, struct dvb_device **pdvbdev,
42168 const struct dvb_device *template, void *priv, int type)
42169 {
42170 struct dvb_device *dvbdev;
42171 - struct file_operations *dvbdevfops;
42172 + file_operations_no_const *dvbdevfops;
42173 struct device *clsdev;
42174 int minor;
42175 int id;
42176 diff --git a/drivers/media/dvb-frontends/dib3000.h b/drivers/media/dvb-frontends/dib3000.h
42177 index 9b6c3bb..baeb5c7 100644
42178 --- a/drivers/media/dvb-frontends/dib3000.h
42179 +++ b/drivers/media/dvb-frontends/dib3000.h
42180 @@ -39,7 +39,7 @@ struct dib_fe_xfer_ops
42181 int (*fifo_ctrl)(struct dvb_frontend *fe, int onoff);
42182 int (*pid_ctrl)(struct dvb_frontend *fe, int index, int pid, int onoff);
42183 int (*tuner_pass_ctrl)(struct dvb_frontend *fe, int onoff, u8 pll_ctrl);
42184 -};
42185 +} __no_const;
42186
42187 #if IS_ENABLED(CONFIG_DVB_DIB3000MB)
42188 extern struct dvb_frontend* dib3000mb_attach(const struct dib3000_config* config,
42189 diff --git a/drivers/media/pci/cx88/cx88-video.c b/drivers/media/pci/cx88/cx88-video.c
42190 index ecf21d9..b992428d 100644
42191 --- a/drivers/media/pci/cx88/cx88-video.c
42192 +++ b/drivers/media/pci/cx88/cx88-video.c
42193 @@ -50,9 +50,9 @@ MODULE_VERSION(CX88_VERSION);
42194
42195 /* ------------------------------------------------------------------ */
42196
42197 -static unsigned int video_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
42198 -static unsigned int vbi_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
42199 -static unsigned int radio_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
42200 +static int video_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
42201 +static int vbi_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
42202 +static int radio_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
42203
42204 module_param_array(video_nr, int, NULL, 0444);
42205 module_param_array(vbi_nr, int, NULL, 0444);
42206 diff --git a/drivers/media/pci/ivtv/ivtv-driver.c b/drivers/media/pci/ivtv/ivtv-driver.c
42207 index c08ae3e..eb59af1 100644
42208 --- a/drivers/media/pci/ivtv/ivtv-driver.c
42209 +++ b/drivers/media/pci/ivtv/ivtv-driver.c
42210 @@ -83,7 +83,7 @@ static struct pci_device_id ivtv_pci_tbl[] = {
42211 MODULE_DEVICE_TABLE(pci,ivtv_pci_tbl);
42212
42213 /* ivtv instance counter */
42214 -static atomic_t ivtv_instance = ATOMIC_INIT(0);
42215 +static atomic_unchecked_t ivtv_instance = ATOMIC_INIT(0);
42216
42217 /* Parameter declarations */
42218 static int cardtype[IVTV_MAX_CARDS];
42219 diff --git a/drivers/media/platform/omap/omap_vout.c b/drivers/media/platform/omap/omap_vout.c
42220 index dfd0a21..6bbb465 100644
42221 --- a/drivers/media/platform/omap/omap_vout.c
42222 +++ b/drivers/media/platform/omap/omap_vout.c
42223 @@ -63,7 +63,6 @@ enum omap_vout_channels {
42224 OMAP_VIDEO2,
42225 };
42226
42227 -static struct videobuf_queue_ops video_vbq_ops;
42228 /* Variables configurable through module params*/
42229 static u32 video1_numbuffers = 3;
42230 static u32 video2_numbuffers = 3;
42231 @@ -1014,6 +1013,12 @@ static int omap_vout_open(struct file *file)
42232 {
42233 struct videobuf_queue *q;
42234 struct omap_vout_device *vout = NULL;
42235 + static struct videobuf_queue_ops video_vbq_ops = {
42236 + .buf_setup = omap_vout_buffer_setup,
42237 + .buf_prepare = omap_vout_buffer_prepare,
42238 + .buf_release = omap_vout_buffer_release,
42239 + .buf_queue = omap_vout_buffer_queue,
42240 + };
42241
42242 vout = video_drvdata(file);
42243 v4l2_dbg(1, debug, &vout->vid_dev->v4l2_dev, "Entering %s\n", __func__);
42244 @@ -1031,10 +1036,6 @@ static int omap_vout_open(struct file *file)
42245 vout->type = V4L2_BUF_TYPE_VIDEO_OUTPUT;
42246
42247 q = &vout->vbq;
42248 - video_vbq_ops.buf_setup = omap_vout_buffer_setup;
42249 - video_vbq_ops.buf_prepare = omap_vout_buffer_prepare;
42250 - video_vbq_ops.buf_release = omap_vout_buffer_release;
42251 - video_vbq_ops.buf_queue = omap_vout_buffer_queue;
42252 spin_lock_init(&vout->vbq_lock);
42253
42254 videobuf_queue_dma_contig_init(q, &video_vbq_ops, q->dev,
42255 diff --git a/drivers/media/platform/s5p-tv/mixer.h b/drivers/media/platform/s5p-tv/mixer.h
42256 index 04e6490..2df65bf 100644
42257 --- a/drivers/media/platform/s5p-tv/mixer.h
42258 +++ b/drivers/media/platform/s5p-tv/mixer.h
42259 @@ -156,7 +156,7 @@ struct mxr_layer {
42260 /** layer index (unique identifier) */
42261 int idx;
42262 /** callbacks for layer methods */
42263 - struct mxr_layer_ops ops;
42264 + struct mxr_layer_ops *ops;
42265 /** format array */
42266 const struct mxr_format **fmt_array;
42267 /** size of format array */
42268 diff --git a/drivers/media/platform/s5p-tv/mixer_grp_layer.c b/drivers/media/platform/s5p-tv/mixer_grp_layer.c
42269 index b93a21f..2535195 100644
42270 --- a/drivers/media/platform/s5p-tv/mixer_grp_layer.c
42271 +++ b/drivers/media/platform/s5p-tv/mixer_grp_layer.c
42272 @@ -235,7 +235,7 @@ struct mxr_layer *mxr_graph_layer_create(struct mxr_device *mdev, int idx)
42273 {
42274 struct mxr_layer *layer;
42275 int ret;
42276 - struct mxr_layer_ops ops = {
42277 + static struct mxr_layer_ops ops = {
42278 .release = mxr_graph_layer_release,
42279 .buffer_set = mxr_graph_buffer_set,
42280 .stream_set = mxr_graph_stream_set,
42281 diff --git a/drivers/media/platform/s5p-tv/mixer_reg.c b/drivers/media/platform/s5p-tv/mixer_reg.c
42282 index b713403..53cb5ad 100644
42283 --- a/drivers/media/platform/s5p-tv/mixer_reg.c
42284 +++ b/drivers/media/platform/s5p-tv/mixer_reg.c
42285 @@ -276,7 +276,7 @@ static void mxr_irq_layer_handle(struct mxr_layer *layer)
42286 layer->update_buf = next;
42287 }
42288
42289 - layer->ops.buffer_set(layer, layer->update_buf);
42290 + layer->ops->buffer_set(layer, layer->update_buf);
42291
42292 if (done && done != layer->shadow_buf)
42293 vb2_buffer_done(&done->vb, VB2_BUF_STATE_DONE);
42294 diff --git a/drivers/media/platform/s5p-tv/mixer_video.c b/drivers/media/platform/s5p-tv/mixer_video.c
42295 index 641b1f0..49cff30 100644
42296 --- a/drivers/media/platform/s5p-tv/mixer_video.c
42297 +++ b/drivers/media/platform/s5p-tv/mixer_video.c
42298 @@ -210,7 +210,7 @@ static void mxr_layer_default_geo(struct mxr_layer *layer)
42299 layer->geo.src.height = layer->geo.src.full_height;
42300
42301 mxr_geometry_dump(mdev, &layer->geo);
42302 - layer->ops.fix_geometry(layer, MXR_GEOMETRY_SINK, 0);
42303 + layer->ops->fix_geometry(layer, MXR_GEOMETRY_SINK, 0);
42304 mxr_geometry_dump(mdev, &layer->geo);
42305 }
42306
42307 @@ -228,7 +228,7 @@ static void mxr_layer_update_output(struct mxr_layer *layer)
42308 layer->geo.dst.full_width = mbus_fmt.width;
42309 layer->geo.dst.full_height = mbus_fmt.height;
42310 layer->geo.dst.field = mbus_fmt.field;
42311 - layer->ops.fix_geometry(layer, MXR_GEOMETRY_SINK, 0);
42312 + layer->ops->fix_geometry(layer, MXR_GEOMETRY_SINK, 0);
42313
42314 mxr_geometry_dump(mdev, &layer->geo);
42315 }
42316 @@ -334,7 +334,7 @@ static int mxr_s_fmt(struct file *file, void *priv,
42317 /* set source size to highest accepted value */
42318 geo->src.full_width = max(geo->dst.full_width, pix->width);
42319 geo->src.full_height = max(geo->dst.full_height, pix->height);
42320 - layer->ops.fix_geometry(layer, MXR_GEOMETRY_SOURCE, 0);
42321 + layer->ops->fix_geometry(layer, MXR_GEOMETRY_SOURCE, 0);
42322 mxr_geometry_dump(mdev, &layer->geo);
42323 /* set cropping to total visible screen */
42324 geo->src.width = pix->width;
42325 @@ -342,12 +342,12 @@ static int mxr_s_fmt(struct file *file, void *priv,
42326 geo->src.x_offset = 0;
42327 geo->src.y_offset = 0;
42328 /* assure consistency of geometry */
42329 - layer->ops.fix_geometry(layer, MXR_GEOMETRY_CROP, MXR_NO_OFFSET);
42330 + layer->ops->fix_geometry(layer, MXR_GEOMETRY_CROP, MXR_NO_OFFSET);
42331 mxr_geometry_dump(mdev, &layer->geo);
42332 /* set full size to lowest possible value */
42333 geo->src.full_width = 0;
42334 geo->src.full_height = 0;
42335 - layer->ops.fix_geometry(layer, MXR_GEOMETRY_SOURCE, 0);
42336 + layer->ops->fix_geometry(layer, MXR_GEOMETRY_SOURCE, 0);
42337 mxr_geometry_dump(mdev, &layer->geo);
42338
42339 /* returning results */
42340 @@ -474,7 +474,7 @@ static int mxr_s_selection(struct file *file, void *fh,
42341 target->width = s->r.width;
42342 target->height = s->r.height;
42343
42344 - layer->ops.fix_geometry(layer, stage, s->flags);
42345 + layer->ops->fix_geometry(layer, stage, s->flags);
42346
42347 /* retrieve update selection rectangle */
42348 res.left = target->x_offset;
42349 @@ -955,13 +955,13 @@ static int start_streaming(struct vb2_queue *vq, unsigned int count)
42350 mxr_output_get(mdev);
42351
42352 mxr_layer_update_output(layer);
42353 - layer->ops.format_set(layer);
42354 + layer->ops->format_set(layer);
42355 /* enabling layer in hardware */
42356 spin_lock_irqsave(&layer->enq_slock, flags);
42357 layer->state = MXR_LAYER_STREAMING;
42358 spin_unlock_irqrestore(&layer->enq_slock, flags);
42359
42360 - layer->ops.stream_set(layer, MXR_ENABLE);
42361 + layer->ops->stream_set(layer, MXR_ENABLE);
42362 mxr_streamer_get(mdev);
42363
42364 return 0;
42365 @@ -1031,7 +1031,7 @@ static int stop_streaming(struct vb2_queue *vq)
42366 spin_unlock_irqrestore(&layer->enq_slock, flags);
42367
42368 /* disabling layer in hardware */
42369 - layer->ops.stream_set(layer, MXR_DISABLE);
42370 + layer->ops->stream_set(layer, MXR_DISABLE);
42371 /* remove one streamer */
42372 mxr_streamer_put(mdev);
42373 /* allow changes in output configuration */
42374 @@ -1070,8 +1070,8 @@ void mxr_base_layer_unregister(struct mxr_layer *layer)
42375
42376 void mxr_layer_release(struct mxr_layer *layer)
42377 {
42378 - if (layer->ops.release)
42379 - layer->ops.release(layer);
42380 + if (layer->ops->release)
42381 + layer->ops->release(layer);
42382 }
42383
42384 void mxr_base_layer_release(struct mxr_layer *layer)
42385 @@ -1097,7 +1097,7 @@ struct mxr_layer *mxr_base_layer_create(struct mxr_device *mdev,
42386
42387 layer->mdev = mdev;
42388 layer->idx = idx;
42389 - layer->ops = *ops;
42390 + layer->ops = ops;
42391
42392 spin_lock_init(&layer->enq_slock);
42393 INIT_LIST_HEAD(&layer->enq_list);
42394 diff --git a/drivers/media/platform/s5p-tv/mixer_vp_layer.c b/drivers/media/platform/s5p-tv/mixer_vp_layer.c
42395 index 3d13a63..da31bf1 100644
42396 --- a/drivers/media/platform/s5p-tv/mixer_vp_layer.c
42397 +++ b/drivers/media/platform/s5p-tv/mixer_vp_layer.c
42398 @@ -206,7 +206,7 @@ struct mxr_layer *mxr_vp_layer_create(struct mxr_device *mdev, int idx)
42399 {
42400 struct mxr_layer *layer;
42401 int ret;
42402 - struct mxr_layer_ops ops = {
42403 + static struct mxr_layer_ops ops = {
42404 .release = mxr_vp_layer_release,
42405 .buffer_set = mxr_vp_buffer_set,
42406 .stream_set = mxr_vp_stream_set,
42407 diff --git a/drivers/media/radio/radio-cadet.c b/drivers/media/radio/radio-cadet.c
42408 index 545c04c..a14bded 100644
42409 --- a/drivers/media/radio/radio-cadet.c
42410 +++ b/drivers/media/radio/radio-cadet.c
42411 @@ -324,6 +324,8 @@ static ssize_t cadet_read(struct file *file, char __user *data, size_t count, lo
42412 unsigned char readbuf[RDS_BUFFER];
42413 int i = 0;
42414
42415 + if (count > RDS_BUFFER)
42416 + return -EFAULT;
42417 mutex_lock(&dev->lock);
42418 if (dev->rdsstat == 0)
42419 cadet_start_rds(dev);
42420 @@ -339,7 +341,7 @@ static ssize_t cadet_read(struct file *file, char __user *data, size_t count, lo
42421 while (i < count && dev->rdsin != dev->rdsout)
42422 readbuf[i++] = dev->rdsbuf[dev->rdsout++];
42423
42424 - if (i && copy_to_user(data, readbuf, i))
42425 + if (i > sizeof(readbuf) || copy_to_user(data, readbuf, i))
42426 i = -EFAULT;
42427 unlock:
42428 mutex_unlock(&dev->lock);
42429 diff --git a/drivers/media/radio/radio-maxiradio.c b/drivers/media/radio/radio-maxiradio.c
42430 index 5236035..c622c74 100644
42431 --- a/drivers/media/radio/radio-maxiradio.c
42432 +++ b/drivers/media/radio/radio-maxiradio.c
42433 @@ -61,7 +61,7 @@ MODULE_PARM_DESC(radio_nr, "Radio device number");
42434 /* TEA5757 pin mappings */
42435 static const int clk = 1, data = 2, wren = 4, mo_st = 8, power = 16;
42436
42437 -static atomic_t maxiradio_instance = ATOMIC_INIT(0);
42438 +static atomic_unchecked_t maxiradio_instance = ATOMIC_INIT(0);
42439
42440 #define PCI_VENDOR_ID_GUILLEMOT 0x5046
42441 #define PCI_DEVICE_ID_GUILLEMOT_MAXIRADIO 0x1001
42442 diff --git a/drivers/media/radio/radio-shark.c b/drivers/media/radio/radio-shark.c
42443 index b914772..7ddbf9b 100644
42444 --- a/drivers/media/radio/radio-shark.c
42445 +++ b/drivers/media/radio/radio-shark.c
42446 @@ -79,7 +79,7 @@ struct shark_device {
42447 u32 last_val;
42448 };
42449
42450 -static atomic_t shark_instance = ATOMIC_INIT(0);
42451 +static atomic_unchecked_t shark_instance = ATOMIC_INIT(0);
42452
42453 static void shark_write_val(struct snd_tea575x *tea, u32 val)
42454 {
42455 diff --git a/drivers/media/radio/radio-shark2.c b/drivers/media/radio/radio-shark2.c
42456 index 9fb6697..f167415 100644
42457 --- a/drivers/media/radio/radio-shark2.c
42458 +++ b/drivers/media/radio/radio-shark2.c
42459 @@ -74,7 +74,7 @@ struct shark_device {
42460 u8 *transfer_buffer;
42461 };
42462
42463 -static atomic_t shark_instance = ATOMIC_INIT(0);
42464 +static atomic_unchecked_t shark_instance = ATOMIC_INIT(0);
42465
42466 static int shark_write_reg(struct radio_tea5777 *tea, u64 reg)
42467 {
42468 diff --git a/drivers/media/radio/radio-si476x.c b/drivers/media/radio/radio-si476x.c
42469 index 9c9084c..a9e8dfb 100644
42470 --- a/drivers/media/radio/radio-si476x.c
42471 +++ b/drivers/media/radio/radio-si476x.c
42472 @@ -1445,7 +1445,7 @@ static int si476x_radio_probe(struct platform_device *pdev)
42473 struct si476x_radio *radio;
42474 struct v4l2_ctrl *ctrl;
42475
42476 - static atomic_t instance = ATOMIC_INIT(0);
42477 + static atomic_unchecked_t instance = ATOMIC_INIT(0);
42478
42479 radio = devm_kzalloc(&pdev->dev, sizeof(*radio), GFP_KERNEL);
42480 if (!radio)
42481 diff --git a/drivers/media/rc/rc-main.c b/drivers/media/rc/rc-main.c
42482 index 46da365..3ba4206 100644
42483 --- a/drivers/media/rc/rc-main.c
42484 +++ b/drivers/media/rc/rc-main.c
42485 @@ -1065,7 +1065,7 @@ EXPORT_SYMBOL_GPL(rc_free_device);
42486 int rc_register_device(struct rc_dev *dev)
42487 {
42488 static bool raw_init = false; /* raw decoders loaded? */
42489 - static atomic_t devno = ATOMIC_INIT(0);
42490 + static atomic_unchecked_t devno = ATOMIC_INIT(0);
42491 struct rc_map *rc_map;
42492 const char *path;
42493 int rc;
42494 @@ -1096,7 +1096,7 @@ int rc_register_device(struct rc_dev *dev)
42495 */
42496 mutex_lock(&dev->lock);
42497
42498 - dev->devno = (unsigned long)(atomic_inc_return(&devno) - 1);
42499 + dev->devno = (unsigned long)(atomic_inc_return_unchecked(&devno) - 1);
42500 dev_set_name(&dev->dev, "rc%ld", dev->devno);
42501 dev_set_drvdata(&dev->dev, dev);
42502 rc = device_add(&dev->dev);
42503 diff --git a/drivers/media/usb/dvb-usb/cxusb.c b/drivers/media/usb/dvb-usb/cxusb.c
42504 index 20e345d..da56fe4 100644
42505 --- a/drivers/media/usb/dvb-usb/cxusb.c
42506 +++ b/drivers/media/usb/dvb-usb/cxusb.c
42507 @@ -1101,7 +1101,7 @@ static struct dib0070_config dib7070p_dib0070_config = {
42508
42509 struct dib0700_adapter_state {
42510 int (*set_param_save) (struct dvb_frontend *);
42511 -};
42512 +} __no_const;
42513
42514 static int dib7070_set_param_override(struct dvb_frontend *fe)
42515 {
42516 diff --git a/drivers/media/usb/dvb-usb/dw2102.c b/drivers/media/usb/dvb-usb/dw2102.c
42517 index 71b22f5..a63b33f 100644
42518 --- a/drivers/media/usb/dvb-usb/dw2102.c
42519 +++ b/drivers/media/usb/dvb-usb/dw2102.c
42520 @@ -121,7 +121,7 @@ struct su3000_state {
42521
42522 struct s6x0_state {
42523 int (*old_set_voltage)(struct dvb_frontend *f, fe_sec_voltage_t v);
42524 -};
42525 +} __no_const;
42526
42527 /* debug */
42528 static int dvb_usb_dw2102_debug;
42529 diff --git a/drivers/media/v4l2-core/v4l2-compat-ioctl32.c b/drivers/media/v4l2-core/v4l2-compat-ioctl32.c
42530 index 8f7a6a4..59502dd 100644
42531 --- a/drivers/media/v4l2-core/v4l2-compat-ioctl32.c
42532 +++ b/drivers/media/v4l2-core/v4l2-compat-ioctl32.c
42533 @@ -326,7 +326,7 @@ struct v4l2_buffer32 {
42534 __u32 reserved;
42535 };
42536
42537 -static int get_v4l2_plane32(struct v4l2_plane *up, struct v4l2_plane32 *up32,
42538 +static int get_v4l2_plane32(struct v4l2_plane __user *up, struct v4l2_plane32 __user *up32,
42539 enum v4l2_memory memory)
42540 {
42541 void __user *up_pln;
42542 @@ -355,7 +355,7 @@ static int get_v4l2_plane32(struct v4l2_plane *up, struct v4l2_plane32 *up32,
42543 return 0;
42544 }
42545
42546 -static int put_v4l2_plane32(struct v4l2_plane *up, struct v4l2_plane32 *up32,
42547 +static int put_v4l2_plane32(struct v4l2_plane __user *up, struct v4l2_plane32 __user *up32,
42548 enum v4l2_memory memory)
42549 {
42550 if (copy_in_user(up32, up, 2 * sizeof(__u32)) ||
42551 @@ -772,7 +772,7 @@ static int put_v4l2_subdev_edid32(struct v4l2_subdev_edid *kp, struct v4l2_subde
42552 put_user(kp->start_block, &up->start_block) ||
42553 put_user(kp->blocks, &up->blocks) ||
42554 put_user(tmp, &up->edid) ||
42555 - copy_to_user(kp->reserved, up->reserved, sizeof(kp->reserved)))
42556 + copy_to_user(up->reserved, kp->reserved, sizeof(kp->reserved)))
42557 return -EFAULT;
42558 return 0;
42559 }
42560 diff --git a/drivers/media/v4l2-core/v4l2-device.c b/drivers/media/v4l2-core/v4l2-device.c
42561 index 02d1b63..5fd6b16 100644
42562 --- a/drivers/media/v4l2-core/v4l2-device.c
42563 +++ b/drivers/media/v4l2-core/v4l2-device.c
42564 @@ -75,9 +75,9 @@ int v4l2_device_put(struct v4l2_device *v4l2_dev)
42565 EXPORT_SYMBOL_GPL(v4l2_device_put);
42566
42567 int v4l2_device_set_name(struct v4l2_device *v4l2_dev, const char *basename,
42568 - atomic_t *instance)
42569 + atomic_unchecked_t *instance)
42570 {
42571 - int num = atomic_inc_return(instance) - 1;
42572 + int num = atomic_inc_return_unchecked(instance) - 1;
42573 int len = strlen(basename);
42574
42575 if (basename[len - 1] >= '0' && basename[len - 1] <= '9')
42576 diff --git a/drivers/media/v4l2-core/v4l2-ioctl.c b/drivers/media/v4l2-core/v4l2-ioctl.c
42577 index 68e6b5e..d8b923e 100644
42578 --- a/drivers/media/v4l2-core/v4l2-ioctl.c
42579 +++ b/drivers/media/v4l2-core/v4l2-ioctl.c
42580 @@ -1939,7 +1939,8 @@ struct v4l2_ioctl_info {
42581 struct file *file, void *fh, void *p);
42582 } u;
42583 void (*debug)(const void *arg, bool write_only);
42584 -};
42585 +} __do_const;
42586 +typedef struct v4l2_ioctl_info __no_const v4l2_ioctl_info_no_const;
42587
42588 /* This control needs a priority check */
42589 #define INFO_FL_PRIO (1 << 0)
42590 @@ -2120,7 +2121,7 @@ static long __video_do_ioctl(struct file *file,
42591 struct video_device *vfd = video_devdata(file);
42592 const struct v4l2_ioctl_ops *ops = vfd->ioctl_ops;
42593 bool write_only = false;
42594 - struct v4l2_ioctl_info default_info;
42595 + v4l2_ioctl_info_no_const default_info;
42596 const struct v4l2_ioctl_info *info;
42597 void *fh = file->private_data;
42598 struct v4l2_fh *vfh = NULL;
42599 @@ -2194,7 +2195,7 @@ done:
42600 }
42601
42602 static int check_array_args(unsigned int cmd, void *parg, size_t *array_size,
42603 - void * __user *user_ptr, void ***kernel_ptr)
42604 + void __user **user_ptr, void ***kernel_ptr)
42605 {
42606 int ret = 0;
42607
42608 @@ -2210,7 +2211,7 @@ static int check_array_args(unsigned int cmd, void *parg, size_t *array_size,
42609 ret = -EINVAL;
42610 break;
42611 }
42612 - *user_ptr = (void __user *)buf->m.planes;
42613 + *user_ptr = (void __force_user *)buf->m.planes;
42614 *kernel_ptr = (void *)&buf->m.planes;
42615 *array_size = sizeof(struct v4l2_plane) * buf->length;
42616 ret = 1;
42617 @@ -2245,7 +2246,7 @@ static int check_array_args(unsigned int cmd, void *parg, size_t *array_size,
42618 ret = -EINVAL;
42619 break;
42620 }
42621 - *user_ptr = (void __user *)ctrls->controls;
42622 + *user_ptr = (void __force_user *)ctrls->controls;
42623 *kernel_ptr = (void *)&ctrls->controls;
42624 *array_size = sizeof(struct v4l2_ext_control)
42625 * ctrls->count;
42626 diff --git a/drivers/message/fusion/mptbase.c b/drivers/message/fusion/mptbase.c
42627 index 767ff4d..c69d259 100644
42628 --- a/drivers/message/fusion/mptbase.c
42629 +++ b/drivers/message/fusion/mptbase.c
42630 @@ -6755,8 +6755,13 @@ static int mpt_iocinfo_proc_show(struct seq_file *m, void *v)
42631 seq_printf(m, " MaxChainDepth = 0x%02x frames\n", ioc->facts.MaxChainDepth);
42632 seq_printf(m, " MinBlockSize = 0x%02x bytes\n", 4*ioc->facts.BlockSize);
42633
42634 +#ifdef CONFIG_GRKERNSEC_HIDESYM
42635 + seq_printf(m, " RequestFrames @ 0x%p (Dma @ 0x%p)\n", NULL, NULL);
42636 +#else
42637 seq_printf(m, " RequestFrames @ 0x%p (Dma @ 0x%p)\n",
42638 (void *)ioc->req_frames, (void *)(ulong)ioc->req_frames_dma);
42639 +#endif
42640 +
42641 /*
42642 * Rounding UP to nearest 4-kB boundary here...
42643 */
42644 @@ -6769,7 +6774,11 @@ static int mpt_iocinfo_proc_show(struct seq_file *m, void *v)
42645 ioc->facts.GlobalCredits);
42646
42647 seq_printf(m, " Frames @ 0x%p (Dma @ 0x%p)\n",
42648 +#ifdef CONFIG_GRKERNSEC_HIDESYM
42649 + NULL, NULL);
42650 +#else
42651 (void *)ioc->alloc, (void *)(ulong)ioc->alloc_dma);
42652 +#endif
42653 sz = (ioc->reply_sz * ioc->reply_depth) + 128;
42654 seq_printf(m, " {CurRepSz=%d} x {CurRepDepth=%d} = %d bytes ^= 0x%x\n",
42655 ioc->reply_sz, ioc->reply_depth, ioc->reply_sz*ioc->reply_depth, sz);
42656 diff --git a/drivers/message/fusion/mptsas.c b/drivers/message/fusion/mptsas.c
42657 index dd239bd..689c4f7 100644
42658 --- a/drivers/message/fusion/mptsas.c
42659 +++ b/drivers/message/fusion/mptsas.c
42660 @@ -446,6 +446,23 @@ mptsas_is_end_device(struct mptsas_devinfo * attached)
42661 return 0;
42662 }
42663
42664 +static inline void
42665 +mptsas_set_rphy(MPT_ADAPTER *ioc, struct mptsas_phyinfo *phy_info, struct sas_rphy *rphy)
42666 +{
42667 + if (phy_info->port_details) {
42668 + phy_info->port_details->rphy = rphy;
42669 + dsaswideprintk(ioc, printk(MYIOC_s_DEBUG_FMT "sas_rphy_add: rphy=%p\n",
42670 + ioc->name, rphy));
42671 + }
42672 +
42673 + if (rphy) {
42674 + dsaswideprintk(ioc, dev_printk(KERN_DEBUG,
42675 + &rphy->dev, MYIOC_s_FMT "add:", ioc->name));
42676 + dsaswideprintk(ioc, printk(MYIOC_s_DEBUG_FMT "rphy=%p release=%p\n",
42677 + ioc->name, rphy, rphy->dev.release));
42678 + }
42679 +}
42680 +
42681 /* no mutex */
42682 static void
42683 mptsas_port_delete(MPT_ADAPTER *ioc, struct mptsas_portinfo_details * port_details)
42684 @@ -484,23 +501,6 @@ mptsas_get_rphy(struct mptsas_phyinfo *phy_info)
42685 return NULL;
42686 }
42687
42688 -static inline void
42689 -mptsas_set_rphy(MPT_ADAPTER *ioc, struct mptsas_phyinfo *phy_info, struct sas_rphy *rphy)
42690 -{
42691 - if (phy_info->port_details) {
42692 - phy_info->port_details->rphy = rphy;
42693 - dsaswideprintk(ioc, printk(MYIOC_s_DEBUG_FMT "sas_rphy_add: rphy=%p\n",
42694 - ioc->name, rphy));
42695 - }
42696 -
42697 - if (rphy) {
42698 - dsaswideprintk(ioc, dev_printk(KERN_DEBUG,
42699 - &rphy->dev, MYIOC_s_FMT "add:", ioc->name));
42700 - dsaswideprintk(ioc, printk(MYIOC_s_DEBUG_FMT "rphy=%p release=%p\n",
42701 - ioc->name, rphy, rphy->dev.release));
42702 - }
42703 -}
42704 -
42705 static inline struct sas_port *
42706 mptsas_get_port(struct mptsas_phyinfo *phy_info)
42707 {
42708 diff --git a/drivers/message/fusion/mptscsih.c b/drivers/message/fusion/mptscsih.c
42709 index 727819c..ad74694 100644
42710 --- a/drivers/message/fusion/mptscsih.c
42711 +++ b/drivers/message/fusion/mptscsih.c
42712 @@ -1271,15 +1271,16 @@ mptscsih_info(struct Scsi_Host *SChost)
42713
42714 h = shost_priv(SChost);
42715
42716 - if (h) {
42717 - if (h->info_kbuf == NULL)
42718 - if ((h->info_kbuf = kmalloc(0x1000 /* 4Kb */, GFP_KERNEL)) == NULL)
42719 - return h->info_kbuf;
42720 - h->info_kbuf[0] = '\0';
42721 + if (!h)
42722 + return NULL;
42723
42724 - mpt_print_ioc_summary(h->ioc, h->info_kbuf, &size, 0, 0);
42725 - h->info_kbuf[size-1] = '\0';
42726 - }
42727 + if (h->info_kbuf == NULL)
42728 + if ((h->info_kbuf = kmalloc(0x1000 /* 4Kb */, GFP_KERNEL)) == NULL)
42729 + return h->info_kbuf;
42730 + h->info_kbuf[0] = '\0';
42731 +
42732 + mpt_print_ioc_summary(h->ioc, h->info_kbuf, &size, 0, 0);
42733 + h->info_kbuf[size-1] = '\0';
42734
42735 return h->info_kbuf;
42736 }
42737 diff --git a/drivers/message/i2o/i2o_proc.c b/drivers/message/i2o/i2o_proc.c
42738 index b7d87cd..3fb36da 100644
42739 --- a/drivers/message/i2o/i2o_proc.c
42740 +++ b/drivers/message/i2o/i2o_proc.c
42741 @@ -255,12 +255,6 @@ static char *scsi_devices[] = {
42742 "Array Controller Device"
42743 };
42744
42745 -static char *chtostr(char *tmp, u8 *chars, int n)
42746 -{
42747 - tmp[0] = 0;
42748 - return strncat(tmp, (char *)chars, n);
42749 -}
42750 -
42751 static int i2o_report_query_status(struct seq_file *seq, int block_status,
42752 char *group)
42753 {
42754 @@ -707,9 +701,9 @@ static int i2o_seq_show_status(struct seq_file *seq, void *v)
42755 static int i2o_seq_show_hw(struct seq_file *seq, void *v)
42756 {
42757 struct i2o_controller *c = (struct i2o_controller *)seq->private;
42758 - static u32 work32[5];
42759 - static u8 *work8 = (u8 *) work32;
42760 - static u16 *work16 = (u16 *) work32;
42761 + u32 work32[5];
42762 + u8 *work8 = (u8 *) work32;
42763 + u16 *work16 = (u16 *) work32;
42764 int token;
42765 u32 hwcap;
42766
42767 @@ -790,7 +784,6 @@ static int i2o_seq_show_ddm_table(struct seq_file *seq, void *v)
42768 } *result;
42769
42770 i2o_exec_execute_ddm_table ddm_table;
42771 - char tmp[28 + 1];
42772
42773 result = kmalloc(sizeof(*result), GFP_KERNEL);
42774 if (!result)
42775 @@ -825,8 +818,7 @@ static int i2o_seq_show_ddm_table(struct seq_file *seq, void *v)
42776
42777 seq_printf(seq, "%-#7x", ddm_table.i2o_vendor_id);
42778 seq_printf(seq, "%-#8x", ddm_table.module_id);
42779 - seq_printf(seq, "%-29s",
42780 - chtostr(tmp, ddm_table.module_name_version, 28));
42781 + seq_printf(seq, "%-.28s", ddm_table.module_name_version);
42782 seq_printf(seq, "%9d ", ddm_table.data_size);
42783 seq_printf(seq, "%8d", ddm_table.code_size);
42784
42785 @@ -893,7 +885,6 @@ static int i2o_seq_show_drivers_stored(struct seq_file *seq, void *v)
42786
42787 i2o_driver_result_table *result;
42788 i2o_driver_store_table *dst;
42789 - char tmp[28 + 1];
42790
42791 result = kmalloc(sizeof(i2o_driver_result_table), GFP_KERNEL);
42792 if (result == NULL)
42793 @@ -928,9 +919,8 @@ static int i2o_seq_show_drivers_stored(struct seq_file *seq, void *v)
42794
42795 seq_printf(seq, "%-#7x", dst->i2o_vendor_id);
42796 seq_printf(seq, "%-#8x", dst->module_id);
42797 - seq_printf(seq, "%-29s",
42798 - chtostr(tmp, dst->module_name_version, 28));
42799 - seq_printf(seq, "%-9s", chtostr(tmp, dst->date, 8));
42800 + seq_printf(seq, "%-.28s", dst->module_name_version);
42801 + seq_printf(seq, "%-.8s", dst->date);
42802 seq_printf(seq, "%8d ", dst->module_size);
42803 seq_printf(seq, "%8d ", dst->mpb_size);
42804 seq_printf(seq, "0x%04x", dst->module_flags);
42805 @@ -1246,11 +1236,10 @@ static int i2o_seq_show_authorized_users(struct seq_file *seq, void *v)
42806 static int i2o_seq_show_dev_identity(struct seq_file *seq, void *v)
42807 {
42808 struct i2o_device *d = (struct i2o_device *)seq->private;
42809 - static u32 work32[128]; // allow for "stuff" + up to 256 byte (max) serial number
42810 + u32 work32[128]; // allow for "stuff" + up to 256 byte (max) serial number
42811 // == (allow) 512d bytes (max)
42812 - static u16 *work16 = (u16 *) work32;
42813 + u16 *work16 = (u16 *) work32;
42814 int token;
42815 - char tmp[16 + 1];
42816
42817 token = i2o_parm_field_get(d, 0xF100, -1, &work32, sizeof(work32));
42818
42819 @@ -1262,14 +1251,10 @@ static int i2o_seq_show_dev_identity(struct seq_file *seq, void *v)
42820 seq_printf(seq, "Device Class : %s\n", i2o_get_class_name(work16[0]));
42821 seq_printf(seq, "Owner TID : %0#5x\n", work16[2]);
42822 seq_printf(seq, "Parent TID : %0#5x\n", work16[3]);
42823 - seq_printf(seq, "Vendor info : %s\n",
42824 - chtostr(tmp, (u8 *) (work32 + 2), 16));
42825 - seq_printf(seq, "Product info : %s\n",
42826 - chtostr(tmp, (u8 *) (work32 + 6), 16));
42827 - seq_printf(seq, "Description : %s\n",
42828 - chtostr(tmp, (u8 *) (work32 + 10), 16));
42829 - seq_printf(seq, "Product rev. : %s\n",
42830 - chtostr(tmp, (u8 *) (work32 + 14), 8));
42831 + seq_printf(seq, "Vendor info : %.16s\n", (u8 *) (work32 + 2));
42832 + seq_printf(seq, "Product info : %.16s\n", (u8 *) (work32 + 6));
42833 + seq_printf(seq, "Description : %.16s\n", (u8 *) (work32 + 10));
42834 + seq_printf(seq, "Product rev. : %.8s\n", (u8 *) (work32 + 14));
42835
42836 seq_printf(seq, "Serial number : ");
42837 print_serial_number(seq, (u8 *) (work32 + 16),
42838 @@ -1306,8 +1291,6 @@ static int i2o_seq_show_ddm_identity(struct seq_file *seq, void *v)
42839 u8 pad[256]; // allow up to 256 byte (max) serial number
42840 } result;
42841
42842 - char tmp[24 + 1];
42843 -
42844 token = i2o_parm_field_get(d, 0xF101, -1, &result, sizeof(result));
42845
42846 if (token < 0) {
42847 @@ -1316,10 +1299,8 @@ static int i2o_seq_show_ddm_identity(struct seq_file *seq, void *v)
42848 }
42849
42850 seq_printf(seq, "Registering DDM TID : 0x%03x\n", result.ddm_tid);
42851 - seq_printf(seq, "Module name : %s\n",
42852 - chtostr(tmp, result.module_name, 24));
42853 - seq_printf(seq, "Module revision : %s\n",
42854 - chtostr(tmp, result.module_rev, 8));
42855 + seq_printf(seq, "Module name : %.24s\n", result.module_name);
42856 + seq_printf(seq, "Module revision : %.8s\n", result.module_rev);
42857
42858 seq_printf(seq, "Serial number : ");
42859 print_serial_number(seq, result.serial_number, sizeof(result) - 36);
42860 @@ -1343,8 +1324,6 @@ static int i2o_seq_show_uinfo(struct seq_file *seq, void *v)
42861 u8 instance_number[4];
42862 } result;
42863
42864 - char tmp[64 + 1];
42865 -
42866 token = i2o_parm_field_get(d, 0xF102, -1, &result, sizeof(result));
42867
42868 if (token < 0) {
42869 @@ -1352,14 +1331,10 @@ static int i2o_seq_show_uinfo(struct seq_file *seq, void *v)
42870 return 0;
42871 }
42872
42873 - seq_printf(seq, "Device name : %s\n",
42874 - chtostr(tmp, result.device_name, 64));
42875 - seq_printf(seq, "Service name : %s\n",
42876 - chtostr(tmp, result.service_name, 64));
42877 - seq_printf(seq, "Physical name : %s\n",
42878 - chtostr(tmp, result.physical_location, 64));
42879 - seq_printf(seq, "Instance number : %s\n",
42880 - chtostr(tmp, result.instance_number, 4));
42881 + seq_printf(seq, "Device name : %.64s\n", result.device_name);
42882 + seq_printf(seq, "Service name : %.64s\n", result.service_name);
42883 + seq_printf(seq, "Physical name : %.64s\n", result.physical_location);
42884 + seq_printf(seq, "Instance number : %.4s\n", result.instance_number);
42885
42886 return 0;
42887 }
42888 @@ -1368,9 +1343,9 @@ static int i2o_seq_show_uinfo(struct seq_file *seq, void *v)
42889 static int i2o_seq_show_sgl_limits(struct seq_file *seq, void *v)
42890 {
42891 struct i2o_device *d = (struct i2o_device *)seq->private;
42892 - static u32 work32[12];
42893 - static u16 *work16 = (u16 *) work32;
42894 - static u8 *work8 = (u8 *) work32;
42895 + u32 work32[12];
42896 + u16 *work16 = (u16 *) work32;
42897 + u8 *work8 = (u8 *) work32;
42898 int token;
42899
42900 token = i2o_parm_field_get(d, 0xF103, -1, &work32, sizeof(work32));
42901 diff --git a/drivers/message/i2o/iop.c b/drivers/message/i2o/iop.c
42902 index a8c08f3..155fe3d 100644
42903 --- a/drivers/message/i2o/iop.c
42904 +++ b/drivers/message/i2o/iop.c
42905 @@ -111,10 +111,10 @@ u32 i2o_cntxt_list_add(struct i2o_controller * c, void *ptr)
42906
42907 spin_lock_irqsave(&c->context_list_lock, flags);
42908
42909 - if (unlikely(atomic_inc_and_test(&c->context_list_counter)))
42910 - atomic_inc(&c->context_list_counter);
42911 + if (unlikely(atomic_inc_and_test_unchecked(&c->context_list_counter)))
42912 + atomic_inc_unchecked(&c->context_list_counter);
42913
42914 - entry->context = atomic_read(&c->context_list_counter);
42915 + entry->context = atomic_read_unchecked(&c->context_list_counter);
42916
42917 list_add(&entry->list, &c->context_list);
42918
42919 @@ -1077,7 +1077,7 @@ struct i2o_controller *i2o_iop_alloc(void)
42920
42921 #if BITS_PER_LONG == 64
42922 spin_lock_init(&c->context_list_lock);
42923 - atomic_set(&c->context_list_counter, 0);
42924 + atomic_set_unchecked(&c->context_list_counter, 0);
42925 INIT_LIST_HEAD(&c->context_list);
42926 #endif
42927
42928 diff --git a/drivers/mfd/janz-cmodio.c b/drivers/mfd/janz-cmodio.c
42929 index fcbb2e9..2635e11 100644
42930 --- a/drivers/mfd/janz-cmodio.c
42931 +++ b/drivers/mfd/janz-cmodio.c
42932 @@ -13,6 +13,7 @@
42933
42934 #include <linux/kernel.h>
42935 #include <linux/module.h>
42936 +#include <linux/slab.h>
42937 #include <linux/init.h>
42938 #include <linux/pci.h>
42939 #include <linux/interrupt.h>
42940 diff --git a/drivers/mfd/max8925-i2c.c b/drivers/mfd/max8925-i2c.c
42941 index de7fb80..7c1b931 100644
42942 --- a/drivers/mfd/max8925-i2c.c
42943 +++ b/drivers/mfd/max8925-i2c.c
42944 @@ -152,7 +152,7 @@ static int max8925_probe(struct i2c_client *client,
42945 const struct i2c_device_id *id)
42946 {
42947 struct max8925_platform_data *pdata = dev_get_platdata(&client->dev);
42948 - static struct max8925_chip *chip;
42949 + struct max8925_chip *chip;
42950 struct device_node *node = client->dev.of_node;
42951
42952 if (node && !pdata) {
42953 diff --git a/drivers/mfd/tps65910.c b/drivers/mfd/tps65910.c
42954 index d792772..cd73ba3 100644
42955 --- a/drivers/mfd/tps65910.c
42956 +++ b/drivers/mfd/tps65910.c
42957 @@ -229,7 +229,7 @@ static int tps65910_irq_init(struct tps65910 *tps65910, int irq,
42958 struct tps65910_platform_data *pdata)
42959 {
42960 int ret = 0;
42961 - static struct regmap_irq_chip *tps6591x_irqs_chip;
42962 + struct regmap_irq_chip *tps6591x_irqs_chip;
42963
42964 if (!irq) {
42965 dev_warn(tps65910->dev, "No interrupt support, no core IRQ\n");
42966 diff --git a/drivers/mfd/twl4030-irq.c b/drivers/mfd/twl4030-irq.c
42967 index 9aa6d1e..1631bfc 100644
42968 --- a/drivers/mfd/twl4030-irq.c
42969 +++ b/drivers/mfd/twl4030-irq.c
42970 @@ -35,6 +35,7 @@
42971 #include <linux/of.h>
42972 #include <linux/irqdomain.h>
42973 #include <linux/i2c/twl.h>
42974 +#include <asm/pgtable.h>
42975
42976 #include "twl-core.h"
42977
42978 @@ -726,10 +727,12 @@ int twl4030_init_irq(struct device *dev, int irq_num)
42979 * Install an irq handler for each of the SIH modules;
42980 * clone dummy irq_chip since PIH can't *do* anything
42981 */
42982 - twl4030_irq_chip = dummy_irq_chip;
42983 - twl4030_irq_chip.name = "twl4030";
42984 + pax_open_kernel();
42985 + memcpy((void *)&twl4030_irq_chip, &dummy_irq_chip, sizeof twl4030_irq_chip);
42986 + *(const char **)&twl4030_irq_chip.name = "twl4030";
42987
42988 - twl4030_sih_irq_chip.irq_ack = dummy_irq_chip.irq_ack;
42989 + *(void **)&twl4030_sih_irq_chip.irq_ack = dummy_irq_chip.irq_ack;
42990 + pax_close_kernel();
42991
42992 for (i = irq_base; i < irq_end; i++) {
42993 irq_set_chip_and_handler(i, &twl4030_irq_chip,
42994 diff --git a/drivers/misc/c2port/core.c b/drivers/misc/c2port/core.c
42995 index 464419b..64bae8d 100644
42996 --- a/drivers/misc/c2port/core.c
42997 +++ b/drivers/misc/c2port/core.c
42998 @@ -922,7 +922,9 @@ struct c2port_device *c2port_device_register(char *name,
42999 goto error_idr_alloc;
43000 c2dev->id = ret;
43001
43002 - bin_attr_flash_data.size = ops->blocks_num * ops->block_size;
43003 + pax_open_kernel();
43004 + *(size_t *)&bin_attr_flash_data.size = ops->blocks_num * ops->block_size;
43005 + pax_close_kernel();
43006
43007 c2dev->dev = device_create(c2port_class, NULL, 0, c2dev,
43008 "c2port%d", c2dev->id);
43009 diff --git a/drivers/misc/kgdbts.c b/drivers/misc/kgdbts.c
43010 index 36f5d52..32311c3 100644
43011 --- a/drivers/misc/kgdbts.c
43012 +++ b/drivers/misc/kgdbts.c
43013 @@ -834,7 +834,7 @@ static void run_plant_and_detach_test(int is_early)
43014 char before[BREAK_INSTR_SIZE];
43015 char after[BREAK_INSTR_SIZE];
43016
43017 - probe_kernel_read(before, (char *)kgdbts_break_test,
43018 + probe_kernel_read(before, ktla_ktva((char *)kgdbts_break_test),
43019 BREAK_INSTR_SIZE);
43020 init_simple_test();
43021 ts.tst = plant_and_detach_test;
43022 @@ -842,7 +842,7 @@ static void run_plant_and_detach_test(int is_early)
43023 /* Activate test with initial breakpoint */
43024 if (!is_early)
43025 kgdb_breakpoint();
43026 - probe_kernel_read(after, (char *)kgdbts_break_test,
43027 + probe_kernel_read(after, ktla_ktva((char *)kgdbts_break_test),
43028 BREAK_INSTR_SIZE);
43029 if (memcmp(before, after, BREAK_INSTR_SIZE)) {
43030 printk(KERN_CRIT "kgdbts: ERROR kgdb corrupted memory\n");
43031 diff --git a/drivers/misc/lis3lv02d/lis3lv02d.c b/drivers/misc/lis3lv02d/lis3lv02d.c
43032 index 036effe..b3a6336 100644
43033 --- a/drivers/misc/lis3lv02d/lis3lv02d.c
43034 +++ b/drivers/misc/lis3lv02d/lis3lv02d.c
43035 @@ -498,7 +498,7 @@ static irqreturn_t lis302dl_interrupt(int irq, void *data)
43036 * the lid is closed. This leads to interrupts as soon as a little move
43037 * is done.
43038 */
43039 - atomic_inc(&lis3->count);
43040 + atomic_inc_unchecked(&lis3->count);
43041
43042 wake_up_interruptible(&lis3->misc_wait);
43043 kill_fasync(&lis3->async_queue, SIGIO, POLL_IN);
43044 @@ -584,7 +584,7 @@ static int lis3lv02d_misc_open(struct inode *inode, struct file *file)
43045 if (lis3->pm_dev)
43046 pm_runtime_get_sync(lis3->pm_dev);
43047
43048 - atomic_set(&lis3->count, 0);
43049 + atomic_set_unchecked(&lis3->count, 0);
43050 return 0;
43051 }
43052
43053 @@ -616,7 +616,7 @@ static ssize_t lis3lv02d_misc_read(struct file *file, char __user *buf,
43054 add_wait_queue(&lis3->misc_wait, &wait);
43055 while (true) {
43056 set_current_state(TASK_INTERRUPTIBLE);
43057 - data = atomic_xchg(&lis3->count, 0);
43058 + data = atomic_xchg_unchecked(&lis3->count, 0);
43059 if (data)
43060 break;
43061
43062 @@ -657,7 +657,7 @@ static unsigned int lis3lv02d_misc_poll(struct file *file, poll_table *wait)
43063 struct lis3lv02d, miscdev);
43064
43065 poll_wait(file, &lis3->misc_wait, wait);
43066 - if (atomic_read(&lis3->count))
43067 + if (atomic_read_unchecked(&lis3->count))
43068 return POLLIN | POLLRDNORM;
43069 return 0;
43070 }
43071 diff --git a/drivers/misc/lis3lv02d/lis3lv02d.h b/drivers/misc/lis3lv02d/lis3lv02d.h
43072 index c439c82..1f20f57 100644
43073 --- a/drivers/misc/lis3lv02d/lis3lv02d.h
43074 +++ b/drivers/misc/lis3lv02d/lis3lv02d.h
43075 @@ -297,7 +297,7 @@ struct lis3lv02d {
43076 struct input_polled_dev *idev; /* input device */
43077 struct platform_device *pdev; /* platform device */
43078 struct regulator_bulk_data regulators[2];
43079 - atomic_t count; /* interrupt count after last read */
43080 + atomic_unchecked_t count; /* interrupt count after last read */
43081 union axis_conversion ac; /* hw -> logical axis */
43082 int mapped_btns[3];
43083
43084 diff --git a/drivers/misc/sgi-gru/gruhandles.c b/drivers/misc/sgi-gru/gruhandles.c
43085 index 2f30bad..c4c13d0 100644
43086 --- a/drivers/misc/sgi-gru/gruhandles.c
43087 +++ b/drivers/misc/sgi-gru/gruhandles.c
43088 @@ -44,8 +44,8 @@ static void update_mcs_stats(enum mcs_op op, unsigned long clks)
43089 unsigned long nsec;
43090
43091 nsec = CLKS2NSEC(clks);
43092 - atomic_long_inc(&mcs_op_statistics[op].count);
43093 - atomic_long_add(nsec, &mcs_op_statistics[op].total);
43094 + atomic_long_inc_unchecked(&mcs_op_statistics[op].count);
43095 + atomic_long_add_unchecked(nsec, &mcs_op_statistics[op].total);
43096 if (mcs_op_statistics[op].max < nsec)
43097 mcs_op_statistics[op].max = nsec;
43098 }
43099 diff --git a/drivers/misc/sgi-gru/gruprocfs.c b/drivers/misc/sgi-gru/gruprocfs.c
43100 index 4f76359..cdfcb2e 100644
43101 --- a/drivers/misc/sgi-gru/gruprocfs.c
43102 +++ b/drivers/misc/sgi-gru/gruprocfs.c
43103 @@ -32,9 +32,9 @@
43104
43105 #define printstat(s, f) printstat_val(s, &gru_stats.f, #f)
43106
43107 -static void printstat_val(struct seq_file *s, atomic_long_t *v, char *id)
43108 +static void printstat_val(struct seq_file *s, atomic_long_unchecked_t *v, char *id)
43109 {
43110 - unsigned long val = atomic_long_read(v);
43111 + unsigned long val = atomic_long_read_unchecked(v);
43112
43113 seq_printf(s, "%16lu %s\n", val, id);
43114 }
43115 @@ -134,8 +134,8 @@ static int mcs_statistics_show(struct seq_file *s, void *p)
43116
43117 seq_printf(s, "%-20s%12s%12s%12s\n", "#id", "count", "aver-clks", "max-clks");
43118 for (op = 0; op < mcsop_last; op++) {
43119 - count = atomic_long_read(&mcs_op_statistics[op].count);
43120 - total = atomic_long_read(&mcs_op_statistics[op].total);
43121 + count = atomic_long_read_unchecked(&mcs_op_statistics[op].count);
43122 + total = atomic_long_read_unchecked(&mcs_op_statistics[op].total);
43123 max = mcs_op_statistics[op].max;
43124 seq_printf(s, "%-20s%12ld%12ld%12ld\n", id[op], count,
43125 count ? total / count : 0, max);
43126 diff --git a/drivers/misc/sgi-gru/grutables.h b/drivers/misc/sgi-gru/grutables.h
43127 index 5c3ce24..4915ccb 100644
43128 --- a/drivers/misc/sgi-gru/grutables.h
43129 +++ b/drivers/misc/sgi-gru/grutables.h
43130 @@ -167,82 +167,82 @@ extern unsigned int gru_max_gids;
43131 * GRU statistics.
43132 */
43133 struct gru_stats_s {
43134 - atomic_long_t vdata_alloc;
43135 - atomic_long_t vdata_free;
43136 - atomic_long_t gts_alloc;
43137 - atomic_long_t gts_free;
43138 - atomic_long_t gms_alloc;
43139 - atomic_long_t gms_free;
43140 - atomic_long_t gts_double_allocate;
43141 - atomic_long_t assign_context;
43142 - atomic_long_t assign_context_failed;
43143 - atomic_long_t free_context;
43144 - atomic_long_t load_user_context;
43145 - atomic_long_t load_kernel_context;
43146 - atomic_long_t lock_kernel_context;
43147 - atomic_long_t unlock_kernel_context;
43148 - atomic_long_t steal_user_context;
43149 - atomic_long_t steal_kernel_context;
43150 - atomic_long_t steal_context_failed;
43151 - atomic_long_t nopfn;
43152 - atomic_long_t asid_new;
43153 - atomic_long_t asid_next;
43154 - atomic_long_t asid_wrap;
43155 - atomic_long_t asid_reuse;
43156 - atomic_long_t intr;
43157 - atomic_long_t intr_cbr;
43158 - atomic_long_t intr_tfh;
43159 - atomic_long_t intr_spurious;
43160 - atomic_long_t intr_mm_lock_failed;
43161 - atomic_long_t call_os;
43162 - atomic_long_t call_os_wait_queue;
43163 - atomic_long_t user_flush_tlb;
43164 - atomic_long_t user_unload_context;
43165 - atomic_long_t user_exception;
43166 - atomic_long_t set_context_option;
43167 - atomic_long_t check_context_retarget_intr;
43168 - atomic_long_t check_context_unload;
43169 - atomic_long_t tlb_dropin;
43170 - atomic_long_t tlb_preload_page;
43171 - atomic_long_t tlb_dropin_fail_no_asid;
43172 - atomic_long_t tlb_dropin_fail_upm;
43173 - atomic_long_t tlb_dropin_fail_invalid;
43174 - atomic_long_t tlb_dropin_fail_range_active;
43175 - atomic_long_t tlb_dropin_fail_idle;
43176 - atomic_long_t tlb_dropin_fail_fmm;
43177 - atomic_long_t tlb_dropin_fail_no_exception;
43178 - atomic_long_t tfh_stale_on_fault;
43179 - atomic_long_t mmu_invalidate_range;
43180 - atomic_long_t mmu_invalidate_page;
43181 - atomic_long_t flush_tlb;
43182 - atomic_long_t flush_tlb_gru;
43183 - atomic_long_t flush_tlb_gru_tgh;
43184 - atomic_long_t flush_tlb_gru_zero_asid;
43185 + atomic_long_unchecked_t vdata_alloc;
43186 + atomic_long_unchecked_t vdata_free;
43187 + atomic_long_unchecked_t gts_alloc;
43188 + atomic_long_unchecked_t gts_free;
43189 + atomic_long_unchecked_t gms_alloc;
43190 + atomic_long_unchecked_t gms_free;
43191 + atomic_long_unchecked_t gts_double_allocate;
43192 + atomic_long_unchecked_t assign_context;
43193 + atomic_long_unchecked_t assign_context_failed;
43194 + atomic_long_unchecked_t free_context;
43195 + atomic_long_unchecked_t load_user_context;
43196 + atomic_long_unchecked_t load_kernel_context;
43197 + atomic_long_unchecked_t lock_kernel_context;
43198 + atomic_long_unchecked_t unlock_kernel_context;
43199 + atomic_long_unchecked_t steal_user_context;
43200 + atomic_long_unchecked_t steal_kernel_context;
43201 + atomic_long_unchecked_t steal_context_failed;
43202 + atomic_long_unchecked_t nopfn;
43203 + atomic_long_unchecked_t asid_new;
43204 + atomic_long_unchecked_t asid_next;
43205 + atomic_long_unchecked_t asid_wrap;
43206 + atomic_long_unchecked_t asid_reuse;
43207 + atomic_long_unchecked_t intr;
43208 + atomic_long_unchecked_t intr_cbr;
43209 + atomic_long_unchecked_t intr_tfh;
43210 + atomic_long_unchecked_t intr_spurious;
43211 + atomic_long_unchecked_t intr_mm_lock_failed;
43212 + atomic_long_unchecked_t call_os;
43213 + atomic_long_unchecked_t call_os_wait_queue;
43214 + atomic_long_unchecked_t user_flush_tlb;
43215 + atomic_long_unchecked_t user_unload_context;
43216 + atomic_long_unchecked_t user_exception;
43217 + atomic_long_unchecked_t set_context_option;
43218 + atomic_long_unchecked_t check_context_retarget_intr;
43219 + atomic_long_unchecked_t check_context_unload;
43220 + atomic_long_unchecked_t tlb_dropin;
43221 + atomic_long_unchecked_t tlb_preload_page;
43222 + atomic_long_unchecked_t tlb_dropin_fail_no_asid;
43223 + atomic_long_unchecked_t tlb_dropin_fail_upm;
43224 + atomic_long_unchecked_t tlb_dropin_fail_invalid;
43225 + atomic_long_unchecked_t tlb_dropin_fail_range_active;
43226 + atomic_long_unchecked_t tlb_dropin_fail_idle;
43227 + atomic_long_unchecked_t tlb_dropin_fail_fmm;
43228 + atomic_long_unchecked_t tlb_dropin_fail_no_exception;
43229 + atomic_long_unchecked_t tfh_stale_on_fault;
43230 + atomic_long_unchecked_t mmu_invalidate_range;
43231 + atomic_long_unchecked_t mmu_invalidate_page;
43232 + atomic_long_unchecked_t flush_tlb;
43233 + atomic_long_unchecked_t flush_tlb_gru;
43234 + atomic_long_unchecked_t flush_tlb_gru_tgh;
43235 + atomic_long_unchecked_t flush_tlb_gru_zero_asid;
43236
43237 - atomic_long_t copy_gpa;
43238 - atomic_long_t read_gpa;
43239 + atomic_long_unchecked_t copy_gpa;
43240 + atomic_long_unchecked_t read_gpa;
43241
43242 - atomic_long_t mesq_receive;
43243 - atomic_long_t mesq_receive_none;
43244 - atomic_long_t mesq_send;
43245 - atomic_long_t mesq_send_failed;
43246 - atomic_long_t mesq_noop;
43247 - atomic_long_t mesq_send_unexpected_error;
43248 - atomic_long_t mesq_send_lb_overflow;
43249 - atomic_long_t mesq_send_qlimit_reached;
43250 - atomic_long_t mesq_send_amo_nacked;
43251 - atomic_long_t mesq_send_put_nacked;
43252 - atomic_long_t mesq_page_overflow;
43253 - atomic_long_t mesq_qf_locked;
43254 - atomic_long_t mesq_qf_noop_not_full;
43255 - atomic_long_t mesq_qf_switch_head_failed;
43256 - atomic_long_t mesq_qf_unexpected_error;
43257 - atomic_long_t mesq_noop_unexpected_error;
43258 - atomic_long_t mesq_noop_lb_overflow;
43259 - atomic_long_t mesq_noop_qlimit_reached;
43260 - atomic_long_t mesq_noop_amo_nacked;
43261 - atomic_long_t mesq_noop_put_nacked;
43262 - atomic_long_t mesq_noop_page_overflow;
43263 + atomic_long_unchecked_t mesq_receive;
43264 + atomic_long_unchecked_t mesq_receive_none;
43265 + atomic_long_unchecked_t mesq_send;
43266 + atomic_long_unchecked_t mesq_send_failed;
43267 + atomic_long_unchecked_t mesq_noop;
43268 + atomic_long_unchecked_t mesq_send_unexpected_error;
43269 + atomic_long_unchecked_t mesq_send_lb_overflow;
43270 + atomic_long_unchecked_t mesq_send_qlimit_reached;
43271 + atomic_long_unchecked_t mesq_send_amo_nacked;
43272 + atomic_long_unchecked_t mesq_send_put_nacked;
43273 + atomic_long_unchecked_t mesq_page_overflow;
43274 + atomic_long_unchecked_t mesq_qf_locked;
43275 + atomic_long_unchecked_t mesq_qf_noop_not_full;
43276 + atomic_long_unchecked_t mesq_qf_switch_head_failed;
43277 + atomic_long_unchecked_t mesq_qf_unexpected_error;
43278 + atomic_long_unchecked_t mesq_noop_unexpected_error;
43279 + atomic_long_unchecked_t mesq_noop_lb_overflow;
43280 + atomic_long_unchecked_t mesq_noop_qlimit_reached;
43281 + atomic_long_unchecked_t mesq_noop_amo_nacked;
43282 + atomic_long_unchecked_t mesq_noop_put_nacked;
43283 + atomic_long_unchecked_t mesq_noop_page_overflow;
43284
43285 };
43286
43287 @@ -251,8 +251,8 @@ enum mcs_op {cchop_allocate, cchop_start, cchop_interrupt, cchop_interrupt_sync,
43288 tghop_invalidate, mcsop_last};
43289
43290 struct mcs_op_statistic {
43291 - atomic_long_t count;
43292 - atomic_long_t total;
43293 + atomic_long_unchecked_t count;
43294 + atomic_long_unchecked_t total;
43295 unsigned long max;
43296 };
43297
43298 @@ -275,7 +275,7 @@ extern struct mcs_op_statistic mcs_op_statistics[mcsop_last];
43299
43300 #define STAT(id) do { \
43301 if (gru_options & OPT_STATS) \
43302 - atomic_long_inc(&gru_stats.id); \
43303 + atomic_long_inc_unchecked(&gru_stats.id); \
43304 } while (0)
43305
43306 #ifdef CONFIG_SGI_GRU_DEBUG
43307 diff --git a/drivers/misc/sgi-xp/xp.h b/drivers/misc/sgi-xp/xp.h
43308 index c862cd4..0d176fe 100644
43309 --- a/drivers/misc/sgi-xp/xp.h
43310 +++ b/drivers/misc/sgi-xp/xp.h
43311 @@ -288,7 +288,7 @@ struct xpc_interface {
43312 xpc_notify_func, void *);
43313 void (*received) (short, int, void *);
43314 enum xp_retval (*partid_to_nasids) (short, void *);
43315 -};
43316 +} __no_const;
43317
43318 extern struct xpc_interface xpc_interface;
43319
43320 diff --git a/drivers/misc/sgi-xp/xpc.h b/drivers/misc/sgi-xp/xpc.h
43321 index b94d5f7..7f494c5 100644
43322 --- a/drivers/misc/sgi-xp/xpc.h
43323 +++ b/drivers/misc/sgi-xp/xpc.h
43324 @@ -835,6 +835,7 @@ struct xpc_arch_operations {
43325 void (*received_payload) (struct xpc_channel *, void *);
43326 void (*notify_senders_of_disconnect) (struct xpc_channel *);
43327 };
43328 +typedef struct xpc_arch_operations __no_const xpc_arch_operations_no_const;
43329
43330 /* struct xpc_partition act_state values (for XPC HB) */
43331
43332 @@ -876,7 +877,7 @@ extern struct xpc_registration xpc_registrations[];
43333 /* found in xpc_main.c */
43334 extern struct device *xpc_part;
43335 extern struct device *xpc_chan;
43336 -extern struct xpc_arch_operations xpc_arch_ops;
43337 +extern xpc_arch_operations_no_const xpc_arch_ops;
43338 extern int xpc_disengage_timelimit;
43339 extern int xpc_disengage_timedout;
43340 extern int xpc_activate_IRQ_rcvd;
43341 diff --git a/drivers/misc/sgi-xp/xpc_main.c b/drivers/misc/sgi-xp/xpc_main.c
43342 index 82dc574..8539ab2 100644
43343 --- a/drivers/misc/sgi-xp/xpc_main.c
43344 +++ b/drivers/misc/sgi-xp/xpc_main.c
43345 @@ -166,7 +166,7 @@ static struct notifier_block xpc_die_notifier = {
43346 .notifier_call = xpc_system_die,
43347 };
43348
43349 -struct xpc_arch_operations xpc_arch_ops;
43350 +xpc_arch_operations_no_const xpc_arch_ops;
43351
43352 /*
43353 * Timer function to enforce the timelimit on the partition disengage.
43354 @@ -1210,7 +1210,7 @@ xpc_system_die(struct notifier_block *nb, unsigned long event, void *_die_args)
43355
43356 if (((die_args->trapnr == X86_TRAP_MF) ||
43357 (die_args->trapnr == X86_TRAP_XF)) &&
43358 - !user_mode_vm(die_args->regs))
43359 + !user_mode(die_args->regs))
43360 xpc_die_deactivate();
43361
43362 break;
43363 diff --git a/drivers/mmc/core/mmc_ops.c b/drivers/mmc/core/mmc_ops.c
43364 index ef18348..1b53cf0 100644
43365 --- a/drivers/mmc/core/mmc_ops.c
43366 +++ b/drivers/mmc/core/mmc_ops.c
43367 @@ -213,7 +213,7 @@ mmc_send_cxd_data(struct mmc_card *card, struct mmc_host *host,
43368 void *data_buf;
43369 int is_on_stack;
43370
43371 - is_on_stack = object_is_on_stack(buf);
43372 + is_on_stack = object_starts_on_stack(buf);
43373 if (is_on_stack) {
43374 /*
43375 * dma onto stack is unsafe/nonportable, but callers to this
43376 diff --git a/drivers/mmc/host/dw_mmc.h b/drivers/mmc/host/dw_mmc.h
43377 index 81b2994..dce857e 100644
43378 --- a/drivers/mmc/host/dw_mmc.h
43379 +++ b/drivers/mmc/host/dw_mmc.h
43380 @@ -203,5 +203,5 @@ struct dw_mci_drv_data {
43381 void (*prepare_command)(struct dw_mci *host, u32 *cmdr);
43382 void (*set_ios)(struct dw_mci *host, struct mmc_ios *ios);
43383 int (*parse_dt)(struct dw_mci *host);
43384 -};
43385 +} __do_const;
43386 #endif /* _DW_MMC_H_ */
43387 diff --git a/drivers/mmc/host/mmci.c b/drivers/mmc/host/mmci.c
43388 index c3785ed..1984c44 100644
43389 --- a/drivers/mmc/host/mmci.c
43390 +++ b/drivers/mmc/host/mmci.c
43391 @@ -1482,7 +1482,9 @@ static int mmci_probe(struct amba_device *dev,
43392 }
43393
43394 if (variant->busy_detect) {
43395 - mmci_ops.card_busy = mmci_card_busy;
43396 + pax_open_kernel();
43397 + *(void **)&mmci_ops.card_busy = mmci_card_busy;
43398 + pax_close_kernel();
43399 mmci_write_datactrlreg(host, MCI_ST_DPSM_BUSYMODE);
43400 }
43401
43402 diff --git a/drivers/mmc/host/sdhci-s3c.c b/drivers/mmc/host/sdhci-s3c.c
43403 index 6debda9..2ba7427 100644
43404 --- a/drivers/mmc/host/sdhci-s3c.c
43405 +++ b/drivers/mmc/host/sdhci-s3c.c
43406 @@ -668,9 +668,11 @@ static int sdhci_s3c_probe(struct platform_device *pdev)
43407 * we can use overriding functions instead of default.
43408 */
43409 if (host->quirks & SDHCI_QUIRK_NONSTANDARD_CLOCK) {
43410 - sdhci_s3c_ops.set_clock = sdhci_cmu_set_clock;
43411 - sdhci_s3c_ops.get_min_clock = sdhci_cmu_get_min_clock;
43412 - sdhci_s3c_ops.get_max_clock = sdhci_cmu_get_max_clock;
43413 + pax_open_kernel();
43414 + *(void **)&sdhci_s3c_ops.set_clock = sdhci_cmu_set_clock;
43415 + *(void **)&sdhci_s3c_ops.get_min_clock = sdhci_cmu_get_min_clock;
43416 + *(void **)&sdhci_s3c_ops.get_max_clock = sdhci_cmu_get_max_clock;
43417 + pax_close_kernel();
43418 }
43419
43420 /* It supports additional host capabilities if needed */
43421 diff --git a/drivers/mtd/chips/cfi_cmdset_0020.c b/drivers/mtd/chips/cfi_cmdset_0020.c
43422 index 096993f..f02c23b 100644
43423 --- a/drivers/mtd/chips/cfi_cmdset_0020.c
43424 +++ b/drivers/mtd/chips/cfi_cmdset_0020.c
43425 @@ -669,7 +669,7 @@ cfi_staa_writev(struct mtd_info *mtd, const struct kvec *vecs,
43426 size_t totlen = 0, thislen;
43427 int ret = 0;
43428 size_t buflen = 0;
43429 - static char *buffer;
43430 + char *buffer;
43431
43432 if (!ECCBUF_SIZE) {
43433 /* We should fall back to a general writev implementation.
43434 diff --git a/drivers/mtd/nand/denali.c b/drivers/mtd/nand/denali.c
43435 index 2ed2bb3..2d0b82e 100644
43436 --- a/drivers/mtd/nand/denali.c
43437 +++ b/drivers/mtd/nand/denali.c
43438 @@ -24,6 +24,7 @@
43439 #include <linux/slab.h>
43440 #include <linux/mtd/mtd.h>
43441 #include <linux/module.h>
43442 +#include <linux/slab.h>
43443
43444 #include "denali.h"
43445
43446 diff --git a/drivers/mtd/nftlmount.c b/drivers/mtd/nftlmount.c
43447 index 51b9d6a..52af9a7 100644
43448 --- a/drivers/mtd/nftlmount.c
43449 +++ b/drivers/mtd/nftlmount.c
43450 @@ -24,6 +24,7 @@
43451 #include <asm/errno.h>
43452 #include <linux/delay.h>
43453 #include <linux/slab.h>
43454 +#include <linux/sched.h>
43455 #include <linux/mtd/mtd.h>
43456 #include <linux/mtd/nand.h>
43457 #include <linux/mtd/nftl.h>
43458 diff --git a/drivers/mtd/sm_ftl.c b/drivers/mtd/sm_ftl.c
43459 index 4b8e895..6b3c498 100644
43460 --- a/drivers/mtd/sm_ftl.c
43461 +++ b/drivers/mtd/sm_ftl.c
43462 @@ -56,7 +56,7 @@ static ssize_t sm_attr_show(struct device *dev, struct device_attribute *attr,
43463 #define SM_CIS_VENDOR_OFFSET 0x59
43464 static struct attribute_group *sm_create_sysfs_attributes(struct sm_ftl *ftl)
43465 {
43466 - struct attribute_group *attr_group;
43467 + attribute_group_no_const *attr_group;
43468 struct attribute **attributes;
43469 struct sm_sysfs_attribute *vendor_attribute;
43470
43471 diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
43472 index dd8057d..22aaf36 100644
43473 --- a/drivers/net/bonding/bond_main.c
43474 +++ b/drivers/net/bonding/bond_main.c
43475 @@ -4511,7 +4511,7 @@ static unsigned int bond_get_num_tx_queues(void)
43476 return tx_queues;
43477 }
43478
43479 -static struct rtnl_link_ops bond_link_ops __read_mostly = {
43480 +static struct rtnl_link_ops bond_link_ops = {
43481 .kind = "bond",
43482 .priv_size = sizeof(struct bonding),
43483 .setup = bond_setup,
43484 @@ -4636,8 +4636,8 @@ static void __exit bonding_exit(void)
43485
43486 bond_destroy_debugfs();
43487
43488 - rtnl_link_unregister(&bond_link_ops);
43489 unregister_pernet_subsys(&bond_net_ops);
43490 + rtnl_link_unregister(&bond_link_ops);
43491
43492 #ifdef CONFIG_NET_POLL_CONTROLLER
43493 /*
43494 diff --git a/drivers/net/ethernet/8390/ax88796.c b/drivers/net/ethernet/8390/ax88796.c
43495 index f92f001..0b2f9bf 100644
43496 --- a/drivers/net/ethernet/8390/ax88796.c
43497 +++ b/drivers/net/ethernet/8390/ax88796.c
43498 @@ -872,9 +872,11 @@ static int ax_probe(struct platform_device *pdev)
43499 if (ax->plat->reg_offsets)
43500 ei_local->reg_offset = ax->plat->reg_offsets;
43501 else {
43502 + resource_size_t _mem_size = mem_size;
43503 + do_div(_mem_size, 0x18);
43504 ei_local->reg_offset = ax->reg_offsets;
43505 for (ret = 0; ret < 0x18; ret++)
43506 - ax->reg_offsets[ret] = (mem_size / 0x18) * ret;
43507 + ax->reg_offsets[ret] = _mem_size * ret;
43508 }
43509
43510 if (!request_mem_region(mem->start, mem_size, pdev->name)) {
43511 diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h
43512 index da8fcaa..f4b5d3b 100644
43513 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h
43514 +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h
43515 @@ -1138,7 +1138,7 @@ static inline u8 bnx2x_get_path_func_num(struct bnx2x *bp)
43516 static inline void bnx2x_init_bp_objs(struct bnx2x *bp)
43517 {
43518 /* RX_MODE controlling object */
43519 - bnx2x_init_rx_mode_obj(bp, &bp->rx_mode_obj);
43520 + bnx2x_init_rx_mode_obj(bp);
43521
43522 /* multicast configuration controlling object */
43523 bnx2x_init_mcast_obj(bp, &bp->mcast_obj, bp->fp->cl_id, bp->fp->cid,
43524 diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c
43525 index 9fbeee5..5e3e37a 100644
43526 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c
43527 +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c
43528 @@ -2590,15 +2590,14 @@ int bnx2x_config_rx_mode(struct bnx2x *bp,
43529 return rc;
43530 }
43531
43532 -void bnx2x_init_rx_mode_obj(struct bnx2x *bp,
43533 - struct bnx2x_rx_mode_obj *o)
43534 +void bnx2x_init_rx_mode_obj(struct bnx2x *bp)
43535 {
43536 if (CHIP_IS_E1x(bp)) {
43537 - o->wait_comp = bnx2x_empty_rx_mode_wait;
43538 - o->config_rx_mode = bnx2x_set_rx_mode_e1x;
43539 + bp->rx_mode_obj.wait_comp = bnx2x_empty_rx_mode_wait;
43540 + bp->rx_mode_obj.config_rx_mode = bnx2x_set_rx_mode_e1x;
43541 } else {
43542 - o->wait_comp = bnx2x_wait_rx_mode_comp_e2;
43543 - o->config_rx_mode = bnx2x_set_rx_mode_e2;
43544 + bp->rx_mode_obj.wait_comp = bnx2x_wait_rx_mode_comp_e2;
43545 + bp->rx_mode_obj.config_rx_mode = bnx2x_set_rx_mode_e2;
43546 }
43547 }
43548
43549 diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.h b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.h
43550 index 658f4e3..15074a6 100644
43551 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.h
43552 +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.h
43553 @@ -1325,8 +1325,7 @@ int bnx2x_vlan_mac_move(struct bnx2x *bp,
43554
43555 /********************* RX MODE ****************/
43556
43557 -void bnx2x_init_rx_mode_obj(struct bnx2x *bp,
43558 - struct bnx2x_rx_mode_obj *o);
43559 +void bnx2x_init_rx_mode_obj(struct bnx2x *bp);
43560
43561 /**
43562 * bnx2x_config_rx_mode - Send and RX_MODE ramrod according to the provided parameters.
43563 diff --git a/drivers/net/ethernet/broadcom/tg3.h b/drivers/net/ethernet/broadcom/tg3.h
43564 index 7025780..e55a71c 100644
43565 --- a/drivers/net/ethernet/broadcom/tg3.h
43566 +++ b/drivers/net/ethernet/broadcom/tg3.h
43567 @@ -147,6 +147,7 @@
43568 #define CHIPREV_ID_5750_A0 0x4000
43569 #define CHIPREV_ID_5750_A1 0x4001
43570 #define CHIPREV_ID_5750_A3 0x4003
43571 +#define CHIPREV_ID_5750_C1 0x4201
43572 #define CHIPREV_ID_5750_C2 0x4202
43573 #define CHIPREV_ID_5752_A0_HW 0x5000
43574 #define CHIPREV_ID_5752_A0 0x6000
43575 diff --git a/drivers/net/ethernet/chelsio/cxgb3/l2t.h b/drivers/net/ethernet/chelsio/cxgb3/l2t.h
43576 index 8cffcdf..aadf043 100644
43577 --- a/drivers/net/ethernet/chelsio/cxgb3/l2t.h
43578 +++ b/drivers/net/ethernet/chelsio/cxgb3/l2t.h
43579 @@ -87,7 +87,7 @@ typedef void (*arp_failure_handler_func)(struct t3cdev * dev,
43580 */
43581 struct l2t_skb_cb {
43582 arp_failure_handler_func arp_failure_handler;
43583 -};
43584 +} __no_const;
43585
43586 #define L2T_SKB_CB(skb) ((struct l2t_skb_cb *)(skb)->cb)
43587
43588 diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
43589 index c73cabd..cd278b1 100644
43590 --- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
43591 +++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
43592 @@ -2186,7 +2186,7 @@ static void get_regs(struct net_device *dev, struct ethtool_regs *regs,
43593
43594 int i;
43595 struct adapter *ap = netdev2adap(dev);
43596 - static const unsigned int *reg_ranges;
43597 + const unsigned int *reg_ranges;
43598 int arr_size = 0, buf_size = 0;
43599
43600 if (is_t4(ap->chip)) {
43601 diff --git a/drivers/net/ethernet/dec/tulip/de4x5.c b/drivers/net/ethernet/dec/tulip/de4x5.c
43602 index 263b92c..f05134b 100644
43603 --- a/drivers/net/ethernet/dec/tulip/de4x5.c
43604 +++ b/drivers/net/ethernet/dec/tulip/de4x5.c
43605 @@ -5388,7 +5388,7 @@ de4x5_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
43606 for (i=0; i<ETH_ALEN; i++) {
43607 tmp.addr[i] = dev->dev_addr[i];
43608 }
43609 - if (copy_to_user(ioc->data, tmp.addr, ioc->len)) return -EFAULT;
43610 + if (ioc->len > sizeof tmp.addr || copy_to_user(ioc->data, tmp.addr, ioc->len)) return -EFAULT;
43611 break;
43612
43613 case DE4X5_SET_HWADDR: /* Set the hardware address */
43614 @@ -5428,7 +5428,7 @@ de4x5_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
43615 spin_lock_irqsave(&lp->lock, flags);
43616 memcpy(&statbuf, &lp->pktStats, ioc->len);
43617 spin_unlock_irqrestore(&lp->lock, flags);
43618 - if (copy_to_user(ioc->data, &statbuf, ioc->len))
43619 + if (ioc->len > sizeof statbuf || copy_to_user(ioc->data, &statbuf, ioc->len))
43620 return -EFAULT;
43621 break;
43622 }
43623 diff --git a/drivers/net/ethernet/emulex/benet/be_main.c b/drivers/net/ethernet/emulex/benet/be_main.c
43624 index 2c38cc4..0323f6e 100644
43625 --- a/drivers/net/ethernet/emulex/benet/be_main.c
43626 +++ b/drivers/net/ethernet/emulex/benet/be_main.c
43627 @@ -470,7 +470,7 @@ static void accumulate_16bit_val(u32 *acc, u16 val)
43628
43629 if (wrapped)
43630 newacc += 65536;
43631 - ACCESS_ONCE(*acc) = newacc;
43632 + ACCESS_ONCE_RW(*acc) = newacc;
43633 }
43634
43635 static void populate_erx_stats(struct be_adapter *adapter,
43636 diff --git a/drivers/net/ethernet/faraday/ftgmac100.c b/drivers/net/ethernet/faraday/ftgmac100.c
43637 index 212f44b..fb69959 100644
43638 --- a/drivers/net/ethernet/faraday/ftgmac100.c
43639 +++ b/drivers/net/ethernet/faraday/ftgmac100.c
43640 @@ -31,6 +31,8 @@
43641 #include <linux/netdevice.h>
43642 #include <linux/phy.h>
43643 #include <linux/platform_device.h>
43644 +#include <linux/interrupt.h>
43645 +#include <linux/irqreturn.h>
43646 #include <net/ip.h>
43647
43648 #include "ftgmac100.h"
43649 diff --git a/drivers/net/ethernet/faraday/ftmac100.c b/drivers/net/ethernet/faraday/ftmac100.c
43650 index 8be5b40..081bc1b 100644
43651 --- a/drivers/net/ethernet/faraday/ftmac100.c
43652 +++ b/drivers/net/ethernet/faraday/ftmac100.c
43653 @@ -31,6 +31,8 @@
43654 #include <linux/module.h>
43655 #include <linux/netdevice.h>
43656 #include <linux/platform_device.h>
43657 +#include <linux/interrupt.h>
43658 +#include <linux/irqreturn.h>
43659
43660 #include "ftmac100.h"
43661
43662 diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c
43663 index 5184e2a..acb28c3 100644
43664 --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c
43665 +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c
43666 @@ -776,7 +776,7 @@ void ixgbe_ptp_start_cyclecounter(struct ixgbe_adapter *adapter)
43667 }
43668
43669 /* update the base incval used to calculate frequency adjustment */
43670 - ACCESS_ONCE(adapter->base_incval) = incval;
43671 + ACCESS_ONCE_RW(adapter->base_incval) = incval;
43672 smp_mb();
43673
43674 /* need lock to prevent incorrect read while modifying cyclecounter */
43675 diff --git a/drivers/net/ethernet/neterion/vxge/vxge-config.c b/drivers/net/ethernet/neterion/vxge/vxge-config.c
43676 index fbe5363..266b4e3 100644
43677 --- a/drivers/net/ethernet/neterion/vxge/vxge-config.c
43678 +++ b/drivers/net/ethernet/neterion/vxge/vxge-config.c
43679 @@ -3461,7 +3461,10 @@ __vxge_hw_fifo_create(struct __vxge_hw_vpath_handle *vp,
43680 struct __vxge_hw_fifo *fifo;
43681 struct vxge_hw_fifo_config *config;
43682 u32 txdl_size, txdl_per_memblock;
43683 - struct vxge_hw_mempool_cbs fifo_mp_callback;
43684 + static struct vxge_hw_mempool_cbs fifo_mp_callback = {
43685 + .item_func_alloc = __vxge_hw_fifo_mempool_item_alloc,
43686 + };
43687 +
43688 struct __vxge_hw_virtualpath *vpath;
43689
43690 if ((vp == NULL) || (attr == NULL)) {
43691 @@ -3544,8 +3547,6 @@ __vxge_hw_fifo_create(struct __vxge_hw_vpath_handle *vp,
43692 goto exit;
43693 }
43694
43695 - fifo_mp_callback.item_func_alloc = __vxge_hw_fifo_mempool_item_alloc;
43696 -
43697 fifo->mempool =
43698 __vxge_hw_mempool_create(vpath->hldev,
43699 fifo->config->memblock_size,
43700 diff --git a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_init.c b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_init.c
43701 index f09e787..f3916a8 100644
43702 --- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_init.c
43703 +++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_init.c
43704 @@ -2055,7 +2055,9 @@ int qlcnic_83xx_configure_opmode(struct qlcnic_adapter *adapter)
43705
43706 } else if (ret == QLC_83XX_DEFAULT_OPMODE) {
43707 ahw->nic_mode = QLC_83XX_DEFAULT_MODE;
43708 - adapter->nic_ops->init_driver = qlcnic_83xx_init_default_driver;
43709 + pax_open_kernel();
43710 + *(void **)&adapter->nic_ops->init_driver = qlcnic_83xx_init_default_driver;
43711 + pax_close_kernel();
43712 ahw->idc.state_entry = qlcnic_83xx_idc_ready_state_entry;
43713 } else {
43714 return -EIO;
43715 diff --git a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_vnic.c b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_vnic.c
43716 index 0248a4c..9648d96 100644
43717 --- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_vnic.c
43718 +++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_vnic.c
43719 @@ -191,17 +191,23 @@ int qlcnic_83xx_config_vnic_opmode(struct qlcnic_adapter *adapter)
43720 case QLCNIC_NON_PRIV_FUNC:
43721 ahw->op_mode = QLCNIC_NON_PRIV_FUNC;
43722 ahw->idc.state_entry = qlcnic_83xx_idc_ready_state_entry;
43723 - nic_ops->init_driver = qlcnic_83xx_init_non_privileged_vnic;
43724 + pax_open_kernel();
43725 + *(void **)&nic_ops->init_driver = qlcnic_83xx_init_non_privileged_vnic;
43726 + pax_close_kernel();
43727 break;
43728 case QLCNIC_PRIV_FUNC:
43729 ahw->op_mode = QLCNIC_PRIV_FUNC;
43730 ahw->idc.state_entry = qlcnic_83xx_idc_vnic_pf_entry;
43731 - nic_ops->init_driver = qlcnic_83xx_init_privileged_vnic;
43732 + pax_open_kernel();
43733 + *(void **)&nic_ops->init_driver = qlcnic_83xx_init_privileged_vnic;
43734 + pax_close_kernel();
43735 break;
43736 case QLCNIC_MGMT_FUNC:
43737 ahw->op_mode = QLCNIC_MGMT_FUNC;
43738 ahw->idc.state_entry = qlcnic_83xx_idc_ready_state_entry;
43739 - nic_ops->init_driver = qlcnic_83xx_init_mgmt_vnic;
43740 + pax_open_kernel();
43741 + *(void **)&nic_ops->init_driver = qlcnic_83xx_init_mgmt_vnic;
43742 + pax_close_kernel();
43743 break;
43744 default:
43745 dev_err(&adapter->pdev->dev, "Invalid Virtual NIC opmode\n");
43746 diff --git a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_minidump.c b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_minidump.c
43747 index 1551360..ed6510f 100644
43748 --- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_minidump.c
43749 +++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_minidump.c
43750 @@ -1108,7 +1108,7 @@ int qlcnic_dump_fw(struct qlcnic_adapter *adapter)
43751 struct qlcnic_dump_entry *entry;
43752 struct qlcnic_fw_dump *fw_dump = &adapter->ahw->fw_dump;
43753 struct qlcnic_dump_template_hdr *tmpl_hdr = fw_dump->tmpl_hdr;
43754 - static const struct qlcnic_dump_operations *fw_dump_ops;
43755 + const struct qlcnic_dump_operations *fw_dump_ops;
43756 struct device *dev = &adapter->pdev->dev;
43757 struct qlcnic_hardware_context *ahw;
43758 void *temp_buffer;
43759 diff --git a/drivers/net/ethernet/realtek/r8169.c b/drivers/net/ethernet/realtek/r8169.c
43760 index fb3f8dc..9d2ff38 100644
43761 --- a/drivers/net/ethernet/realtek/r8169.c
43762 +++ b/drivers/net/ethernet/realtek/r8169.c
43763 @@ -759,22 +759,22 @@ struct rtl8169_private {
43764 struct mdio_ops {
43765 void (*write)(struct rtl8169_private *, int, int);
43766 int (*read)(struct rtl8169_private *, int);
43767 - } mdio_ops;
43768 + } __no_const mdio_ops;
43769
43770 struct pll_power_ops {
43771 void (*down)(struct rtl8169_private *);
43772 void (*up)(struct rtl8169_private *);
43773 - } pll_power_ops;
43774 + } __no_const pll_power_ops;
43775
43776 struct jumbo_ops {
43777 void (*enable)(struct rtl8169_private *);
43778 void (*disable)(struct rtl8169_private *);
43779 - } jumbo_ops;
43780 + } __no_const jumbo_ops;
43781
43782 struct csi_ops {
43783 void (*write)(struct rtl8169_private *, int, int);
43784 u32 (*read)(struct rtl8169_private *, int);
43785 - } csi_ops;
43786 + } __no_const csi_ops;
43787
43788 int (*set_speed)(struct net_device *, u8 aneg, u16 sp, u8 dpx, u32 adv);
43789 int (*get_settings)(struct net_device *, struct ethtool_cmd *);
43790 diff --git a/drivers/net/ethernet/sfc/ptp.c b/drivers/net/ethernet/sfc/ptp.c
43791 index 03acf57..e1251ff 100644
43792 --- a/drivers/net/ethernet/sfc/ptp.c
43793 +++ b/drivers/net/ethernet/sfc/ptp.c
43794 @@ -539,7 +539,7 @@ static int efx_ptp_synchronize(struct efx_nic *efx, unsigned int num_readings)
43795 ptp->start.dma_addr);
43796
43797 /* Clear flag that signals MC ready */
43798 - ACCESS_ONCE(*start) = 0;
43799 + ACCESS_ONCE_RW(*start) = 0;
43800 rc = efx_mcdi_rpc_start(efx, MC_CMD_PTP, synch_buf,
43801 MC_CMD_PTP_IN_SYNCHRONIZE_LEN);
43802 EFX_BUG_ON_PARANOID(rc);
43803 diff --git a/drivers/net/ethernet/stmicro/stmmac/mmc_core.c b/drivers/net/ethernet/stmicro/stmmac/mmc_core.c
43804 index 50617c5..b13724c 100644
43805 --- a/drivers/net/ethernet/stmicro/stmmac/mmc_core.c
43806 +++ b/drivers/net/ethernet/stmicro/stmmac/mmc_core.c
43807 @@ -140,8 +140,8 @@ void dwmac_mmc_ctrl(void __iomem *ioaddr, unsigned int mode)
43808
43809 writel(value, ioaddr + MMC_CNTRL);
43810
43811 - pr_debug("stmmac: MMC ctrl register (offset 0x%x): 0x%08x\n",
43812 - MMC_CNTRL, value);
43813 +// pr_debug("stmmac: MMC ctrl register (offset 0x%x): 0x%08x\n",
43814 +// MMC_CNTRL, value);
43815 }
43816
43817 /* To mask all all interrupts.*/
43818 diff --git a/drivers/net/hyperv/hyperv_net.h b/drivers/net/hyperv/hyperv_net.h
43819 index e6fe0d8..2b7d752 100644
43820 --- a/drivers/net/hyperv/hyperv_net.h
43821 +++ b/drivers/net/hyperv/hyperv_net.h
43822 @@ -101,7 +101,7 @@ struct rndis_device {
43823
43824 enum rndis_device_state state;
43825 bool link_state;
43826 - atomic_t new_req_id;
43827 + atomic_unchecked_t new_req_id;
43828
43829 spinlock_t request_lock;
43830 struct list_head req_list;
43831 diff --git a/drivers/net/hyperv/rndis_filter.c b/drivers/net/hyperv/rndis_filter.c
43832 index 0775f0a..d4fb316 100644
43833 --- a/drivers/net/hyperv/rndis_filter.c
43834 +++ b/drivers/net/hyperv/rndis_filter.c
43835 @@ -104,7 +104,7 @@ static struct rndis_request *get_rndis_request(struct rndis_device *dev,
43836 * template
43837 */
43838 set = &rndis_msg->msg.set_req;
43839 - set->req_id = atomic_inc_return(&dev->new_req_id);
43840 + set->req_id = atomic_inc_return_unchecked(&dev->new_req_id);
43841
43842 /* Add to the request list */
43843 spin_lock_irqsave(&dev->request_lock, flags);
43844 @@ -752,7 +752,7 @@ static void rndis_filter_halt_device(struct rndis_device *dev)
43845
43846 /* Setup the rndis set */
43847 halt = &request->request_msg.msg.halt_req;
43848 - halt->req_id = atomic_inc_return(&dev->new_req_id);
43849 + halt->req_id = atomic_inc_return_unchecked(&dev->new_req_id);
43850
43851 /* Ignore return since this msg is optional. */
43852 rndis_filter_send_request(dev, request);
43853 diff --git a/drivers/net/ieee802154/fakehard.c b/drivers/net/ieee802154/fakehard.c
43854 index bf0d55e..82bcfbd1 100644
43855 --- a/drivers/net/ieee802154/fakehard.c
43856 +++ b/drivers/net/ieee802154/fakehard.c
43857 @@ -364,7 +364,7 @@ static int ieee802154fake_probe(struct platform_device *pdev)
43858 phy->transmit_power = 0xbf;
43859
43860 dev->netdev_ops = &fake_ops;
43861 - dev->ml_priv = &fake_mlme;
43862 + dev->ml_priv = (void *)&fake_mlme;
43863
43864 priv = netdev_priv(dev);
43865 priv->phy = phy;
43866 diff --git a/drivers/net/macvlan.c b/drivers/net/macvlan.c
43867 index 9bf46bd..bfdaa84 100644
43868 --- a/drivers/net/macvlan.c
43869 +++ b/drivers/net/macvlan.c
43870 @@ -939,13 +939,15 @@ static const struct nla_policy macvlan_policy[IFLA_MACVLAN_MAX + 1] = {
43871 int macvlan_link_register(struct rtnl_link_ops *ops)
43872 {
43873 /* common fields */
43874 - ops->priv_size = sizeof(struct macvlan_dev);
43875 - ops->validate = macvlan_validate;
43876 - ops->maxtype = IFLA_MACVLAN_MAX;
43877 - ops->policy = macvlan_policy;
43878 - ops->changelink = macvlan_changelink;
43879 - ops->get_size = macvlan_get_size;
43880 - ops->fill_info = macvlan_fill_info;
43881 + pax_open_kernel();
43882 + *(size_t *)&ops->priv_size = sizeof(struct macvlan_dev);
43883 + *(void **)&ops->validate = macvlan_validate;
43884 + *(int *)&ops->maxtype = IFLA_MACVLAN_MAX;
43885 + *(const void **)&ops->policy = macvlan_policy;
43886 + *(void **)&ops->changelink = macvlan_changelink;
43887 + *(void **)&ops->get_size = macvlan_get_size;
43888 + *(void **)&ops->fill_info = macvlan_fill_info;
43889 + pax_close_kernel();
43890
43891 return rtnl_link_register(ops);
43892 };
43893 @@ -1001,7 +1003,7 @@ static int macvlan_device_event(struct notifier_block *unused,
43894 return NOTIFY_DONE;
43895 }
43896
43897 -static struct notifier_block macvlan_notifier_block __read_mostly = {
43898 +static struct notifier_block macvlan_notifier_block = {
43899 .notifier_call = macvlan_device_event,
43900 };
43901
43902 diff --git a/drivers/net/macvtap.c b/drivers/net/macvtap.c
43903 index dc76670..e18f39c 100644
43904 --- a/drivers/net/macvtap.c
43905 +++ b/drivers/net/macvtap.c
43906 @@ -1189,7 +1189,7 @@ static int macvtap_device_event(struct notifier_block *unused,
43907 return NOTIFY_DONE;
43908 }
43909
43910 -static struct notifier_block macvtap_notifier_block __read_mostly = {
43911 +static struct notifier_block macvtap_notifier_block = {
43912 .notifier_call = macvtap_device_event,
43913 };
43914
43915 diff --git a/drivers/net/phy/mdio-bitbang.c b/drivers/net/phy/mdio-bitbang.c
43916 index daec9b0..6428fcb 100644
43917 --- a/drivers/net/phy/mdio-bitbang.c
43918 +++ b/drivers/net/phy/mdio-bitbang.c
43919 @@ -234,6 +234,7 @@ void free_mdio_bitbang(struct mii_bus *bus)
43920 struct mdiobb_ctrl *ctrl = bus->priv;
43921
43922 module_put(ctrl->ops->owner);
43923 + mdiobus_unregister(bus);
43924 mdiobus_free(bus);
43925 }
43926 EXPORT_SYMBOL(free_mdio_bitbang);
43927 diff --git a/drivers/net/ppp/ppp_generic.c b/drivers/net/ppp/ppp_generic.c
43928 index 72ff14b..11d442d 100644
43929 --- a/drivers/net/ppp/ppp_generic.c
43930 +++ b/drivers/net/ppp/ppp_generic.c
43931 @@ -999,7 +999,6 @@ ppp_net_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
43932 void __user *addr = (void __user *) ifr->ifr_ifru.ifru_data;
43933 struct ppp_stats stats;
43934 struct ppp_comp_stats cstats;
43935 - char *vers;
43936
43937 switch (cmd) {
43938 case SIOCGPPPSTATS:
43939 @@ -1021,8 +1020,7 @@ ppp_net_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
43940 break;
43941
43942 case SIOCGPPPVER:
43943 - vers = PPP_VERSION;
43944 - if (copy_to_user(addr, vers, strlen(vers) + 1))
43945 + if (copy_to_user(addr, PPP_VERSION, sizeof(PPP_VERSION)))
43946 break;
43947 err = 0;
43948 break;
43949 diff --git a/drivers/net/slip/slhc.c b/drivers/net/slip/slhc.c
43950 index 1252d9c..80e660b 100644
43951 --- a/drivers/net/slip/slhc.c
43952 +++ b/drivers/net/slip/slhc.c
43953 @@ -488,7 +488,7 @@ slhc_uncompress(struct slcompress *comp, unsigned char *icp, int isize)
43954 register struct tcphdr *thp;
43955 register struct iphdr *ip;
43956 register struct cstate *cs;
43957 - int len, hdrlen;
43958 + long len, hdrlen;
43959 unsigned char *cp = icp;
43960
43961 /* We've got a compressed packet; read the change byte */
43962 diff --git a/drivers/net/team/team.c b/drivers/net/team/team.c
43963 index 6327df2..e6e1ebe 100644
43964 --- a/drivers/net/team/team.c
43965 +++ b/drivers/net/team/team.c
43966 @@ -2873,7 +2873,7 @@ static int team_device_event(struct notifier_block *unused,
43967 return NOTIFY_DONE;
43968 }
43969
43970 -static struct notifier_block team_notifier_block __read_mostly = {
43971 +static struct notifier_block team_notifier_block = {
43972 .notifier_call = team_device_event,
43973 };
43974
43975 diff --git a/drivers/net/tun.c b/drivers/net/tun.c
43976 index 782e38b..d076fdc 100644
43977 --- a/drivers/net/tun.c
43978 +++ b/drivers/net/tun.c
43979 @@ -1834,7 +1834,7 @@ unlock:
43980 }
43981
43982 static long __tun_chr_ioctl(struct file *file, unsigned int cmd,
43983 - unsigned long arg, int ifreq_len)
43984 + unsigned long arg, size_t ifreq_len)
43985 {
43986 struct tun_file *tfile = file->private_data;
43987 struct tun_struct *tun;
43988 @@ -1847,6 +1847,9 @@ static long __tun_chr_ioctl(struct file *file, unsigned int cmd,
43989 unsigned int ifindex;
43990 int ret;
43991
43992 + if (ifreq_len > sizeof ifr)
43993 + return -EFAULT;
43994 +
43995 if (cmd == TUNSETIFF || cmd == TUNSETQUEUE || _IOC_TYPE(cmd) == 0x89) {
43996 if (copy_from_user(&ifr, argp, ifreq_len))
43997 return -EFAULT;
43998 diff --git a/drivers/net/usb/hso.c b/drivers/net/usb/hso.c
43999 index 86292e6..8d34433 100644
44000 --- a/drivers/net/usb/hso.c
44001 +++ b/drivers/net/usb/hso.c
44002 @@ -71,7 +71,7 @@
44003 #include <asm/byteorder.h>
44004 #include <linux/serial_core.h>
44005 #include <linux/serial.h>
44006 -
44007 +#include <asm/local.h>
44008
44009 #define MOD_AUTHOR "Option Wireless"
44010 #define MOD_DESCRIPTION "USB High Speed Option driver"
44011 @@ -1180,7 +1180,7 @@ static void put_rxbuf_data_and_resubmit_ctrl_urb(struct hso_serial *serial)
44012 struct urb *urb;
44013
44014 urb = serial->rx_urb[0];
44015 - if (serial->port.count > 0) {
44016 + if (atomic_read(&serial->port.count) > 0) {
44017 count = put_rxbuf_data(urb, serial);
44018 if (count == -1)
44019 return;
44020 @@ -1216,7 +1216,7 @@ static void hso_std_serial_read_bulk_callback(struct urb *urb)
44021 DUMP1(urb->transfer_buffer, urb->actual_length);
44022
44023 /* Anyone listening? */
44024 - if (serial->port.count == 0)
44025 + if (atomic_read(&serial->port.count) == 0)
44026 return;
44027
44028 if (status == 0) {
44029 @@ -1298,8 +1298,7 @@ static int hso_serial_open(struct tty_struct *tty, struct file *filp)
44030 tty_port_tty_set(&serial->port, tty);
44031
44032 /* check for port already opened, if not set the termios */
44033 - serial->port.count++;
44034 - if (serial->port.count == 1) {
44035 + if (atomic_inc_return(&serial->port.count) == 1) {
44036 serial->rx_state = RX_IDLE;
44037 /* Force default termio settings */
44038 _hso_serial_set_termios(tty, NULL);
44039 @@ -1311,7 +1310,7 @@ static int hso_serial_open(struct tty_struct *tty, struct file *filp)
44040 result = hso_start_serial_device(serial->parent, GFP_KERNEL);
44041 if (result) {
44042 hso_stop_serial_device(serial->parent);
44043 - serial->port.count--;
44044 + atomic_dec(&serial->port.count);
44045 kref_put(&serial->parent->ref, hso_serial_ref_free);
44046 }
44047 } else {
44048 @@ -1348,10 +1347,10 @@ static void hso_serial_close(struct tty_struct *tty, struct file *filp)
44049
44050 /* reset the rts and dtr */
44051 /* do the actual close */
44052 - serial->port.count--;
44053 + atomic_dec(&serial->port.count);
44054
44055 - if (serial->port.count <= 0) {
44056 - serial->port.count = 0;
44057 + if (atomic_read(&serial->port.count) <= 0) {
44058 + atomic_set(&serial->port.count, 0);
44059 tty_port_tty_set(&serial->port, NULL);
44060 if (!usb_gone)
44061 hso_stop_serial_device(serial->parent);
44062 @@ -1427,7 +1426,7 @@ static void hso_serial_set_termios(struct tty_struct *tty, struct ktermios *old)
44063
44064 /* the actual setup */
44065 spin_lock_irqsave(&serial->serial_lock, flags);
44066 - if (serial->port.count)
44067 + if (atomic_read(&serial->port.count))
44068 _hso_serial_set_termios(tty, old);
44069 else
44070 tty->termios = *old;
44071 @@ -1886,7 +1885,7 @@ static void intr_callback(struct urb *urb)
44072 D1("Pending read interrupt on port %d\n", i);
44073 spin_lock(&serial->serial_lock);
44074 if (serial->rx_state == RX_IDLE &&
44075 - serial->port.count > 0) {
44076 + atomic_read(&serial->port.count) > 0) {
44077 /* Setup and send a ctrl req read on
44078 * port i */
44079 if (!serial->rx_urb_filled[0]) {
44080 @@ -3062,7 +3061,7 @@ static int hso_resume(struct usb_interface *iface)
44081 /* Start all serial ports */
44082 for (i = 0; i < HSO_SERIAL_TTY_MINORS; i++) {
44083 if (serial_table[i] && (serial_table[i]->interface == iface)) {
44084 - if (dev2ser(serial_table[i])->port.count) {
44085 + if (atomic_read(&dev2ser(serial_table[i])->port.count)) {
44086 result =
44087 hso_start_serial_device(serial_table[i], GFP_NOIO);
44088 hso_kick_transmit(dev2ser(serial_table[i]));
44089 diff --git a/drivers/net/usb/sierra_net.c b/drivers/net/usb/sierra_net.c
44090 index a79e9d3..78cd4fa 100644
44091 --- a/drivers/net/usb/sierra_net.c
44092 +++ b/drivers/net/usb/sierra_net.c
44093 @@ -52,7 +52,7 @@ static const char driver_name[] = "sierra_net";
44094 /* atomic counter partially included in MAC address to make sure 2 devices
44095 * do not end up with the same MAC - concept breaks in case of > 255 ifaces
44096 */
44097 -static atomic_t iface_counter = ATOMIC_INIT(0);
44098 +static atomic_unchecked_t iface_counter = ATOMIC_INIT(0);
44099
44100 /*
44101 * SYNC Timer Delay definition used to set the expiry time
44102 @@ -698,7 +698,7 @@ static int sierra_net_bind(struct usbnet *dev, struct usb_interface *intf)
44103 dev->net->netdev_ops = &sierra_net_device_ops;
44104
44105 /* change MAC addr to include, ifacenum, and to be unique */
44106 - dev->net->dev_addr[ETH_ALEN-2] = atomic_inc_return(&iface_counter);
44107 + dev->net->dev_addr[ETH_ALEN-2] = atomic_inc_return_unchecked(&iface_counter);
44108 dev->net->dev_addr[ETH_ALEN-1] = ifacenum;
44109
44110 /* we will have to manufacture ethernet headers, prepare template */
44111 diff --git a/drivers/net/vxlan.c b/drivers/net/vxlan.c
44112 index 2ef5b62..6fa0ec3 100644
44113 --- a/drivers/net/vxlan.c
44114 +++ b/drivers/net/vxlan.c
44115 @@ -2615,7 +2615,7 @@ nla_put_failure:
44116 return -EMSGSIZE;
44117 }
44118
44119 -static struct rtnl_link_ops vxlan_link_ops __read_mostly = {
44120 +static struct rtnl_link_ops vxlan_link_ops = {
44121 .kind = "vxlan",
44122 .maxtype = IFLA_VXLAN_MAX,
44123 .policy = vxlan_policy,
44124 diff --git a/drivers/net/wimax/i2400m/rx.c b/drivers/net/wimax/i2400m/rx.c
44125 index 0b60295..b8bfa5b 100644
44126 --- a/drivers/net/wimax/i2400m/rx.c
44127 +++ b/drivers/net/wimax/i2400m/rx.c
44128 @@ -1359,7 +1359,7 @@ int i2400m_rx_setup(struct i2400m *i2400m)
44129 if (i2400m->rx_roq == NULL)
44130 goto error_roq_alloc;
44131
44132 - rd = kcalloc(I2400M_RO_CIN + 1, sizeof(*i2400m->rx_roq[0].log),
44133 + rd = kcalloc(sizeof(*i2400m->rx_roq[0].log), I2400M_RO_CIN + 1,
44134 GFP_KERNEL);
44135 if (rd == NULL) {
44136 result = -ENOMEM;
44137 diff --git a/drivers/net/wireless/airo.c b/drivers/net/wireless/airo.c
44138 index 7fe1964..7016de0 100644
44139 --- a/drivers/net/wireless/airo.c
44140 +++ b/drivers/net/wireless/airo.c
44141 @@ -7844,7 +7844,7 @@ static int writerids(struct net_device *dev, aironet_ioctl *comp) {
44142 struct airo_info *ai = dev->ml_priv;
44143 int ridcode;
44144 int enabled;
44145 - static int (* writer)(struct airo_info *, u16 rid, const void *, int, int);
44146 + int (* writer)(struct airo_info *, u16 rid, const void *, int, int);
44147 unsigned char *iobuf;
44148
44149 /* Only super-user can write RIDs */
44150 diff --git a/drivers/net/wireless/at76c50x-usb.c b/drivers/net/wireless/at76c50x-usb.c
44151 index 34c8a33..3261fdc 100644
44152 --- a/drivers/net/wireless/at76c50x-usb.c
44153 +++ b/drivers/net/wireless/at76c50x-usb.c
44154 @@ -353,7 +353,7 @@ static int at76_dfu_get_state(struct usb_device *udev, u8 *state)
44155 }
44156
44157 /* Convert timeout from the DFU status to jiffies */
44158 -static inline unsigned long at76_get_timeout(struct dfu_status *s)
44159 +static inline unsigned long __intentional_overflow(-1) at76_get_timeout(struct dfu_status *s)
44160 {
44161 return msecs_to_jiffies((s->poll_timeout[2] << 16)
44162 | (s->poll_timeout[1] << 8)
44163 diff --git a/drivers/net/wireless/ath/ath10k/htc.c b/drivers/net/wireless/ath/ath10k/htc.c
44164 index ef3329e..c28ff5d 100644
44165 --- a/drivers/net/wireless/ath/ath10k/htc.c
44166 +++ b/drivers/net/wireless/ath/ath10k/htc.c
44167 @@ -963,7 +963,10 @@ void ath10k_htc_stop(struct ath10k_htc *htc)
44168 /* registered target arrival callback from the HIF layer */
44169 int ath10k_htc_init(struct ath10k *ar)
44170 {
44171 - struct ath10k_hif_cb htc_callbacks;
44172 + static struct ath10k_hif_cb htc_callbacks = {
44173 + .rx_completion = ath10k_htc_rx_completion_handler,
44174 + .tx_completion = ath10k_htc_tx_completion_handler,
44175 + };
44176 struct ath10k_htc_ep *ep = NULL;
44177 struct ath10k_htc *htc = &ar->htc;
44178
44179 @@ -973,8 +976,6 @@ int ath10k_htc_init(struct ath10k *ar)
44180 ath10k_htc_reset_endpoint_states(htc);
44181
44182 /* setup HIF layer callbacks */
44183 - htc_callbacks.rx_completion = ath10k_htc_rx_completion_handler;
44184 - htc_callbacks.tx_completion = ath10k_htc_tx_completion_handler;
44185 htc->ar = ar;
44186
44187 /* Get HIF default pipe for HTC message exchange */
44188 diff --git a/drivers/net/wireless/ath/ath10k/htc.h b/drivers/net/wireless/ath/ath10k/htc.h
44189 index e1dd8c7..9f91b3f 100644
44190 --- a/drivers/net/wireless/ath/ath10k/htc.h
44191 +++ b/drivers/net/wireless/ath/ath10k/htc.h
44192 @@ -271,12 +271,12 @@ enum ath10k_htc_ep_id {
44193
44194 struct ath10k_htc_ops {
44195 void (*target_send_suspend_complete)(struct ath10k *ar);
44196 -};
44197 +} __no_const;
44198
44199 struct ath10k_htc_ep_ops {
44200 void (*ep_tx_complete)(struct ath10k *, struct sk_buff *);
44201 void (*ep_rx_complete)(struct ath10k *, struct sk_buff *);
44202 -};
44203 +} __no_const;
44204
44205 /* service connection information */
44206 struct ath10k_htc_svc_conn_req {
44207 diff --git a/drivers/net/wireless/ath/ath9k/ar9002_mac.c b/drivers/net/wireless/ath/ath9k/ar9002_mac.c
44208 index 8d78253..bebbb68 100644
44209 --- a/drivers/net/wireless/ath/ath9k/ar9002_mac.c
44210 +++ b/drivers/net/wireless/ath/ath9k/ar9002_mac.c
44211 @@ -184,8 +184,8 @@ ar9002_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
44212 ads->ds_txstatus6 = ads->ds_txstatus7 = 0;
44213 ads->ds_txstatus8 = ads->ds_txstatus9 = 0;
44214
44215 - ACCESS_ONCE(ads->ds_link) = i->link;
44216 - ACCESS_ONCE(ads->ds_data) = i->buf_addr[0];
44217 + ACCESS_ONCE_RW(ads->ds_link) = i->link;
44218 + ACCESS_ONCE_RW(ads->ds_data) = i->buf_addr[0];
44219
44220 ctl1 = i->buf_len[0] | (i->is_last ? 0 : AR_TxMore);
44221 ctl6 = SM(i->keytype, AR_EncrType);
44222 @@ -199,26 +199,26 @@ ar9002_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
44223
44224 if ((i->is_first || i->is_last) &&
44225 i->aggr != AGGR_BUF_MIDDLE && i->aggr != AGGR_BUF_LAST) {
44226 - ACCESS_ONCE(ads->ds_ctl2) = set11nTries(i->rates, 0)
44227 + ACCESS_ONCE_RW(ads->ds_ctl2) = set11nTries(i->rates, 0)
44228 | set11nTries(i->rates, 1)
44229 | set11nTries(i->rates, 2)
44230 | set11nTries(i->rates, 3)
44231 | (i->dur_update ? AR_DurUpdateEna : 0)
44232 | SM(0, AR_BurstDur);
44233
44234 - ACCESS_ONCE(ads->ds_ctl3) = set11nRate(i->rates, 0)
44235 + ACCESS_ONCE_RW(ads->ds_ctl3) = set11nRate(i->rates, 0)
44236 | set11nRate(i->rates, 1)
44237 | set11nRate(i->rates, 2)
44238 | set11nRate(i->rates, 3);
44239 } else {
44240 - ACCESS_ONCE(ads->ds_ctl2) = 0;
44241 - ACCESS_ONCE(ads->ds_ctl3) = 0;
44242 + ACCESS_ONCE_RW(ads->ds_ctl2) = 0;
44243 + ACCESS_ONCE_RW(ads->ds_ctl3) = 0;
44244 }
44245
44246 if (!i->is_first) {
44247 - ACCESS_ONCE(ads->ds_ctl0) = 0;
44248 - ACCESS_ONCE(ads->ds_ctl1) = ctl1;
44249 - ACCESS_ONCE(ads->ds_ctl6) = ctl6;
44250 + ACCESS_ONCE_RW(ads->ds_ctl0) = 0;
44251 + ACCESS_ONCE_RW(ads->ds_ctl1) = ctl1;
44252 + ACCESS_ONCE_RW(ads->ds_ctl6) = ctl6;
44253 return;
44254 }
44255
44256 @@ -243,7 +243,7 @@ ar9002_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
44257 break;
44258 }
44259
44260 - ACCESS_ONCE(ads->ds_ctl0) = (i->pkt_len & AR_FrameLen)
44261 + ACCESS_ONCE_RW(ads->ds_ctl0) = (i->pkt_len & AR_FrameLen)
44262 | (i->flags & ATH9K_TXDESC_VMF ? AR_VirtMoreFrag : 0)
44263 | SM(i->txpower, AR_XmitPower)
44264 | (i->flags & ATH9K_TXDESC_VEOL ? AR_VEOL : 0)
44265 @@ -253,19 +253,19 @@ ar9002_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
44266 | (i->flags & ATH9K_TXDESC_RTSENA ? AR_RTSEnable :
44267 (i->flags & ATH9K_TXDESC_CTSENA ? AR_CTSEnable : 0));
44268
44269 - ACCESS_ONCE(ads->ds_ctl1) = ctl1;
44270 - ACCESS_ONCE(ads->ds_ctl6) = ctl6;
44271 + ACCESS_ONCE_RW(ads->ds_ctl1) = ctl1;
44272 + ACCESS_ONCE_RW(ads->ds_ctl6) = ctl6;
44273
44274 if (i->aggr == AGGR_BUF_MIDDLE || i->aggr == AGGR_BUF_LAST)
44275 return;
44276
44277 - ACCESS_ONCE(ads->ds_ctl4) = set11nPktDurRTSCTS(i->rates, 0)
44278 + ACCESS_ONCE_RW(ads->ds_ctl4) = set11nPktDurRTSCTS(i->rates, 0)
44279 | set11nPktDurRTSCTS(i->rates, 1);
44280
44281 - ACCESS_ONCE(ads->ds_ctl5) = set11nPktDurRTSCTS(i->rates, 2)
44282 + ACCESS_ONCE_RW(ads->ds_ctl5) = set11nPktDurRTSCTS(i->rates, 2)
44283 | set11nPktDurRTSCTS(i->rates, 3);
44284
44285 - ACCESS_ONCE(ads->ds_ctl7) = set11nRateFlags(i->rates, 0)
44286 + ACCESS_ONCE_RW(ads->ds_ctl7) = set11nRateFlags(i->rates, 0)
44287 | set11nRateFlags(i->rates, 1)
44288 | set11nRateFlags(i->rates, 2)
44289 | set11nRateFlags(i->rates, 3)
44290 diff --git a/drivers/net/wireless/ath/ath9k/ar9003_mac.c b/drivers/net/wireless/ath/ath9k/ar9003_mac.c
44291 index f6c5c1b..6058354 100644
44292 --- a/drivers/net/wireless/ath/ath9k/ar9003_mac.c
44293 +++ b/drivers/net/wireless/ath/ath9k/ar9003_mac.c
44294 @@ -39,47 +39,47 @@ ar9003_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
44295 (i->qcu << AR_TxQcuNum_S) | desc_len;
44296
44297 checksum += val;
44298 - ACCESS_ONCE(ads->info) = val;
44299 + ACCESS_ONCE_RW(ads->info) = val;
44300
44301 checksum += i->link;
44302 - ACCESS_ONCE(ads->link) = i->link;
44303 + ACCESS_ONCE_RW(ads->link) = i->link;
44304
44305 checksum += i->buf_addr[0];
44306 - ACCESS_ONCE(ads->data0) = i->buf_addr[0];
44307 + ACCESS_ONCE_RW(ads->data0) = i->buf_addr[0];
44308 checksum += i->buf_addr[1];
44309 - ACCESS_ONCE(ads->data1) = i->buf_addr[1];
44310 + ACCESS_ONCE_RW(ads->data1) = i->buf_addr[1];
44311 checksum += i->buf_addr[2];
44312 - ACCESS_ONCE(ads->data2) = i->buf_addr[2];
44313 + ACCESS_ONCE_RW(ads->data2) = i->buf_addr[2];
44314 checksum += i->buf_addr[3];
44315 - ACCESS_ONCE(ads->data3) = i->buf_addr[3];
44316 + ACCESS_ONCE_RW(ads->data3) = i->buf_addr[3];
44317
44318 checksum += (val = (i->buf_len[0] << AR_BufLen_S) & AR_BufLen);
44319 - ACCESS_ONCE(ads->ctl3) = val;
44320 + ACCESS_ONCE_RW(ads->ctl3) = val;
44321 checksum += (val = (i->buf_len[1] << AR_BufLen_S) & AR_BufLen);
44322 - ACCESS_ONCE(ads->ctl5) = val;
44323 + ACCESS_ONCE_RW(ads->ctl5) = val;
44324 checksum += (val = (i->buf_len[2] << AR_BufLen_S) & AR_BufLen);
44325 - ACCESS_ONCE(ads->ctl7) = val;
44326 + ACCESS_ONCE_RW(ads->ctl7) = val;
44327 checksum += (val = (i->buf_len[3] << AR_BufLen_S) & AR_BufLen);
44328 - ACCESS_ONCE(ads->ctl9) = val;
44329 + ACCESS_ONCE_RW(ads->ctl9) = val;
44330
44331 checksum = (u16) (((checksum & 0xffff) + (checksum >> 16)) & 0xffff);
44332 - ACCESS_ONCE(ads->ctl10) = checksum;
44333 + ACCESS_ONCE_RW(ads->ctl10) = checksum;
44334
44335 if (i->is_first || i->is_last) {
44336 - ACCESS_ONCE(ads->ctl13) = set11nTries(i->rates, 0)
44337 + ACCESS_ONCE_RW(ads->ctl13) = set11nTries(i->rates, 0)
44338 | set11nTries(i->rates, 1)
44339 | set11nTries(i->rates, 2)
44340 | set11nTries(i->rates, 3)
44341 | (i->dur_update ? AR_DurUpdateEna : 0)
44342 | SM(0, AR_BurstDur);
44343
44344 - ACCESS_ONCE(ads->ctl14) = set11nRate(i->rates, 0)
44345 + ACCESS_ONCE_RW(ads->ctl14) = set11nRate(i->rates, 0)
44346 | set11nRate(i->rates, 1)
44347 | set11nRate(i->rates, 2)
44348 | set11nRate(i->rates, 3);
44349 } else {
44350 - ACCESS_ONCE(ads->ctl13) = 0;
44351 - ACCESS_ONCE(ads->ctl14) = 0;
44352 + ACCESS_ONCE_RW(ads->ctl13) = 0;
44353 + ACCESS_ONCE_RW(ads->ctl14) = 0;
44354 }
44355
44356 ads->ctl20 = 0;
44357 @@ -89,17 +89,17 @@ ar9003_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
44358
44359 ctl17 = SM(i->keytype, AR_EncrType);
44360 if (!i->is_first) {
44361 - ACCESS_ONCE(ads->ctl11) = 0;
44362 - ACCESS_ONCE(ads->ctl12) = i->is_last ? 0 : AR_TxMore;
44363 - ACCESS_ONCE(ads->ctl15) = 0;
44364 - ACCESS_ONCE(ads->ctl16) = 0;
44365 - ACCESS_ONCE(ads->ctl17) = ctl17;
44366 - ACCESS_ONCE(ads->ctl18) = 0;
44367 - ACCESS_ONCE(ads->ctl19) = 0;
44368 + ACCESS_ONCE_RW(ads->ctl11) = 0;
44369 + ACCESS_ONCE_RW(ads->ctl12) = i->is_last ? 0 : AR_TxMore;
44370 + ACCESS_ONCE_RW(ads->ctl15) = 0;
44371 + ACCESS_ONCE_RW(ads->ctl16) = 0;
44372 + ACCESS_ONCE_RW(ads->ctl17) = ctl17;
44373 + ACCESS_ONCE_RW(ads->ctl18) = 0;
44374 + ACCESS_ONCE_RW(ads->ctl19) = 0;
44375 return;
44376 }
44377
44378 - ACCESS_ONCE(ads->ctl11) = (i->pkt_len & AR_FrameLen)
44379 + ACCESS_ONCE_RW(ads->ctl11) = (i->pkt_len & AR_FrameLen)
44380 | (i->flags & ATH9K_TXDESC_VMF ? AR_VirtMoreFrag : 0)
44381 | SM(i->txpower, AR_XmitPower)
44382 | (i->flags & ATH9K_TXDESC_VEOL ? AR_VEOL : 0)
44383 @@ -135,22 +135,22 @@ ar9003_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
44384 val = (i->flags & ATH9K_TXDESC_PAPRD) >> ATH9K_TXDESC_PAPRD_S;
44385 ctl12 |= SM(val, AR_PAPRDChainMask);
44386
44387 - ACCESS_ONCE(ads->ctl12) = ctl12;
44388 - ACCESS_ONCE(ads->ctl17) = ctl17;
44389 + ACCESS_ONCE_RW(ads->ctl12) = ctl12;
44390 + ACCESS_ONCE_RW(ads->ctl17) = ctl17;
44391
44392 - ACCESS_ONCE(ads->ctl15) = set11nPktDurRTSCTS(i->rates, 0)
44393 + ACCESS_ONCE_RW(ads->ctl15) = set11nPktDurRTSCTS(i->rates, 0)
44394 | set11nPktDurRTSCTS(i->rates, 1);
44395
44396 - ACCESS_ONCE(ads->ctl16) = set11nPktDurRTSCTS(i->rates, 2)
44397 + ACCESS_ONCE_RW(ads->ctl16) = set11nPktDurRTSCTS(i->rates, 2)
44398 | set11nPktDurRTSCTS(i->rates, 3);
44399
44400 - ACCESS_ONCE(ads->ctl18) = set11nRateFlags(i->rates, 0)
44401 + ACCESS_ONCE_RW(ads->ctl18) = set11nRateFlags(i->rates, 0)
44402 | set11nRateFlags(i->rates, 1)
44403 | set11nRateFlags(i->rates, 2)
44404 | set11nRateFlags(i->rates, 3)
44405 | SM(i->rtscts_rate, AR_RTSCTSRate);
44406
44407 - ACCESS_ONCE(ads->ctl19) = AR_Not_Sounding;
44408 + ACCESS_ONCE_RW(ads->ctl19) = AR_Not_Sounding;
44409 }
44410
44411 static u16 ar9003_calc_ptr_chksum(struct ar9003_txc *ads)
44412 diff --git a/drivers/net/wireless/ath/ath9k/hw.h b/drivers/net/wireless/ath/ath9k/hw.h
44413 index 69a907b..91e071c 100644
44414 --- a/drivers/net/wireless/ath/ath9k/hw.h
44415 +++ b/drivers/net/wireless/ath/ath9k/hw.h
44416 @@ -657,7 +657,7 @@ struct ath_hw_private_ops {
44417
44418 /* ANI */
44419 void (*ani_cache_ini_regs)(struct ath_hw *ah);
44420 -};
44421 +} __no_const;
44422
44423 /**
44424 * struct ath_spec_scan - parameters for Atheros spectral scan
44425 @@ -729,7 +729,7 @@ struct ath_hw_ops {
44426 #ifdef CONFIG_ATH9K_BTCOEX_SUPPORT
44427 void (*set_bt_ant_diversity)(struct ath_hw *hw, bool enable);
44428 #endif
44429 -};
44430 +} __no_const;
44431
44432 struct ath_nf_limits {
44433 s16 max;
44434 diff --git a/drivers/net/wireless/b43/phy_lp.c b/drivers/net/wireless/b43/phy_lp.c
44435 index 92190da..f3a4c4c 100644
44436 --- a/drivers/net/wireless/b43/phy_lp.c
44437 +++ b/drivers/net/wireless/b43/phy_lp.c
44438 @@ -2514,7 +2514,7 @@ static int lpphy_b2063_tune(struct b43_wldev *dev,
44439 {
44440 struct ssb_bus *bus = dev->dev->sdev->bus;
44441
44442 - static const struct b206x_channel *chandata = NULL;
44443 + const struct b206x_channel *chandata = NULL;
44444 u32 crystal_freq = bus->chipco.pmu.crystalfreq * 1000;
44445 u32 freqref, vco_freq, val1, val2, val3, timeout, timeoutref, count;
44446 u16 old_comm15, scale;
44447 diff --git a/drivers/net/wireless/iwlegacy/3945-mac.c b/drivers/net/wireless/iwlegacy/3945-mac.c
44448 index 9581d07..84f6a76 100644
44449 --- a/drivers/net/wireless/iwlegacy/3945-mac.c
44450 +++ b/drivers/net/wireless/iwlegacy/3945-mac.c
44451 @@ -3639,7 +3639,9 @@ il3945_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
44452 */
44453 if (il3945_mod_params.disable_hw_scan) {
44454 D_INFO("Disabling hw_scan\n");
44455 - il3945_mac_ops.hw_scan = NULL;
44456 + pax_open_kernel();
44457 + *(void **)&il3945_mac_ops.hw_scan = NULL;
44458 + pax_close_kernel();
44459 }
44460
44461 D_INFO("*** LOAD DRIVER ***\n");
44462 diff --git a/drivers/net/wireless/iwlwifi/dvm/debugfs.c b/drivers/net/wireless/iwlwifi/dvm/debugfs.c
44463 index d94f8ab..5b568c8 100644
44464 --- a/drivers/net/wireless/iwlwifi/dvm/debugfs.c
44465 +++ b/drivers/net/wireless/iwlwifi/dvm/debugfs.c
44466 @@ -188,7 +188,7 @@ static ssize_t iwl_dbgfs_sram_write(struct file *file,
44467 {
44468 struct iwl_priv *priv = file->private_data;
44469 char buf[64];
44470 - int buf_size;
44471 + size_t buf_size;
44472 u32 offset, len;
44473
44474 memset(buf, 0, sizeof(buf));
44475 @@ -458,7 +458,7 @@ static ssize_t iwl_dbgfs_rx_handlers_write(struct file *file,
44476 struct iwl_priv *priv = file->private_data;
44477
44478 char buf[8];
44479 - int buf_size;
44480 + size_t buf_size;
44481 u32 reset_flag;
44482
44483 memset(buf, 0, sizeof(buf));
44484 @@ -539,7 +539,7 @@ static ssize_t iwl_dbgfs_disable_ht40_write(struct file *file,
44485 {
44486 struct iwl_priv *priv = file->private_data;
44487 char buf[8];
44488 - int buf_size;
44489 + size_t buf_size;
44490 int ht40;
44491
44492 memset(buf, 0, sizeof(buf));
44493 @@ -591,7 +591,7 @@ static ssize_t iwl_dbgfs_sleep_level_override_write(struct file *file,
44494 {
44495 struct iwl_priv *priv = file->private_data;
44496 char buf[8];
44497 - int buf_size;
44498 + size_t buf_size;
44499 int value;
44500
44501 memset(buf, 0, sizeof(buf));
44502 @@ -683,10 +683,10 @@ DEBUGFS_READ_FILE_OPS(temperature);
44503 DEBUGFS_READ_WRITE_FILE_OPS(sleep_level_override);
44504 DEBUGFS_READ_FILE_OPS(current_sleep_command);
44505
44506 -static const char *fmt_value = " %-30s %10u\n";
44507 -static const char *fmt_hex = " %-30s 0x%02X\n";
44508 -static const char *fmt_table = " %-30s %10u %10u %10u %10u\n";
44509 -static const char *fmt_header =
44510 +static const char fmt_value[] = " %-30s %10u\n";
44511 +static const char fmt_hex[] = " %-30s 0x%02X\n";
44512 +static const char fmt_table[] = " %-30s %10u %10u %10u %10u\n";
44513 +static const char fmt_header[] =
44514 "%-32s current cumulative delta max\n";
44515
44516 static int iwl_statistics_flag(struct iwl_priv *priv, char *buf, int bufsz)
44517 @@ -1856,7 +1856,7 @@ static ssize_t iwl_dbgfs_clear_ucode_statistics_write(struct file *file,
44518 {
44519 struct iwl_priv *priv = file->private_data;
44520 char buf[8];
44521 - int buf_size;
44522 + size_t buf_size;
44523 int clear;
44524
44525 memset(buf, 0, sizeof(buf));
44526 @@ -1901,7 +1901,7 @@ static ssize_t iwl_dbgfs_ucode_tracing_write(struct file *file,
44527 {
44528 struct iwl_priv *priv = file->private_data;
44529 char buf[8];
44530 - int buf_size;
44531 + size_t buf_size;
44532 int trace;
44533
44534 memset(buf, 0, sizeof(buf));
44535 @@ -1972,7 +1972,7 @@ static ssize_t iwl_dbgfs_missed_beacon_write(struct file *file,
44536 {
44537 struct iwl_priv *priv = file->private_data;
44538 char buf[8];
44539 - int buf_size;
44540 + size_t buf_size;
44541 int missed;
44542
44543 memset(buf, 0, sizeof(buf));
44544 @@ -2013,7 +2013,7 @@ static ssize_t iwl_dbgfs_plcp_delta_write(struct file *file,
44545
44546 struct iwl_priv *priv = file->private_data;
44547 char buf[8];
44548 - int buf_size;
44549 + size_t buf_size;
44550 int plcp;
44551
44552 memset(buf, 0, sizeof(buf));
44553 @@ -2073,7 +2073,7 @@ static ssize_t iwl_dbgfs_txfifo_flush_write(struct file *file,
44554
44555 struct iwl_priv *priv = file->private_data;
44556 char buf[8];
44557 - int buf_size;
44558 + size_t buf_size;
44559 int flush;
44560
44561 memset(buf, 0, sizeof(buf));
44562 @@ -2163,7 +2163,7 @@ static ssize_t iwl_dbgfs_protection_mode_write(struct file *file,
44563
44564 struct iwl_priv *priv = file->private_data;
44565 char buf[8];
44566 - int buf_size;
44567 + size_t buf_size;
44568 int rts;
44569
44570 if (!priv->cfg->ht_params)
44571 @@ -2205,7 +2205,7 @@ static ssize_t iwl_dbgfs_echo_test_write(struct file *file,
44572 {
44573 struct iwl_priv *priv = file->private_data;
44574 char buf[8];
44575 - int buf_size;
44576 + size_t buf_size;
44577
44578 memset(buf, 0, sizeof(buf));
44579 buf_size = min(count, sizeof(buf) - 1);
44580 @@ -2239,7 +2239,7 @@ static ssize_t iwl_dbgfs_log_event_write(struct file *file,
44581 struct iwl_priv *priv = file->private_data;
44582 u32 event_log_flag;
44583 char buf[8];
44584 - int buf_size;
44585 + size_t buf_size;
44586
44587 /* check that the interface is up */
44588 if (!iwl_is_ready(priv))
44589 @@ -2293,7 +2293,7 @@ static ssize_t iwl_dbgfs_calib_disabled_write(struct file *file,
44590 struct iwl_priv *priv = file->private_data;
44591 char buf[8];
44592 u32 calib_disabled;
44593 - int buf_size;
44594 + size_t buf_size;
44595
44596 memset(buf, 0, sizeof(buf));
44597 buf_size = min(count, sizeof(buf) - 1);
44598 diff --git a/drivers/net/wireless/iwlwifi/dvm/main.c b/drivers/net/wireless/iwlwifi/dvm/main.c
44599 index 7aad766..06addb4 100644
44600 --- a/drivers/net/wireless/iwlwifi/dvm/main.c
44601 +++ b/drivers/net/wireless/iwlwifi/dvm/main.c
44602 @@ -1123,7 +1123,7 @@ static void iwl_option_config(struct iwl_priv *priv)
44603 static int iwl_eeprom_init_hw_params(struct iwl_priv *priv)
44604 {
44605 struct iwl_nvm_data *data = priv->nvm_data;
44606 - char *debug_msg;
44607 + static const char debug_msg[] = "Device SKU: 24GHz %s %s, 52GHz %s %s, 11.n %s %s\n";
44608
44609 if (data->sku_cap_11n_enable &&
44610 !priv->cfg->ht_params) {
44611 @@ -1137,7 +1137,6 @@ static int iwl_eeprom_init_hw_params(struct iwl_priv *priv)
44612 return -EINVAL;
44613 }
44614
44615 - debug_msg = "Device SKU: 24GHz %s %s, 52GHz %s %s, 11.n %s %s\n";
44616 IWL_DEBUG_INFO(priv, debug_msg,
44617 data->sku_cap_band_24GHz_enable ? "" : "NOT", "enabled",
44618 data->sku_cap_band_52GHz_enable ? "" : "NOT", "enabled",
44619 diff --git a/drivers/net/wireless/iwlwifi/pcie/trans.c b/drivers/net/wireless/iwlwifi/pcie/trans.c
44620 index c3f904d..4cadf83 100644
44621 --- a/drivers/net/wireless/iwlwifi/pcie/trans.c
44622 +++ b/drivers/net/wireless/iwlwifi/pcie/trans.c
44623 @@ -1252,7 +1252,7 @@ static ssize_t iwl_dbgfs_interrupt_write(struct file *file,
44624 struct isr_statistics *isr_stats = &trans_pcie->isr_stats;
44625
44626 char buf[8];
44627 - int buf_size;
44628 + size_t buf_size;
44629 u32 reset_flag;
44630
44631 memset(buf, 0, sizeof(buf));
44632 @@ -1273,7 +1273,7 @@ static ssize_t iwl_dbgfs_csr_write(struct file *file,
44633 {
44634 struct iwl_trans *trans = file->private_data;
44635 char buf[8];
44636 - int buf_size;
44637 + size_t buf_size;
44638 int csr;
44639
44640 memset(buf, 0, sizeof(buf));
44641 diff --git a/drivers/net/wireless/mac80211_hwsim.c b/drivers/net/wireless/mac80211_hwsim.c
44642 index 2cd3f54..e936f90 100644
44643 --- a/drivers/net/wireless/mac80211_hwsim.c
44644 +++ b/drivers/net/wireless/mac80211_hwsim.c
44645 @@ -2196,25 +2196,19 @@ static int __init init_mac80211_hwsim(void)
44646
44647 if (channels > 1) {
44648 hwsim_if_comb.num_different_channels = channels;
44649 - mac80211_hwsim_ops.hw_scan = mac80211_hwsim_hw_scan;
44650 - mac80211_hwsim_ops.cancel_hw_scan =
44651 - mac80211_hwsim_cancel_hw_scan;
44652 - mac80211_hwsim_ops.sw_scan_start = NULL;
44653 - mac80211_hwsim_ops.sw_scan_complete = NULL;
44654 - mac80211_hwsim_ops.remain_on_channel =
44655 - mac80211_hwsim_roc;
44656 - mac80211_hwsim_ops.cancel_remain_on_channel =
44657 - mac80211_hwsim_croc;
44658 - mac80211_hwsim_ops.add_chanctx =
44659 - mac80211_hwsim_add_chanctx;
44660 - mac80211_hwsim_ops.remove_chanctx =
44661 - mac80211_hwsim_remove_chanctx;
44662 - mac80211_hwsim_ops.change_chanctx =
44663 - mac80211_hwsim_change_chanctx;
44664 - mac80211_hwsim_ops.assign_vif_chanctx =
44665 - mac80211_hwsim_assign_vif_chanctx;
44666 - mac80211_hwsim_ops.unassign_vif_chanctx =
44667 - mac80211_hwsim_unassign_vif_chanctx;
44668 + pax_open_kernel();
44669 + *(void **)&mac80211_hwsim_ops.hw_scan = mac80211_hwsim_hw_scan;
44670 + *(void **)&mac80211_hwsim_ops.cancel_hw_scan = mac80211_hwsim_cancel_hw_scan;
44671 + *(void **)&mac80211_hwsim_ops.sw_scan_start = NULL;
44672 + *(void **)&mac80211_hwsim_ops.sw_scan_complete = NULL;
44673 + *(void **)&mac80211_hwsim_ops.remain_on_channel = mac80211_hwsim_roc;
44674 + *(void **)&mac80211_hwsim_ops.cancel_remain_on_channel = mac80211_hwsim_croc;
44675 + *(void **)&mac80211_hwsim_ops.add_chanctx = mac80211_hwsim_add_chanctx;
44676 + *(void **)&mac80211_hwsim_ops.remove_chanctx = mac80211_hwsim_remove_chanctx;
44677 + *(void **)&mac80211_hwsim_ops.change_chanctx = mac80211_hwsim_change_chanctx;
44678 + *(void **)&mac80211_hwsim_ops.assign_vif_chanctx = mac80211_hwsim_assign_vif_chanctx;
44679 + *(void **)&mac80211_hwsim_ops.unassign_vif_chanctx = mac80211_hwsim_unassign_vif_chanctx;
44680 + pax_close_kernel();
44681 }
44682
44683 spin_lock_init(&hwsim_radio_lock);
44684 diff --git a/drivers/net/wireless/rndis_wlan.c b/drivers/net/wireless/rndis_wlan.c
44685 index 8169a85..7fa3b47 100644
44686 --- a/drivers/net/wireless/rndis_wlan.c
44687 +++ b/drivers/net/wireless/rndis_wlan.c
44688 @@ -1238,7 +1238,7 @@ static int set_rts_threshold(struct usbnet *usbdev, u32 rts_threshold)
44689
44690 netdev_dbg(usbdev->net, "%s(): %i\n", __func__, rts_threshold);
44691
44692 - if (rts_threshold < 0 || rts_threshold > 2347)
44693 + if (rts_threshold > 2347)
44694 rts_threshold = 2347;
44695
44696 tmp = cpu_to_le32(rts_threshold);
44697 diff --git a/drivers/net/wireless/rt2x00/rt2x00.h b/drivers/net/wireless/rt2x00/rt2x00.h
44698 index fe4c572..99dedfa 100644
44699 --- a/drivers/net/wireless/rt2x00/rt2x00.h
44700 +++ b/drivers/net/wireless/rt2x00/rt2x00.h
44701 @@ -387,7 +387,7 @@ struct rt2x00_intf {
44702 * for hardware which doesn't support hardware
44703 * sequence counting.
44704 */
44705 - atomic_t seqno;
44706 + atomic_unchecked_t seqno;
44707 };
44708
44709 static inline struct rt2x00_intf* vif_to_intf(struct ieee80211_vif *vif)
44710 diff --git a/drivers/net/wireless/rt2x00/rt2x00queue.c b/drivers/net/wireless/rt2x00/rt2x00queue.c
44711 index 66a2db8..70cad04 100644
44712 --- a/drivers/net/wireless/rt2x00/rt2x00queue.c
44713 +++ b/drivers/net/wireless/rt2x00/rt2x00queue.c
44714 @@ -252,9 +252,9 @@ static void rt2x00queue_create_tx_descriptor_seq(struct rt2x00_dev *rt2x00dev,
44715 * sequence counter given by mac80211.
44716 */
44717 if (test_bit(ENTRY_TXD_FIRST_FRAGMENT, &txdesc->flags))
44718 - seqno = atomic_add_return(0x10, &intf->seqno);
44719 + seqno = atomic_add_return_unchecked(0x10, &intf->seqno);
44720 else
44721 - seqno = atomic_read(&intf->seqno);
44722 + seqno = atomic_read_unchecked(&intf->seqno);
44723
44724 hdr->seq_ctrl &= cpu_to_le16(IEEE80211_SCTL_FRAG);
44725 hdr->seq_ctrl |= cpu_to_le16(seqno);
44726 diff --git a/drivers/net/wireless/ti/wl1251/sdio.c b/drivers/net/wireless/ti/wl1251/sdio.c
44727 index e2b3d9c..67a5184 100644
44728 --- a/drivers/net/wireless/ti/wl1251/sdio.c
44729 +++ b/drivers/net/wireless/ti/wl1251/sdio.c
44730 @@ -271,13 +271,17 @@ static int wl1251_sdio_probe(struct sdio_func *func,
44731
44732 irq_set_irq_type(wl->irq, IRQ_TYPE_EDGE_RISING);
44733
44734 - wl1251_sdio_ops.enable_irq = wl1251_enable_line_irq;
44735 - wl1251_sdio_ops.disable_irq = wl1251_disable_line_irq;
44736 + pax_open_kernel();
44737 + *(void **)&wl1251_sdio_ops.enable_irq = wl1251_enable_line_irq;
44738 + *(void **)&wl1251_sdio_ops.disable_irq = wl1251_disable_line_irq;
44739 + pax_close_kernel();
44740
44741 wl1251_info("using dedicated interrupt line");
44742 } else {
44743 - wl1251_sdio_ops.enable_irq = wl1251_sdio_enable_irq;
44744 - wl1251_sdio_ops.disable_irq = wl1251_sdio_disable_irq;
44745 + pax_open_kernel();
44746 + *(void **)&wl1251_sdio_ops.enable_irq = wl1251_sdio_enable_irq;
44747 + *(void **)&wl1251_sdio_ops.disable_irq = wl1251_sdio_disable_irq;
44748 + pax_close_kernel();
44749
44750 wl1251_info("using SDIO interrupt");
44751 }
44752 diff --git a/drivers/net/wireless/ti/wl12xx/main.c b/drivers/net/wireless/ti/wl12xx/main.c
44753 index 1c627da..69f7d17 100644
44754 --- a/drivers/net/wireless/ti/wl12xx/main.c
44755 +++ b/drivers/net/wireless/ti/wl12xx/main.c
44756 @@ -656,7 +656,9 @@ static int wl12xx_identify_chip(struct wl1271 *wl)
44757 sizeof(wl->conf.mem));
44758
44759 /* read data preparation is only needed by wl127x */
44760 - wl->ops->prepare_read = wl127x_prepare_read;
44761 + pax_open_kernel();
44762 + *(void **)&wl->ops->prepare_read = wl127x_prepare_read;
44763 + pax_close_kernel();
44764
44765 wlcore_set_min_fw_ver(wl, WL127X_CHIP_VER,
44766 WL127X_IFTYPE_SR_VER, WL127X_MAJOR_SR_VER,
44767 @@ -681,7 +683,9 @@ static int wl12xx_identify_chip(struct wl1271 *wl)
44768 sizeof(wl->conf.mem));
44769
44770 /* read data preparation is only needed by wl127x */
44771 - wl->ops->prepare_read = wl127x_prepare_read;
44772 + pax_open_kernel();
44773 + *(void **)&wl->ops->prepare_read = wl127x_prepare_read;
44774 + pax_close_kernel();
44775
44776 wlcore_set_min_fw_ver(wl, WL127X_CHIP_VER,
44777 WL127X_IFTYPE_SR_VER, WL127X_MAJOR_SR_VER,
44778 diff --git a/drivers/net/wireless/ti/wl18xx/main.c b/drivers/net/wireless/ti/wl18xx/main.c
44779 index 7aa0eb8..5a9ef38 100644
44780 --- a/drivers/net/wireless/ti/wl18xx/main.c
44781 +++ b/drivers/net/wireless/ti/wl18xx/main.c
44782 @@ -1730,8 +1730,10 @@ static int wl18xx_setup(struct wl1271 *wl)
44783 }
44784
44785 if (!checksum_param) {
44786 - wl18xx_ops.set_rx_csum = NULL;
44787 - wl18xx_ops.init_vif = NULL;
44788 + pax_open_kernel();
44789 + *(void **)&wl18xx_ops.set_rx_csum = NULL;
44790 + *(void **)&wl18xx_ops.init_vif = NULL;
44791 + pax_close_kernel();
44792 }
44793
44794 /* Enable 11a Band only if we have 5G antennas */
44795 diff --git a/drivers/net/wireless/zd1211rw/zd_usb.c b/drivers/net/wireless/zd1211rw/zd_usb.c
44796 index 7ef0b4a..ff65c28 100644
44797 --- a/drivers/net/wireless/zd1211rw/zd_usb.c
44798 +++ b/drivers/net/wireless/zd1211rw/zd_usb.c
44799 @@ -386,7 +386,7 @@ static inline void handle_regs_int(struct urb *urb)
44800 {
44801 struct zd_usb *usb = urb->context;
44802 struct zd_usb_interrupt *intr = &usb->intr;
44803 - int len;
44804 + unsigned int len;
44805 u16 int_num;
44806
44807 ZD_ASSERT(in_interrupt());
44808 diff --git a/drivers/nfc/nfcwilink.c b/drivers/nfc/nfcwilink.c
44809 index 59f95d8..53e0e7f 100644
44810 --- a/drivers/nfc/nfcwilink.c
44811 +++ b/drivers/nfc/nfcwilink.c
44812 @@ -513,7 +513,7 @@ static struct nci_ops nfcwilink_ops = {
44813
44814 static int nfcwilink_probe(struct platform_device *pdev)
44815 {
44816 - static struct nfcwilink *drv;
44817 + struct nfcwilink *drv;
44818 int rc;
44819 __u32 protocols;
44820
44821 diff --git a/drivers/oprofile/buffer_sync.c b/drivers/oprofile/buffer_sync.c
44822 index d93b2b6..ae50401 100644
44823 --- a/drivers/oprofile/buffer_sync.c
44824 +++ b/drivers/oprofile/buffer_sync.c
44825 @@ -332,7 +332,7 @@ static void add_data(struct op_entry *entry, struct mm_struct *mm)
44826 if (cookie == NO_COOKIE)
44827 offset = pc;
44828 if (cookie == INVALID_COOKIE) {
44829 - atomic_inc(&oprofile_stats.sample_lost_no_mapping);
44830 + atomic_inc_unchecked(&oprofile_stats.sample_lost_no_mapping);
44831 offset = pc;
44832 }
44833 if (cookie != last_cookie) {
44834 @@ -376,14 +376,14 @@ add_sample(struct mm_struct *mm, struct op_sample *s, int in_kernel)
44835 /* add userspace sample */
44836
44837 if (!mm) {
44838 - atomic_inc(&oprofile_stats.sample_lost_no_mm);
44839 + atomic_inc_unchecked(&oprofile_stats.sample_lost_no_mm);
44840 return 0;
44841 }
44842
44843 cookie = lookup_dcookie(mm, s->eip, &offset);
44844
44845 if (cookie == INVALID_COOKIE) {
44846 - atomic_inc(&oprofile_stats.sample_lost_no_mapping);
44847 + atomic_inc_unchecked(&oprofile_stats.sample_lost_no_mapping);
44848 return 0;
44849 }
44850
44851 @@ -552,7 +552,7 @@ void sync_buffer(int cpu)
44852 /* ignore backtraces if failed to add a sample */
44853 if (state == sb_bt_start) {
44854 state = sb_bt_ignore;
44855 - atomic_inc(&oprofile_stats.bt_lost_no_mapping);
44856 + atomic_inc_unchecked(&oprofile_stats.bt_lost_no_mapping);
44857 }
44858 }
44859 release_mm(mm);
44860 diff --git a/drivers/oprofile/event_buffer.c b/drivers/oprofile/event_buffer.c
44861 index c0cc4e7..44d4e54 100644
44862 --- a/drivers/oprofile/event_buffer.c
44863 +++ b/drivers/oprofile/event_buffer.c
44864 @@ -53,7 +53,7 @@ void add_event_entry(unsigned long value)
44865 }
44866
44867 if (buffer_pos == buffer_size) {
44868 - atomic_inc(&oprofile_stats.event_lost_overflow);
44869 + atomic_inc_unchecked(&oprofile_stats.event_lost_overflow);
44870 return;
44871 }
44872
44873 diff --git a/drivers/oprofile/oprof.c b/drivers/oprofile/oprof.c
44874 index ed2c3ec..deda85a 100644
44875 --- a/drivers/oprofile/oprof.c
44876 +++ b/drivers/oprofile/oprof.c
44877 @@ -110,7 +110,7 @@ static void switch_worker(struct work_struct *work)
44878 if (oprofile_ops.switch_events())
44879 return;
44880
44881 - atomic_inc(&oprofile_stats.multiplex_counter);
44882 + atomic_inc_unchecked(&oprofile_stats.multiplex_counter);
44883 start_switch_worker();
44884 }
44885
44886 diff --git a/drivers/oprofile/oprofile_files.c b/drivers/oprofile/oprofile_files.c
44887 index ee2cfce..7f8f699 100644
44888 --- a/drivers/oprofile/oprofile_files.c
44889 +++ b/drivers/oprofile/oprofile_files.c
44890 @@ -27,7 +27,7 @@ unsigned long oprofile_time_slice;
44891
44892 #ifdef CONFIG_OPROFILE_EVENT_MULTIPLEX
44893
44894 -static ssize_t timeout_read(struct file *file, char __user *buf,
44895 +static ssize_t __intentional_overflow(-1) timeout_read(struct file *file, char __user *buf,
44896 size_t count, loff_t *offset)
44897 {
44898 return oprofilefs_ulong_to_user(jiffies_to_msecs(oprofile_time_slice),
44899 diff --git a/drivers/oprofile/oprofile_stats.c b/drivers/oprofile/oprofile_stats.c
44900 index 59659ce..6c860a0 100644
44901 --- a/drivers/oprofile/oprofile_stats.c
44902 +++ b/drivers/oprofile/oprofile_stats.c
44903 @@ -30,11 +30,11 @@ void oprofile_reset_stats(void)
44904 cpu_buf->sample_invalid_eip = 0;
44905 }
44906
44907 - atomic_set(&oprofile_stats.sample_lost_no_mm, 0);
44908 - atomic_set(&oprofile_stats.sample_lost_no_mapping, 0);
44909 - atomic_set(&oprofile_stats.event_lost_overflow, 0);
44910 - atomic_set(&oprofile_stats.bt_lost_no_mapping, 0);
44911 - atomic_set(&oprofile_stats.multiplex_counter, 0);
44912 + atomic_set_unchecked(&oprofile_stats.sample_lost_no_mm, 0);
44913 + atomic_set_unchecked(&oprofile_stats.sample_lost_no_mapping, 0);
44914 + atomic_set_unchecked(&oprofile_stats.event_lost_overflow, 0);
44915 + atomic_set_unchecked(&oprofile_stats.bt_lost_no_mapping, 0);
44916 + atomic_set_unchecked(&oprofile_stats.multiplex_counter, 0);
44917 }
44918
44919
44920 diff --git a/drivers/oprofile/oprofile_stats.h b/drivers/oprofile/oprofile_stats.h
44921 index 1fc622b..8c48fc3 100644
44922 --- a/drivers/oprofile/oprofile_stats.h
44923 +++ b/drivers/oprofile/oprofile_stats.h
44924 @@ -13,11 +13,11 @@
44925 #include <linux/atomic.h>
44926
44927 struct oprofile_stat_struct {
44928 - atomic_t sample_lost_no_mm;
44929 - atomic_t sample_lost_no_mapping;
44930 - atomic_t bt_lost_no_mapping;
44931 - atomic_t event_lost_overflow;
44932 - atomic_t multiplex_counter;
44933 + atomic_unchecked_t sample_lost_no_mm;
44934 + atomic_unchecked_t sample_lost_no_mapping;
44935 + atomic_unchecked_t bt_lost_no_mapping;
44936 + atomic_unchecked_t event_lost_overflow;
44937 + atomic_unchecked_t multiplex_counter;
44938 };
44939
44940 extern struct oprofile_stat_struct oprofile_stats;
44941 diff --git a/drivers/oprofile/oprofilefs.c b/drivers/oprofile/oprofilefs.c
44942 index 3f49345..c750d0b 100644
44943 --- a/drivers/oprofile/oprofilefs.c
44944 +++ b/drivers/oprofile/oprofilefs.c
44945 @@ -176,8 +176,8 @@ int oprofilefs_create_ro_ulong(struct dentry *root,
44946
44947 static ssize_t atomic_read_file(struct file *file, char __user *buf, size_t count, loff_t *offset)
44948 {
44949 - atomic_t *val = file->private_data;
44950 - return oprofilefs_ulong_to_user(atomic_read(val), buf, count, offset);
44951 + atomic_unchecked_t *val = file->private_data;
44952 + return oprofilefs_ulong_to_user(atomic_read_unchecked(val), buf, count, offset);
44953 }
44954
44955
44956 @@ -189,7 +189,7 @@ static const struct file_operations atomic_ro_fops = {
44957
44958
44959 int oprofilefs_create_ro_atomic(struct dentry *root,
44960 - char const *name, atomic_t *val)
44961 + char const *name, atomic_unchecked_t *val)
44962 {
44963 return __oprofilefs_create_file(root, name,
44964 &atomic_ro_fops, 0444, val);
44965 diff --git a/drivers/oprofile/timer_int.c b/drivers/oprofile/timer_int.c
44966 index 61be1d9..dec05d7 100644
44967 --- a/drivers/oprofile/timer_int.c
44968 +++ b/drivers/oprofile/timer_int.c
44969 @@ -93,7 +93,7 @@ static int oprofile_cpu_notify(struct notifier_block *self,
44970 return NOTIFY_OK;
44971 }
44972
44973 -static struct notifier_block __refdata oprofile_cpu_notifier = {
44974 +static struct notifier_block oprofile_cpu_notifier = {
44975 .notifier_call = oprofile_cpu_notify,
44976 };
44977
44978 diff --git a/drivers/parport/procfs.c b/drivers/parport/procfs.c
44979 index 92ed045..62d39bd7 100644
44980 --- a/drivers/parport/procfs.c
44981 +++ b/drivers/parport/procfs.c
44982 @@ -64,7 +64,7 @@ static int do_active_device(ctl_table *table, int write,
44983
44984 *ppos += len;
44985
44986 - return copy_to_user(result, buffer, len) ? -EFAULT : 0;
44987 + return (len > sizeof buffer || copy_to_user(result, buffer, len)) ? -EFAULT : 0;
44988 }
44989
44990 #ifdef CONFIG_PARPORT_1284
44991 @@ -106,7 +106,7 @@ static int do_autoprobe(ctl_table *table, int write,
44992
44993 *ppos += len;
44994
44995 - return copy_to_user (result, buffer, len) ? -EFAULT : 0;
44996 + return (len > sizeof buffer || copy_to_user (result, buffer, len)) ? -EFAULT : 0;
44997 }
44998 #endif /* IEEE1284.3 support. */
44999
45000 diff --git a/drivers/pci/hotplug/acpiphp_ibm.c b/drivers/pci/hotplug/acpiphp_ibm.c
45001 index 2f5786c..61ab4d1 100644
45002 --- a/drivers/pci/hotplug/acpiphp_ibm.c
45003 +++ b/drivers/pci/hotplug/acpiphp_ibm.c
45004 @@ -463,7 +463,9 @@ static int __init ibm_acpiphp_init(void)
45005 goto init_cleanup;
45006 }
45007
45008 - ibm_apci_table_attr.size = ibm_get_table_from_acpi(NULL);
45009 + pax_open_kernel();
45010 + *(size_t *)&ibm_apci_table_attr.size = ibm_get_table_from_acpi(NULL);
45011 + pax_close_kernel();
45012 retval = sysfs_create_bin_file(sysdir, &ibm_apci_table_attr);
45013
45014 return retval;
45015 diff --git a/drivers/pci/hotplug/cpcihp_generic.c b/drivers/pci/hotplug/cpcihp_generic.c
45016 index a6a71c4..c91097b 100644
45017 --- a/drivers/pci/hotplug/cpcihp_generic.c
45018 +++ b/drivers/pci/hotplug/cpcihp_generic.c
45019 @@ -73,7 +73,6 @@ static u16 port;
45020 static unsigned int enum_bit;
45021 static u8 enum_mask;
45022
45023 -static struct cpci_hp_controller_ops generic_hpc_ops;
45024 static struct cpci_hp_controller generic_hpc;
45025
45026 static int __init validate_parameters(void)
45027 @@ -139,6 +138,10 @@ static int query_enum(void)
45028 return ((value & enum_mask) == enum_mask);
45029 }
45030
45031 +static struct cpci_hp_controller_ops generic_hpc_ops = {
45032 + .query_enum = query_enum,
45033 +};
45034 +
45035 static int __init cpcihp_generic_init(void)
45036 {
45037 int status;
45038 @@ -165,7 +168,6 @@ static int __init cpcihp_generic_init(void)
45039 pci_dev_put(dev);
45040
45041 memset(&generic_hpc, 0, sizeof (struct cpci_hp_controller));
45042 - generic_hpc_ops.query_enum = query_enum;
45043 generic_hpc.ops = &generic_hpc_ops;
45044
45045 status = cpci_hp_register_controller(&generic_hpc);
45046 diff --git a/drivers/pci/hotplug/cpcihp_zt5550.c b/drivers/pci/hotplug/cpcihp_zt5550.c
45047 index 449b4bb..257e2e8 100644
45048 --- a/drivers/pci/hotplug/cpcihp_zt5550.c
45049 +++ b/drivers/pci/hotplug/cpcihp_zt5550.c
45050 @@ -59,7 +59,6 @@
45051 /* local variables */
45052 static bool debug;
45053 static bool poll;
45054 -static struct cpci_hp_controller_ops zt5550_hpc_ops;
45055 static struct cpci_hp_controller zt5550_hpc;
45056
45057 /* Primary cPCI bus bridge device */
45058 @@ -205,6 +204,10 @@ static int zt5550_hc_disable_irq(void)
45059 return 0;
45060 }
45061
45062 +static struct cpci_hp_controller_ops zt5550_hpc_ops = {
45063 + .query_enum = zt5550_hc_query_enum,
45064 +};
45065 +
45066 static int zt5550_hc_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
45067 {
45068 int status;
45069 @@ -216,16 +219,17 @@ static int zt5550_hc_init_one (struct pci_dev *pdev, const struct pci_device_id
45070 dbg("returned from zt5550_hc_config");
45071
45072 memset(&zt5550_hpc, 0, sizeof (struct cpci_hp_controller));
45073 - zt5550_hpc_ops.query_enum = zt5550_hc_query_enum;
45074 zt5550_hpc.ops = &zt5550_hpc_ops;
45075 if(!poll) {
45076 zt5550_hpc.irq = hc_dev->irq;
45077 zt5550_hpc.irq_flags = IRQF_SHARED;
45078 zt5550_hpc.dev_id = hc_dev;
45079
45080 - zt5550_hpc_ops.enable_irq = zt5550_hc_enable_irq;
45081 - zt5550_hpc_ops.disable_irq = zt5550_hc_disable_irq;
45082 - zt5550_hpc_ops.check_irq = zt5550_hc_check_irq;
45083 + pax_open_kernel();
45084 + *(void **)&zt5550_hpc_ops.enable_irq = zt5550_hc_enable_irq;
45085 + *(void **)&zt5550_hpc_ops.disable_irq = zt5550_hc_disable_irq;
45086 + *(void **)&zt5550_hpc_ops.check_irq = zt5550_hc_check_irq;
45087 + pax_open_kernel();
45088 } else {
45089 info("using ENUM# polling mode");
45090 }
45091 diff --git a/drivers/pci/hotplug/cpqphp_nvram.c b/drivers/pci/hotplug/cpqphp_nvram.c
45092 index 76ba8a1..20ca857 100644
45093 --- a/drivers/pci/hotplug/cpqphp_nvram.c
45094 +++ b/drivers/pci/hotplug/cpqphp_nvram.c
45095 @@ -428,9 +428,13 @@ static u32 store_HRT (void __iomem *rom_start)
45096
45097 void compaq_nvram_init (void __iomem *rom_start)
45098 {
45099 +
45100 +#ifndef CONFIG_PAX_KERNEXEC
45101 if (rom_start) {
45102 compaq_int15_entry_point = (rom_start + ROM_INT15_PHY_ADDR - ROM_PHY_ADDR);
45103 }
45104 +#endif
45105 +
45106 dbg("int15 entry = %p\n", compaq_int15_entry_point);
45107
45108 /* initialize our int15 lock */
45109 diff --git a/drivers/pci/hotplug/pci_hotplug_core.c b/drivers/pci/hotplug/pci_hotplug_core.c
45110 index ec20f74..c1d961e 100644
45111 --- a/drivers/pci/hotplug/pci_hotplug_core.c
45112 +++ b/drivers/pci/hotplug/pci_hotplug_core.c
45113 @@ -441,8 +441,10 @@ int __pci_hp_register(struct hotplug_slot *slot, struct pci_bus *bus,
45114 return -EINVAL;
45115 }
45116
45117 - slot->ops->owner = owner;
45118 - slot->ops->mod_name = mod_name;
45119 + pax_open_kernel();
45120 + *(struct module **)&slot->ops->owner = owner;
45121 + *(const char **)&slot->ops->mod_name = mod_name;
45122 + pax_close_kernel();
45123
45124 mutex_lock(&pci_hp_mutex);
45125 /*
45126 diff --git a/drivers/pci/hotplug/pciehp_core.c b/drivers/pci/hotplug/pciehp_core.c
45127 index f4a18f5..ff2463c 100644
45128 --- a/drivers/pci/hotplug/pciehp_core.c
45129 +++ b/drivers/pci/hotplug/pciehp_core.c
45130 @@ -92,7 +92,7 @@ static int init_slot(struct controller *ctrl)
45131 struct slot *slot = ctrl->slot;
45132 struct hotplug_slot *hotplug = NULL;
45133 struct hotplug_slot_info *info = NULL;
45134 - struct hotplug_slot_ops *ops = NULL;
45135 + hotplug_slot_ops_no_const *ops = NULL;
45136 char name[SLOT_NAME_SIZE];
45137 int retval = -ENOMEM;
45138
45139 diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c
45140 index 7128cfd..a0640d6 100644
45141 --- a/drivers/pci/pci-sysfs.c
45142 +++ b/drivers/pci/pci-sysfs.c
45143 @@ -1083,7 +1083,7 @@ static int pci_create_attr(struct pci_dev *pdev, int num, int write_combine)
45144 {
45145 /* allocate attribute structure, piggyback attribute name */
45146 int name_len = write_combine ? 13 : 10;
45147 - struct bin_attribute *res_attr;
45148 + bin_attribute_no_const *res_attr;
45149 int retval;
45150
45151 res_attr = kzalloc(sizeof(*res_attr) + name_len, GFP_ATOMIC);
45152 @@ -1268,7 +1268,7 @@ static struct device_attribute reset_attr = __ATTR(reset, 0200, NULL, reset_stor
45153 static int pci_create_capabilities_sysfs(struct pci_dev *dev)
45154 {
45155 int retval;
45156 - struct bin_attribute *attr;
45157 + bin_attribute_no_const *attr;
45158
45159 /* If the device has VPD, try to expose it in sysfs. */
45160 if (dev->vpd) {
45161 @@ -1315,7 +1315,7 @@ int __must_check pci_create_sysfs_dev_files (struct pci_dev *pdev)
45162 {
45163 int retval;
45164 int rom_size = 0;
45165 - struct bin_attribute *attr;
45166 + bin_attribute_no_const *attr;
45167
45168 if (!sysfs_initialized)
45169 return -EACCES;
45170 diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h
45171 index 8a00c06..18a9715 100644
45172 --- a/drivers/pci/pci.h
45173 +++ b/drivers/pci/pci.h
45174 @@ -95,7 +95,7 @@ struct pci_vpd_ops {
45175 struct pci_vpd {
45176 unsigned int len;
45177 const struct pci_vpd_ops *ops;
45178 - struct bin_attribute *attr; /* descriptor for sysfs VPD entry */
45179 + bin_attribute_no_const *attr; /* descriptor for sysfs VPD entry */
45180 };
45181
45182 int pci_vpd_pci22_init(struct pci_dev *dev);
45183 diff --git a/drivers/pci/pcie/aspm.c b/drivers/pci/pcie/aspm.c
45184 index 403a443..034e050 100644
45185 --- a/drivers/pci/pcie/aspm.c
45186 +++ b/drivers/pci/pcie/aspm.c
45187 @@ -27,9 +27,9 @@
45188 #define MODULE_PARAM_PREFIX "pcie_aspm."
45189
45190 /* Note: those are not register definitions */
45191 -#define ASPM_STATE_L0S_UP (1) /* Upstream direction L0s state */
45192 -#define ASPM_STATE_L0S_DW (2) /* Downstream direction L0s state */
45193 -#define ASPM_STATE_L1 (4) /* L1 state */
45194 +#define ASPM_STATE_L0S_UP (1U) /* Upstream direction L0s state */
45195 +#define ASPM_STATE_L0S_DW (2U) /* Downstream direction L0s state */
45196 +#define ASPM_STATE_L1 (4U) /* L1 state */
45197 #define ASPM_STATE_L0S (ASPM_STATE_L0S_UP | ASPM_STATE_L0S_DW)
45198 #define ASPM_STATE_ALL (ASPM_STATE_L0S | ASPM_STATE_L1)
45199
45200 diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
45201 index 7ef0f86..17b710f 100644
45202 --- a/drivers/pci/probe.c
45203 +++ b/drivers/pci/probe.c
45204 @@ -175,7 +175,7 @@ int __pci_read_base(struct pci_dev *dev, enum pci_bar_type type,
45205 struct pci_bus_region region, inverted_region;
45206 bool bar_too_big = false, bar_disabled = false;
45207
45208 - mask = type ? PCI_ROM_ADDRESS_MASK : ~0;
45209 + mask = type ? (u32)PCI_ROM_ADDRESS_MASK : ~0;
45210
45211 /* No printks while decoding is disabled! */
45212 if (!dev->mmio_always_on) {
45213 diff --git a/drivers/pci/proc.c b/drivers/pci/proc.c
45214 index cdc7836..528635c 100644
45215 --- a/drivers/pci/proc.c
45216 +++ b/drivers/pci/proc.c
45217 @@ -434,7 +434,16 @@ static const struct file_operations proc_bus_pci_dev_operations = {
45218 static int __init pci_proc_init(void)
45219 {
45220 struct pci_dev *dev = NULL;
45221 +
45222 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
45223 +#ifdef CONFIG_GRKERNSEC_PROC_USER
45224 + proc_bus_pci_dir = proc_mkdir_mode("bus/pci", S_IRUSR | S_IXUSR, NULL);
45225 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
45226 + proc_bus_pci_dir = proc_mkdir_mode("bus/pci", S_IRUSR | S_IXUSR | S_IRGRP | S_IXGRP, NULL);
45227 +#endif
45228 +#else
45229 proc_bus_pci_dir = proc_mkdir("bus/pci", NULL);
45230 +#endif
45231 proc_create("devices", 0, proc_bus_pci_dir,
45232 &proc_bus_pci_dev_operations);
45233 proc_initialized = 1;
45234 diff --git a/drivers/platform/x86/chromeos_laptop.c b/drivers/platform/x86/chromeos_laptop.c
45235 index 3e5b4497..dcdfb70 100644
45236 --- a/drivers/platform/x86/chromeos_laptop.c
45237 +++ b/drivers/platform/x86/chromeos_laptop.c
45238 @@ -301,7 +301,7 @@ static int __init setup_tsl2563_als(const struct dmi_system_id *id)
45239 return 0;
45240 }
45241
45242 -static struct dmi_system_id __initdata chromeos_laptop_dmi_table[] = {
45243 +static struct dmi_system_id __initconst chromeos_laptop_dmi_table[] = {
45244 {
45245 .ident = "Samsung Series 5 550 - Touchpad",
45246 .matches = {
45247 diff --git a/drivers/platform/x86/msi-laptop.c b/drivers/platform/x86/msi-laptop.c
45248 index 62f8030..c7f2a45 100644
45249 --- a/drivers/platform/x86/msi-laptop.c
45250 +++ b/drivers/platform/x86/msi-laptop.c
45251 @@ -1000,12 +1000,14 @@ static int __init load_scm_model_init(struct platform_device *sdev)
45252
45253 if (!quirks->ec_read_only) {
45254 /* allow userland write sysfs file */
45255 - dev_attr_bluetooth.store = store_bluetooth;
45256 - dev_attr_wlan.store = store_wlan;
45257 - dev_attr_threeg.store = store_threeg;
45258 - dev_attr_bluetooth.attr.mode |= S_IWUSR;
45259 - dev_attr_wlan.attr.mode |= S_IWUSR;
45260 - dev_attr_threeg.attr.mode |= S_IWUSR;
45261 + pax_open_kernel();
45262 + *(void **)&dev_attr_bluetooth.store = store_bluetooth;
45263 + *(void **)&dev_attr_wlan.store = store_wlan;
45264 + *(void **)&dev_attr_threeg.store = store_threeg;
45265 + *(umode_t *)&dev_attr_bluetooth.attr.mode |= S_IWUSR;
45266 + *(umode_t *)&dev_attr_wlan.attr.mode |= S_IWUSR;
45267 + *(umode_t *)&dev_attr_threeg.attr.mode |= S_IWUSR;
45268 + pax_close_kernel();
45269 }
45270
45271 /* disable hardware control by fn key */
45272 diff --git a/drivers/platform/x86/msi-wmi.c b/drivers/platform/x86/msi-wmi.c
45273 index 70222f2..8c8ce66 100644
45274 --- a/drivers/platform/x86/msi-wmi.c
45275 +++ b/drivers/platform/x86/msi-wmi.c
45276 @@ -183,7 +183,7 @@ static const struct backlight_ops msi_backlight_ops = {
45277 static void msi_wmi_notify(u32 value, void *context)
45278 {
45279 struct acpi_buffer response = { ACPI_ALLOCATE_BUFFER, NULL };
45280 - static struct key_entry *key;
45281 + struct key_entry *key;
45282 union acpi_object *obj;
45283 acpi_status status;
45284
45285 diff --git a/drivers/platform/x86/sony-laptop.c b/drivers/platform/x86/sony-laptop.c
45286 index 3484dd2..13ee730 100644
45287 --- a/drivers/platform/x86/sony-laptop.c
45288 +++ b/drivers/platform/x86/sony-laptop.c
45289 @@ -2448,7 +2448,7 @@ static void sony_nc_gfx_switch_cleanup(struct platform_device *pd)
45290 }
45291
45292 /* High speed charging function */
45293 -static struct device_attribute *hsc_handle;
45294 +static device_attribute_no_const *hsc_handle;
45295
45296 static ssize_t sony_nc_highspeed_charging_store(struct device *dev,
45297 struct device_attribute *attr,
45298 diff --git a/drivers/platform/x86/thinkpad_acpi.c b/drivers/platform/x86/thinkpad_acpi.c
45299 index 4e86e97..04d50d1 100644
45300 --- a/drivers/platform/x86/thinkpad_acpi.c
45301 +++ b/drivers/platform/x86/thinkpad_acpi.c
45302 @@ -2091,7 +2091,7 @@ static int hotkey_mask_get(void)
45303 return 0;
45304 }
45305
45306 -void static hotkey_mask_warn_incomplete_mask(void)
45307 +static void hotkey_mask_warn_incomplete_mask(void)
45308 {
45309 /* log only what the user can fix... */
45310 const u32 wantedmask = hotkey_driver_mask &
45311 @@ -2318,11 +2318,6 @@ static void hotkey_read_nvram(struct tp_nvram_state *n, const u32 m)
45312 }
45313 }
45314
45315 -static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
45316 - struct tp_nvram_state *newn,
45317 - const u32 event_mask)
45318 -{
45319 -
45320 #define TPACPI_COMPARE_KEY(__scancode, __member) \
45321 do { \
45322 if ((event_mask & (1 << __scancode)) && \
45323 @@ -2336,36 +2331,42 @@ static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
45324 tpacpi_hotkey_send_key(__scancode); \
45325 } while (0)
45326
45327 - void issue_volchange(const unsigned int oldvol,
45328 - const unsigned int newvol)
45329 - {
45330 - unsigned int i = oldvol;
45331 +static void issue_volchange(const unsigned int oldvol,
45332 + const unsigned int newvol,
45333 + const u32 event_mask)
45334 +{
45335 + unsigned int i = oldvol;
45336
45337 - while (i > newvol) {
45338 - TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_VOLUMEDOWN);
45339 - i--;
45340 - }
45341 - while (i < newvol) {
45342 - TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_VOLUMEUP);
45343 - i++;
45344 - }
45345 + while (i > newvol) {
45346 + TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_VOLUMEDOWN);
45347 + i--;
45348 }
45349 + while (i < newvol) {
45350 + TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_VOLUMEUP);
45351 + i++;
45352 + }
45353 +}
45354
45355 - void issue_brightnesschange(const unsigned int oldbrt,
45356 - const unsigned int newbrt)
45357 - {
45358 - unsigned int i = oldbrt;
45359 +static void issue_brightnesschange(const unsigned int oldbrt,
45360 + const unsigned int newbrt,
45361 + const u32 event_mask)
45362 +{
45363 + unsigned int i = oldbrt;
45364
45365 - while (i > newbrt) {
45366 - TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_FNEND);
45367 - i--;
45368 - }
45369 - while (i < newbrt) {
45370 - TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_FNHOME);
45371 - i++;
45372 - }
45373 + while (i > newbrt) {
45374 + TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_FNEND);
45375 + i--;
45376 + }
45377 + while (i < newbrt) {
45378 + TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_FNHOME);
45379 + i++;
45380 }
45381 +}
45382
45383 +static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
45384 + struct tp_nvram_state *newn,
45385 + const u32 event_mask)
45386 +{
45387 TPACPI_COMPARE_KEY(TP_ACPI_HOTKEYSCAN_THINKPAD, thinkpad_toggle);
45388 TPACPI_COMPARE_KEY(TP_ACPI_HOTKEYSCAN_FNSPACE, zoom_toggle);
45389 TPACPI_COMPARE_KEY(TP_ACPI_HOTKEYSCAN_FNF7, display_toggle);
45390 @@ -2399,7 +2400,7 @@ static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
45391 oldn->volume_level != newn->volume_level) {
45392 /* recently muted, or repeated mute keypress, or
45393 * multiple presses ending in mute */
45394 - issue_volchange(oldn->volume_level, newn->volume_level);
45395 + issue_volchange(oldn->volume_level, newn->volume_level, event_mask);
45396 TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_MUTE);
45397 }
45398 } else {
45399 @@ -2409,7 +2410,7 @@ static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
45400 TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_VOLUMEUP);
45401 }
45402 if (oldn->volume_level != newn->volume_level) {
45403 - issue_volchange(oldn->volume_level, newn->volume_level);
45404 + issue_volchange(oldn->volume_level, newn->volume_level, event_mask);
45405 } else if (oldn->volume_toggle != newn->volume_toggle) {
45406 /* repeated vol up/down keypress at end of scale ? */
45407 if (newn->volume_level == 0)
45408 @@ -2422,7 +2423,8 @@ static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
45409 /* handle brightness */
45410 if (oldn->brightness_level != newn->brightness_level) {
45411 issue_brightnesschange(oldn->brightness_level,
45412 - newn->brightness_level);
45413 + newn->brightness_level,
45414 + event_mask);
45415 } else if (oldn->brightness_toggle != newn->brightness_toggle) {
45416 /* repeated key presses that didn't change state */
45417 if (newn->brightness_level == 0)
45418 @@ -2431,10 +2433,10 @@ static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
45419 && !tp_features.bright_unkfw)
45420 TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_FNHOME);
45421 }
45422 +}
45423
45424 #undef TPACPI_COMPARE_KEY
45425 #undef TPACPI_MAY_SEND_KEY
45426 -}
45427
45428 /*
45429 * Polling driver
45430 diff --git a/drivers/pnp/pnpbios/bioscalls.c b/drivers/pnp/pnpbios/bioscalls.c
45431 index 769d265..a3a05ca 100644
45432 --- a/drivers/pnp/pnpbios/bioscalls.c
45433 +++ b/drivers/pnp/pnpbios/bioscalls.c
45434 @@ -58,7 +58,7 @@ do { \
45435 set_desc_limit(&gdt[(selname) >> 3], (size) - 1); \
45436 } while(0)
45437
45438 -static struct desc_struct bad_bios_desc = GDT_ENTRY_INIT(0x4092,
45439 +static const struct desc_struct bad_bios_desc = GDT_ENTRY_INIT(0x4093,
45440 (unsigned long)__va(0x400UL), PAGE_SIZE - 0x400 - 1);
45441
45442 /*
45443 @@ -95,7 +95,10 @@ static inline u16 call_pnp_bios(u16 func, u16 arg1, u16 arg2, u16 arg3,
45444
45445 cpu = get_cpu();
45446 save_desc_40 = get_cpu_gdt_table(cpu)[0x40 / 8];
45447 +
45448 + pax_open_kernel();
45449 get_cpu_gdt_table(cpu)[0x40 / 8] = bad_bios_desc;
45450 + pax_close_kernel();
45451
45452 /* On some boxes IRQ's during PnP BIOS calls are deadly. */
45453 spin_lock_irqsave(&pnp_bios_lock, flags);
45454 @@ -133,7 +136,10 @@ static inline u16 call_pnp_bios(u16 func, u16 arg1, u16 arg2, u16 arg3,
45455 :"memory");
45456 spin_unlock_irqrestore(&pnp_bios_lock, flags);
45457
45458 + pax_open_kernel();
45459 get_cpu_gdt_table(cpu)[0x40 / 8] = save_desc_40;
45460 + pax_close_kernel();
45461 +
45462 put_cpu();
45463
45464 /* If we get here and this is set then the PnP BIOS faulted on us. */
45465 @@ -467,7 +473,7 @@ int pnp_bios_read_escd(char *data, u32 nvram_base)
45466 return status;
45467 }
45468
45469 -void pnpbios_calls_init(union pnp_bios_install_struct *header)
45470 +void __init pnpbios_calls_init(union pnp_bios_install_struct *header)
45471 {
45472 int i;
45473
45474 @@ -475,6 +481,8 @@ void pnpbios_calls_init(union pnp_bios_install_struct *header)
45475 pnp_bios_callpoint.offset = header->fields.pm16offset;
45476 pnp_bios_callpoint.segment = PNP_CS16;
45477
45478 + pax_open_kernel();
45479 +
45480 for_each_possible_cpu(i) {
45481 struct desc_struct *gdt = get_cpu_gdt_table(i);
45482 if (!gdt)
45483 @@ -486,4 +494,6 @@ void pnpbios_calls_init(union pnp_bios_install_struct *header)
45484 set_desc_base(&gdt[GDT_ENTRY_PNPBIOS_DS],
45485 (unsigned long)__va(header->fields.pm16dseg));
45486 }
45487 +
45488 + pax_close_kernel();
45489 }
45490 diff --git a/drivers/pnp/resource.c b/drivers/pnp/resource.c
45491 index d95e101..67f0c3f 100644
45492 --- a/drivers/pnp/resource.c
45493 +++ b/drivers/pnp/resource.c
45494 @@ -360,7 +360,7 @@ int pnp_check_irq(struct pnp_dev *dev, struct resource *res)
45495 return 1;
45496
45497 /* check if the resource is valid */
45498 - if (*irq < 0 || *irq > 15)
45499 + if (*irq > 15)
45500 return 0;
45501
45502 /* check if the resource is reserved */
45503 @@ -424,7 +424,7 @@ int pnp_check_dma(struct pnp_dev *dev, struct resource *res)
45504 return 1;
45505
45506 /* check if the resource is valid */
45507 - if (*dma < 0 || *dma == 4 || *dma > 7)
45508 + if (*dma == 4 || *dma > 7)
45509 return 0;
45510
45511 /* check if the resource is reserved */
45512 diff --git a/drivers/power/pda_power.c b/drivers/power/pda_power.c
45513 index 0c52e2a..3421ab7 100644
45514 --- a/drivers/power/pda_power.c
45515 +++ b/drivers/power/pda_power.c
45516 @@ -37,7 +37,11 @@ static int polling;
45517
45518 #if IS_ENABLED(CONFIG_USB_PHY)
45519 static struct usb_phy *transceiver;
45520 -static struct notifier_block otg_nb;
45521 +static int otg_handle_notification(struct notifier_block *nb,
45522 + unsigned long event, void *unused);
45523 +static struct notifier_block otg_nb = {
45524 + .notifier_call = otg_handle_notification
45525 +};
45526 #endif
45527
45528 static struct regulator *ac_draw;
45529 @@ -369,7 +373,6 @@ static int pda_power_probe(struct platform_device *pdev)
45530
45531 #if IS_ENABLED(CONFIG_USB_PHY)
45532 if (!IS_ERR_OR_NULL(transceiver) && pdata->use_otg_notifier) {
45533 - otg_nb.notifier_call = otg_handle_notification;
45534 ret = usb_register_notifier(transceiver, &otg_nb);
45535 if (ret) {
45536 dev_err(dev, "failure to register otg notifier\n");
45537 diff --git a/drivers/power/power_supply.h b/drivers/power/power_supply.h
45538 index cc439fd..8fa30df 100644
45539 --- a/drivers/power/power_supply.h
45540 +++ b/drivers/power/power_supply.h
45541 @@ -16,12 +16,12 @@ struct power_supply;
45542
45543 #ifdef CONFIG_SYSFS
45544
45545 -extern void power_supply_init_attrs(struct device_type *dev_type);
45546 +extern void power_supply_init_attrs(void);
45547 extern int power_supply_uevent(struct device *dev, struct kobj_uevent_env *env);
45548
45549 #else
45550
45551 -static inline void power_supply_init_attrs(struct device_type *dev_type) {}
45552 +static inline void power_supply_init_attrs(void) {}
45553 #define power_supply_uevent NULL
45554
45555 #endif /* CONFIG_SYSFS */
45556 diff --git a/drivers/power/power_supply_core.c b/drivers/power/power_supply_core.c
45557 index 00e6672..2642c08 100644
45558 --- a/drivers/power/power_supply_core.c
45559 +++ b/drivers/power/power_supply_core.c
45560 @@ -24,7 +24,10 @@
45561 struct class *power_supply_class;
45562 EXPORT_SYMBOL_GPL(power_supply_class);
45563
45564 -static struct device_type power_supply_dev_type;
45565 +extern const struct attribute_group *power_supply_attr_groups[];
45566 +static struct device_type power_supply_dev_type = {
45567 + .groups = power_supply_attr_groups,
45568 +};
45569
45570 static bool __power_supply_is_supplied_by(struct power_supply *supplier,
45571 struct power_supply *supply)
45572 @@ -584,7 +587,7 @@ static int __init power_supply_class_init(void)
45573 return PTR_ERR(power_supply_class);
45574
45575 power_supply_class->dev_uevent = power_supply_uevent;
45576 - power_supply_init_attrs(&power_supply_dev_type);
45577 + power_supply_init_attrs();
45578
45579 return 0;
45580 }
45581 diff --git a/drivers/power/power_supply_sysfs.c b/drivers/power/power_supply_sysfs.c
45582 index 44420d1..967126e 100644
45583 --- a/drivers/power/power_supply_sysfs.c
45584 +++ b/drivers/power/power_supply_sysfs.c
45585 @@ -230,17 +230,15 @@ static struct attribute_group power_supply_attr_group = {
45586 .is_visible = power_supply_attr_is_visible,
45587 };
45588
45589 -static const struct attribute_group *power_supply_attr_groups[] = {
45590 +const struct attribute_group *power_supply_attr_groups[] = {
45591 &power_supply_attr_group,
45592 NULL,
45593 };
45594
45595 -void power_supply_init_attrs(struct device_type *dev_type)
45596 +void power_supply_init_attrs(void)
45597 {
45598 int i;
45599
45600 - dev_type->groups = power_supply_attr_groups;
45601 -
45602 for (i = 0; i < ARRAY_SIZE(power_supply_attrs); i++)
45603 __power_supply_attrs[i] = &power_supply_attrs[i].attr;
45604 }
45605 diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
45606 index a01b8b3..37c2afe 100644
45607 --- a/drivers/regulator/core.c
45608 +++ b/drivers/regulator/core.c
45609 @@ -3307,7 +3307,7 @@ regulator_register(const struct regulator_desc *regulator_desc,
45610 {
45611 const struct regulation_constraints *constraints = NULL;
45612 const struct regulator_init_data *init_data;
45613 - static atomic_t regulator_no = ATOMIC_INIT(0);
45614 + static atomic_unchecked_t regulator_no = ATOMIC_INIT(0);
45615 struct regulator_dev *rdev;
45616 struct device *dev;
45617 int ret, i;
45618 @@ -3377,7 +3377,7 @@ regulator_register(const struct regulator_desc *regulator_desc,
45619 rdev->dev.of_node = config->of_node;
45620 rdev->dev.parent = dev;
45621 dev_set_name(&rdev->dev, "regulator.%d",
45622 - atomic_inc_return(&regulator_no) - 1);
45623 + atomic_inc_return_unchecked(&regulator_no) - 1);
45624 ret = device_register(&rdev->dev);
45625 if (ret != 0) {
45626 put_device(&rdev->dev);
45627 diff --git a/drivers/regulator/max8660.c b/drivers/regulator/max8660.c
45628 index 144bcac..d20e7db 100644
45629 --- a/drivers/regulator/max8660.c
45630 +++ b/drivers/regulator/max8660.c
45631 @@ -420,8 +420,10 @@ static int max8660_probe(struct i2c_client *client,
45632 max8660->shadow_regs[MAX8660_OVER1] = 5;
45633 } else {
45634 /* Otherwise devices can be toggled via software */
45635 - max8660_dcdc_ops.enable = max8660_dcdc_enable;
45636 - max8660_dcdc_ops.disable = max8660_dcdc_disable;
45637 + pax_open_kernel();
45638 + *(void **)&max8660_dcdc_ops.enable = max8660_dcdc_enable;
45639 + *(void **)&max8660_dcdc_ops.disable = max8660_dcdc_disable;
45640 + pax_close_kernel();
45641 }
45642
45643 /*
45644 diff --git a/drivers/regulator/max8973-regulator.c b/drivers/regulator/max8973-regulator.c
45645 index 5b77ab7..a62f061 100644
45646 --- a/drivers/regulator/max8973-regulator.c
45647 +++ b/drivers/regulator/max8973-regulator.c
45648 @@ -406,9 +406,11 @@ static int max8973_probe(struct i2c_client *client,
45649 if (!pdata || !pdata->enable_ext_control) {
45650 max->desc.enable_reg = MAX8973_VOUT;
45651 max->desc.enable_mask = MAX8973_VOUT_ENABLE;
45652 - max->ops.enable = regulator_enable_regmap;
45653 - max->ops.disable = regulator_disable_regmap;
45654 - max->ops.is_enabled = regulator_is_enabled_regmap;
45655 + pax_open_kernel();
45656 + *(void **)&max->ops.enable = regulator_enable_regmap;
45657 + *(void **)&max->ops.disable = regulator_disable_regmap;
45658 + *(void **)&max->ops.is_enabled = regulator_is_enabled_regmap;
45659 + pax_close_kernel();
45660 }
45661
45662 if (pdata) {
45663 diff --git a/drivers/regulator/mc13892-regulator.c b/drivers/regulator/mc13892-regulator.c
45664 index 1037e07..e64dea1 100644
45665 --- a/drivers/regulator/mc13892-regulator.c
45666 +++ b/drivers/regulator/mc13892-regulator.c
45667 @@ -582,10 +582,12 @@ static int mc13892_regulator_probe(struct platform_device *pdev)
45668 }
45669 mc13xxx_unlock(mc13892);
45670
45671 - mc13892_regulators[MC13892_VCAM].desc.ops->set_mode
45672 + pax_open_kernel();
45673 + *(void **)&mc13892_regulators[MC13892_VCAM].desc.ops->set_mode
45674 = mc13892_vcam_set_mode;
45675 - mc13892_regulators[MC13892_VCAM].desc.ops->get_mode
45676 + *(void **)&mc13892_regulators[MC13892_VCAM].desc.ops->get_mode
45677 = mc13892_vcam_get_mode;
45678 + pax_close_kernel();
45679
45680 mc13xxx_data = mc13xxx_parse_regulators_dt(pdev, mc13892_regulators,
45681 ARRAY_SIZE(mc13892_regulators));
45682 diff --git a/drivers/rtc/rtc-cmos.c b/drivers/rtc/rtc-cmos.c
45683 index 24e733c..bfbaa3e 100644
45684 --- a/drivers/rtc/rtc-cmos.c
45685 +++ b/drivers/rtc/rtc-cmos.c
45686 @@ -731,7 +731,9 @@ cmos_do_probe(struct device *dev, struct resource *ports, int rtc_irq)
45687 hpet_rtc_timer_init();
45688
45689 /* export at least the first block of NVRAM */
45690 - nvram.size = address_space - NVRAM_OFFSET;
45691 + pax_open_kernel();
45692 + *(size_t *)&nvram.size = address_space - NVRAM_OFFSET;
45693 + pax_close_kernel();
45694 retval = sysfs_create_bin_file(&dev->kobj, &nvram);
45695 if (retval < 0) {
45696 dev_dbg(dev, "can't create nvram file? %d\n", retval);
45697 diff --git a/drivers/rtc/rtc-dev.c b/drivers/rtc/rtc-dev.c
45698 index d049393..bb20be0 100644
45699 --- a/drivers/rtc/rtc-dev.c
45700 +++ b/drivers/rtc/rtc-dev.c
45701 @@ -16,6 +16,7 @@
45702 #include <linux/module.h>
45703 #include <linux/rtc.h>
45704 #include <linux/sched.h>
45705 +#include <linux/grsecurity.h>
45706 #include "rtc-core.h"
45707
45708 static dev_t rtc_devt;
45709 @@ -347,6 +348,8 @@ static long rtc_dev_ioctl(struct file *file,
45710 if (copy_from_user(&tm, uarg, sizeof(tm)))
45711 return -EFAULT;
45712
45713 + gr_log_timechange();
45714 +
45715 return rtc_set_time(rtc, &tm);
45716
45717 case RTC_PIE_ON:
45718 diff --git a/drivers/rtc/rtc-ds1307.c b/drivers/rtc/rtc-ds1307.c
45719 index ca18fd1..055e42d 100644
45720 --- a/drivers/rtc/rtc-ds1307.c
45721 +++ b/drivers/rtc/rtc-ds1307.c
45722 @@ -107,7 +107,7 @@ struct ds1307 {
45723 u8 offset; /* register's offset */
45724 u8 regs[11];
45725 u16 nvram_offset;
45726 - struct bin_attribute *nvram;
45727 + bin_attribute_no_const *nvram;
45728 enum ds_type type;
45729 unsigned long flags;
45730 #define HAS_NVRAM 0 /* bit 0 == sysfs file active */
45731 diff --git a/drivers/rtc/rtc-m48t59.c b/drivers/rtc/rtc-m48t59.c
45732 index fcb0329..d77b7f2 100644
45733 --- a/drivers/rtc/rtc-m48t59.c
45734 +++ b/drivers/rtc/rtc-m48t59.c
45735 @@ -483,7 +483,9 @@ static int m48t59_rtc_probe(struct platform_device *pdev)
45736 if (IS_ERR(m48t59->rtc))
45737 return PTR_ERR(m48t59->rtc);
45738
45739 - m48t59_nvram_attr.size = pdata->offset;
45740 + pax_open_kernel();
45741 + *(size_t *)&m48t59_nvram_attr.size = pdata->offset;
45742 + pax_close_kernel();
45743
45744 ret = sysfs_create_bin_file(&pdev->dev.kobj, &m48t59_nvram_attr);
45745 if (ret)
45746 diff --git a/drivers/scsi/aic7xxx/aic79xx_pci.c b/drivers/scsi/aic7xxx/aic79xx_pci.c
45747 index 14b5f8d..cc9bd26 100644
45748 --- a/drivers/scsi/aic7xxx/aic79xx_pci.c
45749 +++ b/drivers/scsi/aic7xxx/aic79xx_pci.c
45750 @@ -827,7 +827,7 @@ ahd_pci_intr(struct ahd_softc *ahd)
45751 for (bit = 0; bit < 8; bit++) {
45752
45753 if ((pci_status[i] & (0x1 << bit)) != 0) {
45754 - static const char *s;
45755 + const char *s;
45756
45757 s = pci_status_strings[bit];
45758 if (i == 7/*TARG*/ && bit == 3)
45759 @@ -887,23 +887,15 @@ ahd_pci_split_intr(struct ahd_softc *ahd, u_int intstat)
45760
45761 for (bit = 0; bit < 8; bit++) {
45762
45763 - if ((split_status[i] & (0x1 << bit)) != 0) {
45764 - static const char *s;
45765 -
45766 - s = split_status_strings[bit];
45767 - printk(s, ahd_name(ahd),
45768 + if ((split_status[i] & (0x1 << bit)) != 0)
45769 + printk(split_status_strings[bit], ahd_name(ahd),
45770 split_status_source[i]);
45771 - }
45772
45773 if (i > 1)
45774 continue;
45775
45776 - if ((sg_split_status[i] & (0x1 << bit)) != 0) {
45777 - static const char *s;
45778 -
45779 - s = split_status_strings[bit];
45780 - printk(s, ahd_name(ahd), "SG");
45781 - }
45782 + if ((sg_split_status[i] & (0x1 << bit)) != 0)
45783 + printk(split_status_strings[bit], ahd_name(ahd), "SG");
45784 }
45785 }
45786 /*
45787 diff --git a/drivers/scsi/bfa/bfa_fcpim.h b/drivers/scsi/bfa/bfa_fcpim.h
45788 index e693af6..2e525b6 100644
45789 --- a/drivers/scsi/bfa/bfa_fcpim.h
45790 +++ b/drivers/scsi/bfa/bfa_fcpim.h
45791 @@ -36,7 +36,7 @@ struct bfa_iotag_s {
45792
45793 struct bfa_itn_s {
45794 bfa_isr_func_t isr;
45795 -};
45796 +} __no_const;
45797
45798 void bfa_itn_create(struct bfa_s *bfa, struct bfa_rport_s *rport,
45799 void (*isr)(struct bfa_s *bfa, struct bfi_msg_s *m));
45800 diff --git a/drivers/scsi/bfa/bfa_ioc.h b/drivers/scsi/bfa/bfa_ioc.h
45801 index 90814fe..4384138 100644
45802 --- a/drivers/scsi/bfa/bfa_ioc.h
45803 +++ b/drivers/scsi/bfa/bfa_ioc.h
45804 @@ -258,7 +258,7 @@ struct bfa_ioc_cbfn_s {
45805 bfa_ioc_disable_cbfn_t disable_cbfn;
45806 bfa_ioc_hbfail_cbfn_t hbfail_cbfn;
45807 bfa_ioc_reset_cbfn_t reset_cbfn;
45808 -};
45809 +} __no_const;
45810
45811 /*
45812 * IOC event notification mechanism.
45813 @@ -352,7 +352,7 @@ struct bfa_ioc_hwif_s {
45814 void (*ioc_set_alt_fwstate) (struct bfa_ioc_s *ioc,
45815 enum bfi_ioc_state fwstate);
45816 enum bfi_ioc_state (*ioc_get_alt_fwstate) (struct bfa_ioc_s *ioc);
45817 -};
45818 +} __no_const;
45819
45820 /*
45821 * Queue element to wait for room in request queue. FIFO order is
45822 diff --git a/drivers/scsi/fcoe/fcoe_sysfs.c b/drivers/scsi/fcoe/fcoe_sysfs.c
45823 index c9382d6..6619864 100644
45824 --- a/drivers/scsi/fcoe/fcoe_sysfs.c
45825 +++ b/drivers/scsi/fcoe/fcoe_sysfs.c
45826 @@ -33,8 +33,8 @@
45827 */
45828 #include "libfcoe.h"
45829
45830 -static atomic_t ctlr_num;
45831 -static atomic_t fcf_num;
45832 +static atomic_unchecked_t ctlr_num;
45833 +static atomic_unchecked_t fcf_num;
45834
45835 /*
45836 * fcoe_fcf_dev_loss_tmo: the default number of seconds that fcoe sysfs
45837 @@ -681,7 +681,7 @@ struct fcoe_ctlr_device *fcoe_ctlr_device_add(struct device *parent,
45838 if (!ctlr)
45839 goto out;
45840
45841 - ctlr->id = atomic_inc_return(&ctlr_num) - 1;
45842 + ctlr->id = atomic_inc_return_unchecked(&ctlr_num) - 1;
45843 ctlr->f = f;
45844 ctlr->mode = FIP_CONN_TYPE_FABRIC;
45845 INIT_LIST_HEAD(&ctlr->fcfs);
45846 @@ -898,7 +898,7 @@ struct fcoe_fcf_device *fcoe_fcf_device_add(struct fcoe_ctlr_device *ctlr,
45847 fcf->dev.parent = &ctlr->dev;
45848 fcf->dev.bus = &fcoe_bus_type;
45849 fcf->dev.type = &fcoe_fcf_device_type;
45850 - fcf->id = atomic_inc_return(&fcf_num) - 1;
45851 + fcf->id = atomic_inc_return_unchecked(&fcf_num) - 1;
45852 fcf->state = FCOE_FCF_STATE_UNKNOWN;
45853
45854 fcf->dev_loss_tmo = ctlr->fcf_dev_loss_tmo;
45855 @@ -934,8 +934,8 @@ int __init fcoe_sysfs_setup(void)
45856 {
45857 int error;
45858
45859 - atomic_set(&ctlr_num, 0);
45860 - atomic_set(&fcf_num, 0);
45861 + atomic_set_unchecked(&ctlr_num, 0);
45862 + atomic_set_unchecked(&fcf_num, 0);
45863
45864 error = bus_register(&fcoe_bus_type);
45865 if (error)
45866 diff --git a/drivers/scsi/hosts.c b/drivers/scsi/hosts.c
45867 index df0c3c7..b00e1d0 100644
45868 --- a/drivers/scsi/hosts.c
45869 +++ b/drivers/scsi/hosts.c
45870 @@ -42,7 +42,7 @@
45871 #include "scsi_logging.h"
45872
45873
45874 -static atomic_t scsi_host_next_hn = ATOMIC_INIT(0); /* host_no for next new host */
45875 +static atomic_unchecked_t scsi_host_next_hn = ATOMIC_INIT(0); /* host_no for next new host */
45876
45877
45878 static void scsi_host_cls_release(struct device *dev)
45879 @@ -361,7 +361,7 @@ struct Scsi_Host *scsi_host_alloc(struct scsi_host_template *sht, int privsize)
45880 * subtract one because we increment first then return, but we need to
45881 * know what the next host number was before increment
45882 */
45883 - shost->host_no = atomic_inc_return(&scsi_host_next_hn) - 1;
45884 + shost->host_no = atomic_inc_return_unchecked(&scsi_host_next_hn) - 1;
45885 shost->dma_channel = 0xff;
45886
45887 /* These three are default values which can be overridden */
45888 diff --git a/drivers/scsi/hpsa.c b/drivers/scsi/hpsa.c
45889 index 891c86b..dd1224a0 100644
45890 --- a/drivers/scsi/hpsa.c
45891 +++ b/drivers/scsi/hpsa.c
45892 @@ -578,7 +578,7 @@ static inline u32 next_command(struct ctlr_info *h, u8 q)
45893 unsigned long flags;
45894
45895 if (unlikely(!(h->transMethod & CFGTBL_Trans_Performant)))
45896 - return h->access.command_completed(h, q);
45897 + return h->access->command_completed(h, q);
45898
45899 if ((rq->head[rq->current_entry] & 1) == rq->wraparound) {
45900 a = rq->head[rq->current_entry];
45901 @@ -3444,7 +3444,7 @@ static void start_io(struct ctlr_info *h)
45902 while (!list_empty(&h->reqQ)) {
45903 c = list_entry(h->reqQ.next, struct CommandList, list);
45904 /* can't do anything if fifo is full */
45905 - if ((h->access.fifo_full(h))) {
45906 + if ((h->access->fifo_full(h))) {
45907 dev_warn(&h->pdev->dev, "fifo full\n");
45908 break;
45909 }
45910 @@ -3466,7 +3466,7 @@ static void start_io(struct ctlr_info *h)
45911
45912 /* Tell the controller execute command */
45913 spin_unlock_irqrestore(&h->lock, flags);
45914 - h->access.submit_command(h, c);
45915 + h->access->submit_command(h, c);
45916 spin_lock_irqsave(&h->lock, flags);
45917 }
45918 spin_unlock_irqrestore(&h->lock, flags);
45919 @@ -3474,17 +3474,17 @@ static void start_io(struct ctlr_info *h)
45920
45921 static inline unsigned long get_next_completion(struct ctlr_info *h, u8 q)
45922 {
45923 - return h->access.command_completed(h, q);
45924 + return h->access->command_completed(h, q);
45925 }
45926
45927 static inline bool interrupt_pending(struct ctlr_info *h)
45928 {
45929 - return h->access.intr_pending(h);
45930 + return h->access->intr_pending(h);
45931 }
45932
45933 static inline long interrupt_not_for_us(struct ctlr_info *h)
45934 {
45935 - return (h->access.intr_pending(h) == 0) ||
45936 + return (h->access->intr_pending(h) == 0) ||
45937 (h->interrupts_enabled == 0);
45938 }
45939
45940 @@ -4386,7 +4386,7 @@ static int hpsa_pci_init(struct ctlr_info *h)
45941 if (prod_index < 0)
45942 return -ENODEV;
45943 h->product_name = products[prod_index].product_name;
45944 - h->access = *(products[prod_index].access);
45945 + h->access = products[prod_index].access;
45946
45947 pci_disable_link_state(h->pdev, PCIE_LINK_STATE_L0S |
45948 PCIE_LINK_STATE_L1 | PCIE_LINK_STATE_CLKPM);
45949 @@ -4668,7 +4668,7 @@ static void controller_lockup_detected(struct ctlr_info *h)
45950
45951 assert_spin_locked(&lockup_detector_lock);
45952 remove_ctlr_from_lockup_detector_list(h);
45953 - h->access.set_intr_mask(h, HPSA_INTR_OFF);
45954 + h->access->set_intr_mask(h, HPSA_INTR_OFF);
45955 spin_lock_irqsave(&h->lock, flags);
45956 h->lockup_detected = readl(h->vaddr + SA5_SCRATCHPAD_OFFSET);
45957 spin_unlock_irqrestore(&h->lock, flags);
45958 @@ -4845,7 +4845,7 @@ reinit_after_soft_reset:
45959 }
45960
45961 /* make sure the board interrupts are off */
45962 - h->access.set_intr_mask(h, HPSA_INTR_OFF);
45963 + h->access->set_intr_mask(h, HPSA_INTR_OFF);
45964
45965 if (hpsa_request_irq(h, do_hpsa_intr_msi, do_hpsa_intr_intx))
45966 goto clean2;
45967 @@ -4879,7 +4879,7 @@ reinit_after_soft_reset:
45968 * fake ones to scoop up any residual completions.
45969 */
45970 spin_lock_irqsave(&h->lock, flags);
45971 - h->access.set_intr_mask(h, HPSA_INTR_OFF);
45972 + h->access->set_intr_mask(h, HPSA_INTR_OFF);
45973 spin_unlock_irqrestore(&h->lock, flags);
45974 free_irqs(h);
45975 rc = hpsa_request_irq(h, hpsa_msix_discard_completions,
45976 @@ -4898,9 +4898,9 @@ reinit_after_soft_reset:
45977 dev_info(&h->pdev->dev, "Board READY.\n");
45978 dev_info(&h->pdev->dev,
45979 "Waiting for stale completions to drain.\n");
45980 - h->access.set_intr_mask(h, HPSA_INTR_ON);
45981 + h->access->set_intr_mask(h, HPSA_INTR_ON);
45982 msleep(10000);
45983 - h->access.set_intr_mask(h, HPSA_INTR_OFF);
45984 + h->access->set_intr_mask(h, HPSA_INTR_OFF);
45985
45986 rc = controller_reset_failed(h->cfgtable);
45987 if (rc)
45988 @@ -4921,7 +4921,7 @@ reinit_after_soft_reset:
45989 }
45990
45991 /* Turn the interrupts on so we can service requests */
45992 - h->access.set_intr_mask(h, HPSA_INTR_ON);
45993 + h->access->set_intr_mask(h, HPSA_INTR_ON);
45994
45995 hpsa_hba_inquiry(h);
45996 hpsa_register_scsi(h); /* hook ourselves into SCSI subsystem */
45997 @@ -4976,7 +4976,7 @@ static void hpsa_shutdown(struct pci_dev *pdev)
45998 * To write all data in the battery backed cache to disks
45999 */
46000 hpsa_flush_cache(h);
46001 - h->access.set_intr_mask(h, HPSA_INTR_OFF);
46002 + h->access->set_intr_mask(h, HPSA_INTR_OFF);
46003 hpsa_free_irqs_and_disable_msix(h);
46004 }
46005
46006 @@ -5144,7 +5144,7 @@ static void hpsa_enter_performant_mode(struct ctlr_info *h, u32 use_short_tags)
46007 return;
46008 }
46009 /* Change the access methods to the performant access methods */
46010 - h->access = SA5_performant_access;
46011 + h->access = &SA5_performant_access;
46012 h->transMethod = CFGTBL_Trans_Performant;
46013 }
46014
46015 diff --git a/drivers/scsi/hpsa.h b/drivers/scsi/hpsa.h
46016 index bc85e72..ae04a39 100644
46017 --- a/drivers/scsi/hpsa.h
46018 +++ b/drivers/scsi/hpsa.h
46019 @@ -79,7 +79,7 @@ struct ctlr_info {
46020 unsigned int msix_vector;
46021 unsigned int msi_vector;
46022 int intr_mode; /* either PERF_MODE_INT or SIMPLE_MODE_INT */
46023 - struct access_method access;
46024 + struct access_method *access;
46025
46026 /* queue and queue Info */
46027 struct list_head reqQ;
46028 diff --git a/drivers/scsi/libfc/fc_exch.c b/drivers/scsi/libfc/fc_exch.c
46029 index 5879929..32b241d 100644
46030 --- a/drivers/scsi/libfc/fc_exch.c
46031 +++ b/drivers/scsi/libfc/fc_exch.c
46032 @@ -100,12 +100,12 @@ struct fc_exch_mgr {
46033 u16 pool_max_index;
46034
46035 struct {
46036 - atomic_t no_free_exch;
46037 - atomic_t no_free_exch_xid;
46038 - atomic_t xid_not_found;
46039 - atomic_t xid_busy;
46040 - atomic_t seq_not_found;
46041 - atomic_t non_bls_resp;
46042 + atomic_unchecked_t no_free_exch;
46043 + atomic_unchecked_t no_free_exch_xid;
46044 + atomic_unchecked_t xid_not_found;
46045 + atomic_unchecked_t xid_busy;
46046 + atomic_unchecked_t seq_not_found;
46047 + atomic_unchecked_t non_bls_resp;
46048 } stats;
46049 };
46050
46051 @@ -736,7 +736,7 @@ static struct fc_exch *fc_exch_em_alloc(struct fc_lport *lport,
46052 /* allocate memory for exchange */
46053 ep = mempool_alloc(mp->ep_pool, GFP_ATOMIC);
46054 if (!ep) {
46055 - atomic_inc(&mp->stats.no_free_exch);
46056 + atomic_inc_unchecked(&mp->stats.no_free_exch);
46057 goto out;
46058 }
46059 memset(ep, 0, sizeof(*ep));
46060 @@ -797,7 +797,7 @@ out:
46061 return ep;
46062 err:
46063 spin_unlock_bh(&pool->lock);
46064 - atomic_inc(&mp->stats.no_free_exch_xid);
46065 + atomic_inc_unchecked(&mp->stats.no_free_exch_xid);
46066 mempool_free(ep, mp->ep_pool);
46067 return NULL;
46068 }
46069 @@ -940,7 +940,7 @@ static enum fc_pf_rjt_reason fc_seq_lookup_recip(struct fc_lport *lport,
46070 xid = ntohs(fh->fh_ox_id); /* we originated exch */
46071 ep = fc_exch_find(mp, xid);
46072 if (!ep) {
46073 - atomic_inc(&mp->stats.xid_not_found);
46074 + atomic_inc_unchecked(&mp->stats.xid_not_found);
46075 reject = FC_RJT_OX_ID;
46076 goto out;
46077 }
46078 @@ -970,7 +970,7 @@ static enum fc_pf_rjt_reason fc_seq_lookup_recip(struct fc_lport *lport,
46079 ep = fc_exch_find(mp, xid);
46080 if ((f_ctl & FC_FC_FIRST_SEQ) && fc_sof_is_init(fr_sof(fp))) {
46081 if (ep) {
46082 - atomic_inc(&mp->stats.xid_busy);
46083 + atomic_inc_unchecked(&mp->stats.xid_busy);
46084 reject = FC_RJT_RX_ID;
46085 goto rel;
46086 }
46087 @@ -981,7 +981,7 @@ static enum fc_pf_rjt_reason fc_seq_lookup_recip(struct fc_lport *lport,
46088 }
46089 xid = ep->xid; /* get our XID */
46090 } else if (!ep) {
46091 - atomic_inc(&mp->stats.xid_not_found);
46092 + atomic_inc_unchecked(&mp->stats.xid_not_found);
46093 reject = FC_RJT_RX_ID; /* XID not found */
46094 goto out;
46095 }
46096 @@ -998,7 +998,7 @@ static enum fc_pf_rjt_reason fc_seq_lookup_recip(struct fc_lport *lport,
46097 } else {
46098 sp = &ep->seq;
46099 if (sp->id != fh->fh_seq_id) {
46100 - atomic_inc(&mp->stats.seq_not_found);
46101 + atomic_inc_unchecked(&mp->stats.seq_not_found);
46102 if (f_ctl & FC_FC_END_SEQ) {
46103 /*
46104 * Update sequence_id based on incoming last
46105 @@ -1448,22 +1448,22 @@ static void fc_exch_recv_seq_resp(struct fc_exch_mgr *mp, struct fc_frame *fp)
46106
46107 ep = fc_exch_find(mp, ntohs(fh->fh_ox_id));
46108 if (!ep) {
46109 - atomic_inc(&mp->stats.xid_not_found);
46110 + atomic_inc_unchecked(&mp->stats.xid_not_found);
46111 goto out;
46112 }
46113 if (ep->esb_stat & ESB_ST_COMPLETE) {
46114 - atomic_inc(&mp->stats.xid_not_found);
46115 + atomic_inc_unchecked(&mp->stats.xid_not_found);
46116 goto rel;
46117 }
46118 if (ep->rxid == FC_XID_UNKNOWN)
46119 ep->rxid = ntohs(fh->fh_rx_id);
46120 if (ep->sid != 0 && ep->sid != ntoh24(fh->fh_d_id)) {
46121 - atomic_inc(&mp->stats.xid_not_found);
46122 + atomic_inc_unchecked(&mp->stats.xid_not_found);
46123 goto rel;
46124 }
46125 if (ep->did != ntoh24(fh->fh_s_id) &&
46126 ep->did != FC_FID_FLOGI) {
46127 - atomic_inc(&mp->stats.xid_not_found);
46128 + atomic_inc_unchecked(&mp->stats.xid_not_found);
46129 goto rel;
46130 }
46131 sof = fr_sof(fp);
46132 @@ -1472,7 +1472,7 @@ static void fc_exch_recv_seq_resp(struct fc_exch_mgr *mp, struct fc_frame *fp)
46133 sp->ssb_stat |= SSB_ST_RESP;
46134 sp->id = fh->fh_seq_id;
46135 } else if (sp->id != fh->fh_seq_id) {
46136 - atomic_inc(&mp->stats.seq_not_found);
46137 + atomic_inc_unchecked(&mp->stats.seq_not_found);
46138 goto rel;
46139 }
46140
46141 @@ -1536,9 +1536,9 @@ static void fc_exch_recv_resp(struct fc_exch_mgr *mp, struct fc_frame *fp)
46142 sp = fc_seq_lookup_orig(mp, fp); /* doesn't hold sequence */
46143
46144 if (!sp)
46145 - atomic_inc(&mp->stats.xid_not_found);
46146 + atomic_inc_unchecked(&mp->stats.xid_not_found);
46147 else
46148 - atomic_inc(&mp->stats.non_bls_resp);
46149 + atomic_inc_unchecked(&mp->stats.non_bls_resp);
46150
46151 fc_frame_free(fp);
46152 }
46153 @@ -2185,13 +2185,13 @@ void fc_exch_update_stats(struct fc_lport *lport)
46154
46155 list_for_each_entry(ema, &lport->ema_list, ema_list) {
46156 mp = ema->mp;
46157 - st->fc_no_free_exch += atomic_read(&mp->stats.no_free_exch);
46158 + st->fc_no_free_exch += atomic_read_unchecked(&mp->stats.no_free_exch);
46159 st->fc_no_free_exch_xid +=
46160 - atomic_read(&mp->stats.no_free_exch_xid);
46161 - st->fc_xid_not_found += atomic_read(&mp->stats.xid_not_found);
46162 - st->fc_xid_busy += atomic_read(&mp->stats.xid_busy);
46163 - st->fc_seq_not_found += atomic_read(&mp->stats.seq_not_found);
46164 - st->fc_non_bls_resp += atomic_read(&mp->stats.non_bls_resp);
46165 + atomic_read_unchecked(&mp->stats.no_free_exch_xid);
46166 + st->fc_xid_not_found += atomic_read_unchecked(&mp->stats.xid_not_found);
46167 + st->fc_xid_busy += atomic_read_unchecked(&mp->stats.xid_busy);
46168 + st->fc_seq_not_found += atomic_read_unchecked(&mp->stats.seq_not_found);
46169 + st->fc_non_bls_resp += atomic_read_unchecked(&mp->stats.non_bls_resp);
46170 }
46171 }
46172 EXPORT_SYMBOL(fc_exch_update_stats);
46173 diff --git a/drivers/scsi/libsas/sas_ata.c b/drivers/scsi/libsas/sas_ata.c
46174 index 161c98e..6d563b3 100644
46175 --- a/drivers/scsi/libsas/sas_ata.c
46176 +++ b/drivers/scsi/libsas/sas_ata.c
46177 @@ -554,7 +554,7 @@ static struct ata_port_operations sas_sata_ops = {
46178 .postreset = ata_std_postreset,
46179 .error_handler = ata_std_error_handler,
46180 .post_internal_cmd = sas_ata_post_internal,
46181 - .qc_defer = ata_std_qc_defer,
46182 + .qc_defer = ata_std_qc_defer,
46183 .qc_prep = ata_noop_qc_prep,
46184 .qc_issue = sas_ata_qc_issue,
46185 .qc_fill_rtf = sas_ata_qc_fill_rtf,
46186 diff --git a/drivers/scsi/lpfc/lpfc.h b/drivers/scsi/lpfc/lpfc.h
46187 index 4e1b75c..0bbdfa9 100644
46188 --- a/drivers/scsi/lpfc/lpfc.h
46189 +++ b/drivers/scsi/lpfc/lpfc.h
46190 @@ -432,7 +432,7 @@ struct lpfc_vport {
46191 struct dentry *debug_nodelist;
46192 struct dentry *vport_debugfs_root;
46193 struct lpfc_debugfs_trc *disc_trc;
46194 - atomic_t disc_trc_cnt;
46195 + atomic_unchecked_t disc_trc_cnt;
46196 #endif
46197 uint8_t stat_data_enabled;
46198 uint8_t stat_data_blocked;
46199 @@ -865,8 +865,8 @@ struct lpfc_hba {
46200 struct timer_list fabric_block_timer;
46201 unsigned long bit_flags;
46202 #define FABRIC_COMANDS_BLOCKED 0
46203 - atomic_t num_rsrc_err;
46204 - atomic_t num_cmd_success;
46205 + atomic_unchecked_t num_rsrc_err;
46206 + atomic_unchecked_t num_cmd_success;
46207 unsigned long last_rsrc_error_time;
46208 unsigned long last_ramp_down_time;
46209 unsigned long last_ramp_up_time;
46210 @@ -902,7 +902,7 @@ struct lpfc_hba {
46211
46212 struct dentry *debug_slow_ring_trc;
46213 struct lpfc_debugfs_trc *slow_ring_trc;
46214 - atomic_t slow_ring_trc_cnt;
46215 + atomic_unchecked_t slow_ring_trc_cnt;
46216 /* iDiag debugfs sub-directory */
46217 struct dentry *idiag_root;
46218 struct dentry *idiag_pci_cfg;
46219 diff --git a/drivers/scsi/lpfc/lpfc_debugfs.c b/drivers/scsi/lpfc/lpfc_debugfs.c
46220 index 60084e6..0e2e700 100644
46221 --- a/drivers/scsi/lpfc/lpfc_debugfs.c
46222 +++ b/drivers/scsi/lpfc/lpfc_debugfs.c
46223 @@ -106,7 +106,7 @@ MODULE_PARM_DESC(lpfc_debugfs_mask_disc_trc,
46224
46225 #include <linux/debugfs.h>
46226
46227 -static atomic_t lpfc_debugfs_seq_trc_cnt = ATOMIC_INIT(0);
46228 +static atomic_unchecked_t lpfc_debugfs_seq_trc_cnt = ATOMIC_INIT(0);
46229 static unsigned long lpfc_debugfs_start_time = 0L;
46230
46231 /* iDiag */
46232 @@ -147,7 +147,7 @@ lpfc_debugfs_disc_trc_data(struct lpfc_vport *vport, char *buf, int size)
46233 lpfc_debugfs_enable = 0;
46234
46235 len = 0;
46236 - index = (atomic_read(&vport->disc_trc_cnt) + 1) &
46237 + index = (atomic_read_unchecked(&vport->disc_trc_cnt) + 1) &
46238 (lpfc_debugfs_max_disc_trc - 1);
46239 for (i = index; i < lpfc_debugfs_max_disc_trc; i++) {
46240 dtp = vport->disc_trc + i;
46241 @@ -213,7 +213,7 @@ lpfc_debugfs_slow_ring_trc_data(struct lpfc_hba *phba, char *buf, int size)
46242 lpfc_debugfs_enable = 0;
46243
46244 len = 0;
46245 - index = (atomic_read(&phba->slow_ring_trc_cnt) + 1) &
46246 + index = (atomic_read_unchecked(&phba->slow_ring_trc_cnt) + 1) &
46247 (lpfc_debugfs_max_slow_ring_trc - 1);
46248 for (i = index; i < lpfc_debugfs_max_slow_ring_trc; i++) {
46249 dtp = phba->slow_ring_trc + i;
46250 @@ -646,14 +646,14 @@ lpfc_debugfs_disc_trc(struct lpfc_vport *vport, int mask, char *fmt,
46251 !vport || !vport->disc_trc)
46252 return;
46253
46254 - index = atomic_inc_return(&vport->disc_trc_cnt) &
46255 + index = atomic_inc_return_unchecked(&vport->disc_trc_cnt) &
46256 (lpfc_debugfs_max_disc_trc - 1);
46257 dtp = vport->disc_trc + index;
46258 dtp->fmt = fmt;
46259 dtp->data1 = data1;
46260 dtp->data2 = data2;
46261 dtp->data3 = data3;
46262 - dtp->seq_cnt = atomic_inc_return(&lpfc_debugfs_seq_trc_cnt);
46263 + dtp->seq_cnt = atomic_inc_return_unchecked(&lpfc_debugfs_seq_trc_cnt);
46264 dtp->jif = jiffies;
46265 #endif
46266 return;
46267 @@ -684,14 +684,14 @@ lpfc_debugfs_slow_ring_trc(struct lpfc_hba *phba, char *fmt,
46268 !phba || !phba->slow_ring_trc)
46269 return;
46270
46271 - index = atomic_inc_return(&phba->slow_ring_trc_cnt) &
46272 + index = atomic_inc_return_unchecked(&phba->slow_ring_trc_cnt) &
46273 (lpfc_debugfs_max_slow_ring_trc - 1);
46274 dtp = phba->slow_ring_trc + index;
46275 dtp->fmt = fmt;
46276 dtp->data1 = data1;
46277 dtp->data2 = data2;
46278 dtp->data3 = data3;
46279 - dtp->seq_cnt = atomic_inc_return(&lpfc_debugfs_seq_trc_cnt);
46280 + dtp->seq_cnt = atomic_inc_return_unchecked(&lpfc_debugfs_seq_trc_cnt);
46281 dtp->jif = jiffies;
46282 #endif
46283 return;
46284 @@ -4168,7 +4168,7 @@ lpfc_debugfs_initialize(struct lpfc_vport *vport)
46285 "slow_ring buffer\n");
46286 goto debug_failed;
46287 }
46288 - atomic_set(&phba->slow_ring_trc_cnt, 0);
46289 + atomic_set_unchecked(&phba->slow_ring_trc_cnt, 0);
46290 memset(phba->slow_ring_trc, 0,
46291 (sizeof(struct lpfc_debugfs_trc) *
46292 lpfc_debugfs_max_slow_ring_trc));
46293 @@ -4214,7 +4214,7 @@ lpfc_debugfs_initialize(struct lpfc_vport *vport)
46294 "buffer\n");
46295 goto debug_failed;
46296 }
46297 - atomic_set(&vport->disc_trc_cnt, 0);
46298 + atomic_set_unchecked(&vport->disc_trc_cnt, 0);
46299
46300 snprintf(name, sizeof(name), "discovery_trace");
46301 vport->debug_disc_trc =
46302 diff --git a/drivers/scsi/lpfc/lpfc_init.c b/drivers/scsi/lpfc/lpfc_init.c
46303 index 647f5bf..d0068b9 100644
46304 --- a/drivers/scsi/lpfc/lpfc_init.c
46305 +++ b/drivers/scsi/lpfc/lpfc_init.c
46306 @@ -10952,8 +10952,10 @@ lpfc_init(void)
46307 "misc_register returned with status %d", error);
46308
46309 if (lpfc_enable_npiv) {
46310 - lpfc_transport_functions.vport_create = lpfc_vport_create;
46311 - lpfc_transport_functions.vport_delete = lpfc_vport_delete;
46312 + pax_open_kernel();
46313 + *(void **)&lpfc_transport_functions.vport_create = lpfc_vport_create;
46314 + *(void **)&lpfc_transport_functions.vport_delete = lpfc_vport_delete;
46315 + pax_close_kernel();
46316 }
46317 lpfc_transport_template =
46318 fc_attach_transport(&lpfc_transport_functions);
46319 diff --git a/drivers/scsi/lpfc/lpfc_scsi.c b/drivers/scsi/lpfc/lpfc_scsi.c
46320 index c913e8c..d34a119 100644
46321 --- a/drivers/scsi/lpfc/lpfc_scsi.c
46322 +++ b/drivers/scsi/lpfc/lpfc_scsi.c
46323 @@ -353,7 +353,7 @@ lpfc_rampdown_queue_depth(struct lpfc_hba *phba)
46324 uint32_t evt_posted;
46325
46326 spin_lock_irqsave(&phba->hbalock, flags);
46327 - atomic_inc(&phba->num_rsrc_err);
46328 + atomic_inc_unchecked(&phba->num_rsrc_err);
46329 phba->last_rsrc_error_time = jiffies;
46330
46331 if ((phba->last_ramp_down_time + QUEUE_RAMP_DOWN_INTERVAL) > jiffies) {
46332 @@ -394,7 +394,7 @@ lpfc_rampup_queue_depth(struct lpfc_vport *vport,
46333 unsigned long flags;
46334 struct lpfc_hba *phba = vport->phba;
46335 uint32_t evt_posted;
46336 - atomic_inc(&phba->num_cmd_success);
46337 + atomic_inc_unchecked(&phba->num_cmd_success);
46338
46339 if (vport->cfg_lun_queue_depth <= queue_depth)
46340 return;
46341 @@ -438,8 +438,8 @@ lpfc_ramp_down_queue_handler(struct lpfc_hba *phba)
46342 unsigned long num_rsrc_err, num_cmd_success;
46343 int i;
46344
46345 - num_rsrc_err = atomic_read(&phba->num_rsrc_err);
46346 - num_cmd_success = atomic_read(&phba->num_cmd_success);
46347 + num_rsrc_err = atomic_read_unchecked(&phba->num_rsrc_err);
46348 + num_cmd_success = atomic_read_unchecked(&phba->num_cmd_success);
46349
46350 /*
46351 * The error and success command counters are global per
46352 @@ -467,8 +467,8 @@ lpfc_ramp_down_queue_handler(struct lpfc_hba *phba)
46353 }
46354 }
46355 lpfc_destroy_vport_work_array(phba, vports);
46356 - atomic_set(&phba->num_rsrc_err, 0);
46357 - atomic_set(&phba->num_cmd_success, 0);
46358 + atomic_set_unchecked(&phba->num_rsrc_err, 0);
46359 + atomic_set_unchecked(&phba->num_cmd_success, 0);
46360 }
46361
46362 /**
46363 @@ -502,8 +502,8 @@ lpfc_ramp_up_queue_handler(struct lpfc_hba *phba)
46364 }
46365 }
46366 lpfc_destroy_vport_work_array(phba, vports);
46367 - atomic_set(&phba->num_rsrc_err, 0);
46368 - atomic_set(&phba->num_cmd_success, 0);
46369 + atomic_set_unchecked(&phba->num_rsrc_err, 0);
46370 + atomic_set_unchecked(&phba->num_cmd_success, 0);
46371 }
46372
46373 /**
46374 diff --git a/drivers/scsi/mpt2sas/mpt2sas_scsih.c b/drivers/scsi/mpt2sas/mpt2sas_scsih.c
46375 index 7f0af4f..193ac3e 100644
46376 --- a/drivers/scsi/mpt2sas/mpt2sas_scsih.c
46377 +++ b/drivers/scsi/mpt2sas/mpt2sas_scsih.c
46378 @@ -1557,7 +1557,7 @@ _scsih_get_resync(struct device *dev)
46379 {
46380 struct scsi_device *sdev = to_scsi_device(dev);
46381 struct MPT2SAS_ADAPTER *ioc = shost_priv(sdev->host);
46382 - static struct _raid_device *raid_device;
46383 + struct _raid_device *raid_device;
46384 unsigned long flags;
46385 Mpi2RaidVolPage0_t vol_pg0;
46386 Mpi2ConfigReply_t mpi_reply;
46387 @@ -1609,7 +1609,7 @@ _scsih_get_state(struct device *dev)
46388 {
46389 struct scsi_device *sdev = to_scsi_device(dev);
46390 struct MPT2SAS_ADAPTER *ioc = shost_priv(sdev->host);
46391 - static struct _raid_device *raid_device;
46392 + struct _raid_device *raid_device;
46393 unsigned long flags;
46394 Mpi2RaidVolPage0_t vol_pg0;
46395 Mpi2ConfigReply_t mpi_reply;
46396 @@ -6637,7 +6637,7 @@ _scsih_sas_ir_operation_status_event(struct MPT2SAS_ADAPTER *ioc,
46397 struct fw_event_work *fw_event)
46398 {
46399 Mpi2EventDataIrOperationStatus_t *event_data = fw_event->event_data;
46400 - static struct _raid_device *raid_device;
46401 + struct _raid_device *raid_device;
46402 unsigned long flags;
46403 u16 handle;
46404
46405 @@ -7108,7 +7108,7 @@ _scsih_scan_for_devices_after_reset(struct MPT2SAS_ADAPTER *ioc)
46406 u64 sas_address;
46407 struct _sas_device *sas_device;
46408 struct _sas_node *expander_device;
46409 - static struct _raid_device *raid_device;
46410 + struct _raid_device *raid_device;
46411 u8 retry_count;
46412 unsigned long flags;
46413
46414 diff --git a/drivers/scsi/pmcraid.c b/drivers/scsi/pmcraid.c
46415 index 1eb7b028..b2a6080 100644
46416 --- a/drivers/scsi/pmcraid.c
46417 +++ b/drivers/scsi/pmcraid.c
46418 @@ -200,8 +200,8 @@ static int pmcraid_slave_alloc(struct scsi_device *scsi_dev)
46419 res->scsi_dev = scsi_dev;
46420 scsi_dev->hostdata = res;
46421 res->change_detected = 0;
46422 - atomic_set(&res->read_failures, 0);
46423 - atomic_set(&res->write_failures, 0);
46424 + atomic_set_unchecked(&res->read_failures, 0);
46425 + atomic_set_unchecked(&res->write_failures, 0);
46426 rc = 0;
46427 }
46428 spin_unlock_irqrestore(&pinstance->resource_lock, lock_flags);
46429 @@ -2676,9 +2676,9 @@ static int pmcraid_error_handler(struct pmcraid_cmd *cmd)
46430
46431 /* If this was a SCSI read/write command keep count of errors */
46432 if (SCSI_CMD_TYPE(scsi_cmd->cmnd[0]) == SCSI_READ_CMD)
46433 - atomic_inc(&res->read_failures);
46434 + atomic_inc_unchecked(&res->read_failures);
46435 else if (SCSI_CMD_TYPE(scsi_cmd->cmnd[0]) == SCSI_WRITE_CMD)
46436 - atomic_inc(&res->write_failures);
46437 + atomic_inc_unchecked(&res->write_failures);
46438
46439 if (!RES_IS_GSCSI(res->cfg_entry) &&
46440 masked_ioasc != PMCRAID_IOASC_HW_DEVICE_BUS_STATUS_ERROR) {
46441 @@ -3534,7 +3534,7 @@ static int pmcraid_queuecommand_lck(
46442 * block of scsi_cmd which is re-used (e.g. cancel/abort), which uses
46443 * hrrq_id assigned here in queuecommand
46444 */
46445 - ioarcb->hrrq_id = atomic_add_return(1, &(pinstance->last_message_id)) %
46446 + ioarcb->hrrq_id = atomic_add_return_unchecked(1, &(pinstance->last_message_id)) %
46447 pinstance->num_hrrq;
46448 cmd->cmd_done = pmcraid_io_done;
46449
46450 @@ -3846,7 +3846,7 @@ static long pmcraid_ioctl_passthrough(
46451 * block of scsi_cmd which is re-used (e.g. cancel/abort), which uses
46452 * hrrq_id assigned here in queuecommand
46453 */
46454 - ioarcb->hrrq_id = atomic_add_return(1, &(pinstance->last_message_id)) %
46455 + ioarcb->hrrq_id = atomic_add_return_unchecked(1, &(pinstance->last_message_id)) %
46456 pinstance->num_hrrq;
46457
46458 if (request_size) {
46459 @@ -4483,7 +4483,7 @@ static void pmcraid_worker_function(struct work_struct *workp)
46460
46461 pinstance = container_of(workp, struct pmcraid_instance, worker_q);
46462 /* add resources only after host is added into system */
46463 - if (!atomic_read(&pinstance->expose_resources))
46464 + if (!atomic_read_unchecked(&pinstance->expose_resources))
46465 return;
46466
46467 fw_version = be16_to_cpu(pinstance->inq_data->fw_version);
46468 @@ -5310,8 +5310,8 @@ static int pmcraid_init_instance(struct pci_dev *pdev, struct Scsi_Host *host,
46469 init_waitqueue_head(&pinstance->reset_wait_q);
46470
46471 atomic_set(&pinstance->outstanding_cmds, 0);
46472 - atomic_set(&pinstance->last_message_id, 0);
46473 - atomic_set(&pinstance->expose_resources, 0);
46474 + atomic_set_unchecked(&pinstance->last_message_id, 0);
46475 + atomic_set_unchecked(&pinstance->expose_resources, 0);
46476
46477 INIT_LIST_HEAD(&pinstance->free_res_q);
46478 INIT_LIST_HEAD(&pinstance->used_res_q);
46479 @@ -6024,7 +6024,7 @@ static int pmcraid_probe(struct pci_dev *pdev,
46480 /* Schedule worker thread to handle CCN and take care of adding and
46481 * removing devices to OS
46482 */
46483 - atomic_set(&pinstance->expose_resources, 1);
46484 + atomic_set_unchecked(&pinstance->expose_resources, 1);
46485 schedule_work(&pinstance->worker_q);
46486 return rc;
46487
46488 diff --git a/drivers/scsi/pmcraid.h b/drivers/scsi/pmcraid.h
46489 index e1d150f..6c6df44 100644
46490 --- a/drivers/scsi/pmcraid.h
46491 +++ b/drivers/scsi/pmcraid.h
46492 @@ -748,7 +748,7 @@ struct pmcraid_instance {
46493 struct pmcraid_isr_param hrrq_vector[PMCRAID_NUM_MSIX_VECTORS];
46494
46495 /* Message id as filled in last fired IOARCB, used to identify HRRQ */
46496 - atomic_t last_message_id;
46497 + atomic_unchecked_t last_message_id;
46498
46499 /* configuration table */
46500 struct pmcraid_config_table *cfg_table;
46501 @@ -777,7 +777,7 @@ struct pmcraid_instance {
46502 atomic_t outstanding_cmds;
46503
46504 /* should add/delete resources to mid-layer now ?*/
46505 - atomic_t expose_resources;
46506 + atomic_unchecked_t expose_resources;
46507
46508
46509
46510 @@ -813,8 +813,8 @@ struct pmcraid_resource_entry {
46511 struct pmcraid_config_table_entry_ext cfg_entry_ext;
46512 };
46513 struct scsi_device *scsi_dev; /* Link scsi_device structure */
46514 - atomic_t read_failures; /* count of failed READ commands */
46515 - atomic_t write_failures; /* count of failed WRITE commands */
46516 + atomic_unchecked_t read_failures; /* count of failed READ commands */
46517 + atomic_unchecked_t write_failures; /* count of failed WRITE commands */
46518
46519 /* To indicate add/delete/modify during CCN */
46520 u8 change_detected;
46521 diff --git a/drivers/scsi/qla2xxx/qla_attr.c b/drivers/scsi/qla2xxx/qla_attr.c
46522 index 5f174b8..98d32b0 100644
46523 --- a/drivers/scsi/qla2xxx/qla_attr.c
46524 +++ b/drivers/scsi/qla2xxx/qla_attr.c
46525 @@ -2040,7 +2040,7 @@ qla24xx_vport_disable(struct fc_vport *fc_vport, bool disable)
46526 return 0;
46527 }
46528
46529 -struct fc_function_template qla2xxx_transport_functions = {
46530 +fc_function_template_no_const qla2xxx_transport_functions = {
46531
46532 .show_host_node_name = 1,
46533 .show_host_port_name = 1,
46534 @@ -2088,7 +2088,7 @@ struct fc_function_template qla2xxx_transport_functions = {
46535 .bsg_timeout = qla24xx_bsg_timeout,
46536 };
46537
46538 -struct fc_function_template qla2xxx_transport_vport_functions = {
46539 +fc_function_template_no_const qla2xxx_transport_vport_functions = {
46540
46541 .show_host_node_name = 1,
46542 .show_host_port_name = 1,
46543 diff --git a/drivers/scsi/qla2xxx/qla_gbl.h b/drivers/scsi/qla2xxx/qla_gbl.h
46544 index 4446bf5..9a3574d 100644
46545 --- a/drivers/scsi/qla2xxx/qla_gbl.h
46546 +++ b/drivers/scsi/qla2xxx/qla_gbl.h
46547 @@ -538,8 +538,8 @@ extern void qla2x00_get_sym_node_name(scsi_qla_host_t *, uint8_t *);
46548 struct device_attribute;
46549 extern struct device_attribute *qla2x00_host_attrs[];
46550 struct fc_function_template;
46551 -extern struct fc_function_template qla2xxx_transport_functions;
46552 -extern struct fc_function_template qla2xxx_transport_vport_functions;
46553 +extern fc_function_template_no_const qla2xxx_transport_functions;
46554 +extern fc_function_template_no_const qla2xxx_transport_vport_functions;
46555 extern void qla2x00_alloc_sysfs_attr(scsi_qla_host_t *);
46556 extern void qla2x00_free_sysfs_attr(scsi_qla_host_t *);
46557 extern void qla2x00_init_host_attr(scsi_qla_host_t *);
46558 diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c
46559 index 9f01bbb..5e1dcee 100644
46560 --- a/drivers/scsi/qla2xxx/qla_os.c
46561 +++ b/drivers/scsi/qla2xxx/qla_os.c
46562 @@ -1572,8 +1572,10 @@ qla2x00_config_dma_addressing(struct qla_hw_data *ha)
46563 !pci_set_consistent_dma_mask(ha->pdev, DMA_BIT_MASK(64))) {
46564 /* Ok, a 64bit DMA mask is applicable. */
46565 ha->flags.enable_64bit_addressing = 1;
46566 - ha->isp_ops->calc_req_entries = qla2x00_calc_iocbs_64;
46567 - ha->isp_ops->build_iocbs = qla2x00_build_scsi_iocbs_64;
46568 + pax_open_kernel();
46569 + *(void **)&ha->isp_ops->calc_req_entries = qla2x00_calc_iocbs_64;
46570 + *(void **)&ha->isp_ops->build_iocbs = qla2x00_build_scsi_iocbs_64;
46571 + pax_close_kernel();
46572 return;
46573 }
46574 }
46575 diff --git a/drivers/scsi/qla4xxx/ql4_def.h b/drivers/scsi/qla4xxx/ql4_def.h
46576 index 41327d4..feb03d479 100644
46577 --- a/drivers/scsi/qla4xxx/ql4_def.h
46578 +++ b/drivers/scsi/qla4xxx/ql4_def.h
46579 @@ -296,7 +296,7 @@ struct ddb_entry {
46580 * (4000 only) */
46581 atomic_t relogin_timer; /* Max Time to wait for
46582 * relogin to complete */
46583 - atomic_t relogin_retry_count; /* Num of times relogin has been
46584 + atomic_unchecked_t relogin_retry_count; /* Num of times relogin has been
46585 * retried */
46586 uint32_t default_time2wait; /* Default Min time between
46587 * relogins (+aens) */
46588 diff --git a/drivers/scsi/qla4xxx/ql4_os.c b/drivers/scsi/qla4xxx/ql4_os.c
46589 index f8a0a26..ec03cee 100644
46590 --- a/drivers/scsi/qla4xxx/ql4_os.c
46591 +++ b/drivers/scsi/qla4xxx/ql4_os.c
46592 @@ -3066,12 +3066,12 @@ static void qla4xxx_check_relogin_flash_ddb(struct iscsi_cls_session *cls_sess)
46593 */
46594 if (!iscsi_is_session_online(cls_sess)) {
46595 /* Reset retry relogin timer */
46596 - atomic_inc(&ddb_entry->relogin_retry_count);
46597 + atomic_inc_unchecked(&ddb_entry->relogin_retry_count);
46598 DEBUG2(ql4_printk(KERN_INFO, ha,
46599 "%s: index[%d] relogin timed out-retrying"
46600 " relogin (%d), retry (%d)\n", __func__,
46601 ddb_entry->fw_ddb_index,
46602 - atomic_read(&ddb_entry->relogin_retry_count),
46603 + atomic_read_unchecked(&ddb_entry->relogin_retry_count),
46604 ddb_entry->default_time2wait + 4));
46605 set_bit(DPC_RELOGIN_DEVICE, &ha->dpc_flags);
46606 atomic_set(&ddb_entry->retry_relogin_timer,
46607 @@ -5209,7 +5209,7 @@ static void qla4xxx_setup_flash_ddb_entry(struct scsi_qla_host *ha,
46608
46609 atomic_set(&ddb_entry->retry_relogin_timer, INVALID_ENTRY);
46610 atomic_set(&ddb_entry->relogin_timer, 0);
46611 - atomic_set(&ddb_entry->relogin_retry_count, 0);
46612 + atomic_set_unchecked(&ddb_entry->relogin_retry_count, 0);
46613 def_timeout = le16_to_cpu(ddb_entry->fw_ddb_entry.def_timeout);
46614 ddb_entry->default_relogin_timeout =
46615 (def_timeout > LOGIN_TOV) && (def_timeout < LOGIN_TOV * 10) ?
46616 diff --git a/drivers/scsi/scsi.c b/drivers/scsi/scsi.c
46617 index eaa808e..95f8841 100644
46618 --- a/drivers/scsi/scsi.c
46619 +++ b/drivers/scsi/scsi.c
46620 @@ -661,7 +661,7 @@ int scsi_dispatch_cmd(struct scsi_cmnd *cmd)
46621 unsigned long timeout;
46622 int rtn = 0;
46623
46624 - atomic_inc(&cmd->device->iorequest_cnt);
46625 + atomic_inc_unchecked(&cmd->device->iorequest_cnt);
46626
46627 /* check if the device is still usable */
46628 if (unlikely(cmd->device->sdev_state == SDEV_DEL)) {
46629 diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
46630 index d1549b7..2f60767 100644
46631 --- a/drivers/scsi/scsi_lib.c
46632 +++ b/drivers/scsi/scsi_lib.c
46633 @@ -1474,7 +1474,7 @@ static void scsi_kill_request(struct request *req, struct request_queue *q)
46634 shost = sdev->host;
46635 scsi_init_cmd_errh(cmd);
46636 cmd->result = DID_NO_CONNECT << 16;
46637 - atomic_inc(&cmd->device->iorequest_cnt);
46638 + atomic_inc_unchecked(&cmd->device->iorequest_cnt);
46639
46640 /*
46641 * SCSI request completion path will do scsi_device_unbusy(),
46642 @@ -1500,9 +1500,9 @@ static void scsi_softirq_done(struct request *rq)
46643
46644 INIT_LIST_HEAD(&cmd->eh_entry);
46645
46646 - atomic_inc(&cmd->device->iodone_cnt);
46647 + atomic_inc_unchecked(&cmd->device->iodone_cnt);
46648 if (cmd->result)
46649 - atomic_inc(&cmd->device->ioerr_cnt);
46650 + atomic_inc_unchecked(&cmd->device->ioerr_cnt);
46651
46652 disposition = scsi_decide_disposition(cmd);
46653 if (disposition != SUCCESS &&
46654 diff --git a/drivers/scsi/scsi_sysfs.c b/drivers/scsi/scsi_sysfs.c
46655 index 40c6394..62356c2 100644
46656 --- a/drivers/scsi/scsi_sysfs.c
46657 +++ b/drivers/scsi/scsi_sysfs.c
46658 @@ -687,7 +687,7 @@ show_iostat_##field(struct device *dev, struct device_attribute *attr, \
46659 char *buf) \
46660 { \
46661 struct scsi_device *sdev = to_scsi_device(dev); \
46662 - unsigned long long count = atomic_read(&sdev->field); \
46663 + unsigned long long count = atomic_read_unchecked(&sdev->field); \
46664 return snprintf(buf, 20, "0x%llx\n", count); \
46665 } \
46666 static DEVICE_ATTR(field, S_IRUGO, show_iostat_##field, NULL)
46667 diff --git a/drivers/scsi/scsi_tgt_lib.c b/drivers/scsi/scsi_tgt_lib.c
46668 index 84a1fdf..693b0d6 100644
46669 --- a/drivers/scsi/scsi_tgt_lib.c
46670 +++ b/drivers/scsi/scsi_tgt_lib.c
46671 @@ -362,7 +362,7 @@ static int scsi_map_user_pages(struct scsi_tgt_cmd *tcmd, struct scsi_cmnd *cmd,
46672 int err;
46673
46674 dprintk("%lx %u\n", uaddr, len);
46675 - err = blk_rq_map_user(q, rq, NULL, (void *)uaddr, len, GFP_KERNEL);
46676 + err = blk_rq_map_user(q, rq, NULL, (void __user *)uaddr, len, GFP_KERNEL);
46677 if (err) {
46678 /*
46679 * TODO: need to fixup sg_tablesize, max_segment_size,
46680 diff --git a/drivers/scsi/scsi_transport_fc.c b/drivers/scsi/scsi_transport_fc.c
46681 index 4628fd5..a94a1c2 100644
46682 --- a/drivers/scsi/scsi_transport_fc.c
46683 +++ b/drivers/scsi/scsi_transport_fc.c
46684 @@ -497,7 +497,7 @@ static DECLARE_TRANSPORT_CLASS(fc_vport_class,
46685 * Netlink Infrastructure
46686 */
46687
46688 -static atomic_t fc_event_seq;
46689 +static atomic_unchecked_t fc_event_seq;
46690
46691 /**
46692 * fc_get_event_number - Obtain the next sequential FC event number
46693 @@ -510,7 +510,7 @@ static atomic_t fc_event_seq;
46694 u32
46695 fc_get_event_number(void)
46696 {
46697 - return atomic_add_return(1, &fc_event_seq);
46698 + return atomic_add_return_unchecked(1, &fc_event_seq);
46699 }
46700 EXPORT_SYMBOL(fc_get_event_number);
46701
46702 @@ -654,7 +654,7 @@ static __init int fc_transport_init(void)
46703 {
46704 int error;
46705
46706 - atomic_set(&fc_event_seq, 0);
46707 + atomic_set_unchecked(&fc_event_seq, 0);
46708
46709 error = transport_class_register(&fc_host_class);
46710 if (error)
46711 @@ -844,7 +844,7 @@ static int fc_str_to_dev_loss(const char *buf, unsigned long *val)
46712 char *cp;
46713
46714 *val = simple_strtoul(buf, &cp, 0);
46715 - if ((*cp && (*cp != '\n')) || (*val < 0))
46716 + if (*cp && (*cp != '\n'))
46717 return -EINVAL;
46718 /*
46719 * Check for overflow; dev_loss_tmo is u32
46720 diff --git a/drivers/scsi/scsi_transport_iscsi.c b/drivers/scsi/scsi_transport_iscsi.c
46721 index e4a989f..293090c 100644
46722 --- a/drivers/scsi/scsi_transport_iscsi.c
46723 +++ b/drivers/scsi/scsi_transport_iscsi.c
46724 @@ -79,7 +79,7 @@ struct iscsi_internal {
46725 struct transport_container session_cont;
46726 };
46727
46728 -static atomic_t iscsi_session_nr; /* sysfs session id for next new session */
46729 +static atomic_unchecked_t iscsi_session_nr; /* sysfs session id for next new session */
46730 static struct workqueue_struct *iscsi_eh_timer_workq;
46731
46732 static DEFINE_IDA(iscsi_sess_ida);
46733 @@ -1737,7 +1737,7 @@ int iscsi_add_session(struct iscsi_cls_session *session, unsigned int target_id)
46734 int err;
46735
46736 ihost = shost->shost_data;
46737 - session->sid = atomic_add_return(1, &iscsi_session_nr);
46738 + session->sid = atomic_add_return_unchecked(1, &iscsi_session_nr);
46739
46740 if (target_id == ISCSI_MAX_TARGET) {
46741 id = ida_simple_get(&iscsi_sess_ida, 0, 0, GFP_KERNEL);
46742 @@ -4077,7 +4077,7 @@ static __init int iscsi_transport_init(void)
46743 printk(KERN_INFO "Loading iSCSI transport class v%s.\n",
46744 ISCSI_TRANSPORT_VERSION);
46745
46746 - atomic_set(&iscsi_session_nr, 0);
46747 + atomic_set_unchecked(&iscsi_session_nr, 0);
46748
46749 err = class_register(&iscsi_transport_class);
46750 if (err)
46751 diff --git a/drivers/scsi/scsi_transport_srp.c b/drivers/scsi/scsi_transport_srp.c
46752 index f379c7f..e8fc69c 100644
46753 --- a/drivers/scsi/scsi_transport_srp.c
46754 +++ b/drivers/scsi/scsi_transport_srp.c
46755 @@ -33,7 +33,7 @@
46756 #include "scsi_transport_srp_internal.h"
46757
46758 struct srp_host_attrs {
46759 - atomic_t next_port_id;
46760 + atomic_unchecked_t next_port_id;
46761 };
46762 #define to_srp_host_attrs(host) ((struct srp_host_attrs *)(host)->shost_data)
46763
46764 @@ -61,7 +61,7 @@ static int srp_host_setup(struct transport_container *tc, struct device *dev,
46765 struct Scsi_Host *shost = dev_to_shost(dev);
46766 struct srp_host_attrs *srp_host = to_srp_host_attrs(shost);
46767
46768 - atomic_set(&srp_host->next_port_id, 0);
46769 + atomic_set_unchecked(&srp_host->next_port_id, 0);
46770 return 0;
46771 }
46772
46773 @@ -210,7 +210,7 @@ struct srp_rport *srp_rport_add(struct Scsi_Host *shost,
46774 memcpy(rport->port_id, ids->port_id, sizeof(rport->port_id));
46775 rport->roles = ids->roles;
46776
46777 - id = atomic_inc_return(&to_srp_host_attrs(shost)->next_port_id);
46778 + id = atomic_inc_return_unchecked(&to_srp_host_attrs(shost)->next_port_id);
46779 dev_set_name(&rport->dev, "port-%d:%d", shost->host_no, id);
46780
46781 transport_setup_device(&rport->dev);
46782 diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
46783 index 5693f6d7..b0bf05a 100644
46784 --- a/drivers/scsi/sd.c
46785 +++ b/drivers/scsi/sd.c
46786 @@ -2934,7 +2934,7 @@ static int sd_probe(struct device *dev)
46787 sdkp->disk = gd;
46788 sdkp->index = index;
46789 atomic_set(&sdkp->openers, 0);
46790 - atomic_set(&sdkp->device->ioerr_cnt, 0);
46791 + atomic_set_unchecked(&sdkp->device->ioerr_cnt, 0);
46792
46793 if (!sdp->request_queue->rq_timeout) {
46794 if (sdp->type != TYPE_MOD)
46795 diff --git a/drivers/scsi/sg.c b/drivers/scsi/sg.c
46796 index df5e961..df6b97f 100644
46797 --- a/drivers/scsi/sg.c
46798 +++ b/drivers/scsi/sg.c
46799 @@ -1102,7 +1102,7 @@ sg_ioctl(struct file *filp, unsigned int cmd_in, unsigned long arg)
46800 sdp->disk->disk_name,
46801 MKDEV(SCSI_GENERIC_MAJOR, sdp->index),
46802 NULL,
46803 - (char *)arg);
46804 + (char __user *)arg);
46805 case BLKTRACESTART:
46806 return blk_trace_startstop(sdp->device->request_queue, 1);
46807 case BLKTRACESTOP:
46808 diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
46809 index 9e039c6..ae9e800 100644
46810 --- a/drivers/spi/spi.c
46811 +++ b/drivers/spi/spi.c
46812 @@ -1762,7 +1762,7 @@ int spi_bus_unlock(struct spi_master *master)
46813 EXPORT_SYMBOL_GPL(spi_bus_unlock);
46814
46815 /* portable code must never pass more than 32 bytes */
46816 -#define SPI_BUFSIZ max(32,SMP_CACHE_BYTES)
46817 +#define SPI_BUFSIZ max(32UL,SMP_CACHE_BYTES)
46818
46819 static u8 *buf;
46820
46821 diff --git a/drivers/staging/android/timed_output.c b/drivers/staging/android/timed_output.c
46822 index 2c61783..4d49e4e 100644
46823 --- a/drivers/staging/android/timed_output.c
46824 +++ b/drivers/staging/android/timed_output.c
46825 @@ -25,7 +25,7 @@
46826 #include "timed_output.h"
46827
46828 static struct class *timed_output_class;
46829 -static atomic_t device_count;
46830 +static atomic_unchecked_t device_count;
46831
46832 static ssize_t enable_show(struct device *dev, struct device_attribute *attr,
46833 char *buf)
46834 @@ -63,7 +63,7 @@ static int create_timed_output_class(void)
46835 timed_output_class = class_create(THIS_MODULE, "timed_output");
46836 if (IS_ERR(timed_output_class))
46837 return PTR_ERR(timed_output_class);
46838 - atomic_set(&device_count, 0);
46839 + atomic_set_unchecked(&device_count, 0);
46840 timed_output_class->dev_groups = timed_output_groups;
46841 }
46842
46843 @@ -81,7 +81,7 @@ int timed_output_dev_register(struct timed_output_dev *tdev)
46844 if (ret < 0)
46845 return ret;
46846
46847 - tdev->index = atomic_inc_return(&device_count);
46848 + tdev->index = atomic_inc_return_unchecked(&device_count);
46849 tdev->dev = device_create(timed_output_class, NULL,
46850 MKDEV(0, tdev->index), NULL, "%s", tdev->name);
46851 if (IS_ERR(tdev->dev))
46852 diff --git a/drivers/staging/gdm724x/gdm_tty.c b/drivers/staging/gdm724x/gdm_tty.c
46853 index 0247a20..cb9595c 100644
46854 --- a/drivers/staging/gdm724x/gdm_tty.c
46855 +++ b/drivers/staging/gdm724x/gdm_tty.c
46856 @@ -45,7 +45,7 @@
46857 #define gdm_tty_send_control(n, r, v, d, l) (\
46858 n->tty_dev->send_control(n->tty_dev->priv_dev, r, v, d, l))
46859
46860 -#define GDM_TTY_READY(gdm) (gdm && gdm->tty_dev && gdm->port.count)
46861 +#define GDM_TTY_READY(gdm) (gdm && gdm->tty_dev && atomic_read(&gdm->port.count))
46862
46863 static struct tty_driver *gdm_driver[TTY_MAX_COUNT];
46864 static struct gdm *gdm_table[TTY_MAX_COUNT][GDM_TTY_MINOR];
46865 diff --git a/drivers/staging/lustre/lnet/selftest/brw_test.c b/drivers/staging/lustre/lnet/selftest/brw_test.c
46866 index ef5064e..fce01db 100644
46867 --- a/drivers/staging/lustre/lnet/selftest/brw_test.c
46868 +++ b/drivers/staging/lustre/lnet/selftest/brw_test.c
46869 @@ -478,13 +478,11 @@ brw_server_handle(struct srpc_server_rpc *rpc)
46870 return 0;
46871 }
46872
46873 -sfw_test_client_ops_t brw_test_client;
46874 -void brw_init_test_client(void)
46875 -{
46876 - brw_test_client.tso_init = brw_client_init;
46877 - brw_test_client.tso_fini = brw_client_fini;
46878 - brw_test_client.tso_prep_rpc = brw_client_prep_rpc;
46879 - brw_test_client.tso_done_rpc = brw_client_done_rpc;
46880 +sfw_test_client_ops_t brw_test_client = {
46881 + .tso_init = brw_client_init,
46882 + .tso_fini = brw_client_fini,
46883 + .tso_prep_rpc = brw_client_prep_rpc,
46884 + .tso_done_rpc = brw_client_done_rpc,
46885 };
46886
46887 srpc_service_t brw_test_service;
46888 diff --git a/drivers/staging/lustre/lnet/selftest/framework.c b/drivers/staging/lustre/lnet/selftest/framework.c
46889 index 483c785..e1a2a7b 100644
46890 --- a/drivers/staging/lustre/lnet/selftest/framework.c
46891 +++ b/drivers/staging/lustre/lnet/selftest/framework.c
46892 @@ -1635,12 +1635,10 @@ static srpc_service_t sfw_services[] =
46893
46894 extern sfw_test_client_ops_t ping_test_client;
46895 extern srpc_service_t ping_test_service;
46896 -extern void ping_init_test_client(void);
46897 extern void ping_init_test_service(void);
46898
46899 extern sfw_test_client_ops_t brw_test_client;
46900 extern srpc_service_t brw_test_service;
46901 -extern void brw_init_test_client(void);
46902 extern void brw_init_test_service(void);
46903
46904
46905 @@ -1684,12 +1682,10 @@ sfw_startup (void)
46906 INIT_LIST_HEAD(&sfw_data.fw_zombie_rpcs);
46907 INIT_LIST_HEAD(&sfw_data.fw_zombie_sessions);
46908
46909 - brw_init_test_client();
46910 brw_init_test_service();
46911 rc = sfw_register_test(&brw_test_service, &brw_test_client);
46912 LASSERT (rc == 0);
46913
46914 - ping_init_test_client();
46915 ping_init_test_service();
46916 rc = sfw_register_test(&ping_test_service, &ping_test_client);
46917 LASSERT (rc == 0);
46918 diff --git a/drivers/staging/lustre/lnet/selftest/ping_test.c b/drivers/staging/lustre/lnet/selftest/ping_test.c
46919 index f0f9194..b589047 100644
46920 --- a/drivers/staging/lustre/lnet/selftest/ping_test.c
46921 +++ b/drivers/staging/lustre/lnet/selftest/ping_test.c
46922 @@ -210,14 +210,12 @@ ping_server_handle(struct srpc_server_rpc *rpc)
46923 return 0;
46924 }
46925
46926 -sfw_test_client_ops_t ping_test_client;
46927 -void ping_init_test_client(void)
46928 -{
46929 - ping_test_client.tso_init = ping_client_init;
46930 - ping_test_client.tso_fini = ping_client_fini;
46931 - ping_test_client.tso_prep_rpc = ping_client_prep_rpc;
46932 - ping_test_client.tso_done_rpc = ping_client_done_rpc;
46933 -}
46934 +sfw_test_client_ops_t ping_test_client = {
46935 + .tso_init = ping_client_init,
46936 + .tso_fini = ping_client_fini,
46937 + .tso_prep_rpc = ping_client_prep_rpc,
46938 + .tso_done_rpc = ping_client_done_rpc,
46939 +};
46940
46941 srpc_service_t ping_test_service;
46942 void ping_init_test_service(void)
46943 diff --git a/drivers/staging/lustre/lustre/include/lustre_dlm.h b/drivers/staging/lustre/lustre/include/lustre_dlm.h
46944 index 7020d9c..0d3b580 100644
46945 --- a/drivers/staging/lustre/lustre/include/lustre_dlm.h
46946 +++ b/drivers/staging/lustre/lustre/include/lustre_dlm.h
46947 @@ -1141,7 +1141,7 @@ struct ldlm_callback_suite {
46948 ldlm_completion_callback lcs_completion;
46949 ldlm_blocking_callback lcs_blocking;
46950 ldlm_glimpse_callback lcs_glimpse;
46951 -};
46952 +} __no_const;
46953
46954 /* ldlm_lockd.c */
46955 int ldlm_del_waiting_lock(struct ldlm_lock *lock);
46956 diff --git a/drivers/staging/lustre/lustre/include/obd.h b/drivers/staging/lustre/lustre/include/obd.h
46957 index a612255..9a9e2dd 100644
46958 --- a/drivers/staging/lustre/lustre/include/obd.h
46959 +++ b/drivers/staging/lustre/lustre/include/obd.h
46960 @@ -1417,7 +1417,7 @@ struct md_ops {
46961 * lprocfs_alloc_md_stats() in obdclass/lprocfs_status.c. Also, add a
46962 * wrapper function in include/linux/obd_class.h.
46963 */
46964 -};
46965 +} __no_const;
46966
46967 struct lsm_operations {
46968 void (*lsm_free)(struct lov_stripe_md *);
46969 diff --git a/drivers/staging/lustre/lustre/libcfs/linux/linux-proc.c b/drivers/staging/lustre/lustre/libcfs/linux/linux-proc.c
46970 index fc6c977..df1f956 100644
46971 --- a/drivers/staging/lustre/lustre/libcfs/linux/linux-proc.c
46972 +++ b/drivers/staging/lustre/lustre/libcfs/linux/linux-proc.c
46973 @@ -219,7 +219,7 @@ DECLARE_PROC_HANDLER(proc_debug_mb)
46974 int LL_PROC_PROTO(proc_console_max_delay_cs)
46975 {
46976 int rc, max_delay_cs;
46977 - ctl_table_t dummy = *table;
46978 + ctl_table_no_const dummy = *table;
46979 cfs_duration_t d;
46980
46981 dummy.data = &max_delay_cs;
46982 @@ -250,7 +250,7 @@ int LL_PROC_PROTO(proc_console_max_delay_cs)
46983 int LL_PROC_PROTO(proc_console_min_delay_cs)
46984 {
46985 int rc, min_delay_cs;
46986 - ctl_table_t dummy = *table;
46987 + ctl_table_no_const dummy = *table;
46988 cfs_duration_t d;
46989
46990 dummy.data = &min_delay_cs;
46991 @@ -281,7 +281,7 @@ int LL_PROC_PROTO(proc_console_min_delay_cs)
46992 int LL_PROC_PROTO(proc_console_backoff)
46993 {
46994 int rc, backoff;
46995 - ctl_table_t dummy = *table;
46996 + ctl_table_no_const dummy = *table;
46997
46998 dummy.data = &backoff;
46999 dummy.proc_handler = &proc_dointvec;
47000 diff --git a/drivers/staging/media/solo6x10/solo6x10-core.c b/drivers/staging/media/solo6x10/solo6x10-core.c
47001 index 3675020..e80d92c 100644
47002 --- a/drivers/staging/media/solo6x10/solo6x10-core.c
47003 +++ b/drivers/staging/media/solo6x10/solo6x10-core.c
47004 @@ -434,7 +434,7 @@ static void solo_device_release(struct device *dev)
47005
47006 static int solo_sysfs_init(struct solo_dev *solo_dev)
47007 {
47008 - struct bin_attribute *sdram_attr = &solo_dev->sdram_attr;
47009 + bin_attribute_no_const *sdram_attr = &solo_dev->sdram_attr;
47010 struct device *dev = &solo_dev->dev;
47011 const char *driver;
47012 int i;
47013 diff --git a/drivers/staging/media/solo6x10/solo6x10-p2m.c b/drivers/staging/media/solo6x10/solo6x10-p2m.c
47014 index 3335941..2b26186 100644
47015 --- a/drivers/staging/media/solo6x10/solo6x10-p2m.c
47016 +++ b/drivers/staging/media/solo6x10/solo6x10-p2m.c
47017 @@ -77,7 +77,7 @@ int solo_p2m_dma_desc(struct solo_dev *solo_dev,
47018
47019 /* Get next ID. According to Softlogic, 6110 has problems on !=0 P2M */
47020 if (solo_dev->type != SOLO_DEV_6110 && multi_p2m) {
47021 - p2m_id = atomic_inc_return(&solo_dev->p2m_count) % SOLO_NR_P2M;
47022 + p2m_id = atomic_inc_return_unchecked(&solo_dev->p2m_count) % SOLO_NR_P2M;
47023 if (p2m_id < 0)
47024 p2m_id = -p2m_id;
47025 }
47026 diff --git a/drivers/staging/media/solo6x10/solo6x10.h b/drivers/staging/media/solo6x10/solo6x10.h
47027 index 6f91d2e..3f011d2 100644
47028 --- a/drivers/staging/media/solo6x10/solo6x10.h
47029 +++ b/drivers/staging/media/solo6x10/solo6x10.h
47030 @@ -238,7 +238,7 @@ struct solo_dev {
47031
47032 /* P2M DMA Engine */
47033 struct solo_p2m_dev p2m_dev[SOLO_NR_P2M];
47034 - atomic_t p2m_count;
47035 + atomic_unchecked_t p2m_count;
47036 int p2m_jiffies;
47037 unsigned int p2m_timeouts;
47038
47039 diff --git a/drivers/staging/octeon/ethernet-rx.c b/drivers/staging/octeon/ethernet-rx.c
47040 index e14a1bb..9cb9bbe 100644
47041 --- a/drivers/staging/octeon/ethernet-rx.c
47042 +++ b/drivers/staging/octeon/ethernet-rx.c
47043 @@ -419,11 +419,11 @@ static int cvm_oct_napi_poll(struct napi_struct *napi, int budget)
47044 /* Increment RX stats for virtual ports */
47045 if (work->ipprt >= CVMX_PIP_NUM_INPUT_PORTS) {
47046 #ifdef CONFIG_64BIT
47047 - atomic64_add(1, (atomic64_t *)&priv->stats.rx_packets);
47048 - atomic64_add(skb->len, (atomic64_t *)&priv->stats.rx_bytes);
47049 + atomic64_add_unchecked(1, (atomic64_unchecked_t *)&priv->stats.rx_packets);
47050 + atomic64_add_unchecked(skb->len, (atomic64_unchecked_t *)&priv->stats.rx_bytes);
47051 #else
47052 - atomic_add(1, (atomic_t *)&priv->stats.rx_packets);
47053 - atomic_add(skb->len, (atomic_t *)&priv->stats.rx_bytes);
47054 + atomic_add_unchecked(1, (atomic_unchecked_t *)&priv->stats.rx_packets);
47055 + atomic_add_unchecked(skb->len, (atomic_unchecked_t *)&priv->stats.rx_bytes);
47056 #endif
47057 }
47058 netif_receive_skb(skb);
47059 @@ -434,9 +434,9 @@ static int cvm_oct_napi_poll(struct napi_struct *napi, int budget)
47060 dev->name);
47061 */
47062 #ifdef CONFIG_64BIT
47063 - atomic64_add(1, (atomic64_t *)&priv->stats.rx_dropped);
47064 + atomic64_unchecked_add(1, (atomic64_unchecked_t *)&priv->stats.rx_dropped);
47065 #else
47066 - atomic_add(1, (atomic_t *)&priv->stats.rx_dropped);
47067 + atomic_add_unchecked(1, (atomic_unchecked_t *)&priv->stats.rx_dropped);
47068 #endif
47069 dev_kfree_skb_irq(skb);
47070 }
47071 diff --git a/drivers/staging/octeon/ethernet.c b/drivers/staging/octeon/ethernet.c
47072 index c3a90e7..023619a 100644
47073 --- a/drivers/staging/octeon/ethernet.c
47074 +++ b/drivers/staging/octeon/ethernet.c
47075 @@ -252,11 +252,11 @@ static struct net_device_stats *cvm_oct_common_get_stats(struct net_device *dev)
47076 * since the RX tasklet also increments it.
47077 */
47078 #ifdef CONFIG_64BIT
47079 - atomic64_add(rx_status.dropped_packets,
47080 - (atomic64_t *)&priv->stats.rx_dropped);
47081 + atomic64_add_unchecked(rx_status.dropped_packets,
47082 + (atomic64_unchecked_t *)&priv->stats.rx_dropped);
47083 #else
47084 - atomic_add(rx_status.dropped_packets,
47085 - (atomic_t *)&priv->stats.rx_dropped);
47086 + atomic_add_unchecked(rx_status.dropped_packets,
47087 + (atomic_unchecked_t *)&priv->stats.rx_dropped);
47088 #endif
47089 }
47090
47091 diff --git a/drivers/staging/rtl8188eu/include/hal_intf.h b/drivers/staging/rtl8188eu/include/hal_intf.h
47092 index 439c3c9..2d74293 100644
47093 --- a/drivers/staging/rtl8188eu/include/hal_intf.h
47094 +++ b/drivers/staging/rtl8188eu/include/hal_intf.h
47095 @@ -271,7 +271,7 @@ struct hal_ops {
47096 s32 (*c2h_handler)(struct adapter *padapter,
47097 struct c2h_evt_hdr *c2h_evt);
47098 c2h_id_filter c2h_id_filter_ccx;
47099 -};
47100 +} __no_const;
47101
47102 enum rt_eeprom_type {
47103 EEPROM_93C46,
47104 diff --git a/drivers/staging/rtl8188eu/include/rtw_io.h b/drivers/staging/rtl8188eu/include/rtw_io.h
47105 index eb6f0e5..e6a0958 100644
47106 --- a/drivers/staging/rtl8188eu/include/rtw_io.h
47107 +++ b/drivers/staging/rtl8188eu/include/rtw_io.h
47108 @@ -126,7 +126,7 @@ struct _io_ops {
47109 u32 (*_write_scsi)(struct intf_hdl *pintfhdl,u32 cnt, u8 *pmem);
47110 void (*_read_port_cancel)(struct intf_hdl *pintfhdl);
47111 void (*_write_port_cancel)(struct intf_hdl *pintfhdl);
47112 -};
47113 +} __no_const;
47114
47115 struct io_req {
47116 struct list_head list;
47117 diff --git a/drivers/staging/rtl8712/rtl871x_io.h b/drivers/staging/rtl8712/rtl871x_io.h
47118 index dc23395..cf7e9b1 100644
47119 --- a/drivers/staging/rtl8712/rtl871x_io.h
47120 +++ b/drivers/staging/rtl8712/rtl871x_io.h
47121 @@ -108,7 +108,7 @@ struct _io_ops {
47122 u8 *pmem);
47123 u32 (*_write_port)(struct intf_hdl *pintfhdl, u32 addr, u32 cnt,
47124 u8 *pmem);
47125 -};
47126 +} __no_const;
47127
47128 struct io_req {
47129 struct list_head list;
47130 diff --git a/drivers/staging/sbe-2t3e3/netdev.c b/drivers/staging/sbe-2t3e3/netdev.c
47131 index 1f5088b..0e59820 100644
47132 --- a/drivers/staging/sbe-2t3e3/netdev.c
47133 +++ b/drivers/staging/sbe-2t3e3/netdev.c
47134 @@ -51,7 +51,7 @@ static int t3e3_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
47135 t3e3_if_config(sc, cmd_2t3e3, (char *)&param, &resp, &rlen);
47136
47137 if (rlen)
47138 - if (copy_to_user(data, &resp, rlen))
47139 + if (rlen > sizeof resp || copy_to_user(data, &resp, rlen))
47140 return -EFAULT;
47141
47142 return 0;
47143 diff --git a/drivers/staging/usbip/vhci.h b/drivers/staging/usbip/vhci.h
47144 index a863a98..d272795 100644
47145 --- a/drivers/staging/usbip/vhci.h
47146 +++ b/drivers/staging/usbip/vhci.h
47147 @@ -83,7 +83,7 @@ struct vhci_hcd {
47148 unsigned resuming:1;
47149 unsigned long re_timeout;
47150
47151 - atomic_t seqnum;
47152 + atomic_unchecked_t seqnum;
47153
47154 /*
47155 * NOTE:
47156 diff --git a/drivers/staging/usbip/vhci_hcd.c b/drivers/staging/usbip/vhci_hcd.c
47157 index d7974cb..d78076b 100644
47158 --- a/drivers/staging/usbip/vhci_hcd.c
47159 +++ b/drivers/staging/usbip/vhci_hcd.c
47160 @@ -441,7 +441,7 @@ static void vhci_tx_urb(struct urb *urb)
47161
47162 spin_lock(&vdev->priv_lock);
47163
47164 - priv->seqnum = atomic_inc_return(&the_controller->seqnum);
47165 + priv->seqnum = atomic_inc_return_unchecked(&the_controller->seqnum);
47166 if (priv->seqnum == 0xffff)
47167 dev_info(&urb->dev->dev, "seqnum max\n");
47168
47169 @@ -687,7 +687,7 @@ static int vhci_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, int status)
47170 return -ENOMEM;
47171 }
47172
47173 - unlink->seqnum = atomic_inc_return(&the_controller->seqnum);
47174 + unlink->seqnum = atomic_inc_return_unchecked(&the_controller->seqnum);
47175 if (unlink->seqnum == 0xffff)
47176 pr_info("seqnum max\n");
47177
47178 @@ -891,7 +891,7 @@ static int vhci_start(struct usb_hcd *hcd)
47179 vdev->rhport = rhport;
47180 }
47181
47182 - atomic_set(&vhci->seqnum, 0);
47183 + atomic_set_unchecked(&vhci->seqnum, 0);
47184 spin_lock_init(&vhci->lock);
47185
47186 hcd->power_budget = 0; /* no limit */
47187 diff --git a/drivers/staging/usbip/vhci_rx.c b/drivers/staging/usbip/vhci_rx.c
47188 index d07fcb5..358e1e1 100644
47189 --- a/drivers/staging/usbip/vhci_rx.c
47190 +++ b/drivers/staging/usbip/vhci_rx.c
47191 @@ -80,7 +80,7 @@ static void vhci_recv_ret_submit(struct vhci_device *vdev,
47192 if (!urb) {
47193 pr_err("cannot find a urb of seqnum %u\n", pdu->base.seqnum);
47194 pr_info("max seqnum %d\n",
47195 - atomic_read(&the_controller->seqnum));
47196 + atomic_read_unchecked(&the_controller->seqnum));
47197 usbip_event_add(ud, VDEV_EVENT_ERROR_TCP);
47198 return;
47199 }
47200 diff --git a/drivers/staging/vt6655/hostap.c b/drivers/staging/vt6655/hostap.c
47201 index 8acff44..bdb2fca 100644
47202 --- a/drivers/staging/vt6655/hostap.c
47203 +++ b/drivers/staging/vt6655/hostap.c
47204 @@ -69,14 +69,13 @@ static int msglevel = MSG_LEVEL_INFO;
47205 *
47206 */
47207
47208 +static net_device_ops_no_const apdev_netdev_ops;
47209 +
47210 static int hostap_enable_hostapd(PSDevice pDevice, int rtnl_locked)
47211 {
47212 PSDevice apdev_priv;
47213 struct net_device *dev = pDevice->dev;
47214 int ret;
47215 - const struct net_device_ops apdev_netdev_ops = {
47216 - .ndo_start_xmit = pDevice->tx_80211,
47217 - };
47218
47219 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "%s: Enabling hostapd mode\n", dev->name);
47220
47221 @@ -88,6 +87,8 @@ static int hostap_enable_hostapd(PSDevice pDevice, int rtnl_locked)
47222 *apdev_priv = *pDevice;
47223 eth_hw_addr_inherit(pDevice->apdev, dev);
47224
47225 + /* only half broken now */
47226 + apdev_netdev_ops.ndo_start_xmit = pDevice->tx_80211;
47227 pDevice->apdev->netdev_ops = &apdev_netdev_ops;
47228
47229 pDevice->apdev->type = ARPHRD_IEEE80211;
47230 diff --git a/drivers/staging/vt6656/hostap.c b/drivers/staging/vt6656/hostap.c
47231 index c699a30..b90a5fd 100644
47232 --- a/drivers/staging/vt6656/hostap.c
47233 +++ b/drivers/staging/vt6656/hostap.c
47234 @@ -60,14 +60,13 @@ static int msglevel =MSG_LEVEL_INFO;
47235 *
47236 */
47237
47238 +static net_device_ops_no_const apdev_netdev_ops;
47239 +
47240 static int hostap_enable_hostapd(struct vnt_private *pDevice, int rtnl_locked)
47241 {
47242 struct vnt_private *apdev_priv;
47243 struct net_device *dev = pDevice->dev;
47244 int ret;
47245 - const struct net_device_ops apdev_netdev_ops = {
47246 - .ndo_start_xmit = pDevice->tx_80211,
47247 - };
47248
47249 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "%s: Enabling hostapd mode\n", dev->name);
47250
47251 @@ -79,6 +78,8 @@ static int hostap_enable_hostapd(struct vnt_private *pDevice, int rtnl_locked)
47252 *apdev_priv = *pDevice;
47253 memcpy(pDevice->apdev->dev_addr, dev->dev_addr, ETH_ALEN);
47254
47255 + /* only half broken now */
47256 + apdev_netdev_ops.ndo_start_xmit = pDevice->tx_80211;
47257 pDevice->apdev->netdev_ops = &apdev_netdev_ops;
47258
47259 pDevice->apdev->type = ARPHRD_IEEE80211;
47260 diff --git a/drivers/target/sbp/sbp_target.c b/drivers/target/sbp/sbp_target.c
47261 index e51b09a..5ebac31 100644
47262 --- a/drivers/target/sbp/sbp_target.c
47263 +++ b/drivers/target/sbp/sbp_target.c
47264 @@ -62,7 +62,7 @@ static const u32 sbp_unit_directory_template[] = {
47265
47266 #define SESSION_MAINTENANCE_INTERVAL HZ
47267
47268 -static atomic_t login_id = ATOMIC_INIT(0);
47269 +static atomic_unchecked_t login_id = ATOMIC_INIT(0);
47270
47271 static void session_maintenance_work(struct work_struct *);
47272 static int sbp_run_transaction(struct fw_card *, int, int, int, int,
47273 @@ -444,7 +444,7 @@ static void sbp_management_request_login(
47274 login->lun = se_lun;
47275 login->status_fifo_addr = sbp2_pointer_to_addr(&req->orb.status_fifo);
47276 login->exclusive = LOGIN_ORB_EXCLUSIVE(be32_to_cpu(req->orb.misc));
47277 - login->login_id = atomic_inc_return(&login_id);
47278 + login->login_id = atomic_inc_return_unchecked(&login_id);
47279
47280 login->tgt_agt = sbp_target_agent_register(login);
47281 if (IS_ERR(login->tgt_agt)) {
47282 diff --git a/drivers/target/target_core_device.c b/drivers/target/target_core_device.c
47283 index d90dbb0..6cbe585 100644
47284 --- a/drivers/target/target_core_device.c
47285 +++ b/drivers/target/target_core_device.c
47286 @@ -1431,7 +1431,7 @@ struct se_device *target_alloc_device(struct se_hba *hba, const char *name)
47287 spin_lock_init(&dev->se_tmr_lock);
47288 spin_lock_init(&dev->qf_cmd_lock);
47289 sema_init(&dev->caw_sem, 1);
47290 - atomic_set(&dev->dev_ordered_id, 0);
47291 + atomic_set_unchecked(&dev->dev_ordered_id, 0);
47292 INIT_LIST_HEAD(&dev->t10_wwn.t10_vpd_list);
47293 spin_lock_init(&dev->t10_wwn.t10_vpd_lock);
47294 INIT_LIST_HEAD(&dev->t10_pr.registration_list);
47295 diff --git a/drivers/target/target_core_transport.c b/drivers/target/target_core_transport.c
47296 index 0b0009b..215e88e 100644
47297 --- a/drivers/target/target_core_transport.c
47298 +++ b/drivers/target/target_core_transport.c
47299 @@ -1137,7 +1137,7 @@ transport_check_alloc_task_attr(struct se_cmd *cmd)
47300 * Used to determine when ORDERED commands should go from
47301 * Dormant to Active status.
47302 */
47303 - cmd->se_ordered_id = atomic_inc_return(&dev->dev_ordered_id);
47304 + cmd->se_ordered_id = atomic_inc_return_unchecked(&dev->dev_ordered_id);
47305 smp_mb__after_atomic_inc();
47306 pr_debug("Allocated se_ordered_id: %u for Task Attr: 0x%02x on %s\n",
47307 cmd->se_ordered_id, cmd->sam_task_attr,
47308 diff --git a/drivers/tty/cyclades.c b/drivers/tty/cyclades.c
47309 index 33f83fe..d80f8e1 100644
47310 --- a/drivers/tty/cyclades.c
47311 +++ b/drivers/tty/cyclades.c
47312 @@ -1570,10 +1570,10 @@ static int cy_open(struct tty_struct *tty, struct file *filp)
47313 printk(KERN_DEBUG "cyc:cy_open ttyC%d, count = %d\n", info->line,
47314 info->port.count);
47315 #endif
47316 - info->port.count++;
47317 + atomic_inc(&info->port.count);
47318 #ifdef CY_DEBUG_COUNT
47319 printk(KERN_DEBUG "cyc:cy_open (%d): incrementing count to %d\n",
47320 - current->pid, info->port.count);
47321 + current->pid, atomic_read(&info->port.count));
47322 #endif
47323
47324 /*
47325 @@ -3972,7 +3972,7 @@ static int cyclades_proc_show(struct seq_file *m, void *v)
47326 for (j = 0; j < cy_card[i].nports; j++) {
47327 info = &cy_card[i].ports[j];
47328
47329 - if (info->port.count) {
47330 + if (atomic_read(&info->port.count)) {
47331 /* XXX is the ldisc num worth this? */
47332 struct tty_struct *tty;
47333 struct tty_ldisc *ld;
47334 diff --git a/drivers/tty/hvc/hvc_console.c b/drivers/tty/hvc/hvc_console.c
47335 index 9eba119..5070303 100644
47336 --- a/drivers/tty/hvc/hvc_console.c
47337 +++ b/drivers/tty/hvc/hvc_console.c
47338 @@ -338,7 +338,7 @@ static int hvc_open(struct tty_struct *tty, struct file * filp)
47339
47340 spin_lock_irqsave(&hp->port.lock, flags);
47341 /* Check and then increment for fast path open. */
47342 - if (hp->port.count++ > 0) {
47343 + if (atomic_inc_return(&hp->port.count) > 1) {
47344 spin_unlock_irqrestore(&hp->port.lock, flags);
47345 hvc_kick();
47346 return 0;
47347 @@ -393,7 +393,7 @@ static void hvc_close(struct tty_struct *tty, struct file * filp)
47348
47349 spin_lock_irqsave(&hp->port.lock, flags);
47350
47351 - if (--hp->port.count == 0) {
47352 + if (atomic_dec_return(&hp->port.count) == 0) {
47353 spin_unlock_irqrestore(&hp->port.lock, flags);
47354 /* We are done with the tty pointer now. */
47355 tty_port_tty_set(&hp->port, NULL);
47356 @@ -415,9 +415,9 @@ static void hvc_close(struct tty_struct *tty, struct file * filp)
47357 */
47358 tty_wait_until_sent_from_close(tty, HVC_CLOSE_WAIT);
47359 } else {
47360 - if (hp->port.count < 0)
47361 + if (atomic_read(&hp->port.count) < 0)
47362 printk(KERN_ERR "hvc_close %X: oops, count is %d\n",
47363 - hp->vtermno, hp->port.count);
47364 + hp->vtermno, atomic_read(&hp->port.count));
47365 spin_unlock_irqrestore(&hp->port.lock, flags);
47366 }
47367 }
47368 @@ -447,12 +447,12 @@ static void hvc_hangup(struct tty_struct *tty)
47369 * open->hangup case this can be called after the final close so prevent
47370 * that from happening for now.
47371 */
47372 - if (hp->port.count <= 0) {
47373 + if (atomic_read(&hp->port.count) <= 0) {
47374 spin_unlock_irqrestore(&hp->port.lock, flags);
47375 return;
47376 }
47377
47378 - hp->port.count = 0;
47379 + atomic_set(&hp->port.count, 0);
47380 spin_unlock_irqrestore(&hp->port.lock, flags);
47381 tty_port_tty_set(&hp->port, NULL);
47382
47383 @@ -500,7 +500,7 @@ static int hvc_write(struct tty_struct *tty, const unsigned char *buf, int count
47384 return -EPIPE;
47385
47386 /* FIXME what's this (unprotected) check for? */
47387 - if (hp->port.count <= 0)
47388 + if (atomic_read(&hp->port.count) <= 0)
47389 return -EIO;
47390
47391 spin_lock_irqsave(&hp->lock, flags);
47392 diff --git a/drivers/tty/hvc/hvcs.c b/drivers/tty/hvc/hvcs.c
47393 index 81e939e..95ead10 100644
47394 --- a/drivers/tty/hvc/hvcs.c
47395 +++ b/drivers/tty/hvc/hvcs.c
47396 @@ -83,6 +83,7 @@
47397 #include <asm/hvcserver.h>
47398 #include <asm/uaccess.h>
47399 #include <asm/vio.h>
47400 +#include <asm/local.h>
47401
47402 /*
47403 * 1.3.0 -> 1.3.1 In hvcs_open memset(..,0x00,..) instead of memset(..,0x3F,00).
47404 @@ -416,7 +417,7 @@ static ssize_t hvcs_vterm_state_store(struct device *dev, struct device_attribut
47405
47406 spin_lock_irqsave(&hvcsd->lock, flags);
47407
47408 - if (hvcsd->port.count > 0) {
47409 + if (atomic_read(&hvcsd->port.count) > 0) {
47410 spin_unlock_irqrestore(&hvcsd->lock, flags);
47411 printk(KERN_INFO "HVCS: vterm state unchanged. "
47412 "The hvcs device node is still in use.\n");
47413 @@ -1127,7 +1128,7 @@ static int hvcs_install(struct tty_driver *driver, struct tty_struct *tty)
47414 }
47415 }
47416
47417 - hvcsd->port.count = 0;
47418 + atomic_set(&hvcsd->port.count, 0);
47419 hvcsd->port.tty = tty;
47420 tty->driver_data = hvcsd;
47421
47422 @@ -1180,7 +1181,7 @@ static int hvcs_open(struct tty_struct *tty, struct file *filp)
47423 unsigned long flags;
47424
47425 spin_lock_irqsave(&hvcsd->lock, flags);
47426 - hvcsd->port.count++;
47427 + atomic_inc(&hvcsd->port.count);
47428 hvcsd->todo_mask |= HVCS_SCHED_READ;
47429 spin_unlock_irqrestore(&hvcsd->lock, flags);
47430
47431 @@ -1216,7 +1217,7 @@ static void hvcs_close(struct tty_struct *tty, struct file *filp)
47432 hvcsd = tty->driver_data;
47433
47434 spin_lock_irqsave(&hvcsd->lock, flags);
47435 - if (--hvcsd->port.count == 0) {
47436 + if (atomic_dec_and_test(&hvcsd->port.count)) {
47437
47438 vio_disable_interrupts(hvcsd->vdev);
47439
47440 @@ -1241,10 +1242,10 @@ static void hvcs_close(struct tty_struct *tty, struct file *filp)
47441
47442 free_irq(irq, hvcsd);
47443 return;
47444 - } else if (hvcsd->port.count < 0) {
47445 + } else if (atomic_read(&hvcsd->port.count) < 0) {
47446 printk(KERN_ERR "HVCS: vty-server@%X open_count: %d"
47447 " is missmanaged.\n",
47448 - hvcsd->vdev->unit_address, hvcsd->port.count);
47449 + hvcsd->vdev->unit_address, atomic_read(&hvcsd->port.count));
47450 }
47451
47452 spin_unlock_irqrestore(&hvcsd->lock, flags);
47453 @@ -1266,7 +1267,7 @@ static void hvcs_hangup(struct tty_struct * tty)
47454
47455 spin_lock_irqsave(&hvcsd->lock, flags);
47456 /* Preserve this so that we know how many kref refs to put */
47457 - temp_open_count = hvcsd->port.count;
47458 + temp_open_count = atomic_read(&hvcsd->port.count);
47459
47460 /*
47461 * Don't kref put inside the spinlock because the destruction
47462 @@ -1281,7 +1282,7 @@ static void hvcs_hangup(struct tty_struct * tty)
47463 tty->driver_data = NULL;
47464 hvcsd->port.tty = NULL;
47465
47466 - hvcsd->port.count = 0;
47467 + atomic_set(&hvcsd->port.count, 0);
47468
47469 /* This will drop any buffered data on the floor which is OK in a hangup
47470 * scenario. */
47471 @@ -1352,7 +1353,7 @@ static int hvcs_write(struct tty_struct *tty,
47472 * the middle of a write operation? This is a crummy place to do this
47473 * but we want to keep it all in the spinlock.
47474 */
47475 - if (hvcsd->port.count <= 0) {
47476 + if (atomic_read(&hvcsd->port.count) <= 0) {
47477 spin_unlock_irqrestore(&hvcsd->lock, flags);
47478 return -ENODEV;
47479 }
47480 @@ -1426,7 +1427,7 @@ static int hvcs_write_room(struct tty_struct *tty)
47481 {
47482 struct hvcs_struct *hvcsd = tty->driver_data;
47483
47484 - if (!hvcsd || hvcsd->port.count <= 0)
47485 + if (!hvcsd || atomic_read(&hvcsd->port.count) <= 0)
47486 return 0;
47487
47488 return HVCS_BUFF_LEN - hvcsd->chars_in_buffer;
47489 diff --git a/drivers/tty/hvc/hvsi.c b/drivers/tty/hvc/hvsi.c
47490 index 4190199..48f2920 100644
47491 --- a/drivers/tty/hvc/hvsi.c
47492 +++ b/drivers/tty/hvc/hvsi.c
47493 @@ -85,7 +85,7 @@ struct hvsi_struct {
47494 int n_outbuf;
47495 uint32_t vtermno;
47496 uint32_t virq;
47497 - atomic_t seqno; /* HVSI packet sequence number */
47498 + atomic_unchecked_t seqno; /* HVSI packet sequence number */
47499 uint16_t mctrl;
47500 uint8_t state; /* HVSI protocol state */
47501 uint8_t flags;
47502 @@ -295,7 +295,7 @@ static int hvsi_version_respond(struct hvsi_struct *hp, uint16_t query_seqno)
47503
47504 packet.hdr.type = VS_QUERY_RESPONSE_PACKET_HEADER;
47505 packet.hdr.len = sizeof(struct hvsi_query_response);
47506 - packet.hdr.seqno = atomic_inc_return(&hp->seqno);
47507 + packet.hdr.seqno = atomic_inc_return_unchecked(&hp->seqno);
47508 packet.verb = VSV_SEND_VERSION_NUMBER;
47509 packet.u.version = HVSI_VERSION;
47510 packet.query_seqno = query_seqno+1;
47511 @@ -555,7 +555,7 @@ static int hvsi_query(struct hvsi_struct *hp, uint16_t verb)
47512
47513 packet.hdr.type = VS_QUERY_PACKET_HEADER;
47514 packet.hdr.len = sizeof(struct hvsi_query);
47515 - packet.hdr.seqno = atomic_inc_return(&hp->seqno);
47516 + packet.hdr.seqno = atomic_inc_return_unchecked(&hp->seqno);
47517 packet.verb = verb;
47518
47519 pr_debug("%s: sending %i bytes\n", __func__, packet.hdr.len);
47520 @@ -597,7 +597,7 @@ static int hvsi_set_mctrl(struct hvsi_struct *hp, uint16_t mctrl)
47521 int wrote;
47522
47523 packet.hdr.type = VS_CONTROL_PACKET_HEADER,
47524 - packet.hdr.seqno = atomic_inc_return(&hp->seqno);
47525 + packet.hdr.seqno = atomic_inc_return_unchecked(&hp->seqno);
47526 packet.hdr.len = sizeof(struct hvsi_control);
47527 packet.verb = VSV_SET_MODEM_CTL;
47528 packet.mask = HVSI_TSDTR;
47529 @@ -680,7 +680,7 @@ static int hvsi_put_chars(struct hvsi_struct *hp, const char *buf, int count)
47530 BUG_ON(count > HVSI_MAX_OUTGOING_DATA);
47531
47532 packet.hdr.type = VS_DATA_PACKET_HEADER;
47533 - packet.hdr.seqno = atomic_inc_return(&hp->seqno);
47534 + packet.hdr.seqno = atomic_inc_return_unchecked(&hp->seqno);
47535 packet.hdr.len = count + sizeof(struct hvsi_header);
47536 memcpy(&packet.data, buf, count);
47537
47538 @@ -697,7 +697,7 @@ static void hvsi_close_protocol(struct hvsi_struct *hp)
47539 struct hvsi_control packet __ALIGNED__;
47540
47541 packet.hdr.type = VS_CONTROL_PACKET_HEADER;
47542 - packet.hdr.seqno = atomic_inc_return(&hp->seqno);
47543 + packet.hdr.seqno = atomic_inc_return_unchecked(&hp->seqno);
47544 packet.hdr.len = 6;
47545 packet.verb = VSV_CLOSE_PROTOCOL;
47546
47547 diff --git a/drivers/tty/hvc/hvsi_lib.c b/drivers/tty/hvc/hvsi_lib.c
47548 index ac27671..0f627ee 100644
47549 --- a/drivers/tty/hvc/hvsi_lib.c
47550 +++ b/drivers/tty/hvc/hvsi_lib.c
47551 @@ -9,7 +9,7 @@
47552
47553 static int hvsi_send_packet(struct hvsi_priv *pv, struct hvsi_header *packet)
47554 {
47555 - packet->seqno = atomic_inc_return(&pv->seqno);
47556 + packet->seqno = atomic_inc_return_unchecked(&pv->seqno);
47557
47558 /* Assumes that always succeeds, works in practice */
47559 return pv->put_chars(pv->termno, (char *)packet, packet->len);
47560 @@ -21,7 +21,7 @@ static void hvsi_start_handshake(struct hvsi_priv *pv)
47561
47562 /* Reset state */
47563 pv->established = 0;
47564 - atomic_set(&pv->seqno, 0);
47565 + atomic_set_unchecked(&pv->seqno, 0);
47566
47567 pr_devel("HVSI@%x: Handshaking started\n", pv->termno);
47568
47569 @@ -265,7 +265,7 @@ int hvsilib_read_mctrl(struct hvsi_priv *pv)
47570 pv->mctrl_update = 0;
47571 q.hdr.type = VS_QUERY_PACKET_HEADER;
47572 q.hdr.len = sizeof(struct hvsi_query);
47573 - q.hdr.seqno = atomic_inc_return(&pv->seqno);
47574 + q.hdr.seqno = atomic_inc_return_unchecked(&pv->seqno);
47575 q.verb = VSV_SEND_MODEM_CTL_STATUS;
47576 rc = hvsi_send_packet(pv, &q.hdr);
47577 if (rc <= 0) {
47578 diff --git a/drivers/tty/ipwireless/tty.c b/drivers/tty/ipwireless/tty.c
47579 index 8fd72ff..34a0bed 100644
47580 --- a/drivers/tty/ipwireless/tty.c
47581 +++ b/drivers/tty/ipwireless/tty.c
47582 @@ -29,6 +29,7 @@
47583 #include <linux/tty_driver.h>
47584 #include <linux/tty_flip.h>
47585 #include <linux/uaccess.h>
47586 +#include <asm/local.h>
47587
47588 #include "tty.h"
47589 #include "network.h"
47590 @@ -99,10 +100,10 @@ static int ipw_open(struct tty_struct *linux_tty, struct file *filp)
47591 mutex_unlock(&tty->ipw_tty_mutex);
47592 return -ENODEV;
47593 }
47594 - if (tty->port.count == 0)
47595 + if (atomic_read(&tty->port.count) == 0)
47596 tty->tx_bytes_queued = 0;
47597
47598 - tty->port.count++;
47599 + atomic_inc(&tty->port.count);
47600
47601 tty->port.tty = linux_tty;
47602 linux_tty->driver_data = tty;
47603 @@ -118,9 +119,7 @@ static int ipw_open(struct tty_struct *linux_tty, struct file *filp)
47604
47605 static void do_ipw_close(struct ipw_tty *tty)
47606 {
47607 - tty->port.count--;
47608 -
47609 - if (tty->port.count == 0) {
47610 + if (atomic_dec_return(&tty->port.count) == 0) {
47611 struct tty_struct *linux_tty = tty->port.tty;
47612
47613 if (linux_tty != NULL) {
47614 @@ -141,7 +140,7 @@ static void ipw_hangup(struct tty_struct *linux_tty)
47615 return;
47616
47617 mutex_lock(&tty->ipw_tty_mutex);
47618 - if (tty->port.count == 0) {
47619 + if (atomic_read(&tty->port.count) == 0) {
47620 mutex_unlock(&tty->ipw_tty_mutex);
47621 return;
47622 }
47623 @@ -164,7 +163,7 @@ void ipwireless_tty_received(struct ipw_tty *tty, unsigned char *data,
47624
47625 mutex_lock(&tty->ipw_tty_mutex);
47626
47627 - if (!tty->port.count) {
47628 + if (!atomic_read(&tty->port.count)) {
47629 mutex_unlock(&tty->ipw_tty_mutex);
47630 return;
47631 }
47632 @@ -206,7 +205,7 @@ static int ipw_write(struct tty_struct *linux_tty,
47633 return -ENODEV;
47634
47635 mutex_lock(&tty->ipw_tty_mutex);
47636 - if (!tty->port.count) {
47637 + if (!atomic_read(&tty->port.count)) {
47638 mutex_unlock(&tty->ipw_tty_mutex);
47639 return -EINVAL;
47640 }
47641 @@ -246,7 +245,7 @@ static int ipw_write_room(struct tty_struct *linux_tty)
47642 if (!tty)
47643 return -ENODEV;
47644
47645 - if (!tty->port.count)
47646 + if (!atomic_read(&tty->port.count))
47647 return -EINVAL;
47648
47649 room = IPWIRELESS_TX_QUEUE_SIZE - tty->tx_bytes_queued;
47650 @@ -288,7 +287,7 @@ static int ipw_chars_in_buffer(struct tty_struct *linux_tty)
47651 if (!tty)
47652 return 0;
47653
47654 - if (!tty->port.count)
47655 + if (!atomic_read(&tty->port.count))
47656 return 0;
47657
47658 return tty->tx_bytes_queued;
47659 @@ -369,7 +368,7 @@ static int ipw_tiocmget(struct tty_struct *linux_tty)
47660 if (!tty)
47661 return -ENODEV;
47662
47663 - if (!tty->port.count)
47664 + if (!atomic_read(&tty->port.count))
47665 return -EINVAL;
47666
47667 return get_control_lines(tty);
47668 @@ -385,7 +384,7 @@ ipw_tiocmset(struct tty_struct *linux_tty,
47669 if (!tty)
47670 return -ENODEV;
47671
47672 - if (!tty->port.count)
47673 + if (!atomic_read(&tty->port.count))
47674 return -EINVAL;
47675
47676 return set_control_lines(tty, set, clear);
47677 @@ -399,7 +398,7 @@ static int ipw_ioctl(struct tty_struct *linux_tty,
47678 if (!tty)
47679 return -ENODEV;
47680
47681 - if (!tty->port.count)
47682 + if (!atomic_read(&tty->port.count))
47683 return -EINVAL;
47684
47685 /* FIXME: Exactly how is the tty object locked here .. */
47686 @@ -555,7 +554,7 @@ void ipwireless_tty_free(struct ipw_tty *tty)
47687 * are gone */
47688 mutex_lock(&ttyj->ipw_tty_mutex);
47689 }
47690 - while (ttyj->port.count)
47691 + while (atomic_read(&ttyj->port.count))
47692 do_ipw_close(ttyj);
47693 ipwireless_disassociate_network_ttys(network,
47694 ttyj->channel_idx);
47695 diff --git a/drivers/tty/moxa.c b/drivers/tty/moxa.c
47696 index 1deaca4..c8582d4 100644
47697 --- a/drivers/tty/moxa.c
47698 +++ b/drivers/tty/moxa.c
47699 @@ -1189,7 +1189,7 @@ static int moxa_open(struct tty_struct *tty, struct file *filp)
47700 }
47701
47702 ch = &brd->ports[port % MAX_PORTS_PER_BOARD];
47703 - ch->port.count++;
47704 + atomic_inc(&ch->port.count);
47705 tty->driver_data = ch;
47706 tty_port_tty_set(&ch->port, tty);
47707 mutex_lock(&ch->port.mutex);
47708 diff --git a/drivers/tty/n_gsm.c b/drivers/tty/n_gsm.c
47709 index c0f76da..d974c32 100644
47710 --- a/drivers/tty/n_gsm.c
47711 +++ b/drivers/tty/n_gsm.c
47712 @@ -1632,7 +1632,7 @@ static struct gsm_dlci *gsm_dlci_alloc(struct gsm_mux *gsm, int addr)
47713 spin_lock_init(&dlci->lock);
47714 mutex_init(&dlci->mutex);
47715 dlci->fifo = &dlci->_fifo;
47716 - if (kfifo_alloc(&dlci->_fifo, 4096, GFP_KERNEL) < 0) {
47717 + if (kfifo_alloc(&dlci->_fifo, 4096, GFP_KERNEL)) {
47718 kfree(dlci);
47719 return NULL;
47720 }
47721 @@ -2935,7 +2935,7 @@ static int gsmtty_open(struct tty_struct *tty, struct file *filp)
47722 struct gsm_dlci *dlci = tty->driver_data;
47723 struct tty_port *port = &dlci->port;
47724
47725 - port->count++;
47726 + atomic_inc(&port->count);
47727 dlci_get(dlci);
47728 dlci_get(dlci->gsm->dlci[0]);
47729 mux_get(dlci->gsm);
47730 diff --git a/drivers/tty/n_tty.c b/drivers/tty/n_tty.c
47731 index ff58293..71c87bc 100644
47732 --- a/drivers/tty/n_tty.c
47733 +++ b/drivers/tty/n_tty.c
47734 @@ -2502,6 +2502,7 @@ void n_tty_inherit_ops(struct tty_ldisc_ops *ops)
47735 {
47736 *ops = tty_ldisc_N_TTY;
47737 ops->owner = NULL;
47738 - ops->refcount = ops->flags = 0;
47739 + atomic_set(&ops->refcount, 0);
47740 + ops->flags = 0;
47741 }
47742 EXPORT_SYMBOL_GPL(n_tty_inherit_ops);
47743 diff --git a/drivers/tty/pty.c b/drivers/tty/pty.c
47744 index 25c9bc7..24077b7 100644
47745 --- a/drivers/tty/pty.c
47746 +++ b/drivers/tty/pty.c
47747 @@ -790,8 +790,10 @@ static void __init unix98_pty_init(void)
47748 panic("Couldn't register Unix98 pts driver");
47749
47750 /* Now create the /dev/ptmx special device */
47751 + pax_open_kernel();
47752 tty_default_fops(&ptmx_fops);
47753 - ptmx_fops.open = ptmx_open;
47754 + *(void **)&ptmx_fops.open = ptmx_open;
47755 + pax_close_kernel();
47756
47757 cdev_init(&ptmx_cdev, &ptmx_fops);
47758 if (cdev_add(&ptmx_cdev, MKDEV(TTYAUX_MAJOR, 2), 1) ||
47759 diff --git a/drivers/tty/rocket.c b/drivers/tty/rocket.c
47760 index 354564e..fe50d9a 100644
47761 --- a/drivers/tty/rocket.c
47762 +++ b/drivers/tty/rocket.c
47763 @@ -914,7 +914,7 @@ static int rp_open(struct tty_struct *tty, struct file *filp)
47764 tty->driver_data = info;
47765 tty_port_tty_set(port, tty);
47766
47767 - if (port->count++ == 0) {
47768 + if (atomic_inc_return(&port->count) == 1) {
47769 atomic_inc(&rp_num_ports_open);
47770
47771 #ifdef ROCKET_DEBUG_OPEN
47772 @@ -923,7 +923,7 @@ static int rp_open(struct tty_struct *tty, struct file *filp)
47773 #endif
47774 }
47775 #ifdef ROCKET_DEBUG_OPEN
47776 - printk(KERN_INFO "rp_open ttyR%d, count=%d\n", info->line, info->port.count);
47777 + printk(KERN_INFO "rp_open ttyR%d, count=%d\n", info->line, atomic-read(&info->port.count));
47778 #endif
47779
47780 /*
47781 @@ -1515,7 +1515,7 @@ static void rp_hangup(struct tty_struct *tty)
47782 spin_unlock_irqrestore(&info->port.lock, flags);
47783 return;
47784 }
47785 - if (info->port.count)
47786 + if (atomic_read(&info->port.count))
47787 atomic_dec(&rp_num_ports_open);
47788 clear_bit((info->aiop * 8) + info->chan, (void *) &xmit_flags[info->board]);
47789 spin_unlock_irqrestore(&info->port.lock, flags);
47790 diff --git a/drivers/tty/serial/ioc4_serial.c b/drivers/tty/serial/ioc4_serial.c
47791 index 1274499..f541382 100644
47792 --- a/drivers/tty/serial/ioc4_serial.c
47793 +++ b/drivers/tty/serial/ioc4_serial.c
47794 @@ -437,7 +437,7 @@ struct ioc4_soft {
47795 } is_intr_info[MAX_IOC4_INTR_ENTS];
47796
47797 /* Number of entries active in the above array */
47798 - atomic_t is_num_intrs;
47799 + atomic_unchecked_t is_num_intrs;
47800 } is_intr_type[IOC4_NUM_INTR_TYPES];
47801
47802 /* is_ir_lock must be held while
47803 @@ -974,7 +974,7 @@ intr_connect(struct ioc4_soft *soft, int type,
47804 BUG_ON(!((type == IOC4_SIO_INTR_TYPE)
47805 || (type == IOC4_OTHER_INTR_TYPE)));
47806
47807 - i = atomic_inc_return(&soft-> is_intr_type[type].is_num_intrs) - 1;
47808 + i = atomic_inc_return_unchecked(&soft-> is_intr_type[type].is_num_intrs) - 1;
47809 BUG_ON(!(i < MAX_IOC4_INTR_ENTS || (printk("i %d\n", i), 0)));
47810
47811 /* Save off the lower level interrupt handler */
47812 @@ -1001,7 +1001,7 @@ static irqreturn_t ioc4_intr(int irq, void *arg)
47813
47814 soft = arg;
47815 for (intr_type = 0; intr_type < IOC4_NUM_INTR_TYPES; intr_type++) {
47816 - num_intrs = (int)atomic_read(
47817 + num_intrs = (int)atomic_read_unchecked(
47818 &soft->is_intr_type[intr_type].is_num_intrs);
47819
47820 this_mir = this_ir = pending_intrs(soft, intr_type);
47821 diff --git a/drivers/tty/serial/kgdboc.c b/drivers/tty/serial/kgdboc.c
47822 index a260cde..6b2b5ce 100644
47823 --- a/drivers/tty/serial/kgdboc.c
47824 +++ b/drivers/tty/serial/kgdboc.c
47825 @@ -24,8 +24,9 @@
47826 #define MAX_CONFIG_LEN 40
47827
47828 static struct kgdb_io kgdboc_io_ops;
47829 +static struct kgdb_io kgdboc_io_ops_console;
47830
47831 -/* -1 = init not run yet, 0 = unconfigured, 1 = configured. */
47832 +/* -1 = init not run yet, 0 = unconfigured, 1/2 = configured. */
47833 static int configured = -1;
47834
47835 static char config[MAX_CONFIG_LEN];
47836 @@ -151,6 +152,8 @@ static void cleanup_kgdboc(void)
47837 kgdboc_unregister_kbd();
47838 if (configured == 1)
47839 kgdb_unregister_io_module(&kgdboc_io_ops);
47840 + else if (configured == 2)
47841 + kgdb_unregister_io_module(&kgdboc_io_ops_console);
47842 }
47843
47844 static int configure_kgdboc(void)
47845 @@ -160,13 +163,13 @@ static int configure_kgdboc(void)
47846 int err;
47847 char *cptr = config;
47848 struct console *cons;
47849 + int is_console = 0;
47850
47851 err = kgdboc_option_setup(config);
47852 if (err || !strlen(config) || isspace(config[0]))
47853 goto noconfig;
47854
47855 err = -ENODEV;
47856 - kgdboc_io_ops.is_console = 0;
47857 kgdb_tty_driver = NULL;
47858
47859 kgdboc_use_kms = 0;
47860 @@ -187,7 +190,7 @@ static int configure_kgdboc(void)
47861 int idx;
47862 if (cons->device && cons->device(cons, &idx) == p &&
47863 idx == tty_line) {
47864 - kgdboc_io_ops.is_console = 1;
47865 + is_console = 1;
47866 break;
47867 }
47868 cons = cons->next;
47869 @@ -197,7 +200,13 @@ static int configure_kgdboc(void)
47870 kgdb_tty_line = tty_line;
47871
47872 do_register:
47873 - err = kgdb_register_io_module(&kgdboc_io_ops);
47874 + if (is_console) {
47875 + err = kgdb_register_io_module(&kgdboc_io_ops_console);
47876 + configured = 2;
47877 + } else {
47878 + err = kgdb_register_io_module(&kgdboc_io_ops);
47879 + configured = 1;
47880 + }
47881 if (err)
47882 goto noconfig;
47883
47884 @@ -205,8 +214,6 @@ do_register:
47885 if (err)
47886 goto nmi_con_failed;
47887
47888 - configured = 1;
47889 -
47890 return 0;
47891
47892 nmi_con_failed:
47893 @@ -223,7 +230,7 @@ noconfig:
47894 static int __init init_kgdboc(void)
47895 {
47896 /* Already configured? */
47897 - if (configured == 1)
47898 + if (configured >= 1)
47899 return 0;
47900
47901 return configure_kgdboc();
47902 @@ -272,7 +279,7 @@ static int param_set_kgdboc_var(const char *kmessage, struct kernel_param *kp)
47903 if (config[len - 1] == '\n')
47904 config[len - 1] = '\0';
47905
47906 - if (configured == 1)
47907 + if (configured >= 1)
47908 cleanup_kgdboc();
47909
47910 /* Go and configure with the new params. */
47911 @@ -312,6 +319,15 @@ static struct kgdb_io kgdboc_io_ops = {
47912 .post_exception = kgdboc_post_exp_handler,
47913 };
47914
47915 +static struct kgdb_io kgdboc_io_ops_console = {
47916 + .name = "kgdboc",
47917 + .read_char = kgdboc_get_char,
47918 + .write_char = kgdboc_put_char,
47919 + .pre_exception = kgdboc_pre_exp_handler,
47920 + .post_exception = kgdboc_post_exp_handler,
47921 + .is_console = 1
47922 +};
47923 +
47924 #ifdef CONFIG_KGDB_SERIAL_CONSOLE
47925 /* This is only available if kgdboc is a built in for early debugging */
47926 static int __init kgdboc_early_init(char *opt)
47927 diff --git a/drivers/tty/serial/msm_serial.c b/drivers/tty/serial/msm_serial.c
47928 index b5d779c..3622cfe 100644
47929 --- a/drivers/tty/serial/msm_serial.c
47930 +++ b/drivers/tty/serial/msm_serial.c
47931 @@ -897,7 +897,7 @@ static struct uart_driver msm_uart_driver = {
47932 .cons = MSM_CONSOLE,
47933 };
47934
47935 -static atomic_t msm_uart_next_id = ATOMIC_INIT(0);
47936 +static atomic_unchecked_t msm_uart_next_id = ATOMIC_INIT(0);
47937
47938 static const struct of_device_id msm_uartdm_table[] = {
47939 { .compatible = "qcom,msm-uartdm" },
47940 @@ -912,7 +912,7 @@ static int __init msm_serial_probe(struct platform_device *pdev)
47941 int irq;
47942
47943 if (pdev->id == -1)
47944 - pdev->id = atomic_inc_return(&msm_uart_next_id) - 1;
47945 + pdev->id = atomic_inc_return_unchecked(&msm_uart_next_id) - 1;
47946
47947 if (unlikely(pdev->id < 0 || pdev->id >= UART_NR))
47948 return -ENXIO;
47949 diff --git a/drivers/tty/serial/samsung.c b/drivers/tty/serial/samsung.c
47950 index f3dfa19..342f2ff 100644
47951 --- a/drivers/tty/serial/samsung.c
47952 +++ b/drivers/tty/serial/samsung.c
47953 @@ -456,11 +456,16 @@ static void s3c24xx_serial_shutdown(struct uart_port *port)
47954 }
47955 }
47956
47957 +static int s3c64xx_serial_startup(struct uart_port *port);
47958 static int s3c24xx_serial_startup(struct uart_port *port)
47959 {
47960 struct s3c24xx_uart_port *ourport = to_ourport(port);
47961 int ret;
47962
47963 + /* Startup sequence is different for s3c64xx and higher SoC's */
47964 + if (s3c24xx_serial_has_interrupt_mask(port))
47965 + return s3c64xx_serial_startup(port);
47966 +
47967 dbg("s3c24xx_serial_startup: port=%p (%08lx,%p)\n",
47968 port->mapbase, port->membase);
47969
47970 @@ -1127,10 +1132,6 @@ static int s3c24xx_serial_init_port(struct s3c24xx_uart_port *ourport,
47971 /* setup info for port */
47972 port->dev = &platdev->dev;
47973
47974 - /* Startup sequence is different for s3c64xx and higher SoC's */
47975 - if (s3c24xx_serial_has_interrupt_mask(port))
47976 - s3c24xx_serial_ops.startup = s3c64xx_serial_startup;
47977 -
47978 port->uartclk = 1;
47979
47980 if (cfg->uart_flags & UPF_CONS_FLOW) {
47981 diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c
47982 index 0f02351..07c59c5 100644
47983 --- a/drivers/tty/serial/serial_core.c
47984 +++ b/drivers/tty/serial/serial_core.c
47985 @@ -1448,7 +1448,7 @@ static void uart_hangup(struct tty_struct *tty)
47986 uart_flush_buffer(tty);
47987 uart_shutdown(tty, state);
47988 spin_lock_irqsave(&port->lock, flags);
47989 - port->count = 0;
47990 + atomic_set(&port->count, 0);
47991 clear_bit(ASYNCB_NORMAL_ACTIVE, &port->flags);
47992 spin_unlock_irqrestore(&port->lock, flags);
47993 tty_port_tty_set(port, NULL);
47994 @@ -1544,7 +1544,7 @@ static int uart_open(struct tty_struct *tty, struct file *filp)
47995 goto end;
47996 }
47997
47998 - port->count++;
47999 + atomic_inc(&port->count);
48000 if (!state->uart_port || state->uart_port->flags & UPF_DEAD) {
48001 retval = -ENXIO;
48002 goto err_dec_count;
48003 @@ -1572,7 +1572,7 @@ static int uart_open(struct tty_struct *tty, struct file *filp)
48004 /*
48005 * Make sure the device is in D0 state.
48006 */
48007 - if (port->count == 1)
48008 + if (atomic_read(&port->count) == 1)
48009 uart_change_pm(state, UART_PM_STATE_ON);
48010
48011 /*
48012 @@ -1590,7 +1590,7 @@ static int uart_open(struct tty_struct *tty, struct file *filp)
48013 end:
48014 return retval;
48015 err_dec_count:
48016 - port->count--;
48017 + atomic_inc(&port->count);
48018 mutex_unlock(&port->mutex);
48019 goto end;
48020 }
48021 diff --git a/drivers/tty/synclink.c b/drivers/tty/synclink.c
48022 index e1ce141..6d4ed80 100644
48023 --- a/drivers/tty/synclink.c
48024 +++ b/drivers/tty/synclink.c
48025 @@ -3090,7 +3090,7 @@ static void mgsl_close(struct tty_struct *tty, struct file * filp)
48026
48027 if (debug_level >= DEBUG_LEVEL_INFO)
48028 printk("%s(%d):mgsl_close(%s) entry, count=%d\n",
48029 - __FILE__,__LINE__, info->device_name, info->port.count);
48030 + __FILE__,__LINE__, info->device_name, atomic_read(&info->port.count));
48031
48032 if (tty_port_close_start(&info->port, tty, filp) == 0)
48033 goto cleanup;
48034 @@ -3108,7 +3108,7 @@ static void mgsl_close(struct tty_struct *tty, struct file * filp)
48035 cleanup:
48036 if (debug_level >= DEBUG_LEVEL_INFO)
48037 printk("%s(%d):mgsl_close(%s) exit, count=%d\n", __FILE__,__LINE__,
48038 - tty->driver->name, info->port.count);
48039 + tty->driver->name, atomic_read(&info->port.count));
48040
48041 } /* end of mgsl_close() */
48042
48043 @@ -3207,8 +3207,8 @@ static void mgsl_hangup(struct tty_struct *tty)
48044
48045 mgsl_flush_buffer(tty);
48046 shutdown(info);
48047 -
48048 - info->port.count = 0;
48049 +
48050 + atomic_set(&info->port.count, 0);
48051 info->port.flags &= ~ASYNC_NORMAL_ACTIVE;
48052 info->port.tty = NULL;
48053
48054 @@ -3297,12 +3297,12 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp,
48055
48056 if (debug_level >= DEBUG_LEVEL_INFO)
48057 printk("%s(%d):block_til_ready before block on %s count=%d\n",
48058 - __FILE__,__LINE__, tty->driver->name, port->count );
48059 + __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
48060
48061 spin_lock_irqsave(&info->irq_spinlock, flags);
48062 if (!tty_hung_up_p(filp)) {
48063 extra_count = true;
48064 - port->count--;
48065 + atomic_dec(&port->count);
48066 }
48067 spin_unlock_irqrestore(&info->irq_spinlock, flags);
48068 port->blocked_open++;
48069 @@ -3331,7 +3331,7 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp,
48070
48071 if (debug_level >= DEBUG_LEVEL_INFO)
48072 printk("%s(%d):block_til_ready blocking on %s count=%d\n",
48073 - __FILE__,__LINE__, tty->driver->name, port->count );
48074 + __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
48075
48076 tty_unlock(tty);
48077 schedule();
48078 @@ -3343,12 +3343,12 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp,
48079
48080 /* FIXME: Racy on hangup during close wait */
48081 if (extra_count)
48082 - port->count++;
48083 + atomic_inc(&port->count);
48084 port->blocked_open--;
48085
48086 if (debug_level >= DEBUG_LEVEL_INFO)
48087 printk("%s(%d):block_til_ready after blocking on %s count=%d\n",
48088 - __FILE__,__LINE__, tty->driver->name, port->count );
48089 + __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
48090
48091 if (!retval)
48092 port->flags |= ASYNC_NORMAL_ACTIVE;
48093 @@ -3400,7 +3400,7 @@ static int mgsl_open(struct tty_struct *tty, struct file * filp)
48094
48095 if (debug_level >= DEBUG_LEVEL_INFO)
48096 printk("%s(%d):mgsl_open(%s), old ref count = %d\n",
48097 - __FILE__,__LINE__,tty->driver->name, info->port.count);
48098 + __FILE__,__LINE__,tty->driver->name, atomic_read(&info->port.count));
48099
48100 /* If port is closing, signal caller to try again */
48101 if (tty_hung_up_p(filp) || info->port.flags & ASYNC_CLOSING){
48102 @@ -3419,10 +3419,10 @@ static int mgsl_open(struct tty_struct *tty, struct file * filp)
48103 spin_unlock_irqrestore(&info->netlock, flags);
48104 goto cleanup;
48105 }
48106 - info->port.count++;
48107 + atomic_inc(&info->port.count);
48108 spin_unlock_irqrestore(&info->netlock, flags);
48109
48110 - if (info->port.count == 1) {
48111 + if (atomic_read(&info->port.count) == 1) {
48112 /* 1st open on this device, init hardware */
48113 retval = startup(info);
48114 if (retval < 0)
48115 @@ -3446,8 +3446,8 @@ cleanup:
48116 if (retval) {
48117 if (tty->count == 1)
48118 info->port.tty = NULL; /* tty layer will release tty struct */
48119 - if(info->port.count)
48120 - info->port.count--;
48121 + if (atomic_read(&info->port.count))
48122 + atomic_dec(&info->port.count);
48123 }
48124
48125 return retval;
48126 @@ -7665,7 +7665,7 @@ static int hdlcdev_attach(struct net_device *dev, unsigned short encoding,
48127 unsigned short new_crctype;
48128
48129 /* return error if TTY interface open */
48130 - if (info->port.count)
48131 + if (atomic_read(&info->port.count))
48132 return -EBUSY;
48133
48134 switch (encoding)
48135 @@ -7760,7 +7760,7 @@ static int hdlcdev_open(struct net_device *dev)
48136
48137 /* arbitrate between network and tty opens */
48138 spin_lock_irqsave(&info->netlock, flags);
48139 - if (info->port.count != 0 || info->netcount != 0) {
48140 + if (atomic_read(&info->port.count) != 0 || info->netcount != 0) {
48141 printk(KERN_WARNING "%s: hdlc_open returning busy\n", dev->name);
48142 spin_unlock_irqrestore(&info->netlock, flags);
48143 return -EBUSY;
48144 @@ -7846,7 +7846,7 @@ static int hdlcdev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
48145 printk("%s:hdlcdev_ioctl(%s)\n",__FILE__,dev->name);
48146
48147 /* return error if TTY interface open */
48148 - if (info->port.count)
48149 + if (atomic_read(&info->port.count))
48150 return -EBUSY;
48151
48152 if (cmd != SIOCWANDEV)
48153 diff --git a/drivers/tty/synclink_gt.c b/drivers/tty/synclink_gt.c
48154 index 1abf946..1ee34fc 100644
48155 --- a/drivers/tty/synclink_gt.c
48156 +++ b/drivers/tty/synclink_gt.c
48157 @@ -670,7 +670,7 @@ static int open(struct tty_struct *tty, struct file *filp)
48158 tty->driver_data = info;
48159 info->port.tty = tty;
48160
48161 - DBGINFO(("%s open, old ref count = %d\n", info->device_name, info->port.count));
48162 + DBGINFO(("%s open, old ref count = %d\n", info->device_name, atomic_read(&info->port.count)));
48163
48164 /* If port is closing, signal caller to try again */
48165 if (tty_hung_up_p(filp) || info->port.flags & ASYNC_CLOSING){
48166 @@ -691,10 +691,10 @@ static int open(struct tty_struct *tty, struct file *filp)
48167 mutex_unlock(&info->port.mutex);
48168 goto cleanup;
48169 }
48170 - info->port.count++;
48171 + atomic_inc(&info->port.count);
48172 spin_unlock_irqrestore(&info->netlock, flags);
48173
48174 - if (info->port.count == 1) {
48175 + if (atomic_read(&info->port.count) == 1) {
48176 /* 1st open on this device, init hardware */
48177 retval = startup(info);
48178 if (retval < 0) {
48179 @@ -715,8 +715,8 @@ cleanup:
48180 if (retval) {
48181 if (tty->count == 1)
48182 info->port.tty = NULL; /* tty layer will release tty struct */
48183 - if(info->port.count)
48184 - info->port.count--;
48185 + if(atomic_read(&info->port.count))
48186 + atomic_dec(&info->port.count);
48187 }
48188
48189 DBGINFO(("%s open rc=%d\n", info->device_name, retval));
48190 @@ -729,7 +729,7 @@ static void close(struct tty_struct *tty, struct file *filp)
48191
48192 if (sanity_check(info, tty->name, "close"))
48193 return;
48194 - DBGINFO(("%s close entry, count=%d\n", info->device_name, info->port.count));
48195 + DBGINFO(("%s close entry, count=%d\n", info->device_name, atomic_read(&info->port.count)));
48196
48197 if (tty_port_close_start(&info->port, tty, filp) == 0)
48198 goto cleanup;
48199 @@ -746,7 +746,7 @@ static void close(struct tty_struct *tty, struct file *filp)
48200 tty_port_close_end(&info->port, tty);
48201 info->port.tty = NULL;
48202 cleanup:
48203 - DBGINFO(("%s close exit, count=%d\n", tty->driver->name, info->port.count));
48204 + DBGINFO(("%s close exit, count=%d\n", tty->driver->name, atomic_read(&info->port.count)));
48205 }
48206
48207 static void hangup(struct tty_struct *tty)
48208 @@ -764,7 +764,7 @@ static void hangup(struct tty_struct *tty)
48209 shutdown(info);
48210
48211 spin_lock_irqsave(&info->port.lock, flags);
48212 - info->port.count = 0;
48213 + atomic_set(&info->port.count, 0);
48214 info->port.flags &= ~ASYNC_NORMAL_ACTIVE;
48215 info->port.tty = NULL;
48216 spin_unlock_irqrestore(&info->port.lock, flags);
48217 @@ -1449,7 +1449,7 @@ static int hdlcdev_attach(struct net_device *dev, unsigned short encoding,
48218 unsigned short new_crctype;
48219
48220 /* return error if TTY interface open */
48221 - if (info->port.count)
48222 + if (atomic_read(&info->port.count))
48223 return -EBUSY;
48224
48225 DBGINFO(("%s hdlcdev_attach\n", info->device_name));
48226 @@ -1544,7 +1544,7 @@ static int hdlcdev_open(struct net_device *dev)
48227
48228 /* arbitrate between network and tty opens */
48229 spin_lock_irqsave(&info->netlock, flags);
48230 - if (info->port.count != 0 || info->netcount != 0) {
48231 + if (atomic_read(&info->port.count) != 0 || info->netcount != 0) {
48232 DBGINFO(("%s hdlc_open busy\n", dev->name));
48233 spin_unlock_irqrestore(&info->netlock, flags);
48234 return -EBUSY;
48235 @@ -1629,7 +1629,7 @@ static int hdlcdev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
48236 DBGINFO(("%s hdlcdev_ioctl\n", dev->name));
48237
48238 /* return error if TTY interface open */
48239 - if (info->port.count)
48240 + if (atomic_read(&info->port.count))
48241 return -EBUSY;
48242
48243 if (cmd != SIOCWANDEV)
48244 @@ -2413,7 +2413,7 @@ static irqreturn_t slgt_interrupt(int dummy, void *dev_id)
48245 if (port == NULL)
48246 continue;
48247 spin_lock(&port->lock);
48248 - if ((port->port.count || port->netcount) &&
48249 + if ((atomic_read(&port->port.count) || port->netcount) &&
48250 port->pending_bh && !port->bh_running &&
48251 !port->bh_requested) {
48252 DBGISR(("%s bh queued\n", port->device_name));
48253 @@ -3302,7 +3302,7 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
48254 spin_lock_irqsave(&info->lock, flags);
48255 if (!tty_hung_up_p(filp)) {
48256 extra_count = true;
48257 - port->count--;
48258 + atomic_dec(&port->count);
48259 }
48260 spin_unlock_irqrestore(&info->lock, flags);
48261 port->blocked_open++;
48262 @@ -3339,7 +3339,7 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
48263 remove_wait_queue(&port->open_wait, &wait);
48264
48265 if (extra_count)
48266 - port->count++;
48267 + atomic_inc(&port->count);
48268 port->blocked_open--;
48269
48270 if (!retval)
48271 diff --git a/drivers/tty/synclinkmp.c b/drivers/tty/synclinkmp.c
48272 index dc6e969..5dc8786 100644
48273 --- a/drivers/tty/synclinkmp.c
48274 +++ b/drivers/tty/synclinkmp.c
48275 @@ -750,7 +750,7 @@ static int open(struct tty_struct *tty, struct file *filp)
48276
48277 if (debug_level >= DEBUG_LEVEL_INFO)
48278 printk("%s(%d):%s open(), old ref count = %d\n",
48279 - __FILE__,__LINE__,tty->driver->name, info->port.count);
48280 + __FILE__,__LINE__,tty->driver->name, atomic_read(&info->port.count));
48281
48282 /* If port is closing, signal caller to try again */
48283 if (tty_hung_up_p(filp) || info->port.flags & ASYNC_CLOSING){
48284 @@ -769,10 +769,10 @@ static int open(struct tty_struct *tty, struct file *filp)
48285 spin_unlock_irqrestore(&info->netlock, flags);
48286 goto cleanup;
48287 }
48288 - info->port.count++;
48289 + atomic_inc(&info->port.count);
48290 spin_unlock_irqrestore(&info->netlock, flags);
48291
48292 - if (info->port.count == 1) {
48293 + if (atomic_read(&info->port.count) == 1) {
48294 /* 1st open on this device, init hardware */
48295 retval = startup(info);
48296 if (retval < 0)
48297 @@ -796,8 +796,8 @@ cleanup:
48298 if (retval) {
48299 if (tty->count == 1)
48300 info->port.tty = NULL; /* tty layer will release tty struct */
48301 - if(info->port.count)
48302 - info->port.count--;
48303 + if(atomic_read(&info->port.count))
48304 + atomic_dec(&info->port.count);
48305 }
48306
48307 return retval;
48308 @@ -815,7 +815,7 @@ static void close(struct tty_struct *tty, struct file *filp)
48309
48310 if (debug_level >= DEBUG_LEVEL_INFO)
48311 printk("%s(%d):%s close() entry, count=%d\n",
48312 - __FILE__,__LINE__, info->device_name, info->port.count);
48313 + __FILE__,__LINE__, info->device_name, atomic_read(&info->port.count));
48314
48315 if (tty_port_close_start(&info->port, tty, filp) == 0)
48316 goto cleanup;
48317 @@ -834,7 +834,7 @@ static void close(struct tty_struct *tty, struct file *filp)
48318 cleanup:
48319 if (debug_level >= DEBUG_LEVEL_INFO)
48320 printk("%s(%d):%s close() exit, count=%d\n", __FILE__,__LINE__,
48321 - tty->driver->name, info->port.count);
48322 + tty->driver->name, atomic_read(&info->port.count));
48323 }
48324
48325 /* Called by tty_hangup() when a hangup is signaled.
48326 @@ -857,7 +857,7 @@ static void hangup(struct tty_struct *tty)
48327 shutdown(info);
48328
48329 spin_lock_irqsave(&info->port.lock, flags);
48330 - info->port.count = 0;
48331 + atomic_set(&info->port.count, 0);
48332 info->port.flags &= ~ASYNC_NORMAL_ACTIVE;
48333 info->port.tty = NULL;
48334 spin_unlock_irqrestore(&info->port.lock, flags);
48335 @@ -1565,7 +1565,7 @@ static int hdlcdev_attach(struct net_device *dev, unsigned short encoding,
48336 unsigned short new_crctype;
48337
48338 /* return error if TTY interface open */
48339 - if (info->port.count)
48340 + if (atomic_read(&info->port.count))
48341 return -EBUSY;
48342
48343 switch (encoding)
48344 @@ -1660,7 +1660,7 @@ static int hdlcdev_open(struct net_device *dev)
48345
48346 /* arbitrate between network and tty opens */
48347 spin_lock_irqsave(&info->netlock, flags);
48348 - if (info->port.count != 0 || info->netcount != 0) {
48349 + if (atomic_read(&info->port.count) != 0 || info->netcount != 0) {
48350 printk(KERN_WARNING "%s: hdlc_open returning busy\n", dev->name);
48351 spin_unlock_irqrestore(&info->netlock, flags);
48352 return -EBUSY;
48353 @@ -1746,7 +1746,7 @@ static int hdlcdev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
48354 printk("%s:hdlcdev_ioctl(%s)\n",__FILE__,dev->name);
48355
48356 /* return error if TTY interface open */
48357 - if (info->port.count)
48358 + if (atomic_read(&info->port.count))
48359 return -EBUSY;
48360
48361 if (cmd != SIOCWANDEV)
48362 @@ -2620,7 +2620,7 @@ static irqreturn_t synclinkmp_interrupt(int dummy, void *dev_id)
48363 * do not request bottom half processing if the
48364 * device is not open in a normal mode.
48365 */
48366 - if ( port && (port->port.count || port->netcount) &&
48367 + if ( port && (atomic_read(&port->port.count) || port->netcount) &&
48368 port->pending_bh && !port->bh_running &&
48369 !port->bh_requested ) {
48370 if ( debug_level >= DEBUG_LEVEL_ISR )
48371 @@ -3318,12 +3318,12 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
48372
48373 if (debug_level >= DEBUG_LEVEL_INFO)
48374 printk("%s(%d):%s block_til_ready() before block, count=%d\n",
48375 - __FILE__,__LINE__, tty->driver->name, port->count );
48376 + __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
48377
48378 spin_lock_irqsave(&info->lock, flags);
48379 if (!tty_hung_up_p(filp)) {
48380 extra_count = true;
48381 - port->count--;
48382 + atomic_dec(&port->count);
48383 }
48384 spin_unlock_irqrestore(&info->lock, flags);
48385 port->blocked_open++;
48386 @@ -3352,7 +3352,7 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
48387
48388 if (debug_level >= DEBUG_LEVEL_INFO)
48389 printk("%s(%d):%s block_til_ready() count=%d\n",
48390 - __FILE__,__LINE__, tty->driver->name, port->count );
48391 + __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
48392
48393 tty_unlock(tty);
48394 schedule();
48395 @@ -3363,12 +3363,12 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
48396 remove_wait_queue(&port->open_wait, &wait);
48397
48398 if (extra_count)
48399 - port->count++;
48400 + atomic_inc(&port->count);
48401 port->blocked_open--;
48402
48403 if (debug_level >= DEBUG_LEVEL_INFO)
48404 printk("%s(%d):%s block_til_ready() after, count=%d\n",
48405 - __FILE__,__LINE__, tty->driver->name, port->count );
48406 + __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
48407
48408 if (!retval)
48409 port->flags |= ASYNC_NORMAL_ACTIVE;
48410 diff --git a/drivers/tty/sysrq.c b/drivers/tty/sysrq.c
48411 index 40a9fe9..a3f10cc 100644
48412 --- a/drivers/tty/sysrq.c
48413 +++ b/drivers/tty/sysrq.c
48414 @@ -1075,7 +1075,7 @@ EXPORT_SYMBOL(unregister_sysrq_key);
48415 static ssize_t write_sysrq_trigger(struct file *file, const char __user *buf,
48416 size_t count, loff_t *ppos)
48417 {
48418 - if (count) {
48419 + if (count && capable(CAP_SYS_ADMIN)) {
48420 char c;
48421
48422 if (get_user(c, buf))
48423 diff --git a/drivers/tty/tty_io.c b/drivers/tty/tty_io.c
48424 index c74a00a..02cf211a 100644
48425 --- a/drivers/tty/tty_io.c
48426 +++ b/drivers/tty/tty_io.c
48427 @@ -3474,7 +3474,7 @@ EXPORT_SYMBOL_GPL(get_current_tty);
48428
48429 void tty_default_fops(struct file_operations *fops)
48430 {
48431 - *fops = tty_fops;
48432 + memcpy((void *)fops, &tty_fops, sizeof(tty_fops));
48433 }
48434
48435 /*
48436 diff --git a/drivers/tty/tty_ldisc.c b/drivers/tty/tty_ldisc.c
48437 index 6458e11..6cfc218 100644
48438 --- a/drivers/tty/tty_ldisc.c
48439 +++ b/drivers/tty/tty_ldisc.c
48440 @@ -72,7 +72,7 @@ int tty_register_ldisc(int disc, struct tty_ldisc_ops *new_ldisc)
48441 raw_spin_lock_irqsave(&tty_ldiscs_lock, flags);
48442 tty_ldiscs[disc] = new_ldisc;
48443 new_ldisc->num = disc;
48444 - new_ldisc->refcount = 0;
48445 + atomic_set(&new_ldisc->refcount, 0);
48446 raw_spin_unlock_irqrestore(&tty_ldiscs_lock, flags);
48447
48448 return ret;
48449 @@ -100,7 +100,7 @@ int tty_unregister_ldisc(int disc)
48450 return -EINVAL;
48451
48452 raw_spin_lock_irqsave(&tty_ldiscs_lock, flags);
48453 - if (tty_ldiscs[disc]->refcount)
48454 + if (atomic_read(&tty_ldiscs[disc]->refcount))
48455 ret = -EBUSY;
48456 else
48457 tty_ldiscs[disc] = NULL;
48458 @@ -121,7 +121,7 @@ static struct tty_ldisc_ops *get_ldops(int disc)
48459 if (ldops) {
48460 ret = ERR_PTR(-EAGAIN);
48461 if (try_module_get(ldops->owner)) {
48462 - ldops->refcount++;
48463 + atomic_inc(&ldops->refcount);
48464 ret = ldops;
48465 }
48466 }
48467 @@ -134,7 +134,7 @@ static void put_ldops(struct tty_ldisc_ops *ldops)
48468 unsigned long flags;
48469
48470 raw_spin_lock_irqsave(&tty_ldiscs_lock, flags);
48471 - ldops->refcount--;
48472 + atomic_dec(&ldops->refcount);
48473 module_put(ldops->owner);
48474 raw_spin_unlock_irqrestore(&tty_ldiscs_lock, flags);
48475 }
48476 diff --git a/drivers/tty/tty_port.c b/drivers/tty/tty_port.c
48477 index f597e88..b7f68ed 100644
48478 --- a/drivers/tty/tty_port.c
48479 +++ b/drivers/tty/tty_port.c
48480 @@ -232,7 +232,7 @@ void tty_port_hangup(struct tty_port *port)
48481 unsigned long flags;
48482
48483 spin_lock_irqsave(&port->lock, flags);
48484 - port->count = 0;
48485 + atomic_set(&port->count, 0);
48486 port->flags &= ~ASYNC_NORMAL_ACTIVE;
48487 tty = port->tty;
48488 if (tty)
48489 @@ -390,7 +390,7 @@ int tty_port_block_til_ready(struct tty_port *port,
48490 /* The port lock protects the port counts */
48491 spin_lock_irqsave(&port->lock, flags);
48492 if (!tty_hung_up_p(filp))
48493 - port->count--;
48494 + atomic_dec(&port->count);
48495 port->blocked_open++;
48496 spin_unlock_irqrestore(&port->lock, flags);
48497
48498 @@ -432,7 +432,7 @@ int tty_port_block_til_ready(struct tty_port *port,
48499 we must not mess that up further */
48500 spin_lock_irqsave(&port->lock, flags);
48501 if (!tty_hung_up_p(filp))
48502 - port->count++;
48503 + atomic_inc(&port->count);
48504 port->blocked_open--;
48505 if (retval == 0)
48506 port->flags |= ASYNC_NORMAL_ACTIVE;
48507 @@ -466,19 +466,19 @@ int tty_port_close_start(struct tty_port *port,
48508 return 0;
48509 }
48510
48511 - if (tty->count == 1 && port->count != 1) {
48512 + if (tty->count == 1 && atomic_read(&port->count) != 1) {
48513 printk(KERN_WARNING
48514 "tty_port_close_start: tty->count = 1 port count = %d.\n",
48515 - port->count);
48516 - port->count = 1;
48517 + atomic_read(&port->count));
48518 + atomic_set(&port->count, 1);
48519 }
48520 - if (--port->count < 0) {
48521 + if (atomic_dec_return(&port->count) < 0) {
48522 printk(KERN_WARNING "tty_port_close_start: count = %d\n",
48523 - port->count);
48524 - port->count = 0;
48525 + atomic_read(&port->count));
48526 + atomic_set(&port->count, 0);
48527 }
48528
48529 - if (port->count) {
48530 + if (atomic_read(&port->count)) {
48531 spin_unlock_irqrestore(&port->lock, flags);
48532 if (port->ops->drop)
48533 port->ops->drop(port);
48534 @@ -564,7 +564,7 @@ int tty_port_open(struct tty_port *port, struct tty_struct *tty,
48535 {
48536 spin_lock_irq(&port->lock);
48537 if (!tty_hung_up_p(filp))
48538 - ++port->count;
48539 + atomic_inc(&port->count);
48540 spin_unlock_irq(&port->lock);
48541 tty_port_tty_set(port, tty);
48542
48543 diff --git a/drivers/tty/vt/keyboard.c b/drivers/tty/vt/keyboard.c
48544 index d0e3a44..5f8b754 100644
48545 --- a/drivers/tty/vt/keyboard.c
48546 +++ b/drivers/tty/vt/keyboard.c
48547 @@ -641,6 +641,16 @@ static void k_spec(struct vc_data *vc, unsigned char value, char up_flag)
48548 kbd->kbdmode == VC_OFF) &&
48549 value != KVAL(K_SAK))
48550 return; /* SAK is allowed even in raw mode */
48551 +
48552 +#if defined(CONFIG_GRKERNSEC_PROC) || defined(CONFIG_GRKERNSEC_PROC_MEMMAP)
48553 + {
48554 + void *func = fn_handler[value];
48555 + if (func == fn_show_state || func == fn_show_ptregs ||
48556 + func == fn_show_mem)
48557 + return;
48558 + }
48559 +#endif
48560 +
48561 fn_handler[value](vc);
48562 }
48563
48564 @@ -1776,9 +1786,6 @@ int vt_do_kdsk_ioctl(int cmd, struct kbentry __user *user_kbe, int perm,
48565 if (copy_from_user(&tmp, user_kbe, sizeof(struct kbentry)))
48566 return -EFAULT;
48567
48568 - if (!capable(CAP_SYS_TTY_CONFIG))
48569 - perm = 0;
48570 -
48571 switch (cmd) {
48572 case KDGKBENT:
48573 /* Ensure another thread doesn't free it under us */
48574 @@ -1793,6 +1800,9 @@ int vt_do_kdsk_ioctl(int cmd, struct kbentry __user *user_kbe, int perm,
48575 spin_unlock_irqrestore(&kbd_event_lock, flags);
48576 return put_user(val, &user_kbe->kb_value);
48577 case KDSKBENT:
48578 + if (!capable(CAP_SYS_TTY_CONFIG))
48579 + perm = 0;
48580 +
48581 if (!perm)
48582 return -EPERM;
48583 if (!i && v == K_NOSUCHMAP) {
48584 @@ -1883,9 +1893,6 @@ int vt_do_kdgkb_ioctl(int cmd, struct kbsentry __user *user_kdgkb, int perm)
48585 int i, j, k;
48586 int ret;
48587
48588 - if (!capable(CAP_SYS_TTY_CONFIG))
48589 - perm = 0;
48590 -
48591 kbs = kmalloc(sizeof(*kbs), GFP_KERNEL);
48592 if (!kbs) {
48593 ret = -ENOMEM;
48594 @@ -1919,6 +1926,9 @@ int vt_do_kdgkb_ioctl(int cmd, struct kbsentry __user *user_kdgkb, int perm)
48595 kfree(kbs);
48596 return ((p && *p) ? -EOVERFLOW : 0);
48597 case KDSKBSENT:
48598 + if (!capable(CAP_SYS_TTY_CONFIG))
48599 + perm = 0;
48600 +
48601 if (!perm) {
48602 ret = -EPERM;
48603 goto reterr;
48604 diff --git a/drivers/uio/uio.c b/drivers/uio/uio.c
48605 index 0e808cf..d7d274b 100644
48606 --- a/drivers/uio/uio.c
48607 +++ b/drivers/uio/uio.c
48608 @@ -25,6 +25,7 @@
48609 #include <linux/kobject.h>
48610 #include <linux/cdev.h>
48611 #include <linux/uio_driver.h>
48612 +#include <asm/local.h>
48613
48614 #define UIO_MAX_DEVICES (1U << MINORBITS)
48615
48616 @@ -32,7 +33,7 @@ struct uio_device {
48617 struct module *owner;
48618 struct device *dev;
48619 int minor;
48620 - atomic_t event;
48621 + atomic_unchecked_t event;
48622 struct fasync_struct *async_queue;
48623 wait_queue_head_t wait;
48624 struct uio_info *info;
48625 @@ -243,7 +244,7 @@ static ssize_t event_show(struct device *dev,
48626 struct device_attribute *attr, char *buf)
48627 {
48628 struct uio_device *idev = dev_get_drvdata(dev);
48629 - return sprintf(buf, "%u\n", (unsigned int)atomic_read(&idev->event));
48630 + return sprintf(buf, "%u\n", (unsigned int)atomic_read_unchecked(&idev->event));
48631 }
48632 static DEVICE_ATTR_RO(event);
48633
48634 @@ -401,7 +402,7 @@ void uio_event_notify(struct uio_info *info)
48635 {
48636 struct uio_device *idev = info->uio_dev;
48637
48638 - atomic_inc(&idev->event);
48639 + atomic_inc_unchecked(&idev->event);
48640 wake_up_interruptible(&idev->wait);
48641 kill_fasync(&idev->async_queue, SIGIO, POLL_IN);
48642 }
48643 @@ -454,7 +455,7 @@ static int uio_open(struct inode *inode, struct file *filep)
48644 }
48645
48646 listener->dev = idev;
48647 - listener->event_count = atomic_read(&idev->event);
48648 + listener->event_count = atomic_read_unchecked(&idev->event);
48649 filep->private_data = listener;
48650
48651 if (idev->info->open) {
48652 @@ -505,7 +506,7 @@ static unsigned int uio_poll(struct file *filep, poll_table *wait)
48653 return -EIO;
48654
48655 poll_wait(filep, &idev->wait, wait);
48656 - if (listener->event_count != atomic_read(&idev->event))
48657 + if (listener->event_count != atomic_read_unchecked(&idev->event))
48658 return POLLIN | POLLRDNORM;
48659 return 0;
48660 }
48661 @@ -530,7 +531,7 @@ static ssize_t uio_read(struct file *filep, char __user *buf,
48662 do {
48663 set_current_state(TASK_INTERRUPTIBLE);
48664
48665 - event_count = atomic_read(&idev->event);
48666 + event_count = atomic_read_unchecked(&idev->event);
48667 if (event_count != listener->event_count) {
48668 if (copy_to_user(buf, &event_count, count))
48669 retval = -EFAULT;
48670 @@ -587,9 +588,13 @@ static ssize_t uio_write(struct file *filep, const char __user *buf,
48671 static int uio_find_mem_index(struct vm_area_struct *vma)
48672 {
48673 struct uio_device *idev = vma->vm_private_data;
48674 + unsigned long size;
48675
48676 if (vma->vm_pgoff < MAX_UIO_MAPS) {
48677 - if (idev->info->mem[vma->vm_pgoff].size == 0)
48678 + size = idev->info->mem[vma->vm_pgoff].size;
48679 + if (size == 0)
48680 + return -1;
48681 + if (vma->vm_end - vma->vm_start > size)
48682 return -1;
48683 return (int)vma->vm_pgoff;
48684 }
48685 @@ -647,6 +652,8 @@ static int uio_mmap_physical(struct vm_area_struct *vma)
48686 return -EINVAL;
48687 mem = idev->info->mem + mi;
48688
48689 + if (mem->addr & ~PAGE_MASK)
48690 + return -ENODEV;
48691 if (vma->vm_end - vma->vm_start > mem->size)
48692 return -EINVAL;
48693
48694 @@ -818,7 +825,7 @@ int __uio_register_device(struct module *owner,
48695 idev->owner = owner;
48696 idev->info = info;
48697 init_waitqueue_head(&idev->wait);
48698 - atomic_set(&idev->event, 0);
48699 + atomic_set_unchecked(&idev->event, 0);
48700
48701 ret = uio_get_minor(idev);
48702 if (ret)
48703 diff --git a/drivers/usb/atm/cxacru.c b/drivers/usb/atm/cxacru.c
48704 index 8a7eb77..c00402f 100644
48705 --- a/drivers/usb/atm/cxacru.c
48706 +++ b/drivers/usb/atm/cxacru.c
48707 @@ -473,7 +473,7 @@ static ssize_t cxacru_sysfs_store_adsl_config(struct device *dev,
48708 ret = sscanf(buf + pos, "%x=%x%n", &index, &value, &tmp);
48709 if (ret < 2)
48710 return -EINVAL;
48711 - if (index < 0 || index > 0x7f)
48712 + if (index > 0x7f)
48713 return -EINVAL;
48714 pos += tmp;
48715
48716 diff --git a/drivers/usb/atm/usbatm.c b/drivers/usb/atm/usbatm.c
48717 index 25a7bfc..57f3cf5 100644
48718 --- a/drivers/usb/atm/usbatm.c
48719 +++ b/drivers/usb/atm/usbatm.c
48720 @@ -331,7 +331,7 @@ static void usbatm_extract_one_cell(struct usbatm_data *instance, unsigned char
48721 if (printk_ratelimit())
48722 atm_warn(instance, "%s: OAM not supported (vpi %d, vci %d)!\n",
48723 __func__, vpi, vci);
48724 - atomic_inc(&vcc->stats->rx_err);
48725 + atomic_inc_unchecked(&vcc->stats->rx_err);
48726 return;
48727 }
48728
48729 @@ -358,7 +358,7 @@ static void usbatm_extract_one_cell(struct usbatm_data *instance, unsigned char
48730 if (length > ATM_MAX_AAL5_PDU) {
48731 atm_rldbg(instance, "%s: bogus length %u (vcc: 0x%p)!\n",
48732 __func__, length, vcc);
48733 - atomic_inc(&vcc->stats->rx_err);
48734 + atomic_inc_unchecked(&vcc->stats->rx_err);
48735 goto out;
48736 }
48737
48738 @@ -367,14 +367,14 @@ static void usbatm_extract_one_cell(struct usbatm_data *instance, unsigned char
48739 if (sarb->len < pdu_length) {
48740 atm_rldbg(instance, "%s: bogus pdu_length %u (sarb->len: %u, vcc: 0x%p)!\n",
48741 __func__, pdu_length, sarb->len, vcc);
48742 - atomic_inc(&vcc->stats->rx_err);
48743 + atomic_inc_unchecked(&vcc->stats->rx_err);
48744 goto out;
48745 }
48746
48747 if (crc32_be(~0, skb_tail_pointer(sarb) - pdu_length, pdu_length) != 0xc704dd7b) {
48748 atm_rldbg(instance, "%s: packet failed crc check (vcc: 0x%p)!\n",
48749 __func__, vcc);
48750 - atomic_inc(&vcc->stats->rx_err);
48751 + atomic_inc_unchecked(&vcc->stats->rx_err);
48752 goto out;
48753 }
48754
48755 @@ -386,7 +386,7 @@ static void usbatm_extract_one_cell(struct usbatm_data *instance, unsigned char
48756 if (printk_ratelimit())
48757 atm_err(instance, "%s: no memory for skb (length: %u)!\n",
48758 __func__, length);
48759 - atomic_inc(&vcc->stats->rx_drop);
48760 + atomic_inc_unchecked(&vcc->stats->rx_drop);
48761 goto out;
48762 }
48763
48764 @@ -414,7 +414,7 @@ static void usbatm_extract_one_cell(struct usbatm_data *instance, unsigned char
48765
48766 vcc->push(vcc, skb);
48767
48768 - atomic_inc(&vcc->stats->rx);
48769 + atomic_inc_unchecked(&vcc->stats->rx);
48770 out:
48771 skb_trim(sarb, 0);
48772 }
48773 @@ -612,7 +612,7 @@ static void usbatm_tx_process(unsigned long data)
48774 struct atm_vcc *vcc = UDSL_SKB(skb)->atm.vcc;
48775
48776 usbatm_pop(vcc, skb);
48777 - atomic_inc(&vcc->stats->tx);
48778 + atomic_inc_unchecked(&vcc->stats->tx);
48779
48780 skb = skb_dequeue(&instance->sndqueue);
48781 }
48782 @@ -756,11 +756,11 @@ static int usbatm_atm_proc_read(struct atm_dev *atm_dev, loff_t * pos, char *pag
48783 if (!left--)
48784 return sprintf(page,
48785 "AAL5: tx %d ( %d err ), rx %d ( %d err, %d drop )\n",
48786 - atomic_read(&atm_dev->stats.aal5.tx),
48787 - atomic_read(&atm_dev->stats.aal5.tx_err),
48788 - atomic_read(&atm_dev->stats.aal5.rx),
48789 - atomic_read(&atm_dev->stats.aal5.rx_err),
48790 - atomic_read(&atm_dev->stats.aal5.rx_drop));
48791 + atomic_read_unchecked(&atm_dev->stats.aal5.tx),
48792 + atomic_read_unchecked(&atm_dev->stats.aal5.tx_err),
48793 + atomic_read_unchecked(&atm_dev->stats.aal5.rx),
48794 + atomic_read_unchecked(&atm_dev->stats.aal5.rx_err),
48795 + atomic_read_unchecked(&atm_dev->stats.aal5.rx_drop));
48796
48797 if (!left--) {
48798 if (instance->disconnected)
48799 diff --git a/drivers/usb/core/devices.c b/drivers/usb/core/devices.c
48800 index 2a3bbdf..91d72cf 100644
48801 --- a/drivers/usb/core/devices.c
48802 +++ b/drivers/usb/core/devices.c
48803 @@ -126,7 +126,7 @@ static const char format_endpt[] =
48804 * time it gets called.
48805 */
48806 static struct device_connect_event {
48807 - atomic_t count;
48808 + atomic_unchecked_t count;
48809 wait_queue_head_t wait;
48810 } device_event = {
48811 .count = ATOMIC_INIT(1),
48812 @@ -164,7 +164,7 @@ static const struct class_info clas_info[] = {
48813
48814 void usbfs_conn_disc_event(void)
48815 {
48816 - atomic_add(2, &device_event.count);
48817 + atomic_add_unchecked(2, &device_event.count);
48818 wake_up(&device_event.wait);
48819 }
48820
48821 @@ -652,7 +652,7 @@ static unsigned int usb_device_poll(struct file *file,
48822
48823 poll_wait(file, &device_event.wait, wait);
48824
48825 - event_count = atomic_read(&device_event.count);
48826 + event_count = atomic_read_unchecked(&device_event.count);
48827 if (file->f_version != event_count) {
48828 file->f_version = event_count;
48829 return POLLIN | POLLRDNORM;
48830 diff --git a/drivers/usb/core/devio.c b/drivers/usb/core/devio.c
48831 index 71dc5d7..6135ff2 100644
48832 --- a/drivers/usb/core/devio.c
48833 +++ b/drivers/usb/core/devio.c
48834 @@ -187,7 +187,7 @@ static ssize_t usbdev_read(struct file *file, char __user *buf, size_t nbytes,
48835 struct dev_state *ps = file->private_data;
48836 struct usb_device *dev = ps->dev;
48837 ssize_t ret = 0;
48838 - unsigned len;
48839 + size_t len;
48840 loff_t pos;
48841 int i;
48842
48843 @@ -229,13 +229,13 @@ static ssize_t usbdev_read(struct file *file, char __user *buf, size_t nbytes,
48844 for (i = 0; nbytes && i < dev->descriptor.bNumConfigurations; i++) {
48845 struct usb_config_descriptor *config =
48846 (struct usb_config_descriptor *)dev->rawdescriptors[i];
48847 - unsigned int length = le16_to_cpu(config->wTotalLength);
48848 + size_t length = le16_to_cpu(config->wTotalLength);
48849
48850 if (*ppos < pos + length) {
48851
48852 /* The descriptor may claim to be longer than it
48853 * really is. Here is the actual allocated length. */
48854 - unsigned alloclen =
48855 + size_t alloclen =
48856 le16_to_cpu(dev->config[i].desc.wTotalLength);
48857
48858 len = length - (*ppos - pos);
48859 diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c
48860 index f20a044..d1059aa 100644
48861 --- a/drivers/usb/core/hcd.c
48862 +++ b/drivers/usb/core/hcd.c
48863 @@ -1552,7 +1552,7 @@ int usb_hcd_submit_urb (struct urb *urb, gfp_t mem_flags)
48864 */
48865 usb_get_urb(urb);
48866 atomic_inc(&urb->use_count);
48867 - atomic_inc(&urb->dev->urbnum);
48868 + atomic_inc_unchecked(&urb->dev->urbnum);
48869 usbmon_urb_submit(&hcd->self, urb);
48870
48871 /* NOTE requirements on root-hub callers (usbfs and the hub
48872 @@ -1579,7 +1579,7 @@ int usb_hcd_submit_urb (struct urb *urb, gfp_t mem_flags)
48873 urb->hcpriv = NULL;
48874 INIT_LIST_HEAD(&urb->urb_list);
48875 atomic_dec(&urb->use_count);
48876 - atomic_dec(&urb->dev->urbnum);
48877 + atomic_dec_unchecked(&urb->dev->urbnum);
48878 if (atomic_read(&urb->reject))
48879 wake_up(&usb_kill_urb_queue);
48880 usb_put_urb(urb);
48881 diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
48882 index 243c672..8b66fbb 100644
48883 --- a/drivers/usb/core/hub.c
48884 +++ b/drivers/usb/core/hub.c
48885 @@ -27,6 +27,7 @@
48886 #include <linux/freezer.h>
48887 #include <linux/random.h>
48888 #include <linux/pm_qos.h>
48889 +#include <linux/grsecurity.h>
48890
48891 #include <asm/uaccess.h>
48892 #include <asm/byteorder.h>
48893 @@ -4467,6 +4468,10 @@ static void hub_port_connect_change(struct usb_hub *hub, int port1,
48894 goto done;
48895 return;
48896 }
48897 +
48898 + if (gr_handle_new_usb())
48899 + goto done;
48900 +
48901 if (hub_is_superspeed(hub->hdev))
48902 unit_load = 150;
48903 else
48904 diff --git a/drivers/usb/core/message.c b/drivers/usb/core/message.c
48905 index 82927e1..4993dbf 100644
48906 --- a/drivers/usb/core/message.c
48907 +++ b/drivers/usb/core/message.c
48908 @@ -129,7 +129,7 @@ static int usb_internal_control_msg(struct usb_device *usb_dev,
48909 * Return: If successful, the number of bytes transferred. Otherwise, a negative
48910 * error number.
48911 */
48912 -int usb_control_msg(struct usb_device *dev, unsigned int pipe, __u8 request,
48913 +int __intentional_overflow(-1) usb_control_msg(struct usb_device *dev, unsigned int pipe, __u8 request,
48914 __u8 requesttype, __u16 value, __u16 index, void *data,
48915 __u16 size, int timeout)
48916 {
48917 @@ -181,7 +181,7 @@ EXPORT_SYMBOL_GPL(usb_control_msg);
48918 * If successful, 0. Otherwise a negative error number. The number of actual
48919 * bytes transferred will be stored in the @actual_length paramater.
48920 */
48921 -int usb_interrupt_msg(struct usb_device *usb_dev, unsigned int pipe,
48922 +int __intentional_overflow(-1) usb_interrupt_msg(struct usb_device *usb_dev, unsigned int pipe,
48923 void *data, int len, int *actual_length, int timeout)
48924 {
48925 return usb_bulk_msg(usb_dev, pipe, data, len, actual_length, timeout);
48926 @@ -221,7 +221,7 @@ EXPORT_SYMBOL_GPL(usb_interrupt_msg);
48927 * bytes transferred will be stored in the @actual_length paramater.
48928 *
48929 */
48930 -int usb_bulk_msg(struct usb_device *usb_dev, unsigned int pipe,
48931 +int __intentional_overflow(-1) usb_bulk_msg(struct usb_device *usb_dev, unsigned int pipe,
48932 void *data, int len, int *actual_length, int timeout)
48933 {
48934 struct urb *urb;
48935 diff --git a/drivers/usb/core/sysfs.c b/drivers/usb/core/sysfs.c
48936 index ca516ac..6c36ee4 100644
48937 --- a/drivers/usb/core/sysfs.c
48938 +++ b/drivers/usb/core/sysfs.c
48939 @@ -236,7 +236,7 @@ static ssize_t urbnum_show(struct device *dev, struct device_attribute *attr,
48940 struct usb_device *udev;
48941
48942 udev = to_usb_device(dev);
48943 - return sprintf(buf, "%d\n", atomic_read(&udev->urbnum));
48944 + return sprintf(buf, "%d\n", atomic_read_unchecked(&udev->urbnum));
48945 }
48946 static DEVICE_ATTR_RO(urbnum);
48947
48948 diff --git a/drivers/usb/core/usb.c b/drivers/usb/core/usb.c
48949 index 0a6ee2e..6f8d7e8 100644
48950 --- a/drivers/usb/core/usb.c
48951 +++ b/drivers/usb/core/usb.c
48952 @@ -433,7 +433,7 @@ struct usb_device *usb_alloc_dev(struct usb_device *parent,
48953 set_dev_node(&dev->dev, dev_to_node(bus->controller));
48954 dev->state = USB_STATE_ATTACHED;
48955 dev->lpm_disable_count = 1;
48956 - atomic_set(&dev->urbnum, 0);
48957 + atomic_set_unchecked(&dev->urbnum, 0);
48958
48959 INIT_LIST_HEAD(&dev->ep0.urb_list);
48960 dev->ep0.desc.bLength = USB_DT_ENDPOINT_SIZE;
48961 diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c
48962 index 5452c0f..34c9145 100644
48963 --- a/drivers/usb/dwc3/gadget.c
48964 +++ b/drivers/usb/dwc3/gadget.c
48965 @@ -532,8 +532,6 @@ static int __dwc3_gadget_ep_enable(struct dwc3_ep *dep,
48966 if (!usb_endpoint_xfer_isoc(desc))
48967 return 0;
48968
48969 - memset(&trb_link, 0, sizeof(trb_link));
48970 -
48971 /* Link TRB for ISOC. The HWO bit is never reset */
48972 trb_st_hw = &dep->trb_pool[0];
48973
48974 diff --git a/drivers/usb/early/ehci-dbgp.c b/drivers/usb/early/ehci-dbgp.c
48975 index 5e29dde..eca992f 100644
48976 --- a/drivers/usb/early/ehci-dbgp.c
48977 +++ b/drivers/usb/early/ehci-dbgp.c
48978 @@ -98,7 +98,8 @@ static inline u32 dbgp_len_update(u32 x, u32 len)
48979
48980 #ifdef CONFIG_KGDB
48981 static struct kgdb_io kgdbdbgp_io_ops;
48982 -#define dbgp_kgdb_mode (dbg_io_ops == &kgdbdbgp_io_ops)
48983 +static struct kgdb_io kgdbdbgp_io_ops_console;
48984 +#define dbgp_kgdb_mode (dbg_io_ops == &kgdbdbgp_io_ops || dbg_io_ops == &kgdbdbgp_io_ops_console)
48985 #else
48986 #define dbgp_kgdb_mode (0)
48987 #endif
48988 @@ -1047,6 +1048,13 @@ static struct kgdb_io kgdbdbgp_io_ops = {
48989 .write_char = kgdbdbgp_write_char,
48990 };
48991
48992 +static struct kgdb_io kgdbdbgp_io_ops_console = {
48993 + .name = "kgdbdbgp",
48994 + .read_char = kgdbdbgp_read_char,
48995 + .write_char = kgdbdbgp_write_char,
48996 + .is_console = 1
48997 +};
48998 +
48999 static int kgdbdbgp_wait_time;
49000
49001 static int __init kgdbdbgp_parse_config(char *str)
49002 @@ -1062,8 +1070,10 @@ static int __init kgdbdbgp_parse_config(char *str)
49003 ptr++;
49004 kgdbdbgp_wait_time = simple_strtoul(ptr, &ptr, 10);
49005 }
49006 - kgdb_register_io_module(&kgdbdbgp_io_ops);
49007 - kgdbdbgp_io_ops.is_console = early_dbgp_console.index != -1;
49008 + if (early_dbgp_console.index != -1)
49009 + kgdb_register_io_module(&kgdbdbgp_io_ops_console);
49010 + else
49011 + kgdb_register_io_module(&kgdbdbgp_io_ops);
49012
49013 return 0;
49014 }
49015 diff --git a/drivers/usb/gadget/u_serial.c b/drivers/usb/gadget/u_serial.c
49016 index b369292..9f3ba40 100644
49017 --- a/drivers/usb/gadget/u_serial.c
49018 +++ b/drivers/usb/gadget/u_serial.c
49019 @@ -733,9 +733,9 @@ static int gs_open(struct tty_struct *tty, struct file *file)
49020 spin_lock_irq(&port->port_lock);
49021
49022 /* already open? Great. */
49023 - if (port->port.count) {
49024 + if (atomic_read(&port->port.count)) {
49025 status = 0;
49026 - port->port.count++;
49027 + atomic_inc(&port->port.count);
49028
49029 /* currently opening/closing? wait ... */
49030 } else if (port->openclose) {
49031 @@ -794,7 +794,7 @@ static int gs_open(struct tty_struct *tty, struct file *file)
49032 tty->driver_data = port;
49033 port->port.tty = tty;
49034
49035 - port->port.count = 1;
49036 + atomic_set(&port->port.count, 1);
49037 port->openclose = false;
49038
49039 /* if connected, start the I/O stream */
49040 @@ -836,11 +836,11 @@ static void gs_close(struct tty_struct *tty, struct file *file)
49041
49042 spin_lock_irq(&port->port_lock);
49043
49044 - if (port->port.count != 1) {
49045 - if (port->port.count == 0)
49046 + if (atomic_read(&port->port.count) != 1) {
49047 + if (atomic_read(&port->port.count) == 0)
49048 WARN_ON(1);
49049 else
49050 - --port->port.count;
49051 + atomic_dec(&port->port.count);
49052 goto exit;
49053 }
49054
49055 @@ -850,7 +850,7 @@ static void gs_close(struct tty_struct *tty, struct file *file)
49056 * and sleep if necessary
49057 */
49058 port->openclose = true;
49059 - port->port.count = 0;
49060 + atomic_set(&port->port.count, 0);
49061
49062 gser = port->port_usb;
49063 if (gser && gser->disconnect)
49064 @@ -1066,7 +1066,7 @@ static int gs_closed(struct gs_port *port)
49065 int cond;
49066
49067 spin_lock_irq(&port->port_lock);
49068 - cond = (port->port.count == 0) && !port->openclose;
49069 + cond = (atomic_read(&port->port.count) == 0) && !port->openclose;
49070 spin_unlock_irq(&port->port_lock);
49071 return cond;
49072 }
49073 @@ -1209,7 +1209,7 @@ int gserial_connect(struct gserial *gser, u8 port_num)
49074 /* if it's already open, start I/O ... and notify the serial
49075 * protocol about open/close status (connect/disconnect).
49076 */
49077 - if (port->port.count) {
49078 + if (atomic_read(&port->port.count)) {
49079 pr_debug("gserial_connect: start ttyGS%d\n", port->port_num);
49080 gs_start_io(port);
49081 if (gser->connect)
49082 @@ -1256,7 +1256,7 @@ void gserial_disconnect(struct gserial *gser)
49083
49084 port->port_usb = NULL;
49085 gser->ioport = NULL;
49086 - if (port->port.count > 0 || port->openclose) {
49087 + if (atomic_read(&port->port.count) > 0 || port->openclose) {
49088 wake_up_interruptible(&port->drain_wait);
49089 if (port->port.tty)
49090 tty_hangup(port->port.tty);
49091 @@ -1272,7 +1272,7 @@ void gserial_disconnect(struct gserial *gser)
49092
49093 /* finally, free any unused/unusable I/O buffers */
49094 spin_lock_irqsave(&port->port_lock, flags);
49095 - if (port->port.count == 0 && !port->openclose)
49096 + if (atomic_read(&port->port.count) == 0 && !port->openclose)
49097 gs_buf_free(&port->port_write_buf);
49098 gs_free_requests(gser->out, &port->read_pool, NULL);
49099 gs_free_requests(gser->out, &port->read_queue, NULL);
49100 diff --git a/drivers/usb/host/ehci-hub.c b/drivers/usb/host/ehci-hub.c
49101 index 835fc08..f8b22bf 100644
49102 --- a/drivers/usb/host/ehci-hub.c
49103 +++ b/drivers/usb/host/ehci-hub.c
49104 @@ -762,7 +762,7 @@ static struct urb *request_single_step_set_feature_urb(
49105 urb->transfer_flags = URB_DIR_IN;
49106 usb_get_urb(urb);
49107 atomic_inc(&urb->use_count);
49108 - atomic_inc(&urb->dev->urbnum);
49109 + atomic_inc_unchecked(&urb->dev->urbnum);
49110 urb->setup_dma = dma_map_single(
49111 hcd->self.controller,
49112 urb->setup_packet,
49113 @@ -829,7 +829,7 @@ static int ehset_single_step_set_feature(struct usb_hcd *hcd, int port)
49114 urb->status = -EINPROGRESS;
49115 usb_get_urb(urb);
49116 atomic_inc(&urb->use_count);
49117 - atomic_inc(&urb->dev->urbnum);
49118 + atomic_inc_unchecked(&urb->dev->urbnum);
49119 retval = submit_single_step_set_feature(hcd, urb, 0);
49120 if (!retval && !wait_for_completion_timeout(&done,
49121 msecs_to_jiffies(2000))) {
49122 diff --git a/drivers/usb/misc/appledisplay.c b/drivers/usb/misc/appledisplay.c
49123 index ba6a5d6..f88f7f3 100644
49124 --- a/drivers/usb/misc/appledisplay.c
49125 +++ b/drivers/usb/misc/appledisplay.c
49126 @@ -83,7 +83,7 @@ struct appledisplay {
49127 spinlock_t lock;
49128 };
49129
49130 -static atomic_t count_displays = ATOMIC_INIT(0);
49131 +static atomic_unchecked_t count_displays = ATOMIC_INIT(0);
49132 static struct workqueue_struct *wq;
49133
49134 static void appledisplay_complete(struct urb *urb)
49135 @@ -281,7 +281,7 @@ static int appledisplay_probe(struct usb_interface *iface,
49136
49137 /* Register backlight device */
49138 snprintf(bl_name, sizeof(bl_name), "appledisplay%d",
49139 - atomic_inc_return(&count_displays) - 1);
49140 + atomic_inc_return_unchecked(&count_displays) - 1);
49141 memset(&props, 0, sizeof(struct backlight_properties));
49142 props.type = BACKLIGHT_RAW;
49143 props.max_brightness = 0xff;
49144 diff --git a/drivers/usb/serial/console.c b/drivers/usb/serial/console.c
49145 index c69bb50..215ef37 100644
49146 --- a/drivers/usb/serial/console.c
49147 +++ b/drivers/usb/serial/console.c
49148 @@ -124,7 +124,7 @@ static int usb_console_setup(struct console *co, char *options)
49149
49150 info->port = port;
49151
49152 - ++port->port.count;
49153 + atomic_inc(&port->port.count);
49154 if (!test_bit(ASYNCB_INITIALIZED, &port->port.flags)) {
49155 if (serial->type->set_termios) {
49156 /*
49157 @@ -170,7 +170,7 @@ static int usb_console_setup(struct console *co, char *options)
49158 }
49159 /* Now that any required fake tty operations are completed restore
49160 * the tty port count */
49161 - --port->port.count;
49162 + atomic_dec(&port->port.count);
49163 /* The console is special in terms of closing the device so
49164 * indicate this port is now acting as a system console. */
49165 port->port.console = 1;
49166 @@ -183,7 +183,7 @@ static int usb_console_setup(struct console *co, char *options)
49167 free_tty:
49168 kfree(tty);
49169 reset_open_count:
49170 - port->port.count = 0;
49171 + atomic_set(&port->port.count, 0);
49172 usb_autopm_put_interface(serial->interface);
49173 error_get_interface:
49174 usb_serial_put(serial);
49175 @@ -194,7 +194,7 @@ static int usb_console_setup(struct console *co, char *options)
49176 static void usb_console_write(struct console *co,
49177 const char *buf, unsigned count)
49178 {
49179 - static struct usbcons_info *info = &usbcons_info;
49180 + struct usbcons_info *info = &usbcons_info;
49181 struct usb_serial_port *port = info->port;
49182 struct usb_serial *serial;
49183 int retval = -ENODEV;
49184 diff --git a/drivers/usb/storage/usb.h b/drivers/usb/storage/usb.h
49185 index 75f70f0..d467e1a 100644
49186 --- a/drivers/usb/storage/usb.h
49187 +++ b/drivers/usb/storage/usb.h
49188 @@ -63,7 +63,7 @@ struct us_unusual_dev {
49189 __u8 useProtocol;
49190 __u8 useTransport;
49191 int (*initFunction)(struct us_data *);
49192 -};
49193 +} __do_const;
49194
49195
49196 /* Dynamic bitflag definitions (us->dflags): used in set_bit() etc. */
49197 diff --git a/drivers/usb/wusbcore/wa-hc.h b/drivers/usb/wusbcore/wa-hc.h
49198 index cf250c2..ad9d904 100644
49199 --- a/drivers/usb/wusbcore/wa-hc.h
49200 +++ b/drivers/usb/wusbcore/wa-hc.h
49201 @@ -199,7 +199,7 @@ struct wahc {
49202 spinlock_t xfer_list_lock;
49203 struct work_struct xfer_enqueue_work;
49204 struct work_struct xfer_error_work;
49205 - atomic_t xfer_id_count;
49206 + atomic_unchecked_t xfer_id_count;
49207 };
49208
49209
49210 @@ -255,7 +255,7 @@ static inline void wa_init(struct wahc *wa)
49211 spin_lock_init(&wa->xfer_list_lock);
49212 INIT_WORK(&wa->xfer_enqueue_work, wa_urb_enqueue_run);
49213 INIT_WORK(&wa->xfer_error_work, wa_process_errored_transfers_run);
49214 - atomic_set(&wa->xfer_id_count, 1);
49215 + atomic_set_unchecked(&wa->xfer_id_count, 1);
49216 }
49217
49218 /**
49219 diff --git a/drivers/usb/wusbcore/wa-xfer.c b/drivers/usb/wusbcore/wa-xfer.c
49220 index 3dcf66f..8faaf6e 100644
49221 --- a/drivers/usb/wusbcore/wa-xfer.c
49222 +++ b/drivers/usb/wusbcore/wa-xfer.c
49223 @@ -300,7 +300,7 @@ out:
49224 */
49225 static void wa_xfer_id_init(struct wa_xfer *xfer)
49226 {
49227 - xfer->id = atomic_add_return(1, &xfer->wa->xfer_id_count);
49228 + xfer->id = atomic_add_return_unchecked(1, &xfer->wa->xfer_id_count);
49229 }
49230
49231 /*
49232 diff --git a/drivers/vfio/vfio.c b/drivers/vfio/vfio.c
49233 index 1eab4ac..e21efc9 100644
49234 --- a/drivers/vfio/vfio.c
49235 +++ b/drivers/vfio/vfio.c
49236 @@ -488,7 +488,7 @@ static int vfio_group_nb_add_dev(struct vfio_group *group, struct device *dev)
49237 return 0;
49238
49239 /* TODO Prevent device auto probing */
49240 - WARN("Device %s added to live group %d!\n", dev_name(dev),
49241 + WARN(1, "Device %s added to live group %d!\n", dev_name(dev),
49242 iommu_group_id(group->iommu_group));
49243
49244 return 0;
49245 diff --git a/drivers/vhost/vringh.c b/drivers/vhost/vringh.c
49246 index 5174eba..86e764a 100644
49247 --- a/drivers/vhost/vringh.c
49248 +++ b/drivers/vhost/vringh.c
49249 @@ -800,7 +800,7 @@ static inline int getu16_kern(u16 *val, const u16 *p)
49250
49251 static inline int putu16_kern(u16 *p, u16 val)
49252 {
49253 - ACCESS_ONCE(*p) = val;
49254 + ACCESS_ONCE_RW(*p) = val;
49255 return 0;
49256 }
49257
49258 diff --git a/drivers/video/arcfb.c b/drivers/video/arcfb.c
49259 index e43401a..dd49b3f 100644
49260 --- a/drivers/video/arcfb.c
49261 +++ b/drivers/video/arcfb.c
49262 @@ -458,7 +458,7 @@ static ssize_t arcfb_write(struct fb_info *info, const char __user *buf,
49263 return -ENOSPC;
49264
49265 err = 0;
49266 - if ((count + p) > fbmemlength) {
49267 + if (count > (fbmemlength - p)) {
49268 count = fbmemlength - p;
49269 err = -ENOSPC;
49270 }
49271 diff --git a/drivers/video/aty/aty128fb.c b/drivers/video/aty/aty128fb.c
49272 index a4dfe8c..297ddd9 100644
49273 --- a/drivers/video/aty/aty128fb.c
49274 +++ b/drivers/video/aty/aty128fb.c
49275 @@ -149,7 +149,7 @@ enum {
49276 };
49277
49278 /* Must match above enum */
49279 -static char * const r128_family[] = {
49280 +static const char * const r128_family[] = {
49281 "AGP",
49282 "PCI",
49283 "PRO AGP",
49284 diff --git a/drivers/video/aty/atyfb_base.c b/drivers/video/aty/atyfb_base.c
49285 index 9b0f12c..024673d 100644
49286 --- a/drivers/video/aty/atyfb_base.c
49287 +++ b/drivers/video/aty/atyfb_base.c
49288 @@ -1326,10 +1326,14 @@ static int atyfb_set_par(struct fb_info *info)
49289 par->accel_flags = var->accel_flags; /* hack */
49290
49291 if (var->accel_flags) {
49292 - info->fbops->fb_sync = atyfb_sync;
49293 + pax_open_kernel();
49294 + *(void **)&info->fbops->fb_sync = atyfb_sync;
49295 + pax_close_kernel();
49296 info->flags &= ~FBINFO_HWACCEL_DISABLED;
49297 } else {
49298 - info->fbops->fb_sync = NULL;
49299 + pax_open_kernel();
49300 + *(void **)&info->fbops->fb_sync = NULL;
49301 + pax_close_kernel();
49302 info->flags |= FBINFO_HWACCEL_DISABLED;
49303 }
49304
49305 diff --git a/drivers/video/aty/mach64_cursor.c b/drivers/video/aty/mach64_cursor.c
49306 index 95ec042..e6affdd 100644
49307 --- a/drivers/video/aty/mach64_cursor.c
49308 +++ b/drivers/video/aty/mach64_cursor.c
49309 @@ -7,6 +7,7 @@
49310 #include <linux/string.h>
49311
49312 #include <asm/io.h>
49313 +#include <asm/pgtable.h>
49314
49315 #ifdef __sparc__
49316 #include <asm/fbio.h>
49317 @@ -208,7 +209,9 @@ int aty_init_cursor(struct fb_info *info)
49318 info->sprite.buf_align = 16; /* and 64 lines tall. */
49319 info->sprite.flags = FB_PIXMAP_IO;
49320
49321 - info->fbops->fb_cursor = atyfb_cursor;
49322 + pax_open_kernel();
49323 + *(void **)&info->fbops->fb_cursor = atyfb_cursor;
49324 + pax_close_kernel();
49325
49326 return 0;
49327 }
49328 diff --git a/drivers/video/backlight/kb3886_bl.c b/drivers/video/backlight/kb3886_bl.c
49329 index bca6ccc..252107e 100644
49330 --- a/drivers/video/backlight/kb3886_bl.c
49331 +++ b/drivers/video/backlight/kb3886_bl.c
49332 @@ -78,7 +78,7 @@ static struct kb3886bl_machinfo *bl_machinfo;
49333 static unsigned long kb3886bl_flags;
49334 #define KB3886BL_SUSPENDED 0x01
49335
49336 -static struct dmi_system_id __initdata kb3886bl_device_table[] = {
49337 +static const struct dmi_system_id __initconst kb3886bl_device_table[] = {
49338 {
49339 .ident = "Sahara Touch-iT",
49340 .matches = {
49341 diff --git a/drivers/video/fb_defio.c b/drivers/video/fb_defio.c
49342 index 900aa4e..6d49418 100644
49343 --- a/drivers/video/fb_defio.c
49344 +++ b/drivers/video/fb_defio.c
49345 @@ -206,7 +206,9 @@ void fb_deferred_io_init(struct fb_info *info)
49346
49347 BUG_ON(!fbdefio);
49348 mutex_init(&fbdefio->lock);
49349 - info->fbops->fb_mmap = fb_deferred_io_mmap;
49350 + pax_open_kernel();
49351 + *(void **)&info->fbops->fb_mmap = fb_deferred_io_mmap;
49352 + pax_close_kernel();
49353 INIT_DELAYED_WORK(&info->deferred_work, fb_deferred_io_work);
49354 INIT_LIST_HEAD(&fbdefio->pagelist);
49355 if (fbdefio->delay == 0) /* set a default of 1 s */
49356 @@ -237,7 +239,7 @@ void fb_deferred_io_cleanup(struct fb_info *info)
49357 page->mapping = NULL;
49358 }
49359
49360 - info->fbops->fb_mmap = NULL;
49361 + *(void **)&info->fbops->fb_mmap = NULL;
49362 mutex_destroy(&fbdefio->lock);
49363 }
49364 EXPORT_SYMBOL_GPL(fb_deferred_io_cleanup);
49365 diff --git a/drivers/video/fbmem.c b/drivers/video/fbmem.c
49366 index dacaf74..8478a46 100644
49367 --- a/drivers/video/fbmem.c
49368 +++ b/drivers/video/fbmem.c
49369 @@ -433,7 +433,7 @@ static void fb_do_show_logo(struct fb_info *info, struct fb_image *image,
49370 image->dx += image->width + 8;
49371 }
49372 } else if (rotate == FB_ROTATE_UD) {
49373 - for (x = 0; x < num && image->dx >= 0; x++) {
49374 + for (x = 0; x < num && (__s32)image->dx >= 0; x++) {
49375 info->fbops->fb_imageblit(info, image);
49376 image->dx -= image->width + 8;
49377 }
49378 @@ -445,7 +445,7 @@ static void fb_do_show_logo(struct fb_info *info, struct fb_image *image,
49379 image->dy += image->height + 8;
49380 }
49381 } else if (rotate == FB_ROTATE_CCW) {
49382 - for (x = 0; x < num && image->dy >= 0; x++) {
49383 + for (x = 0; x < num && (__s32)image->dy >= 0; x++) {
49384 info->fbops->fb_imageblit(info, image);
49385 image->dy -= image->height + 8;
49386 }
49387 @@ -1175,7 +1175,7 @@ static long do_fb_ioctl(struct fb_info *info, unsigned int cmd,
49388 return -EFAULT;
49389 if (con2fb.console < 1 || con2fb.console > MAX_NR_CONSOLES)
49390 return -EINVAL;
49391 - if (con2fb.framebuffer < 0 || con2fb.framebuffer >= FB_MAX)
49392 + if (con2fb.framebuffer >= FB_MAX)
49393 return -EINVAL;
49394 if (!registered_fb[con2fb.framebuffer])
49395 request_module("fb%d", con2fb.framebuffer);
49396 diff --git a/drivers/video/hyperv_fb.c b/drivers/video/hyperv_fb.c
49397 index 8d456dc..b4fa44b 100644
49398 --- a/drivers/video/hyperv_fb.c
49399 +++ b/drivers/video/hyperv_fb.c
49400 @@ -233,7 +233,7 @@ static uint screen_fb_size;
49401 static inline int synthvid_send(struct hv_device *hdev,
49402 struct synthvid_msg *msg)
49403 {
49404 - static atomic64_t request_id = ATOMIC64_INIT(0);
49405 + static atomic64_unchecked_t request_id = ATOMIC64_INIT(0);
49406 int ret;
49407
49408 msg->pipe_hdr.type = PIPE_MSG_DATA;
49409 @@ -241,7 +241,7 @@ static inline int synthvid_send(struct hv_device *hdev,
49410
49411 ret = vmbus_sendpacket(hdev->channel, msg,
49412 msg->vid_hdr.size + sizeof(struct pipe_msg_hdr),
49413 - atomic64_inc_return(&request_id),
49414 + atomic64_inc_return_unchecked(&request_id),
49415 VM_PKT_DATA_INBAND, 0);
49416
49417 if (ret)
49418 diff --git a/drivers/video/i810/i810_accel.c b/drivers/video/i810/i810_accel.c
49419 index 7672d2e..b56437f 100644
49420 --- a/drivers/video/i810/i810_accel.c
49421 +++ b/drivers/video/i810/i810_accel.c
49422 @@ -73,6 +73,7 @@ static inline int wait_for_space(struct fb_info *info, u32 space)
49423 }
49424 }
49425 printk("ringbuffer lockup!!!\n");
49426 + printk("head:%u tail:%u iring.size:%u space:%u\n", head, tail, par->iring.size, space);
49427 i810_report_error(mmio);
49428 par->dev_flags |= LOCKUP;
49429 info->pixmap.scan_align = 1;
49430 diff --git a/drivers/video/logo/logo_linux_clut224.ppm b/drivers/video/logo/logo_linux_clut224.ppm
49431 index 3c14e43..2630570 100644
49432 --- a/drivers/video/logo/logo_linux_clut224.ppm
49433 +++ b/drivers/video/logo/logo_linux_clut224.ppm
49434 @@ -2,1603 +2,1123 @@ P3
49435 # Standard 224-color Linux logo
49436 80 80
49437 255
49438 - 0 0 0 0 0 0 0 0 0 0 0 0
49439 - 0 0 0 0 0 0 0 0 0 0 0 0
49440 - 0 0 0 0 0 0 0 0 0 0 0 0
49441 - 0 0 0 0 0 0 0 0 0 0 0 0
49442 - 0 0 0 0 0 0 0 0 0 0 0 0
49443 - 0 0 0 0 0 0 0 0 0 0 0 0
49444 - 0 0 0 0 0 0 0 0 0 0 0 0
49445 - 0 0 0 0 0 0 0 0 0 0 0 0
49446 - 0 0 0 0 0 0 0 0 0 0 0 0
49447 - 6 6 6 6 6 6 10 10 10 10 10 10
49448 - 10 10 10 6 6 6 6 6 6 6 6 6
49449 - 0 0 0 0 0 0 0 0 0 0 0 0
49450 - 0 0 0 0 0 0 0 0 0 0 0 0
49451 - 0 0 0 0 0 0 0 0 0 0 0 0
49452 - 0 0 0 0 0 0 0 0 0 0 0 0
49453 - 0 0 0 0 0 0 0 0 0 0 0 0
49454 - 0 0 0 0 0 0 0 0 0 0 0 0
49455 - 0 0 0 0 0 0 0 0 0 0 0 0
49456 - 0 0 0 0 0 0 0 0 0 0 0 0
49457 - 0 0 0 0 0 0 0 0 0 0 0 0
49458 - 0 0 0 0 0 0 0 0 0 0 0 0
49459 - 0 0 0 0 0 0 0 0 0 0 0 0
49460 - 0 0 0 0 0 0 0 0 0 0 0 0
49461 - 0 0 0 0 0 0 0 0 0 0 0 0
49462 - 0 0 0 0 0 0 0 0 0 0 0 0
49463 - 0 0 0 0 0 0 0 0 0 0 0 0
49464 - 0 0 0 0 0 0 0 0 0 0 0 0
49465 - 0 0 0 0 0 0 0 0 0 0 0 0
49466 - 0 0 0 6 6 6 10 10 10 14 14 14
49467 - 22 22 22 26 26 26 30 30 30 34 34 34
49468 - 30 30 30 30 30 30 26 26 26 18 18 18
49469 - 14 14 14 10 10 10 6 6 6 0 0 0
49470 - 0 0 0 0 0 0 0 0 0 0 0 0
49471 - 0 0 0 0 0 0 0 0 0 0 0 0
49472 - 0 0 0 0 0 0 0 0 0 0 0 0
49473 - 0 0 0 0 0 0 0 0 0 0 0 0
49474 - 0 0 0 0 0 0 0 0 0 0 0 0
49475 - 0 0 0 0 0 0 0 0 0 0 0 0
49476 - 0 0 0 0 0 0 0 0 0 0 0 0
49477 - 0 0 0 0 0 0 0 0 0 0 0 0
49478 - 0 0 0 0 0 0 0 0 0 0 0 0
49479 - 0 0 0 0 0 1 0 0 1 0 0 0
49480 - 0 0 0 0 0 0 0 0 0 0 0 0
49481 - 0 0 0 0 0 0 0 0 0 0 0 0
49482 - 0 0 0 0 0 0 0 0 0 0 0 0
49483 - 0 0 0 0 0 0 0 0 0 0 0 0
49484 - 0 0 0 0 0 0 0 0 0 0 0 0
49485 - 0 0 0 0 0 0 0 0 0 0 0 0
49486 - 6 6 6 14 14 14 26 26 26 42 42 42
49487 - 54 54 54 66 66 66 78 78 78 78 78 78
49488 - 78 78 78 74 74 74 66 66 66 54 54 54
49489 - 42 42 42 26 26 26 18 18 18 10 10 10
49490 - 6 6 6 0 0 0 0 0 0 0 0 0
49491 - 0 0 0 0 0 0 0 0 0 0 0 0
49492 - 0 0 0 0 0 0 0 0 0 0 0 0
49493 - 0 0 0 0 0 0 0 0 0 0 0 0
49494 - 0 0 0 0 0 0 0 0 0 0 0 0
49495 - 0 0 0 0 0 0 0 0 0 0 0 0
49496 - 0 0 0 0 0 0 0 0 0 0 0 0
49497 - 0 0 0 0 0 0 0 0 0 0 0 0
49498 - 0 0 0 0 0 0 0 0 0 0 0 0
49499 - 0 0 1 0 0 0 0 0 0 0 0 0
49500 - 0 0 0 0 0 0 0 0 0 0 0 0
49501 - 0 0 0 0 0 0 0 0 0 0 0 0
49502 - 0 0 0 0 0 0 0 0 0 0 0 0
49503 - 0 0 0 0 0 0 0 0 0 0 0 0
49504 - 0 0 0 0 0 0 0 0 0 0 0 0
49505 - 0 0 0 0 0 0 0 0 0 10 10 10
49506 - 22 22 22 42 42 42 66 66 66 86 86 86
49507 - 66 66 66 38 38 38 38 38 38 22 22 22
49508 - 26 26 26 34 34 34 54 54 54 66 66 66
49509 - 86 86 86 70 70 70 46 46 46 26 26 26
49510 - 14 14 14 6 6 6 0 0 0 0 0 0
49511 - 0 0 0 0 0 0 0 0 0 0 0 0
49512 - 0 0 0 0 0 0 0 0 0 0 0 0
49513 - 0 0 0 0 0 0 0 0 0 0 0 0
49514 - 0 0 0 0 0 0 0 0 0 0 0 0
49515 - 0 0 0 0 0 0 0 0 0 0 0 0
49516 - 0 0 0 0 0 0 0 0 0 0 0 0
49517 - 0 0 0 0 0 0 0 0 0 0 0 0
49518 - 0 0 0 0 0 0 0 0 0 0 0 0
49519 - 0 0 1 0 0 1 0 0 1 0 0 0
49520 - 0 0 0 0 0 0 0 0 0 0 0 0
49521 - 0 0 0 0 0 0 0 0 0 0 0 0
49522 - 0 0 0 0 0 0 0 0 0 0 0 0
49523 - 0 0 0 0 0 0 0 0 0 0 0 0
49524 - 0 0 0 0 0 0 0 0 0 0 0 0
49525 - 0 0 0 0 0 0 10 10 10 26 26 26
49526 - 50 50 50 82 82 82 58 58 58 6 6 6
49527 - 2 2 6 2 2 6 2 2 6 2 2 6
49528 - 2 2 6 2 2 6 2 2 6 2 2 6
49529 - 6 6 6 54 54 54 86 86 86 66 66 66
49530 - 38 38 38 18 18 18 6 6 6 0 0 0
49531 - 0 0 0 0 0 0 0 0 0 0 0 0
49532 - 0 0 0 0 0 0 0 0 0 0 0 0
49533 - 0 0 0 0 0 0 0 0 0 0 0 0
49534 - 0 0 0 0 0 0 0 0 0 0 0 0
49535 - 0 0 0 0 0 0 0 0 0 0 0 0
49536 - 0 0 0 0 0 0 0 0 0 0 0 0
49537 - 0 0 0 0 0 0 0 0 0 0 0 0
49538 - 0 0 0 0 0 0 0 0 0 0 0 0
49539 - 0 0 0 0 0 0 0 0 0 0 0 0
49540 - 0 0 0 0 0 0 0 0 0 0 0 0
49541 - 0 0 0 0 0 0 0 0 0 0 0 0
49542 - 0 0 0 0 0 0 0 0 0 0 0 0
49543 - 0 0 0 0 0 0 0 0 0 0 0 0
49544 - 0 0 0 0 0 0 0 0 0 0 0 0
49545 - 0 0 0 6 6 6 22 22 22 50 50 50
49546 - 78 78 78 34 34 34 2 2 6 2 2 6
49547 - 2 2 6 2 2 6 2 2 6 2 2 6
49548 - 2 2 6 2 2 6 2 2 6 2 2 6
49549 - 2 2 6 2 2 6 6 6 6 70 70 70
49550 - 78 78 78 46 46 46 22 22 22 6 6 6
49551 - 0 0 0 0 0 0 0 0 0 0 0 0
49552 - 0 0 0 0 0 0 0 0 0 0 0 0
49553 - 0 0 0 0 0 0 0 0 0 0 0 0
49554 - 0 0 0 0 0 0 0 0 0 0 0 0
49555 - 0 0 0 0 0 0 0 0 0 0 0 0
49556 - 0 0 0 0 0 0 0 0 0 0 0 0
49557 - 0 0 0 0 0 0 0 0 0 0 0 0
49558 - 0 0 0 0 0 0 0 0 0 0 0 0
49559 - 0 0 1 0 0 1 0 0 1 0 0 0
49560 - 0 0 0 0 0 0 0 0 0 0 0 0
49561 - 0 0 0 0 0 0 0 0 0 0 0 0
49562 - 0 0 0 0 0 0 0 0 0 0 0 0
49563 - 0 0 0 0 0 0 0 0 0 0 0 0
49564 - 0 0 0 0 0 0 0 0 0 0 0 0
49565 - 6 6 6 18 18 18 42 42 42 82 82 82
49566 - 26 26 26 2 2 6 2 2 6 2 2 6
49567 - 2 2 6 2 2 6 2 2 6 2 2 6
49568 - 2 2 6 2 2 6 2 2 6 14 14 14
49569 - 46 46 46 34 34 34 6 6 6 2 2 6
49570 - 42 42 42 78 78 78 42 42 42 18 18 18
49571 - 6 6 6 0 0 0 0 0 0 0 0 0
49572 - 0 0 0 0 0 0 0 0 0 0 0 0
49573 - 0 0 0 0 0 0 0 0 0 0 0 0
49574 - 0 0 0 0 0 0 0 0 0 0 0 0
49575 - 0 0 0 0 0 0 0 0 0 0 0 0
49576 - 0 0 0 0 0 0 0 0 0 0 0 0
49577 - 0 0 0 0 0 0 0 0 0 0 0 0
49578 - 0 0 0 0 0 0 0 0 0 0 0 0
49579 - 0 0 1 0 0 0 0 0 1 0 0 0
49580 - 0 0 0 0 0 0 0 0 0 0 0 0
49581 - 0 0 0 0 0 0 0 0 0 0 0 0
49582 - 0 0 0 0 0 0 0 0 0 0 0 0
49583 - 0 0 0 0 0 0 0 0 0 0 0 0
49584 - 0 0 0 0 0 0 0 0 0 0 0 0
49585 - 10 10 10 30 30 30 66 66 66 58 58 58
49586 - 2 2 6 2 2 6 2 2 6 2 2 6
49587 - 2 2 6 2 2 6 2 2 6 2 2 6
49588 - 2 2 6 2 2 6 2 2 6 26 26 26
49589 - 86 86 86 101 101 101 46 46 46 10 10 10
49590 - 2 2 6 58 58 58 70 70 70 34 34 34
49591 - 10 10 10 0 0 0 0 0 0 0 0 0
49592 - 0 0 0 0 0 0 0 0 0 0 0 0
49593 - 0 0 0 0 0 0 0 0 0 0 0 0
49594 - 0 0 0 0 0 0 0 0 0 0 0 0
49595 - 0 0 0 0 0 0 0 0 0 0 0 0
49596 - 0 0 0 0 0 0 0 0 0 0 0 0
49597 - 0 0 0 0 0 0 0 0 0 0 0 0
49598 - 0 0 0 0 0 0 0 0 0 0 0 0
49599 - 0 0 1 0 0 1 0 0 1 0 0 0
49600 - 0 0 0 0 0 0 0 0 0 0 0 0
49601 - 0 0 0 0 0 0 0 0 0 0 0 0
49602 - 0 0 0 0 0 0 0 0 0 0 0 0
49603 - 0 0 0 0 0 0 0 0 0 0 0 0
49604 - 0 0 0 0 0 0 0 0 0 0 0 0
49605 - 14 14 14 42 42 42 86 86 86 10 10 10
49606 - 2 2 6 2 2 6 2 2 6 2 2 6
49607 - 2 2 6 2 2 6 2 2 6 2 2 6
49608 - 2 2 6 2 2 6 2 2 6 30 30 30
49609 - 94 94 94 94 94 94 58 58 58 26 26 26
49610 - 2 2 6 6 6 6 78 78 78 54 54 54
49611 - 22 22 22 6 6 6 0 0 0 0 0 0
49612 - 0 0 0 0 0 0 0 0 0 0 0 0
49613 - 0 0 0 0 0 0 0 0 0 0 0 0
49614 - 0 0 0 0 0 0 0 0 0 0 0 0
49615 - 0 0 0 0 0 0 0 0 0 0 0 0
49616 - 0 0 0 0 0 0 0 0 0 0 0 0
49617 - 0 0 0 0 0 0 0 0 0 0 0 0
49618 - 0 0 0 0 0 0 0 0 0 0 0 0
49619 - 0 0 0 0 0 0 0 0 0 0 0 0
49620 - 0 0 0 0 0 0 0 0 0 0 0 0
49621 - 0 0 0 0 0 0 0 0 0 0 0 0
49622 - 0 0 0 0 0 0 0 0 0 0 0 0
49623 - 0 0 0 0 0 0 0 0 0 0 0 0
49624 - 0 0 0 0 0 0 0 0 0 6 6 6
49625 - 22 22 22 62 62 62 62 62 62 2 2 6
49626 - 2 2 6 2 2 6 2 2 6 2 2 6
49627 - 2 2 6 2 2 6 2 2 6 2 2 6
49628 - 2 2 6 2 2 6 2 2 6 26 26 26
49629 - 54 54 54 38 38 38 18 18 18 10 10 10
49630 - 2 2 6 2 2 6 34 34 34 82 82 82
49631 - 38 38 38 14 14 14 0 0 0 0 0 0
49632 - 0 0 0 0 0 0 0 0 0 0 0 0
49633 - 0 0 0 0 0 0 0 0 0 0 0 0
49634 - 0 0 0 0 0 0 0 0 0 0 0 0
49635 - 0 0 0 0 0 0 0 0 0 0 0 0
49636 - 0 0 0 0 0 0 0 0 0 0 0 0
49637 - 0 0 0 0 0 0 0 0 0 0 0 0
49638 - 0 0 0 0 0 0 0 0 0 0 0 0
49639 - 0 0 0 0 0 1 0 0 1 0 0 0
49640 - 0 0 0 0 0 0 0 0 0 0 0 0
49641 - 0 0 0 0 0 0 0 0 0 0 0 0
49642 - 0 0 0 0 0 0 0 0 0 0 0 0
49643 - 0 0 0 0 0 0 0 0 0 0 0 0
49644 - 0 0 0 0 0 0 0 0 0 6 6 6
49645 - 30 30 30 78 78 78 30 30 30 2 2 6
49646 - 2 2 6 2 2 6 2 2 6 2 2 6
49647 - 2 2 6 2 2 6 2 2 6 2 2 6
49648 - 2 2 6 2 2 6 2 2 6 10 10 10
49649 - 10 10 10 2 2 6 2 2 6 2 2 6
49650 - 2 2 6 2 2 6 2 2 6 78 78 78
49651 - 50 50 50 18 18 18 6 6 6 0 0 0
49652 - 0 0 0 0 0 0 0 0 0 0 0 0
49653 - 0 0 0 0 0 0 0 0 0 0 0 0
49654 - 0 0 0 0 0 0 0 0 0 0 0 0
49655 - 0 0 0 0 0 0 0 0 0 0 0 0
49656 - 0 0 0 0 0 0 0 0 0 0 0 0
49657 - 0 0 0 0 0 0 0 0 0 0 0 0
49658 - 0 0 0 0 0 0 0 0 0 0 0 0
49659 - 0 0 1 0 0 0 0 0 0 0 0 0
49660 - 0 0 0 0 0 0 0 0 0 0 0 0
49661 - 0 0 0 0 0 0 0 0 0 0 0 0
49662 - 0 0 0 0 0 0 0 0 0 0 0 0
49663 - 0 0 0 0 0 0 0 0 0 0 0 0
49664 - 0 0 0 0 0 0 0 0 0 10 10 10
49665 - 38 38 38 86 86 86 14 14 14 2 2 6
49666 - 2 2 6 2 2 6 2 2 6 2 2 6
49667 - 2 2 6 2 2 6 2 2 6 2 2 6
49668 - 2 2 6 2 2 6 2 2 6 2 2 6
49669 - 2 2 6 2 2 6 2 2 6 2 2 6
49670 - 2 2 6 2 2 6 2 2 6 54 54 54
49671 - 66 66 66 26 26 26 6 6 6 0 0 0
49672 - 0 0 0 0 0 0 0 0 0 0 0 0
49673 - 0 0 0 0 0 0 0 0 0 0 0 0
49674 - 0 0 0 0 0 0 0 0 0 0 0 0
49675 - 0 0 0 0 0 0 0 0 0 0 0 0
49676 - 0 0 0 0 0 0 0 0 0 0 0 0
49677 - 0 0 0 0 0 0 0 0 0 0 0 0
49678 - 0 0 0 0 0 0 0 0 0 0 0 0
49679 - 0 0 0 0 0 1 0 0 1 0 0 0
49680 - 0 0 0 0 0 0 0 0 0 0 0 0
49681 - 0 0 0 0 0 0 0 0 0 0 0 0
49682 - 0 0 0 0 0 0 0 0 0 0 0 0
49683 - 0 0 0 0 0 0 0 0 0 0 0 0
49684 - 0 0 0 0 0 0 0 0 0 14 14 14
49685 - 42 42 42 82 82 82 2 2 6 2 2 6
49686 - 2 2 6 6 6 6 10 10 10 2 2 6
49687 - 2 2 6 2 2 6 2 2 6 2 2 6
49688 - 2 2 6 2 2 6 2 2 6 6 6 6
49689 - 14 14 14 10 10 10 2 2 6 2 2 6
49690 - 2 2 6 2 2 6 2 2 6 18 18 18
49691 - 82 82 82 34 34 34 10 10 10 0 0 0
49692 - 0 0 0 0 0 0 0 0 0 0 0 0
49693 - 0 0 0 0 0 0 0 0 0 0 0 0
49694 - 0 0 0 0 0 0 0 0 0 0 0 0
49695 - 0 0 0 0 0 0 0 0 0 0 0 0
49696 - 0 0 0 0 0 0 0 0 0 0 0 0
49697 - 0 0 0 0 0 0 0 0 0 0 0 0
49698 - 0 0 0 0 0 0 0 0 0 0 0 0
49699 - 0 0 1 0 0 0 0 0 0 0 0 0
49700 - 0 0 0 0 0 0 0 0 0 0 0 0
49701 - 0 0 0 0 0 0 0 0 0 0 0 0
49702 - 0 0 0 0 0 0 0 0 0 0 0 0
49703 - 0 0 0 0 0 0 0 0 0 0 0 0
49704 - 0 0 0 0 0 0 0 0 0 14 14 14
49705 - 46 46 46 86 86 86 2 2 6 2 2 6
49706 - 6 6 6 6 6 6 22 22 22 34 34 34
49707 - 6 6 6 2 2 6 2 2 6 2 2 6
49708 - 2 2 6 2 2 6 18 18 18 34 34 34
49709 - 10 10 10 50 50 50 22 22 22 2 2 6
49710 - 2 2 6 2 2 6 2 2 6 10 10 10
49711 - 86 86 86 42 42 42 14 14 14 0 0 0
49712 - 0 0 0 0 0 0 0 0 0 0 0 0
49713 - 0 0 0 0 0 0 0 0 0 0 0 0
49714 - 0 0 0 0 0 0 0 0 0 0 0 0
49715 - 0 0 0 0 0 0 0 0 0 0 0 0
49716 - 0 0 0 0 0 0 0 0 0 0 0 0
49717 - 0 0 0 0 0 0 0 0 0 0 0 0
49718 - 0 0 0 0 0 0 0 0 0 0 0 0
49719 - 0 0 1 0 0 1 0 0 1 0 0 0
49720 - 0 0 0 0 0 0 0 0 0 0 0 0
49721 - 0 0 0 0 0 0 0 0 0 0 0 0
49722 - 0 0 0 0 0 0 0 0 0 0 0 0
49723 - 0 0 0 0 0 0 0 0 0 0 0 0
49724 - 0 0 0 0 0 0 0 0 0 14 14 14
49725 - 46 46 46 86 86 86 2 2 6 2 2 6
49726 - 38 38 38 116 116 116 94 94 94 22 22 22
49727 - 22 22 22 2 2 6 2 2 6 2 2 6
49728 - 14 14 14 86 86 86 138 138 138 162 162 162
49729 -154 154 154 38 38 38 26 26 26 6 6 6
49730 - 2 2 6 2 2 6 2 2 6 2 2 6
49731 - 86 86 86 46 46 46 14 14 14 0 0 0
49732 - 0 0 0 0 0 0 0 0 0 0 0 0
49733 - 0 0 0 0 0 0 0 0 0 0 0 0
49734 - 0 0 0 0 0 0 0 0 0 0 0 0
49735 - 0 0 0 0 0 0 0 0 0 0 0 0
49736 - 0 0 0 0 0 0 0 0 0 0 0 0
49737 - 0 0 0 0 0 0 0 0 0 0 0 0
49738 - 0 0 0 0 0 0 0 0 0 0 0 0
49739 - 0 0 0 0 0 0 0 0 0 0 0 0
49740 - 0 0 0 0 0 0 0 0 0 0 0 0
49741 - 0 0 0 0 0 0 0 0 0 0 0 0
49742 - 0 0 0 0 0 0 0 0 0 0 0 0
49743 - 0 0 0 0 0 0 0 0 0 0 0 0
49744 - 0 0 0 0 0 0 0 0 0 14 14 14
49745 - 46 46 46 86 86 86 2 2 6 14 14 14
49746 -134 134 134 198 198 198 195 195 195 116 116 116
49747 - 10 10 10 2 2 6 2 2 6 6 6 6
49748 -101 98 89 187 187 187 210 210 210 218 218 218
49749 -214 214 214 134 134 134 14 14 14 6 6 6
49750 - 2 2 6 2 2 6 2 2 6 2 2 6
49751 - 86 86 86 50 50 50 18 18 18 6 6 6
49752 - 0 0 0 0 0 0 0 0 0 0 0 0
49753 - 0 0 0 0 0 0 0 0 0 0 0 0
49754 - 0 0 0 0 0 0 0 0 0 0 0 0
49755 - 0 0 0 0 0 0 0 0 0 0 0 0
49756 - 0 0 0 0 0 0 0 0 0 0 0 0
49757 - 0 0 0 0 0 0 0 0 0 0 0 0
49758 - 0 0 0 0 0 0 0 0 1 0 0 0
49759 - 0 0 1 0 0 1 0 0 1 0 0 0
49760 - 0 0 0 0 0 0 0 0 0 0 0 0
49761 - 0 0 0 0 0 0 0 0 0 0 0 0
49762 - 0 0 0 0 0 0 0 0 0 0 0 0
49763 - 0 0 0 0 0 0 0 0 0 0 0 0
49764 - 0 0 0 0 0 0 0 0 0 14 14 14
49765 - 46 46 46 86 86 86 2 2 6 54 54 54
49766 -218 218 218 195 195 195 226 226 226 246 246 246
49767 - 58 58 58 2 2 6 2 2 6 30 30 30
49768 -210 210 210 253 253 253 174 174 174 123 123 123
49769 -221 221 221 234 234 234 74 74 74 2 2 6
49770 - 2 2 6 2 2 6 2 2 6 2 2 6
49771 - 70 70 70 58 58 58 22 22 22 6 6 6
49772 - 0 0 0 0 0 0 0 0 0 0 0 0
49773 - 0 0 0 0 0 0 0 0 0 0 0 0
49774 - 0 0 0 0 0 0 0 0 0 0 0 0
49775 - 0 0 0 0 0 0 0 0 0 0 0 0
49776 - 0 0 0 0 0 0 0 0 0 0 0 0
49777 - 0 0 0 0 0 0 0 0 0 0 0 0
49778 - 0 0 0 0 0 0 0 0 0 0 0 0
49779 - 0 0 0 0 0 0 0 0 0 0 0 0
49780 - 0 0 0 0 0 0 0 0 0 0 0 0
49781 - 0 0 0 0 0 0 0 0 0 0 0 0
49782 - 0 0 0 0 0 0 0 0 0 0 0 0
49783 - 0 0 0 0 0 0 0 0 0 0 0 0
49784 - 0 0 0 0 0 0 0 0 0 14 14 14
49785 - 46 46 46 82 82 82 2 2 6 106 106 106
49786 -170 170 170 26 26 26 86 86 86 226 226 226
49787 -123 123 123 10 10 10 14 14 14 46 46 46
49788 -231 231 231 190 190 190 6 6 6 70 70 70
49789 - 90 90 90 238 238 238 158 158 158 2 2 6
49790 - 2 2 6 2 2 6 2 2 6 2 2 6
49791 - 70 70 70 58 58 58 22 22 22 6 6 6
49792 - 0 0 0 0 0 0 0 0 0 0 0 0
49793 - 0 0 0 0 0 0 0 0 0 0 0 0
49794 - 0 0 0 0 0 0 0 0 0 0 0 0
49795 - 0 0 0 0 0 0 0 0 0 0 0 0
49796 - 0 0 0 0 0 0 0 0 0 0 0 0
49797 - 0 0 0 0 0 0 0 0 0 0 0 0
49798 - 0 0 0 0 0 0 0 0 1 0 0 0
49799 - 0 0 1 0 0 1 0 0 1 0 0 0
49800 - 0 0 0 0 0 0 0 0 0 0 0 0
49801 - 0 0 0 0 0 0 0 0 0 0 0 0
49802 - 0 0 0 0 0 0 0 0 0 0 0 0
49803 - 0 0 0 0 0 0 0 0 0 0 0 0
49804 - 0 0 0 0 0 0 0 0 0 14 14 14
49805 - 42 42 42 86 86 86 6 6 6 116 116 116
49806 -106 106 106 6 6 6 70 70 70 149 149 149
49807 -128 128 128 18 18 18 38 38 38 54 54 54
49808 -221 221 221 106 106 106 2 2 6 14 14 14
49809 - 46 46 46 190 190 190 198 198 198 2 2 6
49810 - 2 2 6 2 2 6 2 2 6 2 2 6
49811 - 74 74 74 62 62 62 22 22 22 6 6 6
49812 - 0 0 0 0 0 0 0 0 0 0 0 0
49813 - 0 0 0 0 0 0 0 0 0 0 0 0
49814 - 0 0 0 0 0 0 0 0 0 0 0 0
49815 - 0 0 0 0 0 0 0 0 0 0 0 0
49816 - 0 0 0 0 0 0 0 0 0 0 0 0
49817 - 0 0 0 0 0 0 0 0 0 0 0 0
49818 - 0 0 0 0 0 0 0 0 1 0 0 0
49819 - 0 0 1 0 0 0 0 0 1 0 0 0
49820 - 0 0 0 0 0 0 0 0 0 0 0 0
49821 - 0 0 0 0 0 0 0 0 0 0 0 0
49822 - 0 0 0 0 0 0 0 0 0 0 0 0
49823 - 0 0 0 0 0 0 0 0 0 0 0 0
49824 - 0 0 0 0 0 0 0 0 0 14 14 14
49825 - 42 42 42 94 94 94 14 14 14 101 101 101
49826 -128 128 128 2 2 6 18 18 18 116 116 116
49827 -118 98 46 121 92 8 121 92 8 98 78 10
49828 -162 162 162 106 106 106 2 2 6 2 2 6
49829 - 2 2 6 195 195 195 195 195 195 6 6 6
49830 - 2 2 6 2 2 6 2 2 6 2 2 6
49831 - 74 74 74 62 62 62 22 22 22 6 6 6
49832 - 0 0 0 0 0 0 0 0 0 0 0 0
49833 - 0 0 0 0 0 0 0 0 0 0 0 0
49834 - 0 0 0 0 0 0 0 0 0 0 0 0
49835 - 0 0 0 0 0 0 0 0 0 0 0 0
49836 - 0 0 0 0 0 0 0 0 0 0 0 0
49837 - 0 0 0 0 0 0 0 0 0 0 0 0
49838 - 0 0 0 0 0 0 0 0 1 0 0 1
49839 - 0 0 1 0 0 0 0 0 1 0 0 0
49840 - 0 0 0 0 0 0 0 0 0 0 0 0
49841 - 0 0 0 0 0 0 0 0 0 0 0 0
49842 - 0 0 0 0 0 0 0 0 0 0 0 0
49843 - 0 0 0 0 0 0 0 0 0 0 0 0
49844 - 0 0 0 0 0 0 0 0 0 10 10 10
49845 - 38 38 38 90 90 90 14 14 14 58 58 58
49846 -210 210 210 26 26 26 54 38 6 154 114 10
49847 -226 170 11 236 186 11 225 175 15 184 144 12
49848 -215 174 15 175 146 61 37 26 9 2 2 6
49849 - 70 70 70 246 246 246 138 138 138 2 2 6
49850 - 2 2 6 2 2 6 2 2 6 2 2 6
49851 - 70 70 70 66 66 66 26 26 26 6 6 6
49852 - 0 0 0 0 0 0 0 0 0 0 0 0
49853 - 0 0 0 0 0 0 0 0 0 0 0 0
49854 - 0 0 0 0 0 0 0 0 0 0 0 0
49855 - 0 0 0 0 0 0 0 0 0 0 0 0
49856 - 0 0 0 0 0 0 0 0 0 0 0 0
49857 - 0 0 0 0 0 0 0 0 0 0 0 0
49858 - 0 0 0 0 0 0 0 0 0 0 0 0
49859 - 0 0 0 0 0 0 0 0 0 0 0 0
49860 - 0 0 0 0 0 0 0 0 0 0 0 0
49861 - 0 0 0 0 0 0 0 0 0 0 0 0
49862 - 0 0 0 0 0 0 0 0 0 0 0 0
49863 - 0 0 0 0 0 0 0 0 0 0 0 0
49864 - 0 0 0 0 0 0 0 0 0 10 10 10
49865 - 38 38 38 86 86 86 14 14 14 10 10 10
49866 -195 195 195 188 164 115 192 133 9 225 175 15
49867 -239 182 13 234 190 10 232 195 16 232 200 30
49868 -245 207 45 241 208 19 232 195 16 184 144 12
49869 -218 194 134 211 206 186 42 42 42 2 2 6
49870 - 2 2 6 2 2 6 2 2 6 2 2 6
49871 - 50 50 50 74 74 74 30 30 30 6 6 6
49872 - 0 0 0 0 0 0 0 0 0 0 0 0
49873 - 0 0 0 0 0 0 0 0 0 0 0 0
49874 - 0 0 0 0 0 0 0 0 0 0 0 0
49875 - 0 0 0 0 0 0 0 0 0 0 0 0
49876 - 0 0 0 0 0 0 0 0 0 0 0 0
49877 - 0 0 0 0 0 0 0 0 0 0 0 0
49878 - 0 0 0 0 0 0 0 0 0 0 0 0
49879 - 0 0 0 0 0 0 0 0 0 0 0 0
49880 - 0 0 0 0 0 0 0 0 0 0 0 0
49881 - 0 0 0 0 0 0 0 0 0 0 0 0
49882 - 0 0 0 0 0 0 0 0 0 0 0 0
49883 - 0 0 0 0 0 0 0 0 0 0 0 0
49884 - 0 0 0 0 0 0 0 0 0 10 10 10
49885 - 34 34 34 86 86 86 14 14 14 2 2 6
49886 -121 87 25 192 133 9 219 162 10 239 182 13
49887 -236 186 11 232 195 16 241 208 19 244 214 54
49888 -246 218 60 246 218 38 246 215 20 241 208 19
49889 -241 208 19 226 184 13 121 87 25 2 2 6
49890 - 2 2 6 2 2 6 2 2 6 2 2 6
49891 - 50 50 50 82 82 82 34 34 34 10 10 10
49892 - 0 0 0 0 0 0 0 0 0 0 0 0
49893 - 0 0 0 0 0 0 0 0 0 0 0 0
49894 - 0 0 0 0 0 0 0 0 0 0 0 0
49895 - 0 0 0 0 0 0 0 0 0 0 0 0
49896 - 0 0 0 0 0 0 0 0 0 0 0 0
49897 - 0 0 0 0 0 0 0 0 0 0 0 0
49898 - 0 0 0 0 0 0 0 0 0 0 0 0
49899 - 0 0 0 0 0 0 0 0 0 0 0 0
49900 - 0 0 0 0 0 0 0 0 0 0 0 0
49901 - 0 0 0 0 0 0 0 0 0 0 0 0
49902 - 0 0 0 0 0 0 0 0 0 0 0 0
49903 - 0 0 0 0 0 0 0 0 0 0 0 0
49904 - 0 0 0 0 0 0 0 0 0 10 10 10
49905 - 34 34 34 82 82 82 30 30 30 61 42 6
49906 -180 123 7 206 145 10 230 174 11 239 182 13
49907 -234 190 10 238 202 15 241 208 19 246 218 74
49908 -246 218 38 246 215 20 246 215 20 246 215 20
49909 -226 184 13 215 174 15 184 144 12 6 6 6
49910 - 2 2 6 2 2 6 2 2 6 2 2 6
49911 - 26 26 26 94 94 94 42 42 42 14 14 14
49912 - 0 0 0 0 0 0 0 0 0 0 0 0
49913 - 0 0 0 0 0 0 0 0 0 0 0 0
49914 - 0 0 0 0 0 0 0 0 0 0 0 0
49915 - 0 0 0 0 0 0 0 0 0 0 0 0
49916 - 0 0 0 0 0 0 0 0 0 0 0 0
49917 - 0 0 0 0 0 0 0 0 0 0 0 0
49918 - 0 0 0 0 0 0 0 0 0 0 0 0
49919 - 0 0 0 0 0 0 0 0 0 0 0 0
49920 - 0 0 0 0 0 0 0 0 0 0 0 0
49921 - 0 0 0 0 0 0 0 0 0 0 0 0
49922 - 0 0 0 0 0 0 0 0 0 0 0 0
49923 - 0 0 0 0 0 0 0 0 0 0 0 0
49924 - 0 0 0 0 0 0 0 0 0 10 10 10
49925 - 30 30 30 78 78 78 50 50 50 104 69 6
49926 -192 133 9 216 158 10 236 178 12 236 186 11
49927 -232 195 16 241 208 19 244 214 54 245 215 43
49928 -246 215 20 246 215 20 241 208 19 198 155 10
49929 -200 144 11 216 158 10 156 118 10 2 2 6
49930 - 2 2 6 2 2 6 2 2 6 2 2 6
49931 - 6 6 6 90 90 90 54 54 54 18 18 18
49932 - 6 6 6 0 0 0 0 0 0 0 0 0
49933 - 0 0 0 0 0 0 0 0 0 0 0 0
49934 - 0 0 0 0 0 0 0 0 0 0 0 0
49935 - 0 0 0 0 0 0 0 0 0 0 0 0
49936 - 0 0 0 0 0 0 0 0 0 0 0 0
49937 - 0 0 0 0 0 0 0 0 0 0 0 0
49938 - 0 0 0 0 0 0 0 0 0 0 0 0
49939 - 0 0 0 0 0 0 0 0 0 0 0 0
49940 - 0 0 0 0 0 0 0 0 0 0 0 0
49941 - 0 0 0 0 0 0 0 0 0 0 0 0
49942 - 0 0 0 0 0 0 0 0 0 0 0 0
49943 - 0 0 0 0 0 0 0 0 0 0 0 0
49944 - 0 0 0 0 0 0 0 0 0 10 10 10
49945 - 30 30 30 78 78 78 46 46 46 22 22 22
49946 -137 92 6 210 162 10 239 182 13 238 190 10
49947 -238 202 15 241 208 19 246 215 20 246 215 20
49948 -241 208 19 203 166 17 185 133 11 210 150 10
49949 -216 158 10 210 150 10 102 78 10 2 2 6
49950 - 6 6 6 54 54 54 14 14 14 2 2 6
49951 - 2 2 6 62 62 62 74 74 74 30 30 30
49952 - 10 10 10 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 - 0 0 0 0 0 0 0 0 0 0 0 0
49960 - 0 0 0 0 0 0 0 0 0 0 0 0
49961 - 0 0 0 0 0 0 0 0 0 0 0 0
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 10 10 10
49965 - 34 34 34 78 78 78 50 50 50 6 6 6
49966 - 94 70 30 139 102 15 190 146 13 226 184 13
49967 -232 200 30 232 195 16 215 174 15 190 146 13
49968 -168 122 10 192 133 9 210 150 10 213 154 11
49969 -202 150 34 182 157 106 101 98 89 2 2 6
49970 - 2 2 6 78 78 78 116 116 116 58 58 58
49971 - 2 2 6 22 22 22 90 90 90 46 46 46
49972 - 18 18 18 6 6 6 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 0 0 0 0 0 0 0 0 0
49979 - 0 0 0 0 0 0 0 0 0 0 0 0
49980 - 0 0 0 0 0 0 0 0 0 0 0 0
49981 - 0 0 0 0 0 0 0 0 0 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 10 10 10
49985 - 38 38 38 86 86 86 50 50 50 6 6 6
49986 -128 128 128 174 154 114 156 107 11 168 122 10
49987 -198 155 10 184 144 12 197 138 11 200 144 11
49988 -206 145 10 206 145 10 197 138 11 188 164 115
49989 -195 195 195 198 198 198 174 174 174 14 14 14
49990 - 2 2 6 22 22 22 116 116 116 116 116 116
49991 - 22 22 22 2 2 6 74 74 74 70 70 70
49992 - 30 30 30 10 10 10 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 - 0 0 0 0 0 0 0 0 0 0 0 0
49999 - 0 0 0 0 0 0 0 0 0 0 0 0
50000 - 0 0 0 0 0 0 0 0 0 0 0 0
50001 - 0 0 0 0 0 0 0 0 0 0 0 0
50002 - 0 0 0 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 6 6 6 18 18 18
50005 - 50 50 50 101 101 101 26 26 26 10 10 10
50006 -138 138 138 190 190 190 174 154 114 156 107 11
50007 -197 138 11 200 144 11 197 138 11 192 133 9
50008 -180 123 7 190 142 34 190 178 144 187 187 187
50009 -202 202 202 221 221 221 214 214 214 66 66 66
50010 - 2 2 6 2 2 6 50 50 50 62 62 62
50011 - 6 6 6 2 2 6 10 10 10 90 90 90
50012 - 50 50 50 18 18 18 6 6 6 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 0 0 0
50018 - 0 0 0 0 0 0 0 0 0 0 0 0
50019 - 0 0 0 0 0 0 0 0 0 0 0 0
50020 - 0 0 0 0 0 0 0 0 0 0 0 0
50021 - 0 0 0 0 0 0 0 0 0 0 0 0
50022 - 0 0 0 0 0 0 0 0 0 0 0 0
50023 - 0 0 0 0 0 0 0 0 0 0 0 0
50024 - 0 0 0 0 0 0 10 10 10 34 34 34
50025 - 74 74 74 74 74 74 2 2 6 6 6 6
50026 -144 144 144 198 198 198 190 190 190 178 166 146
50027 -154 121 60 156 107 11 156 107 11 168 124 44
50028 -174 154 114 187 187 187 190 190 190 210 210 210
50029 -246 246 246 253 253 253 253 253 253 182 182 182
50030 - 6 6 6 2 2 6 2 2 6 2 2 6
50031 - 2 2 6 2 2 6 2 2 6 62 62 62
50032 - 74 74 74 34 34 34 14 14 14 0 0 0
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 0 0 0 0 0 0
50038 - 0 0 0 0 0 0 0 0 0 0 0 0
50039 - 0 0 0 0 0 0 0 0 0 0 0 0
50040 - 0 0 0 0 0 0 0 0 0 0 0 0
50041 - 0 0 0 0 0 0 0 0 0 0 0 0
50042 - 0 0 0 0 0 0 0 0 0 0 0 0
50043 - 0 0 0 0 0 0 0 0 0 0 0 0
50044 - 0 0 0 10 10 10 22 22 22 54 54 54
50045 - 94 94 94 18 18 18 2 2 6 46 46 46
50046 -234 234 234 221 221 221 190 190 190 190 190 190
50047 -190 190 190 187 187 187 187 187 187 190 190 190
50048 -190 190 190 195 195 195 214 214 214 242 242 242
50049 -253 253 253 253 253 253 253 253 253 253 253 253
50050 - 82 82 82 2 2 6 2 2 6 2 2 6
50051 - 2 2 6 2 2 6 2 2 6 14 14 14
50052 - 86 86 86 54 54 54 22 22 22 6 6 6
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 0 0 0 0 0 0 0 0 0
50058 - 0 0 0 0 0 0 0 0 0 0 0 0
50059 - 0 0 0 0 0 0 0 0 0 0 0 0
50060 - 0 0 0 0 0 0 0 0 0 0 0 0
50061 - 0 0 0 0 0 0 0 0 0 0 0 0
50062 - 0 0 0 0 0 0 0 0 0 0 0 0
50063 - 0 0 0 0 0 0 0 0 0 0 0 0
50064 - 6 6 6 18 18 18 46 46 46 90 90 90
50065 - 46 46 46 18 18 18 6 6 6 182 182 182
50066 -253 253 253 246 246 246 206 206 206 190 190 190
50067 -190 190 190 190 190 190 190 190 190 190 190 190
50068 -206 206 206 231 231 231 250 250 250 253 253 253
50069 -253 253 253 253 253 253 253 253 253 253 253 253
50070 -202 202 202 14 14 14 2 2 6 2 2 6
50071 - 2 2 6 2 2 6 2 2 6 2 2 6
50072 - 42 42 42 86 86 86 42 42 42 18 18 18
50073 - 6 6 6 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 - 0 0 0 0 0 0 0 0 0 0 0 0
50078 - 0 0 0 0 0 0 0 0 0 0 0 0
50079 - 0 0 0 0 0 0 0 0 0 0 0 0
50080 - 0 0 0 0 0 0 0 0 0 0 0 0
50081 - 0 0 0 0 0 0 0 0 0 0 0 0
50082 - 0 0 0 0 0 0 0 0 0 0 0 0
50083 - 0 0 0 0 0 0 0 0 0 6 6 6
50084 - 14 14 14 38 38 38 74 74 74 66 66 66
50085 - 2 2 6 6 6 6 90 90 90 250 250 250
50086 -253 253 253 253 253 253 238 238 238 198 198 198
50087 -190 190 190 190 190 190 195 195 195 221 221 221
50088 -246 246 246 253 253 253 253 253 253 253 253 253
50089 -253 253 253 253 253 253 253 253 253 253 253 253
50090 -253 253 253 82 82 82 2 2 6 2 2 6
50091 - 2 2 6 2 2 6 2 2 6 2 2 6
50092 - 2 2 6 78 78 78 70 70 70 34 34 34
50093 - 14 14 14 6 6 6 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 - 0 0 0 0 0 0 0 0 0 0 0 0
50098 - 0 0 0 0 0 0 0 0 0 0 0 0
50099 - 0 0 0 0 0 0 0 0 0 0 0 0
50100 - 0 0 0 0 0 0 0 0 0 0 0 0
50101 - 0 0 0 0 0 0 0 0 0 0 0 0
50102 - 0 0 0 0 0 0 0 0 0 0 0 0
50103 - 0 0 0 0 0 0 0 0 0 14 14 14
50104 - 34 34 34 66 66 66 78 78 78 6 6 6
50105 - 2 2 6 18 18 18 218 218 218 253 253 253
50106 -253 253 253 253 253 253 253 253 253 246 246 246
50107 -226 226 226 231 231 231 246 246 246 253 253 253
50108 -253 253 253 253 253 253 253 253 253 253 253 253
50109 -253 253 253 253 253 253 253 253 253 253 253 253
50110 -253 253 253 178 178 178 2 2 6 2 2 6
50111 - 2 2 6 2 2 6 2 2 6 2 2 6
50112 - 2 2 6 18 18 18 90 90 90 62 62 62
50113 - 30 30 30 10 10 10 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 - 0 0 0 0 0 0 0 0 0 0 0 0
50118 - 0 0 0 0 0 0 0 0 0 0 0 0
50119 - 0 0 0 0 0 0 0 0 0 0 0 0
50120 - 0 0 0 0 0 0 0 0 0 0 0 0
50121 - 0 0 0 0 0 0 0 0 0 0 0 0
50122 - 0 0 0 0 0 0 0 0 0 0 0 0
50123 - 0 0 0 0 0 0 10 10 10 26 26 26
50124 - 58 58 58 90 90 90 18 18 18 2 2 6
50125 - 2 2 6 110 110 110 253 253 253 253 253 253
50126 -253 253 253 253 253 253 253 253 253 253 253 253
50127 -250 250 250 253 253 253 253 253 253 253 253 253
50128 -253 253 253 253 253 253 253 253 253 253 253 253
50129 -253 253 253 253 253 253 253 253 253 253 253 253
50130 -253 253 253 231 231 231 18 18 18 2 2 6
50131 - 2 2 6 2 2 6 2 2 6 2 2 6
50132 - 2 2 6 2 2 6 18 18 18 94 94 94
50133 - 54 54 54 26 26 26 10 10 10 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 0 0 0
50137 - 0 0 0 0 0 0 0 0 0 0 0 0
50138 - 0 0 0 0 0 0 0 0 0 0 0 0
50139 - 0 0 0 0 0 0 0 0 0 0 0 0
50140 - 0 0 0 0 0 0 0 0 0 0 0 0
50141 - 0 0 0 0 0 0 0 0 0 0 0 0
50142 - 0 0 0 0 0 0 0 0 0 0 0 0
50143 - 0 0 0 6 6 6 22 22 22 50 50 50
50144 - 90 90 90 26 26 26 2 2 6 2 2 6
50145 - 14 14 14 195 195 195 250 250 250 253 253 253
50146 -253 253 253 253 253 253 253 253 253 253 253 253
50147 -253 253 253 253 253 253 253 253 253 253 253 253
50148 -253 253 253 253 253 253 253 253 253 253 253 253
50149 -253 253 253 253 253 253 253 253 253 253 253 253
50150 -250 250 250 242 242 242 54 54 54 2 2 6
50151 - 2 2 6 2 2 6 2 2 6 2 2 6
50152 - 2 2 6 2 2 6 2 2 6 38 38 38
50153 - 86 86 86 50 50 50 22 22 22 6 6 6
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 0 0 0
50157 - 0 0 0 0 0 0 0 0 0 0 0 0
50158 - 0 0 0 0 0 0 0 0 0 0 0 0
50159 - 0 0 0 0 0 0 0 0 0 0 0 0
50160 - 0 0 0 0 0 0 0 0 0 0 0 0
50161 - 0 0 0 0 0 0 0 0 0 0 0 0
50162 - 0 0 0 0 0 0 0 0 0 0 0 0
50163 - 6 6 6 14 14 14 38 38 38 82 82 82
50164 - 34 34 34 2 2 6 2 2 6 2 2 6
50165 - 42 42 42 195 195 195 246 246 246 253 253 253
50166 -253 253 253 253 253 253 253 253 253 250 250 250
50167 -242 242 242 242 242 242 250 250 250 253 253 253
50168 -253 253 253 253 253 253 253 253 253 253 253 253
50169 -253 253 253 250 250 250 246 246 246 238 238 238
50170 -226 226 226 231 231 231 101 101 101 6 6 6
50171 - 2 2 6 2 2 6 2 2 6 2 2 6
50172 - 2 2 6 2 2 6 2 2 6 2 2 6
50173 - 38 38 38 82 82 82 42 42 42 14 14 14
50174 - 6 6 6 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 0 0 0
50177 - 0 0 0 0 0 0 0 0 0 0 0 0
50178 - 0 0 0 0 0 0 0 0 0 0 0 0
50179 - 0 0 0 0 0 0 0 0 0 0 0 0
50180 - 0 0 0 0 0 0 0 0 0 0 0 0
50181 - 0 0 0 0 0 0 0 0 0 0 0 0
50182 - 0 0 0 0 0 0 0 0 0 0 0 0
50183 - 10 10 10 26 26 26 62 62 62 66 66 66
50184 - 2 2 6 2 2 6 2 2 6 6 6 6
50185 - 70 70 70 170 170 170 206 206 206 234 234 234
50186 -246 246 246 250 250 250 250 250 250 238 238 238
50187 -226 226 226 231 231 231 238 238 238 250 250 250
50188 -250 250 250 250 250 250 246 246 246 231 231 231
50189 -214 214 214 206 206 206 202 202 202 202 202 202
50190 -198 198 198 202 202 202 182 182 182 18 18 18
50191 - 2 2 6 2 2 6 2 2 6 2 2 6
50192 - 2 2 6 2 2 6 2 2 6 2 2 6
50193 - 2 2 6 62 62 62 66 66 66 30 30 30
50194 - 10 10 10 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 0 0 0
50197 - 0 0 0 0 0 0 0 0 0 0 0 0
50198 - 0 0 0 0 0 0 0 0 0 0 0 0
50199 - 0 0 0 0 0 0 0 0 0 0 0 0
50200 - 0 0 0 0 0 0 0 0 0 0 0 0
50201 - 0 0 0 0 0 0 0 0 0 0 0 0
50202 - 0 0 0 0 0 0 0 0 0 0 0 0
50203 - 14 14 14 42 42 42 82 82 82 18 18 18
50204 - 2 2 6 2 2 6 2 2 6 10 10 10
50205 - 94 94 94 182 182 182 218 218 218 242 242 242
50206 -250 250 250 253 253 253 253 253 253 250 250 250
50207 -234 234 234 253 253 253 253 253 253 253 253 253
50208 -253 253 253 253 253 253 253 253 253 246 246 246
50209 -238 238 238 226 226 226 210 210 210 202 202 202
50210 -195 195 195 195 195 195 210 210 210 158 158 158
50211 - 6 6 6 14 14 14 50 50 50 14 14 14
50212 - 2 2 6 2 2 6 2 2 6 2 2 6
50213 - 2 2 6 6 6 6 86 86 86 46 46 46
50214 - 18 18 18 6 6 6 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 0 0 0
50217 - 0 0 0 0 0 0 0 0 0 0 0 0
50218 - 0 0 0 0 0 0 0 0 0 0 0 0
50219 - 0 0 0 0 0 0 0 0 0 0 0 0
50220 - 0 0 0 0 0 0 0 0 0 0 0 0
50221 - 0 0 0 0 0 0 0 0 0 0 0 0
50222 - 0 0 0 0 0 0 0 0 0 6 6 6
50223 - 22 22 22 54 54 54 70 70 70 2 2 6
50224 - 2 2 6 10 10 10 2 2 6 22 22 22
50225 -166 166 166 231 231 231 250 250 250 253 253 253
50226 -253 253 253 253 253 253 253 253 253 250 250 250
50227 -242 242 242 253 253 253 253 253 253 253 253 253
50228 -253 253 253 253 253 253 253 253 253 253 253 253
50229 -253 253 253 253 253 253 253 253 253 246 246 246
50230 -231 231 231 206 206 206 198 198 198 226 226 226
50231 - 94 94 94 2 2 6 6 6 6 38 38 38
50232 - 30 30 30 2 2 6 2 2 6 2 2 6
50233 - 2 2 6 2 2 6 62 62 62 66 66 66
50234 - 26 26 26 10 10 10 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 0 0 0
50237 - 0 0 0 0 0 0 0 0 0 0 0 0
50238 - 0 0 0 0 0 0 0 0 0 0 0 0
50239 - 0 0 0 0 0 0 0 0 0 0 0 0
50240 - 0 0 0 0 0 0 0 0 0 0 0 0
50241 - 0 0 0 0 0 0 0 0 0 0 0 0
50242 - 0 0 0 0 0 0 0 0 0 10 10 10
50243 - 30 30 30 74 74 74 50 50 50 2 2 6
50244 - 26 26 26 26 26 26 2 2 6 106 106 106
50245 -238 238 238 253 253 253 253 253 253 253 253 253
50246 -253 253 253 253 253 253 253 253 253 253 253 253
50247 -253 253 253 253 253 253 253 253 253 253 253 253
50248 -253 253 253 253 253 253 253 253 253 253 253 253
50249 -253 253 253 253 253 253 253 253 253 253 253 253
50250 -253 253 253 246 246 246 218 218 218 202 202 202
50251 -210 210 210 14 14 14 2 2 6 2 2 6
50252 - 30 30 30 22 22 22 2 2 6 2 2 6
50253 - 2 2 6 2 2 6 18 18 18 86 86 86
50254 - 42 42 42 14 14 14 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 0 0 0
50257 - 0 0 0 0 0 0 0 0 0 0 0 0
50258 - 0 0 0 0 0 0 0 0 0 0 0 0
50259 - 0 0 0 0 0 0 0 0 0 0 0 0
50260 - 0 0 0 0 0 0 0 0 0 0 0 0
50261 - 0 0 0 0 0 0 0 0 0 0 0 0
50262 - 0 0 0 0 0 0 0 0 0 14 14 14
50263 - 42 42 42 90 90 90 22 22 22 2 2 6
50264 - 42 42 42 2 2 6 18 18 18 218 218 218
50265 -253 253 253 253 253 253 253 253 253 253 253 253
50266 -253 253 253 253 253 253 253 253 253 253 253 253
50267 -253 253 253 253 253 253 253 253 253 253 253 253
50268 -253 253 253 253 253 253 253 253 253 253 253 253
50269 -253 253 253 253 253 253 253 253 253 253 253 253
50270 -253 253 253 253 253 253 250 250 250 221 221 221
50271 -218 218 218 101 101 101 2 2 6 14 14 14
50272 - 18 18 18 38 38 38 10 10 10 2 2 6
50273 - 2 2 6 2 2 6 2 2 6 78 78 78
50274 - 58 58 58 22 22 22 6 6 6 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 0 0 0
50277 - 0 0 0 0 0 0 0 0 0 0 0 0
50278 - 0 0 0 0 0 0 0 0 0 0 0 0
50279 - 0 0 0 0 0 0 0 0 0 0 0 0
50280 - 0 0 0 0 0 0 0 0 0 0 0 0
50281 - 0 0 0 0 0 0 0 0 0 0 0 0
50282 - 0 0 0 0 0 0 6 6 6 18 18 18
50283 - 54 54 54 82 82 82 2 2 6 26 26 26
50284 - 22 22 22 2 2 6 123 123 123 253 253 253
50285 -253 253 253 253 253 253 253 253 253 253 253 253
50286 -253 253 253 253 253 253 253 253 253 253 253 253
50287 -253 253 253 253 253 253 253 253 253 253 253 253
50288 -253 253 253 253 253 253 253 253 253 253 253 253
50289 -253 253 253 253 253 253 253 253 253 253 253 253
50290 -253 253 253 253 253 253 253 253 253 250 250 250
50291 -238 238 238 198 198 198 6 6 6 38 38 38
50292 - 58 58 58 26 26 26 38 38 38 2 2 6
50293 - 2 2 6 2 2 6 2 2 6 46 46 46
50294 - 78 78 78 30 30 30 10 10 10 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 0 0 0
50297 - 0 0 0 0 0 0 0 0 0 0 0 0
50298 - 0 0 0 0 0 0 0 0 0 0 0 0
50299 - 0 0 0 0 0 0 0 0 0 0 0 0
50300 - 0 0 0 0 0 0 0 0 0 0 0 0
50301 - 0 0 0 0 0 0 0 0 0 0 0 0
50302 - 0 0 0 0 0 0 10 10 10 30 30 30
50303 - 74 74 74 58 58 58 2 2 6 42 42 42
50304 - 2 2 6 22 22 22 231 231 231 253 253 253
50305 -253 253 253 253 253 253 253 253 253 253 253 253
50306 -253 253 253 253 253 253 253 253 253 250 250 250
50307 -253 253 253 253 253 253 253 253 253 253 253 253
50308 -253 253 253 253 253 253 253 253 253 253 253 253
50309 -253 253 253 253 253 253 253 253 253 253 253 253
50310 -253 253 253 253 253 253 253 253 253 253 253 253
50311 -253 253 253 246 246 246 46 46 46 38 38 38
50312 - 42 42 42 14 14 14 38 38 38 14 14 14
50313 - 2 2 6 2 2 6 2 2 6 6 6 6
50314 - 86 86 86 46 46 46 14 14 14 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 0 0 0
50317 - 0 0 0 0 0 0 0 0 0 0 0 0
50318 - 0 0 0 0 0 0 0 0 0 0 0 0
50319 - 0 0 0 0 0 0 0 0 0 0 0 0
50320 - 0 0 0 0 0 0 0 0 0 0 0 0
50321 - 0 0 0 0 0 0 0 0 0 0 0 0
50322 - 0 0 0 6 6 6 14 14 14 42 42 42
50323 - 90 90 90 18 18 18 18 18 18 26 26 26
50324 - 2 2 6 116 116 116 253 253 253 253 253 253
50325 -253 253 253 253 253 253 253 253 253 253 253 253
50326 -253 253 253 253 253 253 250 250 250 238 238 238
50327 -253 253 253 253 253 253 253 253 253 253 253 253
50328 -253 253 253 253 253 253 253 253 253 253 253 253
50329 -253 253 253 253 253 253 253 253 253 253 253 253
50330 -253 253 253 253 253 253 253 253 253 253 253 253
50331 -253 253 253 253 253 253 94 94 94 6 6 6
50332 - 2 2 6 2 2 6 10 10 10 34 34 34
50333 - 2 2 6 2 2 6 2 2 6 2 2 6
50334 - 74 74 74 58 58 58 22 22 22 6 6 6
50335 - 0 0 0 0 0 0 0 0 0 0 0 0
50336 - 0 0 0 0 0 0 0 0 0 0 0 0
50337 - 0 0 0 0 0 0 0 0 0 0 0 0
50338 - 0 0 0 0 0 0 0 0 0 0 0 0
50339 - 0 0 0 0 0 0 0 0 0 0 0 0
50340 - 0 0 0 0 0 0 0 0 0 0 0 0
50341 - 0 0 0 0 0 0 0 0 0 0 0 0
50342 - 0 0 0 10 10 10 26 26 26 66 66 66
50343 - 82 82 82 2 2 6 38 38 38 6 6 6
50344 - 14 14 14 210 210 210 253 253 253 253 253 253
50345 -253 253 253 253 253 253 253 253 253 253 253 253
50346 -253 253 253 253 253 253 246 246 246 242 242 242
50347 -253 253 253 253 253 253 253 253 253 253 253 253
50348 -253 253 253 253 253 253 253 253 253 253 253 253
50349 -253 253 253 253 253 253 253 253 253 253 253 253
50350 -253 253 253 253 253 253 253 253 253 253 253 253
50351 -253 253 253 253 253 253 144 144 144 2 2 6
50352 - 2 2 6 2 2 6 2 2 6 46 46 46
50353 - 2 2 6 2 2 6 2 2 6 2 2 6
50354 - 42 42 42 74 74 74 30 30 30 10 10 10
50355 - 0 0 0 0 0 0 0 0 0 0 0 0
50356 - 0 0 0 0 0 0 0 0 0 0 0 0
50357 - 0 0 0 0 0 0 0 0 0 0 0 0
50358 - 0 0 0 0 0 0 0 0 0 0 0 0
50359 - 0 0 0 0 0 0 0 0 0 0 0 0
50360 - 0 0 0 0 0 0 0 0 0 0 0 0
50361 - 0 0 0 0 0 0 0 0 0 0 0 0
50362 - 6 6 6 14 14 14 42 42 42 90 90 90
50363 - 26 26 26 6 6 6 42 42 42 2 2 6
50364 - 74 74 74 250 250 250 253 253 253 253 253 253
50365 -253 253 253 253 253 253 253 253 253 253 253 253
50366 -253 253 253 253 253 253 242 242 242 242 242 242
50367 -253 253 253 253 253 253 253 253 253 253 253 253
50368 -253 253 253 253 253 253 253 253 253 253 253 253
50369 -253 253 253 253 253 253 253 253 253 253 253 253
50370 -253 253 253 253 253 253 253 253 253 253 253 253
50371 -253 253 253 253 253 253 182 182 182 2 2 6
50372 - 2 2 6 2 2 6 2 2 6 46 46 46
50373 - 2 2 6 2 2 6 2 2 6 2 2 6
50374 - 10 10 10 86 86 86 38 38 38 10 10 10
50375 - 0 0 0 0 0 0 0 0 0 0 0 0
50376 - 0 0 0 0 0 0 0 0 0 0 0 0
50377 - 0 0 0 0 0 0 0 0 0 0 0 0
50378 - 0 0 0 0 0 0 0 0 0 0 0 0
50379 - 0 0 0 0 0 0 0 0 0 0 0 0
50380 - 0 0 0 0 0 0 0 0 0 0 0 0
50381 - 0 0 0 0 0 0 0 0 0 0 0 0
50382 - 10 10 10 26 26 26 66 66 66 82 82 82
50383 - 2 2 6 22 22 22 18 18 18 2 2 6
50384 -149 149 149 253 253 253 253 253 253 253 253 253
50385 -253 253 253 253 253 253 253 253 253 253 253 253
50386 -253 253 253 253 253 253 234 234 234 242 242 242
50387 -253 253 253 253 253 253 253 253 253 253 253 253
50388 -253 253 253 253 253 253 253 253 253 253 253 253
50389 -253 253 253 253 253 253 253 253 253 253 253 253
50390 -253 253 253 253 253 253 253 253 253 253 253 253
50391 -253 253 253 253 253 253 206 206 206 2 2 6
50392 - 2 2 6 2 2 6 2 2 6 38 38 38
50393 - 2 2 6 2 2 6 2 2 6 2 2 6
50394 - 6 6 6 86 86 86 46 46 46 14 14 14
50395 - 0 0 0 0 0 0 0 0 0 0 0 0
50396 - 0 0 0 0 0 0 0 0 0 0 0 0
50397 - 0 0 0 0 0 0 0 0 0 0 0 0
50398 - 0 0 0 0 0 0 0 0 0 0 0 0
50399 - 0 0 0 0 0 0 0 0 0 0 0 0
50400 - 0 0 0 0 0 0 0 0 0 0 0 0
50401 - 0 0 0 0 0 0 0 0 0 6 6 6
50402 - 18 18 18 46 46 46 86 86 86 18 18 18
50403 - 2 2 6 34 34 34 10 10 10 6 6 6
50404 -210 210 210 253 253 253 253 253 253 253 253 253
50405 -253 253 253 253 253 253 253 253 253 253 253 253
50406 -253 253 253 253 253 253 234 234 234 242 242 242
50407 -253 253 253 253 253 253 253 253 253 253 253 253
50408 -253 253 253 253 253 253 253 253 253 253 253 253
50409 -253 253 253 253 253 253 253 253 253 253 253 253
50410 -253 253 253 253 253 253 253 253 253 253 253 253
50411 -253 253 253 253 253 253 221 221 221 6 6 6
50412 - 2 2 6 2 2 6 6 6 6 30 30 30
50413 - 2 2 6 2 2 6 2 2 6 2 2 6
50414 - 2 2 6 82 82 82 54 54 54 18 18 18
50415 - 6 6 6 0 0 0 0 0 0 0 0 0
50416 - 0 0 0 0 0 0 0 0 0 0 0 0
50417 - 0 0 0 0 0 0 0 0 0 0 0 0
50418 - 0 0 0 0 0 0 0 0 0 0 0 0
50419 - 0 0 0 0 0 0 0 0 0 0 0 0
50420 - 0 0 0 0 0 0 0 0 0 0 0 0
50421 - 0 0 0 0 0 0 0 0 0 10 10 10
50422 - 26 26 26 66 66 66 62 62 62 2 2 6
50423 - 2 2 6 38 38 38 10 10 10 26 26 26
50424 -238 238 238 253 253 253 253 253 253 253 253 253
50425 -253 253 253 253 253 253 253 253 253 253 253 253
50426 -253 253 253 253 253 253 231 231 231 238 238 238
50427 -253 253 253 253 253 253 253 253 253 253 253 253
50428 -253 253 253 253 253 253 253 253 253 253 253 253
50429 -253 253 253 253 253 253 253 253 253 253 253 253
50430 -253 253 253 253 253 253 253 253 253 253 253 253
50431 -253 253 253 253 253 253 231 231 231 6 6 6
50432 - 2 2 6 2 2 6 10 10 10 30 30 30
50433 - 2 2 6 2 2 6 2 2 6 2 2 6
50434 - 2 2 6 66 66 66 58 58 58 22 22 22
50435 - 6 6 6 0 0 0 0 0 0 0 0 0
50436 - 0 0 0 0 0 0 0 0 0 0 0 0
50437 - 0 0 0 0 0 0 0 0 0 0 0 0
50438 - 0 0 0 0 0 0 0 0 0 0 0 0
50439 - 0 0 0 0 0 0 0 0 0 0 0 0
50440 - 0 0 0 0 0 0 0 0 0 0 0 0
50441 - 0 0 0 0 0 0 0 0 0 10 10 10
50442 - 38 38 38 78 78 78 6 6 6 2 2 6
50443 - 2 2 6 46 46 46 14 14 14 42 42 42
50444 -246 246 246 253 253 253 253 253 253 253 253 253
50445 -253 253 253 253 253 253 253 253 253 253 253 253
50446 -253 253 253 253 253 253 231 231 231 242 242 242
50447 -253 253 253 253 253 253 253 253 253 253 253 253
50448 -253 253 253 253 253 253 253 253 253 253 253 253
50449 -253 253 253 253 253 253 253 253 253 253 253 253
50450 -253 253 253 253 253 253 253 253 253 253 253 253
50451 -253 253 253 253 253 253 234 234 234 10 10 10
50452 - 2 2 6 2 2 6 22 22 22 14 14 14
50453 - 2 2 6 2 2 6 2 2 6 2 2 6
50454 - 2 2 6 66 66 66 62 62 62 22 22 22
50455 - 6 6 6 0 0 0 0 0 0 0 0 0
50456 - 0 0 0 0 0 0 0 0 0 0 0 0
50457 - 0 0 0 0 0 0 0 0 0 0 0 0
50458 - 0 0 0 0 0 0 0 0 0 0 0 0
50459 - 0 0 0 0 0 0 0 0 0 0 0 0
50460 - 0 0 0 0 0 0 0 0 0 0 0 0
50461 - 0 0 0 0 0 0 6 6 6 18 18 18
50462 - 50 50 50 74 74 74 2 2 6 2 2 6
50463 - 14 14 14 70 70 70 34 34 34 62 62 62
50464 -250 250 250 253 253 253 253 253 253 253 253 253
50465 -253 253 253 253 253 253 253 253 253 253 253 253
50466 -253 253 253 253 253 253 231 231 231 246 246 246
50467 -253 253 253 253 253 253 253 253 253 253 253 253
50468 -253 253 253 253 253 253 253 253 253 253 253 253
50469 -253 253 253 253 253 253 253 253 253 253 253 253
50470 -253 253 253 253 253 253 253 253 253 253 253 253
50471 -253 253 253 253 253 253 234 234 234 14 14 14
50472 - 2 2 6 2 2 6 30 30 30 2 2 6
50473 - 2 2 6 2 2 6 2 2 6 2 2 6
50474 - 2 2 6 66 66 66 62 62 62 22 22 22
50475 - 6 6 6 0 0 0 0 0 0 0 0 0
50476 - 0 0 0 0 0 0 0 0 0 0 0 0
50477 - 0 0 0 0 0 0 0 0 0 0 0 0
50478 - 0 0 0 0 0 0 0 0 0 0 0 0
50479 - 0 0 0 0 0 0 0 0 0 0 0 0
50480 - 0 0 0 0 0 0 0 0 0 0 0 0
50481 - 0 0 0 0 0 0 6 6 6 18 18 18
50482 - 54 54 54 62 62 62 2 2 6 2 2 6
50483 - 2 2 6 30 30 30 46 46 46 70 70 70
50484 -250 250 250 253 253 253 253 253 253 253 253 253
50485 -253 253 253 253 253 253 253 253 253 253 253 253
50486 -253 253 253 253 253 253 231 231 231 246 246 246
50487 -253 253 253 253 253 253 253 253 253 253 253 253
50488 -253 253 253 253 253 253 253 253 253 253 253 253
50489 -253 253 253 253 253 253 253 253 253 253 253 253
50490 -253 253 253 253 253 253 253 253 253 253 253 253
50491 -253 253 253 253 253 253 226 226 226 10 10 10
50492 - 2 2 6 6 6 6 30 30 30 2 2 6
50493 - 2 2 6 2 2 6 2 2 6 2 2 6
50494 - 2 2 6 66 66 66 58 58 58 22 22 22
50495 - 6 6 6 0 0 0 0 0 0 0 0 0
50496 - 0 0 0 0 0 0 0 0 0 0 0 0
50497 - 0 0 0 0 0 0 0 0 0 0 0 0
50498 - 0 0 0 0 0 0 0 0 0 0 0 0
50499 - 0 0 0 0 0 0 0 0 0 0 0 0
50500 - 0 0 0 0 0 0 0 0 0 0 0 0
50501 - 0 0 0 0 0 0 6 6 6 22 22 22
50502 - 58 58 58 62 62 62 2 2 6 2 2 6
50503 - 2 2 6 2 2 6 30 30 30 78 78 78
50504 -250 250 250 253 253 253 253 253 253 253 253 253
50505 -253 253 253 253 253 253 253 253 253 253 253 253
50506 -253 253 253 253 253 253 231 231 231 246 246 246
50507 -253 253 253 253 253 253 253 253 253 253 253 253
50508 -253 253 253 253 253 253 253 253 253 253 253 253
50509 -253 253 253 253 253 253 253 253 253 253 253 253
50510 -253 253 253 253 253 253 253 253 253 253 253 253
50511 -253 253 253 253 253 253 206 206 206 2 2 6
50512 - 22 22 22 34 34 34 18 14 6 22 22 22
50513 - 26 26 26 18 18 18 6 6 6 2 2 6
50514 - 2 2 6 82 82 82 54 54 54 18 18 18
50515 - 6 6 6 0 0 0 0 0 0 0 0 0
50516 - 0 0 0 0 0 0 0 0 0 0 0 0
50517 - 0 0 0 0 0 0 0 0 0 0 0 0
50518 - 0 0 0 0 0 0 0 0 0 0 0 0
50519 - 0 0 0 0 0 0 0 0 0 0 0 0
50520 - 0 0 0 0 0 0 0 0 0 0 0 0
50521 - 0 0 0 0 0 0 6 6 6 26 26 26
50522 - 62 62 62 106 106 106 74 54 14 185 133 11
50523 -210 162 10 121 92 8 6 6 6 62 62 62
50524 -238 238 238 253 253 253 253 253 253 253 253 253
50525 -253 253 253 253 253 253 253 253 253 253 253 253
50526 -253 253 253 253 253 253 231 231 231 246 246 246
50527 -253 253 253 253 253 253 253 253 253 253 253 253
50528 -253 253 253 253 253 253 253 253 253 253 253 253
50529 -253 253 253 253 253 253 253 253 253 253 253 253
50530 -253 253 253 253 253 253 253 253 253 253 253 253
50531 -253 253 253 253 253 253 158 158 158 18 18 18
50532 - 14 14 14 2 2 6 2 2 6 2 2 6
50533 - 6 6 6 18 18 18 66 66 66 38 38 38
50534 - 6 6 6 94 94 94 50 50 50 18 18 18
50535 - 6 6 6 0 0 0 0 0 0 0 0 0
50536 - 0 0 0 0 0 0 0 0 0 0 0 0
50537 - 0 0 0 0 0 0 0 0 0 0 0 0
50538 - 0 0 0 0 0 0 0 0 0 0 0 0
50539 - 0 0 0 0 0 0 0 0 0 0 0 0
50540 - 0 0 0 0 0 0 0 0 0 6 6 6
50541 - 10 10 10 10 10 10 18 18 18 38 38 38
50542 - 78 78 78 142 134 106 216 158 10 242 186 14
50543 -246 190 14 246 190 14 156 118 10 10 10 10
50544 - 90 90 90 238 238 238 253 253 253 253 253 253
50545 -253 253 253 253 253 253 253 253 253 253 253 253
50546 -253 253 253 253 253 253 231 231 231 250 250 250
50547 -253 253 253 253 253 253 253 253 253 253 253 253
50548 -253 253 253 253 253 253 253 253 253 253 253 253
50549 -253 253 253 253 253 253 253 253 253 253 253 253
50550 -253 253 253 253 253 253 253 253 253 246 230 190
50551 -238 204 91 238 204 91 181 142 44 37 26 9
50552 - 2 2 6 2 2 6 2 2 6 2 2 6
50553 - 2 2 6 2 2 6 38 38 38 46 46 46
50554 - 26 26 26 106 106 106 54 54 54 18 18 18
50555 - 6 6 6 0 0 0 0 0 0 0 0 0
50556 - 0 0 0 0 0 0 0 0 0 0 0 0
50557 - 0 0 0 0 0 0 0 0 0 0 0 0
50558 - 0 0 0 0 0 0 0 0 0 0 0 0
50559 - 0 0 0 0 0 0 0 0 0 0 0 0
50560 - 0 0 0 6 6 6 14 14 14 22 22 22
50561 - 30 30 30 38 38 38 50 50 50 70 70 70
50562 -106 106 106 190 142 34 226 170 11 242 186 14
50563 -246 190 14 246 190 14 246 190 14 154 114 10
50564 - 6 6 6 74 74 74 226 226 226 253 253 253
50565 -253 253 253 253 253 253 253 253 253 253 253 253
50566 -253 253 253 253 253 253 231 231 231 250 250 250
50567 -253 253 253 253 253 253 253 253 253 253 253 253
50568 -253 253 253 253 253 253 253 253 253 253 253 253
50569 -253 253 253 253 253 253 253 253 253 253 253 253
50570 -253 253 253 253 253 253 253 253 253 228 184 62
50571 -241 196 14 241 208 19 232 195 16 38 30 10
50572 - 2 2 6 2 2 6 2 2 6 2 2 6
50573 - 2 2 6 6 6 6 30 30 30 26 26 26
50574 -203 166 17 154 142 90 66 66 66 26 26 26
50575 - 6 6 6 0 0 0 0 0 0 0 0 0
50576 - 0 0 0 0 0 0 0 0 0 0 0 0
50577 - 0 0 0 0 0 0 0 0 0 0 0 0
50578 - 0 0 0 0 0 0 0 0 0 0 0 0
50579 - 0 0 0 0 0 0 0 0 0 0 0 0
50580 - 6 6 6 18 18 18 38 38 38 58 58 58
50581 - 78 78 78 86 86 86 101 101 101 123 123 123
50582 -175 146 61 210 150 10 234 174 13 246 186 14
50583 -246 190 14 246 190 14 246 190 14 238 190 10
50584 -102 78 10 2 2 6 46 46 46 198 198 198
50585 -253 253 253 253 253 253 253 253 253 253 253 253
50586 -253 253 253 253 253 253 234 234 234 242 242 242
50587 -253 253 253 253 253 253 253 253 253 253 253 253
50588 -253 253 253 253 253 253 253 253 253 253 253 253
50589 -253 253 253 253 253 253 253 253 253 253 253 253
50590 -253 253 253 253 253 253 253 253 253 224 178 62
50591 -242 186 14 241 196 14 210 166 10 22 18 6
50592 - 2 2 6 2 2 6 2 2 6 2 2 6
50593 - 2 2 6 2 2 6 6 6 6 121 92 8
50594 -238 202 15 232 195 16 82 82 82 34 34 34
50595 - 10 10 10 0 0 0 0 0 0 0 0 0
50596 - 0 0 0 0 0 0 0 0 0 0 0 0
50597 - 0 0 0 0 0 0 0 0 0 0 0 0
50598 - 0 0 0 0 0 0 0 0 0 0 0 0
50599 - 0 0 0 0 0 0 0 0 0 0 0 0
50600 - 14 14 14 38 38 38 70 70 70 154 122 46
50601 -190 142 34 200 144 11 197 138 11 197 138 11
50602 -213 154 11 226 170 11 242 186 14 246 190 14
50603 -246 190 14 246 190 14 246 190 14 246 190 14
50604 -225 175 15 46 32 6 2 2 6 22 22 22
50605 -158 158 158 250 250 250 253 253 253 253 253 253
50606 -253 253 253 253 253 253 253 253 253 253 253 253
50607 -253 253 253 253 253 253 253 253 253 253 253 253
50608 -253 253 253 253 253 253 253 253 253 253 253 253
50609 -253 253 253 253 253 253 253 253 253 253 253 253
50610 -253 253 253 250 250 250 242 242 242 224 178 62
50611 -239 182 13 236 186 11 213 154 11 46 32 6
50612 - 2 2 6 2 2 6 2 2 6 2 2 6
50613 - 2 2 6 2 2 6 61 42 6 225 175 15
50614 -238 190 10 236 186 11 112 100 78 42 42 42
50615 - 14 14 14 0 0 0 0 0 0 0 0 0
50616 - 0 0 0 0 0 0 0 0 0 0 0 0
50617 - 0 0 0 0 0 0 0 0 0 0 0 0
50618 - 0 0 0 0 0 0 0 0 0 0 0 0
50619 - 0 0 0 0 0 0 0 0 0 6 6 6
50620 - 22 22 22 54 54 54 154 122 46 213 154 11
50621 -226 170 11 230 174 11 226 170 11 226 170 11
50622 -236 178 12 242 186 14 246 190 14 246 190 14
50623 -246 190 14 246 190 14 246 190 14 246 190 14
50624 -241 196 14 184 144 12 10 10 10 2 2 6
50625 - 6 6 6 116 116 116 242 242 242 253 253 253
50626 -253 253 253 253 253 253 253 253 253 253 253 253
50627 -253 253 253 253 253 253 253 253 253 253 253 253
50628 -253 253 253 253 253 253 253 253 253 253 253 253
50629 -253 253 253 253 253 253 253 253 253 253 253 253
50630 -253 253 253 231 231 231 198 198 198 214 170 54
50631 -236 178 12 236 178 12 210 150 10 137 92 6
50632 - 18 14 6 2 2 6 2 2 6 2 2 6
50633 - 6 6 6 70 47 6 200 144 11 236 178 12
50634 -239 182 13 239 182 13 124 112 88 58 58 58
50635 - 22 22 22 6 6 6 0 0 0 0 0 0
50636 - 0 0 0 0 0 0 0 0 0 0 0 0
50637 - 0 0 0 0 0 0 0 0 0 0 0 0
50638 - 0 0 0 0 0 0 0 0 0 0 0 0
50639 - 0 0 0 0 0 0 0 0 0 10 10 10
50640 - 30 30 30 70 70 70 180 133 36 226 170 11
50641 -239 182 13 242 186 14 242 186 14 246 186 14
50642 -246 190 14 246 190 14 246 190 14 246 190 14
50643 -246 190 14 246 190 14 246 190 14 246 190 14
50644 -246 190 14 232 195 16 98 70 6 2 2 6
50645 - 2 2 6 2 2 6 66 66 66 221 221 221
50646 -253 253 253 253 253 253 253 253 253 253 253 253
50647 -253 253 253 253 253 253 253 253 253 253 253 253
50648 -253 253 253 253 253 253 253 253 253 253 253 253
50649 -253 253 253 253 253 253 253 253 253 253 253 253
50650 -253 253 253 206 206 206 198 198 198 214 166 58
50651 -230 174 11 230 174 11 216 158 10 192 133 9
50652 -163 110 8 116 81 8 102 78 10 116 81 8
50653 -167 114 7 197 138 11 226 170 11 239 182 13
50654 -242 186 14 242 186 14 162 146 94 78 78 78
50655 - 34 34 34 14 14 14 6 6 6 0 0 0
50656 - 0 0 0 0 0 0 0 0 0 0 0 0
50657 - 0 0 0 0 0 0 0 0 0 0 0 0
50658 - 0 0 0 0 0 0 0 0 0 0 0 0
50659 - 0 0 0 0 0 0 0 0 0 6 6 6
50660 - 30 30 30 78 78 78 190 142 34 226 170 11
50661 -239 182 13 246 190 14 246 190 14 246 190 14
50662 -246 190 14 246 190 14 246 190 14 246 190 14
50663 -246 190 14 246 190 14 246 190 14 246 190 14
50664 -246 190 14 241 196 14 203 166 17 22 18 6
50665 - 2 2 6 2 2 6 2 2 6 38 38 38
50666 -218 218 218 253 253 253 253 253 253 253 253 253
50667 -253 253 253 253 253 253 253 253 253 253 253 253
50668 -253 253 253 253 253 253 253 253 253 253 253 253
50669 -253 253 253 253 253 253 253 253 253 253 253 253
50670 -250 250 250 206 206 206 198 198 198 202 162 69
50671 -226 170 11 236 178 12 224 166 10 210 150 10
50672 -200 144 11 197 138 11 192 133 9 197 138 11
50673 -210 150 10 226 170 11 242 186 14 246 190 14
50674 -246 190 14 246 186 14 225 175 15 124 112 88
50675 - 62 62 62 30 30 30 14 14 14 6 6 6
50676 - 0 0 0 0 0 0 0 0 0 0 0 0
50677 - 0 0 0 0 0 0 0 0 0 0 0 0
50678 - 0 0 0 0 0 0 0 0 0 0 0 0
50679 - 0 0 0 0 0 0 0 0 0 10 10 10
50680 - 30 30 30 78 78 78 174 135 50 224 166 10
50681 -239 182 13 246 190 14 246 190 14 246 190 14
50682 -246 190 14 246 190 14 246 190 14 246 190 14
50683 -246 190 14 246 190 14 246 190 14 246 190 14
50684 -246 190 14 246 190 14 241 196 14 139 102 15
50685 - 2 2 6 2 2 6 2 2 6 2 2 6
50686 - 78 78 78 250 250 250 253 253 253 253 253 253
50687 -253 253 253 253 253 253 253 253 253 253 253 253
50688 -253 253 253 253 253 253 253 253 253 253 253 253
50689 -253 253 253 253 253 253 253 253 253 253 253 253
50690 -250 250 250 214 214 214 198 198 198 190 150 46
50691 -219 162 10 236 178 12 234 174 13 224 166 10
50692 -216 158 10 213 154 11 213 154 11 216 158 10
50693 -226 170 11 239 182 13 246 190 14 246 190 14
50694 -246 190 14 246 190 14 242 186 14 206 162 42
50695 -101 101 101 58 58 58 30 30 30 14 14 14
50696 - 6 6 6 0 0 0 0 0 0 0 0 0
50697 - 0 0 0 0 0 0 0 0 0 0 0 0
50698 - 0 0 0 0 0 0 0 0 0 0 0 0
50699 - 0 0 0 0 0 0 0 0 0 10 10 10
50700 - 30 30 30 74 74 74 174 135 50 216 158 10
50701 -236 178 12 246 190 14 246 190 14 246 190 14
50702 -246 190 14 246 190 14 246 190 14 246 190 14
50703 -246 190 14 246 190 14 246 190 14 246 190 14
50704 -246 190 14 246 190 14 241 196 14 226 184 13
50705 - 61 42 6 2 2 6 2 2 6 2 2 6
50706 - 22 22 22 238 238 238 253 253 253 253 253 253
50707 -253 253 253 253 253 253 253 253 253 253 253 253
50708 -253 253 253 253 253 253 253 253 253 253 253 253
50709 -253 253 253 253 253 253 253 253 253 253 253 253
50710 -253 253 253 226 226 226 187 187 187 180 133 36
50711 -216 158 10 236 178 12 239 182 13 236 178 12
50712 -230 174 11 226 170 11 226 170 11 230 174 11
50713 -236 178 12 242 186 14 246 190 14 246 190 14
50714 -246 190 14 246 190 14 246 186 14 239 182 13
50715 -206 162 42 106 106 106 66 66 66 34 34 34
50716 - 14 14 14 6 6 6 0 0 0 0 0 0
50717 - 0 0 0 0 0 0 0 0 0 0 0 0
50718 - 0 0 0 0 0 0 0 0 0 0 0 0
50719 - 0 0 0 0 0 0 0 0 0 6 6 6
50720 - 26 26 26 70 70 70 163 133 67 213 154 11
50721 -236 178 12 246 190 14 246 190 14 246 190 14
50722 -246 190 14 246 190 14 246 190 14 246 190 14
50723 -246 190 14 246 190 14 246 190 14 246 190 14
50724 -246 190 14 246 190 14 246 190 14 241 196 14
50725 -190 146 13 18 14 6 2 2 6 2 2 6
50726 - 46 46 46 246 246 246 253 253 253 253 253 253
50727 -253 253 253 253 253 253 253 253 253 253 253 253
50728 -253 253 253 253 253 253 253 253 253 253 253 253
50729 -253 253 253 253 253 253 253 253 253 253 253 253
50730 -253 253 253 221 221 221 86 86 86 156 107 11
50731 -216 158 10 236 178 12 242 186 14 246 186 14
50732 -242 186 14 239 182 13 239 182 13 242 186 14
50733 -242 186 14 246 186 14 246 190 14 246 190 14
50734 -246 190 14 246 190 14 246 190 14 246 190 14
50735 -242 186 14 225 175 15 142 122 72 66 66 66
50736 - 30 30 30 10 10 10 0 0 0 0 0 0
50737 - 0 0 0 0 0 0 0 0 0 0 0 0
50738 - 0 0 0 0 0 0 0 0 0 0 0 0
50739 - 0 0 0 0 0 0 0 0 0 6 6 6
50740 - 26 26 26 70 70 70 163 133 67 210 150 10
50741 -236 178 12 246 190 14 246 190 14 246 190 14
50742 -246 190 14 246 190 14 246 190 14 246 190 14
50743 -246 190 14 246 190 14 246 190 14 246 190 14
50744 -246 190 14 246 190 14 246 190 14 246 190 14
50745 -232 195 16 121 92 8 34 34 34 106 106 106
50746 -221 221 221 253 253 253 253 253 253 253 253 253
50747 -253 253 253 253 253 253 253 253 253 253 253 253
50748 -253 253 253 253 253 253 253 253 253 253 253 253
50749 -253 253 253 253 253 253 253 253 253 253 253 253
50750 -242 242 242 82 82 82 18 14 6 163 110 8
50751 -216 158 10 236 178 12 242 186 14 246 190 14
50752 -246 190 14 246 190 14 246 190 14 246 190 14
50753 -246 190 14 246 190 14 246 190 14 246 190 14
50754 -246 190 14 246 190 14 246 190 14 246 190 14
50755 -246 190 14 246 190 14 242 186 14 163 133 67
50756 - 46 46 46 18 18 18 6 6 6 0 0 0
50757 - 0 0 0 0 0 0 0 0 0 0 0 0
50758 - 0 0 0 0 0 0 0 0 0 0 0 0
50759 - 0 0 0 0 0 0 0 0 0 10 10 10
50760 - 30 30 30 78 78 78 163 133 67 210 150 10
50761 -236 178 12 246 186 14 246 190 14 246 190 14
50762 -246 190 14 246 190 14 246 190 14 246 190 14
50763 -246 190 14 246 190 14 246 190 14 246 190 14
50764 -246 190 14 246 190 14 246 190 14 246 190 14
50765 -241 196 14 215 174 15 190 178 144 253 253 253
50766 -253 253 253 253 253 253 253 253 253 253 253 253
50767 -253 253 253 253 253 253 253 253 253 253 253 253
50768 -253 253 253 253 253 253 253 253 253 253 253 253
50769 -253 253 253 253 253 253 253 253 253 218 218 218
50770 - 58 58 58 2 2 6 22 18 6 167 114 7
50771 -216 158 10 236 178 12 246 186 14 246 190 14
50772 -246 190 14 246 190 14 246 190 14 246 190 14
50773 -246 190 14 246 190 14 246 190 14 246 190 14
50774 -246 190 14 246 190 14 246 190 14 246 190 14
50775 -246 190 14 246 186 14 242 186 14 190 150 46
50776 - 54 54 54 22 22 22 6 6 6 0 0 0
50777 - 0 0 0 0 0 0 0 0 0 0 0 0
50778 - 0 0 0 0 0 0 0 0 0 0 0 0
50779 - 0 0 0 0 0 0 0 0 0 14 14 14
50780 - 38 38 38 86 86 86 180 133 36 213 154 11
50781 -236 178 12 246 186 14 246 190 14 246 190 14
50782 -246 190 14 246 190 14 246 190 14 246 190 14
50783 -246 190 14 246 190 14 246 190 14 246 190 14
50784 -246 190 14 246 190 14 246 190 14 246 190 14
50785 -246 190 14 232 195 16 190 146 13 214 214 214
50786 -253 253 253 253 253 253 253 253 253 253 253 253
50787 -253 253 253 253 253 253 253 253 253 253 253 253
50788 -253 253 253 253 253 253 253 253 253 253 253 253
50789 -253 253 253 250 250 250 170 170 170 26 26 26
50790 - 2 2 6 2 2 6 37 26 9 163 110 8
50791 -219 162 10 239 182 13 246 186 14 246 190 14
50792 -246 190 14 246 190 14 246 190 14 246 190 14
50793 -246 190 14 246 190 14 246 190 14 246 190 14
50794 -246 190 14 246 190 14 246 190 14 246 190 14
50795 -246 186 14 236 178 12 224 166 10 142 122 72
50796 - 46 46 46 18 18 18 6 6 6 0 0 0
50797 - 0 0 0 0 0 0 0 0 0 0 0 0
50798 - 0 0 0 0 0 0 0 0 0 0 0 0
50799 - 0 0 0 0 0 0 6 6 6 18 18 18
50800 - 50 50 50 109 106 95 192 133 9 224 166 10
50801 -242 186 14 246 190 14 246 190 14 246 190 14
50802 -246 190 14 246 190 14 246 190 14 246 190 14
50803 -246 190 14 246 190 14 246 190 14 246 190 14
50804 -246 190 14 246 190 14 246 190 14 246 190 14
50805 -242 186 14 226 184 13 210 162 10 142 110 46
50806 -226 226 226 253 253 253 253 253 253 253 253 253
50807 -253 253 253 253 253 253 253 253 253 253 253 253
50808 -253 253 253 253 253 253 253 253 253 253 253 253
50809 -198 198 198 66 66 66 2 2 6 2 2 6
50810 - 2 2 6 2 2 6 50 34 6 156 107 11
50811 -219 162 10 239 182 13 246 186 14 246 190 14
50812 -246 190 14 246 190 14 246 190 14 246 190 14
50813 -246 190 14 246 190 14 246 190 14 246 190 14
50814 -246 190 14 246 190 14 246 190 14 242 186 14
50815 -234 174 13 213 154 11 154 122 46 66 66 66
50816 - 30 30 30 10 10 10 0 0 0 0 0 0
50817 - 0 0 0 0 0 0 0 0 0 0 0 0
50818 - 0 0 0 0 0 0 0 0 0 0 0 0
50819 - 0 0 0 0 0 0 6 6 6 22 22 22
50820 - 58 58 58 154 121 60 206 145 10 234 174 13
50821 -242 186 14 246 186 14 246 190 14 246 190 14
50822 -246 190 14 246 190 14 246 190 14 246 190 14
50823 -246 190 14 246 190 14 246 190 14 246 190 14
50824 -246 190 14 246 190 14 246 190 14 246 190 14
50825 -246 186 14 236 178 12 210 162 10 163 110 8
50826 - 61 42 6 138 138 138 218 218 218 250 250 250
50827 -253 253 253 253 253 253 253 253 253 250 250 250
50828 -242 242 242 210 210 210 144 144 144 66 66 66
50829 - 6 6 6 2 2 6 2 2 6 2 2 6
50830 - 2 2 6 2 2 6 61 42 6 163 110 8
50831 -216 158 10 236 178 12 246 190 14 246 190 14
50832 -246 190 14 246 190 14 246 190 14 246 190 14
50833 -246 190 14 246 190 14 246 190 14 246 190 14
50834 -246 190 14 239 182 13 230 174 11 216 158 10
50835 -190 142 34 124 112 88 70 70 70 38 38 38
50836 - 18 18 18 6 6 6 0 0 0 0 0 0
50837 - 0 0 0 0 0 0 0 0 0 0 0 0
50838 - 0 0 0 0 0 0 0 0 0 0 0 0
50839 - 0 0 0 0 0 0 6 6 6 22 22 22
50840 - 62 62 62 168 124 44 206 145 10 224 166 10
50841 -236 178 12 239 182 13 242 186 14 242 186 14
50842 -246 186 14 246 190 14 246 190 14 246 190 14
50843 -246 190 14 246 190 14 246 190 14 246 190 14
50844 -246 190 14 246 190 14 246 190 14 246 190 14
50845 -246 190 14 236 178 12 216 158 10 175 118 6
50846 - 80 54 7 2 2 6 6 6 6 30 30 30
50847 - 54 54 54 62 62 62 50 50 50 38 38 38
50848 - 14 14 14 2 2 6 2 2 6 2 2 6
50849 - 2 2 6 2 2 6 2 2 6 2 2 6
50850 - 2 2 6 6 6 6 80 54 7 167 114 7
50851 -213 154 11 236 178 12 246 190 14 246 190 14
50852 -246 190 14 246 190 14 246 190 14 246 190 14
50853 -246 190 14 242 186 14 239 182 13 239 182 13
50854 -230 174 11 210 150 10 174 135 50 124 112 88
50855 - 82 82 82 54 54 54 34 34 34 18 18 18
50856 - 6 6 6 0 0 0 0 0 0 0 0 0
50857 - 0 0 0 0 0 0 0 0 0 0 0 0
50858 - 0 0 0 0 0 0 0 0 0 0 0 0
50859 - 0 0 0 0 0 0 6 6 6 18 18 18
50860 - 50 50 50 158 118 36 192 133 9 200 144 11
50861 -216 158 10 219 162 10 224 166 10 226 170 11
50862 -230 174 11 236 178 12 239 182 13 239 182 13
50863 -242 186 14 246 186 14 246 190 14 246 190 14
50864 -246 190 14 246 190 14 246 190 14 246 190 14
50865 -246 186 14 230 174 11 210 150 10 163 110 8
50866 -104 69 6 10 10 10 2 2 6 2 2 6
50867 - 2 2 6 2 2 6 2 2 6 2 2 6
50868 - 2 2 6 2 2 6 2 2 6 2 2 6
50869 - 2 2 6 2 2 6 2 2 6 2 2 6
50870 - 2 2 6 6 6 6 91 60 6 167 114 7
50871 -206 145 10 230 174 11 242 186 14 246 190 14
50872 -246 190 14 246 190 14 246 186 14 242 186 14
50873 -239 182 13 230 174 11 224 166 10 213 154 11
50874 -180 133 36 124 112 88 86 86 86 58 58 58
50875 - 38 38 38 22 22 22 10 10 10 6 6 6
50876 - 0 0 0 0 0 0 0 0 0 0 0 0
50877 - 0 0 0 0 0 0 0 0 0 0 0 0
50878 - 0 0 0 0 0 0 0 0 0 0 0 0
50879 - 0 0 0 0 0 0 0 0 0 14 14 14
50880 - 34 34 34 70 70 70 138 110 50 158 118 36
50881 -167 114 7 180 123 7 192 133 9 197 138 11
50882 -200 144 11 206 145 10 213 154 11 219 162 10
50883 -224 166 10 230 174 11 239 182 13 242 186 14
50884 -246 186 14 246 186 14 246 186 14 246 186 14
50885 -239 182 13 216 158 10 185 133 11 152 99 6
50886 -104 69 6 18 14 6 2 2 6 2 2 6
50887 - 2 2 6 2 2 6 2 2 6 2 2 6
50888 - 2 2 6 2 2 6 2 2 6 2 2 6
50889 - 2 2 6 2 2 6 2 2 6 2 2 6
50890 - 2 2 6 6 6 6 80 54 7 152 99 6
50891 -192 133 9 219 162 10 236 178 12 239 182 13
50892 -246 186 14 242 186 14 239 182 13 236 178 12
50893 -224 166 10 206 145 10 192 133 9 154 121 60
50894 - 94 94 94 62 62 62 42 42 42 22 22 22
50895 - 14 14 14 6 6 6 0 0 0 0 0 0
50896 - 0 0 0 0 0 0 0 0 0 0 0 0
50897 - 0 0 0 0 0 0 0 0 0 0 0 0
50898 - 0 0 0 0 0 0 0 0 0 0 0 0
50899 - 0 0 0 0 0 0 0 0 0 6 6 6
50900 - 18 18 18 34 34 34 58 58 58 78 78 78
50901 -101 98 89 124 112 88 142 110 46 156 107 11
50902 -163 110 8 167 114 7 175 118 6 180 123 7
50903 -185 133 11 197 138 11 210 150 10 219 162 10
50904 -226 170 11 236 178 12 236 178 12 234 174 13
50905 -219 162 10 197 138 11 163 110 8 130 83 6
50906 - 91 60 6 10 10 10 2 2 6 2 2 6
50907 - 18 18 18 38 38 38 38 38 38 38 38 38
50908 - 38 38 38 38 38 38 38 38 38 38 38 38
50909 - 38 38 38 38 38 38 26 26 26 2 2 6
50910 - 2 2 6 6 6 6 70 47 6 137 92 6
50911 -175 118 6 200 144 11 219 162 10 230 174 11
50912 -234 174 13 230 174 11 219 162 10 210 150 10
50913 -192 133 9 163 110 8 124 112 88 82 82 82
50914 - 50 50 50 30 30 30 14 14 14 6 6 6
50915 - 0 0 0 0 0 0 0 0 0 0 0 0
50916 - 0 0 0 0 0 0 0 0 0 0 0 0
50917 - 0 0 0 0 0 0 0 0 0 0 0 0
50918 - 0 0 0 0 0 0 0 0 0 0 0 0
50919 - 0 0 0 0 0 0 0 0 0 0 0 0
50920 - 6 6 6 14 14 14 22 22 22 34 34 34
50921 - 42 42 42 58 58 58 74 74 74 86 86 86
50922 -101 98 89 122 102 70 130 98 46 121 87 25
50923 -137 92 6 152 99 6 163 110 8 180 123 7
50924 -185 133 11 197 138 11 206 145 10 200 144 11
50925 -180 123 7 156 107 11 130 83 6 104 69 6
50926 - 50 34 6 54 54 54 110 110 110 101 98 89
50927 - 86 86 86 82 82 82 78 78 78 78 78 78
50928 - 78 78 78 78 78 78 78 78 78 78 78 78
50929 - 78 78 78 82 82 82 86 86 86 94 94 94
50930 -106 106 106 101 101 101 86 66 34 124 80 6
50931 -156 107 11 180 123 7 192 133 9 200 144 11
50932 -206 145 10 200 144 11 192 133 9 175 118 6
50933 -139 102 15 109 106 95 70 70 70 42 42 42
50934 - 22 22 22 10 10 10 0 0 0 0 0 0
50935 - 0 0 0 0 0 0 0 0 0 0 0 0
50936 - 0 0 0 0 0 0 0 0 0 0 0 0
50937 - 0 0 0 0 0 0 0 0 0 0 0 0
50938 - 0 0 0 0 0 0 0 0 0 0 0 0
50939 - 0 0 0 0 0 0 0 0 0 0 0 0
50940 - 0 0 0 0 0 0 6 6 6 10 10 10
50941 - 14 14 14 22 22 22 30 30 30 38 38 38
50942 - 50 50 50 62 62 62 74 74 74 90 90 90
50943 -101 98 89 112 100 78 121 87 25 124 80 6
50944 -137 92 6 152 99 6 152 99 6 152 99 6
50945 -138 86 6 124 80 6 98 70 6 86 66 30
50946 -101 98 89 82 82 82 58 58 58 46 46 46
50947 - 38 38 38 34 34 34 34 34 34 34 34 34
50948 - 34 34 34 34 34 34 34 34 34 34 34 34
50949 - 34 34 34 34 34 34 38 38 38 42 42 42
50950 - 54 54 54 82 82 82 94 86 76 91 60 6
50951 -134 86 6 156 107 11 167 114 7 175 118 6
50952 -175 118 6 167 114 7 152 99 6 121 87 25
50953 -101 98 89 62 62 62 34 34 34 18 18 18
50954 - 6 6 6 0 0 0 0 0 0 0 0 0
50955 - 0 0 0 0 0 0 0 0 0 0 0 0
50956 - 0 0 0 0 0 0 0 0 0 0 0 0
50957 - 0 0 0 0 0 0 0 0 0 0 0 0
50958 - 0 0 0 0 0 0 0 0 0 0 0 0
50959 - 0 0 0 0 0 0 0 0 0 0 0 0
50960 - 0 0 0 0 0 0 0 0 0 0 0 0
50961 - 0 0 0 6 6 6 6 6 6 10 10 10
50962 - 18 18 18 22 22 22 30 30 30 42 42 42
50963 - 50 50 50 66 66 66 86 86 86 101 98 89
50964 -106 86 58 98 70 6 104 69 6 104 69 6
50965 -104 69 6 91 60 6 82 62 34 90 90 90
50966 - 62 62 62 38 38 38 22 22 22 14 14 14
50967 - 10 10 10 10 10 10 10 10 10 10 10 10
50968 - 10 10 10 10 10 10 6 6 6 10 10 10
50969 - 10 10 10 10 10 10 10 10 10 14 14 14
50970 - 22 22 22 42 42 42 70 70 70 89 81 66
50971 - 80 54 7 104 69 6 124 80 6 137 92 6
50972 -134 86 6 116 81 8 100 82 52 86 86 86
50973 - 58 58 58 30 30 30 14 14 14 6 6 6
50974 - 0 0 0 0 0 0 0 0 0 0 0 0
50975 - 0 0 0 0 0 0 0 0 0 0 0 0
50976 - 0 0 0 0 0 0 0 0 0 0 0 0
50977 - 0 0 0 0 0 0 0 0 0 0 0 0
50978 - 0 0 0 0 0 0 0 0 0 0 0 0
50979 - 0 0 0 0 0 0 0 0 0 0 0 0
50980 - 0 0 0 0 0 0 0 0 0 0 0 0
50981 - 0 0 0 0 0 0 0 0 0 0 0 0
50982 - 0 0 0 6 6 6 10 10 10 14 14 14
50983 - 18 18 18 26 26 26 38 38 38 54 54 54
50984 - 70 70 70 86 86 86 94 86 76 89 81 66
50985 - 89 81 66 86 86 86 74 74 74 50 50 50
50986 - 30 30 30 14 14 14 6 6 6 0 0 0
50987 - 0 0 0 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 - 6 6 6 18 18 18 34 34 34 58 58 58
50991 - 82 82 82 89 81 66 89 81 66 89 81 66
50992 - 94 86 66 94 86 76 74 74 74 50 50 50
50993 - 26 26 26 14 14 14 6 6 6 0 0 0
50994 - 0 0 0 0 0 0 0 0 0 0 0 0
50995 - 0 0 0 0 0 0 0 0 0 0 0 0
50996 - 0 0 0 0 0 0 0 0 0 0 0 0
50997 - 0 0 0 0 0 0 0 0 0 0 0 0
50998 - 0 0 0 0 0 0 0 0 0 0 0 0
50999 - 0 0 0 0 0 0 0 0 0 0 0 0
51000 - 0 0 0 0 0 0 0 0 0 0 0 0
51001 - 0 0 0 0 0 0 0 0 0 0 0 0
51002 - 0 0 0 0 0 0 0 0 0 0 0 0
51003 - 6 6 6 6 6 6 14 14 14 18 18 18
51004 - 30 30 30 38 38 38 46 46 46 54 54 54
51005 - 50 50 50 42 42 42 30 30 30 18 18 18
51006 - 10 10 10 0 0 0 0 0 0 0 0 0
51007 - 0 0 0 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 6 6 6 14 14 14 26 26 26
51011 - 38 38 38 50 50 50 58 58 58 58 58 58
51012 - 54 54 54 42 42 42 30 30 30 18 18 18
51013 - 10 10 10 0 0 0 0 0 0 0 0 0
51014 - 0 0 0 0 0 0 0 0 0 0 0 0
51015 - 0 0 0 0 0 0 0 0 0 0 0 0
51016 - 0 0 0 0 0 0 0 0 0 0 0 0
51017 - 0 0 0 0 0 0 0 0 0 0 0 0
51018 - 0 0 0 0 0 0 0 0 0 0 0 0
51019 - 0 0 0 0 0 0 0 0 0 0 0 0
51020 - 0 0 0 0 0 0 0 0 0 0 0 0
51021 - 0 0 0 0 0 0 0 0 0 0 0 0
51022 - 0 0 0 0 0 0 0 0 0 0 0 0
51023 - 0 0 0 0 0 0 0 0 0 6 6 6
51024 - 6 6 6 10 10 10 14 14 14 18 18 18
51025 - 18 18 18 14 14 14 10 10 10 6 6 6
51026 - 0 0 0 0 0 0 0 0 0 0 0 0
51027 - 0 0 0 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 6 6 6
51031 - 14 14 14 18 18 18 22 22 22 22 22 22
51032 - 18 18 18 14 14 14 10 10 10 6 6 6
51033 - 0 0 0 0 0 0 0 0 0 0 0 0
51034 - 0 0 0 0 0 0 0 0 0 0 0 0
51035 - 0 0 0 0 0 0 0 0 0 0 0 0
51036 - 0 0 0 0 0 0 0 0 0 0 0 0
51037 - 0 0 0 0 0 0 0 0 0 0 0 0
51038 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51039 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51040 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51041 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51042 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51043 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51044 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51045 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51046 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51047 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51048 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51049 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51050 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51051 +4 4 4 4 4 4
51052 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51053 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51054 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51055 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51056 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51057 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51058 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51059 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51060 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51061 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51062 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51063 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51064 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51065 +4 4 4 4 4 4
51066 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51067 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51068 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51069 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51070 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51071 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51072 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51073 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51074 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51075 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51076 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51077 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51078 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51079 +4 4 4 4 4 4
51080 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51081 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51082 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51083 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51084 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51085 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51086 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51087 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51088 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51089 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51090 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51091 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51092 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51093 +4 4 4 4 4 4
51094 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51095 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51096 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51097 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51098 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51099 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51100 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51101 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51102 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51103 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51104 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51105 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51106 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51107 +4 4 4 4 4 4
51108 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51109 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51110 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51111 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51112 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51113 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51114 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51115 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51116 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51117 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51118 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51119 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51120 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51121 +4 4 4 4 4 4
51122 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51123 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51124 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51125 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51126 +4 4 4 4 4 4 4 4 4 3 3 3 0 0 0 0 0 0
51127 +0 0 0 0 0 0 0 0 0 0 0 0 3 3 3 4 4 4
51128 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51129 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51130 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51131 +4 4 4 4 4 4 4 4 4 4 4 4 1 1 1 0 0 0
51132 +0 0 0 3 3 3 4 4 4 4 4 4 4 4 4 4 4 4
51133 +4 4 4 4 4 4 4 4 4 2 1 0 2 1 0 3 2 2
51134 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51135 +4 4 4 4 4 4
51136 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51137 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51138 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51139 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51140 +4 4 4 4 4 4 2 2 2 0 0 0 3 4 3 26 28 28
51141 +37 38 37 37 38 37 14 17 19 2 2 2 0 0 0 2 2 2
51142 +5 5 5 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51143 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51144 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51145 +4 4 4 4 4 4 3 3 3 0 0 0 1 1 1 6 6 6
51146 +2 2 2 0 0 0 3 3 3 4 4 4 4 4 4 4 4 4
51147 +4 4 5 3 3 3 1 0 0 0 0 0 1 0 0 0 0 0
51148 +1 1 1 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51149 +4 4 4 4 4 4
51150 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51151 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51152 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51153 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51154 +2 2 2 0 0 0 0 0 0 14 17 19 60 74 84 137 136 137
51155 +153 152 153 137 136 137 125 124 125 60 73 81 6 6 6 3 1 0
51156 +0 0 0 3 3 3 4 4 4 4 4 4 4 4 4 4 4 4
51157 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51158 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51159 +4 4 4 4 4 4 0 0 0 4 4 4 41 54 63 125 124 125
51160 +60 73 81 6 6 6 4 0 0 3 3 3 4 4 4 4 4 4
51161 +4 4 4 0 0 0 6 9 11 41 54 63 41 65 82 22 30 35
51162 +2 2 2 2 1 0 4 4 4 4 4 4 4 4 4 4 4 4
51163 +4 4 4 4 4 4
51164 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51165 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51166 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51167 +4 4 4 4 4 4 5 5 5 5 5 5 2 2 2 0 0 0
51168 +4 0 0 6 6 6 41 54 63 137 136 137 174 174 174 167 166 167
51169 +165 164 165 165 164 165 163 162 163 163 162 163 125 124 125 41 54 63
51170 +1 1 1 0 0 0 0 0 0 3 3 3 5 5 5 4 4 4
51171 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51172 +4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 5 5 5
51173 +3 3 3 2 0 0 4 0 0 60 73 81 156 155 156 167 166 167
51174 +163 162 163 85 115 134 5 7 8 0 0 0 4 4 4 5 5 5
51175 +0 0 0 2 5 5 55 98 126 90 154 193 90 154 193 72 125 159
51176 +37 51 59 2 0 0 1 1 1 4 5 5 4 4 4 4 4 4
51177 +4 4 4 4 4 4
51178 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51179 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51180 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51181 +4 4 4 5 5 5 4 4 4 1 1 1 0 0 0 3 3 3
51182 +37 38 37 125 124 125 163 162 163 174 174 174 158 157 158 158 157 158
51183 +156 155 156 156 155 156 158 157 158 165 164 165 174 174 174 166 165 166
51184 +125 124 125 16 19 21 1 0 0 0 0 0 0 0 0 4 4 4
51185 +5 5 5 5 5 5 4 4 4 4 4 4 4 4 4 4 4 4
51186 +4 4 4 4 4 4 4 4 4 5 5 5 5 5 5 1 1 1
51187 +0 0 0 0 0 0 37 38 37 153 152 153 174 174 174 158 157 158
51188 +174 174 174 163 162 163 37 38 37 4 3 3 4 0 0 1 1 1
51189 +0 0 0 22 40 52 101 161 196 101 161 196 90 154 193 101 161 196
51190 +64 123 161 14 17 19 0 0 0 4 4 4 4 4 4 4 4 4
51191 +4 4 4 4 4 4
51192 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51193 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51194 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5 5 5
51195 +5 5 5 2 2 2 0 0 0 4 0 0 24 26 27 85 115 134
51196 +156 155 156 174 174 174 167 166 167 156 155 156 154 153 154 157 156 157
51197 +156 155 156 156 155 156 155 154 155 153 152 153 158 157 158 167 166 167
51198 +174 174 174 156 155 156 60 74 84 16 19 21 0 0 0 0 0 0
51199 +1 1 1 5 5 5 5 5 5 4 4 4 4 4 4 4 4 4
51200 +4 4 4 5 5 5 6 6 6 3 3 3 0 0 0 4 0 0
51201 +13 16 17 60 73 81 137 136 137 165 164 165 156 155 156 153 152 153
51202 +174 174 174 177 184 187 60 73 81 3 1 0 0 0 0 1 1 2
51203 +22 30 35 64 123 161 136 185 209 90 154 193 90 154 193 90 154 193
51204 +90 154 193 21 29 34 0 0 0 3 2 2 4 4 5 4 4 4
51205 +4 4 4 4 4 4
51206 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51207 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51208 +4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 3 3 3
51209 +0 0 0 0 0 0 10 13 16 60 74 84 157 156 157 174 174 174
51210 +174 174 174 158 157 158 153 152 153 154 153 154 156 155 156 155 154 155
51211 +156 155 156 155 154 155 154 153 154 157 156 157 154 153 154 153 152 153
51212 +163 162 163 174 174 174 177 184 187 137 136 137 60 73 81 13 16 17
51213 +4 0 0 0 0 0 3 3 3 5 5 5 4 4 4 4 4 4
51214 +5 5 5 4 4 4 1 1 1 0 0 0 3 3 3 41 54 63
51215 +131 129 131 174 174 174 174 174 174 174 174 174 167 166 167 174 174 174
51216 +190 197 201 137 136 137 24 26 27 4 0 0 16 21 25 50 82 103
51217 +90 154 193 136 185 209 90 154 193 101 161 196 101 161 196 101 161 196
51218 +31 91 132 3 6 7 0 0 0 4 4 4 4 4 4 4 4 4
51219 +4 4 4 4 4 4
51220 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51221 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51222 +4 4 4 4 4 4 4 4 4 2 2 2 0 0 0 4 0 0
51223 +4 0 0 43 57 68 137 136 137 177 184 187 174 174 174 163 162 163
51224 +155 154 155 155 154 155 156 155 156 155 154 155 158 157 158 165 164 165
51225 +167 166 167 166 165 166 163 162 163 157 156 157 155 154 155 155 154 155
51226 +153 152 153 156 155 156 167 166 167 174 174 174 174 174 174 131 129 131
51227 +41 54 63 5 5 5 0 0 0 0 0 0 3 3 3 4 4 4
51228 +1 1 1 0 0 0 1 0 0 26 28 28 125 124 125 174 174 174
51229 +177 184 187 174 174 174 174 174 174 156 155 156 131 129 131 137 136 137
51230 +125 124 125 24 26 27 4 0 0 41 65 82 90 154 193 136 185 209
51231 +136 185 209 101 161 196 53 118 160 37 112 160 90 154 193 34 86 122
51232 +7 12 15 0 0 0 4 4 4 4 4 4 4 4 4 4 4 4
51233 +4 4 4 4 4 4
51234 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51235 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51236 +4 4 4 3 3 3 0 0 0 0 0 0 5 5 5 37 38 37
51237 +125 124 125 167 166 167 174 174 174 167 166 167 158 157 158 155 154 155
51238 +156 155 156 156 155 156 156 155 156 163 162 163 167 166 167 155 154 155
51239 +137 136 137 153 152 153 156 155 156 165 164 165 163 162 163 156 155 156
51240 +156 155 156 156 155 156 155 154 155 158 157 158 166 165 166 174 174 174
51241 +167 166 167 125 124 125 37 38 37 1 0 0 0 0 0 0 0 0
51242 +0 0 0 24 26 27 60 74 84 158 157 158 174 174 174 174 174 174
51243 +166 165 166 158 157 158 125 124 125 41 54 63 13 16 17 6 6 6
51244 +6 6 6 37 38 37 80 127 157 136 185 209 101 161 196 101 161 196
51245 +90 154 193 28 67 93 6 10 14 13 20 25 13 20 25 6 10 14
51246 +1 1 2 4 3 3 4 4 4 4 4 4 4 4 4 4 4 4
51247 +4 4 4 4 4 4
51248 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51249 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51250 +1 1 1 1 0 0 4 3 3 37 38 37 60 74 84 153 152 153
51251 +167 166 167 167 166 167 158 157 158 154 153 154 155 154 155 156 155 156
51252 +157 156 157 158 157 158 167 166 167 167 166 167 131 129 131 43 57 68
51253 +26 28 28 37 38 37 60 73 81 131 129 131 165 164 165 166 165 166
51254 +158 157 158 155 154 155 156 155 156 156 155 156 156 155 156 158 157 158
51255 +165 164 165 174 174 174 163 162 163 60 74 84 16 19 21 13 16 17
51256 +60 73 81 131 129 131 174 174 174 174 174 174 167 166 167 165 164 165
51257 +137 136 137 60 73 81 24 26 27 4 0 0 4 0 0 16 19 21
51258 +52 104 138 101 161 196 136 185 209 136 185 209 90 154 193 27 99 146
51259 +13 20 25 4 5 7 2 5 5 4 5 7 1 1 2 0 0 0
51260 +4 4 4 4 4 4 3 3 3 2 2 2 2 2 2 4 4 4
51261 +4 4 4 4 4 4
51262 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51263 +4 4 4 4 4 4 4 4 4 4 4 4 3 3 3 0 0 0
51264 +0 0 0 13 16 17 60 73 81 137 136 137 174 174 174 166 165 166
51265 +158 157 158 156 155 156 157 156 157 156 155 156 155 154 155 158 157 158
51266 +167 166 167 174 174 174 153 152 153 60 73 81 16 19 21 4 0 0
51267 +4 0 0 4 0 0 6 6 6 26 28 28 60 74 84 158 157 158
51268 +174 174 174 166 165 166 157 156 157 155 154 155 156 155 156 156 155 156
51269 +155 154 155 158 157 158 167 166 167 167 166 167 131 129 131 125 124 125
51270 +137 136 137 167 166 167 167 166 167 174 174 174 158 157 158 125 124 125
51271 +16 19 21 4 0 0 4 0 0 10 13 16 49 76 92 107 159 188
51272 +136 185 209 136 185 209 90 154 193 26 108 161 22 40 52 6 10 14
51273 +2 3 3 1 1 2 1 1 2 4 4 5 4 4 5 4 4 5
51274 +4 4 5 2 2 1 0 0 0 0 0 0 0 0 0 2 2 2
51275 +4 4 4 4 4 4
51276 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51277 +4 4 4 5 5 5 3 3 3 0 0 0 1 0 0 4 0 0
51278 +37 51 59 131 129 131 167 166 167 167 166 167 163 162 163 157 156 157
51279 +157 156 157 155 154 155 153 152 153 157 156 157 167 166 167 174 174 174
51280 +153 152 153 125 124 125 37 38 37 4 0 0 4 0 0 4 0 0
51281 +4 3 3 4 3 3 4 0 0 6 6 6 4 0 0 37 38 37
51282 +125 124 125 174 174 174 174 174 174 165 164 165 156 155 156 154 153 154
51283 +156 155 156 156 155 156 155 154 155 163 162 163 158 157 158 163 162 163
51284 +174 174 174 174 174 174 174 174 174 125 124 125 37 38 37 0 0 0
51285 +4 0 0 6 9 11 41 54 63 90 154 193 136 185 209 146 190 211
51286 +136 185 209 37 112 160 22 40 52 6 10 14 3 6 7 1 1 2
51287 +1 1 2 3 3 3 1 1 2 3 3 3 4 4 4 4 4 4
51288 +2 2 2 2 0 0 16 19 21 37 38 37 24 26 27 0 0 0
51289 +0 0 0 4 4 4
51290 +4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 5 5 5
51291 +4 4 4 0 0 0 0 0 0 0 0 0 26 28 28 120 125 127
51292 +158 157 158 174 174 174 165 164 165 157 156 157 155 154 155 156 155 156
51293 +153 152 153 153 152 153 167 166 167 174 174 174 174 174 174 125 124 125
51294 +37 38 37 4 0 0 0 0 0 4 0 0 4 3 3 4 4 4
51295 +4 4 4 4 4 4 5 5 5 4 0 0 4 0 0 4 0 0
51296 +4 3 3 43 57 68 137 136 137 174 174 174 174 174 174 165 164 165
51297 +154 153 154 153 152 153 153 152 153 153 152 153 163 162 163 174 174 174
51298 +174 174 174 153 152 153 60 73 81 6 6 6 4 0 0 4 3 3
51299 +32 43 50 80 127 157 136 185 209 146 190 211 146 190 211 90 154 193
51300 +28 67 93 28 67 93 40 71 93 3 6 7 1 1 2 2 5 5
51301 +50 82 103 79 117 143 26 37 45 0 0 0 3 3 3 1 1 1
51302 +0 0 0 41 54 63 137 136 137 174 174 174 153 152 153 60 73 81
51303 +2 0 0 0 0 0
51304 +4 4 4 4 4 4 4 4 4 4 4 4 6 6 6 2 2 2
51305 +0 0 0 2 0 0 24 26 27 60 74 84 153 152 153 174 174 174
51306 +174 174 174 157 156 157 154 153 154 156 155 156 154 153 154 153 152 153
51307 +165 164 165 174 174 174 177 184 187 137 136 137 43 57 68 6 6 6
51308 +4 0 0 2 0 0 3 3 3 5 5 5 5 5 5 4 4 4
51309 +4 4 4 4 4 4 4 4 4 5 5 5 6 6 6 4 3 3
51310 +4 0 0 4 0 0 24 26 27 60 73 81 153 152 153 174 174 174
51311 +174 174 174 158 157 158 158 157 158 174 174 174 174 174 174 158 157 158
51312 +60 74 84 24 26 27 4 0 0 4 0 0 17 23 27 59 113 148
51313 +136 185 209 191 222 234 146 190 211 136 185 209 31 91 132 7 11 13
51314 +22 40 52 101 161 196 90 154 193 6 9 11 3 4 4 43 95 132
51315 +136 185 209 172 205 220 55 98 126 0 0 0 0 0 0 2 0 0
51316 +26 28 28 153 152 153 177 184 187 167 166 167 177 184 187 165 164 165
51317 +37 38 37 0 0 0
51318 +4 4 4 4 4 4 5 5 5 5 5 5 1 1 1 0 0 0
51319 +13 16 17 60 73 81 137 136 137 174 174 174 174 174 174 165 164 165
51320 +153 152 153 153 152 153 155 154 155 154 153 154 158 157 158 174 174 174
51321 +177 184 187 163 162 163 60 73 81 16 19 21 4 0 0 4 0 0
51322 +4 3 3 4 4 4 5 5 5 5 5 5 4 4 4 5 5 5
51323 +5 5 5 5 5 5 5 5 5 4 4 4 4 4 4 5 5 5
51324 +6 6 6 4 0 0 4 0 0 4 0 0 24 26 27 60 74 84
51325 +166 165 166 174 174 174 177 184 187 165 164 165 125 124 125 24 26 27
51326 +4 0 0 4 0 0 5 5 5 50 82 103 136 185 209 172 205 220
51327 +146 190 211 136 185 209 26 108 161 22 40 52 7 12 15 44 81 103
51328 +71 116 144 28 67 93 37 51 59 41 65 82 100 139 164 101 161 196
51329 +90 154 193 90 154 193 28 67 93 0 0 0 0 0 0 26 28 28
51330 +125 124 125 167 166 167 163 162 163 153 152 153 163 162 163 174 174 174
51331 +85 115 134 4 0 0
51332 +4 4 4 5 5 5 4 4 4 1 0 0 4 0 0 34 47 55
51333 +125 124 125 174 174 174 174 174 174 167 166 167 157 156 157 153 152 153
51334 +155 154 155 155 154 155 158 157 158 166 165 166 167 166 167 154 153 154
51335 +125 124 125 26 28 28 4 0 0 4 0 0 4 0 0 5 5 5
51336 +5 5 5 4 4 4 4 4 4 4 4 4 4 4 4 1 1 1
51337 +0 0 0 0 0 0 1 1 1 4 4 4 4 4 4 4 4 4
51338 +5 5 5 5 5 5 4 3 3 4 0 0 4 0 0 6 6 6
51339 +37 38 37 131 129 131 137 136 137 37 38 37 0 0 0 4 0 0
51340 +4 5 5 43 61 72 90 154 193 172 205 220 146 190 211 136 185 209
51341 +90 154 193 28 67 93 13 20 25 43 61 72 71 116 144 44 81 103
51342 +2 5 5 7 11 13 59 113 148 101 161 196 90 154 193 28 67 93
51343 +13 20 25 6 10 14 0 0 0 13 16 17 60 73 81 137 136 137
51344 +166 165 166 158 157 158 156 155 156 154 153 154 167 166 167 174 174 174
51345 +60 73 81 4 0 0
51346 +4 4 4 4 4 4 0 0 0 3 3 3 60 74 84 174 174 174
51347 +174 174 174 167 166 167 163 162 163 155 154 155 157 156 157 155 154 155
51348 +156 155 156 163 162 163 167 166 167 158 157 158 125 124 125 37 38 37
51349 +4 3 3 4 0 0 4 0 0 6 6 6 6 6 6 5 5 5
51350 +4 4 4 4 4 4 4 4 4 1 1 1 0 0 0 2 3 3
51351 +10 13 16 7 11 13 1 0 0 0 0 0 2 2 1 4 4 4
51352 +4 4 4 4 4 4 4 4 4 5 5 5 4 3 3 4 0 0
51353 +4 0 0 7 11 13 13 16 17 4 0 0 3 3 3 34 47 55
51354 +80 127 157 146 190 211 172 205 220 136 185 209 136 185 209 136 185 209
51355 +28 67 93 22 40 52 55 98 126 55 98 126 21 29 34 7 11 13
51356 +50 82 103 101 161 196 101 161 196 35 83 115 13 20 25 2 2 1
51357 +1 1 2 1 1 2 37 51 59 131 129 131 174 174 174 174 174 174
51358 +167 166 167 163 162 163 163 162 163 167 166 167 174 174 174 125 124 125
51359 +16 19 21 4 0 0
51360 +4 4 4 4 0 0 4 0 0 60 74 84 174 174 174 174 174 174
51361 +158 157 158 155 154 155 155 154 155 156 155 156 155 154 155 158 157 158
51362 +167 166 167 165 164 165 131 129 131 60 73 81 13 16 17 4 0 0
51363 +4 0 0 4 3 3 6 6 6 4 3 3 5 5 5 4 4 4
51364 +4 4 4 3 2 2 0 0 0 0 0 0 7 11 13 45 69 86
51365 +80 127 157 71 116 144 43 61 72 7 11 13 0 0 0 1 1 1
51366 +4 3 3 4 4 4 4 4 4 4 4 4 6 6 6 5 5 5
51367 +3 2 2 4 0 0 1 0 0 21 29 34 59 113 148 136 185 209
51368 +146 190 211 136 185 209 136 185 209 136 185 209 136 185 209 136 185 209
51369 +68 124 159 44 81 103 22 40 52 13 16 17 43 61 72 90 154 193
51370 +136 185 209 59 113 148 21 29 34 3 4 3 1 1 1 0 0 0
51371 +24 26 27 125 124 125 163 162 163 174 174 174 166 165 166 165 164 165
51372 +163 162 163 125 124 125 125 124 125 125 124 125 125 124 125 26 28 28
51373 +4 0 0 4 3 3
51374 +3 3 3 0 0 0 24 26 27 153 152 153 177 184 187 158 157 158
51375 +156 155 156 156 155 156 155 154 155 155 154 155 165 164 165 174 174 174
51376 +155 154 155 60 74 84 26 28 28 4 0 0 4 0 0 3 1 0
51377 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 3 3
51378 +2 0 0 0 0 0 0 0 0 32 43 50 72 125 159 101 161 196
51379 +136 185 209 101 161 196 101 161 196 79 117 143 32 43 50 0 0 0
51380 +0 0 0 2 2 2 4 4 4 4 4 4 3 3 3 1 0 0
51381 +0 0 0 4 5 5 49 76 92 101 161 196 146 190 211 146 190 211
51382 +136 185 209 136 185 209 136 185 209 136 185 209 136 185 209 90 154 193
51383 +28 67 93 13 16 17 37 51 59 80 127 157 136 185 209 90 154 193
51384 +22 40 52 6 9 11 3 4 3 2 2 1 16 19 21 60 73 81
51385 +137 136 137 163 162 163 158 157 158 166 165 166 167 166 167 153 152 153
51386 +60 74 84 37 38 37 6 6 6 13 16 17 4 0 0 1 0 0
51387 +3 2 2 4 4 4
51388 +3 2 2 4 0 0 37 38 37 137 136 137 167 166 167 158 157 158
51389 +157 156 157 154 153 154 157 156 157 167 166 167 174 174 174 125 124 125
51390 +37 38 37 4 0 0 4 0 0 4 0 0 4 3 3 4 4 4
51391 +4 4 4 4 4 4 5 5 5 5 5 5 1 1 1 0 0 0
51392 +0 0 0 16 21 25 55 98 126 90 154 193 136 185 209 101 161 196
51393 +101 161 196 101 161 196 136 185 209 136 185 209 101 161 196 55 98 126
51394 +14 17 19 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
51395 +22 40 52 90 154 193 146 190 211 146 190 211 136 185 209 136 185 209
51396 +136 185 209 136 185 209 136 185 209 101 161 196 35 83 115 7 11 13
51397 +17 23 27 59 113 148 136 185 209 101 161 196 34 86 122 7 12 15
51398 +2 5 5 3 4 3 6 6 6 60 73 81 131 129 131 163 162 163
51399 +166 165 166 174 174 174 174 174 174 163 162 163 125 124 125 41 54 63
51400 +13 16 17 4 0 0 4 0 0 4 0 0 1 0 0 2 2 2
51401 +4 4 4 4 4 4
51402 +1 1 1 2 1 0 43 57 68 137 136 137 153 152 153 153 152 153
51403 +163 162 163 156 155 156 165 164 165 167 166 167 60 74 84 6 6 6
51404 +4 0 0 4 0 0 5 5 5 4 4 4 4 4 4 4 4 4
51405 +4 5 5 6 6 6 4 3 3 0 0 0 0 0 0 11 15 18
51406 +40 71 93 100 139 164 101 161 196 101 161 196 101 161 196 101 161 196
51407 +101 161 196 101 161 196 101 161 196 101 161 196 136 185 209 136 185 209
51408 +101 161 196 45 69 86 6 6 6 0 0 0 17 23 27 55 98 126
51409 +136 185 209 146 190 211 136 185 209 136 185 209 136 185 209 136 185 209
51410 +136 185 209 136 185 209 90 154 193 22 40 52 7 11 13 50 82 103
51411 +136 185 209 136 185 209 53 118 160 22 40 52 7 11 13 2 5 5
51412 +3 4 3 37 38 37 125 124 125 157 156 157 166 165 166 167 166 167
51413 +174 174 174 174 174 174 137 136 137 60 73 81 4 0 0 4 0 0
51414 +4 0 0 4 0 0 5 5 5 3 3 3 3 3 3 4 4 4
51415 +4 4 4 4 4 4
51416 +4 0 0 4 0 0 41 54 63 137 136 137 125 124 125 131 129 131
51417 +155 154 155 167 166 167 174 174 174 60 74 84 6 6 6 4 0 0
51418 +4 3 3 6 6 6 4 4 4 4 4 4 4 4 4 5 5 5
51419 +4 4 4 1 1 1 0 0 0 3 6 7 41 65 82 72 125 159
51420 +101 161 196 101 161 196 101 161 196 90 154 193 90 154 193 101 161 196
51421 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 136 185 209
51422 +136 185 209 136 185 209 80 127 157 55 98 126 101 161 196 146 190 211
51423 +136 185 209 136 185 209 136 185 209 101 161 196 136 185 209 101 161 196
51424 +136 185 209 101 161 196 35 83 115 22 30 35 101 161 196 172 205 220
51425 +90 154 193 28 67 93 7 11 13 2 5 5 3 4 3 13 16 17
51426 +85 115 134 167 166 167 174 174 174 174 174 174 174 174 174 174 174 174
51427 +167 166 167 60 74 84 13 16 17 4 0 0 4 0 0 4 3 3
51428 +6 6 6 5 5 5 4 4 4 5 5 5 4 4 4 5 5 5
51429 +5 5 5 5 5 5
51430 +1 1 1 4 0 0 41 54 63 137 136 137 137 136 137 125 124 125
51431 +131 129 131 167 166 167 157 156 157 37 38 37 6 6 6 4 0 0
51432 +6 6 6 5 5 5 4 4 4 4 4 4 4 5 5 2 2 1
51433 +0 0 0 0 0 0 26 37 45 58 111 146 101 161 196 101 161 196
51434 +101 161 196 90 154 193 90 154 193 90 154 193 101 161 196 101 161 196
51435 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 101 161 196
51436 +101 161 196 136 185 209 136 185 209 136 185 209 146 190 211 136 185 209
51437 +136 185 209 101 161 196 136 185 209 136 185 209 101 161 196 136 185 209
51438 +101 161 196 136 185 209 136 185 209 136 185 209 136 185 209 16 89 141
51439 +7 11 13 2 5 5 2 5 5 13 16 17 60 73 81 154 154 154
51440 +174 174 174 174 174 174 174 174 174 174 174 174 163 162 163 125 124 125
51441 +24 26 27 4 0 0 4 0 0 4 0 0 5 5 5 5 5 5
51442 +4 4 4 4 4 4 4 4 4 5 5 5 5 5 5 5 5 5
51443 +5 5 5 4 4 4
51444 +4 0 0 6 6 6 37 38 37 137 136 137 137 136 137 131 129 131
51445 +131 129 131 153 152 153 131 129 131 26 28 28 4 0 0 4 3 3
51446 +6 6 6 4 4 4 4 4 4 4 4 4 0 0 0 0 0 0
51447 +13 20 25 51 88 114 90 154 193 101 161 196 101 161 196 90 154 193
51448 +90 154 193 90 154 193 90 154 193 90 154 193 90 154 193 101 161 196
51449 +101 161 196 101 161 196 101 161 196 101 161 196 136 185 209 101 161 196
51450 +101 161 196 136 185 209 101 161 196 136 185 209 136 185 209 101 161 196
51451 +136 185 209 101 161 196 136 185 209 101 161 196 101 161 196 101 161 196
51452 +136 185 209 136 185 209 136 185 209 37 112 160 21 29 34 5 7 8
51453 +2 5 5 13 16 17 43 57 68 131 129 131 174 174 174 174 174 174
51454 +174 174 174 167 166 167 157 156 157 125 124 125 37 38 37 4 0 0
51455 +4 0 0 4 0 0 5 5 5 5 5 5 4 4 4 4 4 4
51456 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51457 +4 4 4 4 4 4
51458 +1 1 1 4 0 0 41 54 63 153 152 153 137 136 137 137 136 137
51459 +137 136 137 153 152 153 125 124 125 24 26 27 4 0 0 3 2 2
51460 +4 4 4 4 4 4 4 3 3 4 0 0 3 6 7 43 61 72
51461 +64 123 161 101 161 196 90 154 193 90 154 193 90 154 193 90 154 193
51462 +90 154 193 90 154 193 90 154 193 90 154 193 101 161 196 90 154 193
51463 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 101 161 196
51464 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 101 161 196
51465 +136 185 209 101 161 196 101 161 196 136 185 209 136 185 209 101 161 196
51466 +101 161 196 90 154 193 28 67 93 13 16 17 7 11 13 3 6 7
51467 +37 51 59 125 124 125 163 162 163 174 174 174 167 166 167 166 165 166
51468 +167 166 167 131 129 131 60 73 81 4 0 0 4 0 0 4 0 0
51469 +3 3 3 5 5 5 6 6 6 4 4 4 4 4 4 4 4 4
51470 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51471 +4 4 4 4 4 4
51472 +4 0 0 4 0 0 41 54 63 137 136 137 153 152 153 137 136 137
51473 +153 152 153 157 156 157 125 124 125 24 26 27 0 0 0 2 2 2
51474 +4 4 4 4 4 4 2 0 0 0 0 0 28 67 93 90 154 193
51475 +90 154 193 90 154 193 90 154 193 90 154 193 64 123 161 90 154 193
51476 +90 154 193 90 154 193 90 154 193 90 154 193 90 154 193 101 161 196
51477 +90 154 193 101 161 196 101 161 196 101 161 196 90 154 193 136 185 209
51478 +101 161 196 101 161 196 136 185 209 101 161 196 136 185 209 101 161 196
51479 +101 161 196 101 161 196 136 185 209 101 161 196 101 161 196 90 154 193
51480 +35 83 115 13 16 17 3 6 7 2 5 5 13 16 17 60 74 84
51481 +154 154 154 166 165 166 165 164 165 158 157 158 163 162 163 157 156 157
51482 +60 74 84 13 16 17 4 0 0 4 0 0 3 2 2 4 4 4
51483 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51484 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51485 +4 4 4 4 4 4
51486 +1 1 1 4 0 0 41 54 63 157 156 157 155 154 155 137 136 137
51487 +153 152 153 158 157 158 137 136 137 26 28 28 2 0 0 2 2 2
51488 +4 4 4 4 4 4 1 0 0 6 10 14 34 86 122 90 154 193
51489 +64 123 161 90 154 193 64 123 161 90 154 193 90 154 193 90 154 193
51490 +64 123 161 90 154 193 90 154 193 90 154 193 90 154 193 90 154 193
51491 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 101 161 196
51492 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 101 161 196
51493 +136 185 209 101 161 196 136 185 209 90 154 193 26 108 161 22 40 52
51494 +13 16 17 5 7 8 2 5 5 2 5 5 37 38 37 165 164 165
51495 +174 174 174 163 162 163 154 154 154 165 164 165 167 166 167 60 73 81
51496 +6 6 6 4 0 0 4 0 0 4 4 4 4 4 4 4 4 4
51497 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51498 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51499 +4 4 4 4 4 4
51500 +4 0 0 6 6 6 41 54 63 156 155 156 158 157 158 153 152 153
51501 +156 155 156 165 164 165 137 136 137 26 28 28 0 0 0 2 2 2
51502 +4 4 5 4 4 4 2 0 0 7 12 15 31 96 139 64 123 161
51503 +90 154 193 64 123 161 90 154 193 90 154 193 64 123 161 90 154 193
51504 +90 154 193 90 154 193 90 154 193 90 154 193 90 154 193 90 154 193
51505 +90 154 193 90 154 193 90 154 193 101 161 196 101 161 196 101 161 196
51506 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 136 185 209
51507 +101 161 196 136 185 209 26 108 161 22 40 52 7 11 13 5 7 8
51508 +2 5 5 2 5 5 2 5 5 2 2 1 37 38 37 158 157 158
51509 +174 174 174 154 154 154 156 155 156 167 166 167 165 164 165 37 38 37
51510 +4 0 0 4 3 3 5 5 5 4 4 4 4 4 4 4 4 4
51511 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51512 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51513 +4 4 4 4 4 4
51514 +3 1 0 4 0 0 60 73 81 157 156 157 163 162 163 153 152 153
51515 +158 157 158 167 166 167 137 136 137 26 28 28 2 0 0 2 2 2
51516 +4 5 5 4 4 4 4 0 0 7 12 15 24 86 132 26 108 161
51517 +37 112 160 64 123 161 90 154 193 64 123 161 90 154 193 90 154 193
51518 +90 154 193 90 154 193 90 154 193 90 154 193 90 154 193 90 154 193
51519 +90 154 193 101 161 196 90 154 193 101 161 196 101 161 196 101 161 196
51520 +101 161 196 101 161 196 101 161 196 136 185 209 101 161 196 136 185 209
51521 +90 154 193 35 83 115 13 16 17 13 16 17 7 11 13 3 6 7
51522 +5 7 8 6 6 6 3 4 3 2 2 1 30 32 34 154 154 154
51523 +167 166 167 154 154 154 154 154 154 174 174 174 165 164 165 37 38 37
51524 +6 6 6 4 0 0 6 6 6 4 4 4 4 4 4 4 4 4
51525 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51526 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51527 +4 4 4 4 4 4
51528 +4 0 0 4 0 0 41 54 63 163 162 163 166 165 166 154 154 154
51529 +163 162 163 174 174 174 137 136 137 26 28 28 0 0 0 2 2 2
51530 +4 5 5 4 4 5 1 1 2 6 10 14 28 67 93 18 97 151
51531 +18 97 151 18 97 151 26 108 161 37 112 160 37 112 160 90 154 193
51532 +64 123 161 90 154 193 90 154 193 90 154 193 90 154 193 101 161 196
51533 +90 154 193 101 161 196 101 161 196 90 154 193 101 161 196 101 161 196
51534 +101 161 196 101 161 196 101 161 196 136 185 209 90 154 193 16 89 141
51535 +13 20 25 7 11 13 5 7 8 5 7 8 2 5 5 4 5 5
51536 +3 4 3 4 5 5 3 4 3 0 0 0 37 38 37 158 157 158
51537 +174 174 174 158 157 158 158 157 158 167 166 167 174 174 174 41 54 63
51538 +4 0 0 3 2 2 5 5 5 4 4 4 4 4 4 4 4 4
51539 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51540 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51541 +4 4 4 4 4 4
51542 +1 1 1 4 0 0 60 73 81 165 164 165 174 174 174 158 157 158
51543 +167 166 167 174 174 174 153 152 153 26 28 28 2 0 0 2 2 2
51544 +4 5 5 4 4 4 4 0 0 7 12 15 10 87 144 10 87 144
51545 +18 97 151 18 97 151 18 97 151 26 108 161 26 108 161 26 108 161
51546 +26 108 161 37 112 160 53 118 160 90 154 193 90 154 193 90 154 193
51547 +90 154 193 90 154 193 101 161 196 101 161 196 101 161 196 101 161 196
51548 +101 161 196 136 185 209 90 154 193 26 108 161 22 40 52 13 16 17
51549 +7 11 13 3 6 7 5 7 8 5 7 8 2 5 5 4 5 5
51550 +4 5 5 6 6 6 3 4 3 0 0 0 30 32 34 158 157 158
51551 +174 174 174 156 155 156 155 154 155 165 164 165 154 153 154 37 38 37
51552 +4 0 0 4 3 3 5 5 5 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
51556 +4 0 0 4 0 0 60 73 81 167 166 167 174 174 174 163 162 163
51557 +174 174 174 174 174 174 153 152 153 26 28 28 0 0 0 3 3 3
51558 +5 5 5 4 4 4 1 1 2 7 12 15 28 67 93 18 97 151
51559 +18 97 151 18 97 151 18 97 151 18 97 151 18 97 151 26 108 161
51560 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
51561 +90 154 193 26 108 161 90 154 193 90 154 193 90 154 193 101 161 196
51562 +101 161 196 26 108 161 22 40 52 13 16 17 7 11 13 2 5 5
51563 +2 5 5 6 6 6 2 5 5 4 5 5 4 5 5 4 5 5
51564 +3 4 3 5 5 5 3 4 3 2 0 0 30 32 34 137 136 137
51565 +153 152 153 137 136 137 131 129 131 137 136 137 131 129 131 37 38 37
51566 +4 0 0 4 3 3 5 5 5 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
51570 +1 1 1 4 0 0 60 73 81 167 166 167 174 174 174 166 165 166
51571 +174 174 174 177 184 187 153 152 153 30 32 34 1 0 0 3 3 3
51572 +5 5 5 4 3 3 4 0 0 7 12 15 10 87 144 10 87 144
51573 +18 97 151 18 97 151 18 97 151 26 108 161 26 108 161 26 108 161
51574 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
51575 +26 108 161 26 108 161 26 108 161 90 154 193 90 154 193 26 108 161
51576 +35 83 115 13 16 17 7 11 13 5 7 8 3 6 7 5 7 8
51577 +2 5 5 6 6 6 4 5 5 4 5 5 3 4 3 4 5 5
51578 +3 4 3 6 6 6 3 4 3 0 0 0 26 28 28 125 124 125
51579 +131 129 131 125 124 125 125 124 125 131 129 131 131 129 131 37 38 37
51580 +4 0 0 3 3 3 5 5 5 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
51584 +3 1 0 4 0 0 60 73 81 174 174 174 177 184 187 167 166 167
51585 +174 174 174 177 184 187 153 152 153 30 32 34 0 0 0 3 3 3
51586 +5 5 5 4 4 4 1 1 2 6 10 14 28 67 93 18 97 151
51587 +18 97 151 18 97 151 18 97 151 18 97 151 18 97 151 26 108 161
51588 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
51589 +26 108 161 90 154 193 26 108 161 26 108 161 24 86 132 13 20 25
51590 +7 11 13 13 20 25 22 40 52 5 7 8 3 4 3 3 4 3
51591 +4 5 5 3 4 3 4 5 5 3 4 3 4 5 5 3 4 3
51592 +4 4 4 5 5 5 3 3 3 2 0 0 26 28 28 125 124 125
51593 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
51594 +0 0 0 3 3 3 5 5 5 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
51598 +1 1 1 4 0 0 60 73 81 174 174 174 177 184 187 174 174 174
51599 +174 174 174 190 197 201 157 156 157 30 32 34 1 0 0 3 3 3
51600 +5 5 5 4 3 3 4 0 0 7 12 15 10 87 144 10 87 144
51601 +18 97 151 19 95 150 19 95 150 18 97 151 18 97 151 26 108 161
51602 +18 97 151 26 108 161 26 108 161 26 108 161 26 108 161 90 154 193
51603 +26 108 161 26 108 161 26 108 161 22 40 52 2 5 5 3 4 3
51604 +28 67 93 37 112 160 34 86 122 2 5 5 3 4 3 3 4 3
51605 +3 4 3 3 4 3 3 4 3 2 2 1 3 4 3 4 4 4
51606 +4 5 5 5 5 5 3 3 3 0 0 0 26 28 28 131 129 131
51607 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
51608 +0 0 0 3 3 3 5 5 5 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
51612 +4 0 0 4 0 0 60 73 81 174 174 174 177 184 187 174 174 174
51613 +174 174 174 190 197 201 158 157 158 30 32 34 0 0 0 2 2 2
51614 +5 5 5 4 4 4 1 1 2 6 10 14 28 67 93 18 97 151
51615 +10 87 144 19 95 150 19 95 150 18 97 151 18 97 151 18 97 151
51616 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
51617 +18 97 151 22 40 52 2 5 5 2 2 1 22 40 52 26 108 161
51618 +90 154 193 37 112 160 22 40 52 3 4 3 13 20 25 22 30 35
51619 +3 6 7 1 1 1 2 2 2 6 9 11 5 5 5 4 3 3
51620 +4 4 4 5 5 5 3 3 3 2 0 0 26 28 28 131 129 131
51621 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
51622 +0 0 0 3 3 3 5 5 5 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
51626 +1 1 1 4 0 0 60 73 81 177 184 187 193 200 203 174 174 174
51627 +177 184 187 193 200 203 163 162 163 30 32 34 4 0 0 2 2 2
51628 +5 5 5 4 3 3 4 0 0 6 10 14 24 86 132 10 87 144
51629 +10 87 144 10 87 144 19 95 150 19 95 150 19 95 150 18 97 151
51630 +26 108 161 26 108 161 26 108 161 90 154 193 26 108 161 28 67 93
51631 +6 10 14 2 5 5 13 20 25 24 86 132 37 112 160 90 154 193
51632 +10 87 144 7 12 15 2 5 5 28 67 93 37 112 160 28 67 93
51633 +2 2 1 7 12 15 35 83 115 28 67 93 3 6 7 1 0 0
51634 +4 4 4 5 5 5 3 3 3 0 0 0 26 28 28 131 129 131
51635 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
51636 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
51637 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51638 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51639 +4 4 4 4 4 4
51640 +4 0 0 4 0 0 60 73 81 174 174 174 190 197 201 174 174 174
51641 +177 184 187 193 200 203 163 162 163 30 32 34 0 0 0 2 2 2
51642 +5 5 5 4 4 4 1 1 2 6 10 14 28 67 93 10 87 144
51643 +10 87 144 16 89 141 19 95 150 10 87 144 26 108 161 26 108 161
51644 +26 108 161 26 108 161 26 108 161 28 67 93 6 10 14 1 1 2
51645 +7 12 15 28 67 93 26 108 161 16 89 141 24 86 132 21 29 34
51646 +3 4 3 21 29 34 37 112 160 37 112 160 27 99 146 21 29 34
51647 +21 29 34 26 108 161 90 154 193 35 83 115 1 1 2 2 0 0
51648 +4 4 4 5 5 5 3 3 3 2 0 0 26 28 28 125 124 125
51649 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
51650 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
51651 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51652 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51653 +4 4 4 4 4 4
51654 +3 1 0 4 0 0 60 73 81 193 200 203 193 200 203 174 174 174
51655 +190 197 201 193 200 203 165 164 165 37 38 37 4 0 0 2 2 2
51656 +5 5 5 4 3 3 4 0 0 6 10 14 24 86 132 10 87 144
51657 +10 87 144 10 87 144 16 89 141 18 97 151 18 97 151 10 87 144
51658 +24 86 132 24 86 132 13 20 25 4 5 7 4 5 7 22 40 52
51659 +18 97 151 37 112 160 26 108 161 7 12 15 1 1 1 0 0 0
51660 +28 67 93 37 112 160 26 108 161 28 67 93 22 40 52 28 67 93
51661 +26 108 161 90 154 193 26 108 161 10 87 144 0 0 0 2 0 0
51662 +4 4 4 5 5 5 3 3 3 0 0 0 26 28 28 131 129 131
51663 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
51664 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
51665 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51666 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51667 +4 4 4 4 4 4
51668 +4 0 0 6 6 6 60 73 81 174 174 174 193 200 203 174 174 174
51669 +190 197 201 193 200 203 165 164 165 30 32 34 0 0 0 2 2 2
51670 +5 5 5 4 4 4 1 1 2 6 10 14 28 67 93 10 87 144
51671 +10 87 144 10 87 144 10 87 144 18 97 151 28 67 93 6 10 14
51672 +0 0 0 1 1 2 4 5 7 13 20 25 16 89 141 26 108 161
51673 +26 108 161 26 108 161 24 86 132 6 9 11 2 3 3 22 40 52
51674 +37 112 160 16 89 141 22 40 52 28 67 93 26 108 161 26 108 161
51675 +90 154 193 26 108 161 26 108 161 28 67 93 1 1 1 4 0 0
51676 +4 4 4 5 5 5 3 3 3 4 0 0 26 28 28 124 126 130
51677 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
51678 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
51679 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51680 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51681 +4 4 4 4 4 4
51682 +4 0 0 4 0 0 60 73 81 193 200 203 193 200 203 174 174 174
51683 +193 200 203 193 200 203 167 166 167 37 38 37 4 0 0 2 2 2
51684 +5 5 5 4 4 4 4 0 0 6 10 14 28 67 93 10 87 144
51685 +10 87 144 10 87 144 18 97 151 10 87 144 13 20 25 4 5 7
51686 +1 1 2 1 1 1 22 40 52 26 108 161 26 108 161 26 108 161
51687 +26 108 161 26 108 161 26 108 161 24 86 132 22 40 52 22 40 52
51688 +22 40 52 22 40 52 10 87 144 26 108 161 26 108 161 26 108 161
51689 +26 108 161 26 108 161 90 154 193 10 87 144 0 0 0 4 0 0
51690 +4 4 4 5 5 5 3 3 3 0 0 0 26 28 28 131 129 131
51691 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
51692 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
51693 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51694 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51695 +4 4 4 4 4 4
51696 +4 0 0 6 6 6 60 73 81 174 174 174 220 221 221 174 174 174
51697 +190 197 201 205 212 215 167 166 167 30 32 34 0 0 0 2 2 2
51698 +5 5 5 4 4 4 1 1 2 6 10 14 28 67 93 10 87 144
51699 +10 87 144 10 87 144 10 87 144 10 87 144 22 40 52 1 1 2
51700 +2 0 0 1 1 2 24 86 132 26 108 161 26 108 161 26 108 161
51701 +26 108 161 19 95 150 16 89 141 10 87 144 22 40 52 22 40 52
51702 +10 87 144 26 108 161 37 112 160 26 108 161 26 108 161 26 108 161
51703 +26 108 161 26 108 161 26 108 161 28 67 93 2 0 0 3 1 0
51704 +4 4 4 5 5 5 3 3 3 2 0 0 26 28 28 131 129 131
51705 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
51706 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
51707 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51708 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51709 +4 4 4 4 4 4
51710 +4 0 0 4 0 0 60 73 81 220 221 221 190 197 201 174 174 174
51711 +193 200 203 193 200 203 174 174 174 37 38 37 4 0 0 2 2 2
51712 +5 5 5 4 4 4 3 2 2 1 1 2 13 20 25 10 87 144
51713 +10 87 144 10 87 144 10 87 144 10 87 144 10 87 144 13 20 25
51714 +13 20 25 22 40 52 10 87 144 18 97 151 18 97 151 26 108 161
51715 +10 87 144 13 20 25 6 10 14 21 29 34 24 86 132 18 97 151
51716 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
51717 +26 108 161 90 154 193 18 97 151 13 20 25 0 0 0 4 3 3
51718 +4 4 4 5 5 5 3 3 3 0 0 0 26 28 28 131 129 131
51719 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
51720 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
51721 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51722 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51723 +4 4 4 4 4 4
51724 +4 0 0 6 6 6 60 73 81 174 174 174 220 221 221 174 174 174
51725 +190 197 201 220 221 221 167 166 167 30 32 34 1 0 0 2 2 2
51726 +5 5 5 4 4 4 4 4 5 2 5 5 4 5 7 13 20 25
51727 +28 67 93 10 87 144 10 87 144 10 87 144 10 87 144 10 87 144
51728 +10 87 144 10 87 144 18 97 151 10 87 144 18 97 151 18 97 151
51729 +28 67 93 2 3 3 0 0 0 28 67 93 26 108 161 26 108 161
51730 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
51731 +26 108 161 10 87 144 13 20 25 1 1 2 3 2 2 4 4 4
51732 +4 4 4 5 5 5 3 3 3 2 0 0 26 28 28 131 129 131
51733 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
51734 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
51735 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51736 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51737 +4 4 4 4 4 4
51738 +4 0 0 4 0 0 60 73 81 220 221 221 190 197 201 174 174 174
51739 +193 200 203 193 200 203 174 174 174 26 28 28 4 0 0 4 3 3
51740 +5 5 5 4 4 4 4 4 4 4 4 5 1 1 2 2 5 5
51741 +4 5 7 22 40 52 10 87 144 10 87 144 18 97 151 10 87 144
51742 +10 87 144 10 87 144 10 87 144 10 87 144 10 87 144 18 97 151
51743 +10 87 144 28 67 93 22 40 52 10 87 144 26 108 161 18 97 151
51744 +18 97 151 18 97 151 26 108 161 26 108 161 26 108 161 26 108 161
51745 +22 40 52 1 1 2 0 0 0 2 3 3 4 4 4 4 4 4
51746 +4 4 4 5 5 5 4 4 4 0 0 0 26 28 28 131 129 131
51747 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
51748 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
51749 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51750 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51751 +4 4 4 4 4 4
51752 +4 0 0 6 6 6 60 73 81 174 174 174 220 221 221 174 174 174
51753 +190 197 201 220 221 221 190 197 201 41 54 63 4 0 0 2 2 2
51754 +6 6 6 4 4 4 4 4 4 4 4 5 4 4 5 3 3 3
51755 +1 1 2 1 1 2 6 10 14 22 40 52 10 87 144 18 97 151
51756 +18 97 151 10 87 144 10 87 144 10 87 144 18 97 151 10 87 144
51757 +10 87 144 18 97 151 26 108 161 18 97 151 18 97 151 10 87 144
51758 +26 108 161 26 108 161 26 108 161 10 87 144 28 67 93 6 10 14
51759 +1 1 2 1 1 2 4 3 3 4 4 5 4 4 4 4 4 4
51760 +5 5 5 5 5 5 1 1 1 4 0 0 37 51 59 137 136 137
51761 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
51762 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
51763 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51764 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51765 +4 4 4 4 4 4
51766 +4 0 0 4 0 0 60 73 81 220 221 221 193 200 203 174 174 174
51767 +193 200 203 193 200 203 220 221 221 137 136 137 13 16 17 4 0 0
51768 +2 2 2 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5
51769 +4 4 5 4 3 3 1 1 2 4 5 7 13 20 25 28 67 93
51770 +10 87 144 10 87 144 10 87 144 10 87 144 10 87 144 10 87 144
51771 +10 87 144 18 97 151 18 97 151 10 87 144 18 97 151 26 108 161
51772 +26 108 161 18 97 151 28 67 93 6 10 14 0 0 0 0 0 0
51773 +2 3 3 4 5 5 4 4 5 4 4 4 4 4 4 5 5 5
51774 +3 3 3 1 1 1 0 0 0 16 19 21 125 124 125 137 136 137
51775 +131 129 131 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
51776 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
51777 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51778 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51779 +4 4 4 4 4 4
51780 +4 0 0 6 6 6 60 73 81 174 174 174 220 221 221 174 174 174
51781 +193 200 203 190 197 201 220 221 221 220 221 221 153 152 153 30 32 34
51782 +0 0 0 0 0 0 2 2 2 4 4 4 4 4 4 4 4 4
51783 +4 4 4 4 5 5 4 5 7 1 1 2 1 1 2 4 5 7
51784 +13 20 25 28 67 93 10 87 144 18 97 151 10 87 144 10 87 144
51785 +10 87 144 10 87 144 10 87 144 18 97 151 26 108 161 18 97 151
51786 +28 67 93 7 12 15 0 0 0 0 0 0 2 2 1 4 4 4
51787 +4 5 5 4 5 5 4 4 4 4 4 4 3 3 3 0 0 0
51788 +0 0 0 0 0 0 37 38 37 125 124 125 158 157 158 131 129 131
51789 +125 124 125 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
51790 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
51791 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51792 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51793 +4 4 4 4 4 4
51794 +4 3 3 4 0 0 41 54 63 193 200 203 220 221 221 174 174 174
51795 +193 200 203 193 200 203 193 200 203 220 221 221 244 246 246 193 200 203
51796 +120 125 127 5 5 5 1 0 0 0 0 0 1 1 1 4 4 4
51797 +4 4 4 4 4 4 4 5 5 4 5 5 4 4 5 1 1 2
51798 +4 5 7 4 5 7 22 40 52 10 87 144 10 87 144 10 87 144
51799 +10 87 144 10 87 144 18 97 151 10 87 144 10 87 144 13 20 25
51800 +4 5 7 2 3 3 1 1 2 4 4 4 4 5 5 4 4 4
51801 +4 4 4 4 4 4 4 4 4 1 1 1 0 0 0 1 1 2
51802 +24 26 27 60 74 84 153 152 153 163 162 163 137 136 137 125 124 125
51803 +125 124 125 125 124 125 125 124 125 137 136 137 125 124 125 26 28 28
51804 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
51805 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51806 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51807 +4 4 4 4 4 4
51808 +4 0 0 6 6 6 26 28 28 156 155 156 220 221 221 220 221 221
51809 +174 174 174 193 200 203 193 200 203 193 200 203 205 212 215 220 221 221
51810 +220 221 221 167 166 167 60 73 81 7 11 13 0 0 0 0 0 0
51811 +3 3 3 4 4 4 4 4 4 4 4 4 4 4 5 4 4 5
51812 +4 4 5 1 1 2 1 1 2 4 5 7 22 40 52 10 87 144
51813 +10 87 144 10 87 144 10 87 144 22 40 52 4 5 7 1 1 2
51814 +1 1 2 4 4 5 4 4 4 4 4 4 4 4 4 4 4 4
51815 +5 5 5 2 2 2 0 0 0 4 0 0 16 19 21 60 73 81
51816 +137 136 137 167 166 167 158 157 158 137 136 137 131 129 131 131 129 131
51817 +125 124 125 125 124 125 131 129 131 155 154 155 60 74 84 5 7 8
51818 +0 0 0 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51819 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51820 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51821 +4 4 4 4 4 4
51822 +5 5 5 4 0 0 4 0 0 60 73 81 193 200 203 220 221 221
51823 +193 200 203 193 200 203 193 200 203 193 200 203 205 212 215 220 221 221
51824 +220 221 221 220 221 221 220 221 221 137 136 137 43 57 68 6 6 6
51825 +4 0 0 1 1 1 4 4 4 4 4 4 4 4 4 4 4 4
51826 +4 4 5 4 4 5 3 2 2 1 1 2 2 5 5 13 20 25
51827 +22 40 52 22 40 52 13 20 25 2 3 3 1 1 2 3 3 3
51828 +4 5 7 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51829 +1 1 1 0 0 0 2 3 3 41 54 63 131 129 131 166 165 166
51830 +166 165 166 155 154 155 153 152 153 137 136 137 137 136 137 125 124 125
51831 +125 124 125 137 136 137 137 136 137 125 124 125 37 38 37 4 3 3
51832 +4 3 3 5 5 5 4 4 4 4 4 4 4 4 4 4 4 4
51833 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51834 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51835 +4 4 4 4 4 4
51836 +4 3 3 6 6 6 6 6 6 13 16 17 60 73 81 167 166 167
51837 +220 221 221 220 221 221 220 221 221 193 200 203 193 200 203 193 200 203
51838 +205 212 215 220 221 221 220 221 221 244 246 246 205 212 215 125 124 125
51839 +24 26 27 0 0 0 0 0 0 2 2 2 5 5 5 5 5 5
51840 +4 4 4 4 4 4 4 4 4 4 4 5 1 1 2 4 5 7
51841 +4 5 7 4 5 7 1 1 2 3 2 2 4 4 5 4 4 4
51842 +4 4 4 4 4 4 5 5 5 4 4 4 0 0 0 0 0 0
51843 +2 0 0 26 28 28 125 124 125 174 174 174 174 174 174 166 165 166
51844 +156 155 156 153 152 153 137 136 137 137 136 137 131 129 131 137 136 137
51845 +137 136 137 137 136 137 60 74 84 30 32 34 4 0 0 4 0 0
51846 +5 5 5 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51847 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51848 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51849 +4 4 4 4 4 4
51850 +5 5 5 6 6 6 4 0 0 4 0 0 6 6 6 26 28 28
51851 +125 124 125 174 174 174 220 221 221 220 221 221 220 221 221 193 200 203
51852 +205 212 215 220 221 221 205 212 215 220 221 221 220 221 221 244 246 246
51853 +193 200 203 60 74 84 13 16 17 4 0 0 0 0 0 3 3 3
51854 +5 5 5 5 5 5 4 4 4 4 4 4 4 4 5 3 3 3
51855 +1 1 2 3 3 3 4 4 5 4 4 5 4 4 4 4 4 4
51856 +5 5 5 5 5 5 2 2 2 0 0 0 0 0 0 13 16 17
51857 +60 74 84 174 174 174 193 200 203 174 174 174 167 166 167 163 162 163
51858 +153 152 153 153 152 153 137 136 137 137 136 137 153 152 153 137 136 137
51859 +125 124 125 41 54 63 24 26 27 4 0 0 4 0 0 5 5 5
51860 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51861 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51862 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51863 +4 4 4 4 4 4
51864 +4 3 3 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6
51865 +6 6 6 37 38 37 131 129 131 220 221 221 220 221 221 220 221 221
51866 +193 200 203 193 200 203 220 221 221 205 212 215 220 221 221 244 246 246
51867 +244 246 246 244 246 246 174 174 174 41 54 63 0 0 0 0 0 0
51868 +0 0 0 4 4 4 5 5 5 5 5 5 4 4 4 4 4 5
51869 +4 4 5 4 4 5 4 4 4 4 4 4 6 6 6 6 6 6
51870 +3 3 3 0 0 0 2 0 0 13 16 17 60 73 81 156 155 156
51871 +220 221 221 193 200 203 174 174 174 165 164 165 163 162 163 154 153 154
51872 +153 152 153 153 152 153 158 157 158 163 162 163 137 136 137 60 73 81
51873 +13 16 17 4 0 0 4 0 0 4 3 3 4 4 4 4 4 4
51874 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51875 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51876 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51877 +4 4 4 4 4 4
51878 +5 5 5 4 3 3 4 3 3 6 6 6 6 6 6 6 6 6
51879 +6 6 6 6 6 6 6 6 6 37 38 37 167 166 167 244 246 246
51880 +244 246 246 220 221 221 205 212 215 205 212 215 220 221 221 193 200 203
51881 +220 221 221 244 246 246 244 246 246 244 246 246 137 136 137 37 38 37
51882 +3 2 2 0 0 0 1 1 1 5 5 5 5 5 5 4 4 4
51883 +4 4 4 4 4 4 4 4 4 5 5 5 4 4 4 1 1 1
51884 +0 0 0 5 5 5 43 57 68 153 152 153 193 200 203 220 221 221
51885 +177 184 187 174 174 174 167 166 167 166 165 166 158 157 158 157 156 157
51886 +158 157 158 166 165 166 156 155 156 85 115 134 13 16 17 4 0 0
51887 +4 0 0 4 0 0 5 5 5 5 5 5 4 4 4 4 4 4
51888 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51889 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51890 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51891 +4 4 4 4 4 4
51892 +5 5 5 4 3 3 6 6 6 6 6 6 4 0 0 6 6 6
51893 +6 6 6 6 6 6 6 6 6 6 6 6 13 16 17 60 73 81
51894 +177 184 187 220 221 221 220 221 221 220 221 221 205 212 215 220 221 221
51895 +220 221 221 205 212 215 220 221 221 244 246 246 244 246 246 205 212 215
51896 +125 124 125 30 32 34 0 0 0 0 0 0 2 2 2 5 5 5
51897 +4 4 4 4 4 4 4 4 4 1 1 1 0 0 0 1 0 0
51898 +37 38 37 131 129 131 205 212 215 220 221 221 193 200 203 174 174 174
51899 +174 174 174 174 174 174 167 166 167 165 164 165 166 165 166 167 166 167
51900 +158 157 158 125 124 125 37 38 37 4 0 0 4 0 0 4 0 0
51901 +4 3 3 5 5 5 4 4 4 4 4 4 4 4 4 4 4 4
51902 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51903 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51904 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51905 +4 4 4 4 4 4
51906 +4 4 4 5 5 5 4 3 3 4 3 3 6 6 6 6 6 6
51907 +4 0 0 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6
51908 +26 28 28 125 124 125 205 212 215 220 221 221 220 221 221 220 221 221
51909 +205 212 215 220 221 221 205 212 215 220 221 221 220 221 221 244 246 246
51910 +244 246 246 190 197 201 60 74 84 16 19 21 4 0 0 0 0 0
51911 +0 0 0 0 0 0 0 0 0 0 0 0 16 19 21 120 125 127
51912 +177 184 187 220 221 221 205 212 215 177 184 187 174 174 174 177 184 187
51913 +174 174 174 174 174 174 167 166 167 174 174 174 166 165 166 137 136 137
51914 +60 73 81 13 16 17 4 0 0 4 0 0 4 3 3 6 6 6
51915 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51916 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51917 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51918 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51919 +4 4 4 4 4 4
51920 +5 5 5 4 3 3 5 5 5 4 3 3 6 6 6 4 0 0
51921 +6 6 6 6 6 6 4 0 0 6 6 6 4 0 0 6 6 6
51922 +6 6 6 6 6 6 37 38 37 137 136 137 193 200 203 220 221 221
51923 +220 221 221 205 212 215 220 221 221 205 212 215 205 212 215 220 221 221
51924 +220 221 221 220 221 221 244 246 246 166 165 166 43 57 68 2 2 2
51925 +0 0 0 4 0 0 16 19 21 60 73 81 157 156 157 202 210 214
51926 +220 221 221 193 200 203 177 184 187 177 184 187 177 184 187 174 174 174
51927 +174 174 174 174 174 174 174 174 174 157 156 157 60 74 84 24 26 27
51928 +4 0 0 4 0 0 4 0 0 6 6 6 4 4 4 4 4 4
51929 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51930 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51931 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51932 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51933 +4 4 4 4 4 4
51934 +4 4 4 4 4 4 5 5 5 4 3 3 5 5 5 6 6 6
51935 +6 6 6 4 0 0 6 6 6 6 6 6 6 6 6 4 0 0
51936 +4 0 0 4 0 0 6 6 6 24 26 27 60 73 81 167 166 167
51937 +220 221 221 220 221 221 220 221 221 205 212 215 205 212 215 205 212 215
51938 +205 212 215 220 221 221 220 221 221 220 221 221 205 212 215 137 136 137
51939 +60 74 84 125 124 125 137 136 137 190 197 201 220 221 221 193 200 203
51940 +177 184 187 177 184 187 177 184 187 174 174 174 174 174 174 177 184 187
51941 +190 197 201 174 174 174 125 124 125 37 38 37 6 6 6 4 0 0
51942 +4 0 0 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51943 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51944 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51945 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51946 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51947 +4 4 4 4 4 4
51948 +4 4 4 4 4 4 5 5 5 5 5 5 4 3 3 6 6 6
51949 +4 0 0 6 6 6 6 6 6 6 6 6 4 0 0 6 6 6
51950 +6 6 6 6 6 6 4 0 0 4 0 0 6 6 6 6 6 6
51951 +125 124 125 193 200 203 244 246 246 220 221 221 205 212 215 205 212 215
51952 +205 212 215 193 200 203 205 212 215 205 212 215 220 221 221 220 221 221
51953 +193 200 203 193 200 203 205 212 215 193 200 203 193 200 203 177 184 187
51954 +190 197 201 190 197 201 174 174 174 190 197 201 193 200 203 190 197 201
51955 +153 152 153 60 73 81 4 0 0 4 0 0 4 0 0 3 2 2
51956 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51957 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51958 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51959 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51960 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51961 +4 4 4 4 4 4
51962 +4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 4 3 3
51963 +6 6 6 4 3 3 4 3 3 4 3 3 6 6 6 6 6 6
51964 +4 0 0 6 6 6 6 6 6 6 6 6 4 0 0 4 0 0
51965 +4 0 0 26 28 28 131 129 131 220 221 221 244 246 246 220 221 221
51966 +205 212 215 193 200 203 205 212 215 193 200 203 193 200 203 205 212 215
51967 +220 221 221 193 200 203 193 200 203 193 200 203 190 197 201 174 174 174
51968 +174 174 174 190 197 201 193 200 203 193 200 203 167 166 167 125 124 125
51969 +6 6 6 4 0 0 4 0 0 4 3 3 4 4 4 4 4 4
51970 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51971 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51972 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51973 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51974 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51975 +4 4 4 4 4 4
51976 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5 5 5
51977 +5 5 5 4 3 3 5 5 5 6 6 6 4 3 3 5 5 5
51978 +6 6 6 6 6 6 4 0 0 6 6 6 6 6 6 6 6 6
51979 +4 0 0 4 0 0 6 6 6 41 54 63 158 157 158 220 221 221
51980 +220 221 221 220 221 221 193 200 203 193 200 203 193 200 203 190 197 201
51981 +190 197 201 190 197 201 190 197 201 190 197 201 174 174 174 193 200 203
51982 +193 200 203 220 221 221 174 174 174 125 124 125 37 38 37 4 0 0
51983 +4 0 0 4 3 3 6 6 6 4 4 4 4 4 4 4 4 4
51984 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51985 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51986 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51987 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51988 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51989 +4 4 4 4 4 4
51990 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51991 +4 4 4 5 5 5 4 3 3 4 3 3 4 3 3 5 5 5
51992 +4 3 3 6 6 6 5 5 5 4 3 3 6 6 6 6 6 6
51993 +6 6 6 6 6 6 4 0 0 4 0 0 13 16 17 60 73 81
51994 +174 174 174 220 221 221 220 221 221 205 212 215 190 197 201 174 174 174
51995 +193 200 203 174 174 174 190 197 201 174 174 174 193 200 203 220 221 221
51996 +193 200 203 131 129 131 37 38 37 6 6 6 4 0 0 4 0 0
51997 +6 6 6 6 6 6 4 3 3 5 5 5 4 4 4 4 4 4
51998 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51999 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52000 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52001 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52002 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52003 +4 4 4 4 4 4
52004 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52005 +4 4 4 4 4 4 4 4 4 5 5 5 5 5 5 5 5 5
52006 +5 5 5 4 3 3 4 3 3 5 5 5 4 3 3 4 3 3
52007 +5 5 5 6 6 6 6 6 6 4 0 0 6 6 6 6 6 6
52008 +6 6 6 125 124 125 174 174 174 220 221 221 220 221 221 193 200 203
52009 +193 200 203 193 200 203 193 200 203 193 200 203 220 221 221 158 157 158
52010 +60 73 81 6 6 6 4 0 0 4 0 0 5 5 5 6 6 6
52011 +5 5 5 5 5 5 4 4 4 4 4 4 4 4 4 4 4 4
52012 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52013 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52014 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52015 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52016 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52017 +4 4 4 4 4 4
52018 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52019 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52020 +4 4 4 5 5 5 5 5 5 4 3 3 5 5 5 4 3 3
52021 +5 5 5 5 5 5 6 6 6 6 6 6 4 0 0 4 0 0
52022 +4 0 0 4 0 0 26 28 28 125 124 125 174 174 174 193 200 203
52023 +193 200 203 174 174 174 193 200 203 167 166 167 125 124 125 6 6 6
52024 +6 6 6 6 6 6 4 0 0 6 6 6 6 6 6 5 5 5
52025 +4 3 3 5 5 5 4 4 4 4 4 4 4 4 4 4 4 4
52026 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52027 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52028 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52029 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52030 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52031 +4 4 4 4 4 4
52032 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52033 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52034 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5 5 5
52035 +4 3 3 6 6 6 4 0 0 6 6 6 6 6 6 6 6 6
52036 +6 6 6 4 0 0 4 0 0 6 6 6 37 38 37 125 124 125
52037 +153 152 153 131 129 131 125 124 125 37 38 37 6 6 6 6 6 6
52038 +6 6 6 4 0 0 6 6 6 6 6 6 4 3 3 5 5 5
52039 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52040 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52041 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52042 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52043 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52044 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52045 +4 4 4 4 4 4
52046 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52047 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52048 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52049 +4 4 4 5 5 5 5 5 5 4 3 3 5 5 5 4 3 3
52050 +6 6 6 6 6 6 4 0 0 4 0 0 6 6 6 6 6 6
52051 +24 26 27 24 26 27 6 6 6 6 6 6 6 6 6 4 0 0
52052 +6 6 6 6 6 6 4 0 0 6 6 6 5 5 5 4 3 3
52053 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52054 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52055 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52056 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52057 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52058 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52059 +4 4 4 4 4 4
52060 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52061 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52062 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52063 +4 4 4 4 4 4 5 5 5 4 3 3 5 5 5 6 6 6
52064 +4 0 0 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6
52065 +6 6 6 6 6 6 6 6 6 4 0 0 6 6 6 6 6 6
52066 +4 0 0 6 6 6 6 6 6 4 3 3 5 5 5 4 4 4
52067 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52068 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52069 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52070 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52071 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52072 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52073 +4 4 4 4 4 4
52074 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52075 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52076 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52077 +4 4 4 4 4 4 4 4 4 5 5 5 4 3 3 5 5 5
52078 +5 5 5 5 5 5 4 0 0 6 6 6 4 0 0 6 6 6
52079 +6 6 6 6 6 6 6 6 6 4 0 0 6 6 6 4 0 0
52080 +6 6 6 4 3 3 5 5 5 4 3 3 5 5 5 4 4 4
52081 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52082 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52083 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52084 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52085 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52086 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52087 +4 4 4 4 4 4
52088 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52089 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52090 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52091 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5 5 5
52092 +4 3 3 6 6 6 4 3 3 6 6 6 6 6 6 6 6 6
52093 +4 0 0 6 6 6 4 0 0 6 6 6 6 6 6 6 6 6
52094 +6 6 6 4 3 3 5 5 5 4 4 4 4 4 4 4 4 4
52095 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52096 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52097 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52098 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52099 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52100 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52101 +4 4 4 4 4 4
52102 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52103 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52104 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52105 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52106 +4 4 4 5 5 5 4 3 3 5 5 5 4 0 0 6 6 6
52107 +6 6 6 4 0 0 6 6 6 6 6 6 4 0 0 6 6 6
52108 +4 3 3 5 5 5 5 5 5 4 4 4 4 4 4 4 4 4
52109 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52110 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52111 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52112 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52113 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52114 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52115 +4 4 4 4 4 4
52116 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52117 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52118 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52119 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52120 +4 4 4 5 5 5 4 3 3 5 5 5 6 6 6 4 3 3
52121 +4 3 3 6 6 6 6 6 6 4 3 3 6 6 6 4 3 3
52122 +5 5 5 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52123 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52124 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52125 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52126 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52127 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52128 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52129 +4 4 4 4 4 4
52130 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52131 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52132 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52133 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52134 +4 4 4 4 4 4 4 4 4 5 5 5 4 3 3 6 6 6
52135 +5 5 5 4 3 3 4 3 3 4 3 3 5 5 5 5 5 5
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 4 4 4 4 4 4 4 4 4 4 4 4
52138 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52139 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52140 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52141 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52142 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52143 +4 4 4 4 4 4
52144 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52145 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52146 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52147 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52148 +4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 4 3 3
52149 +5 5 5 4 3 3 5 5 5 5 5 5 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 4 4 4 4 4 4 4 4 4 4 4 4
52152 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52153 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52154 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52155 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52156 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52157 +4 4 4 4 4 4
52158 diff --git a/drivers/video/mb862xx/mb862xxfb_accel.c b/drivers/video/mb862xx/mb862xxfb_accel.c
52159 index fe92eed..106e085 100644
52160 --- a/drivers/video/mb862xx/mb862xxfb_accel.c
52161 +++ b/drivers/video/mb862xx/mb862xxfb_accel.c
52162 @@ -312,14 +312,18 @@ void mb862xxfb_init_accel(struct fb_info *info, int xres)
52163 struct mb862xxfb_par *par = info->par;
52164
52165 if (info->var.bits_per_pixel == 32) {
52166 - info->fbops->fb_fillrect = cfb_fillrect;
52167 - info->fbops->fb_copyarea = cfb_copyarea;
52168 - info->fbops->fb_imageblit = cfb_imageblit;
52169 + pax_open_kernel();
52170 + *(void **)&info->fbops->fb_fillrect = cfb_fillrect;
52171 + *(void **)&info->fbops->fb_copyarea = cfb_copyarea;
52172 + *(void **)&info->fbops->fb_imageblit = cfb_imageblit;
52173 + pax_close_kernel();
52174 } else {
52175 outreg(disp, GC_L0EM, 3);
52176 - info->fbops->fb_fillrect = mb86290fb_fillrect;
52177 - info->fbops->fb_copyarea = mb86290fb_copyarea;
52178 - info->fbops->fb_imageblit = mb86290fb_imageblit;
52179 + pax_open_kernel();
52180 + *(void **)&info->fbops->fb_fillrect = mb86290fb_fillrect;
52181 + *(void **)&info->fbops->fb_copyarea = mb86290fb_copyarea;
52182 + *(void **)&info->fbops->fb_imageblit = mb86290fb_imageblit;
52183 + pax_close_kernel();
52184 }
52185 outreg(draw, GDC_REG_DRAW_BASE, 0);
52186 outreg(draw, GDC_REG_MODE_MISC, 0x8000);
52187 diff --git a/drivers/video/nvidia/nvidia.c b/drivers/video/nvidia/nvidia.c
52188 index ff22871..b129bed 100644
52189 --- a/drivers/video/nvidia/nvidia.c
52190 +++ b/drivers/video/nvidia/nvidia.c
52191 @@ -669,19 +669,23 @@ static int nvidiafb_set_par(struct fb_info *info)
52192 info->fix.line_length = (info->var.xres_virtual *
52193 info->var.bits_per_pixel) >> 3;
52194 if (info->var.accel_flags) {
52195 - info->fbops->fb_imageblit = nvidiafb_imageblit;
52196 - info->fbops->fb_fillrect = nvidiafb_fillrect;
52197 - info->fbops->fb_copyarea = nvidiafb_copyarea;
52198 - info->fbops->fb_sync = nvidiafb_sync;
52199 + pax_open_kernel();
52200 + *(void **)&info->fbops->fb_imageblit = nvidiafb_imageblit;
52201 + *(void **)&info->fbops->fb_fillrect = nvidiafb_fillrect;
52202 + *(void **)&info->fbops->fb_copyarea = nvidiafb_copyarea;
52203 + *(void **)&info->fbops->fb_sync = nvidiafb_sync;
52204 + pax_close_kernel();
52205 info->pixmap.scan_align = 4;
52206 info->flags &= ~FBINFO_HWACCEL_DISABLED;
52207 info->flags |= FBINFO_READS_FAST;
52208 NVResetGraphics(info);
52209 } else {
52210 - info->fbops->fb_imageblit = cfb_imageblit;
52211 - info->fbops->fb_fillrect = cfb_fillrect;
52212 - info->fbops->fb_copyarea = cfb_copyarea;
52213 - info->fbops->fb_sync = NULL;
52214 + pax_open_kernel();
52215 + *(void **)&info->fbops->fb_imageblit = cfb_imageblit;
52216 + *(void **)&info->fbops->fb_fillrect = cfb_fillrect;
52217 + *(void **)&info->fbops->fb_copyarea = cfb_copyarea;
52218 + *(void **)&info->fbops->fb_sync = NULL;
52219 + pax_close_kernel();
52220 info->pixmap.scan_align = 1;
52221 info->flags |= FBINFO_HWACCEL_DISABLED;
52222 info->flags &= ~FBINFO_READS_FAST;
52223 @@ -1173,8 +1177,11 @@ static int nvidia_set_fbinfo(struct fb_info *info)
52224 info->pixmap.size = 8 * 1024;
52225 info->pixmap.flags = FB_PIXMAP_SYSTEM;
52226
52227 - if (!hwcur)
52228 - info->fbops->fb_cursor = NULL;
52229 + if (!hwcur) {
52230 + pax_open_kernel();
52231 + *(void **)&info->fbops->fb_cursor = NULL;
52232 + pax_close_kernel();
52233 + }
52234
52235 info->var.accel_flags = (!noaccel);
52236
52237 diff --git a/drivers/video/omap2/dss/display.c b/drivers/video/omap2/dss/display.c
52238 index fafe7c9..93197b9 100644
52239 --- a/drivers/video/omap2/dss/display.c
52240 +++ b/drivers/video/omap2/dss/display.c
52241 @@ -137,12 +137,14 @@ int omapdss_register_display(struct omap_dss_device *dssdev)
52242 snprintf(dssdev->alias, sizeof(dssdev->alias),
52243 "display%d", disp_num_counter++);
52244
52245 + pax_open_kernel();
52246 if (drv && drv->get_resolution == NULL)
52247 - drv->get_resolution = omapdss_default_get_resolution;
52248 + *(void **)&drv->get_resolution = omapdss_default_get_resolution;
52249 if (drv && drv->get_recommended_bpp == NULL)
52250 - drv->get_recommended_bpp = omapdss_default_get_recommended_bpp;
52251 + *(void **)&drv->get_recommended_bpp = omapdss_default_get_recommended_bpp;
52252 if (drv && drv->get_timings == NULL)
52253 - drv->get_timings = omapdss_default_get_timings;
52254 + *(void **)&drv->get_timings = omapdss_default_get_timings;
52255 + pax_close_kernel();
52256
52257 mutex_lock(&panel_list_mutex);
52258 list_add_tail(&dssdev->panel_list, &panel_list);
52259 diff --git a/drivers/video/s1d13xxxfb.c b/drivers/video/s1d13xxxfb.c
52260 index 05c2dc3..ea1f391 100644
52261 --- a/drivers/video/s1d13xxxfb.c
52262 +++ b/drivers/video/s1d13xxxfb.c
52263 @@ -881,8 +881,10 @@ static int s1d13xxxfb_probe(struct platform_device *pdev)
52264
52265 switch(prod_id) {
52266 case S1D13506_PROD_ID: /* activate acceleration */
52267 - s1d13xxxfb_fbops.fb_fillrect = s1d13xxxfb_bitblt_solidfill;
52268 - s1d13xxxfb_fbops.fb_copyarea = s1d13xxxfb_bitblt_copyarea;
52269 + pax_open_kernel();
52270 + *(void **)&s1d13xxxfb_fbops.fb_fillrect = s1d13xxxfb_bitblt_solidfill;
52271 + *(void **)&s1d13xxxfb_fbops.fb_copyarea = s1d13xxxfb_bitblt_copyarea;
52272 + pax_close_kernel();
52273 info->flags = FBINFO_DEFAULT | FBINFO_HWACCEL_YPAN |
52274 FBINFO_HWACCEL_FILLRECT | FBINFO_HWACCEL_COPYAREA;
52275 break;
52276 diff --git a/drivers/video/smscufx.c b/drivers/video/smscufx.c
52277 index e188ada..aac63c8 100644
52278 --- a/drivers/video/smscufx.c
52279 +++ b/drivers/video/smscufx.c
52280 @@ -1175,7 +1175,9 @@ static int ufx_ops_release(struct fb_info *info, int user)
52281 fb_deferred_io_cleanup(info);
52282 kfree(info->fbdefio);
52283 info->fbdefio = NULL;
52284 - info->fbops->fb_mmap = ufx_ops_mmap;
52285 + pax_open_kernel();
52286 + *(void **)&info->fbops->fb_mmap = ufx_ops_mmap;
52287 + pax_close_kernel();
52288 }
52289
52290 pr_debug("released /dev/fb%d user=%d count=%d",
52291 diff --git a/drivers/video/udlfb.c b/drivers/video/udlfb.c
52292 index d2e5bc3..4cb05d1 100644
52293 --- a/drivers/video/udlfb.c
52294 +++ b/drivers/video/udlfb.c
52295 @@ -623,11 +623,11 @@ static int dlfb_handle_damage(struct dlfb_data *dev, int x, int y,
52296 dlfb_urb_completion(urb);
52297
52298 error:
52299 - atomic_add(bytes_sent, &dev->bytes_sent);
52300 - atomic_add(bytes_identical, &dev->bytes_identical);
52301 - atomic_add(width*height*2, &dev->bytes_rendered);
52302 + atomic_add_unchecked(bytes_sent, &dev->bytes_sent);
52303 + atomic_add_unchecked(bytes_identical, &dev->bytes_identical);
52304 + atomic_add_unchecked(width*height*2, &dev->bytes_rendered);
52305 end_cycles = get_cycles();
52306 - atomic_add(((unsigned int) ((end_cycles - start_cycles)
52307 + atomic_add_unchecked(((unsigned int) ((end_cycles - start_cycles)
52308 >> 10)), /* Kcycles */
52309 &dev->cpu_kcycles_used);
52310
52311 @@ -748,11 +748,11 @@ static void dlfb_dpy_deferred_io(struct fb_info *info,
52312 dlfb_urb_completion(urb);
52313
52314 error:
52315 - atomic_add(bytes_sent, &dev->bytes_sent);
52316 - atomic_add(bytes_identical, &dev->bytes_identical);
52317 - atomic_add(bytes_rendered, &dev->bytes_rendered);
52318 + atomic_add_unchecked(bytes_sent, &dev->bytes_sent);
52319 + atomic_add_unchecked(bytes_identical, &dev->bytes_identical);
52320 + atomic_add_unchecked(bytes_rendered, &dev->bytes_rendered);
52321 end_cycles = get_cycles();
52322 - atomic_add(((unsigned int) ((end_cycles - start_cycles)
52323 + atomic_add_unchecked(((unsigned int) ((end_cycles - start_cycles)
52324 >> 10)), /* Kcycles */
52325 &dev->cpu_kcycles_used);
52326 }
52327 @@ -993,7 +993,9 @@ static int dlfb_ops_release(struct fb_info *info, int user)
52328 fb_deferred_io_cleanup(info);
52329 kfree(info->fbdefio);
52330 info->fbdefio = NULL;
52331 - info->fbops->fb_mmap = dlfb_ops_mmap;
52332 + pax_open_kernel();
52333 + *(void **)&info->fbops->fb_mmap = dlfb_ops_mmap;
52334 + pax_close_kernel();
52335 }
52336
52337 pr_warn("released /dev/fb%d user=%d count=%d\n",
52338 @@ -1376,7 +1378,7 @@ static ssize_t metrics_bytes_rendered_show(struct device *fbdev,
52339 struct fb_info *fb_info = dev_get_drvdata(fbdev);
52340 struct dlfb_data *dev = fb_info->par;
52341 return snprintf(buf, PAGE_SIZE, "%u\n",
52342 - atomic_read(&dev->bytes_rendered));
52343 + atomic_read_unchecked(&dev->bytes_rendered));
52344 }
52345
52346 static ssize_t metrics_bytes_identical_show(struct device *fbdev,
52347 @@ -1384,7 +1386,7 @@ static ssize_t metrics_bytes_identical_show(struct device *fbdev,
52348 struct fb_info *fb_info = dev_get_drvdata(fbdev);
52349 struct dlfb_data *dev = fb_info->par;
52350 return snprintf(buf, PAGE_SIZE, "%u\n",
52351 - atomic_read(&dev->bytes_identical));
52352 + atomic_read_unchecked(&dev->bytes_identical));
52353 }
52354
52355 static ssize_t metrics_bytes_sent_show(struct device *fbdev,
52356 @@ -1392,7 +1394,7 @@ static ssize_t metrics_bytes_sent_show(struct device *fbdev,
52357 struct fb_info *fb_info = dev_get_drvdata(fbdev);
52358 struct dlfb_data *dev = fb_info->par;
52359 return snprintf(buf, PAGE_SIZE, "%u\n",
52360 - atomic_read(&dev->bytes_sent));
52361 + atomic_read_unchecked(&dev->bytes_sent));
52362 }
52363
52364 static ssize_t metrics_cpu_kcycles_used_show(struct device *fbdev,
52365 @@ -1400,7 +1402,7 @@ static ssize_t metrics_cpu_kcycles_used_show(struct device *fbdev,
52366 struct fb_info *fb_info = dev_get_drvdata(fbdev);
52367 struct dlfb_data *dev = fb_info->par;
52368 return snprintf(buf, PAGE_SIZE, "%u\n",
52369 - atomic_read(&dev->cpu_kcycles_used));
52370 + atomic_read_unchecked(&dev->cpu_kcycles_used));
52371 }
52372
52373 static ssize_t edid_show(
52374 @@ -1460,10 +1462,10 @@ static ssize_t metrics_reset_store(struct device *fbdev,
52375 struct fb_info *fb_info = dev_get_drvdata(fbdev);
52376 struct dlfb_data *dev = fb_info->par;
52377
52378 - atomic_set(&dev->bytes_rendered, 0);
52379 - atomic_set(&dev->bytes_identical, 0);
52380 - atomic_set(&dev->bytes_sent, 0);
52381 - atomic_set(&dev->cpu_kcycles_used, 0);
52382 + atomic_set_unchecked(&dev->bytes_rendered, 0);
52383 + atomic_set_unchecked(&dev->bytes_identical, 0);
52384 + atomic_set_unchecked(&dev->bytes_sent, 0);
52385 + atomic_set_unchecked(&dev->cpu_kcycles_used, 0);
52386
52387 return count;
52388 }
52389 diff --git a/drivers/video/uvesafb.c b/drivers/video/uvesafb.c
52390 index 7aec6f3..e3b2d55 100644
52391 --- a/drivers/video/uvesafb.c
52392 +++ b/drivers/video/uvesafb.c
52393 @@ -19,6 +19,7 @@
52394 #include <linux/io.h>
52395 #include <linux/mutex.h>
52396 #include <linux/slab.h>
52397 +#include <linux/moduleloader.h>
52398 #include <video/edid.h>
52399 #include <video/uvesafb.h>
52400 #ifdef CONFIG_X86
52401 @@ -566,10 +567,32 @@ static int uvesafb_vbe_getpmi(struct uvesafb_ktask *task,
52402 if ((task->t.regs.eax & 0xffff) != 0x4f || task->t.regs.es < 0xc000) {
52403 par->pmi_setpal = par->ypan = 0;
52404 } else {
52405 +
52406 +#ifdef CONFIG_PAX_KERNEXEC
52407 +#ifdef CONFIG_MODULES
52408 + par->pmi_code = module_alloc_exec((u16)task->t.regs.ecx);
52409 +#endif
52410 + if (!par->pmi_code) {
52411 + par->pmi_setpal = par->ypan = 0;
52412 + return 0;
52413 + }
52414 +#endif
52415 +
52416 par->pmi_base = (u16 *)phys_to_virt(((u32)task->t.regs.es << 4)
52417 + task->t.regs.edi);
52418 +
52419 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
52420 + pax_open_kernel();
52421 + memcpy(par->pmi_code, par->pmi_base, (u16)task->t.regs.ecx);
52422 + pax_close_kernel();
52423 +
52424 + par->pmi_start = ktva_ktla(par->pmi_code + par->pmi_base[1]);
52425 + par->pmi_pal = ktva_ktla(par->pmi_code + par->pmi_base[2]);
52426 +#else
52427 par->pmi_start = (u8 *)par->pmi_base + par->pmi_base[1];
52428 par->pmi_pal = (u8 *)par->pmi_base + par->pmi_base[2];
52429 +#endif
52430 +
52431 printk(KERN_INFO "uvesafb: protected mode interface info at "
52432 "%04x:%04x\n",
52433 (u16)task->t.regs.es, (u16)task->t.regs.edi);
52434 @@ -814,13 +837,14 @@ static int uvesafb_vbe_init(struct fb_info *info)
52435 par->ypan = ypan;
52436
52437 if (par->pmi_setpal || par->ypan) {
52438 +#if !defined(CONFIG_MODULES) || !defined(CONFIG_PAX_KERNEXEC)
52439 if (__supported_pte_mask & _PAGE_NX) {
52440 par->pmi_setpal = par->ypan = 0;
52441 printk(KERN_WARNING "uvesafb: NX protection is active, "
52442 "better not use the PMI.\n");
52443 - } else {
52444 + } else
52445 +#endif
52446 uvesafb_vbe_getpmi(task, par);
52447 - }
52448 }
52449 #else
52450 /* The protected mode interface is not available on non-x86. */
52451 @@ -1454,8 +1478,11 @@ static void uvesafb_init_info(struct fb_info *info, struct vbe_mode_ib *mode)
52452 info->fix.ywrapstep = (par->ypan > 1) ? 1 : 0;
52453
52454 /* Disable blanking if the user requested so. */
52455 - if (!blank)
52456 - info->fbops->fb_blank = NULL;
52457 + if (!blank) {
52458 + pax_open_kernel();
52459 + *(void **)&info->fbops->fb_blank = NULL;
52460 + pax_close_kernel();
52461 + }
52462
52463 /*
52464 * Find out how much IO memory is required for the mode with
52465 @@ -1531,8 +1558,11 @@ static void uvesafb_init_info(struct fb_info *info, struct vbe_mode_ib *mode)
52466 info->flags = FBINFO_FLAG_DEFAULT |
52467 (par->ypan ? FBINFO_HWACCEL_YPAN : 0);
52468
52469 - if (!par->ypan)
52470 - info->fbops->fb_pan_display = NULL;
52471 + if (!par->ypan) {
52472 + pax_open_kernel();
52473 + *(void **)&info->fbops->fb_pan_display = NULL;
52474 + pax_close_kernel();
52475 + }
52476 }
52477
52478 static void uvesafb_init_mtrr(struct fb_info *info)
52479 @@ -1796,6 +1826,11 @@ out:
52480 if (par->vbe_modes)
52481 kfree(par->vbe_modes);
52482
52483 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
52484 + if (par->pmi_code)
52485 + module_free_exec(NULL, par->pmi_code);
52486 +#endif
52487 +
52488 framebuffer_release(info);
52489 return err;
52490 }
52491 @@ -1823,6 +1858,12 @@ static int uvesafb_remove(struct platform_device *dev)
52492 kfree(par->vbe_state_orig);
52493 if (par->vbe_state_saved)
52494 kfree(par->vbe_state_saved);
52495 +
52496 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
52497 + if (par->pmi_code)
52498 + module_free_exec(NULL, par->pmi_code);
52499 +#endif
52500 +
52501 }
52502
52503 framebuffer_release(info);
52504 diff --git a/drivers/video/vesafb.c b/drivers/video/vesafb.c
52505 index bd83233..7d8a5aa 100644
52506 --- a/drivers/video/vesafb.c
52507 +++ b/drivers/video/vesafb.c
52508 @@ -9,6 +9,7 @@
52509 */
52510
52511 #include <linux/module.h>
52512 +#include <linux/moduleloader.h>
52513 #include <linux/kernel.h>
52514 #include <linux/errno.h>
52515 #include <linux/string.h>
52516 @@ -52,8 +53,8 @@ static int vram_remap; /* Set amount of memory to be used */
52517 static int vram_total; /* Set total amount of memory */
52518 static int pmi_setpal __read_mostly = 1; /* pmi for palette changes ??? */
52519 static int ypan __read_mostly; /* 0..nothing, 1..ypan, 2..ywrap */
52520 -static void (*pmi_start)(void) __read_mostly;
52521 -static void (*pmi_pal) (void) __read_mostly;
52522 +static void (*pmi_start)(void) __read_only;
52523 +static void (*pmi_pal) (void) __read_only;
52524 static int depth __read_mostly;
52525 static int vga_compat __read_mostly;
52526 /* --------------------------------------------------------------------- */
52527 @@ -234,6 +235,7 @@ static int vesafb_probe(struct platform_device *dev)
52528 unsigned int size_remap;
52529 unsigned int size_total;
52530 char *option = NULL;
52531 + void *pmi_code = NULL;
52532
52533 /* ignore error return of fb_get_options */
52534 fb_get_options("vesafb", &option);
52535 @@ -280,10 +282,6 @@ static int vesafb_probe(struct platform_device *dev)
52536 size_remap = size_total;
52537 vesafb_fix.smem_len = size_remap;
52538
52539 -#ifndef __i386__
52540 - screen_info.vesapm_seg = 0;
52541 -#endif
52542 -
52543 if (!request_mem_region(vesafb_fix.smem_start, size_total, "vesafb")) {
52544 printk(KERN_WARNING
52545 "vesafb: cannot reserve video memory at 0x%lx\n",
52546 @@ -312,9 +310,21 @@ static int vesafb_probe(struct platform_device *dev)
52547 printk(KERN_INFO "vesafb: mode is %dx%dx%d, linelength=%d, pages=%d\n",
52548 vesafb_defined.xres, vesafb_defined.yres, vesafb_defined.bits_per_pixel, vesafb_fix.line_length, screen_info.pages);
52549
52550 +#ifdef __i386__
52551 +
52552 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
52553 + pmi_code = module_alloc_exec(screen_info.vesapm_size);
52554 + if (!pmi_code)
52555 +#elif !defined(CONFIG_PAX_KERNEXEC)
52556 + if (0)
52557 +#endif
52558 +
52559 +#endif
52560 + screen_info.vesapm_seg = 0;
52561 +
52562 if (screen_info.vesapm_seg) {
52563 - printk(KERN_INFO "vesafb: protected mode interface info at %04x:%04x\n",
52564 - screen_info.vesapm_seg,screen_info.vesapm_off);
52565 + printk(KERN_INFO "vesafb: protected mode interface info at %04x:%04x %04x bytes\n",
52566 + screen_info.vesapm_seg,screen_info.vesapm_off,screen_info.vesapm_size);
52567 }
52568
52569 if (screen_info.vesapm_seg < 0xc000)
52570 @@ -322,9 +332,25 @@ static int vesafb_probe(struct platform_device *dev)
52571
52572 if (ypan || pmi_setpal) {
52573 unsigned short *pmi_base;
52574 +
52575 pmi_base = (unsigned short*)phys_to_virt(((unsigned long)screen_info.vesapm_seg << 4) + screen_info.vesapm_off);
52576 - pmi_start = (void*)((char*)pmi_base + pmi_base[1]);
52577 - pmi_pal = (void*)((char*)pmi_base + pmi_base[2]);
52578 +
52579 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
52580 + pax_open_kernel();
52581 + memcpy(pmi_code, pmi_base, screen_info.vesapm_size);
52582 +#else
52583 + pmi_code = pmi_base;
52584 +#endif
52585 +
52586 + pmi_start = (void*)((char*)pmi_code + pmi_base[1]);
52587 + pmi_pal = (void*)((char*)pmi_code + pmi_base[2]);
52588 +
52589 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
52590 + pmi_start = ktva_ktla(pmi_start);
52591 + pmi_pal = ktva_ktla(pmi_pal);
52592 + pax_close_kernel();
52593 +#endif
52594 +
52595 printk(KERN_INFO "vesafb: pmi: set display start = %p, set palette = %p\n",pmi_start,pmi_pal);
52596 if (pmi_base[3]) {
52597 printk(KERN_INFO "vesafb: pmi: ports = ");
52598 @@ -477,8 +503,11 @@ static int vesafb_probe(struct platform_device *dev)
52599 info->flags = FBINFO_FLAG_DEFAULT | FBINFO_MISC_FIRMWARE |
52600 (ypan ? FBINFO_HWACCEL_YPAN : 0);
52601
52602 - if (!ypan)
52603 - info->fbops->fb_pan_display = NULL;
52604 + if (!ypan) {
52605 + pax_open_kernel();
52606 + *(void **)&info->fbops->fb_pan_display = NULL;
52607 + pax_close_kernel();
52608 + }
52609
52610 if (fb_alloc_cmap(&info->cmap, 256, 0) < 0) {
52611 err = -ENOMEM;
52612 @@ -493,6 +522,11 @@ static int vesafb_probe(struct platform_device *dev)
52613 info->node, info->fix.id);
52614 return 0;
52615 err:
52616 +
52617 +#if defined(__i386__) && defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
52618 + module_free_exec(NULL, pmi_code);
52619 +#endif
52620 +
52621 if (info->screen_base)
52622 iounmap(info->screen_base);
52623 framebuffer_release(info);
52624 diff --git a/drivers/video/via/via_clock.h b/drivers/video/via/via_clock.h
52625 index 88714ae..16c2e11 100644
52626 --- a/drivers/video/via/via_clock.h
52627 +++ b/drivers/video/via/via_clock.h
52628 @@ -56,7 +56,7 @@ struct via_clock {
52629
52630 void (*set_engine_pll_state)(u8 state);
52631 void (*set_engine_pll)(struct via_pll_config config);
52632 -};
52633 +} __no_const;
52634
52635
52636 static inline u32 get_pll_internal_frequency(u32 ref_freq,
52637 diff --git a/drivers/xen/xenfs/xenstored.c b/drivers/xen/xenfs/xenstored.c
52638 index fef20db..d28b1ab 100644
52639 --- a/drivers/xen/xenfs/xenstored.c
52640 +++ b/drivers/xen/xenfs/xenstored.c
52641 @@ -24,7 +24,12 @@ static int xsd_release(struct inode *inode, struct file *file)
52642 static int xsd_kva_open(struct inode *inode, struct file *file)
52643 {
52644 file->private_data = (void *)kasprintf(GFP_KERNEL, "0x%p",
52645 +#ifdef CONFIG_GRKERNSEC_HIDESYM
52646 + NULL);
52647 +#else
52648 xen_store_interface);
52649 +#endif
52650 +
52651 if (!file->private_data)
52652 return -ENOMEM;
52653 return 0;
52654 diff --git a/fs/9p/vfs_addr.c b/fs/9p/vfs_addr.c
52655 index 9ff073f..05cef23 100644
52656 --- a/fs/9p/vfs_addr.c
52657 +++ b/fs/9p/vfs_addr.c
52658 @@ -187,7 +187,7 @@ static int v9fs_vfs_writepage_locked(struct page *page)
52659
52660 retval = v9fs_file_write_internal(inode,
52661 v9inode->writeback_fid,
52662 - (__force const char __user *)buffer,
52663 + (const char __force_user *)buffer,
52664 len, &offset, 0);
52665 if (retval > 0)
52666 retval = 0;
52667 diff --git a/fs/9p/vfs_inode.c b/fs/9p/vfs_inode.c
52668 index 94de6d1..8d81256 100644
52669 --- a/fs/9p/vfs_inode.c
52670 +++ b/fs/9p/vfs_inode.c
52671 @@ -1312,7 +1312,7 @@ static void *v9fs_vfs_follow_link(struct dentry *dentry, struct nameidata *nd)
52672 void
52673 v9fs_vfs_put_link(struct dentry *dentry, struct nameidata *nd, void *p)
52674 {
52675 - char *s = nd_get_link(nd);
52676 + const char *s = nd_get_link(nd);
52677
52678 p9_debug(P9_DEBUG_VFS, " %s %s\n",
52679 dentry->d_name.name, IS_ERR(s) ? "<error>" : s);
52680 diff --git a/fs/Kconfig.binfmt b/fs/Kconfig.binfmt
52681 index 370b24c..ff0be7b 100644
52682 --- a/fs/Kconfig.binfmt
52683 +++ b/fs/Kconfig.binfmt
52684 @@ -103,7 +103,7 @@ config HAVE_AOUT
52685
52686 config BINFMT_AOUT
52687 tristate "Kernel support for a.out and ECOFF binaries"
52688 - depends on HAVE_AOUT
52689 + depends on HAVE_AOUT && BROKEN
52690 ---help---
52691 A.out (Assembler.OUTput) is a set of formats for libraries and
52692 executables used in the earliest versions of UNIX. Linux used
52693 diff --git a/fs/afs/inode.c b/fs/afs/inode.c
52694 index 789bc25..fafaeea 100644
52695 --- a/fs/afs/inode.c
52696 +++ b/fs/afs/inode.c
52697 @@ -141,7 +141,7 @@ struct inode *afs_iget_autocell(struct inode *dir, const char *dev_name,
52698 struct afs_vnode *vnode;
52699 struct super_block *sb;
52700 struct inode *inode;
52701 - static atomic_t afs_autocell_ino;
52702 + static atomic_unchecked_t afs_autocell_ino;
52703
52704 _enter("{%x:%u},%*.*s,",
52705 AFS_FS_I(dir)->fid.vid, AFS_FS_I(dir)->fid.vnode,
52706 @@ -154,7 +154,7 @@ struct inode *afs_iget_autocell(struct inode *dir, const char *dev_name,
52707 data.fid.unique = 0;
52708 data.fid.vnode = 0;
52709
52710 - inode = iget5_locked(sb, atomic_inc_return(&afs_autocell_ino),
52711 + inode = iget5_locked(sb, atomic_inc_return_unchecked(&afs_autocell_ino),
52712 afs_iget5_autocell_test, afs_iget5_set,
52713 &data);
52714 if (!inode) {
52715 diff --git a/fs/aio.c b/fs/aio.c
52716 index 6efb7f6..37da952 100644
52717 --- a/fs/aio.c
52718 +++ b/fs/aio.c
52719 @@ -338,7 +338,7 @@ static int aio_setup_ring(struct kioctx *ctx)
52720 size += sizeof(struct io_event) * nr_events;
52721
52722 nr_pages = PFN_UP(size);
52723 - if (nr_pages < 0)
52724 + if (nr_pages <= 0)
52725 return -EINVAL;
52726
52727 file = aio_private_file(ctx, nr_pages);
52728 diff --git a/fs/attr.c b/fs/attr.c
52729 index 1449adb..a2038c2 100644
52730 --- a/fs/attr.c
52731 +++ b/fs/attr.c
52732 @@ -102,6 +102,7 @@ int inode_newsize_ok(const struct inode *inode, loff_t offset)
52733 unsigned long limit;
52734
52735 limit = rlimit(RLIMIT_FSIZE);
52736 + gr_learn_resource(current, RLIMIT_FSIZE, (unsigned long)offset, 1);
52737 if (limit != RLIM_INFINITY && offset > limit)
52738 goto out_sig;
52739 if (offset > inode->i_sb->s_maxbytes)
52740 diff --git a/fs/autofs4/waitq.c b/fs/autofs4/waitq.c
52741 index 689e40d..515cac5 100644
52742 --- a/fs/autofs4/waitq.c
52743 +++ b/fs/autofs4/waitq.c
52744 @@ -59,7 +59,7 @@ static int autofs4_write(struct autofs_sb_info *sbi,
52745 {
52746 unsigned long sigpipe, flags;
52747 mm_segment_t fs;
52748 - const char *data = (const char *)addr;
52749 + const char __user *data = (const char __force_user *)addr;
52750 ssize_t wr = 0;
52751
52752 sigpipe = sigismember(&current->pending.signal, SIGPIPE);
52753 @@ -340,6 +340,10 @@ static int validate_request(struct autofs_wait_queue **wait,
52754 return 1;
52755 }
52756
52757 +#ifdef CONFIG_GRKERNSEC_HIDESYM
52758 +static atomic_unchecked_t autofs_dummy_name_id = ATOMIC_INIT(0);
52759 +#endif
52760 +
52761 int autofs4_wait(struct autofs_sb_info *sbi, struct dentry *dentry,
52762 enum autofs_notify notify)
52763 {
52764 @@ -373,7 +377,12 @@ int autofs4_wait(struct autofs_sb_info *sbi, struct dentry *dentry,
52765
52766 /* If this is a direct mount request create a dummy name */
52767 if (IS_ROOT(dentry) && autofs_type_trigger(sbi->type))
52768 +#ifdef CONFIG_GRKERNSEC_HIDESYM
52769 + /* this name does get written to userland via autofs4_write() */
52770 + qstr.len = sprintf(name, "%08x", atomic_inc_return_unchecked(&autofs_dummy_name_id));
52771 +#else
52772 qstr.len = sprintf(name, "%p", dentry);
52773 +#endif
52774 else {
52775 qstr.len = autofs4_getpath(sbi, dentry, &name);
52776 if (!qstr.len) {
52777 diff --git a/fs/befs/endian.h b/fs/befs/endian.h
52778 index 2722387..56059b5 100644
52779 --- a/fs/befs/endian.h
52780 +++ b/fs/befs/endian.h
52781 @@ -11,7 +11,7 @@
52782
52783 #include <asm/byteorder.h>
52784
52785 -static inline u64
52786 +static inline u64 __intentional_overflow(-1)
52787 fs64_to_cpu(const struct super_block *sb, fs64 n)
52788 {
52789 if (BEFS_SB(sb)->byte_order == BEFS_BYTESEX_LE)
52790 @@ -29,7 +29,7 @@ cpu_to_fs64(const struct super_block *sb, u64 n)
52791 return (__force fs64)cpu_to_be64(n);
52792 }
52793
52794 -static inline u32
52795 +static inline u32 __intentional_overflow(-1)
52796 fs32_to_cpu(const struct super_block *sb, fs32 n)
52797 {
52798 if (BEFS_SB(sb)->byte_order == BEFS_BYTESEX_LE)
52799 @@ -47,7 +47,7 @@ cpu_to_fs32(const struct super_block *sb, u32 n)
52800 return (__force fs32)cpu_to_be32(n);
52801 }
52802
52803 -static inline u16
52804 +static inline u16 __intentional_overflow(-1)
52805 fs16_to_cpu(const struct super_block *sb, fs16 n)
52806 {
52807 if (BEFS_SB(sb)->byte_order == BEFS_BYTESEX_LE)
52808 diff --git a/fs/befs/linuxvfs.c b/fs/befs/linuxvfs.c
52809 index e9c75e2..1baece1 100644
52810 --- a/fs/befs/linuxvfs.c
52811 +++ b/fs/befs/linuxvfs.c
52812 @@ -514,7 +514,7 @@ static void befs_put_link(struct dentry *dentry, struct nameidata *nd, void *p)
52813 {
52814 befs_inode_info *befs_ino = BEFS_I(dentry->d_inode);
52815 if (befs_ino->i_flags & BEFS_LONG_SYMLINK) {
52816 - char *link = nd_get_link(nd);
52817 + const char *link = nd_get_link(nd);
52818 if (!IS_ERR(link))
52819 kfree(link);
52820 }
52821 diff --git a/fs/binfmt_aout.c b/fs/binfmt_aout.c
52822 index 89dec7f..361b0d75 100644
52823 --- a/fs/binfmt_aout.c
52824 +++ b/fs/binfmt_aout.c
52825 @@ -16,6 +16,7 @@
52826 #include <linux/string.h>
52827 #include <linux/fs.h>
52828 #include <linux/file.h>
52829 +#include <linux/security.h>
52830 #include <linux/stat.h>
52831 #include <linux/fcntl.h>
52832 #include <linux/ptrace.h>
52833 @@ -59,6 +60,8 @@ static int aout_core_dump(struct coredump_params *cprm)
52834 #endif
52835 # define START_STACK(u) ((void __user *)u.start_stack)
52836
52837 + memset(&dump, 0, sizeof(dump));
52838 +
52839 fs = get_fs();
52840 set_fs(KERNEL_DS);
52841 has_dumped = 1;
52842 @@ -69,10 +72,12 @@ static int aout_core_dump(struct coredump_params *cprm)
52843
52844 /* If the size of the dump file exceeds the rlimit, then see what would happen
52845 if we wrote the stack, but not the data area. */
52846 + gr_learn_resource(current, RLIMIT_CORE, (dump.u_dsize + dump.u_ssize+1) * PAGE_SIZE, 1);
52847 if ((dump.u_dsize + dump.u_ssize+1) * PAGE_SIZE > cprm->limit)
52848 dump.u_dsize = 0;
52849
52850 /* Make sure we have enough room to write the stack and data areas. */
52851 + gr_learn_resource(current, RLIMIT_CORE, (dump.u_ssize + 1) * PAGE_SIZE, 1);
52852 if ((dump.u_ssize + 1) * PAGE_SIZE > cprm->limit)
52853 dump.u_ssize = 0;
52854
52855 @@ -233,6 +238,8 @@ static int load_aout_binary(struct linux_binprm * bprm)
52856 rlim = rlimit(RLIMIT_DATA);
52857 if (rlim >= RLIM_INFINITY)
52858 rlim = ~0;
52859 +
52860 + gr_learn_resource(current, RLIMIT_DATA, ex.a_data + ex.a_bss, 1);
52861 if (ex.a_data + ex.a_bss > rlim)
52862 return -ENOMEM;
52863
52864 @@ -265,6 +272,27 @@ static int load_aout_binary(struct linux_binprm * bprm)
52865
52866 install_exec_creds(bprm);
52867
52868 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
52869 + current->mm->pax_flags = 0UL;
52870 +#endif
52871 +
52872 +#ifdef CONFIG_PAX_PAGEEXEC
52873 + if (!(N_FLAGS(ex) & F_PAX_PAGEEXEC)) {
52874 + current->mm->pax_flags |= MF_PAX_PAGEEXEC;
52875 +
52876 +#ifdef CONFIG_PAX_EMUTRAMP
52877 + if (N_FLAGS(ex) & F_PAX_EMUTRAMP)
52878 + current->mm->pax_flags |= MF_PAX_EMUTRAMP;
52879 +#endif
52880 +
52881 +#ifdef CONFIG_PAX_MPROTECT
52882 + if (!(N_FLAGS(ex) & F_PAX_MPROTECT))
52883 + current->mm->pax_flags |= MF_PAX_MPROTECT;
52884 +#endif
52885 +
52886 + }
52887 +#endif
52888 +
52889 if (N_MAGIC(ex) == OMAGIC) {
52890 unsigned long text_addr, map_size;
52891 loff_t pos;
52892 @@ -322,7 +350,7 @@ static int load_aout_binary(struct linux_binprm * bprm)
52893 }
52894
52895 error = vm_mmap(bprm->file, N_DATADDR(ex), ex.a_data,
52896 - PROT_READ | PROT_WRITE | PROT_EXEC,
52897 + PROT_READ | PROT_WRITE,
52898 MAP_FIXED | MAP_PRIVATE | MAP_DENYWRITE | MAP_EXECUTABLE,
52899 fd_offset + ex.a_text);
52900 if (error != N_DATADDR(ex)) {
52901 diff --git a/fs/binfmt_elf.c b/fs/binfmt_elf.c
52902 index 4c94a79..f428019 100644
52903 --- a/fs/binfmt_elf.c
52904 +++ b/fs/binfmt_elf.c
52905 @@ -34,6 +34,7 @@
52906 #include <linux/utsname.h>
52907 #include <linux/coredump.h>
52908 #include <linux/sched.h>
52909 +#include <linux/xattr.h>
52910 #include <asm/uaccess.h>
52911 #include <asm/param.h>
52912 #include <asm/page.h>
52913 @@ -60,6 +61,14 @@ static int elf_core_dump(struct coredump_params *cprm);
52914 #define elf_core_dump NULL
52915 #endif
52916
52917 +#ifdef CONFIG_PAX_MPROTECT
52918 +static void elf_handle_mprotect(struct vm_area_struct *vma, unsigned long newflags);
52919 +#endif
52920 +
52921 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
52922 +static void elf_handle_mmap(struct file *file);
52923 +#endif
52924 +
52925 #if ELF_EXEC_PAGESIZE > PAGE_SIZE
52926 #define ELF_MIN_ALIGN ELF_EXEC_PAGESIZE
52927 #else
52928 @@ -79,6 +88,15 @@ static struct linux_binfmt elf_format = {
52929 .load_binary = load_elf_binary,
52930 .load_shlib = load_elf_library,
52931 .core_dump = elf_core_dump,
52932 +
52933 +#ifdef CONFIG_PAX_MPROTECT
52934 + .handle_mprotect= elf_handle_mprotect,
52935 +#endif
52936 +
52937 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
52938 + .handle_mmap = elf_handle_mmap,
52939 +#endif
52940 +
52941 .min_coredump = ELF_EXEC_PAGESIZE,
52942 };
52943
52944 @@ -86,6 +104,8 @@ static struct linux_binfmt elf_format = {
52945
52946 static int set_brk(unsigned long start, unsigned long end)
52947 {
52948 + unsigned long e = end;
52949 +
52950 start = ELF_PAGEALIGN(start);
52951 end = ELF_PAGEALIGN(end);
52952 if (end > start) {
52953 @@ -94,7 +114,7 @@ static int set_brk(unsigned long start, unsigned long end)
52954 if (BAD_ADDR(addr))
52955 return addr;
52956 }
52957 - current->mm->start_brk = current->mm->brk = end;
52958 + current->mm->start_brk = current->mm->brk = e;
52959 return 0;
52960 }
52961
52962 @@ -155,12 +175,13 @@ create_elf_tables(struct linux_binprm *bprm, struct elfhdr *exec,
52963 elf_addr_t __user *u_rand_bytes;
52964 const char *k_platform = ELF_PLATFORM;
52965 const char *k_base_platform = ELF_BASE_PLATFORM;
52966 - unsigned char k_rand_bytes[16];
52967 + u32 k_rand_bytes[4];
52968 int items;
52969 elf_addr_t *elf_info;
52970 int ei_index = 0;
52971 const struct cred *cred = current_cred();
52972 struct vm_area_struct *vma;
52973 + unsigned long saved_auxv[AT_VECTOR_SIZE];
52974
52975 /*
52976 * In some cases (e.g. Hyper-Threading), we want to avoid L1
52977 @@ -202,8 +223,12 @@ create_elf_tables(struct linux_binprm *bprm, struct elfhdr *exec,
52978 * Generate 16 random bytes for userspace PRNG seeding.
52979 */
52980 get_random_bytes(k_rand_bytes, sizeof(k_rand_bytes));
52981 - u_rand_bytes = (elf_addr_t __user *)
52982 - STACK_ALLOC(p, sizeof(k_rand_bytes));
52983 + prandom_seed(k_rand_bytes[0] ^ prandom_u32());
52984 + prandom_seed(k_rand_bytes[1] ^ prandom_u32());
52985 + prandom_seed(k_rand_bytes[2] ^ prandom_u32());
52986 + prandom_seed(k_rand_bytes[3] ^ prandom_u32());
52987 + p = STACK_ROUND(p, sizeof(k_rand_bytes));
52988 + u_rand_bytes = (elf_addr_t __user *) p;
52989 if (__copy_to_user(u_rand_bytes, k_rand_bytes, sizeof(k_rand_bytes)))
52990 return -EFAULT;
52991
52992 @@ -318,9 +343,11 @@ create_elf_tables(struct linux_binprm *bprm, struct elfhdr *exec,
52993 return -EFAULT;
52994 current->mm->env_end = p;
52995
52996 + memcpy(saved_auxv, elf_info, ei_index * sizeof(elf_addr_t));
52997 +
52998 /* Put the elf_info on the stack in the right place. */
52999 sp = (elf_addr_t __user *)envp + 1;
53000 - if (copy_to_user(sp, elf_info, ei_index * sizeof(elf_addr_t)))
53001 + if (copy_to_user(sp, saved_auxv, ei_index * sizeof(elf_addr_t)))
53002 return -EFAULT;
53003 return 0;
53004 }
53005 @@ -388,15 +415,14 @@ static unsigned long total_mapping_size(struct elf_phdr *cmds, int nr)
53006 an ELF header */
53007
53008 static unsigned long load_elf_interp(struct elfhdr *interp_elf_ex,
53009 - struct file *interpreter, unsigned long *interp_map_addr,
53010 - unsigned long no_base)
53011 + struct file *interpreter, unsigned long no_base)
53012 {
53013 struct elf_phdr *elf_phdata;
53014 struct elf_phdr *eppnt;
53015 - unsigned long load_addr = 0;
53016 + unsigned long load_addr = 0, pax_task_size = TASK_SIZE;
53017 int load_addr_set = 0;
53018 unsigned long last_bss = 0, elf_bss = 0;
53019 - unsigned long error = ~0UL;
53020 + unsigned long error = -EINVAL;
53021 unsigned long total_size;
53022 int retval, i, size;
53023
53024 @@ -442,6 +468,11 @@ static unsigned long load_elf_interp(struct elfhdr *interp_elf_ex,
53025 goto out_close;
53026 }
53027
53028 +#ifdef CONFIG_PAX_SEGMEXEC
53029 + if (current->mm->pax_flags & MF_PAX_SEGMEXEC)
53030 + pax_task_size = SEGMEXEC_TASK_SIZE;
53031 +#endif
53032 +
53033 eppnt = elf_phdata;
53034 for (i = 0; i < interp_elf_ex->e_phnum; i++, eppnt++) {
53035 if (eppnt->p_type == PT_LOAD) {
53036 @@ -465,8 +496,6 @@ static unsigned long load_elf_interp(struct elfhdr *interp_elf_ex,
53037 map_addr = elf_map(interpreter, load_addr + vaddr,
53038 eppnt, elf_prot, elf_type, total_size);
53039 total_size = 0;
53040 - if (!*interp_map_addr)
53041 - *interp_map_addr = map_addr;
53042 error = map_addr;
53043 if (BAD_ADDR(map_addr))
53044 goto out_close;
53045 @@ -485,8 +514,8 @@ static unsigned long load_elf_interp(struct elfhdr *interp_elf_ex,
53046 k = load_addr + eppnt->p_vaddr;
53047 if (BAD_ADDR(k) ||
53048 eppnt->p_filesz > eppnt->p_memsz ||
53049 - eppnt->p_memsz > TASK_SIZE ||
53050 - TASK_SIZE - eppnt->p_memsz < k) {
53051 + eppnt->p_memsz > pax_task_size ||
53052 + pax_task_size - eppnt->p_memsz < k) {
53053 error = -ENOMEM;
53054 goto out_close;
53055 }
53056 @@ -525,9 +554,11 @@ static unsigned long load_elf_interp(struct elfhdr *interp_elf_ex,
53057 elf_bss = ELF_PAGESTART(elf_bss + ELF_MIN_ALIGN - 1);
53058
53059 /* Map the last of the bss segment */
53060 - error = vm_brk(elf_bss, last_bss - elf_bss);
53061 - if (BAD_ADDR(error))
53062 - goto out_close;
53063 + if (last_bss > elf_bss) {
53064 + error = vm_brk(elf_bss, last_bss - elf_bss);
53065 + if (BAD_ADDR(error))
53066 + goto out_close;
53067 + }
53068 }
53069
53070 error = load_addr;
53071 @@ -538,6 +569,315 @@ out:
53072 return error;
53073 }
53074
53075 +#ifdef CONFIG_PAX_PT_PAX_FLAGS
53076 +#ifdef CONFIG_PAX_SOFTMODE
53077 +static unsigned long pax_parse_pt_pax_softmode(const struct elf_phdr * const elf_phdata)
53078 +{
53079 + unsigned long pax_flags = 0UL;
53080 +
53081 +#ifdef CONFIG_PAX_PAGEEXEC
53082 + if (elf_phdata->p_flags & PF_PAGEEXEC)
53083 + pax_flags |= MF_PAX_PAGEEXEC;
53084 +#endif
53085 +
53086 +#ifdef CONFIG_PAX_SEGMEXEC
53087 + if (elf_phdata->p_flags & PF_SEGMEXEC)
53088 + pax_flags |= MF_PAX_SEGMEXEC;
53089 +#endif
53090 +
53091 +#ifdef CONFIG_PAX_EMUTRAMP
53092 + if ((elf_phdata->p_flags & PF_EMUTRAMP) && (pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)))
53093 + pax_flags |= MF_PAX_EMUTRAMP;
53094 +#endif
53095 +
53096 +#ifdef CONFIG_PAX_MPROTECT
53097 + if (elf_phdata->p_flags & PF_MPROTECT)
53098 + pax_flags |= MF_PAX_MPROTECT;
53099 +#endif
53100 +
53101 +#if defined(CONFIG_PAX_RANDMMAP) || defined(CONFIG_PAX_RANDUSTACK)
53102 + if (randomize_va_space && (elf_phdata->p_flags & PF_RANDMMAP))
53103 + pax_flags |= MF_PAX_RANDMMAP;
53104 +#endif
53105 +
53106 + return pax_flags;
53107 +}
53108 +#endif
53109 +
53110 +static unsigned long pax_parse_pt_pax_hardmode(const struct elf_phdr * const elf_phdata)
53111 +{
53112 + unsigned long pax_flags = 0UL;
53113 +
53114 +#ifdef CONFIG_PAX_PAGEEXEC
53115 + if (!(elf_phdata->p_flags & PF_NOPAGEEXEC))
53116 + pax_flags |= MF_PAX_PAGEEXEC;
53117 +#endif
53118 +
53119 +#ifdef CONFIG_PAX_SEGMEXEC
53120 + if (!(elf_phdata->p_flags & PF_NOSEGMEXEC))
53121 + pax_flags |= MF_PAX_SEGMEXEC;
53122 +#endif
53123 +
53124 +#ifdef CONFIG_PAX_EMUTRAMP
53125 + if (!(elf_phdata->p_flags & PF_NOEMUTRAMP))
53126 + pax_flags |= MF_PAX_EMUTRAMP;
53127 +#endif
53128 +
53129 +#ifdef CONFIG_PAX_MPROTECT
53130 + if (!(elf_phdata->p_flags & PF_NOMPROTECT))
53131 + pax_flags |= MF_PAX_MPROTECT;
53132 +#endif
53133 +
53134 +#if defined(CONFIG_PAX_RANDMMAP) || defined(CONFIG_PAX_RANDUSTACK)
53135 + if (randomize_va_space && !(elf_phdata->p_flags & PF_NORANDMMAP))
53136 + pax_flags |= MF_PAX_RANDMMAP;
53137 +#endif
53138 +
53139 + return pax_flags;
53140 +}
53141 +#endif
53142 +
53143 +#ifdef CONFIG_PAX_XATTR_PAX_FLAGS
53144 +#ifdef CONFIG_PAX_SOFTMODE
53145 +static unsigned long pax_parse_xattr_pax_softmode(unsigned long pax_flags_softmode)
53146 +{
53147 + unsigned long pax_flags = 0UL;
53148 +
53149 +#ifdef CONFIG_PAX_PAGEEXEC
53150 + if (pax_flags_softmode & MF_PAX_PAGEEXEC)
53151 + pax_flags |= MF_PAX_PAGEEXEC;
53152 +#endif
53153 +
53154 +#ifdef CONFIG_PAX_SEGMEXEC
53155 + if (pax_flags_softmode & MF_PAX_SEGMEXEC)
53156 + pax_flags |= MF_PAX_SEGMEXEC;
53157 +#endif
53158 +
53159 +#ifdef CONFIG_PAX_EMUTRAMP
53160 + if ((pax_flags_softmode & MF_PAX_EMUTRAMP) && (pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)))
53161 + pax_flags |= MF_PAX_EMUTRAMP;
53162 +#endif
53163 +
53164 +#ifdef CONFIG_PAX_MPROTECT
53165 + if (pax_flags_softmode & MF_PAX_MPROTECT)
53166 + pax_flags |= MF_PAX_MPROTECT;
53167 +#endif
53168 +
53169 +#if defined(CONFIG_PAX_RANDMMAP) || defined(CONFIG_PAX_RANDUSTACK)
53170 + if (randomize_va_space && (pax_flags_softmode & MF_PAX_RANDMMAP))
53171 + pax_flags |= MF_PAX_RANDMMAP;
53172 +#endif
53173 +
53174 + return pax_flags;
53175 +}
53176 +#endif
53177 +
53178 +static unsigned long pax_parse_xattr_pax_hardmode(unsigned long pax_flags_hardmode)
53179 +{
53180 + unsigned long pax_flags = 0UL;
53181 +
53182 +#ifdef CONFIG_PAX_PAGEEXEC
53183 + if (!(pax_flags_hardmode & MF_PAX_PAGEEXEC))
53184 + pax_flags |= MF_PAX_PAGEEXEC;
53185 +#endif
53186 +
53187 +#ifdef CONFIG_PAX_SEGMEXEC
53188 + if (!(pax_flags_hardmode & MF_PAX_SEGMEXEC))
53189 + pax_flags |= MF_PAX_SEGMEXEC;
53190 +#endif
53191 +
53192 +#ifdef CONFIG_PAX_EMUTRAMP
53193 + if (!(pax_flags_hardmode & MF_PAX_EMUTRAMP))
53194 + pax_flags |= MF_PAX_EMUTRAMP;
53195 +#endif
53196 +
53197 +#ifdef CONFIG_PAX_MPROTECT
53198 + if (!(pax_flags_hardmode & MF_PAX_MPROTECT))
53199 + pax_flags |= MF_PAX_MPROTECT;
53200 +#endif
53201 +
53202 +#if defined(CONFIG_PAX_RANDMMAP) || defined(CONFIG_PAX_RANDUSTACK)
53203 + if (randomize_va_space && !(pax_flags_hardmode & MF_PAX_RANDMMAP))
53204 + pax_flags |= MF_PAX_RANDMMAP;
53205 +#endif
53206 +
53207 + return pax_flags;
53208 +}
53209 +#endif
53210 +
53211 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
53212 +static unsigned long pax_parse_ei_pax(const struct elfhdr * const elf_ex)
53213 +{
53214 + unsigned long pax_flags = 0UL;
53215 +
53216 +#ifdef CONFIG_PAX_EI_PAX
53217 +
53218 +#ifdef CONFIG_PAX_PAGEEXEC
53219 + if (!(elf_ex->e_ident[EI_PAX] & EF_PAX_PAGEEXEC))
53220 + pax_flags |= MF_PAX_PAGEEXEC;
53221 +#endif
53222 +
53223 +#ifdef CONFIG_PAX_SEGMEXEC
53224 + if (!(elf_ex->e_ident[EI_PAX] & EF_PAX_SEGMEXEC))
53225 + pax_flags |= MF_PAX_SEGMEXEC;
53226 +#endif
53227 +
53228 +#ifdef CONFIG_PAX_EMUTRAMP
53229 + if ((pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) && (elf_ex->e_ident[EI_PAX] & EF_PAX_EMUTRAMP))
53230 + pax_flags |= MF_PAX_EMUTRAMP;
53231 +#endif
53232 +
53233 +#ifdef CONFIG_PAX_MPROTECT
53234 + if ((pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) && !(elf_ex->e_ident[EI_PAX] & EF_PAX_MPROTECT))
53235 + pax_flags |= MF_PAX_MPROTECT;
53236 +#endif
53237 +
53238 +#ifdef CONFIG_PAX_ASLR
53239 + if (randomize_va_space && !(elf_ex->e_ident[EI_PAX] & EF_PAX_RANDMMAP))
53240 + pax_flags |= MF_PAX_RANDMMAP;
53241 +#endif
53242 +
53243 +#else
53244 +
53245 +#ifdef CONFIG_PAX_PAGEEXEC
53246 + pax_flags |= MF_PAX_PAGEEXEC;
53247 +#endif
53248 +
53249 +#ifdef CONFIG_PAX_SEGMEXEC
53250 + pax_flags |= MF_PAX_SEGMEXEC;
53251 +#endif
53252 +
53253 +#ifdef CONFIG_PAX_MPROTECT
53254 + pax_flags |= MF_PAX_MPROTECT;
53255 +#endif
53256 +
53257 +#ifdef CONFIG_PAX_RANDMMAP
53258 + if (randomize_va_space)
53259 + pax_flags |= MF_PAX_RANDMMAP;
53260 +#endif
53261 +
53262 +#endif
53263 +
53264 + return pax_flags;
53265 +}
53266 +
53267 +static unsigned long pax_parse_pt_pax(const struct elfhdr * const elf_ex, const struct elf_phdr * const elf_phdata)
53268 +{
53269 +
53270 +#ifdef CONFIG_PAX_PT_PAX_FLAGS
53271 + unsigned long i;
53272 +
53273 + for (i = 0UL; i < elf_ex->e_phnum; i++)
53274 + if (elf_phdata[i].p_type == PT_PAX_FLAGS) {
53275 + if (((elf_phdata[i].p_flags & PF_PAGEEXEC) && (elf_phdata[i].p_flags & PF_NOPAGEEXEC)) ||
53276 + ((elf_phdata[i].p_flags & PF_SEGMEXEC) && (elf_phdata[i].p_flags & PF_NOSEGMEXEC)) ||
53277 + ((elf_phdata[i].p_flags & PF_EMUTRAMP) && (elf_phdata[i].p_flags & PF_NOEMUTRAMP)) ||
53278 + ((elf_phdata[i].p_flags & PF_MPROTECT) && (elf_phdata[i].p_flags & PF_NOMPROTECT)) ||
53279 + ((elf_phdata[i].p_flags & PF_RANDMMAP) && (elf_phdata[i].p_flags & PF_NORANDMMAP)))
53280 + return ~0UL;
53281 +
53282 +#ifdef CONFIG_PAX_SOFTMODE
53283 + if (pax_softmode)
53284 + return pax_parse_pt_pax_softmode(&elf_phdata[i]);
53285 + else
53286 +#endif
53287 +
53288 + return pax_parse_pt_pax_hardmode(&elf_phdata[i]);
53289 + break;
53290 + }
53291 +#endif
53292 +
53293 + return ~0UL;
53294 +}
53295 +
53296 +static unsigned long pax_parse_xattr_pax(struct file * const file)
53297 +{
53298 +
53299 +#ifdef CONFIG_PAX_XATTR_PAX_FLAGS
53300 + ssize_t xattr_size, i;
53301 + unsigned char xattr_value[sizeof("pemrs") - 1];
53302 + unsigned long pax_flags_hardmode = 0UL, pax_flags_softmode = 0UL;
53303 +
53304 + xattr_size = pax_getxattr(file->f_path.dentry, xattr_value, sizeof xattr_value);
53305 + if (xattr_size <= 0 || xattr_size > sizeof xattr_value)
53306 + return ~0UL;
53307 +
53308 + for (i = 0; i < xattr_size; i++)
53309 + switch (xattr_value[i]) {
53310 + default:
53311 + return ~0UL;
53312 +
53313 +#define parse_flag(option1, option2, flag) \
53314 + case option1: \
53315 + if (pax_flags_hardmode & MF_PAX_##flag) \
53316 + return ~0UL; \
53317 + pax_flags_hardmode |= MF_PAX_##flag; \
53318 + break; \
53319 + case option2: \
53320 + if (pax_flags_softmode & MF_PAX_##flag) \
53321 + return ~0UL; \
53322 + pax_flags_softmode |= MF_PAX_##flag; \
53323 + break;
53324 +
53325 + parse_flag('p', 'P', PAGEEXEC);
53326 + parse_flag('e', 'E', EMUTRAMP);
53327 + parse_flag('m', 'M', MPROTECT);
53328 + parse_flag('r', 'R', RANDMMAP);
53329 + parse_flag('s', 'S', SEGMEXEC);
53330 +
53331 +#undef parse_flag
53332 + }
53333 +
53334 + if (pax_flags_hardmode & pax_flags_softmode)
53335 + return ~0UL;
53336 +
53337 +#ifdef CONFIG_PAX_SOFTMODE
53338 + if (pax_softmode)
53339 + return pax_parse_xattr_pax_softmode(pax_flags_softmode);
53340 + else
53341 +#endif
53342 +
53343 + return pax_parse_xattr_pax_hardmode(pax_flags_hardmode);
53344 +#else
53345 + return ~0UL;
53346 +#endif
53347 +
53348 +}
53349 +
53350 +static long pax_parse_pax_flags(const struct elfhdr * const elf_ex, const struct elf_phdr * const elf_phdata, struct file * const file)
53351 +{
53352 + unsigned long pax_flags, pt_pax_flags, xattr_pax_flags;
53353 +
53354 + pax_flags = pax_parse_ei_pax(elf_ex);
53355 + pt_pax_flags = pax_parse_pt_pax(elf_ex, elf_phdata);
53356 + xattr_pax_flags = pax_parse_xattr_pax(file);
53357 +
53358 + if (pt_pax_flags == ~0UL)
53359 + pt_pax_flags = xattr_pax_flags;
53360 + else if (xattr_pax_flags == ~0UL)
53361 + xattr_pax_flags = pt_pax_flags;
53362 + if (pt_pax_flags != xattr_pax_flags)
53363 + return -EINVAL;
53364 + if (pt_pax_flags != ~0UL)
53365 + pax_flags = pt_pax_flags;
53366 +
53367 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_PAX_SEGMEXEC)
53368 + if ((pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) == (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) {
53369 + if ((__supported_pte_mask & _PAGE_NX))
53370 + pax_flags &= ~MF_PAX_SEGMEXEC;
53371 + else
53372 + pax_flags &= ~MF_PAX_PAGEEXEC;
53373 + }
53374 +#endif
53375 +
53376 + if (0 > pax_check_flags(&pax_flags))
53377 + return -EINVAL;
53378 +
53379 + current->mm->pax_flags = pax_flags;
53380 + return 0;
53381 +}
53382 +#endif
53383 +
53384 /*
53385 * These are the functions used to load ELF style executables and shared
53386 * libraries. There is no binary dependent code anywhere else.
53387 @@ -554,6 +894,11 @@ static unsigned long randomize_stack_top(unsigned long stack_top)
53388 {
53389 unsigned int random_variable = 0;
53390
53391 +#ifdef CONFIG_PAX_RANDUSTACK
53392 + if (current->mm->pax_flags & MF_PAX_RANDMMAP)
53393 + return stack_top - current->mm->delta_stack;
53394 +#endif
53395 +
53396 if ((current->flags & PF_RANDOMIZE) &&
53397 !(current->personality & ADDR_NO_RANDOMIZE)) {
53398 random_variable = get_random_int() & STACK_RND_MASK;
53399 @@ -572,7 +917,7 @@ static int load_elf_binary(struct linux_binprm *bprm)
53400 unsigned long load_addr = 0, load_bias = 0;
53401 int load_addr_set = 0;
53402 char * elf_interpreter = NULL;
53403 - unsigned long error;
53404 + unsigned long error = 0;
53405 struct elf_phdr *elf_ppnt, *elf_phdata;
53406 unsigned long elf_bss, elf_brk;
53407 int retval, i;
53408 @@ -582,12 +927,12 @@ static int load_elf_binary(struct linux_binprm *bprm)
53409 unsigned long start_code, end_code, start_data, end_data;
53410 unsigned long reloc_func_desc __maybe_unused = 0;
53411 int executable_stack = EXSTACK_DEFAULT;
53412 - unsigned long def_flags = 0;
53413 struct pt_regs *regs = current_pt_regs();
53414 struct {
53415 struct elfhdr elf_ex;
53416 struct elfhdr interp_elf_ex;
53417 } *loc;
53418 + unsigned long pax_task_size = TASK_SIZE;
53419
53420 loc = kmalloc(sizeof(*loc), GFP_KERNEL);
53421 if (!loc) {
53422 @@ -723,11 +1068,81 @@ static int load_elf_binary(struct linux_binprm *bprm)
53423 goto out_free_dentry;
53424
53425 /* OK, This is the point of no return */
53426 - current->mm->def_flags = def_flags;
53427 +
53428 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
53429 + current->mm->pax_flags = 0UL;
53430 +#endif
53431 +
53432 +#ifdef CONFIG_PAX_DLRESOLVE
53433 + current->mm->call_dl_resolve = 0UL;
53434 +#endif
53435 +
53436 +#if defined(CONFIG_PPC32) && defined(CONFIG_PAX_EMUSIGRT)
53437 + current->mm->call_syscall = 0UL;
53438 +#endif
53439 +
53440 +#ifdef CONFIG_PAX_ASLR
53441 + current->mm->delta_mmap = 0UL;
53442 + current->mm->delta_stack = 0UL;
53443 +#endif
53444 +
53445 + current->mm->def_flags = 0;
53446 +
53447 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
53448 + if (0 > pax_parse_pax_flags(&loc->elf_ex, elf_phdata, bprm->file)) {
53449 + send_sig(SIGKILL, current, 0);
53450 + goto out_free_dentry;
53451 + }
53452 +#endif
53453 +
53454 +#ifdef CONFIG_PAX_HAVE_ACL_FLAGS
53455 + pax_set_initial_flags(bprm);
53456 +#elif defined(CONFIG_PAX_HOOK_ACL_FLAGS)
53457 + if (pax_set_initial_flags_func)
53458 + (pax_set_initial_flags_func)(bprm);
53459 +#endif
53460 +
53461 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
53462 + if ((current->mm->pax_flags & MF_PAX_PAGEEXEC) && !(__supported_pte_mask & _PAGE_NX)) {
53463 + current->mm->context.user_cs_limit = PAGE_SIZE;
53464 + current->mm->def_flags |= VM_PAGEEXEC | VM_NOHUGEPAGE;
53465 + }
53466 +#endif
53467 +
53468 +#ifdef CONFIG_PAX_SEGMEXEC
53469 + if (current->mm->pax_flags & MF_PAX_SEGMEXEC) {
53470 + current->mm->context.user_cs_base = SEGMEXEC_TASK_SIZE;
53471 + current->mm->context.user_cs_limit = TASK_SIZE-SEGMEXEC_TASK_SIZE;
53472 + pax_task_size = SEGMEXEC_TASK_SIZE;
53473 + current->mm->def_flags |= VM_NOHUGEPAGE;
53474 + }
53475 +#endif
53476 +
53477 +#if defined(CONFIG_ARCH_TRACK_EXEC_LIMIT) || defined(CONFIG_PAX_SEGMEXEC)
53478 + if (current->mm->pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) {
53479 + set_user_cs(current->mm->context.user_cs_base, current->mm->context.user_cs_limit, get_cpu());
53480 + put_cpu();
53481 + }
53482 +#endif
53483
53484 /* Do this immediately, since STACK_TOP as used in setup_arg_pages
53485 may depend on the personality. */
53486 SET_PERSONALITY(loc->elf_ex);
53487 +
53488 +#ifdef CONFIG_PAX_ASLR
53489 + if (current->mm->pax_flags & MF_PAX_RANDMMAP) {
53490 + current->mm->delta_mmap = (pax_get_random_long() & ((1UL << PAX_DELTA_MMAP_LEN)-1)) << PAGE_SHIFT;
53491 + current->mm->delta_stack = (pax_get_random_long() & ((1UL << PAX_DELTA_STACK_LEN)-1)) << PAGE_SHIFT;
53492 + }
53493 +#endif
53494 +
53495 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
53496 + if (current->mm->pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) {
53497 + executable_stack = EXSTACK_DISABLE_X;
53498 + current->personality &= ~READ_IMPLIES_EXEC;
53499 + } else
53500 +#endif
53501 +
53502 if (elf_read_implies_exec(loc->elf_ex, executable_stack))
53503 current->personality |= READ_IMPLIES_EXEC;
53504
53505 @@ -817,6 +1232,20 @@ static int load_elf_binary(struct linux_binprm *bprm)
53506 #else
53507 load_bias = ELF_PAGESTART(ELF_ET_DYN_BASE - vaddr);
53508 #endif
53509 +
53510 +#ifdef CONFIG_PAX_RANDMMAP
53511 + /* PaX: randomize base address at the default exe base if requested */
53512 + if ((current->mm->pax_flags & MF_PAX_RANDMMAP) && elf_interpreter) {
53513 +#ifdef CONFIG_SPARC64
53514 + load_bias = (pax_get_random_long() & ((1UL << PAX_DELTA_MMAP_LEN) - 1)) << (PAGE_SHIFT+1);
53515 +#else
53516 + load_bias = (pax_get_random_long() & ((1UL << PAX_DELTA_MMAP_LEN) - 1)) << PAGE_SHIFT;
53517 +#endif
53518 + load_bias = ELF_PAGESTART(PAX_ELF_ET_DYN_BASE - vaddr + load_bias);
53519 + elf_flags |= MAP_FIXED;
53520 + }
53521 +#endif
53522 +
53523 }
53524
53525 error = elf_map(bprm->file, load_bias + vaddr, elf_ppnt,
53526 @@ -849,9 +1278,9 @@ static int load_elf_binary(struct linux_binprm *bprm)
53527 * allowed task size. Note that p_filesz must always be
53528 * <= p_memsz so it is only necessary to check p_memsz.
53529 */
53530 - if (BAD_ADDR(k) || elf_ppnt->p_filesz > elf_ppnt->p_memsz ||
53531 - elf_ppnt->p_memsz > TASK_SIZE ||
53532 - TASK_SIZE - elf_ppnt->p_memsz < k) {
53533 + if (k >= pax_task_size || elf_ppnt->p_filesz > elf_ppnt->p_memsz ||
53534 + elf_ppnt->p_memsz > pax_task_size ||
53535 + pax_task_size - elf_ppnt->p_memsz < k) {
53536 /* set_brk can never work. Avoid overflows. */
53537 send_sig(SIGKILL, current, 0);
53538 retval = -EINVAL;
53539 @@ -890,17 +1319,45 @@ static int load_elf_binary(struct linux_binprm *bprm)
53540 goto out_free_dentry;
53541 }
53542 if (likely(elf_bss != elf_brk) && unlikely(padzero(elf_bss))) {
53543 - send_sig(SIGSEGV, current, 0);
53544 - retval = -EFAULT; /* Nobody gets to see this, but.. */
53545 - goto out_free_dentry;
53546 + /*
53547 + * This bss-zeroing can fail if the ELF
53548 + * file specifies odd protections. So
53549 + * we don't check the return value
53550 + */
53551 }
53552
53553 +#ifdef CONFIG_PAX_RANDMMAP
53554 + if (current->mm->pax_flags & MF_PAX_RANDMMAP) {
53555 + unsigned long start, size, flags;
53556 + vm_flags_t vm_flags;
53557 +
53558 + start = ELF_PAGEALIGN(elf_brk);
53559 + size = PAGE_SIZE + ((pax_get_random_long() & ((1UL << 22) - 1UL)) << 4);
53560 + flags = MAP_FIXED | MAP_PRIVATE;
53561 + vm_flags = VM_DONTEXPAND | VM_DONTDUMP;
53562 +
53563 + down_write(&current->mm->mmap_sem);
53564 + start = get_unmapped_area(NULL, start, PAGE_ALIGN(size), 0, flags);
53565 + retval = -ENOMEM;
53566 + if (!IS_ERR_VALUE(start) && !find_vma_intersection(current->mm, start, start + size + PAGE_SIZE)) {
53567 +// if (current->personality & ADDR_NO_RANDOMIZE)
53568 +// vm_flags |= VM_READ | VM_MAYREAD;
53569 + start = mmap_region(NULL, start, PAGE_ALIGN(size), vm_flags, 0);
53570 + retval = IS_ERR_VALUE(start) ? start : 0;
53571 + }
53572 + up_write(&current->mm->mmap_sem);
53573 + if (retval == 0)
53574 + retval = set_brk(start + size, start + size + PAGE_SIZE);
53575 + if (retval < 0) {
53576 + send_sig(SIGKILL, current, 0);
53577 + goto out_free_dentry;
53578 + }
53579 + }
53580 +#endif
53581 +
53582 if (elf_interpreter) {
53583 - unsigned long interp_map_addr = 0;
53584 -
53585 elf_entry = load_elf_interp(&loc->interp_elf_ex,
53586 interpreter,
53587 - &interp_map_addr,
53588 load_bias);
53589 if (!IS_ERR((void *)elf_entry)) {
53590 /*
53591 @@ -1122,7 +1579,7 @@ static bool always_dump_vma(struct vm_area_struct *vma)
53592 * Decide what to dump of a segment, part, all or none.
53593 */
53594 static unsigned long vma_dump_size(struct vm_area_struct *vma,
53595 - unsigned long mm_flags)
53596 + unsigned long mm_flags, long signr)
53597 {
53598 #define FILTER(type) (mm_flags & (1UL << MMF_DUMP_##type))
53599
53600 @@ -1160,7 +1617,7 @@ static unsigned long vma_dump_size(struct vm_area_struct *vma,
53601 if (vma->vm_file == NULL)
53602 return 0;
53603
53604 - if (FILTER(MAPPED_PRIVATE))
53605 + if (signr == SIGKILL || FILTER(MAPPED_PRIVATE))
53606 goto whole;
53607
53608 /*
53609 @@ -1385,9 +1842,9 @@ static void fill_auxv_note(struct memelfnote *note, struct mm_struct *mm)
53610 {
53611 elf_addr_t *auxv = (elf_addr_t *) mm->saved_auxv;
53612 int i = 0;
53613 - do
53614 + do {
53615 i += 2;
53616 - while (auxv[i - 2] != AT_NULL);
53617 + } while (auxv[i - 2] != AT_NULL);
53618 fill_note(note, "CORE", NT_AUXV, i * sizeof(elf_addr_t), auxv);
53619 }
53620
53621 @@ -1396,7 +1853,7 @@ static void fill_siginfo_note(struct memelfnote *note, user_siginfo_t *csigdata,
53622 {
53623 mm_segment_t old_fs = get_fs();
53624 set_fs(KERNEL_DS);
53625 - copy_siginfo_to_user((user_siginfo_t __user *) csigdata, siginfo);
53626 + copy_siginfo_to_user((user_siginfo_t __force_user *) csigdata, siginfo);
53627 set_fs(old_fs);
53628 fill_note(note, "CORE", NT_SIGINFO, sizeof(*csigdata), csigdata);
53629 }
53630 @@ -2023,14 +2480,14 @@ static void fill_extnum_info(struct elfhdr *elf, struct elf_shdr *shdr4extnum,
53631 }
53632
53633 static size_t elf_core_vma_data_size(struct vm_area_struct *gate_vma,
53634 - unsigned long mm_flags)
53635 + struct coredump_params *cprm)
53636 {
53637 struct vm_area_struct *vma;
53638 size_t size = 0;
53639
53640 for (vma = first_vma(current, gate_vma); vma != NULL;
53641 vma = next_vma(vma, gate_vma))
53642 - size += vma_dump_size(vma, mm_flags);
53643 + size += vma_dump_size(vma, cprm->mm_flags, cprm->siginfo->si_signo);
53644 return size;
53645 }
53646
53647 @@ -2123,7 +2580,7 @@ static int elf_core_dump(struct coredump_params *cprm)
53648
53649 dataoff = offset = roundup(offset, ELF_EXEC_PAGESIZE);
53650
53651 - offset += elf_core_vma_data_size(gate_vma, cprm->mm_flags);
53652 + offset += elf_core_vma_data_size(gate_vma, cprm);
53653 offset += elf_core_extra_data_size();
53654 e_shoff = offset;
53655
53656 @@ -2137,10 +2594,12 @@ static int elf_core_dump(struct coredump_params *cprm)
53657 offset = dataoff;
53658
53659 size += sizeof(*elf);
53660 + gr_learn_resource(current, RLIMIT_CORE, size, 1);
53661 if (size > cprm->limit || !dump_write(cprm->file, elf, sizeof(*elf)))
53662 goto end_coredump;
53663
53664 size += sizeof(*phdr4note);
53665 + gr_learn_resource(current, RLIMIT_CORE, size, 1);
53666 if (size > cprm->limit
53667 || !dump_write(cprm->file, phdr4note, sizeof(*phdr4note)))
53668 goto end_coredump;
53669 @@ -2154,7 +2613,7 @@ static int elf_core_dump(struct coredump_params *cprm)
53670 phdr.p_offset = offset;
53671 phdr.p_vaddr = vma->vm_start;
53672 phdr.p_paddr = 0;
53673 - phdr.p_filesz = vma_dump_size(vma, cprm->mm_flags);
53674 + phdr.p_filesz = vma_dump_size(vma, cprm->mm_flags, cprm->siginfo->si_signo);
53675 phdr.p_memsz = vma->vm_end - vma->vm_start;
53676 offset += phdr.p_filesz;
53677 phdr.p_flags = vma->vm_flags & VM_READ ? PF_R : 0;
53678 @@ -2165,6 +2624,7 @@ static int elf_core_dump(struct coredump_params *cprm)
53679 phdr.p_align = ELF_EXEC_PAGESIZE;
53680
53681 size += sizeof(phdr);
53682 + gr_learn_resource(current, RLIMIT_CORE, size, 1);
53683 if (size > cprm->limit
53684 || !dump_write(cprm->file, &phdr, sizeof(phdr)))
53685 goto end_coredump;
53686 @@ -2189,7 +2649,7 @@ static int elf_core_dump(struct coredump_params *cprm)
53687 unsigned long addr;
53688 unsigned long end;
53689
53690 - end = vma->vm_start + vma_dump_size(vma, cprm->mm_flags);
53691 + end = vma->vm_start + vma_dump_size(vma, cprm->mm_flags, cprm->siginfo->si_signo);
53692
53693 for (addr = vma->vm_start; addr < end; addr += PAGE_SIZE) {
53694 struct page *page;
53695 @@ -2198,6 +2658,7 @@ static int elf_core_dump(struct coredump_params *cprm)
53696 page = get_dump_page(addr);
53697 if (page) {
53698 void *kaddr = kmap(page);
53699 + gr_learn_resource(current, RLIMIT_CORE, size + PAGE_SIZE, 1);
53700 stop = ((size += PAGE_SIZE) > cprm->limit) ||
53701 !dump_write(cprm->file, kaddr,
53702 PAGE_SIZE);
53703 @@ -2215,6 +2676,7 @@ static int elf_core_dump(struct coredump_params *cprm)
53704
53705 if (e_phnum == PN_XNUM) {
53706 size += sizeof(*shdr4extnum);
53707 + gr_learn_resource(current, RLIMIT_CORE, size, 1);
53708 if (size > cprm->limit
53709 || !dump_write(cprm->file, shdr4extnum,
53710 sizeof(*shdr4extnum)))
53711 @@ -2235,6 +2697,167 @@ out:
53712
53713 #endif /* CONFIG_ELF_CORE */
53714
53715 +#ifdef CONFIG_PAX_MPROTECT
53716 +/* PaX: non-PIC ELF libraries need relocations on their executable segments
53717 + * therefore we'll grant them VM_MAYWRITE once during their life. Similarly
53718 + * we'll remove VM_MAYWRITE for good on RELRO segments.
53719 + *
53720 + * The checks favour ld-linux.so behaviour which operates on a per ELF segment
53721 + * basis because we want to allow the common case and not the special ones.
53722 + */
53723 +static void elf_handle_mprotect(struct vm_area_struct *vma, unsigned long newflags)
53724 +{
53725 + struct elfhdr elf_h;
53726 + struct elf_phdr elf_p;
53727 + unsigned long i;
53728 + unsigned long oldflags;
53729 + bool is_textrel_rw, is_textrel_rx, is_relro;
53730 +
53731 + if (!(vma->vm_mm->pax_flags & MF_PAX_MPROTECT) || !vma->vm_file)
53732 + return;
53733 +
53734 + oldflags = vma->vm_flags & (VM_MAYEXEC | VM_MAYWRITE | VM_MAYREAD | VM_EXEC | VM_WRITE | VM_READ);
53735 + newflags &= VM_MAYEXEC | VM_MAYWRITE | VM_MAYREAD | VM_EXEC | VM_WRITE | VM_READ;
53736 +
53737 +#ifdef CONFIG_PAX_ELFRELOCS
53738 + /* possible TEXTREL */
53739 + is_textrel_rw = !vma->anon_vma && oldflags == (VM_MAYEXEC | VM_MAYREAD | VM_EXEC | VM_READ) && newflags == (VM_WRITE | VM_READ);
53740 + is_textrel_rx = vma->anon_vma && oldflags == (VM_MAYEXEC | VM_MAYWRITE | VM_MAYREAD | VM_WRITE | VM_READ) && newflags == (VM_EXEC | VM_READ);
53741 +#else
53742 + is_textrel_rw = false;
53743 + is_textrel_rx = false;
53744 +#endif
53745 +
53746 + /* possible RELRO */
53747 + is_relro = vma->anon_vma && oldflags == (VM_MAYWRITE | VM_MAYREAD | VM_READ) && newflags == (VM_MAYWRITE | VM_MAYREAD | VM_READ);
53748 +
53749 + if (!is_textrel_rw && !is_textrel_rx && !is_relro)
53750 + return;
53751 +
53752 + if (sizeof(elf_h) != kernel_read(vma->vm_file, 0UL, (char *)&elf_h, sizeof(elf_h)) ||
53753 + memcmp(elf_h.e_ident, ELFMAG, SELFMAG) ||
53754 +
53755 +#ifdef CONFIG_PAX_ETEXECRELOCS
53756 + ((is_textrel_rw || is_textrel_rx) && (elf_h.e_type != ET_DYN && elf_h.e_type != ET_EXEC)) ||
53757 +#else
53758 + ((is_textrel_rw || is_textrel_rx) && elf_h.e_type != ET_DYN) ||
53759 +#endif
53760 +
53761 + (is_relro && (elf_h.e_type != ET_DYN && elf_h.e_type != ET_EXEC)) ||
53762 + !elf_check_arch(&elf_h) ||
53763 + elf_h.e_phentsize != sizeof(struct elf_phdr) ||
53764 + elf_h.e_phnum > 65536UL / sizeof(struct elf_phdr))
53765 + return;
53766 +
53767 + for (i = 0UL; i < elf_h.e_phnum; i++) {
53768 + if (sizeof(elf_p) != kernel_read(vma->vm_file, elf_h.e_phoff + i*sizeof(elf_p), (char *)&elf_p, sizeof(elf_p)))
53769 + return;
53770 + switch (elf_p.p_type) {
53771 + case PT_DYNAMIC:
53772 + if (!is_textrel_rw && !is_textrel_rx)
53773 + continue;
53774 + i = 0UL;
53775 + while ((i+1) * sizeof(elf_dyn) <= elf_p.p_filesz) {
53776 + elf_dyn dyn;
53777 +
53778 + if (sizeof(dyn) != kernel_read(vma->vm_file, elf_p.p_offset + i*sizeof(dyn), (char *)&dyn, sizeof(dyn)))
53779 + break;
53780 + if (dyn.d_tag == DT_NULL)
53781 + break;
53782 + if (dyn.d_tag == DT_TEXTREL || (dyn.d_tag == DT_FLAGS && (dyn.d_un.d_val & DF_TEXTREL))) {
53783 + gr_log_textrel(vma);
53784 + if (is_textrel_rw)
53785 + vma->vm_flags |= VM_MAYWRITE;
53786 + else
53787 + /* PaX: disallow write access after relocs are done, hopefully noone else needs it... */
53788 + vma->vm_flags &= ~VM_MAYWRITE;
53789 + break;
53790 + }
53791 + i++;
53792 + }
53793 + is_textrel_rw = false;
53794 + is_textrel_rx = false;
53795 + continue;
53796 +
53797 + case PT_GNU_RELRO:
53798 + if (!is_relro)
53799 + continue;
53800 + if ((elf_p.p_offset >> PAGE_SHIFT) == vma->vm_pgoff && ELF_PAGEALIGN(elf_p.p_memsz) == vma->vm_end - vma->vm_start)
53801 + vma->vm_flags &= ~VM_MAYWRITE;
53802 + is_relro = false;
53803 + continue;
53804 +
53805 +#ifdef CONFIG_PAX_PT_PAX_FLAGS
53806 + case PT_PAX_FLAGS: {
53807 + const char *msg_mprotect = "", *msg_emutramp = "";
53808 + char *buffer_lib, *buffer_exe;
53809 +
53810 + if (elf_p.p_flags & PF_NOMPROTECT)
53811 + msg_mprotect = "MPROTECT disabled";
53812 +
53813 +#ifdef CONFIG_PAX_EMUTRAMP
53814 + if (!(vma->vm_mm->pax_flags & MF_PAX_EMUTRAMP) && !(elf_p.p_flags & PF_NOEMUTRAMP))
53815 + msg_emutramp = "EMUTRAMP enabled";
53816 +#endif
53817 +
53818 + if (!msg_mprotect[0] && !msg_emutramp[0])
53819 + continue;
53820 +
53821 + if (!printk_ratelimit())
53822 + continue;
53823 +
53824 + buffer_lib = (char *)__get_free_page(GFP_KERNEL);
53825 + buffer_exe = (char *)__get_free_page(GFP_KERNEL);
53826 + if (buffer_lib && buffer_exe) {
53827 + char *path_lib, *path_exe;
53828 +
53829 + path_lib = pax_get_path(&vma->vm_file->f_path, buffer_lib, PAGE_SIZE);
53830 + path_exe = pax_get_path(&vma->vm_mm->exe_file->f_path, buffer_exe, PAGE_SIZE);
53831 +
53832 + pr_info("PAX: %s wants %s%s%s on %s\n", path_lib, msg_mprotect,
53833 + (msg_mprotect[0] && msg_emutramp[0] ? " and " : ""), msg_emutramp, path_exe);
53834 +
53835 + }
53836 + free_page((unsigned long)buffer_exe);
53837 + free_page((unsigned long)buffer_lib);
53838 + continue;
53839 + }
53840 +#endif
53841 +
53842 + }
53843 + }
53844 +}
53845 +#endif
53846 +
53847 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
53848 +
53849 +extern int grsec_enable_log_rwxmaps;
53850 +
53851 +static void elf_handle_mmap(struct file *file)
53852 +{
53853 + struct elfhdr elf_h;
53854 + struct elf_phdr elf_p;
53855 + unsigned long i;
53856 +
53857 + if (!grsec_enable_log_rwxmaps)
53858 + return;
53859 +
53860 + if (sizeof(elf_h) != kernel_read(file, 0UL, (char *)&elf_h, sizeof(elf_h)) ||
53861 + memcmp(elf_h.e_ident, ELFMAG, SELFMAG) ||
53862 + (elf_h.e_type != ET_DYN && elf_h.e_type != ET_EXEC) || !elf_check_arch(&elf_h) ||
53863 + elf_h.e_phentsize != sizeof(struct elf_phdr) ||
53864 + elf_h.e_phnum > 65536UL / sizeof(struct elf_phdr))
53865 + return;
53866 +
53867 + for (i = 0UL; i < elf_h.e_phnum; i++) {
53868 + if (sizeof(elf_p) != kernel_read(file, elf_h.e_phoff + i*sizeof(elf_p), (char *)&elf_p, sizeof(elf_p)))
53869 + return;
53870 + if (elf_p.p_type == PT_GNU_STACK && (elf_p.p_flags & PF_X))
53871 + gr_log_ptgnustack(file);
53872 + }
53873 +}
53874 +#endif
53875 +
53876 static int __init init_elf_binfmt(void)
53877 {
53878 register_binfmt(&elf_format);
53879 diff --git a/fs/binfmt_flat.c b/fs/binfmt_flat.c
53880 index d50bbe5..af3b649 100644
53881 --- a/fs/binfmt_flat.c
53882 +++ b/fs/binfmt_flat.c
53883 @@ -566,7 +566,9 @@ static int load_flat_file(struct linux_binprm * bprm,
53884 realdatastart = (unsigned long) -ENOMEM;
53885 printk("Unable to allocate RAM for process data, errno %d\n",
53886 (int)-realdatastart);
53887 + down_write(&current->mm->mmap_sem);
53888 vm_munmap(textpos, text_len);
53889 + up_write(&current->mm->mmap_sem);
53890 ret = realdatastart;
53891 goto err;
53892 }
53893 @@ -590,8 +592,10 @@ static int load_flat_file(struct linux_binprm * bprm,
53894 }
53895 if (IS_ERR_VALUE(result)) {
53896 printk("Unable to read data+bss, errno %d\n", (int)-result);
53897 + down_write(&current->mm->mmap_sem);
53898 vm_munmap(textpos, text_len);
53899 vm_munmap(realdatastart, len);
53900 + up_write(&current->mm->mmap_sem);
53901 ret = result;
53902 goto err;
53903 }
53904 @@ -653,8 +657,10 @@ static int load_flat_file(struct linux_binprm * bprm,
53905 }
53906 if (IS_ERR_VALUE(result)) {
53907 printk("Unable to read code+data+bss, errno %d\n",(int)-result);
53908 + down_write(&current->mm->mmap_sem);
53909 vm_munmap(textpos, text_len + data_len + extra +
53910 MAX_SHARED_LIBS * sizeof(unsigned long));
53911 + up_write(&current->mm->mmap_sem);
53912 ret = result;
53913 goto err;
53914 }
53915 diff --git a/fs/bio.c b/fs/bio.c
53916 index ea5035d..a2932eb 100644
53917 --- a/fs/bio.c
53918 +++ b/fs/bio.c
53919 @@ -1106,7 +1106,7 @@ struct bio *bio_copy_user_iov(struct request_queue *q,
53920 /*
53921 * Overflow, abort
53922 */
53923 - if (end < start)
53924 + if (end < start || end - start > INT_MAX - nr_pages)
53925 return ERR_PTR(-EINVAL);
53926
53927 nr_pages += end - start;
53928 @@ -1240,7 +1240,7 @@ static struct bio *__bio_map_user_iov(struct request_queue *q,
53929 /*
53930 * Overflow, abort
53931 */
53932 - if (end < start)
53933 + if (end < start || end - start > INT_MAX - nr_pages)
53934 return ERR_PTR(-EINVAL);
53935
53936 nr_pages += end - start;
53937 @@ -1502,7 +1502,7 @@ static void bio_copy_kern_endio(struct bio *bio, int err)
53938 const int read = bio_data_dir(bio) == READ;
53939 struct bio_map_data *bmd = bio->bi_private;
53940 int i;
53941 - char *p = bmd->sgvecs[0].iov_base;
53942 + char *p = (char __force_kernel *)bmd->sgvecs[0].iov_base;
53943
53944 bio_for_each_segment_all(bvec, bio, i) {
53945 char *addr = page_address(bvec->bv_page);
53946 diff --git a/fs/block_dev.c b/fs/block_dev.c
53947 index 1e86823..8e34695 100644
53948 --- a/fs/block_dev.c
53949 +++ b/fs/block_dev.c
53950 @@ -637,7 +637,7 @@ static bool bd_may_claim(struct block_device *bdev, struct block_device *whole,
53951 else if (bdev->bd_contains == bdev)
53952 return true; /* is a whole device which isn't held */
53953
53954 - else if (whole->bd_holder == bd_may_claim)
53955 + else if (whole->bd_holder == (void *)bd_may_claim)
53956 return true; /* is a partition of a device that is being partitioned */
53957 else if (whole->bd_holder != NULL)
53958 return false; /* is a partition of a held device */
53959 diff --git a/fs/btrfs/ctree.c b/fs/btrfs/ctree.c
53960 index 61b5bcd..7eeede8 100644
53961 --- a/fs/btrfs/ctree.c
53962 +++ b/fs/btrfs/ctree.c
53963 @@ -1028,9 +1028,12 @@ static noinline int __btrfs_cow_block(struct btrfs_trans_handle *trans,
53964 free_extent_buffer(buf);
53965 add_root_to_dirty_list(root);
53966 } else {
53967 - if (root->root_key.objectid == BTRFS_TREE_RELOC_OBJECTID)
53968 - parent_start = parent->start;
53969 - else
53970 + if (root->root_key.objectid == BTRFS_TREE_RELOC_OBJECTID) {
53971 + if (parent)
53972 + parent_start = parent->start;
53973 + else
53974 + parent_start = 0;
53975 + } else
53976 parent_start = 0;
53977
53978 WARN_ON(trans->transid != btrfs_header_generation(parent));
53979 diff --git a/fs/btrfs/delayed-inode.c b/fs/btrfs/delayed-inode.c
53980 index cbd9523..5cca781 100644
53981 --- a/fs/btrfs/delayed-inode.c
53982 +++ b/fs/btrfs/delayed-inode.c
53983 @@ -459,7 +459,7 @@ static int __btrfs_add_delayed_deletion_item(struct btrfs_delayed_node *node,
53984
53985 static void finish_one_item(struct btrfs_delayed_root *delayed_root)
53986 {
53987 - int seq = atomic_inc_return(&delayed_root->items_seq);
53988 + int seq = atomic_inc_return_unchecked(&delayed_root->items_seq);
53989 if ((atomic_dec_return(&delayed_root->items) <
53990 BTRFS_DELAYED_BACKGROUND || seq % BTRFS_DELAYED_BATCH == 0) &&
53991 waitqueue_active(&delayed_root->wait))
53992 @@ -1378,7 +1378,7 @@ void btrfs_assert_delayed_root_empty(struct btrfs_root *root)
53993 static int refs_newer(struct btrfs_delayed_root *delayed_root,
53994 int seq, int count)
53995 {
53996 - int val = atomic_read(&delayed_root->items_seq);
53997 + int val = atomic_read_unchecked(&delayed_root->items_seq);
53998
53999 if (val < seq || val >= seq + count)
54000 return 1;
54001 @@ -1395,7 +1395,7 @@ void btrfs_balance_delayed_items(struct btrfs_root *root)
54002 if (atomic_read(&delayed_root->items) < BTRFS_DELAYED_BACKGROUND)
54003 return;
54004
54005 - seq = atomic_read(&delayed_root->items_seq);
54006 + seq = atomic_read_unchecked(&delayed_root->items_seq);
54007
54008 if (atomic_read(&delayed_root->items) >= BTRFS_DELAYED_WRITEBACK) {
54009 int ret;
54010 diff --git a/fs/btrfs/delayed-inode.h b/fs/btrfs/delayed-inode.h
54011 index a4b38f9..f86a509 100644
54012 --- a/fs/btrfs/delayed-inode.h
54013 +++ b/fs/btrfs/delayed-inode.h
54014 @@ -43,7 +43,7 @@ struct btrfs_delayed_root {
54015 */
54016 struct list_head prepare_list;
54017 atomic_t items; /* for delayed items */
54018 - atomic_t items_seq; /* for delayed items */
54019 + atomic_unchecked_t items_seq; /* for delayed items */
54020 int nodes; /* for delayed nodes */
54021 wait_queue_head_t wait;
54022 };
54023 @@ -87,7 +87,7 @@ static inline void btrfs_init_delayed_root(
54024 struct btrfs_delayed_root *delayed_root)
54025 {
54026 atomic_set(&delayed_root->items, 0);
54027 - atomic_set(&delayed_root->items_seq, 0);
54028 + atomic_set_unchecked(&delayed_root->items_seq, 0);
54029 delayed_root->nodes = 0;
54030 spin_lock_init(&delayed_root->lock);
54031 init_waitqueue_head(&delayed_root->wait);
54032 diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
54033 index 9d46f60..a8f09eb 100644
54034 --- a/fs/btrfs/ioctl.c
54035 +++ b/fs/btrfs/ioctl.c
54036 @@ -3464,9 +3464,12 @@ static long btrfs_ioctl_space_info(struct btrfs_root *root, void __user *arg)
54037 for (i = 0; i < num_types; i++) {
54038 struct btrfs_space_info *tmp;
54039
54040 + /* Don't copy in more than we allocated */
54041 if (!slot_count)
54042 break;
54043
54044 + slot_count--;
54045 +
54046 info = NULL;
54047 rcu_read_lock();
54048 list_for_each_entry_rcu(tmp, &root->fs_info->space_info,
54049 @@ -3488,10 +3491,7 @@ static long btrfs_ioctl_space_info(struct btrfs_root *root, void __user *arg)
54050 memcpy(dest, &space, sizeof(space));
54051 dest++;
54052 space_args.total_spaces++;
54053 - slot_count--;
54054 }
54055 - if (!slot_count)
54056 - break;
54057 }
54058 up_read(&info->groups_sem);
54059 }
54060 diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c
54061 index e913328..a34fb36 100644
54062 --- a/fs/btrfs/super.c
54063 +++ b/fs/btrfs/super.c
54064 @@ -266,7 +266,7 @@ void __btrfs_abort_transaction(struct btrfs_trans_handle *trans,
54065 function, line, errstr);
54066 return;
54067 }
54068 - ACCESS_ONCE(trans->transaction->aborted) = errno;
54069 + ACCESS_ONCE_RW(trans->transaction->aborted) = errno;
54070 /* Wake up anybody who may be waiting on this transaction */
54071 wake_up(&root->fs_info->transaction_wait);
54072 wake_up(&root->fs_info->transaction_blocked_wait);
54073 diff --git a/fs/buffer.c b/fs/buffer.c
54074 index 6024877..7bd000a 100644
54075 --- a/fs/buffer.c
54076 +++ b/fs/buffer.c
54077 @@ -3426,7 +3426,7 @@ void __init buffer_init(void)
54078 bh_cachep = kmem_cache_create("buffer_head",
54079 sizeof(struct buffer_head), 0,
54080 (SLAB_RECLAIM_ACCOUNT|SLAB_PANIC|
54081 - SLAB_MEM_SPREAD),
54082 + SLAB_MEM_SPREAD|SLAB_NO_SANITIZE),
54083 NULL);
54084
54085 /*
54086 diff --git a/fs/cachefiles/bind.c b/fs/cachefiles/bind.c
54087 index 622f469..e8d2d55 100644
54088 --- a/fs/cachefiles/bind.c
54089 +++ b/fs/cachefiles/bind.c
54090 @@ -39,13 +39,11 @@ int cachefiles_daemon_bind(struct cachefiles_cache *cache, char *args)
54091 args);
54092
54093 /* start by checking things over */
54094 - ASSERT(cache->fstop_percent >= 0 &&
54095 - cache->fstop_percent < cache->fcull_percent &&
54096 + ASSERT(cache->fstop_percent < cache->fcull_percent &&
54097 cache->fcull_percent < cache->frun_percent &&
54098 cache->frun_percent < 100);
54099
54100 - ASSERT(cache->bstop_percent >= 0 &&
54101 - cache->bstop_percent < cache->bcull_percent &&
54102 + ASSERT(cache->bstop_percent < cache->bcull_percent &&
54103 cache->bcull_percent < cache->brun_percent &&
54104 cache->brun_percent < 100);
54105
54106 diff --git a/fs/cachefiles/daemon.c b/fs/cachefiles/daemon.c
54107 index 0a1467b..6a53245 100644
54108 --- a/fs/cachefiles/daemon.c
54109 +++ b/fs/cachefiles/daemon.c
54110 @@ -196,7 +196,7 @@ static ssize_t cachefiles_daemon_read(struct file *file, char __user *_buffer,
54111 if (n > buflen)
54112 return -EMSGSIZE;
54113
54114 - if (copy_to_user(_buffer, buffer, n) != 0)
54115 + if (n > sizeof(buffer) || copy_to_user(_buffer, buffer, n) != 0)
54116 return -EFAULT;
54117
54118 return n;
54119 @@ -222,7 +222,7 @@ static ssize_t cachefiles_daemon_write(struct file *file,
54120 if (test_bit(CACHEFILES_DEAD, &cache->flags))
54121 return -EIO;
54122
54123 - if (datalen < 0 || datalen > PAGE_SIZE - 1)
54124 + if (datalen > PAGE_SIZE - 1)
54125 return -EOPNOTSUPP;
54126
54127 /* drag the command string into the kernel so we can parse it */
54128 @@ -386,7 +386,7 @@ static int cachefiles_daemon_fstop(struct cachefiles_cache *cache, char *args)
54129 if (args[0] != '%' || args[1] != '\0')
54130 return -EINVAL;
54131
54132 - if (fstop < 0 || fstop >= cache->fcull_percent)
54133 + if (fstop >= cache->fcull_percent)
54134 return cachefiles_daemon_range_error(cache, args);
54135
54136 cache->fstop_percent = fstop;
54137 @@ -458,7 +458,7 @@ static int cachefiles_daemon_bstop(struct cachefiles_cache *cache, char *args)
54138 if (args[0] != '%' || args[1] != '\0')
54139 return -EINVAL;
54140
54141 - if (bstop < 0 || bstop >= cache->bcull_percent)
54142 + if (bstop >= cache->bcull_percent)
54143 return cachefiles_daemon_range_error(cache, args);
54144
54145 cache->bstop_percent = bstop;
54146 diff --git a/fs/cachefiles/internal.h b/fs/cachefiles/internal.h
54147 index 5349473..d6c0b93 100644
54148 --- a/fs/cachefiles/internal.h
54149 +++ b/fs/cachefiles/internal.h
54150 @@ -59,7 +59,7 @@ struct cachefiles_cache {
54151 wait_queue_head_t daemon_pollwq; /* poll waitqueue for daemon */
54152 struct rb_root active_nodes; /* active nodes (can't be culled) */
54153 rwlock_t active_lock; /* lock for active_nodes */
54154 - atomic_t gravecounter; /* graveyard uniquifier */
54155 + atomic_unchecked_t gravecounter; /* graveyard uniquifier */
54156 unsigned frun_percent; /* when to stop culling (% files) */
54157 unsigned fcull_percent; /* when to start culling (% files) */
54158 unsigned fstop_percent; /* when to stop allocating (% files) */
54159 @@ -171,19 +171,19 @@ extern int cachefiles_check_in_use(struct cachefiles_cache *cache,
54160 * proc.c
54161 */
54162 #ifdef CONFIG_CACHEFILES_HISTOGRAM
54163 -extern atomic_t cachefiles_lookup_histogram[HZ];
54164 -extern atomic_t cachefiles_mkdir_histogram[HZ];
54165 -extern atomic_t cachefiles_create_histogram[HZ];
54166 +extern atomic_unchecked_t cachefiles_lookup_histogram[HZ];
54167 +extern atomic_unchecked_t cachefiles_mkdir_histogram[HZ];
54168 +extern atomic_unchecked_t cachefiles_create_histogram[HZ];
54169
54170 extern int __init cachefiles_proc_init(void);
54171 extern void cachefiles_proc_cleanup(void);
54172 static inline
54173 -void cachefiles_hist(atomic_t histogram[], unsigned long start_jif)
54174 +void cachefiles_hist(atomic_unchecked_t histogram[], unsigned long start_jif)
54175 {
54176 unsigned long jif = jiffies - start_jif;
54177 if (jif >= HZ)
54178 jif = HZ - 1;
54179 - atomic_inc(&histogram[jif]);
54180 + atomic_inc_unchecked(&histogram[jif]);
54181 }
54182
54183 #else
54184 diff --git a/fs/cachefiles/namei.c b/fs/cachefiles/namei.c
54185 index f4a08d7..5aa4599 100644
54186 --- a/fs/cachefiles/namei.c
54187 +++ b/fs/cachefiles/namei.c
54188 @@ -317,7 +317,7 @@ try_again:
54189 /* first step is to make up a grave dentry in the graveyard */
54190 sprintf(nbuffer, "%08x%08x",
54191 (uint32_t) get_seconds(),
54192 - (uint32_t) atomic_inc_return(&cache->gravecounter));
54193 + (uint32_t) atomic_inc_return_unchecked(&cache->gravecounter));
54194
54195 /* do the multiway lock magic */
54196 trap = lock_rename(cache->graveyard, dir);
54197 diff --git a/fs/cachefiles/proc.c b/fs/cachefiles/proc.c
54198 index eccd339..4c1d995 100644
54199 --- a/fs/cachefiles/proc.c
54200 +++ b/fs/cachefiles/proc.c
54201 @@ -14,9 +14,9 @@
54202 #include <linux/seq_file.h>
54203 #include "internal.h"
54204
54205 -atomic_t cachefiles_lookup_histogram[HZ];
54206 -atomic_t cachefiles_mkdir_histogram[HZ];
54207 -atomic_t cachefiles_create_histogram[HZ];
54208 +atomic_unchecked_t cachefiles_lookup_histogram[HZ];
54209 +atomic_unchecked_t cachefiles_mkdir_histogram[HZ];
54210 +atomic_unchecked_t cachefiles_create_histogram[HZ];
54211
54212 /*
54213 * display the latency histogram
54214 @@ -35,9 +35,9 @@ static int cachefiles_histogram_show(struct seq_file *m, void *v)
54215 return 0;
54216 default:
54217 index = (unsigned long) v - 3;
54218 - x = atomic_read(&cachefiles_lookup_histogram[index]);
54219 - y = atomic_read(&cachefiles_mkdir_histogram[index]);
54220 - z = atomic_read(&cachefiles_create_histogram[index]);
54221 + x = atomic_read_unchecked(&cachefiles_lookup_histogram[index]);
54222 + y = atomic_read_unchecked(&cachefiles_mkdir_histogram[index]);
54223 + z = atomic_read_unchecked(&cachefiles_create_histogram[index]);
54224 if (x == 0 && y == 0 && z == 0)
54225 return 0;
54226
54227 diff --git a/fs/cachefiles/rdwr.c b/fs/cachefiles/rdwr.c
54228 index ebaff36..7e3ea26 100644
54229 --- a/fs/cachefiles/rdwr.c
54230 +++ b/fs/cachefiles/rdwr.c
54231 @@ -950,7 +950,7 @@ int cachefiles_write_page(struct fscache_storage *op, struct page *page)
54232 old_fs = get_fs();
54233 set_fs(KERNEL_DS);
54234 ret = file->f_op->write(
54235 - file, (const void __user *) data, len, &pos);
54236 + file, (const void __force_user *) data, len, &pos);
54237 set_fs(old_fs);
54238 kunmap(page);
54239 file_end_write(file);
54240 diff --git a/fs/ceph/dir.c b/fs/ceph/dir.c
54241 index 868b61d..58835a5 100644
54242 --- a/fs/ceph/dir.c
54243 +++ b/fs/ceph/dir.c
54244 @@ -240,7 +240,7 @@ static int ceph_readdir(struct file *file, struct dir_context *ctx)
54245 struct ceph_fs_client *fsc = ceph_inode_to_client(inode);
54246 struct ceph_mds_client *mdsc = fsc->mdsc;
54247 unsigned frag = fpos_frag(ctx->pos);
54248 - int off = fpos_off(ctx->pos);
54249 + unsigned int off = fpos_off(ctx->pos);
54250 int err;
54251 u32 ftype;
54252 struct ceph_mds_reply_info_parsed *rinfo;
54253 diff --git a/fs/ceph/super.c b/fs/ceph/super.c
54254 index 6a0951e..03fac6d 100644
54255 --- a/fs/ceph/super.c
54256 +++ b/fs/ceph/super.c
54257 @@ -870,7 +870,7 @@ static int ceph_compare_super(struct super_block *sb, void *data)
54258 /*
54259 * construct our own bdi so we can control readahead, etc.
54260 */
54261 -static atomic_long_t bdi_seq = ATOMIC_LONG_INIT(0);
54262 +static atomic_long_unchecked_t bdi_seq = ATOMIC_LONG_INIT(0);
54263
54264 static int ceph_register_bdi(struct super_block *sb,
54265 struct ceph_fs_client *fsc)
54266 @@ -887,7 +887,7 @@ static int ceph_register_bdi(struct super_block *sb,
54267 default_backing_dev_info.ra_pages;
54268
54269 err = bdi_register(&fsc->backing_dev_info, NULL, "ceph-%ld",
54270 - atomic_long_inc_return(&bdi_seq));
54271 + atomic_long_inc_return_unchecked(&bdi_seq));
54272 if (!err)
54273 sb->s_bdi = &fsc->backing_dev_info;
54274 return err;
54275 diff --git a/fs/cifs/cifs_debug.c b/fs/cifs/cifs_debug.c
54276 index f3ac415..3d2420c 100644
54277 --- a/fs/cifs/cifs_debug.c
54278 +++ b/fs/cifs/cifs_debug.c
54279 @@ -286,8 +286,8 @@ static ssize_t cifs_stats_proc_write(struct file *file,
54280
54281 if (c == '1' || c == 'y' || c == 'Y' || c == '0') {
54282 #ifdef CONFIG_CIFS_STATS2
54283 - atomic_set(&totBufAllocCount, 0);
54284 - atomic_set(&totSmBufAllocCount, 0);
54285 + atomic_set_unchecked(&totBufAllocCount, 0);
54286 + atomic_set_unchecked(&totSmBufAllocCount, 0);
54287 #endif /* CONFIG_CIFS_STATS2 */
54288 spin_lock(&cifs_tcp_ses_lock);
54289 list_for_each(tmp1, &cifs_tcp_ses_list) {
54290 @@ -300,7 +300,7 @@ static ssize_t cifs_stats_proc_write(struct file *file,
54291 tcon = list_entry(tmp3,
54292 struct cifs_tcon,
54293 tcon_list);
54294 - atomic_set(&tcon->num_smbs_sent, 0);
54295 + atomic_set_unchecked(&tcon->num_smbs_sent, 0);
54296 if (server->ops->clear_stats)
54297 server->ops->clear_stats(tcon);
54298 }
54299 @@ -332,8 +332,8 @@ static int cifs_stats_proc_show(struct seq_file *m, void *v)
54300 smBufAllocCount.counter, cifs_min_small);
54301 #ifdef CONFIG_CIFS_STATS2
54302 seq_printf(m, "Total Large %d Small %d Allocations\n",
54303 - atomic_read(&totBufAllocCount),
54304 - atomic_read(&totSmBufAllocCount));
54305 + atomic_read_unchecked(&totBufAllocCount),
54306 + atomic_read_unchecked(&totSmBufAllocCount));
54307 #endif /* CONFIG_CIFS_STATS2 */
54308
54309 seq_printf(m, "Operations (MIDs): %d\n", atomic_read(&midCount));
54310 @@ -362,7 +362,7 @@ static int cifs_stats_proc_show(struct seq_file *m, void *v)
54311 if (tcon->need_reconnect)
54312 seq_puts(m, "\tDISCONNECTED ");
54313 seq_printf(m, "\nSMBs: %d",
54314 - atomic_read(&tcon->num_smbs_sent));
54315 + atomic_read_unchecked(&tcon->num_smbs_sent));
54316 if (server->ops->print_stats)
54317 server->ops->print_stats(m, tcon);
54318 }
54319 diff --git a/fs/cifs/cifsfs.c b/fs/cifs/cifsfs.c
54320 index 77fc5e1..e3d13e6 100644
54321 --- a/fs/cifs/cifsfs.c
54322 +++ b/fs/cifs/cifsfs.c
54323 @@ -1056,7 +1056,7 @@ cifs_init_request_bufs(void)
54324 */
54325 cifs_req_cachep = kmem_cache_create("cifs_request",
54326 CIFSMaxBufSize + max_hdr_size, 0,
54327 - SLAB_HWCACHE_ALIGN, NULL);
54328 + SLAB_HWCACHE_ALIGN | SLAB_USERCOPY, NULL);
54329 if (cifs_req_cachep == NULL)
54330 return -ENOMEM;
54331
54332 @@ -1083,7 +1083,7 @@ cifs_init_request_bufs(void)
54333 efficient to alloc 1 per page off the slab compared to 17K (5page)
54334 alloc of large cifs buffers even when page debugging is on */
54335 cifs_sm_req_cachep = kmem_cache_create("cifs_small_rq",
54336 - MAX_CIFS_SMALL_BUFFER_SIZE, 0, SLAB_HWCACHE_ALIGN,
54337 + MAX_CIFS_SMALL_BUFFER_SIZE, 0, SLAB_HWCACHE_ALIGN | SLAB_USERCOPY,
54338 NULL);
54339 if (cifs_sm_req_cachep == NULL) {
54340 mempool_destroy(cifs_req_poolp);
54341 @@ -1168,8 +1168,8 @@ init_cifs(void)
54342 atomic_set(&bufAllocCount, 0);
54343 atomic_set(&smBufAllocCount, 0);
54344 #ifdef CONFIG_CIFS_STATS2
54345 - atomic_set(&totBufAllocCount, 0);
54346 - atomic_set(&totSmBufAllocCount, 0);
54347 + atomic_set_unchecked(&totBufAllocCount, 0);
54348 + atomic_set_unchecked(&totSmBufAllocCount, 0);
54349 #endif /* CONFIG_CIFS_STATS2 */
54350
54351 atomic_set(&midCount, 0);
54352 diff --git a/fs/cifs/cifsglob.h b/fs/cifs/cifsglob.h
54353 index c8e03f8..75362f6 100644
54354 --- a/fs/cifs/cifsglob.h
54355 +++ b/fs/cifs/cifsglob.h
54356 @@ -758,35 +758,35 @@ struct cifs_tcon {
54357 __u16 Flags; /* optional support bits */
54358 enum statusEnum tidStatus;
54359 #ifdef CONFIG_CIFS_STATS
54360 - atomic_t num_smbs_sent;
54361 + atomic_unchecked_t num_smbs_sent;
54362 union {
54363 struct {
54364 - atomic_t num_writes;
54365 - atomic_t num_reads;
54366 - atomic_t num_flushes;
54367 - atomic_t num_oplock_brks;
54368 - atomic_t num_opens;
54369 - atomic_t num_closes;
54370 - atomic_t num_deletes;
54371 - atomic_t num_mkdirs;
54372 - atomic_t num_posixopens;
54373 - atomic_t num_posixmkdirs;
54374 - atomic_t num_rmdirs;
54375 - atomic_t num_renames;
54376 - atomic_t num_t2renames;
54377 - atomic_t num_ffirst;
54378 - atomic_t num_fnext;
54379 - atomic_t num_fclose;
54380 - atomic_t num_hardlinks;
54381 - atomic_t num_symlinks;
54382 - atomic_t num_locks;
54383 - atomic_t num_acl_get;
54384 - atomic_t num_acl_set;
54385 + atomic_unchecked_t num_writes;
54386 + atomic_unchecked_t num_reads;
54387 + atomic_unchecked_t num_flushes;
54388 + atomic_unchecked_t num_oplock_brks;
54389 + atomic_unchecked_t num_opens;
54390 + atomic_unchecked_t num_closes;
54391 + atomic_unchecked_t num_deletes;
54392 + atomic_unchecked_t num_mkdirs;
54393 + atomic_unchecked_t num_posixopens;
54394 + atomic_unchecked_t num_posixmkdirs;
54395 + atomic_unchecked_t num_rmdirs;
54396 + atomic_unchecked_t num_renames;
54397 + atomic_unchecked_t num_t2renames;
54398 + atomic_unchecked_t num_ffirst;
54399 + atomic_unchecked_t num_fnext;
54400 + atomic_unchecked_t num_fclose;
54401 + atomic_unchecked_t num_hardlinks;
54402 + atomic_unchecked_t num_symlinks;
54403 + atomic_unchecked_t num_locks;
54404 + atomic_unchecked_t num_acl_get;
54405 + atomic_unchecked_t num_acl_set;
54406 } cifs_stats;
54407 #ifdef CONFIG_CIFS_SMB2
54408 struct {
54409 - atomic_t smb2_com_sent[NUMBER_OF_SMB2_COMMANDS];
54410 - atomic_t smb2_com_failed[NUMBER_OF_SMB2_COMMANDS];
54411 + atomic_unchecked_t smb2_com_sent[NUMBER_OF_SMB2_COMMANDS];
54412 + atomic_unchecked_t smb2_com_failed[NUMBER_OF_SMB2_COMMANDS];
54413 } smb2_stats;
54414 #endif /* CONFIG_CIFS_SMB2 */
54415 } stats;
54416 @@ -1111,7 +1111,7 @@ convert_delimiter(char *path, char delim)
54417 }
54418
54419 #ifdef CONFIG_CIFS_STATS
54420 -#define cifs_stats_inc atomic_inc
54421 +#define cifs_stats_inc atomic_inc_unchecked
54422
54423 static inline void cifs_stats_bytes_written(struct cifs_tcon *tcon,
54424 unsigned int bytes)
54425 @@ -1477,8 +1477,8 @@ GLOBAL_EXTERN atomic_t tconInfoReconnectCount;
54426 /* Various Debug counters */
54427 GLOBAL_EXTERN atomic_t bufAllocCount; /* current number allocated */
54428 #ifdef CONFIG_CIFS_STATS2
54429 -GLOBAL_EXTERN atomic_t totBufAllocCount; /* total allocated over all time */
54430 -GLOBAL_EXTERN atomic_t totSmBufAllocCount;
54431 +GLOBAL_EXTERN atomic_unchecked_t totBufAllocCount; /* total allocated over all time */
54432 +GLOBAL_EXTERN atomic_unchecked_t totSmBufAllocCount;
54433 #endif
54434 GLOBAL_EXTERN atomic_t smBufAllocCount;
54435 GLOBAL_EXTERN atomic_t midCount;
54436 diff --git a/fs/cifs/link.c b/fs/cifs/link.c
54437 index 7e36ceb..109252f 100644
54438 --- a/fs/cifs/link.c
54439 +++ b/fs/cifs/link.c
54440 @@ -624,7 +624,7 @@ symlink_exit:
54441
54442 void cifs_put_link(struct dentry *direntry, struct nameidata *nd, void *cookie)
54443 {
54444 - char *p = nd_get_link(nd);
54445 + const char *p = nd_get_link(nd);
54446 if (!IS_ERR(p))
54447 kfree(p);
54448 }
54449 diff --git a/fs/cifs/misc.c b/fs/cifs/misc.c
54450 index 138a011..cf9e13a 100644
54451 --- a/fs/cifs/misc.c
54452 +++ b/fs/cifs/misc.c
54453 @@ -170,7 +170,7 @@ cifs_buf_get(void)
54454 memset(ret_buf, 0, buf_size + 3);
54455 atomic_inc(&bufAllocCount);
54456 #ifdef CONFIG_CIFS_STATS2
54457 - atomic_inc(&totBufAllocCount);
54458 + atomic_inc_unchecked(&totBufAllocCount);
54459 #endif /* CONFIG_CIFS_STATS2 */
54460 }
54461
54462 @@ -205,7 +205,7 @@ cifs_small_buf_get(void)
54463 /* memset(ret_buf, 0, sizeof(struct smb_hdr) + 27);*/
54464 atomic_inc(&smBufAllocCount);
54465 #ifdef CONFIG_CIFS_STATS2
54466 - atomic_inc(&totSmBufAllocCount);
54467 + atomic_inc_unchecked(&totSmBufAllocCount);
54468 #endif /* CONFIG_CIFS_STATS2 */
54469
54470 }
54471 diff --git a/fs/cifs/smb1ops.c b/fs/cifs/smb1ops.c
54472 index e50554b..c011413 100644
54473 --- a/fs/cifs/smb1ops.c
54474 +++ b/fs/cifs/smb1ops.c
54475 @@ -609,27 +609,27 @@ static void
54476 cifs_clear_stats(struct cifs_tcon *tcon)
54477 {
54478 #ifdef CONFIG_CIFS_STATS
54479 - atomic_set(&tcon->stats.cifs_stats.num_writes, 0);
54480 - atomic_set(&tcon->stats.cifs_stats.num_reads, 0);
54481 - atomic_set(&tcon->stats.cifs_stats.num_flushes, 0);
54482 - atomic_set(&tcon->stats.cifs_stats.num_oplock_brks, 0);
54483 - atomic_set(&tcon->stats.cifs_stats.num_opens, 0);
54484 - atomic_set(&tcon->stats.cifs_stats.num_posixopens, 0);
54485 - atomic_set(&tcon->stats.cifs_stats.num_posixmkdirs, 0);
54486 - atomic_set(&tcon->stats.cifs_stats.num_closes, 0);
54487 - atomic_set(&tcon->stats.cifs_stats.num_deletes, 0);
54488 - atomic_set(&tcon->stats.cifs_stats.num_mkdirs, 0);
54489 - atomic_set(&tcon->stats.cifs_stats.num_rmdirs, 0);
54490 - atomic_set(&tcon->stats.cifs_stats.num_renames, 0);
54491 - atomic_set(&tcon->stats.cifs_stats.num_t2renames, 0);
54492 - atomic_set(&tcon->stats.cifs_stats.num_ffirst, 0);
54493 - atomic_set(&tcon->stats.cifs_stats.num_fnext, 0);
54494 - atomic_set(&tcon->stats.cifs_stats.num_fclose, 0);
54495 - atomic_set(&tcon->stats.cifs_stats.num_hardlinks, 0);
54496 - atomic_set(&tcon->stats.cifs_stats.num_symlinks, 0);
54497 - atomic_set(&tcon->stats.cifs_stats.num_locks, 0);
54498 - atomic_set(&tcon->stats.cifs_stats.num_acl_get, 0);
54499 - atomic_set(&tcon->stats.cifs_stats.num_acl_set, 0);
54500 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_writes, 0);
54501 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_reads, 0);
54502 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_flushes, 0);
54503 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_oplock_brks, 0);
54504 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_opens, 0);
54505 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_posixopens, 0);
54506 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_posixmkdirs, 0);
54507 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_closes, 0);
54508 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_deletes, 0);
54509 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_mkdirs, 0);
54510 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_rmdirs, 0);
54511 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_renames, 0);
54512 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_t2renames, 0);
54513 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_ffirst, 0);
54514 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_fnext, 0);
54515 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_fclose, 0);
54516 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_hardlinks, 0);
54517 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_symlinks, 0);
54518 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_locks, 0);
54519 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_acl_get, 0);
54520 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_acl_set, 0);
54521 #endif
54522 }
54523
54524 @@ -638,36 +638,36 @@ cifs_print_stats(struct seq_file *m, struct cifs_tcon *tcon)
54525 {
54526 #ifdef CONFIG_CIFS_STATS
54527 seq_printf(m, " Oplocks breaks: %d",
54528 - atomic_read(&tcon->stats.cifs_stats.num_oplock_brks));
54529 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_oplock_brks));
54530 seq_printf(m, "\nReads: %d Bytes: %llu",
54531 - atomic_read(&tcon->stats.cifs_stats.num_reads),
54532 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_reads),
54533 (long long)(tcon->bytes_read));
54534 seq_printf(m, "\nWrites: %d Bytes: %llu",
54535 - atomic_read(&tcon->stats.cifs_stats.num_writes),
54536 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_writes),
54537 (long long)(tcon->bytes_written));
54538 seq_printf(m, "\nFlushes: %d",
54539 - atomic_read(&tcon->stats.cifs_stats.num_flushes));
54540 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_flushes));
54541 seq_printf(m, "\nLocks: %d HardLinks: %d Symlinks: %d",
54542 - atomic_read(&tcon->stats.cifs_stats.num_locks),
54543 - atomic_read(&tcon->stats.cifs_stats.num_hardlinks),
54544 - atomic_read(&tcon->stats.cifs_stats.num_symlinks));
54545 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_locks),
54546 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_hardlinks),
54547 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_symlinks));
54548 seq_printf(m, "\nOpens: %d Closes: %d Deletes: %d",
54549 - atomic_read(&tcon->stats.cifs_stats.num_opens),
54550 - atomic_read(&tcon->stats.cifs_stats.num_closes),
54551 - atomic_read(&tcon->stats.cifs_stats.num_deletes));
54552 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_opens),
54553 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_closes),
54554 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_deletes));
54555 seq_printf(m, "\nPosix Opens: %d Posix Mkdirs: %d",
54556 - atomic_read(&tcon->stats.cifs_stats.num_posixopens),
54557 - atomic_read(&tcon->stats.cifs_stats.num_posixmkdirs));
54558 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_posixopens),
54559 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_posixmkdirs));
54560 seq_printf(m, "\nMkdirs: %d Rmdirs: %d",
54561 - atomic_read(&tcon->stats.cifs_stats.num_mkdirs),
54562 - atomic_read(&tcon->stats.cifs_stats.num_rmdirs));
54563 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_mkdirs),
54564 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_rmdirs));
54565 seq_printf(m, "\nRenames: %d T2 Renames %d",
54566 - atomic_read(&tcon->stats.cifs_stats.num_renames),
54567 - atomic_read(&tcon->stats.cifs_stats.num_t2renames));
54568 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_renames),
54569 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_t2renames));
54570 seq_printf(m, "\nFindFirst: %d FNext %d FClose %d",
54571 - atomic_read(&tcon->stats.cifs_stats.num_ffirst),
54572 - atomic_read(&tcon->stats.cifs_stats.num_fnext),
54573 - atomic_read(&tcon->stats.cifs_stats.num_fclose));
54574 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_ffirst),
54575 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_fnext),
54576 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_fclose));
54577 #endif
54578 }
54579
54580 diff --git a/fs/cifs/smb2ops.c b/fs/cifs/smb2ops.c
54581 index 861b332..5506392 100644
54582 --- a/fs/cifs/smb2ops.c
54583 +++ b/fs/cifs/smb2ops.c
54584 @@ -282,8 +282,8 @@ smb2_clear_stats(struct cifs_tcon *tcon)
54585 #ifdef CONFIG_CIFS_STATS
54586 int i;
54587 for (i = 0; i < NUMBER_OF_SMB2_COMMANDS; i++) {
54588 - atomic_set(&tcon->stats.smb2_stats.smb2_com_sent[i], 0);
54589 - atomic_set(&tcon->stats.smb2_stats.smb2_com_failed[i], 0);
54590 + atomic_set_unchecked(&tcon->stats.smb2_stats.smb2_com_sent[i], 0);
54591 + atomic_set_unchecked(&tcon->stats.smb2_stats.smb2_com_failed[i], 0);
54592 }
54593 #endif
54594 }
54595 @@ -311,65 +311,65 @@ static void
54596 smb2_print_stats(struct seq_file *m, struct cifs_tcon *tcon)
54597 {
54598 #ifdef CONFIG_CIFS_STATS
54599 - atomic_t *sent = tcon->stats.smb2_stats.smb2_com_sent;
54600 - atomic_t *failed = tcon->stats.smb2_stats.smb2_com_failed;
54601 + atomic_unchecked_t *sent = tcon->stats.smb2_stats.smb2_com_sent;
54602 + atomic_unchecked_t *failed = tcon->stats.smb2_stats.smb2_com_failed;
54603 seq_printf(m, "\nNegotiates: %d sent %d failed",
54604 - atomic_read(&sent[SMB2_NEGOTIATE_HE]),
54605 - atomic_read(&failed[SMB2_NEGOTIATE_HE]));
54606 + atomic_read_unchecked(&sent[SMB2_NEGOTIATE_HE]),
54607 + atomic_read_unchecked(&failed[SMB2_NEGOTIATE_HE]));
54608 seq_printf(m, "\nSessionSetups: %d sent %d failed",
54609 - atomic_read(&sent[SMB2_SESSION_SETUP_HE]),
54610 - atomic_read(&failed[SMB2_SESSION_SETUP_HE]));
54611 + atomic_read_unchecked(&sent[SMB2_SESSION_SETUP_HE]),
54612 + atomic_read_unchecked(&failed[SMB2_SESSION_SETUP_HE]));
54613 seq_printf(m, "\nLogoffs: %d sent %d failed",
54614 - atomic_read(&sent[SMB2_LOGOFF_HE]),
54615 - atomic_read(&failed[SMB2_LOGOFF_HE]));
54616 + atomic_read_unchecked(&sent[SMB2_LOGOFF_HE]),
54617 + atomic_read_unchecked(&failed[SMB2_LOGOFF_HE]));
54618 seq_printf(m, "\nTreeConnects: %d sent %d failed",
54619 - atomic_read(&sent[SMB2_TREE_CONNECT_HE]),
54620 - atomic_read(&failed[SMB2_TREE_CONNECT_HE]));
54621 + atomic_read_unchecked(&sent[SMB2_TREE_CONNECT_HE]),
54622 + atomic_read_unchecked(&failed[SMB2_TREE_CONNECT_HE]));
54623 seq_printf(m, "\nTreeDisconnects: %d sent %d failed",
54624 - atomic_read(&sent[SMB2_TREE_DISCONNECT_HE]),
54625 - atomic_read(&failed[SMB2_TREE_DISCONNECT_HE]));
54626 + atomic_read_unchecked(&sent[SMB2_TREE_DISCONNECT_HE]),
54627 + atomic_read_unchecked(&failed[SMB2_TREE_DISCONNECT_HE]));
54628 seq_printf(m, "\nCreates: %d sent %d failed",
54629 - atomic_read(&sent[SMB2_CREATE_HE]),
54630 - atomic_read(&failed[SMB2_CREATE_HE]));
54631 + atomic_read_unchecked(&sent[SMB2_CREATE_HE]),
54632 + atomic_read_unchecked(&failed[SMB2_CREATE_HE]));
54633 seq_printf(m, "\nCloses: %d sent %d failed",
54634 - atomic_read(&sent[SMB2_CLOSE_HE]),
54635 - atomic_read(&failed[SMB2_CLOSE_HE]));
54636 + atomic_read_unchecked(&sent[SMB2_CLOSE_HE]),
54637 + atomic_read_unchecked(&failed[SMB2_CLOSE_HE]));
54638 seq_printf(m, "\nFlushes: %d sent %d failed",
54639 - atomic_read(&sent[SMB2_FLUSH_HE]),
54640 - atomic_read(&failed[SMB2_FLUSH_HE]));
54641 + atomic_read_unchecked(&sent[SMB2_FLUSH_HE]),
54642 + atomic_read_unchecked(&failed[SMB2_FLUSH_HE]));
54643 seq_printf(m, "\nReads: %d sent %d failed",
54644 - atomic_read(&sent[SMB2_READ_HE]),
54645 - atomic_read(&failed[SMB2_READ_HE]));
54646 + atomic_read_unchecked(&sent[SMB2_READ_HE]),
54647 + atomic_read_unchecked(&failed[SMB2_READ_HE]));
54648 seq_printf(m, "\nWrites: %d sent %d failed",
54649 - atomic_read(&sent[SMB2_WRITE_HE]),
54650 - atomic_read(&failed[SMB2_WRITE_HE]));
54651 + atomic_read_unchecked(&sent[SMB2_WRITE_HE]),
54652 + atomic_read_unchecked(&failed[SMB2_WRITE_HE]));
54653 seq_printf(m, "\nLocks: %d sent %d failed",
54654 - atomic_read(&sent[SMB2_LOCK_HE]),
54655 - atomic_read(&failed[SMB2_LOCK_HE]));
54656 + atomic_read_unchecked(&sent[SMB2_LOCK_HE]),
54657 + atomic_read_unchecked(&failed[SMB2_LOCK_HE]));
54658 seq_printf(m, "\nIOCTLs: %d sent %d failed",
54659 - atomic_read(&sent[SMB2_IOCTL_HE]),
54660 - atomic_read(&failed[SMB2_IOCTL_HE]));
54661 + atomic_read_unchecked(&sent[SMB2_IOCTL_HE]),
54662 + atomic_read_unchecked(&failed[SMB2_IOCTL_HE]));
54663 seq_printf(m, "\nCancels: %d sent %d failed",
54664 - atomic_read(&sent[SMB2_CANCEL_HE]),
54665 - atomic_read(&failed[SMB2_CANCEL_HE]));
54666 + atomic_read_unchecked(&sent[SMB2_CANCEL_HE]),
54667 + atomic_read_unchecked(&failed[SMB2_CANCEL_HE]));
54668 seq_printf(m, "\nEchos: %d sent %d failed",
54669 - atomic_read(&sent[SMB2_ECHO_HE]),
54670 - atomic_read(&failed[SMB2_ECHO_HE]));
54671 + atomic_read_unchecked(&sent[SMB2_ECHO_HE]),
54672 + atomic_read_unchecked(&failed[SMB2_ECHO_HE]));
54673 seq_printf(m, "\nQueryDirectories: %d sent %d failed",
54674 - atomic_read(&sent[SMB2_QUERY_DIRECTORY_HE]),
54675 - atomic_read(&failed[SMB2_QUERY_DIRECTORY_HE]));
54676 + atomic_read_unchecked(&sent[SMB2_QUERY_DIRECTORY_HE]),
54677 + atomic_read_unchecked(&failed[SMB2_QUERY_DIRECTORY_HE]));
54678 seq_printf(m, "\nChangeNotifies: %d sent %d failed",
54679 - atomic_read(&sent[SMB2_CHANGE_NOTIFY_HE]),
54680 - atomic_read(&failed[SMB2_CHANGE_NOTIFY_HE]));
54681 + atomic_read_unchecked(&sent[SMB2_CHANGE_NOTIFY_HE]),
54682 + atomic_read_unchecked(&failed[SMB2_CHANGE_NOTIFY_HE]));
54683 seq_printf(m, "\nQueryInfos: %d sent %d failed",
54684 - atomic_read(&sent[SMB2_QUERY_INFO_HE]),
54685 - atomic_read(&failed[SMB2_QUERY_INFO_HE]));
54686 + atomic_read_unchecked(&sent[SMB2_QUERY_INFO_HE]),
54687 + atomic_read_unchecked(&failed[SMB2_QUERY_INFO_HE]));
54688 seq_printf(m, "\nSetInfos: %d sent %d failed",
54689 - atomic_read(&sent[SMB2_SET_INFO_HE]),
54690 - atomic_read(&failed[SMB2_SET_INFO_HE]));
54691 + atomic_read_unchecked(&sent[SMB2_SET_INFO_HE]),
54692 + atomic_read_unchecked(&failed[SMB2_SET_INFO_HE]));
54693 seq_printf(m, "\nOplockBreaks: %d sent %d failed",
54694 - atomic_read(&sent[SMB2_OPLOCK_BREAK_HE]),
54695 - atomic_read(&failed[SMB2_OPLOCK_BREAK_HE]));
54696 + atomic_read_unchecked(&sent[SMB2_OPLOCK_BREAK_HE]),
54697 + atomic_read_unchecked(&failed[SMB2_OPLOCK_BREAK_HE]));
54698 #endif
54699 }
54700
54701 diff --git a/fs/cifs/smb2pdu.c b/fs/cifs/smb2pdu.c
54702 index edccb52..16bc6db 100644
54703 --- a/fs/cifs/smb2pdu.c
54704 +++ b/fs/cifs/smb2pdu.c
54705 @@ -1957,8 +1957,7 @@ SMB2_query_directory(const unsigned int xid, struct cifs_tcon *tcon,
54706 default:
54707 cifs_dbg(VFS, "info level %u isn't supported\n",
54708 srch_inf->info_level);
54709 - rc = -EINVAL;
54710 - goto qdir_exit;
54711 + return -EINVAL;
54712 }
54713
54714 req->FileIndex = cpu_to_le32(index);
54715 diff --git a/fs/coda/cache.c b/fs/coda/cache.c
54716 index 1da168c..8bc7ff6 100644
54717 --- a/fs/coda/cache.c
54718 +++ b/fs/coda/cache.c
54719 @@ -24,7 +24,7 @@
54720 #include "coda_linux.h"
54721 #include "coda_cache.h"
54722
54723 -static atomic_t permission_epoch = ATOMIC_INIT(0);
54724 +static atomic_unchecked_t permission_epoch = ATOMIC_INIT(0);
54725
54726 /* replace or extend an acl cache hit */
54727 void coda_cache_enter(struct inode *inode, int mask)
54728 @@ -32,7 +32,7 @@ void coda_cache_enter(struct inode *inode, int mask)
54729 struct coda_inode_info *cii = ITOC(inode);
54730
54731 spin_lock(&cii->c_lock);
54732 - cii->c_cached_epoch = atomic_read(&permission_epoch);
54733 + cii->c_cached_epoch = atomic_read_unchecked(&permission_epoch);
54734 if (!uid_eq(cii->c_uid, current_fsuid())) {
54735 cii->c_uid = current_fsuid();
54736 cii->c_cached_perm = mask;
54737 @@ -46,14 +46,14 @@ void coda_cache_clear_inode(struct inode *inode)
54738 {
54739 struct coda_inode_info *cii = ITOC(inode);
54740 spin_lock(&cii->c_lock);
54741 - cii->c_cached_epoch = atomic_read(&permission_epoch) - 1;
54742 + cii->c_cached_epoch = atomic_read_unchecked(&permission_epoch) - 1;
54743 spin_unlock(&cii->c_lock);
54744 }
54745
54746 /* remove all acl caches */
54747 void coda_cache_clear_all(struct super_block *sb)
54748 {
54749 - atomic_inc(&permission_epoch);
54750 + atomic_inc_unchecked(&permission_epoch);
54751 }
54752
54753
54754 @@ -66,7 +66,7 @@ int coda_cache_check(struct inode *inode, int mask)
54755 spin_lock(&cii->c_lock);
54756 hit = (mask & cii->c_cached_perm) == mask &&
54757 uid_eq(cii->c_uid, current_fsuid()) &&
54758 - cii->c_cached_epoch == atomic_read(&permission_epoch);
54759 + cii->c_cached_epoch == atomic_read_unchecked(&permission_epoch);
54760 spin_unlock(&cii->c_lock);
54761
54762 return hit;
54763 diff --git a/fs/compat.c b/fs/compat.c
54764 index 6af20de..fec3fbb 100644
54765 --- a/fs/compat.c
54766 +++ b/fs/compat.c
54767 @@ -54,7 +54,7 @@
54768 #include <asm/ioctls.h>
54769 #include "internal.h"
54770
54771 -int compat_log = 1;
54772 +int compat_log = 0;
54773
54774 int compat_printk(const char *fmt, ...)
54775 {
54776 @@ -488,7 +488,7 @@ compat_sys_io_setup(unsigned nr_reqs, u32 __user *ctx32p)
54777
54778 set_fs(KERNEL_DS);
54779 /* The __user pointer cast is valid because of the set_fs() */
54780 - ret = sys_io_setup(nr_reqs, (aio_context_t __user *) &ctx64);
54781 + ret = sys_io_setup(nr_reqs, (aio_context_t __force_user *) &ctx64);
54782 set_fs(oldfs);
54783 /* truncating is ok because it's a user address */
54784 if (!ret)
54785 @@ -546,7 +546,7 @@ ssize_t compat_rw_copy_check_uvector(int type,
54786 goto out;
54787
54788 ret = -EINVAL;
54789 - if (nr_segs > UIO_MAXIOV || nr_segs < 0)
54790 + if (nr_segs > UIO_MAXIOV)
54791 goto out;
54792 if (nr_segs > fast_segs) {
54793 ret = -ENOMEM;
54794 @@ -834,6 +834,7 @@ struct compat_old_linux_dirent {
54795 struct compat_readdir_callback {
54796 struct dir_context ctx;
54797 struct compat_old_linux_dirent __user *dirent;
54798 + struct file * file;
54799 int result;
54800 };
54801
54802 @@ -851,6 +852,10 @@ static int compat_fillonedir(void *__buf, const char *name, int namlen,
54803 buf->result = -EOVERFLOW;
54804 return -EOVERFLOW;
54805 }
54806 +
54807 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
54808 + return 0;
54809 +
54810 buf->result++;
54811 dirent = buf->dirent;
54812 if (!access_ok(VERIFY_WRITE, dirent,
54813 @@ -882,6 +887,7 @@ asmlinkage long compat_sys_old_readdir(unsigned int fd,
54814 if (!f.file)
54815 return -EBADF;
54816
54817 + buf.file = f.file;
54818 error = iterate_dir(f.file, &buf.ctx);
54819 if (buf.result)
54820 error = buf.result;
54821 @@ -901,6 +907,7 @@ struct compat_getdents_callback {
54822 struct dir_context ctx;
54823 struct compat_linux_dirent __user *current_dir;
54824 struct compat_linux_dirent __user *previous;
54825 + struct file * file;
54826 int count;
54827 int error;
54828 };
54829 @@ -922,6 +929,10 @@ static int compat_filldir(void *__buf, const char *name, int namlen,
54830 buf->error = -EOVERFLOW;
54831 return -EOVERFLOW;
54832 }
54833 +
54834 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
54835 + return 0;
54836 +
54837 dirent = buf->previous;
54838 if (dirent) {
54839 if (__put_user(offset, &dirent->d_off))
54840 @@ -967,6 +978,7 @@ asmlinkage long compat_sys_getdents(unsigned int fd,
54841 if (!f.file)
54842 return -EBADF;
54843
54844 + buf.file = f.file;
54845 error = iterate_dir(f.file, &buf.ctx);
54846 if (error >= 0)
54847 error = buf.error;
54848 @@ -987,6 +999,7 @@ struct compat_getdents_callback64 {
54849 struct dir_context ctx;
54850 struct linux_dirent64 __user *current_dir;
54851 struct linux_dirent64 __user *previous;
54852 + struct file * file;
54853 int count;
54854 int error;
54855 };
54856 @@ -1003,6 +1016,10 @@ static int compat_filldir64(void * __buf, const char * name, int namlen, loff_t
54857 buf->error = -EINVAL; /* only used if we fail.. */
54858 if (reclen > buf->count)
54859 return -EINVAL;
54860 +
54861 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
54862 + return 0;
54863 +
54864 dirent = buf->previous;
54865
54866 if (dirent) {
54867 @@ -1052,6 +1069,7 @@ asmlinkage long compat_sys_getdents64(unsigned int fd,
54868 if (!f.file)
54869 return -EBADF;
54870
54871 + buf.file = f.file;
54872 error = iterate_dir(f.file, &buf.ctx);
54873 if (error >= 0)
54874 error = buf.error;
54875 diff --git a/fs/compat_binfmt_elf.c b/fs/compat_binfmt_elf.c
54876 index a81147e..20bf2b5 100644
54877 --- a/fs/compat_binfmt_elf.c
54878 +++ b/fs/compat_binfmt_elf.c
54879 @@ -30,11 +30,13 @@
54880 #undef elf_phdr
54881 #undef elf_shdr
54882 #undef elf_note
54883 +#undef elf_dyn
54884 #undef elf_addr_t
54885 #define elfhdr elf32_hdr
54886 #define elf_phdr elf32_phdr
54887 #define elf_shdr elf32_shdr
54888 #define elf_note elf32_note
54889 +#define elf_dyn Elf32_Dyn
54890 #define elf_addr_t Elf32_Addr
54891
54892 /*
54893 diff --git a/fs/compat_ioctl.c b/fs/compat_ioctl.c
54894 index 5d19acf..9ab093b 100644
54895 --- a/fs/compat_ioctl.c
54896 +++ b/fs/compat_ioctl.c
54897 @@ -621,7 +621,7 @@ static int serial_struct_ioctl(unsigned fd, unsigned cmd,
54898 return -EFAULT;
54899 if (__get_user(udata, &ss32->iomem_base))
54900 return -EFAULT;
54901 - ss.iomem_base = compat_ptr(udata);
54902 + ss.iomem_base = (unsigned char __force_kernel *)compat_ptr(udata);
54903 if (__get_user(ss.iomem_reg_shift, &ss32->iomem_reg_shift) ||
54904 __get_user(ss.port_high, &ss32->port_high))
54905 return -EFAULT;
54906 @@ -702,8 +702,8 @@ static int do_i2c_rdwr_ioctl(unsigned int fd, unsigned int cmd,
54907 for (i = 0; i < nmsgs; i++) {
54908 if (copy_in_user(&tmsgs[i].addr, &umsgs[i].addr, 3*sizeof(u16)))
54909 return -EFAULT;
54910 - if (get_user(datap, &umsgs[i].buf) ||
54911 - put_user(compat_ptr(datap), &tmsgs[i].buf))
54912 + if (get_user(datap, (u8 __user * __user *)&umsgs[i].buf) ||
54913 + put_user(compat_ptr(datap), (u8 __user * __user *)&tmsgs[i].buf))
54914 return -EFAULT;
54915 }
54916 return sys_ioctl(fd, cmd, (unsigned long)tdata);
54917 @@ -796,7 +796,7 @@ static int compat_ioctl_preallocate(struct file *file,
54918 copy_in_user(&p->l_len, &p32->l_len, sizeof(s64)) ||
54919 copy_in_user(&p->l_sysid, &p32->l_sysid, sizeof(s32)) ||
54920 copy_in_user(&p->l_pid, &p32->l_pid, sizeof(u32)) ||
54921 - copy_in_user(&p->l_pad, &p32->l_pad, 4*sizeof(u32)))
54922 + copy_in_user(p->l_pad, &p32->l_pad, 4*sizeof(u32)))
54923 return -EFAULT;
54924
54925 return ioctl_preallocate(file, p);
54926 @@ -1616,8 +1616,8 @@ asmlinkage long compat_sys_ioctl(unsigned int fd, unsigned int cmd,
54927 static int __init init_sys32_ioctl_cmp(const void *p, const void *q)
54928 {
54929 unsigned int a, b;
54930 - a = *(unsigned int *)p;
54931 - b = *(unsigned int *)q;
54932 + a = *(const unsigned int *)p;
54933 + b = *(const unsigned int *)q;
54934 if (a > b)
54935 return 1;
54936 if (a < b)
54937 diff --git a/fs/configfs/dir.c b/fs/configfs/dir.c
54938 index 511d415..319d0e5 100644
54939 --- a/fs/configfs/dir.c
54940 +++ b/fs/configfs/dir.c
54941 @@ -1558,7 +1558,8 @@ static int configfs_readdir(struct file *file, struct dir_context *ctx)
54942 }
54943 for (p = q->next; p != &parent_sd->s_children; p = p->next) {
54944 struct configfs_dirent *next;
54945 - const char *name;
54946 + const unsigned char * name;
54947 + char d_name[sizeof(next->s_dentry->d_iname)];
54948 int len;
54949 struct inode *inode = NULL;
54950
54951 @@ -1567,7 +1568,12 @@ static int configfs_readdir(struct file *file, struct dir_context *ctx)
54952 continue;
54953
54954 name = configfs_get_name(next);
54955 - len = strlen(name);
54956 + if (next->s_dentry && name == next->s_dentry->d_iname) {
54957 + len = next->s_dentry->d_name.len;
54958 + memcpy(d_name, name, len);
54959 + name = d_name;
54960 + } else
54961 + len = strlen(name);
54962
54963 /*
54964 * We'll have a dentry and an inode for
54965 diff --git a/fs/coredump.c b/fs/coredump.c
54966 index 9bdeca1..2a9b08d 100644
54967 --- a/fs/coredump.c
54968 +++ b/fs/coredump.c
54969 @@ -438,8 +438,8 @@ static void wait_for_dump_helpers(struct file *file)
54970 struct pipe_inode_info *pipe = file->private_data;
54971
54972 pipe_lock(pipe);
54973 - pipe->readers++;
54974 - pipe->writers--;
54975 + atomic_inc(&pipe->readers);
54976 + atomic_dec(&pipe->writers);
54977 wake_up_interruptible_sync(&pipe->wait);
54978 kill_fasync(&pipe->fasync_readers, SIGIO, POLL_IN);
54979 pipe_unlock(pipe);
54980 @@ -448,11 +448,11 @@ static void wait_for_dump_helpers(struct file *file)
54981 * We actually want wait_event_freezable() but then we need
54982 * to clear TIF_SIGPENDING and improve dump_interrupted().
54983 */
54984 - wait_event_interruptible(pipe->wait, pipe->readers == 1);
54985 + wait_event_interruptible(pipe->wait, atomic_read(&pipe->readers) == 1);
54986
54987 pipe_lock(pipe);
54988 - pipe->readers--;
54989 - pipe->writers++;
54990 + atomic_dec(&pipe->readers);
54991 + atomic_inc(&pipe->writers);
54992 pipe_unlock(pipe);
54993 }
54994
54995 @@ -499,7 +499,9 @@ void do_coredump(siginfo_t *siginfo)
54996 struct files_struct *displaced;
54997 bool need_nonrelative = false;
54998 bool core_dumped = false;
54999 - static atomic_t core_dump_count = ATOMIC_INIT(0);
55000 + static atomic_unchecked_t core_dump_count = ATOMIC_INIT(0);
55001 + long signr = siginfo->si_signo;
55002 + int dumpable;
55003 struct coredump_params cprm = {
55004 .siginfo = siginfo,
55005 .regs = signal_pt_regs(),
55006 @@ -512,12 +514,17 @@ void do_coredump(siginfo_t *siginfo)
55007 .mm_flags = mm->flags,
55008 };
55009
55010 - audit_core_dumps(siginfo->si_signo);
55011 + audit_core_dumps(signr);
55012 +
55013 + dumpable = __get_dumpable(cprm.mm_flags);
55014 +
55015 + if (signr == SIGSEGV || signr == SIGBUS || signr == SIGKILL || signr == SIGILL)
55016 + gr_handle_brute_attach(dumpable);
55017
55018 binfmt = mm->binfmt;
55019 if (!binfmt || !binfmt->core_dump)
55020 goto fail;
55021 - if (!__get_dumpable(cprm.mm_flags))
55022 + if (!dumpable)
55023 goto fail;
55024
55025 cred = prepare_creds();
55026 @@ -536,7 +543,7 @@ void do_coredump(siginfo_t *siginfo)
55027 need_nonrelative = true;
55028 }
55029
55030 - retval = coredump_wait(siginfo->si_signo, &core_state);
55031 + retval = coredump_wait(signr, &core_state);
55032 if (retval < 0)
55033 goto fail_creds;
55034
55035 @@ -579,7 +586,7 @@ void do_coredump(siginfo_t *siginfo)
55036 }
55037 cprm.limit = RLIM_INFINITY;
55038
55039 - dump_count = atomic_inc_return(&core_dump_count);
55040 + dump_count = atomic_inc_return_unchecked(&core_dump_count);
55041 if (core_pipe_limit && (core_pipe_limit < dump_count)) {
55042 printk(KERN_WARNING "Pid %d(%s) over core_pipe_limit\n",
55043 task_tgid_vnr(current), current->comm);
55044 @@ -611,6 +618,8 @@ void do_coredump(siginfo_t *siginfo)
55045 } else {
55046 struct inode *inode;
55047
55048 + gr_learn_resource(current, RLIMIT_CORE, binfmt->min_coredump, 1);
55049 +
55050 if (cprm.limit < binfmt->min_coredump)
55051 goto fail_unlock;
55052
55053 @@ -669,7 +678,7 @@ close_fail:
55054 filp_close(cprm.file, NULL);
55055 fail_dropcount:
55056 if (ispipe)
55057 - atomic_dec(&core_dump_count);
55058 + atomic_dec_unchecked(&core_dump_count);
55059 fail_unlock:
55060 kfree(cn.corename);
55061 coredump_finish(mm, core_dumped);
55062 @@ -689,7 +698,7 @@ int dump_write(struct file *file, const void *addr, int nr)
55063 {
55064 return !dump_interrupted() &&
55065 access_ok(VERIFY_READ, addr, nr) &&
55066 - file->f_op->write(file, addr, nr, &file->f_pos) == nr;
55067 + file->f_op->write(file, (const char __force_user *)addr, nr, &file->f_pos) == nr;
55068 }
55069 EXPORT_SYMBOL(dump_write);
55070
55071 diff --git a/fs/dcache.c b/fs/dcache.c
55072 index 89f9671..5977a84 100644
55073 --- a/fs/dcache.c
55074 +++ b/fs/dcache.c
55075 @@ -2893,6 +2893,7 @@ static int prepend_path(const struct path *path,
55076 restart:
55077 bptr = *buffer;
55078 blen = *buflen;
55079 + error = 0;
55080 dentry = path->dentry;
55081 vfsmnt = path->mnt;
55082 mnt = real_mount(vfsmnt);
55083 @@ -3432,7 +3433,8 @@ void __init vfs_caches_init(unsigned long mempages)
55084 mempages -= reserve;
55085
55086 names_cachep = kmem_cache_create("names_cache", PATH_MAX, 0,
55087 - SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL);
55088 + SLAB_HWCACHE_ALIGN|SLAB_PANIC|SLAB_USERCOPY|
55089 + SLAB_NO_SANITIZE, NULL);
55090
55091 dcache_init();
55092 inode_init();
55093 diff --git a/fs/debugfs/inode.c b/fs/debugfs/inode.c
55094 index c7c83ff..bda9461 100644
55095 --- a/fs/debugfs/inode.c
55096 +++ b/fs/debugfs/inode.c
55097 @@ -415,7 +415,11 @@ EXPORT_SYMBOL_GPL(debugfs_create_file);
55098 */
55099 struct dentry *debugfs_create_dir(const char *name, struct dentry *parent)
55100 {
55101 +#ifdef CONFIG_GRKERNSEC_SYSFS_RESTRICT
55102 + return __create_file(name, S_IFDIR | S_IRWXU,
55103 +#else
55104 return __create_file(name, S_IFDIR | S_IRWXU | S_IRUGO | S_IXUGO,
55105 +#endif
55106 parent, NULL, NULL);
55107 }
55108 EXPORT_SYMBOL_GPL(debugfs_create_dir);
55109 diff --git a/fs/ecryptfs/inode.c b/fs/ecryptfs/inode.c
55110 index 67e9b63..a9adb68 100644
55111 --- a/fs/ecryptfs/inode.c
55112 +++ b/fs/ecryptfs/inode.c
55113 @@ -674,7 +674,7 @@ static int ecryptfs_readlink_lower(struct dentry *dentry, char **buf,
55114 old_fs = get_fs();
55115 set_fs(get_ds());
55116 rc = lower_dentry->d_inode->i_op->readlink(lower_dentry,
55117 - (char __user *)lower_buf,
55118 + (char __force_user *)lower_buf,
55119 PATH_MAX);
55120 set_fs(old_fs);
55121 if (rc < 0)
55122 @@ -706,7 +706,7 @@ out:
55123 static void
55124 ecryptfs_put_link(struct dentry *dentry, struct nameidata *nd, void *ptr)
55125 {
55126 - char *buf = nd_get_link(nd);
55127 + const char *buf = nd_get_link(nd);
55128 if (!IS_ERR(buf)) {
55129 /* Free the char* */
55130 kfree(buf);
55131 diff --git a/fs/ecryptfs/miscdev.c b/fs/ecryptfs/miscdev.c
55132 index e4141f2..d8263e8 100644
55133 --- a/fs/ecryptfs/miscdev.c
55134 +++ b/fs/ecryptfs/miscdev.c
55135 @@ -304,7 +304,7 @@ check_list:
55136 goto out_unlock_msg_ctx;
55137 i = PKT_TYPE_SIZE + PKT_CTR_SIZE;
55138 if (msg_ctx->msg) {
55139 - if (copy_to_user(&buf[i], packet_length, packet_length_size))
55140 + if (packet_length_size > sizeof(packet_length) || copy_to_user(&buf[i], packet_length, packet_length_size))
55141 goto out_unlock_msg_ctx;
55142 i += packet_length_size;
55143 if (copy_to_user(&buf[i], msg_ctx->msg, msg_ctx->msg_size))
55144 diff --git a/fs/exec.c b/fs/exec.c
55145 index bb8afc1..2f5087e 100644
55146 --- a/fs/exec.c
55147 +++ b/fs/exec.c
55148 @@ -55,8 +55,20 @@
55149 #include <linux/pipe_fs_i.h>
55150 #include <linux/oom.h>
55151 #include <linux/compat.h>
55152 +#include <linux/random.h>
55153 +#include <linux/seq_file.h>
55154 +#include <linux/coredump.h>
55155 +#include <linux/mman.h>
55156 +
55157 +#ifdef CONFIG_PAX_REFCOUNT
55158 +#include <linux/kallsyms.h>
55159 +#include <linux/kdebug.h>
55160 +#endif
55161 +
55162 +#include <trace/events/fs.h>
55163
55164 #include <asm/uaccess.h>
55165 +#include <asm/sections.h>
55166 #include <asm/mmu_context.h>
55167 #include <asm/tlb.h>
55168
55169 @@ -66,19 +78,34 @@
55170
55171 #include <trace/events/sched.h>
55172
55173 +#ifdef CONFIG_PAX_HAVE_ACL_FLAGS
55174 +void __weak pax_set_initial_flags(struct linux_binprm *bprm)
55175 +{
55176 + 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");
55177 +}
55178 +#endif
55179 +
55180 +#ifdef CONFIG_PAX_HOOK_ACL_FLAGS
55181 +void (*pax_set_initial_flags_func)(struct linux_binprm *bprm);
55182 +EXPORT_SYMBOL(pax_set_initial_flags_func);
55183 +#endif
55184 +
55185 int suid_dumpable = 0;
55186
55187 static LIST_HEAD(formats);
55188 static DEFINE_RWLOCK(binfmt_lock);
55189
55190 +extern int gr_process_kernel_exec_ban(void);
55191 +extern int gr_process_suid_exec_ban(const struct linux_binprm *bprm);
55192 +
55193 void __register_binfmt(struct linux_binfmt * fmt, int insert)
55194 {
55195 BUG_ON(!fmt);
55196 if (WARN_ON(!fmt->load_binary))
55197 return;
55198 write_lock(&binfmt_lock);
55199 - insert ? list_add(&fmt->lh, &formats) :
55200 - list_add_tail(&fmt->lh, &formats);
55201 + insert ? pax_list_add((struct list_head *)&fmt->lh, &formats) :
55202 + pax_list_add_tail((struct list_head *)&fmt->lh, &formats);
55203 write_unlock(&binfmt_lock);
55204 }
55205
55206 @@ -87,7 +114,7 @@ EXPORT_SYMBOL(__register_binfmt);
55207 void unregister_binfmt(struct linux_binfmt * fmt)
55208 {
55209 write_lock(&binfmt_lock);
55210 - list_del(&fmt->lh);
55211 + pax_list_del((struct list_head *)&fmt->lh);
55212 write_unlock(&binfmt_lock);
55213 }
55214
55215 @@ -183,18 +210,10 @@ static struct page *get_arg_page(struct linux_binprm *bprm, unsigned long pos,
55216 int write)
55217 {
55218 struct page *page;
55219 - int ret;
55220
55221 -#ifdef CONFIG_STACK_GROWSUP
55222 - if (write) {
55223 - ret = expand_downwards(bprm->vma, pos);
55224 - if (ret < 0)
55225 - return NULL;
55226 - }
55227 -#endif
55228 - ret = get_user_pages(current, bprm->mm, pos,
55229 - 1, write, 1, &page, NULL);
55230 - if (ret <= 0)
55231 + if (0 > expand_downwards(bprm->vma, pos))
55232 + return NULL;
55233 + if (0 >= get_user_pages(current, bprm->mm, pos, 1, write, 1, &page, NULL))
55234 return NULL;
55235
55236 if (write) {
55237 @@ -210,6 +229,17 @@ static struct page *get_arg_page(struct linux_binprm *bprm, unsigned long pos,
55238 if (size <= ARG_MAX)
55239 return page;
55240
55241 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55242 + // only allow 512KB for argv+env on suid/sgid binaries
55243 + // to prevent easy ASLR exhaustion
55244 + if (((!uid_eq(bprm->cred->euid, current_euid())) ||
55245 + (!gid_eq(bprm->cred->egid, current_egid()))) &&
55246 + (size > (512 * 1024))) {
55247 + put_page(page);
55248 + return NULL;
55249 + }
55250 +#endif
55251 +
55252 /*
55253 * Limit to 1/4-th the stack size for the argv+env strings.
55254 * This ensures that:
55255 @@ -269,6 +299,11 @@ static int __bprm_mm_init(struct linux_binprm *bprm)
55256 vma->vm_end = STACK_TOP_MAX;
55257 vma->vm_start = vma->vm_end - PAGE_SIZE;
55258 vma->vm_flags = VM_SOFTDIRTY | VM_STACK_FLAGS | VM_STACK_INCOMPLETE_SETUP;
55259 +
55260 +#ifdef CONFIG_PAX_SEGMEXEC
55261 + vma->vm_flags &= ~(VM_EXEC | VM_MAYEXEC);
55262 +#endif
55263 +
55264 vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
55265 INIT_LIST_HEAD(&vma->anon_vma_chain);
55266
55267 @@ -279,6 +314,12 @@ static int __bprm_mm_init(struct linux_binprm *bprm)
55268 mm->stack_vm = mm->total_vm = 1;
55269 up_write(&mm->mmap_sem);
55270 bprm->p = vma->vm_end - sizeof(void *);
55271 +
55272 +#ifdef CONFIG_PAX_RANDUSTACK
55273 + if (randomize_va_space)
55274 + bprm->p ^= prandom_u32() & ~PAGE_MASK;
55275 +#endif
55276 +
55277 return 0;
55278 err:
55279 up_write(&mm->mmap_sem);
55280 @@ -399,7 +440,7 @@ struct user_arg_ptr {
55281 } ptr;
55282 };
55283
55284 -static const char __user *get_user_arg_ptr(struct user_arg_ptr argv, int nr)
55285 +const char __user *get_user_arg_ptr(struct user_arg_ptr argv, int nr)
55286 {
55287 const char __user *native;
55288
55289 @@ -408,14 +449,14 @@ static const char __user *get_user_arg_ptr(struct user_arg_ptr argv, int nr)
55290 compat_uptr_t compat;
55291
55292 if (get_user(compat, argv.ptr.compat + nr))
55293 - return ERR_PTR(-EFAULT);
55294 + return (const char __force_user *)ERR_PTR(-EFAULT);
55295
55296 return compat_ptr(compat);
55297 }
55298 #endif
55299
55300 if (get_user(native, argv.ptr.native + nr))
55301 - return ERR_PTR(-EFAULT);
55302 + return (const char __force_user *)ERR_PTR(-EFAULT);
55303
55304 return native;
55305 }
55306 @@ -434,7 +475,7 @@ static int count(struct user_arg_ptr argv, int max)
55307 if (!p)
55308 break;
55309
55310 - if (IS_ERR(p))
55311 + if (IS_ERR((const char __force_kernel *)p))
55312 return -EFAULT;
55313
55314 if (i >= max)
55315 @@ -469,7 +510,7 @@ static int copy_strings(int argc, struct user_arg_ptr argv,
55316
55317 ret = -EFAULT;
55318 str = get_user_arg_ptr(argv, argc);
55319 - if (IS_ERR(str))
55320 + if (IS_ERR((const char __force_kernel *)str))
55321 goto out;
55322
55323 len = strnlen_user(str, MAX_ARG_STRLEN);
55324 @@ -551,7 +592,7 @@ int copy_strings_kernel(int argc, const char *const *__argv,
55325 int r;
55326 mm_segment_t oldfs = get_fs();
55327 struct user_arg_ptr argv = {
55328 - .ptr.native = (const char __user *const __user *)__argv,
55329 + .ptr.native = (const char __force_user * const __force_user *)__argv,
55330 };
55331
55332 set_fs(KERNEL_DS);
55333 @@ -586,7 +627,8 @@ static int shift_arg_pages(struct vm_area_struct *vma, unsigned long shift)
55334 unsigned long new_end = old_end - shift;
55335 struct mmu_gather tlb;
55336
55337 - BUG_ON(new_start > new_end);
55338 + if (new_start >= new_end || new_start < mmap_min_addr)
55339 + return -ENOMEM;
55340
55341 /*
55342 * ensure there are no vmas between where we want to go
55343 @@ -595,6 +637,10 @@ static int shift_arg_pages(struct vm_area_struct *vma, unsigned long shift)
55344 if (vma != find_vma(mm, new_start))
55345 return -EFAULT;
55346
55347 +#ifdef CONFIG_PAX_SEGMEXEC
55348 + BUG_ON(pax_find_mirror_vma(vma));
55349 +#endif
55350 +
55351 /*
55352 * cover the whole range: [new_start, old_end)
55353 */
55354 @@ -675,10 +721,6 @@ int setup_arg_pages(struct linux_binprm *bprm,
55355 stack_top = arch_align_stack(stack_top);
55356 stack_top = PAGE_ALIGN(stack_top);
55357
55358 - if (unlikely(stack_top < mmap_min_addr) ||
55359 - unlikely(vma->vm_end - vma->vm_start >= stack_top - mmap_min_addr))
55360 - return -ENOMEM;
55361 -
55362 stack_shift = vma->vm_end - stack_top;
55363
55364 bprm->p -= stack_shift;
55365 @@ -690,8 +732,28 @@ int setup_arg_pages(struct linux_binprm *bprm,
55366 bprm->exec -= stack_shift;
55367
55368 down_write(&mm->mmap_sem);
55369 +
55370 + /* Move stack pages down in memory. */
55371 + if (stack_shift) {
55372 + ret = shift_arg_pages(vma, stack_shift);
55373 + if (ret)
55374 + goto out_unlock;
55375 + }
55376 +
55377 vm_flags = VM_STACK_FLAGS;
55378
55379 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
55380 + if (mm->pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) {
55381 + vm_flags &= ~VM_EXEC;
55382 +
55383 +#ifdef CONFIG_PAX_MPROTECT
55384 + if (mm->pax_flags & MF_PAX_MPROTECT)
55385 + vm_flags &= ~VM_MAYEXEC;
55386 +#endif
55387 +
55388 + }
55389 +#endif
55390 +
55391 /*
55392 * Adjust stack execute permissions; explicitly enable for
55393 * EXSTACK_ENABLE_X, disable for EXSTACK_DISABLE_X and leave alone
55394 @@ -710,13 +772,6 @@ int setup_arg_pages(struct linux_binprm *bprm,
55395 goto out_unlock;
55396 BUG_ON(prev != vma);
55397
55398 - /* Move stack pages down in memory. */
55399 - if (stack_shift) {
55400 - ret = shift_arg_pages(vma, stack_shift);
55401 - if (ret)
55402 - goto out_unlock;
55403 - }
55404 -
55405 /* mprotect_fixup is overkill to remove the temporary stack flags */
55406 vma->vm_flags &= ~VM_STACK_INCOMPLETE_SETUP;
55407
55408 @@ -740,6 +795,27 @@ int setup_arg_pages(struct linux_binprm *bprm,
55409 #endif
55410 current->mm->start_stack = bprm->p;
55411 ret = expand_stack(vma, stack_base);
55412 +
55413 +#if !defined(CONFIG_STACK_GROWSUP) && defined(CONFIG_PAX_RANDMMAP)
55414 + if (!ret && (mm->pax_flags & MF_PAX_RANDMMAP) && STACK_TOP <= 0xFFFFFFFFU && STACK_TOP > vma->vm_end) {
55415 + unsigned long size;
55416 + vm_flags_t vm_flags;
55417 +
55418 + size = STACK_TOP - vma->vm_end;
55419 + vm_flags = VM_NONE | VM_DONTEXPAND | VM_DONTDUMP;
55420 +
55421 + ret = vma->vm_end != mmap_region(NULL, vma->vm_end, size, vm_flags, 0);
55422 +
55423 +#ifdef CONFIG_X86
55424 + if (!ret) {
55425 + size = PAGE_SIZE + mmap_min_addr + ((mm->delta_mmap ^ mm->delta_stack) & (0xFFUL << PAGE_SHIFT));
55426 + ret = 0 != mmap_region(NULL, 0, PAGE_ALIGN(size), vm_flags, 0);
55427 + }
55428 +#endif
55429 +
55430 + }
55431 +#endif
55432 +
55433 if (ret)
55434 ret = -EFAULT;
55435
55436 @@ -776,6 +852,8 @@ struct file *open_exec(const char *name)
55437
55438 fsnotify_open(file);
55439
55440 + trace_open_exec(name);
55441 +
55442 err = deny_write_access(file);
55443 if (err)
55444 goto exit;
55445 @@ -799,7 +877,7 @@ int kernel_read(struct file *file, loff_t offset,
55446 old_fs = get_fs();
55447 set_fs(get_ds());
55448 /* The cast to a user pointer is valid due to the set_fs() */
55449 - result = vfs_read(file, (void __user *)addr, count, &pos);
55450 + result = vfs_read(file, (void __force_user *)addr, count, &pos);
55451 set_fs(old_fs);
55452 return result;
55453 }
55454 @@ -1255,7 +1333,7 @@ static int check_unsafe_exec(struct linux_binprm *bprm)
55455 }
55456 rcu_read_unlock();
55457
55458 - if (p->fs->users > n_fs) {
55459 + if (atomic_read(&p->fs->users) > n_fs) {
55460 bprm->unsafe |= LSM_UNSAFE_SHARE;
55461 } else {
55462 res = -EAGAIN;
55463 @@ -1451,6 +1529,31 @@ static int exec_binprm(struct linux_binprm *bprm)
55464 return ret;
55465 }
55466
55467 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55468 +static DEFINE_PER_CPU(u64, exec_counter);
55469 +static int __init init_exec_counters(void)
55470 +{
55471 + unsigned int cpu;
55472 +
55473 + for_each_possible_cpu(cpu) {
55474 + per_cpu(exec_counter, cpu) = (u64)cpu;
55475 + }
55476 +
55477 + return 0;
55478 +}
55479 +early_initcall(init_exec_counters);
55480 +static inline void increment_exec_counter(void)
55481 +{
55482 + BUILD_BUG_ON(NR_CPUS > (1 << 16));
55483 + current->exec_id = this_cpu_add_return(exec_counter, 1 << 16);
55484 +}
55485 +#else
55486 +static inline void increment_exec_counter(void) {}
55487 +#endif
55488 +
55489 +extern void gr_handle_exec_args(struct linux_binprm *bprm,
55490 + struct user_arg_ptr argv);
55491 +
55492 /*
55493 * sys_execve() executes a new program.
55494 */
55495 @@ -1458,12 +1561,19 @@ static int do_execve_common(const char *filename,
55496 struct user_arg_ptr argv,
55497 struct user_arg_ptr envp)
55498 {
55499 +#ifdef CONFIG_GRKERNSEC
55500 + struct file *old_exec_file;
55501 + struct acl_subject_label *old_acl;
55502 + struct rlimit old_rlim[RLIM_NLIMITS];
55503 +#endif
55504 struct linux_binprm *bprm;
55505 struct file *file;
55506 struct files_struct *displaced;
55507 bool clear_in_exec;
55508 int retval;
55509
55510 + gr_learn_resource(current, RLIMIT_NPROC, atomic_read(&current_user()->processes), 1);
55511 +
55512 /*
55513 * We move the actual failure in case of RLIMIT_NPROC excess from
55514 * set*uid() to execve() because too many poorly written programs
55515 @@ -1504,12 +1614,22 @@ static int do_execve_common(const char *filename,
55516 if (IS_ERR(file))
55517 goto out_unmark;
55518
55519 + if (gr_ptrace_readexec(file, bprm->unsafe)) {
55520 + retval = -EPERM;
55521 + goto out_file;
55522 + }
55523 +
55524 sched_exec();
55525
55526 bprm->file = file;
55527 bprm->filename = filename;
55528 bprm->interp = filename;
55529
55530 + if (!gr_acl_handle_execve(file->f_path.dentry, file->f_path.mnt)) {
55531 + retval = -EACCES;
55532 + goto out_file;
55533 + }
55534 +
55535 retval = bprm_mm_init(bprm);
55536 if (retval)
55537 goto out_file;
55538 @@ -1526,24 +1646,70 @@ static int do_execve_common(const char *filename,
55539 if (retval < 0)
55540 goto out;
55541
55542 +#ifdef CONFIG_GRKERNSEC
55543 + old_acl = current->acl;
55544 + memcpy(old_rlim, current->signal->rlim, sizeof(old_rlim));
55545 + old_exec_file = current->exec_file;
55546 + get_file(file);
55547 + current->exec_file = file;
55548 +#endif
55549 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55550 + /* limit suid stack to 8MB
55551 + * we saved the old limits above and will restore them if this exec fails
55552 + */
55553 + if (((!uid_eq(bprm->cred->euid, current_euid())) || (!gid_eq(bprm->cred->egid, current_egid()))) &&
55554 + (old_rlim[RLIMIT_STACK].rlim_cur > (8 * 1024 * 1024)))
55555 + current->signal->rlim[RLIMIT_STACK].rlim_cur = 8 * 1024 * 1024;
55556 +#endif
55557 +
55558 + if (gr_process_kernel_exec_ban() || gr_process_suid_exec_ban(bprm)) {
55559 + retval = -EPERM;
55560 + goto out_fail;
55561 + }
55562 +
55563 + if (!gr_tpe_allow(file)) {
55564 + retval = -EACCES;
55565 + goto out_fail;
55566 + }
55567 +
55568 + if (gr_check_crash_exec(file)) {
55569 + retval = -EACCES;
55570 + goto out_fail;
55571 + }
55572 +
55573 + retval = gr_set_proc_label(file->f_path.dentry, file->f_path.mnt,
55574 + bprm->unsafe);
55575 + if (retval < 0)
55576 + goto out_fail;
55577 +
55578 retval = copy_strings_kernel(1, &bprm->filename, bprm);
55579 if (retval < 0)
55580 - goto out;
55581 + goto out_fail;
55582
55583 bprm->exec = bprm->p;
55584 retval = copy_strings(bprm->envc, envp, bprm);
55585 if (retval < 0)
55586 - goto out;
55587 + goto out_fail;
55588
55589 retval = copy_strings(bprm->argc, argv, bprm);
55590 if (retval < 0)
55591 - goto out;
55592 + goto out_fail;
55593 +
55594 + gr_log_chroot_exec(file->f_path.dentry, file->f_path.mnt);
55595 +
55596 + gr_handle_exec_args(bprm, argv);
55597
55598 retval = exec_binprm(bprm);
55599 if (retval < 0)
55600 - goto out;
55601 + goto out_fail;
55602 +#ifdef CONFIG_GRKERNSEC
55603 + if (old_exec_file)
55604 + fput(old_exec_file);
55605 +#endif
55606
55607 /* execve succeeded */
55608 +
55609 + increment_exec_counter();
55610 current->fs->in_exec = 0;
55611 current->in_execve = 0;
55612 acct_update_integrals(current);
55613 @@ -1552,6 +1718,14 @@ static int do_execve_common(const char *filename,
55614 put_files_struct(displaced);
55615 return retval;
55616
55617 +out_fail:
55618 +#ifdef CONFIG_GRKERNSEC
55619 + current->acl = old_acl;
55620 + memcpy(current->signal->rlim, old_rlim, sizeof(old_rlim));
55621 + fput(current->exec_file);
55622 + current->exec_file = old_exec_file;
55623 +#endif
55624 +
55625 out:
55626 if (bprm->mm) {
55627 acct_arg_size(bprm, 0);
55628 @@ -1706,3 +1880,295 @@ asmlinkage long compat_sys_execve(const char __user * filename,
55629 return error;
55630 }
55631 #endif
55632 +
55633 +int pax_check_flags(unsigned long *flags)
55634 +{
55635 + int retval = 0;
55636 +
55637 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_SEGMEXEC)
55638 + if (*flags & MF_PAX_SEGMEXEC)
55639 + {
55640 + *flags &= ~MF_PAX_SEGMEXEC;
55641 + retval = -EINVAL;
55642 + }
55643 +#endif
55644 +
55645 + if ((*flags & MF_PAX_PAGEEXEC)
55646 +
55647 +#ifdef CONFIG_PAX_PAGEEXEC
55648 + && (*flags & MF_PAX_SEGMEXEC)
55649 +#endif
55650 +
55651 + )
55652 + {
55653 + *flags &= ~MF_PAX_PAGEEXEC;
55654 + retval = -EINVAL;
55655 + }
55656 +
55657 + if ((*flags & MF_PAX_MPROTECT)
55658 +
55659 +#ifdef CONFIG_PAX_MPROTECT
55660 + && !(*flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC))
55661 +#endif
55662 +
55663 + )
55664 + {
55665 + *flags &= ~MF_PAX_MPROTECT;
55666 + retval = -EINVAL;
55667 + }
55668 +
55669 + if ((*flags & MF_PAX_EMUTRAMP)
55670 +
55671 +#ifdef CONFIG_PAX_EMUTRAMP
55672 + && !(*flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC))
55673 +#endif
55674 +
55675 + )
55676 + {
55677 + *flags &= ~MF_PAX_EMUTRAMP;
55678 + retval = -EINVAL;
55679 + }
55680 +
55681 + return retval;
55682 +}
55683 +
55684 +EXPORT_SYMBOL(pax_check_flags);
55685 +
55686 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
55687 +char *pax_get_path(const struct path *path, char *buf, int buflen)
55688 +{
55689 + char *pathname = d_path(path, buf, buflen);
55690 +
55691 + if (IS_ERR(pathname))
55692 + goto toolong;
55693 +
55694 + pathname = mangle_path(buf, pathname, "\t\n\\");
55695 + if (!pathname)
55696 + goto toolong;
55697 +
55698 + *pathname = 0;
55699 + return buf;
55700 +
55701 +toolong:
55702 + return "<path too long>";
55703 +}
55704 +EXPORT_SYMBOL(pax_get_path);
55705 +
55706 +void pax_report_fault(struct pt_regs *regs, void *pc, void *sp)
55707 +{
55708 + struct task_struct *tsk = current;
55709 + struct mm_struct *mm = current->mm;
55710 + char *buffer_exec = (char *)__get_free_page(GFP_KERNEL);
55711 + char *buffer_fault = (char *)__get_free_page(GFP_KERNEL);
55712 + char *path_exec = NULL;
55713 + char *path_fault = NULL;
55714 + unsigned long start = 0UL, end = 0UL, offset = 0UL;
55715 + siginfo_t info = { };
55716 +
55717 + if (buffer_exec && buffer_fault) {
55718 + struct vm_area_struct *vma, *vma_exec = NULL, *vma_fault = NULL;
55719 +
55720 + down_read(&mm->mmap_sem);
55721 + vma = mm->mmap;
55722 + while (vma && (!vma_exec || !vma_fault)) {
55723 + if (vma->vm_file && mm->exe_file == vma->vm_file && (vma->vm_flags & VM_EXEC))
55724 + vma_exec = vma;
55725 + if (vma->vm_start <= (unsigned long)pc && (unsigned long)pc < vma->vm_end)
55726 + vma_fault = vma;
55727 + vma = vma->vm_next;
55728 + }
55729 + if (vma_exec)
55730 + path_exec = pax_get_path(&vma_exec->vm_file->f_path, buffer_exec, PAGE_SIZE);
55731 + if (vma_fault) {
55732 + start = vma_fault->vm_start;
55733 + end = vma_fault->vm_end;
55734 + offset = vma_fault->vm_pgoff << PAGE_SHIFT;
55735 + if (vma_fault->vm_file)
55736 + path_fault = pax_get_path(&vma_fault->vm_file->f_path, buffer_fault, PAGE_SIZE);
55737 + else if ((unsigned long)pc >= mm->start_brk && (unsigned long)pc < mm->brk)
55738 + path_fault = "<heap>";
55739 + else if (vma_fault->vm_flags & (VM_GROWSDOWN | VM_GROWSUP))
55740 + path_fault = "<stack>";
55741 + else
55742 + path_fault = "<anonymous mapping>";
55743 + }
55744 + up_read(&mm->mmap_sem);
55745 + }
55746 + if (tsk->signal->curr_ip)
55747 + printk(KERN_ERR "PAX: From %pI4: execution attempt in: %s, %08lx-%08lx %08lx\n", &tsk->signal->curr_ip, path_fault, start, end, offset);
55748 + else
55749 + printk(KERN_ERR "PAX: execution attempt in: %s, %08lx-%08lx %08lx\n", path_fault, start, end, offset);
55750 + 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),
55751 + from_kuid_munged(&init_user_ns, task_uid(tsk)), from_kuid_munged(&init_user_ns, task_euid(tsk)), pc, sp);
55752 + free_page((unsigned long)buffer_exec);
55753 + free_page((unsigned long)buffer_fault);
55754 + pax_report_insns(regs, pc, sp);
55755 + info.si_signo = SIGKILL;
55756 + info.si_errno = 0;
55757 + info.si_code = SI_KERNEL;
55758 + info.si_pid = 0;
55759 + info.si_uid = 0;
55760 + do_coredump(&info);
55761 +}
55762 +#endif
55763 +
55764 +#ifdef CONFIG_PAX_REFCOUNT
55765 +void pax_report_refcount_overflow(struct pt_regs *regs)
55766 +{
55767 + if (current->signal->curr_ip)
55768 + printk(KERN_ERR "PAX: From %pI4: refcount overflow detected in: %s:%d, uid/euid: %u/%u\n",
55769 + &current->signal->curr_ip, current->comm, task_pid_nr(current),
55770 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()));
55771 + else
55772 + printk(KERN_ERR "PAX: refcount overflow detected in: %s:%d, uid/euid: %u/%u\n", current->comm, task_pid_nr(current),
55773 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()));
55774 + print_symbol(KERN_ERR "PAX: refcount overflow occured at: %s\n", instruction_pointer(regs));
55775 + preempt_disable();
55776 + show_regs(regs);
55777 + preempt_enable();
55778 + force_sig_info(SIGKILL, SEND_SIG_FORCED, current);
55779 +}
55780 +#endif
55781 +
55782 +#ifdef CONFIG_PAX_USERCOPY
55783 +/* 0: not at all, 1: fully, 2: fully inside frame, -1: partially (implies an error) */
55784 +static noinline int check_stack_object(const void *obj, unsigned long len)
55785 +{
55786 + const void * const stack = task_stack_page(current);
55787 + const void * const stackend = stack + THREAD_SIZE;
55788 +
55789 +#if defined(CONFIG_FRAME_POINTER) && defined(CONFIG_X86)
55790 + const void *frame = NULL;
55791 + const void *oldframe;
55792 +#endif
55793 +
55794 + if (obj + len < obj)
55795 + return -1;
55796 +
55797 + if (obj + len <= stack || stackend <= obj)
55798 + return 0;
55799 +
55800 + if (obj < stack || stackend < obj + len)
55801 + return -1;
55802 +
55803 +#if defined(CONFIG_FRAME_POINTER) && defined(CONFIG_X86)
55804 + oldframe = __builtin_frame_address(1);
55805 + if (oldframe)
55806 + frame = __builtin_frame_address(2);
55807 + /*
55808 + low ----------------------------------------------> high
55809 + [saved bp][saved ip][args][local vars][saved bp][saved ip]
55810 + ^----------------^
55811 + allow copies only within here
55812 + */
55813 + while (stack <= frame && frame < stackend) {
55814 + /* if obj + len extends past the last frame, this
55815 + check won't pass and the next frame will be 0,
55816 + causing us to bail out and correctly report
55817 + the copy as invalid
55818 + */
55819 + if (obj + len <= frame)
55820 + return obj >= oldframe + 2 * sizeof(void *) ? 2 : -1;
55821 + oldframe = frame;
55822 + frame = *(const void * const *)frame;
55823 + }
55824 + return -1;
55825 +#else
55826 + return 1;
55827 +#endif
55828 +}
55829 +
55830 +static __noreturn void pax_report_usercopy(const void *ptr, unsigned long len, bool to_user, const char *type)
55831 +{
55832 + if (current->signal->curr_ip)
55833 + printk(KERN_ERR "PAX: From %pI4: kernel memory %s attempt detected %s %p (%s) (%lu bytes)\n",
55834 + &current->signal->curr_ip, to_user ? "leak" : "overwrite", to_user ? "from" : "to", ptr, type ? : "unknown", len);
55835 + else
55836 + printk(KERN_ERR "PAX: kernel memory %s attempt detected %s %p (%s) (%lu bytes)\n",
55837 + to_user ? "leak" : "overwrite", to_user ? "from" : "to", ptr, type ? : "unknown", len);
55838 + dump_stack();
55839 + gr_handle_kernel_exploit();
55840 + do_group_exit(SIGKILL);
55841 +}
55842 +#endif
55843 +
55844 +#ifdef CONFIG_PAX_USERCOPY
55845 +static inline bool check_kernel_text_object(unsigned long low, unsigned long high)
55846 +{
55847 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
55848 + unsigned long textlow = ktla_ktva((unsigned long)_stext);
55849 +#ifdef CONFIG_MODULES
55850 + unsigned long texthigh = (unsigned long)MODULES_EXEC_VADDR;
55851 +#else
55852 + unsigned long texthigh = ktla_ktva((unsigned long)_etext);
55853 +#endif
55854 +
55855 +#else
55856 + unsigned long textlow = (unsigned long)_stext;
55857 + unsigned long texthigh = (unsigned long)_etext;
55858 +
55859 +#ifdef CONFIG_X86_64
55860 + /* check against linear mapping as well */
55861 + if (high > (unsigned long)__va(__pa(textlow)) &&
55862 + low <= (unsigned long)__va(__pa(texthigh)))
55863 + return true;
55864 +#endif
55865 +
55866 +#endif
55867 +
55868 + if (high <= textlow || low > texthigh)
55869 + return false;
55870 + else
55871 + return true;
55872 +}
55873 +#endif
55874 +
55875 +void __check_object_size(const void *ptr, unsigned long n, bool to_user)
55876 +{
55877 +
55878 +#ifdef CONFIG_PAX_USERCOPY
55879 + const char *type;
55880 +
55881 + if (!n)
55882 + return;
55883 +
55884 + type = check_heap_object(ptr, n);
55885 + if (!type) {
55886 + int ret = check_stack_object(ptr, n);
55887 + if (ret == 1 || ret == 2)
55888 + return;
55889 + if (ret == 0) {
55890 + if (check_kernel_text_object((unsigned long)ptr, (unsigned long)ptr + n))
55891 + type = "<kernel text>";
55892 + else
55893 + return;
55894 + } else
55895 + type = "<process stack>";
55896 + }
55897 +
55898 + pax_report_usercopy(ptr, n, to_user, type);
55899 +#endif
55900 +
55901 +}
55902 +EXPORT_SYMBOL(__check_object_size);
55903 +
55904 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
55905 +void pax_track_stack(void)
55906 +{
55907 + unsigned long sp = (unsigned long)&sp;
55908 + if (sp < current_thread_info()->lowest_stack &&
55909 + sp > (unsigned long)task_stack_page(current))
55910 + current_thread_info()->lowest_stack = sp;
55911 +}
55912 +EXPORT_SYMBOL(pax_track_stack);
55913 +#endif
55914 +
55915 +#ifdef CONFIG_PAX_SIZE_OVERFLOW
55916 +void report_size_overflow(const char *file, unsigned int line, const char *func, const char *ssa_name)
55917 +{
55918 + printk(KERN_ERR "PAX: size overflow detected in function %s %s:%u %s", func, file, line, ssa_name);
55919 + dump_stack();
55920 + do_group_exit(SIGKILL);
55921 +}
55922 +EXPORT_SYMBOL(report_size_overflow);
55923 +#endif
55924 diff --git a/fs/ext2/balloc.c b/fs/ext2/balloc.c
55925 index 9f9992b..8b59411 100644
55926 --- a/fs/ext2/balloc.c
55927 +++ b/fs/ext2/balloc.c
55928 @@ -1184,10 +1184,10 @@ static int ext2_has_free_blocks(struct ext2_sb_info *sbi)
55929
55930 free_blocks = percpu_counter_read_positive(&sbi->s_freeblocks_counter);
55931 root_blocks = le32_to_cpu(sbi->s_es->s_r_blocks_count);
55932 - if (free_blocks < root_blocks + 1 && !capable(CAP_SYS_RESOURCE) &&
55933 + if (free_blocks < root_blocks + 1 &&
55934 !uid_eq(sbi->s_resuid, current_fsuid()) &&
55935 (gid_eq(sbi->s_resgid, GLOBAL_ROOT_GID) ||
55936 - !in_group_p (sbi->s_resgid))) {
55937 + !in_group_p (sbi->s_resgid)) && !capable_nolog(CAP_SYS_RESOURCE)) {
55938 return 0;
55939 }
55940 return 1;
55941 diff --git a/fs/ext2/xattr.c b/fs/ext2/xattr.c
55942 index 2d7557d..14e38f94 100644
55943 --- a/fs/ext2/xattr.c
55944 +++ b/fs/ext2/xattr.c
55945 @@ -247,7 +247,7 @@ ext2_xattr_list(struct dentry *dentry, char *buffer, size_t buffer_size)
55946 struct buffer_head *bh = NULL;
55947 struct ext2_xattr_entry *entry;
55948 char *end;
55949 - size_t rest = buffer_size;
55950 + size_t rest = buffer_size, total_size = 0;
55951 int error;
55952
55953 ea_idebug(inode, "buffer=%p, buffer_size=%ld",
55954 @@ -305,9 +305,10 @@ bad_block: ext2_error(inode->i_sb, "ext2_xattr_list",
55955 buffer += size;
55956 }
55957 rest -= size;
55958 + total_size += size;
55959 }
55960 }
55961 - error = buffer_size - rest; /* total size */
55962 + error = total_size;
55963
55964 cleanup:
55965 brelse(bh);
55966 diff --git a/fs/ext3/balloc.c b/fs/ext3/balloc.c
55967 index 22548f5..41521d8 100644
55968 --- a/fs/ext3/balloc.c
55969 +++ b/fs/ext3/balloc.c
55970 @@ -1438,10 +1438,10 @@ static int ext3_has_free_blocks(struct ext3_sb_info *sbi, int use_reservation)
55971
55972 free_blocks = percpu_counter_read_positive(&sbi->s_freeblocks_counter);
55973 root_blocks = le32_to_cpu(sbi->s_es->s_r_blocks_count);
55974 - if (free_blocks < root_blocks + 1 && !capable(CAP_SYS_RESOURCE) &&
55975 + if (free_blocks < root_blocks + 1 &&
55976 !use_reservation && !uid_eq(sbi->s_resuid, current_fsuid()) &&
55977 (gid_eq(sbi->s_resgid, GLOBAL_ROOT_GID) ||
55978 - !in_group_p (sbi->s_resgid))) {
55979 + !in_group_p (sbi->s_resgid)) && !capable_nolog(CAP_SYS_RESOURCE)) {
55980 return 0;
55981 }
55982 return 1;
55983 diff --git a/fs/ext3/xattr.c b/fs/ext3/xattr.c
55984 index b1fc963..881228c 100644
55985 --- a/fs/ext3/xattr.c
55986 +++ b/fs/ext3/xattr.c
55987 @@ -330,7 +330,7 @@ static int
55988 ext3_xattr_list_entries(struct dentry *dentry, struct ext3_xattr_entry *entry,
55989 char *buffer, size_t buffer_size)
55990 {
55991 - size_t rest = buffer_size;
55992 + size_t rest = buffer_size, total_size = 0;
55993
55994 for (; !IS_LAST_ENTRY(entry); entry = EXT3_XATTR_NEXT(entry)) {
55995 const struct xattr_handler *handler =
55996 @@ -347,9 +347,10 @@ ext3_xattr_list_entries(struct dentry *dentry, struct ext3_xattr_entry *entry,
55997 buffer += size;
55998 }
55999 rest -= size;
56000 + total_size += size;
56001 }
56002 }
56003 - return buffer_size - rest;
56004 + return total_size;
56005 }
56006
56007 static int
56008 diff --git a/fs/ext4/balloc.c b/fs/ext4/balloc.c
56009 index dc5d572..4c21f8e 100644
56010 --- a/fs/ext4/balloc.c
56011 +++ b/fs/ext4/balloc.c
56012 @@ -534,8 +534,8 @@ static int ext4_has_free_clusters(struct ext4_sb_info *sbi,
56013 /* Hm, nope. Are (enough) root reserved clusters available? */
56014 if (uid_eq(sbi->s_resuid, current_fsuid()) ||
56015 (!gid_eq(sbi->s_resgid, GLOBAL_ROOT_GID) && in_group_p(sbi->s_resgid)) ||
56016 - capable(CAP_SYS_RESOURCE) ||
56017 - (flags & EXT4_MB_USE_ROOT_BLOCKS)) {
56018 + (flags & EXT4_MB_USE_ROOT_BLOCKS) ||
56019 + capable_nolog(CAP_SYS_RESOURCE)) {
56020
56021 if (free_clusters >= (nclusters + dirty_clusters +
56022 resv_clusters))
56023 diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h
56024 index af815ea..99294a6 100644
56025 --- a/fs/ext4/ext4.h
56026 +++ b/fs/ext4/ext4.h
56027 @@ -1256,19 +1256,19 @@ struct ext4_sb_info {
56028 unsigned long s_mb_last_start;
56029
56030 /* stats for buddy allocator */
56031 - atomic_t s_bal_reqs; /* number of reqs with len > 1 */
56032 - atomic_t s_bal_success; /* we found long enough chunks */
56033 - atomic_t s_bal_allocated; /* in blocks */
56034 - atomic_t s_bal_ex_scanned; /* total extents scanned */
56035 - atomic_t s_bal_goals; /* goal hits */
56036 - atomic_t s_bal_breaks; /* too long searches */
56037 - atomic_t s_bal_2orders; /* 2^order hits */
56038 + atomic_unchecked_t s_bal_reqs; /* number of reqs with len > 1 */
56039 + atomic_unchecked_t s_bal_success; /* we found long enough chunks */
56040 + atomic_unchecked_t s_bal_allocated; /* in blocks */
56041 + atomic_unchecked_t s_bal_ex_scanned; /* total extents scanned */
56042 + atomic_unchecked_t s_bal_goals; /* goal hits */
56043 + atomic_unchecked_t s_bal_breaks; /* too long searches */
56044 + atomic_unchecked_t s_bal_2orders; /* 2^order hits */
56045 spinlock_t s_bal_lock;
56046 unsigned long s_mb_buddies_generated;
56047 unsigned long long s_mb_generation_time;
56048 - atomic_t s_mb_lost_chunks;
56049 - atomic_t s_mb_preallocated;
56050 - atomic_t s_mb_discarded;
56051 + atomic_unchecked_t s_mb_lost_chunks;
56052 + atomic_unchecked_t s_mb_preallocated;
56053 + atomic_unchecked_t s_mb_discarded;
56054 atomic_t s_lock_busy;
56055
56056 /* locality groups */
56057 diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c
56058 index a41e3ba..e574a00 100644
56059 --- a/fs/ext4/mballoc.c
56060 +++ b/fs/ext4/mballoc.c
56061 @@ -1880,7 +1880,7 @@ void ext4_mb_simple_scan_group(struct ext4_allocation_context *ac,
56062 BUG_ON(ac->ac_b_ex.fe_len != ac->ac_g_ex.fe_len);
56063
56064 if (EXT4_SB(sb)->s_mb_stats)
56065 - atomic_inc(&EXT4_SB(sb)->s_bal_2orders);
56066 + atomic_inc_unchecked(&EXT4_SB(sb)->s_bal_2orders);
56067
56068 break;
56069 }
56070 @@ -2189,7 +2189,7 @@ repeat:
56071 ac->ac_status = AC_STATUS_CONTINUE;
56072 ac->ac_flags |= EXT4_MB_HINT_FIRST;
56073 cr = 3;
56074 - atomic_inc(&sbi->s_mb_lost_chunks);
56075 + atomic_inc_unchecked(&sbi->s_mb_lost_chunks);
56076 goto repeat;
56077 }
56078 }
56079 @@ -2697,25 +2697,25 @@ int ext4_mb_release(struct super_block *sb)
56080 if (sbi->s_mb_stats) {
56081 ext4_msg(sb, KERN_INFO,
56082 "mballoc: %u blocks %u reqs (%u success)",
56083 - atomic_read(&sbi->s_bal_allocated),
56084 - atomic_read(&sbi->s_bal_reqs),
56085 - atomic_read(&sbi->s_bal_success));
56086 + atomic_read_unchecked(&sbi->s_bal_allocated),
56087 + atomic_read_unchecked(&sbi->s_bal_reqs),
56088 + atomic_read_unchecked(&sbi->s_bal_success));
56089 ext4_msg(sb, KERN_INFO,
56090 "mballoc: %u extents scanned, %u goal hits, "
56091 "%u 2^N hits, %u breaks, %u lost",
56092 - atomic_read(&sbi->s_bal_ex_scanned),
56093 - atomic_read(&sbi->s_bal_goals),
56094 - atomic_read(&sbi->s_bal_2orders),
56095 - atomic_read(&sbi->s_bal_breaks),
56096 - atomic_read(&sbi->s_mb_lost_chunks));
56097 + atomic_read_unchecked(&sbi->s_bal_ex_scanned),
56098 + atomic_read_unchecked(&sbi->s_bal_goals),
56099 + atomic_read_unchecked(&sbi->s_bal_2orders),
56100 + atomic_read_unchecked(&sbi->s_bal_breaks),
56101 + atomic_read_unchecked(&sbi->s_mb_lost_chunks));
56102 ext4_msg(sb, KERN_INFO,
56103 "mballoc: %lu generated and it took %Lu",
56104 sbi->s_mb_buddies_generated,
56105 sbi->s_mb_generation_time);
56106 ext4_msg(sb, KERN_INFO,
56107 "mballoc: %u preallocated, %u discarded",
56108 - atomic_read(&sbi->s_mb_preallocated),
56109 - atomic_read(&sbi->s_mb_discarded));
56110 + atomic_read_unchecked(&sbi->s_mb_preallocated),
56111 + atomic_read_unchecked(&sbi->s_mb_discarded));
56112 }
56113
56114 free_percpu(sbi->s_locality_groups);
56115 @@ -3169,16 +3169,16 @@ static void ext4_mb_collect_stats(struct ext4_allocation_context *ac)
56116 struct ext4_sb_info *sbi = EXT4_SB(ac->ac_sb);
56117
56118 if (sbi->s_mb_stats && ac->ac_g_ex.fe_len > 1) {
56119 - atomic_inc(&sbi->s_bal_reqs);
56120 - atomic_add(ac->ac_b_ex.fe_len, &sbi->s_bal_allocated);
56121 + atomic_inc_unchecked(&sbi->s_bal_reqs);
56122 + atomic_add_unchecked(ac->ac_b_ex.fe_len, &sbi->s_bal_allocated);
56123 if (ac->ac_b_ex.fe_len >= ac->ac_o_ex.fe_len)
56124 - atomic_inc(&sbi->s_bal_success);
56125 - atomic_add(ac->ac_found, &sbi->s_bal_ex_scanned);
56126 + atomic_inc_unchecked(&sbi->s_bal_success);
56127 + atomic_add_unchecked(ac->ac_found, &sbi->s_bal_ex_scanned);
56128 if (ac->ac_g_ex.fe_start == ac->ac_b_ex.fe_start &&
56129 ac->ac_g_ex.fe_group == ac->ac_b_ex.fe_group)
56130 - atomic_inc(&sbi->s_bal_goals);
56131 + atomic_inc_unchecked(&sbi->s_bal_goals);
56132 if (ac->ac_found > sbi->s_mb_max_to_scan)
56133 - atomic_inc(&sbi->s_bal_breaks);
56134 + atomic_inc_unchecked(&sbi->s_bal_breaks);
56135 }
56136
56137 if (ac->ac_op == EXT4_MB_HISTORY_ALLOC)
56138 @@ -3578,7 +3578,7 @@ ext4_mb_new_inode_pa(struct ext4_allocation_context *ac)
56139 trace_ext4_mb_new_inode_pa(ac, pa);
56140
56141 ext4_mb_use_inode_pa(ac, pa);
56142 - atomic_add(pa->pa_free, &sbi->s_mb_preallocated);
56143 + atomic_add_unchecked(pa->pa_free, &sbi->s_mb_preallocated);
56144
56145 ei = EXT4_I(ac->ac_inode);
56146 grp = ext4_get_group_info(sb, ac->ac_b_ex.fe_group);
56147 @@ -3638,7 +3638,7 @@ ext4_mb_new_group_pa(struct ext4_allocation_context *ac)
56148 trace_ext4_mb_new_group_pa(ac, pa);
56149
56150 ext4_mb_use_group_pa(ac, pa);
56151 - atomic_add(pa->pa_free, &EXT4_SB(sb)->s_mb_preallocated);
56152 + atomic_add_unchecked(pa->pa_free, &EXT4_SB(sb)->s_mb_preallocated);
56153
56154 grp = ext4_get_group_info(sb, ac->ac_b_ex.fe_group);
56155 lg = ac->ac_lg;
56156 @@ -3727,7 +3727,7 @@ ext4_mb_release_inode_pa(struct ext4_buddy *e4b, struct buffer_head *bitmap_bh,
56157 * from the bitmap and continue.
56158 */
56159 }
56160 - atomic_add(free, &sbi->s_mb_discarded);
56161 + atomic_add_unchecked(free, &sbi->s_mb_discarded);
56162
56163 return err;
56164 }
56165 @@ -3745,7 +3745,7 @@ ext4_mb_release_group_pa(struct ext4_buddy *e4b,
56166 ext4_get_group_no_and_offset(sb, pa->pa_pstart, &group, &bit);
56167 BUG_ON(group != e4b->bd_group && pa->pa_len != 0);
56168 mb_free_blocks(pa->pa_inode, e4b, bit, pa->pa_len);
56169 - atomic_add(pa->pa_len, &EXT4_SB(sb)->s_mb_discarded);
56170 + atomic_add_unchecked(pa->pa_len, &EXT4_SB(sb)->s_mb_discarded);
56171 trace_ext4_mballoc_discard(sb, NULL, group, bit, pa->pa_len);
56172
56173 return 0;
56174 diff --git a/fs/ext4/mmp.c b/fs/ext4/mmp.c
56175 index 214461e..3614c89 100644
56176 --- a/fs/ext4/mmp.c
56177 +++ b/fs/ext4/mmp.c
56178 @@ -113,7 +113,7 @@ static int read_mmp_block(struct super_block *sb, struct buffer_head **bh,
56179 void __dump_mmp_msg(struct super_block *sb, struct mmp_struct *mmp,
56180 const char *function, unsigned int line, const char *msg)
56181 {
56182 - __ext4_warning(sb, function, line, msg);
56183 + __ext4_warning(sb, function, line, "%s", msg);
56184 __ext4_warning(sb, function, line,
56185 "MMP failure info: last update time: %llu, last update "
56186 "node: %s, last update device: %s\n",
56187 diff --git a/fs/ext4/super.c b/fs/ext4/super.c
56188 index 2c2e6cb..7c3ee62 100644
56189 --- a/fs/ext4/super.c
56190 +++ b/fs/ext4/super.c
56191 @@ -1251,7 +1251,7 @@ static ext4_fsblk_t get_sb_block(void **data)
56192 }
56193
56194 #define DEFAULT_JOURNAL_IOPRIO (IOPRIO_PRIO_VALUE(IOPRIO_CLASS_BE, 3))
56195 -static char deprecated_msg[] = "Mount option \"%s\" will be removed by %s\n"
56196 +static const char deprecated_msg[] = "Mount option \"%s\" will be removed by %s\n"
56197 "Contact linux-ext4@vger.kernel.org if you think we should keep it.\n";
56198
56199 #ifdef CONFIG_QUOTA
56200 @@ -2431,7 +2431,7 @@ struct ext4_attr {
56201 int offset;
56202 int deprecated_val;
56203 } u;
56204 -};
56205 +} __do_const;
56206
56207 static int parse_strtoull(const char *buf,
56208 unsigned long long max, unsigned long long *value)
56209 diff --git a/fs/ext4/xattr.c b/fs/ext4/xattr.c
56210 index 1423c48..9c0c6dc 100644
56211 --- a/fs/ext4/xattr.c
56212 +++ b/fs/ext4/xattr.c
56213 @@ -381,7 +381,7 @@ static int
56214 ext4_xattr_list_entries(struct dentry *dentry, struct ext4_xattr_entry *entry,
56215 char *buffer, size_t buffer_size)
56216 {
56217 - size_t rest = buffer_size;
56218 + size_t rest = buffer_size, total_size = 0;
56219
56220 for (; !IS_LAST_ENTRY(entry); entry = EXT4_XATTR_NEXT(entry)) {
56221 const struct xattr_handler *handler =
56222 @@ -398,9 +398,10 @@ ext4_xattr_list_entries(struct dentry *dentry, struct ext4_xattr_entry *entry,
56223 buffer += size;
56224 }
56225 rest -= size;
56226 + total_size += size;
56227 }
56228 }
56229 - return buffer_size - rest;
56230 + return total_size;
56231 }
56232
56233 static int
56234 diff --git a/fs/fcntl.c b/fs/fcntl.c
56235 index 65343c3..9969dcf 100644
56236 --- a/fs/fcntl.c
56237 +++ b/fs/fcntl.c
56238 @@ -107,6 +107,11 @@ int __f_setown(struct file *filp, struct pid *pid, enum pid_type type,
56239 if (err)
56240 return err;
56241
56242 + if (gr_handle_chroot_fowner(pid, type))
56243 + return -ENOENT;
56244 + if (gr_check_protected_task_fowner(pid, type))
56245 + return -EACCES;
56246 +
56247 f_modown(filp, pid, type, force);
56248 return 0;
56249 }
56250 diff --git a/fs/fhandle.c b/fs/fhandle.c
56251 index 999ff5c..41f4109 100644
56252 --- a/fs/fhandle.c
56253 +++ b/fs/fhandle.c
56254 @@ -67,8 +67,7 @@ static long do_sys_name_to_handle(struct path *path,
56255 } else
56256 retval = 0;
56257 /* copy the mount id */
56258 - if (copy_to_user(mnt_id, &real_mount(path->mnt)->mnt_id,
56259 - sizeof(*mnt_id)) ||
56260 + if (put_user(real_mount(path->mnt)->mnt_id, mnt_id) ||
56261 copy_to_user(ufh, handle,
56262 sizeof(struct file_handle) + handle_bytes))
56263 retval = -EFAULT;
56264 diff --git a/fs/file.c b/fs/file.c
56265 index 4a78f98..9447397 100644
56266 --- a/fs/file.c
56267 +++ b/fs/file.c
56268 @@ -16,6 +16,7 @@
56269 #include <linux/slab.h>
56270 #include <linux/vmalloc.h>
56271 #include <linux/file.h>
56272 +#include <linux/security.h>
56273 #include <linux/fdtable.h>
56274 #include <linux/bitops.h>
56275 #include <linux/interrupt.h>
56276 @@ -828,6 +829,7 @@ int replace_fd(unsigned fd, struct file *file, unsigned flags)
56277 if (!file)
56278 return __close_fd(files, fd);
56279
56280 + gr_learn_resource(current, RLIMIT_NOFILE, fd, 0);
56281 if (fd >= rlimit(RLIMIT_NOFILE))
56282 return -EBADF;
56283
56284 @@ -854,6 +856,7 @@ SYSCALL_DEFINE3(dup3, unsigned int, oldfd, unsigned int, newfd, int, flags)
56285 if (unlikely(oldfd == newfd))
56286 return -EINVAL;
56287
56288 + gr_learn_resource(current, RLIMIT_NOFILE, newfd, 0);
56289 if (newfd >= rlimit(RLIMIT_NOFILE))
56290 return -EBADF;
56291
56292 @@ -909,6 +912,7 @@ SYSCALL_DEFINE1(dup, unsigned int, fildes)
56293 int f_dupfd(unsigned int from, struct file *file, unsigned flags)
56294 {
56295 int err;
56296 + gr_learn_resource(current, RLIMIT_NOFILE, from, 0);
56297 if (from >= rlimit(RLIMIT_NOFILE))
56298 return -EINVAL;
56299 err = alloc_fd(from, flags);
56300 diff --git a/fs/filesystems.c b/fs/filesystems.c
56301 index 92567d9..fcd8cbf 100644
56302 --- a/fs/filesystems.c
56303 +++ b/fs/filesystems.c
56304 @@ -273,7 +273,11 @@ struct file_system_type *get_fs_type(const char *name)
56305 int len = dot ? dot - name : strlen(name);
56306
56307 fs = __get_fs_type(name, len);
56308 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
56309 + if (!fs && (___request_module(true, "grsec_modharden_fs", "fs-%.*s", len, name) == 0))
56310 +#else
56311 if (!fs && (request_module("fs-%.*s", len, name) == 0))
56312 +#endif
56313 fs = __get_fs_type(name, len);
56314
56315 if (dot && fs && !(fs->fs_flags & FS_HAS_SUBTYPE)) {
56316 diff --git a/fs/fs_struct.c b/fs/fs_struct.c
56317 index d8ac61d..79a36f0 100644
56318 --- a/fs/fs_struct.c
56319 +++ b/fs/fs_struct.c
56320 @@ -4,6 +4,7 @@
56321 #include <linux/path.h>
56322 #include <linux/slab.h>
56323 #include <linux/fs_struct.h>
56324 +#include <linux/grsecurity.h>
56325 #include "internal.h"
56326
56327 /*
56328 @@ -19,6 +20,7 @@ void set_fs_root(struct fs_struct *fs, const struct path *path)
56329 write_seqcount_begin(&fs->seq);
56330 old_root = fs->root;
56331 fs->root = *path;
56332 + gr_set_chroot_entries(current, path);
56333 write_seqcount_end(&fs->seq);
56334 spin_unlock(&fs->lock);
56335 if (old_root.dentry)
56336 @@ -67,6 +69,10 @@ void chroot_fs_refs(const struct path *old_root, const struct path *new_root)
56337 int hits = 0;
56338 spin_lock(&fs->lock);
56339 write_seqcount_begin(&fs->seq);
56340 + /* this root replacement is only done by pivot_root,
56341 + leave grsec's chroot tagging alone for this task
56342 + so that a pivoted root isn't treated as a chroot
56343 + */
56344 hits += replace_path(&fs->root, old_root, new_root);
56345 hits += replace_path(&fs->pwd, old_root, new_root);
56346 write_seqcount_end(&fs->seq);
56347 @@ -99,7 +105,8 @@ void exit_fs(struct task_struct *tsk)
56348 task_lock(tsk);
56349 spin_lock(&fs->lock);
56350 tsk->fs = NULL;
56351 - kill = !--fs->users;
56352 + gr_clear_chroot_entries(tsk);
56353 + kill = !atomic_dec_return(&fs->users);
56354 spin_unlock(&fs->lock);
56355 task_unlock(tsk);
56356 if (kill)
56357 @@ -112,7 +119,7 @@ struct fs_struct *copy_fs_struct(struct fs_struct *old)
56358 struct fs_struct *fs = kmem_cache_alloc(fs_cachep, GFP_KERNEL);
56359 /* We don't need to lock fs - think why ;-) */
56360 if (fs) {
56361 - fs->users = 1;
56362 + atomic_set(&fs->users, 1);
56363 fs->in_exec = 0;
56364 spin_lock_init(&fs->lock);
56365 seqcount_init(&fs->seq);
56366 @@ -121,6 +128,9 @@ struct fs_struct *copy_fs_struct(struct fs_struct *old)
56367 spin_lock(&old->lock);
56368 fs->root = old->root;
56369 path_get(&fs->root);
56370 + /* instead of calling gr_set_chroot_entries here,
56371 + we call it from every caller of this function
56372 + */
56373 fs->pwd = old->pwd;
56374 path_get(&fs->pwd);
56375 spin_unlock(&old->lock);
56376 @@ -139,8 +149,9 @@ int unshare_fs_struct(void)
56377
56378 task_lock(current);
56379 spin_lock(&fs->lock);
56380 - kill = !--fs->users;
56381 + kill = !atomic_dec_return(&fs->users);
56382 current->fs = new_fs;
56383 + gr_set_chroot_entries(current, &new_fs->root);
56384 spin_unlock(&fs->lock);
56385 task_unlock(current);
56386
56387 @@ -153,13 +164,13 @@ EXPORT_SYMBOL_GPL(unshare_fs_struct);
56388
56389 int current_umask(void)
56390 {
56391 - return current->fs->umask;
56392 + return current->fs->umask | gr_acl_umask();
56393 }
56394 EXPORT_SYMBOL(current_umask);
56395
56396 /* to be mentioned only in INIT_TASK */
56397 struct fs_struct init_fs = {
56398 - .users = 1,
56399 + .users = ATOMIC_INIT(1),
56400 .lock = __SPIN_LOCK_UNLOCKED(init_fs.lock),
56401 .seq = SEQCNT_ZERO,
56402 .umask = 0022,
56403 diff --git a/fs/fscache/cookie.c b/fs/fscache/cookie.c
56404 index b2a86e3..37f425a 100644
56405 --- a/fs/fscache/cookie.c
56406 +++ b/fs/fscache/cookie.c
56407 @@ -19,7 +19,7 @@
56408
56409 struct kmem_cache *fscache_cookie_jar;
56410
56411 -static atomic_t fscache_object_debug_id = ATOMIC_INIT(0);
56412 +static atomic_unchecked_t fscache_object_debug_id = ATOMIC_INIT(0);
56413
56414 static int fscache_acquire_non_index_cookie(struct fscache_cookie *cookie);
56415 static int fscache_alloc_object(struct fscache_cache *cache,
56416 @@ -68,11 +68,11 @@ struct fscache_cookie *__fscache_acquire_cookie(
56417 parent ? (char *) parent->def->name : "<no-parent>",
56418 def->name, netfs_data);
56419
56420 - fscache_stat(&fscache_n_acquires);
56421 + fscache_stat_unchecked(&fscache_n_acquires);
56422
56423 /* if there's no parent cookie, then we don't create one here either */
56424 if (!parent) {
56425 - fscache_stat(&fscache_n_acquires_null);
56426 + fscache_stat_unchecked(&fscache_n_acquires_null);
56427 _leave(" [no parent]");
56428 return NULL;
56429 }
56430 @@ -87,7 +87,7 @@ struct fscache_cookie *__fscache_acquire_cookie(
56431 /* allocate and initialise a cookie */
56432 cookie = kmem_cache_alloc(fscache_cookie_jar, GFP_KERNEL);
56433 if (!cookie) {
56434 - fscache_stat(&fscache_n_acquires_oom);
56435 + fscache_stat_unchecked(&fscache_n_acquires_oom);
56436 _leave(" [ENOMEM]");
56437 return NULL;
56438 }
56439 @@ -114,13 +114,13 @@ struct fscache_cookie *__fscache_acquire_cookie(
56440
56441 switch (cookie->def->type) {
56442 case FSCACHE_COOKIE_TYPE_INDEX:
56443 - fscache_stat(&fscache_n_cookie_index);
56444 + fscache_stat_unchecked(&fscache_n_cookie_index);
56445 break;
56446 case FSCACHE_COOKIE_TYPE_DATAFILE:
56447 - fscache_stat(&fscache_n_cookie_data);
56448 + fscache_stat_unchecked(&fscache_n_cookie_data);
56449 break;
56450 default:
56451 - fscache_stat(&fscache_n_cookie_special);
56452 + fscache_stat_unchecked(&fscache_n_cookie_special);
56453 break;
56454 }
56455
56456 @@ -131,13 +131,13 @@ struct fscache_cookie *__fscache_acquire_cookie(
56457 if (fscache_acquire_non_index_cookie(cookie) < 0) {
56458 atomic_dec(&parent->n_children);
56459 __fscache_cookie_put(cookie);
56460 - fscache_stat(&fscache_n_acquires_nobufs);
56461 + fscache_stat_unchecked(&fscache_n_acquires_nobufs);
56462 _leave(" = NULL");
56463 return NULL;
56464 }
56465 }
56466
56467 - fscache_stat(&fscache_n_acquires_ok);
56468 + fscache_stat_unchecked(&fscache_n_acquires_ok);
56469 _leave(" = %p", cookie);
56470 return cookie;
56471 }
56472 @@ -173,7 +173,7 @@ static int fscache_acquire_non_index_cookie(struct fscache_cookie *cookie)
56473 cache = fscache_select_cache_for_object(cookie->parent);
56474 if (!cache) {
56475 up_read(&fscache_addremove_sem);
56476 - fscache_stat(&fscache_n_acquires_no_cache);
56477 + fscache_stat_unchecked(&fscache_n_acquires_no_cache);
56478 _leave(" = -ENOMEDIUM [no cache]");
56479 return -ENOMEDIUM;
56480 }
56481 @@ -259,14 +259,14 @@ static int fscache_alloc_object(struct fscache_cache *cache,
56482 object = cache->ops->alloc_object(cache, cookie);
56483 fscache_stat_d(&fscache_n_cop_alloc_object);
56484 if (IS_ERR(object)) {
56485 - fscache_stat(&fscache_n_object_no_alloc);
56486 + fscache_stat_unchecked(&fscache_n_object_no_alloc);
56487 ret = PTR_ERR(object);
56488 goto error;
56489 }
56490
56491 - fscache_stat(&fscache_n_object_alloc);
56492 + fscache_stat_unchecked(&fscache_n_object_alloc);
56493
56494 - object->debug_id = atomic_inc_return(&fscache_object_debug_id);
56495 + object->debug_id = atomic_inc_return_unchecked(&fscache_object_debug_id);
56496
56497 _debug("ALLOC OBJ%x: %s {%lx}",
56498 object->debug_id, cookie->def->name, object->events);
56499 @@ -380,7 +380,7 @@ void __fscache_invalidate(struct fscache_cookie *cookie)
56500
56501 _enter("{%s}", cookie->def->name);
56502
56503 - fscache_stat(&fscache_n_invalidates);
56504 + fscache_stat_unchecked(&fscache_n_invalidates);
56505
56506 /* Only permit invalidation of data files. Invalidating an index will
56507 * require the caller to release all its attachments to the tree rooted
56508 @@ -438,10 +438,10 @@ void __fscache_update_cookie(struct fscache_cookie *cookie)
56509 {
56510 struct fscache_object *object;
56511
56512 - fscache_stat(&fscache_n_updates);
56513 + fscache_stat_unchecked(&fscache_n_updates);
56514
56515 if (!cookie) {
56516 - fscache_stat(&fscache_n_updates_null);
56517 + fscache_stat_unchecked(&fscache_n_updates_null);
56518 _leave(" [no cookie]");
56519 return;
56520 }
56521 @@ -473,12 +473,12 @@ void __fscache_relinquish_cookie(struct fscache_cookie *cookie, int retire)
56522 {
56523 struct fscache_object *object;
56524
56525 - fscache_stat(&fscache_n_relinquishes);
56526 + fscache_stat_unchecked(&fscache_n_relinquishes);
56527 if (retire)
56528 - fscache_stat(&fscache_n_relinquishes_retire);
56529 + fscache_stat_unchecked(&fscache_n_relinquishes_retire);
56530
56531 if (!cookie) {
56532 - fscache_stat(&fscache_n_relinquishes_null);
56533 + fscache_stat_unchecked(&fscache_n_relinquishes_null);
56534 _leave(" [no cookie]");
56535 return;
56536 }
56537 @@ -598,7 +598,7 @@ int __fscache_check_consistency(struct fscache_cookie *cookie)
56538 if (test_bit(FSCACHE_IOERROR, &object->cache->flags))
56539 goto inconsistent;
56540
56541 - op->debug_id = atomic_inc_return(&fscache_op_debug_id);
56542 + op->debug_id = atomic_inc_return_unchecked(&fscache_op_debug_id);
56543
56544 atomic_inc(&cookie->n_active);
56545 if (fscache_submit_op(object, op) < 0)
56546 diff --git a/fs/fscache/internal.h b/fs/fscache/internal.h
56547 index 4226f66..0fb3f45 100644
56548 --- a/fs/fscache/internal.h
56549 +++ b/fs/fscache/internal.h
56550 @@ -133,8 +133,8 @@ extern void fscache_operation_gc(struct work_struct *);
56551 extern int fscache_wait_for_deferred_lookup(struct fscache_cookie *);
56552 extern int fscache_wait_for_operation_activation(struct fscache_object *,
56553 struct fscache_operation *,
56554 - atomic_t *,
56555 - atomic_t *,
56556 + atomic_unchecked_t *,
56557 + atomic_unchecked_t *,
56558 void (*)(struct fscache_operation *));
56559 extern void fscache_invalidate_writes(struct fscache_cookie *);
56560
56561 @@ -153,101 +153,101 @@ extern void fscache_proc_cleanup(void);
56562 * stats.c
56563 */
56564 #ifdef CONFIG_FSCACHE_STATS
56565 -extern atomic_t fscache_n_ops_processed[FSCACHE_MAX_THREADS];
56566 -extern atomic_t fscache_n_objs_processed[FSCACHE_MAX_THREADS];
56567 +extern atomic_unchecked_t fscache_n_ops_processed[FSCACHE_MAX_THREADS];
56568 +extern atomic_unchecked_t fscache_n_objs_processed[FSCACHE_MAX_THREADS];
56569
56570 -extern atomic_t fscache_n_op_pend;
56571 -extern atomic_t fscache_n_op_run;
56572 -extern atomic_t fscache_n_op_enqueue;
56573 -extern atomic_t fscache_n_op_deferred_release;
56574 -extern atomic_t fscache_n_op_release;
56575 -extern atomic_t fscache_n_op_gc;
56576 -extern atomic_t fscache_n_op_cancelled;
56577 -extern atomic_t fscache_n_op_rejected;
56578 +extern atomic_unchecked_t fscache_n_op_pend;
56579 +extern atomic_unchecked_t fscache_n_op_run;
56580 +extern atomic_unchecked_t fscache_n_op_enqueue;
56581 +extern atomic_unchecked_t fscache_n_op_deferred_release;
56582 +extern atomic_unchecked_t fscache_n_op_release;
56583 +extern atomic_unchecked_t fscache_n_op_gc;
56584 +extern atomic_unchecked_t fscache_n_op_cancelled;
56585 +extern atomic_unchecked_t fscache_n_op_rejected;
56586
56587 -extern atomic_t fscache_n_attr_changed;
56588 -extern atomic_t fscache_n_attr_changed_ok;
56589 -extern atomic_t fscache_n_attr_changed_nobufs;
56590 -extern atomic_t fscache_n_attr_changed_nomem;
56591 -extern atomic_t fscache_n_attr_changed_calls;
56592 +extern atomic_unchecked_t fscache_n_attr_changed;
56593 +extern atomic_unchecked_t fscache_n_attr_changed_ok;
56594 +extern atomic_unchecked_t fscache_n_attr_changed_nobufs;
56595 +extern atomic_unchecked_t fscache_n_attr_changed_nomem;
56596 +extern atomic_unchecked_t fscache_n_attr_changed_calls;
56597
56598 -extern atomic_t fscache_n_allocs;
56599 -extern atomic_t fscache_n_allocs_ok;
56600 -extern atomic_t fscache_n_allocs_wait;
56601 -extern atomic_t fscache_n_allocs_nobufs;
56602 -extern atomic_t fscache_n_allocs_intr;
56603 -extern atomic_t fscache_n_allocs_object_dead;
56604 -extern atomic_t fscache_n_alloc_ops;
56605 -extern atomic_t fscache_n_alloc_op_waits;
56606 +extern atomic_unchecked_t fscache_n_allocs;
56607 +extern atomic_unchecked_t fscache_n_allocs_ok;
56608 +extern atomic_unchecked_t fscache_n_allocs_wait;
56609 +extern atomic_unchecked_t fscache_n_allocs_nobufs;
56610 +extern atomic_unchecked_t fscache_n_allocs_intr;
56611 +extern atomic_unchecked_t fscache_n_allocs_object_dead;
56612 +extern atomic_unchecked_t fscache_n_alloc_ops;
56613 +extern atomic_unchecked_t fscache_n_alloc_op_waits;
56614
56615 -extern atomic_t fscache_n_retrievals;
56616 -extern atomic_t fscache_n_retrievals_ok;
56617 -extern atomic_t fscache_n_retrievals_wait;
56618 -extern atomic_t fscache_n_retrievals_nodata;
56619 -extern atomic_t fscache_n_retrievals_nobufs;
56620 -extern atomic_t fscache_n_retrievals_intr;
56621 -extern atomic_t fscache_n_retrievals_nomem;
56622 -extern atomic_t fscache_n_retrievals_object_dead;
56623 -extern atomic_t fscache_n_retrieval_ops;
56624 -extern atomic_t fscache_n_retrieval_op_waits;
56625 +extern atomic_unchecked_t fscache_n_retrievals;
56626 +extern atomic_unchecked_t fscache_n_retrievals_ok;
56627 +extern atomic_unchecked_t fscache_n_retrievals_wait;
56628 +extern atomic_unchecked_t fscache_n_retrievals_nodata;
56629 +extern atomic_unchecked_t fscache_n_retrievals_nobufs;
56630 +extern atomic_unchecked_t fscache_n_retrievals_intr;
56631 +extern atomic_unchecked_t fscache_n_retrievals_nomem;
56632 +extern atomic_unchecked_t fscache_n_retrievals_object_dead;
56633 +extern atomic_unchecked_t fscache_n_retrieval_ops;
56634 +extern atomic_unchecked_t fscache_n_retrieval_op_waits;
56635
56636 -extern atomic_t fscache_n_stores;
56637 -extern atomic_t fscache_n_stores_ok;
56638 -extern atomic_t fscache_n_stores_again;
56639 -extern atomic_t fscache_n_stores_nobufs;
56640 -extern atomic_t fscache_n_stores_oom;
56641 -extern atomic_t fscache_n_store_ops;
56642 -extern atomic_t fscache_n_store_calls;
56643 -extern atomic_t fscache_n_store_pages;
56644 -extern atomic_t fscache_n_store_radix_deletes;
56645 -extern atomic_t fscache_n_store_pages_over_limit;
56646 +extern atomic_unchecked_t fscache_n_stores;
56647 +extern atomic_unchecked_t fscache_n_stores_ok;
56648 +extern atomic_unchecked_t fscache_n_stores_again;
56649 +extern atomic_unchecked_t fscache_n_stores_nobufs;
56650 +extern atomic_unchecked_t fscache_n_stores_oom;
56651 +extern atomic_unchecked_t fscache_n_store_ops;
56652 +extern atomic_unchecked_t fscache_n_store_calls;
56653 +extern atomic_unchecked_t fscache_n_store_pages;
56654 +extern atomic_unchecked_t fscache_n_store_radix_deletes;
56655 +extern atomic_unchecked_t fscache_n_store_pages_over_limit;
56656
56657 -extern atomic_t fscache_n_store_vmscan_not_storing;
56658 -extern atomic_t fscache_n_store_vmscan_gone;
56659 -extern atomic_t fscache_n_store_vmscan_busy;
56660 -extern atomic_t fscache_n_store_vmscan_cancelled;
56661 -extern atomic_t fscache_n_store_vmscan_wait;
56662 +extern atomic_unchecked_t fscache_n_store_vmscan_not_storing;
56663 +extern atomic_unchecked_t fscache_n_store_vmscan_gone;
56664 +extern atomic_unchecked_t fscache_n_store_vmscan_busy;
56665 +extern atomic_unchecked_t fscache_n_store_vmscan_cancelled;
56666 +extern atomic_unchecked_t fscache_n_store_vmscan_wait;
56667
56668 -extern atomic_t fscache_n_marks;
56669 -extern atomic_t fscache_n_uncaches;
56670 +extern atomic_unchecked_t fscache_n_marks;
56671 +extern atomic_unchecked_t fscache_n_uncaches;
56672
56673 -extern atomic_t fscache_n_acquires;
56674 -extern atomic_t fscache_n_acquires_null;
56675 -extern atomic_t fscache_n_acquires_no_cache;
56676 -extern atomic_t fscache_n_acquires_ok;
56677 -extern atomic_t fscache_n_acquires_nobufs;
56678 -extern atomic_t fscache_n_acquires_oom;
56679 +extern atomic_unchecked_t fscache_n_acquires;
56680 +extern atomic_unchecked_t fscache_n_acquires_null;
56681 +extern atomic_unchecked_t fscache_n_acquires_no_cache;
56682 +extern atomic_unchecked_t fscache_n_acquires_ok;
56683 +extern atomic_unchecked_t fscache_n_acquires_nobufs;
56684 +extern atomic_unchecked_t fscache_n_acquires_oom;
56685
56686 -extern atomic_t fscache_n_invalidates;
56687 -extern atomic_t fscache_n_invalidates_run;
56688 +extern atomic_unchecked_t fscache_n_invalidates;
56689 +extern atomic_unchecked_t fscache_n_invalidates_run;
56690
56691 -extern atomic_t fscache_n_updates;
56692 -extern atomic_t fscache_n_updates_null;
56693 -extern atomic_t fscache_n_updates_run;
56694 +extern atomic_unchecked_t fscache_n_updates;
56695 +extern atomic_unchecked_t fscache_n_updates_null;
56696 +extern atomic_unchecked_t fscache_n_updates_run;
56697
56698 -extern atomic_t fscache_n_relinquishes;
56699 -extern atomic_t fscache_n_relinquishes_null;
56700 -extern atomic_t fscache_n_relinquishes_waitcrt;
56701 -extern atomic_t fscache_n_relinquishes_retire;
56702 +extern atomic_unchecked_t fscache_n_relinquishes;
56703 +extern atomic_unchecked_t fscache_n_relinquishes_null;
56704 +extern atomic_unchecked_t fscache_n_relinquishes_waitcrt;
56705 +extern atomic_unchecked_t fscache_n_relinquishes_retire;
56706
56707 -extern atomic_t fscache_n_cookie_index;
56708 -extern atomic_t fscache_n_cookie_data;
56709 -extern atomic_t fscache_n_cookie_special;
56710 +extern atomic_unchecked_t fscache_n_cookie_index;
56711 +extern atomic_unchecked_t fscache_n_cookie_data;
56712 +extern atomic_unchecked_t fscache_n_cookie_special;
56713
56714 -extern atomic_t fscache_n_object_alloc;
56715 -extern atomic_t fscache_n_object_no_alloc;
56716 -extern atomic_t fscache_n_object_lookups;
56717 -extern atomic_t fscache_n_object_lookups_negative;
56718 -extern atomic_t fscache_n_object_lookups_positive;
56719 -extern atomic_t fscache_n_object_lookups_timed_out;
56720 -extern atomic_t fscache_n_object_created;
56721 -extern atomic_t fscache_n_object_avail;
56722 -extern atomic_t fscache_n_object_dead;
56723 +extern atomic_unchecked_t fscache_n_object_alloc;
56724 +extern atomic_unchecked_t fscache_n_object_no_alloc;
56725 +extern atomic_unchecked_t fscache_n_object_lookups;
56726 +extern atomic_unchecked_t fscache_n_object_lookups_negative;
56727 +extern atomic_unchecked_t fscache_n_object_lookups_positive;
56728 +extern atomic_unchecked_t fscache_n_object_lookups_timed_out;
56729 +extern atomic_unchecked_t fscache_n_object_created;
56730 +extern atomic_unchecked_t fscache_n_object_avail;
56731 +extern atomic_unchecked_t fscache_n_object_dead;
56732
56733 -extern atomic_t fscache_n_checkaux_none;
56734 -extern atomic_t fscache_n_checkaux_okay;
56735 -extern atomic_t fscache_n_checkaux_update;
56736 -extern atomic_t fscache_n_checkaux_obsolete;
56737 +extern atomic_unchecked_t fscache_n_checkaux_none;
56738 +extern atomic_unchecked_t fscache_n_checkaux_okay;
56739 +extern atomic_unchecked_t fscache_n_checkaux_update;
56740 +extern atomic_unchecked_t fscache_n_checkaux_obsolete;
56741
56742 extern atomic_t fscache_n_cop_alloc_object;
56743 extern atomic_t fscache_n_cop_lookup_object;
56744 @@ -272,6 +272,11 @@ static inline void fscache_stat(atomic_t *stat)
56745 atomic_inc(stat);
56746 }
56747
56748 +static inline void fscache_stat_unchecked(atomic_unchecked_t *stat)
56749 +{
56750 + atomic_inc_unchecked(stat);
56751 +}
56752 +
56753 static inline void fscache_stat_d(atomic_t *stat)
56754 {
56755 atomic_dec(stat);
56756 @@ -284,6 +289,7 @@ extern const struct file_operations fscache_stats_fops;
56757
56758 #define __fscache_stat(stat) (NULL)
56759 #define fscache_stat(stat) do {} while (0)
56760 +#define fscache_stat_unchecked(stat) do {} while (0)
56761 #define fscache_stat_d(stat) do {} while (0)
56762 #endif
56763
56764 diff --git a/fs/fscache/object.c b/fs/fscache/object.c
56765 index 86d75a6..5f3d7a0 100644
56766 --- a/fs/fscache/object.c
56767 +++ b/fs/fscache/object.c
56768 @@ -451,7 +451,7 @@ static const struct fscache_state *fscache_look_up_object(struct fscache_object
56769 _debug("LOOKUP \"%s\" in \"%s\"",
56770 cookie->def->name, object->cache->tag->name);
56771
56772 - fscache_stat(&fscache_n_object_lookups);
56773 + fscache_stat_unchecked(&fscache_n_object_lookups);
56774 fscache_stat(&fscache_n_cop_lookup_object);
56775 ret = object->cache->ops->lookup_object(object);
56776 fscache_stat_d(&fscache_n_cop_lookup_object);
56777 @@ -461,7 +461,7 @@ static const struct fscache_state *fscache_look_up_object(struct fscache_object
56778 if (ret == -ETIMEDOUT) {
56779 /* probably stuck behind another object, so move this one to
56780 * the back of the queue */
56781 - fscache_stat(&fscache_n_object_lookups_timed_out);
56782 + fscache_stat_unchecked(&fscache_n_object_lookups_timed_out);
56783 _leave(" [timeout]");
56784 return NO_TRANSIT;
56785 }
56786 @@ -489,7 +489,7 @@ void fscache_object_lookup_negative(struct fscache_object *object)
56787 _enter("{OBJ%x,%s}", object->debug_id, object->state->name);
56788
56789 if (!test_and_set_bit(FSCACHE_OBJECT_IS_LOOKED_UP, &object->flags)) {
56790 - fscache_stat(&fscache_n_object_lookups_negative);
56791 + fscache_stat_unchecked(&fscache_n_object_lookups_negative);
56792
56793 /* Allow write requests to begin stacking up and read requests to begin
56794 * returning ENODATA.
56795 @@ -523,7 +523,7 @@ void fscache_obtained_object(struct fscache_object *object)
56796 /* if we were still looking up, then we must have a positive lookup
56797 * result, in which case there may be data available */
56798 if (!test_and_set_bit(FSCACHE_OBJECT_IS_LOOKED_UP, &object->flags)) {
56799 - fscache_stat(&fscache_n_object_lookups_positive);
56800 + fscache_stat_unchecked(&fscache_n_object_lookups_positive);
56801
56802 /* We do (presumably) have data */
56803 clear_bit_unlock(FSCACHE_COOKIE_NO_DATA_YET, &cookie->flags);
56804 @@ -534,7 +534,7 @@ void fscache_obtained_object(struct fscache_object *object)
56805 clear_bit_unlock(FSCACHE_COOKIE_LOOKING_UP, &cookie->flags);
56806 wake_up_bit(&cookie->flags, FSCACHE_COOKIE_LOOKING_UP);
56807 } else {
56808 - fscache_stat(&fscache_n_object_created);
56809 + fscache_stat_unchecked(&fscache_n_object_created);
56810 }
56811
56812 set_bit(FSCACHE_OBJECT_IS_AVAILABLE, &object->flags);
56813 @@ -570,7 +570,7 @@ static const struct fscache_state *fscache_object_available(struct fscache_objec
56814 fscache_stat_d(&fscache_n_cop_lookup_complete);
56815
56816 fscache_hist(fscache_obj_instantiate_histogram, object->lookup_jif);
56817 - fscache_stat(&fscache_n_object_avail);
56818 + fscache_stat_unchecked(&fscache_n_object_avail);
56819
56820 _leave("");
56821 return transit_to(JUMPSTART_DEPS);
56822 @@ -716,7 +716,7 @@ static const struct fscache_state *fscache_drop_object(struct fscache_object *ob
56823
56824 /* this just shifts the object release to the work processor */
56825 fscache_put_object(object);
56826 - fscache_stat(&fscache_n_object_dead);
56827 + fscache_stat_unchecked(&fscache_n_object_dead);
56828
56829 _leave("");
56830 return transit_to(OBJECT_DEAD);
56831 @@ -881,7 +881,7 @@ enum fscache_checkaux fscache_check_aux(struct fscache_object *object,
56832 enum fscache_checkaux result;
56833
56834 if (!object->cookie->def->check_aux) {
56835 - fscache_stat(&fscache_n_checkaux_none);
56836 + fscache_stat_unchecked(&fscache_n_checkaux_none);
56837 return FSCACHE_CHECKAUX_OKAY;
56838 }
56839
56840 @@ -890,17 +890,17 @@ enum fscache_checkaux fscache_check_aux(struct fscache_object *object,
56841 switch (result) {
56842 /* entry okay as is */
56843 case FSCACHE_CHECKAUX_OKAY:
56844 - fscache_stat(&fscache_n_checkaux_okay);
56845 + fscache_stat_unchecked(&fscache_n_checkaux_okay);
56846 break;
56847
56848 /* entry requires update */
56849 case FSCACHE_CHECKAUX_NEEDS_UPDATE:
56850 - fscache_stat(&fscache_n_checkaux_update);
56851 + fscache_stat_unchecked(&fscache_n_checkaux_update);
56852 break;
56853
56854 /* entry requires deletion */
56855 case FSCACHE_CHECKAUX_OBSOLETE:
56856 - fscache_stat(&fscache_n_checkaux_obsolete);
56857 + fscache_stat_unchecked(&fscache_n_checkaux_obsolete);
56858 break;
56859
56860 default:
56861 @@ -986,7 +986,7 @@ static const struct fscache_state *fscache_invalidate_object(struct fscache_obje
56862 {
56863 const struct fscache_state *s;
56864
56865 - fscache_stat(&fscache_n_invalidates_run);
56866 + fscache_stat_unchecked(&fscache_n_invalidates_run);
56867 fscache_stat(&fscache_n_cop_invalidate_object);
56868 s = _fscache_invalidate_object(object, event);
56869 fscache_stat_d(&fscache_n_cop_invalidate_object);
56870 @@ -1001,7 +1001,7 @@ static const struct fscache_state *fscache_update_object(struct fscache_object *
56871 {
56872 _enter("{OBJ%x},%d", object->debug_id, event);
56873
56874 - fscache_stat(&fscache_n_updates_run);
56875 + fscache_stat_unchecked(&fscache_n_updates_run);
56876 fscache_stat(&fscache_n_cop_update_object);
56877 object->cache->ops->update_object(object);
56878 fscache_stat_d(&fscache_n_cop_update_object);
56879 diff --git a/fs/fscache/operation.c b/fs/fscache/operation.c
56880 index 318071a..379938b 100644
56881 --- a/fs/fscache/operation.c
56882 +++ b/fs/fscache/operation.c
56883 @@ -17,7 +17,7 @@
56884 #include <linux/slab.h>
56885 #include "internal.h"
56886
56887 -atomic_t fscache_op_debug_id;
56888 +atomic_unchecked_t fscache_op_debug_id;
56889 EXPORT_SYMBOL(fscache_op_debug_id);
56890
56891 /**
56892 @@ -39,7 +39,7 @@ void fscache_enqueue_operation(struct fscache_operation *op)
56893 ASSERTCMP(atomic_read(&op->usage), >, 0);
56894 ASSERTCMP(op->state, ==, FSCACHE_OP_ST_IN_PROGRESS);
56895
56896 - fscache_stat(&fscache_n_op_enqueue);
56897 + fscache_stat_unchecked(&fscache_n_op_enqueue);
56898 switch (op->flags & FSCACHE_OP_TYPE) {
56899 case FSCACHE_OP_ASYNC:
56900 _debug("queue async");
56901 @@ -73,7 +73,7 @@ static void fscache_run_op(struct fscache_object *object,
56902 wake_up_bit(&op->flags, FSCACHE_OP_WAITING);
56903 if (op->processor)
56904 fscache_enqueue_operation(op);
56905 - fscache_stat(&fscache_n_op_run);
56906 + fscache_stat_unchecked(&fscache_n_op_run);
56907 }
56908
56909 /*
56910 @@ -105,11 +105,11 @@ int fscache_submit_exclusive_op(struct fscache_object *object,
56911 if (object->n_in_progress > 0) {
56912 atomic_inc(&op->usage);
56913 list_add_tail(&op->pend_link, &object->pending_ops);
56914 - fscache_stat(&fscache_n_op_pend);
56915 + fscache_stat_unchecked(&fscache_n_op_pend);
56916 } else if (!list_empty(&object->pending_ops)) {
56917 atomic_inc(&op->usage);
56918 list_add_tail(&op->pend_link, &object->pending_ops);
56919 - fscache_stat(&fscache_n_op_pend);
56920 + fscache_stat_unchecked(&fscache_n_op_pend);
56921 fscache_start_operations(object);
56922 } else {
56923 ASSERTCMP(object->n_in_progress, ==, 0);
56924 @@ -125,7 +125,7 @@ int fscache_submit_exclusive_op(struct fscache_object *object,
56925 object->n_exclusive++; /* reads and writes must wait */
56926 atomic_inc(&op->usage);
56927 list_add_tail(&op->pend_link, &object->pending_ops);
56928 - fscache_stat(&fscache_n_op_pend);
56929 + fscache_stat_unchecked(&fscache_n_op_pend);
56930 ret = 0;
56931 } else {
56932 /* If we're in any other state, there must have been an I/O
56933 @@ -212,11 +212,11 @@ int fscache_submit_op(struct fscache_object *object,
56934 if (object->n_exclusive > 0) {
56935 atomic_inc(&op->usage);
56936 list_add_tail(&op->pend_link, &object->pending_ops);
56937 - fscache_stat(&fscache_n_op_pend);
56938 + fscache_stat_unchecked(&fscache_n_op_pend);
56939 } else if (!list_empty(&object->pending_ops)) {
56940 atomic_inc(&op->usage);
56941 list_add_tail(&op->pend_link, &object->pending_ops);
56942 - fscache_stat(&fscache_n_op_pend);
56943 + fscache_stat_unchecked(&fscache_n_op_pend);
56944 fscache_start_operations(object);
56945 } else {
56946 ASSERTCMP(object->n_exclusive, ==, 0);
56947 @@ -228,10 +228,10 @@ int fscache_submit_op(struct fscache_object *object,
56948 object->n_ops++;
56949 atomic_inc(&op->usage);
56950 list_add_tail(&op->pend_link, &object->pending_ops);
56951 - fscache_stat(&fscache_n_op_pend);
56952 + fscache_stat_unchecked(&fscache_n_op_pend);
56953 ret = 0;
56954 } else if (fscache_object_is_dying(object)) {
56955 - fscache_stat(&fscache_n_op_rejected);
56956 + fscache_stat_unchecked(&fscache_n_op_rejected);
56957 op->state = FSCACHE_OP_ST_CANCELLED;
56958 ret = -ENOBUFS;
56959 } else if (!test_bit(FSCACHE_IOERROR, &object->cache->flags)) {
56960 @@ -310,7 +310,7 @@ int fscache_cancel_op(struct fscache_operation *op,
56961 ret = -EBUSY;
56962 if (op->state == FSCACHE_OP_ST_PENDING) {
56963 ASSERT(!list_empty(&op->pend_link));
56964 - fscache_stat(&fscache_n_op_cancelled);
56965 + fscache_stat_unchecked(&fscache_n_op_cancelled);
56966 list_del_init(&op->pend_link);
56967 if (do_cancel)
56968 do_cancel(op);
56969 @@ -342,7 +342,7 @@ void fscache_cancel_all_ops(struct fscache_object *object)
56970 while (!list_empty(&object->pending_ops)) {
56971 op = list_entry(object->pending_ops.next,
56972 struct fscache_operation, pend_link);
56973 - fscache_stat(&fscache_n_op_cancelled);
56974 + fscache_stat_unchecked(&fscache_n_op_cancelled);
56975 list_del_init(&op->pend_link);
56976
56977 ASSERTCMP(op->state, ==, FSCACHE_OP_ST_PENDING);
56978 @@ -414,7 +414,7 @@ void fscache_put_operation(struct fscache_operation *op)
56979 op->state, ==, FSCACHE_OP_ST_CANCELLED);
56980 op->state = FSCACHE_OP_ST_DEAD;
56981
56982 - fscache_stat(&fscache_n_op_release);
56983 + fscache_stat_unchecked(&fscache_n_op_release);
56984
56985 if (op->release) {
56986 op->release(op);
56987 @@ -433,7 +433,7 @@ void fscache_put_operation(struct fscache_operation *op)
56988 * lock, and defer it otherwise */
56989 if (!spin_trylock(&object->lock)) {
56990 _debug("defer put");
56991 - fscache_stat(&fscache_n_op_deferred_release);
56992 + fscache_stat_unchecked(&fscache_n_op_deferred_release);
56993
56994 cache = object->cache;
56995 spin_lock(&cache->op_gc_list_lock);
56996 @@ -486,7 +486,7 @@ void fscache_operation_gc(struct work_struct *work)
56997
56998 _debug("GC DEFERRED REL OBJ%x OP%x",
56999 object->debug_id, op->debug_id);
57000 - fscache_stat(&fscache_n_op_gc);
57001 + fscache_stat_unchecked(&fscache_n_op_gc);
57002
57003 ASSERTCMP(atomic_read(&op->usage), ==, 0);
57004 ASSERTCMP(op->state, ==, FSCACHE_OP_ST_DEAD);
57005 diff --git a/fs/fscache/page.c b/fs/fscache/page.c
57006 index 73899c1..ae40c58 100644
57007 --- a/fs/fscache/page.c
57008 +++ b/fs/fscache/page.c
57009 @@ -61,7 +61,7 @@ try_again:
57010 val = radix_tree_lookup(&cookie->stores, page->index);
57011 if (!val) {
57012 rcu_read_unlock();
57013 - fscache_stat(&fscache_n_store_vmscan_not_storing);
57014 + fscache_stat_unchecked(&fscache_n_store_vmscan_not_storing);
57015 __fscache_uncache_page(cookie, page);
57016 return true;
57017 }
57018 @@ -91,11 +91,11 @@ try_again:
57019 spin_unlock(&cookie->stores_lock);
57020
57021 if (xpage) {
57022 - fscache_stat(&fscache_n_store_vmscan_cancelled);
57023 - fscache_stat(&fscache_n_store_radix_deletes);
57024 + fscache_stat_unchecked(&fscache_n_store_vmscan_cancelled);
57025 + fscache_stat_unchecked(&fscache_n_store_radix_deletes);
57026 ASSERTCMP(xpage, ==, page);
57027 } else {
57028 - fscache_stat(&fscache_n_store_vmscan_gone);
57029 + fscache_stat_unchecked(&fscache_n_store_vmscan_gone);
57030 }
57031
57032 wake_up_bit(&cookie->flags, 0);
57033 @@ -110,11 +110,11 @@ page_busy:
57034 * sleeping on memory allocation, so we may need to impose a timeout
57035 * too. */
57036 if (!(gfp & __GFP_WAIT) || !(gfp & __GFP_FS)) {
57037 - fscache_stat(&fscache_n_store_vmscan_busy);
57038 + fscache_stat_unchecked(&fscache_n_store_vmscan_busy);
57039 return false;
57040 }
57041
57042 - fscache_stat(&fscache_n_store_vmscan_wait);
57043 + fscache_stat_unchecked(&fscache_n_store_vmscan_wait);
57044 __fscache_wait_on_page_write(cookie, page);
57045 gfp &= ~__GFP_WAIT;
57046 goto try_again;
57047 @@ -140,7 +140,7 @@ static void fscache_end_page_write(struct fscache_object *object,
57048 FSCACHE_COOKIE_STORING_TAG);
57049 if (!radix_tree_tag_get(&cookie->stores, page->index,
57050 FSCACHE_COOKIE_PENDING_TAG)) {
57051 - fscache_stat(&fscache_n_store_radix_deletes);
57052 + fscache_stat_unchecked(&fscache_n_store_radix_deletes);
57053 xpage = radix_tree_delete(&cookie->stores, page->index);
57054 }
57055 spin_unlock(&cookie->stores_lock);
57056 @@ -161,7 +161,7 @@ static void fscache_attr_changed_op(struct fscache_operation *op)
57057
57058 _enter("{OBJ%x OP%x}", object->debug_id, op->debug_id);
57059
57060 - fscache_stat(&fscache_n_attr_changed_calls);
57061 + fscache_stat_unchecked(&fscache_n_attr_changed_calls);
57062
57063 if (fscache_object_is_active(object) &&
57064 fscache_use_cookie(object)) {
57065 @@ -189,11 +189,11 @@ int __fscache_attr_changed(struct fscache_cookie *cookie)
57066
57067 ASSERTCMP(cookie->def->type, !=, FSCACHE_COOKIE_TYPE_INDEX);
57068
57069 - fscache_stat(&fscache_n_attr_changed);
57070 + fscache_stat_unchecked(&fscache_n_attr_changed);
57071
57072 op = kzalloc(sizeof(*op), GFP_KERNEL);
57073 if (!op) {
57074 - fscache_stat(&fscache_n_attr_changed_nomem);
57075 + fscache_stat_unchecked(&fscache_n_attr_changed_nomem);
57076 _leave(" = -ENOMEM");
57077 return -ENOMEM;
57078 }
57079 @@ -211,7 +211,7 @@ int __fscache_attr_changed(struct fscache_cookie *cookie)
57080 if (fscache_submit_exclusive_op(object, op) < 0)
57081 goto nobufs;
57082 spin_unlock(&cookie->lock);
57083 - fscache_stat(&fscache_n_attr_changed_ok);
57084 + fscache_stat_unchecked(&fscache_n_attr_changed_ok);
57085 fscache_put_operation(op);
57086 _leave(" = 0");
57087 return 0;
57088 @@ -219,7 +219,7 @@ int __fscache_attr_changed(struct fscache_cookie *cookie)
57089 nobufs:
57090 spin_unlock(&cookie->lock);
57091 kfree(op);
57092 - fscache_stat(&fscache_n_attr_changed_nobufs);
57093 + fscache_stat_unchecked(&fscache_n_attr_changed_nobufs);
57094 _leave(" = %d", -ENOBUFS);
57095 return -ENOBUFS;
57096 }
57097 @@ -258,7 +258,7 @@ static struct fscache_retrieval *fscache_alloc_retrieval(
57098 /* allocate a retrieval operation and attempt to submit it */
57099 op = kzalloc(sizeof(*op), GFP_NOIO);
57100 if (!op) {
57101 - fscache_stat(&fscache_n_retrievals_nomem);
57102 + fscache_stat_unchecked(&fscache_n_retrievals_nomem);
57103 return NULL;
57104 }
57105
57106 @@ -289,13 +289,13 @@ int fscache_wait_for_deferred_lookup(struct fscache_cookie *cookie)
57107 return 0;
57108 }
57109
57110 - fscache_stat(&fscache_n_retrievals_wait);
57111 + fscache_stat_unchecked(&fscache_n_retrievals_wait);
57112
57113 jif = jiffies;
57114 if (wait_on_bit(&cookie->flags, FSCACHE_COOKIE_LOOKING_UP,
57115 fscache_wait_bit_interruptible,
57116 TASK_INTERRUPTIBLE) != 0) {
57117 - fscache_stat(&fscache_n_retrievals_intr);
57118 + fscache_stat_unchecked(&fscache_n_retrievals_intr);
57119 _leave(" = -ERESTARTSYS");
57120 return -ERESTARTSYS;
57121 }
57122 @@ -324,8 +324,8 @@ static void fscache_do_cancel_retrieval(struct fscache_operation *_op)
57123 */
57124 int fscache_wait_for_operation_activation(struct fscache_object *object,
57125 struct fscache_operation *op,
57126 - atomic_t *stat_op_waits,
57127 - atomic_t *stat_object_dead,
57128 + atomic_unchecked_t *stat_op_waits,
57129 + atomic_unchecked_t *stat_object_dead,
57130 void (*do_cancel)(struct fscache_operation *))
57131 {
57132 int ret;
57133 @@ -335,7 +335,7 @@ int fscache_wait_for_operation_activation(struct fscache_object *object,
57134
57135 _debug(">>> WT");
57136 if (stat_op_waits)
57137 - fscache_stat(stat_op_waits);
57138 + fscache_stat_unchecked(stat_op_waits);
57139 if (wait_on_bit(&op->flags, FSCACHE_OP_WAITING,
57140 fscache_wait_bit_interruptible,
57141 TASK_INTERRUPTIBLE) != 0) {
57142 @@ -353,7 +353,7 @@ int fscache_wait_for_operation_activation(struct fscache_object *object,
57143 check_if_dead:
57144 if (op->state == FSCACHE_OP_ST_CANCELLED) {
57145 if (stat_object_dead)
57146 - fscache_stat(stat_object_dead);
57147 + fscache_stat_unchecked(stat_object_dead);
57148 _leave(" = -ENOBUFS [cancelled]");
57149 return -ENOBUFS;
57150 }
57151 @@ -361,7 +361,7 @@ check_if_dead:
57152 pr_err("%s() = -ENOBUFS [obj dead %d]\n", __func__, op->state);
57153 fscache_cancel_op(op, do_cancel);
57154 if (stat_object_dead)
57155 - fscache_stat(stat_object_dead);
57156 + fscache_stat_unchecked(stat_object_dead);
57157 return -ENOBUFS;
57158 }
57159 return 0;
57160 @@ -388,7 +388,7 @@ int __fscache_read_or_alloc_page(struct fscache_cookie *cookie,
57161
57162 _enter("%p,%p,,,", cookie, page);
57163
57164 - fscache_stat(&fscache_n_retrievals);
57165 + fscache_stat_unchecked(&fscache_n_retrievals);
57166
57167 if (hlist_empty(&cookie->backing_objects))
57168 goto nobufs;
57169 @@ -428,7 +428,7 @@ int __fscache_read_or_alloc_page(struct fscache_cookie *cookie,
57170 goto nobufs_unlock_dec;
57171 spin_unlock(&cookie->lock);
57172
57173 - fscache_stat(&fscache_n_retrieval_ops);
57174 + fscache_stat_unchecked(&fscache_n_retrieval_ops);
57175
57176 /* pin the netfs read context in case we need to do the actual netfs
57177 * read because we've encountered a cache read failure */
57178 @@ -459,15 +459,15 @@ int __fscache_read_or_alloc_page(struct fscache_cookie *cookie,
57179
57180 error:
57181 if (ret == -ENOMEM)
57182 - fscache_stat(&fscache_n_retrievals_nomem);
57183 + fscache_stat_unchecked(&fscache_n_retrievals_nomem);
57184 else if (ret == -ERESTARTSYS)
57185 - fscache_stat(&fscache_n_retrievals_intr);
57186 + fscache_stat_unchecked(&fscache_n_retrievals_intr);
57187 else if (ret == -ENODATA)
57188 - fscache_stat(&fscache_n_retrievals_nodata);
57189 + fscache_stat_unchecked(&fscache_n_retrievals_nodata);
57190 else if (ret < 0)
57191 - fscache_stat(&fscache_n_retrievals_nobufs);
57192 + fscache_stat_unchecked(&fscache_n_retrievals_nobufs);
57193 else
57194 - fscache_stat(&fscache_n_retrievals_ok);
57195 + fscache_stat_unchecked(&fscache_n_retrievals_ok);
57196
57197 fscache_put_retrieval(op);
57198 _leave(" = %d", ret);
57199 @@ -480,7 +480,7 @@ nobufs_unlock:
57200 atomic_dec(&cookie->n_active);
57201 kfree(op);
57202 nobufs:
57203 - fscache_stat(&fscache_n_retrievals_nobufs);
57204 + fscache_stat_unchecked(&fscache_n_retrievals_nobufs);
57205 _leave(" = -ENOBUFS");
57206 return -ENOBUFS;
57207 }
57208 @@ -518,7 +518,7 @@ int __fscache_read_or_alloc_pages(struct fscache_cookie *cookie,
57209
57210 _enter("%p,,%d,,,", cookie, *nr_pages);
57211
57212 - fscache_stat(&fscache_n_retrievals);
57213 + fscache_stat_unchecked(&fscache_n_retrievals);
57214
57215 if (hlist_empty(&cookie->backing_objects))
57216 goto nobufs;
57217 @@ -554,7 +554,7 @@ int __fscache_read_or_alloc_pages(struct fscache_cookie *cookie,
57218 goto nobufs_unlock_dec;
57219 spin_unlock(&cookie->lock);
57220
57221 - fscache_stat(&fscache_n_retrieval_ops);
57222 + fscache_stat_unchecked(&fscache_n_retrieval_ops);
57223
57224 /* pin the netfs read context in case we need to do the actual netfs
57225 * read because we've encountered a cache read failure */
57226 @@ -585,15 +585,15 @@ int __fscache_read_or_alloc_pages(struct fscache_cookie *cookie,
57227
57228 error:
57229 if (ret == -ENOMEM)
57230 - fscache_stat(&fscache_n_retrievals_nomem);
57231 + fscache_stat_unchecked(&fscache_n_retrievals_nomem);
57232 else if (ret == -ERESTARTSYS)
57233 - fscache_stat(&fscache_n_retrievals_intr);
57234 + fscache_stat_unchecked(&fscache_n_retrievals_intr);
57235 else if (ret == -ENODATA)
57236 - fscache_stat(&fscache_n_retrievals_nodata);
57237 + fscache_stat_unchecked(&fscache_n_retrievals_nodata);
57238 else if (ret < 0)
57239 - fscache_stat(&fscache_n_retrievals_nobufs);
57240 + fscache_stat_unchecked(&fscache_n_retrievals_nobufs);
57241 else
57242 - fscache_stat(&fscache_n_retrievals_ok);
57243 + fscache_stat_unchecked(&fscache_n_retrievals_ok);
57244
57245 fscache_put_retrieval(op);
57246 _leave(" = %d", ret);
57247 @@ -606,7 +606,7 @@ nobufs_unlock:
57248 atomic_dec(&cookie->n_active);
57249 kfree(op);
57250 nobufs:
57251 - fscache_stat(&fscache_n_retrievals_nobufs);
57252 + fscache_stat_unchecked(&fscache_n_retrievals_nobufs);
57253 _leave(" = -ENOBUFS");
57254 return -ENOBUFS;
57255 }
57256 @@ -630,7 +630,7 @@ int __fscache_alloc_page(struct fscache_cookie *cookie,
57257
57258 _enter("%p,%p,,,", cookie, page);
57259
57260 - fscache_stat(&fscache_n_allocs);
57261 + fscache_stat_unchecked(&fscache_n_allocs);
57262
57263 if (hlist_empty(&cookie->backing_objects))
57264 goto nobufs;
57265 @@ -662,7 +662,7 @@ int __fscache_alloc_page(struct fscache_cookie *cookie,
57266 goto nobufs_unlock;
57267 spin_unlock(&cookie->lock);
57268
57269 - fscache_stat(&fscache_n_alloc_ops);
57270 + fscache_stat_unchecked(&fscache_n_alloc_ops);
57271
57272 ret = fscache_wait_for_operation_activation(
57273 object, &op->op,
57274 @@ -679,11 +679,11 @@ int __fscache_alloc_page(struct fscache_cookie *cookie,
57275
57276 error:
57277 if (ret == -ERESTARTSYS)
57278 - fscache_stat(&fscache_n_allocs_intr);
57279 + fscache_stat_unchecked(&fscache_n_allocs_intr);
57280 else if (ret < 0)
57281 - fscache_stat(&fscache_n_allocs_nobufs);
57282 + fscache_stat_unchecked(&fscache_n_allocs_nobufs);
57283 else
57284 - fscache_stat(&fscache_n_allocs_ok);
57285 + fscache_stat_unchecked(&fscache_n_allocs_ok);
57286
57287 fscache_put_retrieval(op);
57288 _leave(" = %d", ret);
57289 @@ -694,7 +694,7 @@ nobufs_unlock:
57290 atomic_dec(&cookie->n_active);
57291 kfree(op);
57292 nobufs:
57293 - fscache_stat(&fscache_n_allocs_nobufs);
57294 + fscache_stat_unchecked(&fscache_n_allocs_nobufs);
57295 _leave(" = -ENOBUFS");
57296 return -ENOBUFS;
57297 }
57298 @@ -770,7 +770,7 @@ static void fscache_write_op(struct fscache_operation *_op)
57299
57300 spin_lock(&cookie->stores_lock);
57301
57302 - fscache_stat(&fscache_n_store_calls);
57303 + fscache_stat_unchecked(&fscache_n_store_calls);
57304
57305 /* find a page to store */
57306 page = NULL;
57307 @@ -781,7 +781,7 @@ static void fscache_write_op(struct fscache_operation *_op)
57308 page = results[0];
57309 _debug("gang %d [%lx]", n, page->index);
57310 if (page->index > op->store_limit) {
57311 - fscache_stat(&fscache_n_store_pages_over_limit);
57312 + fscache_stat_unchecked(&fscache_n_store_pages_over_limit);
57313 goto superseded;
57314 }
57315
57316 @@ -793,7 +793,7 @@ static void fscache_write_op(struct fscache_operation *_op)
57317 spin_unlock(&cookie->stores_lock);
57318 spin_unlock(&object->lock);
57319
57320 - fscache_stat(&fscache_n_store_pages);
57321 + fscache_stat_unchecked(&fscache_n_store_pages);
57322 fscache_stat(&fscache_n_cop_write_page);
57323 ret = object->cache->ops->write_page(op, page);
57324 fscache_stat_d(&fscache_n_cop_write_page);
57325 @@ -896,7 +896,7 @@ int __fscache_write_page(struct fscache_cookie *cookie,
57326 ASSERTCMP(cookie->def->type, !=, FSCACHE_COOKIE_TYPE_INDEX);
57327 ASSERT(PageFsCache(page));
57328
57329 - fscache_stat(&fscache_n_stores);
57330 + fscache_stat_unchecked(&fscache_n_stores);
57331
57332 if (test_bit(FSCACHE_COOKIE_INVALIDATING, &cookie->flags)) {
57333 _leave(" = -ENOBUFS [invalidating]");
57334 @@ -954,7 +954,7 @@ int __fscache_write_page(struct fscache_cookie *cookie,
57335 spin_unlock(&cookie->stores_lock);
57336 spin_unlock(&object->lock);
57337
57338 - op->op.debug_id = atomic_inc_return(&fscache_op_debug_id);
57339 + op->op.debug_id = atomic_inc_return_unchecked(&fscache_op_debug_id);
57340 op->store_limit = object->store_limit;
57341
57342 atomic_inc(&cookie->n_active);
57343 @@ -963,8 +963,8 @@ int __fscache_write_page(struct fscache_cookie *cookie,
57344
57345 spin_unlock(&cookie->lock);
57346 radix_tree_preload_end();
57347 - fscache_stat(&fscache_n_store_ops);
57348 - fscache_stat(&fscache_n_stores_ok);
57349 + fscache_stat_unchecked(&fscache_n_store_ops);
57350 + fscache_stat_unchecked(&fscache_n_stores_ok);
57351
57352 /* the work queue now carries its own ref on the object */
57353 fscache_put_operation(&op->op);
57354 @@ -972,14 +972,14 @@ int __fscache_write_page(struct fscache_cookie *cookie,
57355 return 0;
57356
57357 already_queued:
57358 - fscache_stat(&fscache_n_stores_again);
57359 + fscache_stat_unchecked(&fscache_n_stores_again);
57360 already_pending:
57361 spin_unlock(&cookie->stores_lock);
57362 spin_unlock(&object->lock);
57363 spin_unlock(&cookie->lock);
57364 radix_tree_preload_end();
57365 kfree(op);
57366 - fscache_stat(&fscache_n_stores_ok);
57367 + fscache_stat_unchecked(&fscache_n_stores_ok);
57368 _leave(" = 0");
57369 return 0;
57370
57371 @@ -999,14 +999,14 @@ nobufs:
57372 spin_unlock(&cookie->lock);
57373 radix_tree_preload_end();
57374 kfree(op);
57375 - fscache_stat(&fscache_n_stores_nobufs);
57376 + fscache_stat_unchecked(&fscache_n_stores_nobufs);
57377 _leave(" = -ENOBUFS");
57378 return -ENOBUFS;
57379
57380 nomem_free:
57381 kfree(op);
57382 nomem:
57383 - fscache_stat(&fscache_n_stores_oom);
57384 + fscache_stat_unchecked(&fscache_n_stores_oom);
57385 _leave(" = -ENOMEM");
57386 return -ENOMEM;
57387 }
57388 @@ -1024,7 +1024,7 @@ void __fscache_uncache_page(struct fscache_cookie *cookie, struct page *page)
57389 ASSERTCMP(cookie->def->type, !=, FSCACHE_COOKIE_TYPE_INDEX);
57390 ASSERTCMP(page, !=, NULL);
57391
57392 - fscache_stat(&fscache_n_uncaches);
57393 + fscache_stat_unchecked(&fscache_n_uncaches);
57394
57395 /* cache withdrawal may beat us to it */
57396 if (!PageFsCache(page))
57397 @@ -1075,7 +1075,7 @@ void fscache_mark_page_cached(struct fscache_retrieval *op, struct page *page)
57398 struct fscache_cookie *cookie = op->op.object->cookie;
57399
57400 #ifdef CONFIG_FSCACHE_STATS
57401 - atomic_inc(&fscache_n_marks);
57402 + atomic_inc_unchecked(&fscache_n_marks);
57403 #endif
57404
57405 _debug("- mark %p{%lx}", page, page->index);
57406 diff --git a/fs/fscache/stats.c b/fs/fscache/stats.c
57407 index 40d13c7..ddf52b9 100644
57408 --- a/fs/fscache/stats.c
57409 +++ b/fs/fscache/stats.c
57410 @@ -18,99 +18,99 @@
57411 /*
57412 * operation counters
57413 */
57414 -atomic_t fscache_n_op_pend;
57415 -atomic_t fscache_n_op_run;
57416 -atomic_t fscache_n_op_enqueue;
57417 -atomic_t fscache_n_op_requeue;
57418 -atomic_t fscache_n_op_deferred_release;
57419 -atomic_t fscache_n_op_release;
57420 -atomic_t fscache_n_op_gc;
57421 -atomic_t fscache_n_op_cancelled;
57422 -atomic_t fscache_n_op_rejected;
57423 +atomic_unchecked_t fscache_n_op_pend;
57424 +atomic_unchecked_t fscache_n_op_run;
57425 +atomic_unchecked_t fscache_n_op_enqueue;
57426 +atomic_unchecked_t fscache_n_op_requeue;
57427 +atomic_unchecked_t fscache_n_op_deferred_release;
57428 +atomic_unchecked_t fscache_n_op_release;
57429 +atomic_unchecked_t fscache_n_op_gc;
57430 +atomic_unchecked_t fscache_n_op_cancelled;
57431 +atomic_unchecked_t fscache_n_op_rejected;
57432
57433 -atomic_t fscache_n_attr_changed;
57434 -atomic_t fscache_n_attr_changed_ok;
57435 -atomic_t fscache_n_attr_changed_nobufs;
57436 -atomic_t fscache_n_attr_changed_nomem;
57437 -atomic_t fscache_n_attr_changed_calls;
57438 +atomic_unchecked_t fscache_n_attr_changed;
57439 +atomic_unchecked_t fscache_n_attr_changed_ok;
57440 +atomic_unchecked_t fscache_n_attr_changed_nobufs;
57441 +atomic_unchecked_t fscache_n_attr_changed_nomem;
57442 +atomic_unchecked_t fscache_n_attr_changed_calls;
57443
57444 -atomic_t fscache_n_allocs;
57445 -atomic_t fscache_n_allocs_ok;
57446 -atomic_t fscache_n_allocs_wait;
57447 -atomic_t fscache_n_allocs_nobufs;
57448 -atomic_t fscache_n_allocs_intr;
57449 -atomic_t fscache_n_allocs_object_dead;
57450 -atomic_t fscache_n_alloc_ops;
57451 -atomic_t fscache_n_alloc_op_waits;
57452 +atomic_unchecked_t fscache_n_allocs;
57453 +atomic_unchecked_t fscache_n_allocs_ok;
57454 +atomic_unchecked_t fscache_n_allocs_wait;
57455 +atomic_unchecked_t fscache_n_allocs_nobufs;
57456 +atomic_unchecked_t fscache_n_allocs_intr;
57457 +atomic_unchecked_t fscache_n_allocs_object_dead;
57458 +atomic_unchecked_t fscache_n_alloc_ops;
57459 +atomic_unchecked_t fscache_n_alloc_op_waits;
57460
57461 -atomic_t fscache_n_retrievals;
57462 -atomic_t fscache_n_retrievals_ok;
57463 -atomic_t fscache_n_retrievals_wait;
57464 -atomic_t fscache_n_retrievals_nodata;
57465 -atomic_t fscache_n_retrievals_nobufs;
57466 -atomic_t fscache_n_retrievals_intr;
57467 -atomic_t fscache_n_retrievals_nomem;
57468 -atomic_t fscache_n_retrievals_object_dead;
57469 -atomic_t fscache_n_retrieval_ops;
57470 -atomic_t fscache_n_retrieval_op_waits;
57471 +atomic_unchecked_t fscache_n_retrievals;
57472 +atomic_unchecked_t fscache_n_retrievals_ok;
57473 +atomic_unchecked_t fscache_n_retrievals_wait;
57474 +atomic_unchecked_t fscache_n_retrievals_nodata;
57475 +atomic_unchecked_t fscache_n_retrievals_nobufs;
57476 +atomic_unchecked_t fscache_n_retrievals_intr;
57477 +atomic_unchecked_t fscache_n_retrievals_nomem;
57478 +atomic_unchecked_t fscache_n_retrievals_object_dead;
57479 +atomic_unchecked_t fscache_n_retrieval_ops;
57480 +atomic_unchecked_t fscache_n_retrieval_op_waits;
57481
57482 -atomic_t fscache_n_stores;
57483 -atomic_t fscache_n_stores_ok;
57484 -atomic_t fscache_n_stores_again;
57485 -atomic_t fscache_n_stores_nobufs;
57486 -atomic_t fscache_n_stores_oom;
57487 -atomic_t fscache_n_store_ops;
57488 -atomic_t fscache_n_store_calls;
57489 -atomic_t fscache_n_store_pages;
57490 -atomic_t fscache_n_store_radix_deletes;
57491 -atomic_t fscache_n_store_pages_over_limit;
57492 +atomic_unchecked_t fscache_n_stores;
57493 +atomic_unchecked_t fscache_n_stores_ok;
57494 +atomic_unchecked_t fscache_n_stores_again;
57495 +atomic_unchecked_t fscache_n_stores_nobufs;
57496 +atomic_unchecked_t fscache_n_stores_oom;
57497 +atomic_unchecked_t fscache_n_store_ops;
57498 +atomic_unchecked_t fscache_n_store_calls;
57499 +atomic_unchecked_t fscache_n_store_pages;
57500 +atomic_unchecked_t fscache_n_store_radix_deletes;
57501 +atomic_unchecked_t fscache_n_store_pages_over_limit;
57502
57503 -atomic_t fscache_n_store_vmscan_not_storing;
57504 -atomic_t fscache_n_store_vmscan_gone;
57505 -atomic_t fscache_n_store_vmscan_busy;
57506 -atomic_t fscache_n_store_vmscan_cancelled;
57507 -atomic_t fscache_n_store_vmscan_wait;
57508 +atomic_unchecked_t fscache_n_store_vmscan_not_storing;
57509 +atomic_unchecked_t fscache_n_store_vmscan_gone;
57510 +atomic_unchecked_t fscache_n_store_vmscan_busy;
57511 +atomic_unchecked_t fscache_n_store_vmscan_cancelled;
57512 +atomic_unchecked_t fscache_n_store_vmscan_wait;
57513
57514 -atomic_t fscache_n_marks;
57515 -atomic_t fscache_n_uncaches;
57516 +atomic_unchecked_t fscache_n_marks;
57517 +atomic_unchecked_t fscache_n_uncaches;
57518
57519 -atomic_t fscache_n_acquires;
57520 -atomic_t fscache_n_acquires_null;
57521 -atomic_t fscache_n_acquires_no_cache;
57522 -atomic_t fscache_n_acquires_ok;
57523 -atomic_t fscache_n_acquires_nobufs;
57524 -atomic_t fscache_n_acquires_oom;
57525 +atomic_unchecked_t fscache_n_acquires;
57526 +atomic_unchecked_t fscache_n_acquires_null;
57527 +atomic_unchecked_t fscache_n_acquires_no_cache;
57528 +atomic_unchecked_t fscache_n_acquires_ok;
57529 +atomic_unchecked_t fscache_n_acquires_nobufs;
57530 +atomic_unchecked_t fscache_n_acquires_oom;
57531
57532 -atomic_t fscache_n_invalidates;
57533 -atomic_t fscache_n_invalidates_run;
57534 +atomic_unchecked_t fscache_n_invalidates;
57535 +atomic_unchecked_t fscache_n_invalidates_run;
57536
57537 -atomic_t fscache_n_updates;
57538 -atomic_t fscache_n_updates_null;
57539 -atomic_t fscache_n_updates_run;
57540 +atomic_unchecked_t fscache_n_updates;
57541 +atomic_unchecked_t fscache_n_updates_null;
57542 +atomic_unchecked_t fscache_n_updates_run;
57543
57544 -atomic_t fscache_n_relinquishes;
57545 -atomic_t fscache_n_relinquishes_null;
57546 -atomic_t fscache_n_relinquishes_waitcrt;
57547 -atomic_t fscache_n_relinquishes_retire;
57548 +atomic_unchecked_t fscache_n_relinquishes;
57549 +atomic_unchecked_t fscache_n_relinquishes_null;
57550 +atomic_unchecked_t fscache_n_relinquishes_waitcrt;
57551 +atomic_unchecked_t fscache_n_relinquishes_retire;
57552
57553 -atomic_t fscache_n_cookie_index;
57554 -atomic_t fscache_n_cookie_data;
57555 -atomic_t fscache_n_cookie_special;
57556 +atomic_unchecked_t fscache_n_cookie_index;
57557 +atomic_unchecked_t fscache_n_cookie_data;
57558 +atomic_unchecked_t fscache_n_cookie_special;
57559
57560 -atomic_t fscache_n_object_alloc;
57561 -atomic_t fscache_n_object_no_alloc;
57562 -atomic_t fscache_n_object_lookups;
57563 -atomic_t fscache_n_object_lookups_negative;
57564 -atomic_t fscache_n_object_lookups_positive;
57565 -atomic_t fscache_n_object_lookups_timed_out;
57566 -atomic_t fscache_n_object_created;
57567 -atomic_t fscache_n_object_avail;
57568 -atomic_t fscache_n_object_dead;
57569 +atomic_unchecked_t fscache_n_object_alloc;
57570 +atomic_unchecked_t fscache_n_object_no_alloc;
57571 +atomic_unchecked_t fscache_n_object_lookups;
57572 +atomic_unchecked_t fscache_n_object_lookups_negative;
57573 +atomic_unchecked_t fscache_n_object_lookups_positive;
57574 +atomic_unchecked_t fscache_n_object_lookups_timed_out;
57575 +atomic_unchecked_t fscache_n_object_created;
57576 +atomic_unchecked_t fscache_n_object_avail;
57577 +atomic_unchecked_t fscache_n_object_dead;
57578
57579 -atomic_t fscache_n_checkaux_none;
57580 -atomic_t fscache_n_checkaux_okay;
57581 -atomic_t fscache_n_checkaux_update;
57582 -atomic_t fscache_n_checkaux_obsolete;
57583 +atomic_unchecked_t fscache_n_checkaux_none;
57584 +atomic_unchecked_t fscache_n_checkaux_okay;
57585 +atomic_unchecked_t fscache_n_checkaux_update;
57586 +atomic_unchecked_t fscache_n_checkaux_obsolete;
57587
57588 atomic_t fscache_n_cop_alloc_object;
57589 atomic_t fscache_n_cop_lookup_object;
57590 @@ -138,118 +138,118 @@ static int fscache_stats_show(struct seq_file *m, void *v)
57591 seq_puts(m, "FS-Cache statistics\n");
57592
57593 seq_printf(m, "Cookies: idx=%u dat=%u spc=%u\n",
57594 - atomic_read(&fscache_n_cookie_index),
57595 - atomic_read(&fscache_n_cookie_data),
57596 - atomic_read(&fscache_n_cookie_special));
57597 + atomic_read_unchecked(&fscache_n_cookie_index),
57598 + atomic_read_unchecked(&fscache_n_cookie_data),
57599 + atomic_read_unchecked(&fscache_n_cookie_special));
57600
57601 seq_printf(m, "Objects: alc=%u nal=%u avl=%u ded=%u\n",
57602 - atomic_read(&fscache_n_object_alloc),
57603 - atomic_read(&fscache_n_object_no_alloc),
57604 - atomic_read(&fscache_n_object_avail),
57605 - atomic_read(&fscache_n_object_dead));
57606 + atomic_read_unchecked(&fscache_n_object_alloc),
57607 + atomic_read_unchecked(&fscache_n_object_no_alloc),
57608 + atomic_read_unchecked(&fscache_n_object_avail),
57609 + atomic_read_unchecked(&fscache_n_object_dead));
57610 seq_printf(m, "ChkAux : non=%u ok=%u upd=%u obs=%u\n",
57611 - atomic_read(&fscache_n_checkaux_none),
57612 - atomic_read(&fscache_n_checkaux_okay),
57613 - atomic_read(&fscache_n_checkaux_update),
57614 - atomic_read(&fscache_n_checkaux_obsolete));
57615 + atomic_read_unchecked(&fscache_n_checkaux_none),
57616 + atomic_read_unchecked(&fscache_n_checkaux_okay),
57617 + atomic_read_unchecked(&fscache_n_checkaux_update),
57618 + atomic_read_unchecked(&fscache_n_checkaux_obsolete));
57619
57620 seq_printf(m, "Pages : mrk=%u unc=%u\n",
57621 - atomic_read(&fscache_n_marks),
57622 - atomic_read(&fscache_n_uncaches));
57623 + atomic_read_unchecked(&fscache_n_marks),
57624 + atomic_read_unchecked(&fscache_n_uncaches));
57625
57626 seq_printf(m, "Acquire: n=%u nul=%u noc=%u ok=%u nbf=%u"
57627 " oom=%u\n",
57628 - atomic_read(&fscache_n_acquires),
57629 - atomic_read(&fscache_n_acquires_null),
57630 - atomic_read(&fscache_n_acquires_no_cache),
57631 - atomic_read(&fscache_n_acquires_ok),
57632 - atomic_read(&fscache_n_acquires_nobufs),
57633 - atomic_read(&fscache_n_acquires_oom));
57634 + atomic_read_unchecked(&fscache_n_acquires),
57635 + atomic_read_unchecked(&fscache_n_acquires_null),
57636 + atomic_read_unchecked(&fscache_n_acquires_no_cache),
57637 + atomic_read_unchecked(&fscache_n_acquires_ok),
57638 + atomic_read_unchecked(&fscache_n_acquires_nobufs),
57639 + atomic_read_unchecked(&fscache_n_acquires_oom));
57640
57641 seq_printf(m, "Lookups: n=%u neg=%u pos=%u crt=%u tmo=%u\n",
57642 - atomic_read(&fscache_n_object_lookups),
57643 - atomic_read(&fscache_n_object_lookups_negative),
57644 - atomic_read(&fscache_n_object_lookups_positive),
57645 - atomic_read(&fscache_n_object_created),
57646 - atomic_read(&fscache_n_object_lookups_timed_out));
57647 + atomic_read_unchecked(&fscache_n_object_lookups),
57648 + atomic_read_unchecked(&fscache_n_object_lookups_negative),
57649 + atomic_read_unchecked(&fscache_n_object_lookups_positive),
57650 + atomic_read_unchecked(&fscache_n_object_created),
57651 + atomic_read_unchecked(&fscache_n_object_lookups_timed_out));
57652
57653 seq_printf(m, "Invals : n=%u run=%u\n",
57654 - atomic_read(&fscache_n_invalidates),
57655 - atomic_read(&fscache_n_invalidates_run));
57656 + atomic_read_unchecked(&fscache_n_invalidates),
57657 + atomic_read_unchecked(&fscache_n_invalidates_run));
57658
57659 seq_printf(m, "Updates: n=%u nul=%u run=%u\n",
57660 - atomic_read(&fscache_n_updates),
57661 - atomic_read(&fscache_n_updates_null),
57662 - atomic_read(&fscache_n_updates_run));
57663 + atomic_read_unchecked(&fscache_n_updates),
57664 + atomic_read_unchecked(&fscache_n_updates_null),
57665 + atomic_read_unchecked(&fscache_n_updates_run));
57666
57667 seq_printf(m, "Relinqs: n=%u nul=%u wcr=%u rtr=%u\n",
57668 - atomic_read(&fscache_n_relinquishes),
57669 - atomic_read(&fscache_n_relinquishes_null),
57670 - atomic_read(&fscache_n_relinquishes_waitcrt),
57671 - atomic_read(&fscache_n_relinquishes_retire));
57672 + atomic_read_unchecked(&fscache_n_relinquishes),
57673 + atomic_read_unchecked(&fscache_n_relinquishes_null),
57674 + atomic_read_unchecked(&fscache_n_relinquishes_waitcrt),
57675 + atomic_read_unchecked(&fscache_n_relinquishes_retire));
57676
57677 seq_printf(m, "AttrChg: n=%u ok=%u nbf=%u oom=%u run=%u\n",
57678 - atomic_read(&fscache_n_attr_changed),
57679 - atomic_read(&fscache_n_attr_changed_ok),
57680 - atomic_read(&fscache_n_attr_changed_nobufs),
57681 - atomic_read(&fscache_n_attr_changed_nomem),
57682 - atomic_read(&fscache_n_attr_changed_calls));
57683 + atomic_read_unchecked(&fscache_n_attr_changed),
57684 + atomic_read_unchecked(&fscache_n_attr_changed_ok),
57685 + atomic_read_unchecked(&fscache_n_attr_changed_nobufs),
57686 + atomic_read_unchecked(&fscache_n_attr_changed_nomem),
57687 + atomic_read_unchecked(&fscache_n_attr_changed_calls));
57688
57689 seq_printf(m, "Allocs : n=%u ok=%u wt=%u nbf=%u int=%u\n",
57690 - atomic_read(&fscache_n_allocs),
57691 - atomic_read(&fscache_n_allocs_ok),
57692 - atomic_read(&fscache_n_allocs_wait),
57693 - atomic_read(&fscache_n_allocs_nobufs),
57694 - atomic_read(&fscache_n_allocs_intr));
57695 + atomic_read_unchecked(&fscache_n_allocs),
57696 + atomic_read_unchecked(&fscache_n_allocs_ok),
57697 + atomic_read_unchecked(&fscache_n_allocs_wait),
57698 + atomic_read_unchecked(&fscache_n_allocs_nobufs),
57699 + atomic_read_unchecked(&fscache_n_allocs_intr));
57700 seq_printf(m, "Allocs : ops=%u owt=%u abt=%u\n",
57701 - atomic_read(&fscache_n_alloc_ops),
57702 - atomic_read(&fscache_n_alloc_op_waits),
57703 - atomic_read(&fscache_n_allocs_object_dead));
57704 + atomic_read_unchecked(&fscache_n_alloc_ops),
57705 + atomic_read_unchecked(&fscache_n_alloc_op_waits),
57706 + atomic_read_unchecked(&fscache_n_allocs_object_dead));
57707
57708 seq_printf(m, "Retrvls: n=%u ok=%u wt=%u nod=%u nbf=%u"
57709 " int=%u oom=%u\n",
57710 - atomic_read(&fscache_n_retrievals),
57711 - atomic_read(&fscache_n_retrievals_ok),
57712 - atomic_read(&fscache_n_retrievals_wait),
57713 - atomic_read(&fscache_n_retrievals_nodata),
57714 - atomic_read(&fscache_n_retrievals_nobufs),
57715 - atomic_read(&fscache_n_retrievals_intr),
57716 - atomic_read(&fscache_n_retrievals_nomem));
57717 + atomic_read_unchecked(&fscache_n_retrievals),
57718 + atomic_read_unchecked(&fscache_n_retrievals_ok),
57719 + atomic_read_unchecked(&fscache_n_retrievals_wait),
57720 + atomic_read_unchecked(&fscache_n_retrievals_nodata),
57721 + atomic_read_unchecked(&fscache_n_retrievals_nobufs),
57722 + atomic_read_unchecked(&fscache_n_retrievals_intr),
57723 + atomic_read_unchecked(&fscache_n_retrievals_nomem));
57724 seq_printf(m, "Retrvls: ops=%u owt=%u abt=%u\n",
57725 - atomic_read(&fscache_n_retrieval_ops),
57726 - atomic_read(&fscache_n_retrieval_op_waits),
57727 - atomic_read(&fscache_n_retrievals_object_dead));
57728 + atomic_read_unchecked(&fscache_n_retrieval_ops),
57729 + atomic_read_unchecked(&fscache_n_retrieval_op_waits),
57730 + atomic_read_unchecked(&fscache_n_retrievals_object_dead));
57731
57732 seq_printf(m, "Stores : n=%u ok=%u agn=%u nbf=%u oom=%u\n",
57733 - atomic_read(&fscache_n_stores),
57734 - atomic_read(&fscache_n_stores_ok),
57735 - atomic_read(&fscache_n_stores_again),
57736 - atomic_read(&fscache_n_stores_nobufs),
57737 - atomic_read(&fscache_n_stores_oom));
57738 + atomic_read_unchecked(&fscache_n_stores),
57739 + atomic_read_unchecked(&fscache_n_stores_ok),
57740 + atomic_read_unchecked(&fscache_n_stores_again),
57741 + atomic_read_unchecked(&fscache_n_stores_nobufs),
57742 + atomic_read_unchecked(&fscache_n_stores_oom));
57743 seq_printf(m, "Stores : ops=%u run=%u pgs=%u rxd=%u olm=%u\n",
57744 - atomic_read(&fscache_n_store_ops),
57745 - atomic_read(&fscache_n_store_calls),
57746 - atomic_read(&fscache_n_store_pages),
57747 - atomic_read(&fscache_n_store_radix_deletes),
57748 - atomic_read(&fscache_n_store_pages_over_limit));
57749 + atomic_read_unchecked(&fscache_n_store_ops),
57750 + atomic_read_unchecked(&fscache_n_store_calls),
57751 + atomic_read_unchecked(&fscache_n_store_pages),
57752 + atomic_read_unchecked(&fscache_n_store_radix_deletes),
57753 + atomic_read_unchecked(&fscache_n_store_pages_over_limit));
57754
57755 seq_printf(m, "VmScan : nos=%u gon=%u bsy=%u can=%u wt=%u\n",
57756 - atomic_read(&fscache_n_store_vmscan_not_storing),
57757 - atomic_read(&fscache_n_store_vmscan_gone),
57758 - atomic_read(&fscache_n_store_vmscan_busy),
57759 - atomic_read(&fscache_n_store_vmscan_cancelled),
57760 - atomic_read(&fscache_n_store_vmscan_wait));
57761 + atomic_read_unchecked(&fscache_n_store_vmscan_not_storing),
57762 + atomic_read_unchecked(&fscache_n_store_vmscan_gone),
57763 + atomic_read_unchecked(&fscache_n_store_vmscan_busy),
57764 + atomic_read_unchecked(&fscache_n_store_vmscan_cancelled),
57765 + atomic_read_unchecked(&fscache_n_store_vmscan_wait));
57766
57767 seq_printf(m, "Ops : pend=%u run=%u enq=%u can=%u rej=%u\n",
57768 - atomic_read(&fscache_n_op_pend),
57769 - atomic_read(&fscache_n_op_run),
57770 - atomic_read(&fscache_n_op_enqueue),
57771 - atomic_read(&fscache_n_op_cancelled),
57772 - atomic_read(&fscache_n_op_rejected));
57773 + atomic_read_unchecked(&fscache_n_op_pend),
57774 + atomic_read_unchecked(&fscache_n_op_run),
57775 + atomic_read_unchecked(&fscache_n_op_enqueue),
57776 + atomic_read_unchecked(&fscache_n_op_cancelled),
57777 + atomic_read_unchecked(&fscache_n_op_rejected));
57778 seq_printf(m, "Ops : dfr=%u rel=%u gc=%u\n",
57779 - atomic_read(&fscache_n_op_deferred_release),
57780 - atomic_read(&fscache_n_op_release),
57781 - atomic_read(&fscache_n_op_gc));
57782 + atomic_read_unchecked(&fscache_n_op_deferred_release),
57783 + atomic_read_unchecked(&fscache_n_op_release),
57784 + atomic_read_unchecked(&fscache_n_op_gc));
57785
57786 seq_printf(m, "CacheOp: alo=%d luo=%d luc=%d gro=%d\n",
57787 atomic_read(&fscache_n_cop_alloc_object),
57788 diff --git a/fs/fuse/cuse.c b/fs/fuse/cuse.c
57789 index adbfd66..4b25822 100644
57790 --- a/fs/fuse/cuse.c
57791 +++ b/fs/fuse/cuse.c
57792 @@ -603,10 +603,12 @@ static int __init cuse_init(void)
57793 INIT_LIST_HEAD(&cuse_conntbl[i]);
57794
57795 /* inherit and extend fuse_dev_operations */
57796 - cuse_channel_fops = fuse_dev_operations;
57797 - cuse_channel_fops.owner = THIS_MODULE;
57798 - cuse_channel_fops.open = cuse_channel_open;
57799 - cuse_channel_fops.release = cuse_channel_release;
57800 + pax_open_kernel();
57801 + memcpy((void *)&cuse_channel_fops, &fuse_dev_operations, sizeof(fuse_dev_operations));
57802 + *(void **)&cuse_channel_fops.owner = THIS_MODULE;
57803 + *(void **)&cuse_channel_fops.open = cuse_channel_open;
57804 + *(void **)&cuse_channel_fops.release = cuse_channel_release;
57805 + pax_close_kernel();
57806
57807 cuse_class = class_create(THIS_MODULE, "cuse");
57808 if (IS_ERR(cuse_class))
57809 diff --git a/fs/fuse/dev.c b/fs/fuse/dev.c
57810 index ef74ad5..c9ac759e 100644
57811 --- a/fs/fuse/dev.c
57812 +++ b/fs/fuse/dev.c
57813 @@ -1339,7 +1339,7 @@ static ssize_t fuse_dev_splice_read(struct file *in, loff_t *ppos,
57814 ret = 0;
57815 pipe_lock(pipe);
57816
57817 - if (!pipe->readers) {
57818 + if (!atomic_read(&pipe->readers)) {
57819 send_sig(SIGPIPE, current, 0);
57820 if (!ret)
57821 ret = -EPIPE;
57822 @@ -1364,7 +1364,7 @@ static ssize_t fuse_dev_splice_read(struct file *in, loff_t *ppos,
57823 page_nr++;
57824 ret += buf->len;
57825
57826 - if (pipe->files)
57827 + if (atomic_read(&pipe->files))
57828 do_wakeup = 1;
57829 }
57830
57831 diff --git a/fs/fuse/dir.c b/fs/fuse/dir.c
57832 index b7989f2..1f72ec4 100644
57833 --- a/fs/fuse/dir.c
57834 +++ b/fs/fuse/dir.c
57835 @@ -1438,7 +1438,7 @@ static char *read_link(struct dentry *dentry)
57836 return link;
57837 }
57838
57839 -static void free_link(char *link)
57840 +static void free_link(const char *link)
57841 {
57842 if (!IS_ERR(link))
57843 free_page((unsigned long) link);
57844 diff --git a/fs/gfs2/inode.c b/fs/gfs2/inode.c
57845 index 1298766..c964c60 100644
57846 --- a/fs/gfs2/inode.c
57847 +++ b/fs/gfs2/inode.c
57848 @@ -1515,7 +1515,7 @@ out:
57849
57850 static void gfs2_put_link(struct dentry *dentry, struct nameidata *nd, void *p)
57851 {
57852 - char *s = nd_get_link(nd);
57853 + const char *s = nd_get_link(nd);
57854 if (!IS_ERR(s))
57855 kfree(s);
57856 }
57857 diff --git a/fs/hostfs/hostfs_kern.c b/fs/hostfs/hostfs_kern.c
57858 index 2543728..14d7bd4 100644
57859 --- a/fs/hostfs/hostfs_kern.c
57860 +++ b/fs/hostfs/hostfs_kern.c
57861 @@ -904,7 +904,7 @@ static void *hostfs_follow_link(struct dentry *dentry, struct nameidata *nd)
57862
57863 static void hostfs_put_link(struct dentry *dentry, struct nameidata *nd, void *cookie)
57864 {
57865 - char *s = nd_get_link(nd);
57866 + const char *s = nd_get_link(nd);
57867 if (!IS_ERR(s))
57868 __putname(s);
57869 }
57870 diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c
57871 index d19b30a..ef89c36 100644
57872 --- a/fs/hugetlbfs/inode.c
57873 +++ b/fs/hugetlbfs/inode.c
57874 @@ -152,6 +152,7 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
57875 struct mm_struct *mm = current->mm;
57876 struct vm_area_struct *vma;
57877 struct hstate *h = hstate_file(file);
57878 + unsigned long offset = gr_rand_threadstack_offset(mm, file, flags);
57879 struct vm_unmapped_area_info info;
57880
57881 if (len & ~huge_page_mask(h))
57882 @@ -165,17 +166,26 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
57883 return addr;
57884 }
57885
57886 +#ifdef CONFIG_PAX_RANDMMAP
57887 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
57888 +#endif
57889 +
57890 if (addr) {
57891 addr = ALIGN(addr, huge_page_size(h));
57892 vma = find_vma(mm, addr);
57893 - if (TASK_SIZE - len >= addr &&
57894 - (!vma || addr + len <= vma->vm_start))
57895 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
57896 return addr;
57897 }
57898
57899 info.flags = 0;
57900 info.length = len;
57901 info.low_limit = TASK_UNMAPPED_BASE;
57902 +
57903 +#ifdef CONFIG_PAX_RANDMMAP
57904 + if (mm->pax_flags & MF_PAX_RANDMMAP)
57905 + info.low_limit += mm->delta_mmap;
57906 +#endif
57907 +
57908 info.high_limit = TASK_SIZE;
57909 info.align_mask = PAGE_MASK & ~huge_page_mask(h);
57910 info.align_offset = 0;
57911 @@ -908,7 +918,7 @@ static struct file_system_type hugetlbfs_fs_type = {
57912 };
57913 MODULE_ALIAS_FS("hugetlbfs");
57914
57915 -static struct vfsmount *hugetlbfs_vfsmount[HUGE_MAX_HSTATE];
57916 +struct vfsmount *hugetlbfs_vfsmount[HUGE_MAX_HSTATE];
57917
57918 static int can_do_hugetlb_shm(void)
57919 {
57920 diff --git a/fs/inode.c b/fs/inode.c
57921 index b33ba8e..3c79a47 100644
57922 --- a/fs/inode.c
57923 +++ b/fs/inode.c
57924 @@ -849,8 +849,8 @@ unsigned int get_next_ino(void)
57925
57926 #ifdef CONFIG_SMP
57927 if (unlikely((res & (LAST_INO_BATCH-1)) == 0)) {
57928 - static atomic_t shared_last_ino;
57929 - int next = atomic_add_return(LAST_INO_BATCH, &shared_last_ino);
57930 + static atomic_unchecked_t shared_last_ino;
57931 + int next = atomic_add_return_unchecked(LAST_INO_BATCH, &shared_last_ino);
57932
57933 res = next - LAST_INO_BATCH;
57934 }
57935 diff --git a/fs/jffs2/erase.c b/fs/jffs2/erase.c
57936 index 4a6cf28..d3a29d3 100644
57937 --- a/fs/jffs2/erase.c
57938 +++ b/fs/jffs2/erase.c
57939 @@ -452,7 +452,8 @@ static void jffs2_mark_erased_block(struct jffs2_sb_info *c, struct jffs2_eraseb
57940 struct jffs2_unknown_node marker = {
57941 .magic = cpu_to_je16(JFFS2_MAGIC_BITMASK),
57942 .nodetype = cpu_to_je16(JFFS2_NODETYPE_CLEANMARKER),
57943 - .totlen = cpu_to_je32(c->cleanmarker_size)
57944 + .totlen = cpu_to_je32(c->cleanmarker_size),
57945 + .hdr_crc = cpu_to_je32(0)
57946 };
57947
57948 jffs2_prealloc_raw_node_refs(c, jeb, 1);
57949 diff --git a/fs/jffs2/wbuf.c b/fs/jffs2/wbuf.c
57950 index a6597d6..41b30ec 100644
57951 --- a/fs/jffs2/wbuf.c
57952 +++ b/fs/jffs2/wbuf.c
57953 @@ -1023,7 +1023,8 @@ static const struct jffs2_unknown_node oob_cleanmarker =
57954 {
57955 .magic = constant_cpu_to_je16(JFFS2_MAGIC_BITMASK),
57956 .nodetype = constant_cpu_to_je16(JFFS2_NODETYPE_CLEANMARKER),
57957 - .totlen = constant_cpu_to_je32(8)
57958 + .totlen = constant_cpu_to_je32(8),
57959 + .hdr_crc = constant_cpu_to_je32(0)
57960 };
57961
57962 /*
57963 diff --git a/fs/jfs/super.c b/fs/jfs/super.c
57964 index 6669aa2..36b033d 100644
57965 --- a/fs/jfs/super.c
57966 +++ b/fs/jfs/super.c
57967 @@ -882,7 +882,7 @@ static int __init init_jfs_fs(void)
57968
57969 jfs_inode_cachep =
57970 kmem_cache_create("jfs_ip", sizeof(struct jfs_inode_info), 0,
57971 - SLAB_RECLAIM_ACCOUNT|SLAB_MEM_SPREAD,
57972 + SLAB_RECLAIM_ACCOUNT|SLAB_MEM_SPREAD|SLAB_USERCOPY,
57973 init_once);
57974 if (jfs_inode_cachep == NULL)
57975 return -ENOMEM;
57976 diff --git a/fs/libfs.c b/fs/libfs.c
57977 index 193e0c2..7404665 100644
57978 --- a/fs/libfs.c
57979 +++ b/fs/libfs.c
57980 @@ -150,6 +150,9 @@ int dcache_readdir(struct file *file, struct dir_context *ctx)
57981
57982 for (p = q->next; p != &dentry->d_subdirs; p = p->next) {
57983 struct dentry *next = list_entry(p, struct dentry, d_u.d_child);
57984 + char d_name[sizeof(next->d_iname)];
57985 + const unsigned char *name;
57986 +
57987 spin_lock_nested(&next->d_lock, DENTRY_D_LOCK_NESTED);
57988 if (!simple_positive(next)) {
57989 spin_unlock(&next->d_lock);
57990 @@ -158,7 +161,12 @@ int dcache_readdir(struct file *file, struct dir_context *ctx)
57991
57992 spin_unlock(&next->d_lock);
57993 spin_unlock(&dentry->d_lock);
57994 - if (!dir_emit(ctx, next->d_name.name, next->d_name.len,
57995 + name = next->d_name.name;
57996 + if (name == next->d_iname) {
57997 + memcpy(d_name, name, next->d_name.len);
57998 + name = d_name;
57999 + }
58000 + if (!dir_emit(ctx, name, next->d_name.len,
58001 next->d_inode->i_ino, dt_type(next->d_inode)))
58002 return 0;
58003 spin_lock(&dentry->d_lock);
58004 diff --git a/fs/lockd/clntproc.c b/fs/lockd/clntproc.c
58005 index acd3947..1f896e2 100644
58006 --- a/fs/lockd/clntproc.c
58007 +++ b/fs/lockd/clntproc.c
58008 @@ -36,11 +36,11 @@ static const struct rpc_call_ops nlmclnt_cancel_ops;
58009 /*
58010 * Cookie counter for NLM requests
58011 */
58012 -static atomic_t nlm_cookie = ATOMIC_INIT(0x1234);
58013 +static atomic_unchecked_t nlm_cookie = ATOMIC_INIT(0x1234);
58014
58015 void nlmclnt_next_cookie(struct nlm_cookie *c)
58016 {
58017 - u32 cookie = atomic_inc_return(&nlm_cookie);
58018 + u32 cookie = atomic_inc_return_unchecked(&nlm_cookie);
58019
58020 memcpy(c->data, &cookie, 4);
58021 c->len=4;
58022 diff --git a/fs/locks.c b/fs/locks.c
58023 index b27a300..4156d0b 100644
58024 --- a/fs/locks.c
58025 +++ b/fs/locks.c
58026 @@ -2183,16 +2183,16 @@ void locks_remove_flock(struct file *filp)
58027 return;
58028
58029 if (filp->f_op && filp->f_op->flock) {
58030 - struct file_lock fl = {
58031 + struct file_lock flock = {
58032 .fl_pid = current->tgid,
58033 .fl_file = filp,
58034 .fl_flags = FL_FLOCK,
58035 .fl_type = F_UNLCK,
58036 .fl_end = OFFSET_MAX,
58037 };
58038 - filp->f_op->flock(filp, F_SETLKW, &fl);
58039 - if (fl.fl_ops && fl.fl_ops->fl_release_private)
58040 - fl.fl_ops->fl_release_private(&fl);
58041 + filp->f_op->flock(filp, F_SETLKW, &flock);
58042 + if (flock.fl_ops && flock.fl_ops->fl_release_private)
58043 + flock.fl_ops->fl_release_private(&flock);
58044 }
58045
58046 spin_lock(&inode->i_lock);
58047 diff --git a/fs/namei.c b/fs/namei.c
58048 index 23ac50f..c6757a5 100644
58049 --- a/fs/namei.c
58050 +++ b/fs/namei.c
58051 @@ -319,16 +319,32 @@ int generic_permission(struct inode *inode, int mask)
58052 if (ret != -EACCES)
58053 return ret;
58054
58055 +#ifdef CONFIG_GRKERNSEC
58056 + /* we'll block if we have to log due to a denied capability use */
58057 + if (mask & MAY_NOT_BLOCK)
58058 + return -ECHILD;
58059 +#endif
58060 +
58061 if (S_ISDIR(inode->i_mode)) {
58062 /* DACs are overridable for directories */
58063 - if (inode_capable(inode, CAP_DAC_OVERRIDE))
58064 - return 0;
58065 if (!(mask & MAY_WRITE))
58066 - if (inode_capable(inode, CAP_DAC_READ_SEARCH))
58067 + if (inode_capable_nolog(inode, CAP_DAC_OVERRIDE) ||
58068 + inode_capable(inode, CAP_DAC_READ_SEARCH))
58069 return 0;
58070 + if (inode_capable(inode, CAP_DAC_OVERRIDE))
58071 + return 0;
58072 return -EACCES;
58073 }
58074 /*
58075 + * Searching includes executable on directories, else just read.
58076 + */
58077 + mask &= MAY_READ | MAY_WRITE | MAY_EXEC;
58078 + if (mask == MAY_READ)
58079 + if (inode_capable_nolog(inode, CAP_DAC_OVERRIDE) ||
58080 + inode_capable(inode, CAP_DAC_READ_SEARCH))
58081 + return 0;
58082 +
58083 + /*
58084 * Read/write DACs are always overridable.
58085 * Executable DACs are overridable when there is
58086 * at least one exec bit set.
58087 @@ -337,14 +353,6 @@ int generic_permission(struct inode *inode, int mask)
58088 if (inode_capable(inode, CAP_DAC_OVERRIDE))
58089 return 0;
58090
58091 - /*
58092 - * Searching includes executable on directories, else just read.
58093 - */
58094 - mask &= MAY_READ | MAY_WRITE | MAY_EXEC;
58095 - if (mask == MAY_READ)
58096 - if (inode_capable(inode, CAP_DAC_READ_SEARCH))
58097 - return 0;
58098 -
58099 return -EACCES;
58100 }
58101
58102 @@ -821,7 +829,7 @@ follow_link(struct path *link, struct nameidata *nd, void **p)
58103 {
58104 struct dentry *dentry = link->dentry;
58105 int error;
58106 - char *s;
58107 + const char *s;
58108
58109 BUG_ON(nd->flags & LOOKUP_RCU);
58110
58111 @@ -842,6 +850,12 @@ follow_link(struct path *link, struct nameidata *nd, void **p)
58112 if (error)
58113 goto out_put_nd_path;
58114
58115 + if (gr_handle_follow_link(dentry->d_parent->d_inode,
58116 + dentry->d_inode, dentry, nd->path.mnt)) {
58117 + error = -EACCES;
58118 + goto out_put_nd_path;
58119 + }
58120 +
58121 nd->last_type = LAST_BIND;
58122 *p = dentry->d_inode->i_op->follow_link(dentry, nd);
58123 error = PTR_ERR(*p);
58124 @@ -1602,6 +1616,8 @@ static inline int nested_symlink(struct path *path, struct nameidata *nd)
58125 if (res)
58126 break;
58127 res = walk_component(nd, path, LOOKUP_FOLLOW);
58128 + if (res >= 0 && gr_handle_symlink_owner(&link, nd->inode))
58129 + res = -EACCES;
58130 put_link(nd, &link, cookie);
58131 } while (res > 0);
58132
58133 @@ -1700,7 +1716,7 @@ EXPORT_SYMBOL(full_name_hash);
58134 static inline unsigned long hash_name(const char *name, unsigned int *hashp)
58135 {
58136 unsigned long a, b, adata, bdata, mask, hash, len;
58137 - const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
58138 + static const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
58139
58140 hash = a = 0;
58141 len = -sizeof(unsigned long);
58142 @@ -1981,6 +1997,8 @@ static int path_lookupat(int dfd, const char *name,
58143 if (err)
58144 break;
58145 err = lookup_last(nd, &path);
58146 + if (!err && gr_handle_symlink_owner(&link, nd->inode))
58147 + err = -EACCES;
58148 put_link(nd, &link, cookie);
58149 }
58150 }
58151 @@ -1988,6 +2006,13 @@ static int path_lookupat(int dfd, const char *name,
58152 if (!err)
58153 err = complete_walk(nd);
58154
58155 + if (!err && !(nd->flags & LOOKUP_PARENT)) {
58156 + if (!gr_acl_handle_hidden_file(nd->path.dentry, nd->path.mnt)) {
58157 + path_put(&nd->path);
58158 + err = -ENOENT;
58159 + }
58160 + }
58161 +
58162 if (!err && nd->flags & LOOKUP_DIRECTORY) {
58163 if (!can_lookup(nd->inode)) {
58164 path_put(&nd->path);
58165 @@ -2015,8 +2040,15 @@ static int filename_lookup(int dfd, struct filename *name,
58166 retval = path_lookupat(dfd, name->name,
58167 flags | LOOKUP_REVAL, nd);
58168
58169 - if (likely(!retval))
58170 + if (likely(!retval)) {
58171 audit_inode(name, nd->path.dentry, flags & LOOKUP_PARENT);
58172 + if (name->name[0] != '/' && nd->path.dentry && nd->inode) {
58173 + if (!gr_chroot_fchdir(nd->path.dentry, nd->path.mnt)) {
58174 + path_put(&nd->path);
58175 + return -ENOENT;
58176 + }
58177 + }
58178 + }
58179 return retval;
58180 }
58181
58182 @@ -2587,6 +2619,13 @@ static int may_open(struct path *path, int acc_mode, int flag)
58183 if (flag & O_NOATIME && !inode_owner_or_capable(inode))
58184 return -EPERM;
58185
58186 + if (gr_handle_rofs_blockwrite(dentry, path->mnt, acc_mode))
58187 + return -EPERM;
58188 + if (gr_handle_rawio(inode))
58189 + return -EPERM;
58190 + if (!gr_acl_handle_open(dentry, path->mnt, acc_mode))
58191 + return -EACCES;
58192 +
58193 return 0;
58194 }
58195
58196 @@ -2818,7 +2857,7 @@ looked_up:
58197 * cleared otherwise prior to returning.
58198 */
58199 static int lookup_open(struct nameidata *nd, struct path *path,
58200 - struct file *file,
58201 + struct path *link, struct file *file,
58202 const struct open_flags *op,
58203 bool got_write, int *opened)
58204 {
58205 @@ -2853,6 +2892,17 @@ static int lookup_open(struct nameidata *nd, struct path *path,
58206 /* Negative dentry, just create the file */
58207 if (!dentry->d_inode && (op->open_flag & O_CREAT)) {
58208 umode_t mode = op->mode;
58209 +
58210 + if (link && gr_handle_symlink_owner(link, dir->d_inode)) {
58211 + error = -EACCES;
58212 + goto out_dput;
58213 + }
58214 +
58215 + if (!gr_acl_handle_creat(dentry, dir, nd->path.mnt, op->open_flag, op->acc_mode, mode)) {
58216 + error = -EACCES;
58217 + goto out_dput;
58218 + }
58219 +
58220 if (!IS_POSIXACL(dir->d_inode))
58221 mode &= ~current_umask();
58222 /*
58223 @@ -2874,6 +2924,8 @@ static int lookup_open(struct nameidata *nd, struct path *path,
58224 nd->flags & LOOKUP_EXCL);
58225 if (error)
58226 goto out_dput;
58227 + else
58228 + gr_handle_create(dentry, nd->path.mnt);
58229 }
58230 out_no_open:
58231 path->dentry = dentry;
58232 @@ -2888,7 +2940,7 @@ out_dput:
58233 /*
58234 * Handle the last step of open()
58235 */
58236 -static int do_last(struct nameidata *nd, struct path *path,
58237 +static int do_last(struct nameidata *nd, struct path *path, struct path *link,
58238 struct file *file, const struct open_flags *op,
58239 int *opened, struct filename *name)
58240 {
58241 @@ -2938,6 +2990,15 @@ static int do_last(struct nameidata *nd, struct path *path,
58242 if (error)
58243 return error;
58244
58245 + if (!gr_acl_handle_hidden_file(dir, nd->path.mnt)) {
58246 + error = -ENOENT;
58247 + goto out;
58248 + }
58249 + if (link && gr_handle_symlink_owner(link, nd->inode)) {
58250 + error = -EACCES;
58251 + goto out;
58252 + }
58253 +
58254 audit_inode(name, dir, LOOKUP_PARENT);
58255 error = -EISDIR;
58256 /* trailing slashes? */
58257 @@ -2957,7 +3018,7 @@ retry_lookup:
58258 */
58259 }
58260 mutex_lock(&dir->d_inode->i_mutex);
58261 - error = lookup_open(nd, path, file, op, got_write, opened);
58262 + error = lookup_open(nd, path, link, file, op, got_write, opened);
58263 mutex_unlock(&dir->d_inode->i_mutex);
58264
58265 if (error <= 0) {
58266 @@ -2981,11 +3042,28 @@ retry_lookup:
58267 goto finish_open_created;
58268 }
58269
58270 + if (!gr_acl_handle_hidden_file(path->dentry, nd->path.mnt)) {
58271 + error = -ENOENT;
58272 + goto exit_dput;
58273 + }
58274 + if (link && gr_handle_symlink_owner(link, path->dentry->d_inode)) {
58275 + error = -EACCES;
58276 + goto exit_dput;
58277 + }
58278 +
58279 /*
58280 * create/update audit record if it already exists.
58281 */
58282 - if (path->dentry->d_inode)
58283 + if (path->dentry->d_inode) {
58284 + /* only check if O_CREAT is specified, all other checks need to go
58285 + into may_open */
58286 + if (gr_handle_fifo(path->dentry, path->mnt, dir, open_flag, acc_mode)) {
58287 + error = -EACCES;
58288 + goto exit_dput;
58289 + }
58290 +
58291 audit_inode(name, path->dentry, 0);
58292 + }
58293
58294 /*
58295 * If atomic_open() acquired write access it is dropped now due to
58296 @@ -3026,6 +3104,11 @@ finish_lookup:
58297 }
58298 }
58299 BUG_ON(inode != path->dentry->d_inode);
58300 + /* if we're resolving a symlink to another symlink */
58301 + if (link && gr_handle_symlink_owner(link, inode)) {
58302 + error = -EACCES;
58303 + goto out;
58304 + }
58305 return 1;
58306 }
58307
58308 @@ -3035,7 +3118,6 @@ finish_lookup:
58309 save_parent.dentry = nd->path.dentry;
58310 save_parent.mnt = mntget(path->mnt);
58311 nd->path.dentry = path->dentry;
58312 -
58313 }
58314 nd->inode = inode;
58315 /* Why this, you ask? _Now_ we might have grown LOOKUP_JUMPED... */
58316 @@ -3045,7 +3127,18 @@ finish_open:
58317 path_put(&save_parent);
58318 return error;
58319 }
58320 +
58321 + if (!gr_acl_handle_hidden_file(nd->path.dentry, nd->path.mnt)) {
58322 + error = -ENOENT;
58323 + goto out;
58324 + }
58325 + if (link && gr_handle_symlink_owner(link, nd->inode)) {
58326 + error = -EACCES;
58327 + goto out;
58328 + }
58329 +
58330 audit_inode(name, nd->path.dentry, 0);
58331 +
58332 error = -EISDIR;
58333 if ((open_flag & O_CREAT) && S_ISDIR(nd->inode->i_mode))
58334 goto out;
58335 @@ -3208,7 +3301,7 @@ static struct file *path_openat(int dfd, struct filename *pathname,
58336 if (unlikely(error))
58337 goto out;
58338
58339 - error = do_last(nd, &path, file, op, &opened, pathname);
58340 + error = do_last(nd, &path, NULL, file, op, &opened, pathname);
58341 while (unlikely(error > 0)) { /* trailing symlink */
58342 struct path link = path;
58343 void *cookie;
58344 @@ -3226,7 +3319,7 @@ static struct file *path_openat(int dfd, struct filename *pathname,
58345 error = follow_link(&link, nd, &cookie);
58346 if (unlikely(error))
58347 break;
58348 - error = do_last(nd, &path, file, op, &opened, pathname);
58349 + error = do_last(nd, &path, &link, file, op, &opened, pathname);
58350 put_link(nd, &link, cookie);
58351 }
58352 out:
58353 @@ -3326,8 +3419,12 @@ struct dentry *kern_path_create(int dfd, const char *pathname,
58354 goto unlock;
58355
58356 error = -EEXIST;
58357 - if (dentry->d_inode)
58358 + if (dentry->d_inode) {
58359 + if (!gr_acl_handle_hidden_file(dentry, nd.path.mnt)) {
58360 + error = -ENOENT;
58361 + }
58362 goto fail;
58363 + }
58364 /*
58365 * Special case - lookup gave negative, but... we had foo/bar/
58366 * From the vfs_mknod() POV we just have a negative dentry -
58367 @@ -3379,6 +3476,20 @@ struct dentry *user_path_create(int dfd, const char __user *pathname,
58368 }
58369 EXPORT_SYMBOL(user_path_create);
58370
58371 +static struct dentry *user_path_create_with_name(int dfd, const char __user *pathname, struct path *path, struct filename **to, unsigned int lookup_flags)
58372 +{
58373 + struct filename *tmp = getname(pathname);
58374 + struct dentry *res;
58375 + if (IS_ERR(tmp))
58376 + return ERR_CAST(tmp);
58377 + res = kern_path_create(dfd, tmp->name, path, lookup_flags);
58378 + if (IS_ERR(res))
58379 + putname(tmp);
58380 + else
58381 + *to = tmp;
58382 + return res;
58383 +}
58384 +
58385 int vfs_mknod(struct inode *dir, struct dentry *dentry, umode_t mode, dev_t dev)
58386 {
58387 int error = may_create(dir, dentry);
58388 @@ -3441,6 +3552,17 @@ retry:
58389
58390 if (!IS_POSIXACL(path.dentry->d_inode))
58391 mode &= ~current_umask();
58392 +
58393 + if (gr_handle_chroot_mknod(dentry, path.mnt, mode)) {
58394 + error = -EPERM;
58395 + goto out;
58396 + }
58397 +
58398 + if (!gr_acl_handle_mknod(dentry, path.dentry, path.mnt, mode)) {
58399 + error = -EACCES;
58400 + goto out;
58401 + }
58402 +
58403 error = security_path_mknod(&path, dentry, mode, dev);
58404 if (error)
58405 goto out;
58406 @@ -3457,6 +3579,8 @@ retry:
58407 break;
58408 }
58409 out:
58410 + if (!error)
58411 + gr_handle_create(dentry, path.mnt);
58412 done_path_create(&path, dentry);
58413 if (retry_estale(error, lookup_flags)) {
58414 lookup_flags |= LOOKUP_REVAL;
58415 @@ -3509,9 +3633,16 @@ retry:
58416
58417 if (!IS_POSIXACL(path.dentry->d_inode))
58418 mode &= ~current_umask();
58419 + if (!gr_acl_handle_mkdir(dentry, path.dentry, path.mnt)) {
58420 + error = -EACCES;
58421 + goto out;
58422 + }
58423 error = security_path_mkdir(&path, dentry, mode);
58424 if (!error)
58425 error = vfs_mkdir(path.dentry->d_inode, dentry, mode);
58426 + if (!error)
58427 + gr_handle_create(dentry, path.mnt);
58428 +out:
58429 done_path_create(&path, dentry);
58430 if (retry_estale(error, lookup_flags)) {
58431 lookup_flags |= LOOKUP_REVAL;
58432 @@ -3592,6 +3723,8 @@ static long do_rmdir(int dfd, const char __user *pathname)
58433 struct filename *name;
58434 struct dentry *dentry;
58435 struct nameidata nd;
58436 + ino_t saved_ino = 0;
58437 + dev_t saved_dev = 0;
58438 unsigned int lookup_flags = 0;
58439 retry:
58440 name = user_path_parent(dfd, pathname, &nd, lookup_flags);
58441 @@ -3624,10 +3757,21 @@ retry:
58442 error = -ENOENT;
58443 goto exit3;
58444 }
58445 +
58446 + saved_ino = dentry->d_inode->i_ino;
58447 + saved_dev = gr_get_dev_from_dentry(dentry);
58448 +
58449 + if (!gr_acl_handle_rmdir(dentry, nd.path.mnt)) {
58450 + error = -EACCES;
58451 + goto exit3;
58452 + }
58453 +
58454 error = security_path_rmdir(&nd.path, dentry);
58455 if (error)
58456 goto exit3;
58457 error = vfs_rmdir(nd.path.dentry->d_inode, dentry);
58458 + if (!error && (saved_dev || saved_ino))
58459 + gr_handle_delete(saved_ino, saved_dev);
58460 exit3:
58461 dput(dentry);
58462 exit2:
58463 @@ -3693,6 +3837,8 @@ static long do_unlinkat(int dfd, const char __user *pathname)
58464 struct dentry *dentry;
58465 struct nameidata nd;
58466 struct inode *inode = NULL;
58467 + ino_t saved_ino = 0;
58468 + dev_t saved_dev = 0;
58469 unsigned int lookup_flags = 0;
58470 retry:
58471 name = user_path_parent(dfd, pathname, &nd, lookup_flags);
58472 @@ -3719,10 +3865,22 @@ retry:
58473 if (!inode)
58474 goto slashes;
58475 ihold(inode);
58476 +
58477 + if (inode->i_nlink <= 1) {
58478 + saved_ino = inode->i_ino;
58479 + saved_dev = gr_get_dev_from_dentry(dentry);
58480 + }
58481 + if (!gr_acl_handle_unlink(dentry, nd.path.mnt)) {
58482 + error = -EACCES;
58483 + goto exit2;
58484 + }
58485 +
58486 error = security_path_unlink(&nd.path, dentry);
58487 if (error)
58488 goto exit2;
58489 error = vfs_unlink(nd.path.dentry->d_inode, dentry);
58490 + if (!error && (saved_ino || saved_dev))
58491 + gr_handle_delete(saved_ino, saved_dev);
58492 exit2:
58493 dput(dentry);
58494 }
58495 @@ -3800,9 +3958,17 @@ retry:
58496 if (IS_ERR(dentry))
58497 goto out_putname;
58498
58499 + if (!gr_acl_handle_symlink(dentry, path.dentry, path.mnt, from)) {
58500 + error = -EACCES;
58501 + goto out;
58502 + }
58503 +
58504 error = security_path_symlink(&path, dentry, from->name);
58505 if (!error)
58506 error = vfs_symlink(path.dentry->d_inode, dentry, from->name);
58507 + if (!error)
58508 + gr_handle_create(dentry, path.mnt);
58509 +out:
58510 done_path_create(&path, dentry);
58511 if (retry_estale(error, lookup_flags)) {
58512 lookup_flags |= LOOKUP_REVAL;
58513 @@ -3882,6 +4048,7 @@ SYSCALL_DEFINE5(linkat, int, olddfd, const char __user *, oldname,
58514 {
58515 struct dentry *new_dentry;
58516 struct path old_path, new_path;
58517 + struct filename *to = NULL;
58518 int how = 0;
58519 int error;
58520
58521 @@ -3905,7 +4072,7 @@ retry:
58522 if (error)
58523 return error;
58524
58525 - new_dentry = user_path_create(newdfd, newname, &new_path,
58526 + new_dentry = user_path_create_with_name(newdfd, newname, &new_path, &to,
58527 (how & LOOKUP_REVAL));
58528 error = PTR_ERR(new_dentry);
58529 if (IS_ERR(new_dentry))
58530 @@ -3917,11 +4084,28 @@ retry:
58531 error = may_linkat(&old_path);
58532 if (unlikely(error))
58533 goto out_dput;
58534 +
58535 + if (gr_handle_hardlink(old_path.dentry, old_path.mnt,
58536 + old_path.dentry->d_inode,
58537 + old_path.dentry->d_inode->i_mode, to)) {
58538 + error = -EACCES;
58539 + goto out_dput;
58540 + }
58541 +
58542 + if (!gr_acl_handle_link(new_dentry, new_path.dentry, new_path.mnt,
58543 + old_path.dentry, old_path.mnt, to)) {
58544 + error = -EACCES;
58545 + goto out_dput;
58546 + }
58547 +
58548 error = security_path_link(old_path.dentry, &new_path, new_dentry);
58549 if (error)
58550 goto out_dput;
58551 error = vfs_link(old_path.dentry, new_path.dentry->d_inode, new_dentry);
58552 + if (!error)
58553 + gr_handle_create(new_dentry, new_path.mnt);
58554 out_dput:
58555 + putname(to);
58556 done_path_create(&new_path, new_dentry);
58557 if (retry_estale(error, how)) {
58558 how |= LOOKUP_REVAL;
58559 @@ -4167,12 +4351,21 @@ retry:
58560 if (new_dentry == trap)
58561 goto exit5;
58562
58563 + error = gr_acl_handle_rename(new_dentry, new_dir, newnd.path.mnt,
58564 + old_dentry, old_dir->d_inode, oldnd.path.mnt,
58565 + to);
58566 + if (error)
58567 + goto exit5;
58568 +
58569 error = security_path_rename(&oldnd.path, old_dentry,
58570 &newnd.path, new_dentry);
58571 if (error)
58572 goto exit5;
58573 error = vfs_rename(old_dir->d_inode, old_dentry,
58574 new_dir->d_inode, new_dentry);
58575 + if (!error)
58576 + gr_handle_rename(old_dir->d_inode, new_dir->d_inode, old_dentry,
58577 + new_dentry, oldnd.path.mnt, new_dentry->d_inode ? 1 : 0);
58578 exit5:
58579 dput(new_dentry);
58580 exit4:
58581 @@ -4204,6 +4397,8 @@ SYSCALL_DEFINE2(rename, const char __user *, oldname, const char __user *, newna
58582
58583 int vfs_readlink(struct dentry *dentry, char __user *buffer, int buflen, const char *link)
58584 {
58585 + char tmpbuf[64];
58586 + const char *newlink;
58587 int len;
58588
58589 len = PTR_ERR(link);
58590 @@ -4213,7 +4408,14 @@ int vfs_readlink(struct dentry *dentry, char __user *buffer, int buflen, const c
58591 len = strlen(link);
58592 if (len > (unsigned) buflen)
58593 len = buflen;
58594 - if (copy_to_user(buffer, link, len))
58595 +
58596 + if (len < sizeof(tmpbuf)) {
58597 + memcpy(tmpbuf, link, len);
58598 + newlink = tmpbuf;
58599 + } else
58600 + newlink = link;
58601 +
58602 + if (copy_to_user(buffer, newlink, len))
58603 len = -EFAULT;
58604 out:
58605 return len;
58606 diff --git a/fs/namespace.c b/fs/namespace.c
58607 index da5c494..a755a54 100644
58608 --- a/fs/namespace.c
58609 +++ b/fs/namespace.c
58610 @@ -1268,6 +1268,9 @@ static int do_umount(struct mount *mnt, int flags)
58611 if (!(sb->s_flags & MS_RDONLY))
58612 retval = do_remount_sb(sb, MS_RDONLY, NULL, 0);
58613 up_write(&sb->s_umount);
58614 +
58615 + gr_log_remount(mnt->mnt_devname, retval);
58616 +
58617 return retval;
58618 }
58619
58620 @@ -1286,6 +1289,9 @@ static int do_umount(struct mount *mnt, int flags)
58621 }
58622 br_write_unlock(&vfsmount_lock);
58623 namespace_unlock();
58624 +
58625 + gr_log_unmount(mnt->mnt_devname, retval);
58626 +
58627 return retval;
58628 }
58629
58630 @@ -1305,7 +1311,7 @@ static inline bool may_mount(void)
58631 * unixes. Our API is identical to OSF/1 to avoid making a mess of AMD
58632 */
58633
58634 -SYSCALL_DEFINE2(umount, char __user *, name, int, flags)
58635 +SYSCALL_DEFINE2(umount, const char __user *, name, int, flags)
58636 {
58637 struct path path;
58638 struct mount *mnt;
58639 @@ -1347,7 +1353,7 @@ out:
58640 /*
58641 * The 2.0 compatible umount. No flags.
58642 */
58643 -SYSCALL_DEFINE1(oldumount, char __user *, name)
58644 +SYSCALL_DEFINE1(oldumount, const char __user *, name)
58645 {
58646 return sys_umount(name, 0);
58647 }
58648 @@ -2358,6 +2364,16 @@ long do_mount(const char *dev_name, const char *dir_name,
58649 MS_NOATIME | MS_NODIRATIME | MS_RELATIME| MS_KERNMOUNT |
58650 MS_STRICTATIME);
58651
58652 + if (gr_handle_rofs_mount(path.dentry, path.mnt, mnt_flags)) {
58653 + retval = -EPERM;
58654 + goto dput_out;
58655 + }
58656 +
58657 + if (gr_handle_chroot_mount(path.dentry, path.mnt, dev_name)) {
58658 + retval = -EPERM;
58659 + goto dput_out;
58660 + }
58661 +
58662 if (flags & MS_REMOUNT)
58663 retval = do_remount(&path, flags & ~MS_REMOUNT, mnt_flags,
58664 data_page);
58665 @@ -2372,6 +2388,9 @@ long do_mount(const char *dev_name, const char *dir_name,
58666 dev_name, data_page);
58667 dput_out:
58668 path_put(&path);
58669 +
58670 + gr_log_mount(dev_name, dir_name, retval);
58671 +
58672 return retval;
58673 }
58674
58675 @@ -2389,7 +2408,7 @@ static void free_mnt_ns(struct mnt_namespace *ns)
58676 * number incrementing at 10Ghz will take 12,427 years to wrap which
58677 * is effectively never, so we can ignore the possibility.
58678 */
58679 -static atomic64_t mnt_ns_seq = ATOMIC64_INIT(1);
58680 +static atomic64_unchecked_t mnt_ns_seq = ATOMIC64_INIT(1);
58681
58682 static struct mnt_namespace *alloc_mnt_ns(struct user_namespace *user_ns)
58683 {
58684 @@ -2404,7 +2423,7 @@ static struct mnt_namespace *alloc_mnt_ns(struct user_namespace *user_ns)
58685 kfree(new_ns);
58686 return ERR_PTR(ret);
58687 }
58688 - new_ns->seq = atomic64_add_return(1, &mnt_ns_seq);
58689 + new_ns->seq = atomic64_inc_return_unchecked(&mnt_ns_seq);
58690 atomic_set(&new_ns->count, 1);
58691 new_ns->root = NULL;
58692 INIT_LIST_HEAD(&new_ns->list);
58693 @@ -2418,7 +2437,7 @@ static struct mnt_namespace *alloc_mnt_ns(struct user_namespace *user_ns)
58694 * Allocate a new namespace structure and populate it with contents
58695 * copied from the namespace of the passed in task structure.
58696 */
58697 -static struct mnt_namespace *dup_mnt_ns(struct mnt_namespace *mnt_ns,
58698 +static __latent_entropy struct mnt_namespace *dup_mnt_ns(struct mnt_namespace *mnt_ns,
58699 struct user_namespace *user_ns, struct fs_struct *fs)
58700 {
58701 struct mnt_namespace *new_ns;
58702 @@ -2549,8 +2568,8 @@ struct dentry *mount_subtree(struct vfsmount *mnt, const char *name)
58703 }
58704 EXPORT_SYMBOL(mount_subtree);
58705
58706 -SYSCALL_DEFINE5(mount, char __user *, dev_name, char __user *, dir_name,
58707 - char __user *, type, unsigned long, flags, void __user *, data)
58708 +SYSCALL_DEFINE5(mount, const char __user *, dev_name, const char __user *, dir_name,
58709 + const char __user *, type, unsigned long, flags, void __user *, data)
58710 {
58711 int ret;
58712 char *kernel_type;
58713 @@ -2663,6 +2682,11 @@ SYSCALL_DEFINE2(pivot_root, const char __user *, new_root,
58714 if (error)
58715 goto out2;
58716
58717 + if (gr_handle_chroot_pivot()) {
58718 + error = -EPERM;
58719 + goto out2;
58720 + }
58721 +
58722 get_fs_root(current->fs, &root);
58723 old_mp = lock_mount(&old);
58724 error = PTR_ERR(old_mp);
58725 @@ -2932,7 +2956,7 @@ static int mntns_install(struct nsproxy *nsproxy, void *ns)
58726 !ns_capable(current_user_ns(), CAP_SYS_ADMIN))
58727 return -EPERM;
58728
58729 - if (fs->users != 1)
58730 + if (atomic_read(&fs->users) != 1)
58731 return -EINVAL;
58732
58733 get_mnt_ns(mnt_ns);
58734 diff --git a/fs/nfs/callback_xdr.c b/fs/nfs/callback_xdr.c
58735 index f4ccfe6..a5cf064 100644
58736 --- a/fs/nfs/callback_xdr.c
58737 +++ b/fs/nfs/callback_xdr.c
58738 @@ -51,7 +51,7 @@ struct callback_op {
58739 callback_decode_arg_t decode_args;
58740 callback_encode_res_t encode_res;
58741 long res_maxsize;
58742 -};
58743 +} __do_const;
58744
58745 static struct callback_op callback_ops[];
58746
58747 diff --git a/fs/nfs/inode.c b/fs/nfs/inode.c
58748 index eda8879..bfc6837 100644
58749 --- a/fs/nfs/inode.c
58750 +++ b/fs/nfs/inode.c
58751 @@ -1150,16 +1150,16 @@ static int nfs_size_need_update(const struct inode *inode, const struct nfs_fatt
58752 return nfs_size_to_loff_t(fattr->size) > i_size_read(inode);
58753 }
58754
58755 -static atomic_long_t nfs_attr_generation_counter;
58756 +static atomic_long_unchecked_t nfs_attr_generation_counter;
58757
58758 static unsigned long nfs_read_attr_generation_counter(void)
58759 {
58760 - return atomic_long_read(&nfs_attr_generation_counter);
58761 + return atomic_long_read_unchecked(&nfs_attr_generation_counter);
58762 }
58763
58764 unsigned long nfs_inc_attr_generation_counter(void)
58765 {
58766 - return atomic_long_inc_return(&nfs_attr_generation_counter);
58767 + return atomic_long_inc_return_unchecked(&nfs_attr_generation_counter);
58768 }
58769
58770 void nfs_fattr_init(struct nfs_fattr *fattr)
58771 diff --git a/fs/nfsd/nfs4proc.c b/fs/nfsd/nfs4proc.c
58772 index 419572f..5414a23 100644
58773 --- a/fs/nfsd/nfs4proc.c
58774 +++ b/fs/nfsd/nfs4proc.c
58775 @@ -1168,7 +1168,7 @@ struct nfsd4_operation {
58776 nfsd4op_rsize op_rsize_bop;
58777 stateid_getter op_get_currentstateid;
58778 stateid_setter op_set_currentstateid;
58779 -};
58780 +} __do_const;
58781
58782 static struct nfsd4_operation nfsd4_ops[];
58783
58784 diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c
58785 index ecc735e..79b2d31 100644
58786 --- a/fs/nfsd/nfs4xdr.c
58787 +++ b/fs/nfsd/nfs4xdr.c
58788 @@ -1500,7 +1500,7 @@ nfsd4_decode_notsupp(struct nfsd4_compoundargs *argp, void *p)
58789
58790 typedef __be32(*nfsd4_dec)(struct nfsd4_compoundargs *argp, void *);
58791
58792 -static nfsd4_dec nfsd4_dec_ops[] = {
58793 +static const nfsd4_dec nfsd4_dec_ops[] = {
58794 [OP_ACCESS] = (nfsd4_dec)nfsd4_decode_access,
58795 [OP_CLOSE] = (nfsd4_dec)nfsd4_decode_close,
58796 [OP_COMMIT] = (nfsd4_dec)nfsd4_decode_commit,
58797 @@ -1540,7 +1540,7 @@ static nfsd4_dec nfsd4_dec_ops[] = {
58798 [OP_RELEASE_LOCKOWNER] = (nfsd4_dec)nfsd4_decode_release_lockowner,
58799 };
58800
58801 -static nfsd4_dec nfsd41_dec_ops[] = {
58802 +static const nfsd4_dec nfsd41_dec_ops[] = {
58803 [OP_ACCESS] = (nfsd4_dec)nfsd4_decode_access,
58804 [OP_CLOSE] = (nfsd4_dec)nfsd4_decode_close,
58805 [OP_COMMIT] = (nfsd4_dec)nfsd4_decode_commit,
58806 @@ -1602,7 +1602,7 @@ static nfsd4_dec nfsd41_dec_ops[] = {
58807 };
58808
58809 struct nfsd4_minorversion_ops {
58810 - nfsd4_dec *decoders;
58811 + const nfsd4_dec *decoders;
58812 int nops;
58813 };
58814
58815 diff --git a/fs/nfsd/nfscache.c b/fs/nfsd/nfscache.c
58816 index 9186c7c..3fdde3e 100644
58817 --- a/fs/nfsd/nfscache.c
58818 +++ b/fs/nfsd/nfscache.c
58819 @@ -540,14 +540,17 @@ nfsd_cache_update(struct svc_rqst *rqstp, int cachetype, __be32 *statp)
58820 {
58821 struct svc_cacherep *rp = rqstp->rq_cacherep;
58822 struct kvec *resv = &rqstp->rq_res.head[0], *cachv;
58823 - int len;
58824 + long len;
58825 size_t bufsize = 0;
58826
58827 if (!rp)
58828 return;
58829
58830 - len = resv->iov_len - ((char*)statp - (char*)resv->iov_base);
58831 - len >>= 2;
58832 + if (statp) {
58833 + len = (char*)statp - (char*)resv->iov_base;
58834 + len = resv->iov_len - len;
58835 + len >>= 2;
58836 + }
58837
58838 /* Don't cache excessive amounts of data and XDR failures */
58839 if (!statp || len > (256 >> 2)) {
58840 diff --git a/fs/nfsd/vfs.c b/fs/nfsd/vfs.c
58841 index 72cb28e..5b5f87d 100644
58842 --- a/fs/nfsd/vfs.c
58843 +++ b/fs/nfsd/vfs.c
58844 @@ -993,7 +993,7 @@ nfsd_vfs_read(struct svc_rqst *rqstp, struct svc_fh *fhp, struct file *file,
58845 } else {
58846 oldfs = get_fs();
58847 set_fs(KERNEL_DS);
58848 - host_err = vfs_readv(file, (struct iovec __user *)vec, vlen, &offset);
58849 + host_err = vfs_readv(file, (struct iovec __force_user *)vec, vlen, &offset);
58850 set_fs(oldfs);
58851 }
58852
58853 @@ -1080,7 +1080,7 @@ nfsd_vfs_write(struct svc_rqst *rqstp, struct svc_fh *fhp, struct file *file,
58854
58855 /* Write the data. */
58856 oldfs = get_fs(); set_fs(KERNEL_DS);
58857 - host_err = vfs_writev(file, (struct iovec __user *)vec, vlen, &pos);
58858 + host_err = vfs_writev(file, (struct iovec __force_user *)vec, vlen, &pos);
58859 set_fs(oldfs);
58860 if (host_err < 0)
58861 goto out_nfserr;
58862 @@ -1626,7 +1626,7 @@ nfsd_readlink(struct svc_rqst *rqstp, struct svc_fh *fhp, char *buf, int *lenp)
58863 */
58864
58865 oldfs = get_fs(); set_fs(KERNEL_DS);
58866 - host_err = inode->i_op->readlink(path.dentry, (char __user *)buf, *lenp);
58867 + host_err = inode->i_op->readlink(path.dentry, (char __force_user *)buf, *lenp);
58868 set_fs(oldfs);
58869
58870 if (host_err < 0)
58871 diff --git a/fs/nls/nls_base.c b/fs/nls/nls_base.c
58872 index fea6bd5..8ee9d81 100644
58873 --- a/fs/nls/nls_base.c
58874 +++ b/fs/nls/nls_base.c
58875 @@ -234,20 +234,22 @@ EXPORT_SYMBOL(utf16s_to_utf8s);
58876
58877 int register_nls(struct nls_table * nls)
58878 {
58879 - struct nls_table ** tmp = &tables;
58880 + struct nls_table *tmp = tables;
58881
58882 if (nls->next)
58883 return -EBUSY;
58884
58885 spin_lock(&nls_lock);
58886 - while (*tmp) {
58887 - if (nls == *tmp) {
58888 + while (tmp) {
58889 + if (nls == tmp) {
58890 spin_unlock(&nls_lock);
58891 return -EBUSY;
58892 }
58893 - tmp = &(*tmp)->next;
58894 + tmp = tmp->next;
58895 }
58896 - nls->next = tables;
58897 + pax_open_kernel();
58898 + *(struct nls_table **)&nls->next = tables;
58899 + pax_close_kernel();
58900 tables = nls;
58901 spin_unlock(&nls_lock);
58902 return 0;
58903 @@ -255,12 +257,14 @@ int register_nls(struct nls_table * nls)
58904
58905 int unregister_nls(struct nls_table * nls)
58906 {
58907 - struct nls_table ** tmp = &tables;
58908 + struct nls_table * const * tmp = &tables;
58909
58910 spin_lock(&nls_lock);
58911 while (*tmp) {
58912 if (nls == *tmp) {
58913 - *tmp = nls->next;
58914 + pax_open_kernel();
58915 + *(struct nls_table **)tmp = nls->next;
58916 + pax_close_kernel();
58917 spin_unlock(&nls_lock);
58918 return 0;
58919 }
58920 diff --git a/fs/nls/nls_euc-jp.c b/fs/nls/nls_euc-jp.c
58921 index 7424929..35f6be5 100644
58922 --- a/fs/nls/nls_euc-jp.c
58923 +++ b/fs/nls/nls_euc-jp.c
58924 @@ -561,8 +561,10 @@ static int __init init_nls_euc_jp(void)
58925 p_nls = load_nls("cp932");
58926
58927 if (p_nls) {
58928 - table.charset2upper = p_nls->charset2upper;
58929 - table.charset2lower = p_nls->charset2lower;
58930 + pax_open_kernel();
58931 + *(const unsigned char **)&table.charset2upper = p_nls->charset2upper;
58932 + *(const unsigned char **)&table.charset2lower = p_nls->charset2lower;
58933 + pax_close_kernel();
58934 return register_nls(&table);
58935 }
58936
58937 diff --git a/fs/nls/nls_koi8-ru.c b/fs/nls/nls_koi8-ru.c
58938 index e7bc1d7..06bd4bb 100644
58939 --- a/fs/nls/nls_koi8-ru.c
58940 +++ b/fs/nls/nls_koi8-ru.c
58941 @@ -63,8 +63,10 @@ static int __init init_nls_koi8_ru(void)
58942 p_nls = load_nls("koi8-u");
58943
58944 if (p_nls) {
58945 - table.charset2upper = p_nls->charset2upper;
58946 - table.charset2lower = p_nls->charset2lower;
58947 + pax_open_kernel();
58948 + *(const unsigned char **)&table.charset2upper = p_nls->charset2upper;
58949 + *(const unsigned char **)&table.charset2lower = p_nls->charset2lower;
58950 + pax_close_kernel();
58951 return register_nls(&table);
58952 }
58953
58954 diff --git a/fs/notify/fanotify/fanotify_user.c b/fs/notify/fanotify/fanotify_user.c
58955 index e44cb64..4807084 100644
58956 --- a/fs/notify/fanotify/fanotify_user.c
58957 +++ b/fs/notify/fanotify/fanotify_user.c
58958 @@ -253,8 +253,8 @@ static ssize_t copy_event_to_user(struct fsnotify_group *group,
58959
58960 fd = fanotify_event_metadata.fd;
58961 ret = -EFAULT;
58962 - if (copy_to_user(buf, &fanotify_event_metadata,
58963 - fanotify_event_metadata.event_len))
58964 + if (fanotify_event_metadata.event_len > sizeof fanotify_event_metadata ||
58965 + copy_to_user(buf, &fanotify_event_metadata, fanotify_event_metadata.event_len))
58966 goto out_close_fd;
58967
58968 ret = prepare_for_access_response(group, event, fd);
58969 diff --git a/fs/notify/notification.c b/fs/notify/notification.c
58970 index 7b51b05..5ea5ef6 100644
58971 --- a/fs/notify/notification.c
58972 +++ b/fs/notify/notification.c
58973 @@ -57,7 +57,7 @@ static struct kmem_cache *fsnotify_event_holder_cachep;
58974 * get set to 0 so it will never get 'freed'
58975 */
58976 static struct fsnotify_event *q_overflow_event;
58977 -static atomic_t fsnotify_sync_cookie = ATOMIC_INIT(0);
58978 +static atomic_unchecked_t fsnotify_sync_cookie = ATOMIC_INIT(0);
58979
58980 /**
58981 * fsnotify_get_cookie - return a unique cookie for use in synchronizing events.
58982 @@ -65,7 +65,7 @@ static atomic_t fsnotify_sync_cookie = ATOMIC_INIT(0);
58983 */
58984 u32 fsnotify_get_cookie(void)
58985 {
58986 - return atomic_inc_return(&fsnotify_sync_cookie);
58987 + return atomic_inc_return_unchecked(&fsnotify_sync_cookie);
58988 }
58989 EXPORT_SYMBOL_GPL(fsnotify_get_cookie);
58990
58991 diff --git a/fs/ntfs/dir.c b/fs/ntfs/dir.c
58992 index 9e38daf..5727cae 100644
58993 --- a/fs/ntfs/dir.c
58994 +++ b/fs/ntfs/dir.c
58995 @@ -1310,7 +1310,7 @@ find_next_index_buffer:
58996 ia = (INDEX_ALLOCATION*)(kaddr + (ia_pos & ~PAGE_CACHE_MASK &
58997 ~(s64)(ndir->itype.index.block_size - 1)));
58998 /* Bounds checks. */
58999 - if (unlikely((u8*)ia < kaddr || (u8*)ia > kaddr + PAGE_CACHE_SIZE)) {
59000 + if (unlikely(!kaddr || (u8*)ia < kaddr || (u8*)ia > kaddr + PAGE_CACHE_SIZE)) {
59001 ntfs_error(sb, "Out of bounds check failed. Corrupt directory "
59002 "inode 0x%lx or driver bug.", vdir->i_ino);
59003 goto err_out;
59004 diff --git a/fs/ntfs/file.c b/fs/ntfs/file.c
59005 index ea4ba9d..1e13d34 100644
59006 --- a/fs/ntfs/file.c
59007 +++ b/fs/ntfs/file.c
59008 @@ -1282,7 +1282,7 @@ static inline size_t ntfs_copy_from_user(struct page **pages,
59009 char *addr;
59010 size_t total = 0;
59011 unsigned len;
59012 - int left;
59013 + unsigned left;
59014
59015 do {
59016 len = PAGE_CACHE_SIZE - ofs;
59017 diff --git a/fs/ntfs/super.c b/fs/ntfs/super.c
59018 index 82650d5..db37dcf 100644
59019 --- a/fs/ntfs/super.c
59020 +++ b/fs/ntfs/super.c
59021 @@ -685,7 +685,7 @@ static struct buffer_head *read_ntfs_boot_sector(struct super_block *sb,
59022 if (!silent)
59023 ntfs_error(sb, "Primary boot sector is invalid.");
59024 } else if (!silent)
59025 - ntfs_error(sb, read_err_str, "primary");
59026 + ntfs_error(sb, read_err_str, "%s", "primary");
59027 if (!(NTFS_SB(sb)->on_errors & ON_ERRORS_RECOVER)) {
59028 if (bh_primary)
59029 brelse(bh_primary);
59030 @@ -701,7 +701,7 @@ static struct buffer_head *read_ntfs_boot_sector(struct super_block *sb,
59031 goto hotfix_primary_boot_sector;
59032 brelse(bh_backup);
59033 } else if (!silent)
59034 - ntfs_error(sb, read_err_str, "backup");
59035 + ntfs_error(sb, read_err_str, "%s", "backup");
59036 /* Try to read NT3.51- backup boot sector. */
59037 if ((bh_backup = sb_bread(sb, nr_blocks >> 1))) {
59038 if (is_boot_sector_ntfs(sb, (NTFS_BOOT_SECTOR*)
59039 @@ -712,7 +712,7 @@ static struct buffer_head *read_ntfs_boot_sector(struct super_block *sb,
59040 "sector.");
59041 brelse(bh_backup);
59042 } else if (!silent)
59043 - ntfs_error(sb, read_err_str, "backup");
59044 + ntfs_error(sb, read_err_str, "%s", "backup");
59045 /* We failed. Cleanup and return. */
59046 if (bh_primary)
59047 brelse(bh_primary);
59048 diff --git a/fs/ocfs2/localalloc.c b/fs/ocfs2/localalloc.c
59049 index cd5496b..26a1055 100644
59050 --- a/fs/ocfs2/localalloc.c
59051 +++ b/fs/ocfs2/localalloc.c
59052 @@ -1278,7 +1278,7 @@ static int ocfs2_local_alloc_slide_window(struct ocfs2_super *osb,
59053 goto bail;
59054 }
59055
59056 - atomic_inc(&osb->alloc_stats.moves);
59057 + atomic_inc_unchecked(&osb->alloc_stats.moves);
59058
59059 bail:
59060 if (handle)
59061 diff --git a/fs/ocfs2/ocfs2.h b/fs/ocfs2/ocfs2.h
59062 index 3a90347..c40bef8 100644
59063 --- a/fs/ocfs2/ocfs2.h
59064 +++ b/fs/ocfs2/ocfs2.h
59065 @@ -235,11 +235,11 @@ enum ocfs2_vol_state
59066
59067 struct ocfs2_alloc_stats
59068 {
59069 - atomic_t moves;
59070 - atomic_t local_data;
59071 - atomic_t bitmap_data;
59072 - atomic_t bg_allocs;
59073 - atomic_t bg_extends;
59074 + atomic_unchecked_t moves;
59075 + atomic_unchecked_t local_data;
59076 + atomic_unchecked_t bitmap_data;
59077 + atomic_unchecked_t bg_allocs;
59078 + atomic_unchecked_t bg_extends;
59079 };
59080
59081 enum ocfs2_local_alloc_state
59082 diff --git a/fs/ocfs2/suballoc.c b/fs/ocfs2/suballoc.c
59083 index 5397c07..54afc55 100644
59084 --- a/fs/ocfs2/suballoc.c
59085 +++ b/fs/ocfs2/suballoc.c
59086 @@ -872,7 +872,7 @@ static int ocfs2_reserve_suballoc_bits(struct ocfs2_super *osb,
59087 mlog_errno(status);
59088 goto bail;
59089 }
59090 - atomic_inc(&osb->alloc_stats.bg_extends);
59091 + atomic_inc_unchecked(&osb->alloc_stats.bg_extends);
59092
59093 /* You should never ask for this much metadata */
59094 BUG_ON(bits_wanted >
59095 @@ -2000,7 +2000,7 @@ int ocfs2_claim_metadata(handle_t *handle,
59096 mlog_errno(status);
59097 goto bail;
59098 }
59099 - atomic_inc(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
59100 + atomic_inc_unchecked(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
59101
59102 *suballoc_loc = res.sr_bg_blkno;
59103 *suballoc_bit_start = res.sr_bit_offset;
59104 @@ -2164,7 +2164,7 @@ int ocfs2_claim_new_inode_at_loc(handle_t *handle,
59105 trace_ocfs2_claim_new_inode_at_loc((unsigned long long)di_blkno,
59106 res->sr_bits);
59107
59108 - atomic_inc(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
59109 + atomic_inc_unchecked(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
59110
59111 BUG_ON(res->sr_bits != 1);
59112
59113 @@ -2206,7 +2206,7 @@ int ocfs2_claim_new_inode(handle_t *handle,
59114 mlog_errno(status);
59115 goto bail;
59116 }
59117 - atomic_inc(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
59118 + atomic_inc_unchecked(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
59119
59120 BUG_ON(res.sr_bits != 1);
59121
59122 @@ -2310,7 +2310,7 @@ int __ocfs2_claim_clusters(handle_t *handle,
59123 cluster_start,
59124 num_clusters);
59125 if (!status)
59126 - atomic_inc(&osb->alloc_stats.local_data);
59127 + atomic_inc_unchecked(&osb->alloc_stats.local_data);
59128 } else {
59129 if (min_clusters > (osb->bitmap_cpg - 1)) {
59130 /* The only paths asking for contiguousness
59131 @@ -2336,7 +2336,7 @@ int __ocfs2_claim_clusters(handle_t *handle,
59132 ocfs2_desc_bitmap_to_cluster_off(ac->ac_inode,
59133 res.sr_bg_blkno,
59134 res.sr_bit_offset);
59135 - atomic_inc(&osb->alloc_stats.bitmap_data);
59136 + atomic_inc_unchecked(&osb->alloc_stats.bitmap_data);
59137 *num_clusters = res.sr_bits;
59138 }
59139 }
59140 diff --git a/fs/ocfs2/super.c b/fs/ocfs2/super.c
59141 index d4e81e4..ad89f5f 100644
59142 --- a/fs/ocfs2/super.c
59143 +++ b/fs/ocfs2/super.c
59144 @@ -300,11 +300,11 @@ static int ocfs2_osb_dump(struct ocfs2_super *osb, char *buf, int len)
59145 "%10s => GlobalAllocs: %d LocalAllocs: %d "
59146 "SubAllocs: %d LAWinMoves: %d SAExtends: %d\n",
59147 "Stats",
59148 - atomic_read(&osb->alloc_stats.bitmap_data),
59149 - atomic_read(&osb->alloc_stats.local_data),
59150 - atomic_read(&osb->alloc_stats.bg_allocs),
59151 - atomic_read(&osb->alloc_stats.moves),
59152 - atomic_read(&osb->alloc_stats.bg_extends));
59153 + atomic_read_unchecked(&osb->alloc_stats.bitmap_data),
59154 + atomic_read_unchecked(&osb->alloc_stats.local_data),
59155 + atomic_read_unchecked(&osb->alloc_stats.bg_allocs),
59156 + atomic_read_unchecked(&osb->alloc_stats.moves),
59157 + atomic_read_unchecked(&osb->alloc_stats.bg_extends));
59158
59159 out += snprintf(buf + out, len - out,
59160 "%10s => State: %u Descriptor: %llu Size: %u bits "
59161 @@ -2121,11 +2121,11 @@ static int ocfs2_initialize_super(struct super_block *sb,
59162 spin_lock_init(&osb->osb_xattr_lock);
59163 ocfs2_init_steal_slots(osb);
59164
59165 - atomic_set(&osb->alloc_stats.moves, 0);
59166 - atomic_set(&osb->alloc_stats.local_data, 0);
59167 - atomic_set(&osb->alloc_stats.bitmap_data, 0);
59168 - atomic_set(&osb->alloc_stats.bg_allocs, 0);
59169 - atomic_set(&osb->alloc_stats.bg_extends, 0);
59170 + atomic_set_unchecked(&osb->alloc_stats.moves, 0);
59171 + atomic_set_unchecked(&osb->alloc_stats.local_data, 0);
59172 + atomic_set_unchecked(&osb->alloc_stats.bitmap_data, 0);
59173 + atomic_set_unchecked(&osb->alloc_stats.bg_allocs, 0);
59174 + atomic_set_unchecked(&osb->alloc_stats.bg_extends, 0);
59175
59176 /* Copy the blockcheck stats from the superblock probe */
59177 osb->osb_ecc_stats = *stats;
59178 diff --git a/fs/open.c b/fs/open.c
59179 index d420331..2dbb3fd 100644
59180 --- a/fs/open.c
59181 +++ b/fs/open.c
59182 @@ -32,6 +32,8 @@
59183 #include <linux/dnotify.h>
59184 #include <linux/compat.h>
59185
59186 +#define CREATE_TRACE_POINTS
59187 +#include <trace/events/fs.h>
59188 #include "internal.h"
59189
59190 int do_truncate(struct dentry *dentry, loff_t length, unsigned int time_attrs,
59191 @@ -102,6 +104,8 @@ long vfs_truncate(struct path *path, loff_t length)
59192 error = locks_verify_truncate(inode, NULL, length);
59193 if (!error)
59194 error = security_path_truncate(path);
59195 + if (!error && !gr_acl_handle_truncate(path->dentry, path->mnt))
59196 + error = -EACCES;
59197 if (!error)
59198 error = do_truncate(path->dentry, length, 0, NULL);
59199
59200 @@ -186,6 +190,8 @@ static long do_sys_ftruncate(unsigned int fd, loff_t length, int small)
59201 error = locks_verify_truncate(inode, f.file, length);
59202 if (!error)
59203 error = security_path_truncate(&f.file->f_path);
59204 + if (!error && !gr_acl_handle_truncate(f.file->f_path.dentry, f.file->f_path.mnt))
59205 + error = -EACCES;
59206 if (!error)
59207 error = do_truncate(dentry, length, ATTR_MTIME|ATTR_CTIME, f.file);
59208 sb_end_write(inode->i_sb);
59209 @@ -360,6 +366,9 @@ retry:
59210 if (__mnt_is_readonly(path.mnt))
59211 res = -EROFS;
59212
59213 + if (!res && !gr_acl_handle_access(path.dentry, path.mnt, mode))
59214 + res = -EACCES;
59215 +
59216 out_path_release:
59217 path_put(&path);
59218 if (retry_estale(res, lookup_flags)) {
59219 @@ -391,6 +400,8 @@ retry:
59220 if (error)
59221 goto dput_and_out;
59222
59223 + gr_log_chdir(path.dentry, path.mnt);
59224 +
59225 set_fs_pwd(current->fs, &path);
59226
59227 dput_and_out:
59228 @@ -420,6 +431,13 @@ SYSCALL_DEFINE1(fchdir, unsigned int, fd)
59229 goto out_putf;
59230
59231 error = inode_permission(inode, MAY_EXEC | MAY_CHDIR);
59232 +
59233 + if (!error && !gr_chroot_fchdir(f.file->f_path.dentry, f.file->f_path.mnt))
59234 + error = -EPERM;
59235 +
59236 + if (!error)
59237 + gr_log_chdir(f.file->f_path.dentry, f.file->f_path.mnt);
59238 +
59239 if (!error)
59240 set_fs_pwd(current->fs, &f.file->f_path);
59241 out_putf:
59242 @@ -449,7 +467,13 @@ retry:
59243 if (error)
59244 goto dput_and_out;
59245
59246 + if (gr_handle_chroot_chroot(path.dentry, path.mnt))
59247 + goto dput_and_out;
59248 +
59249 set_fs_root(current->fs, &path);
59250 +
59251 + gr_handle_chroot_chdir(&path);
59252 +
59253 error = 0;
59254 dput_and_out:
59255 path_put(&path);
59256 @@ -471,6 +495,16 @@ static int chmod_common(struct path *path, umode_t mode)
59257 if (error)
59258 return error;
59259 mutex_lock(&inode->i_mutex);
59260 +
59261 + if (!gr_acl_handle_chmod(path->dentry, path->mnt, &mode)) {
59262 + error = -EACCES;
59263 + goto out_unlock;
59264 + }
59265 + if (gr_handle_chroot_chmod(path->dentry, path->mnt, mode)) {
59266 + error = -EACCES;
59267 + goto out_unlock;
59268 + }
59269 +
59270 error = security_path_chmod(path, mode);
59271 if (error)
59272 goto out_unlock;
59273 @@ -530,6 +564,9 @@ static int chown_common(struct path *path, uid_t user, gid_t group)
59274 uid = make_kuid(current_user_ns(), user);
59275 gid = make_kgid(current_user_ns(), group);
59276
59277 + if (!gr_acl_handle_chown(path->dentry, path->mnt))
59278 + return -EACCES;
59279 +
59280 newattrs.ia_valid = ATTR_CTIME;
59281 if (user != (uid_t) -1) {
59282 if (!uid_valid(uid))
59283 @@ -974,6 +1011,7 @@ long do_sys_open(int dfd, const char __user *filename, int flags, umode_t mode)
59284 } else {
59285 fsnotify_open(f);
59286 fd_install(fd, f);
59287 + trace_do_sys_open(tmp->name, flags, mode);
59288 }
59289 }
59290 putname(tmp);
59291 diff --git a/fs/pipe.c b/fs/pipe.c
59292 index d2c45e1..009fe1c 100644
59293 --- a/fs/pipe.c
59294 +++ b/fs/pipe.c
59295 @@ -56,7 +56,7 @@ unsigned int pipe_min_size = PAGE_SIZE;
59296
59297 static void pipe_lock_nested(struct pipe_inode_info *pipe, int subclass)
59298 {
59299 - if (pipe->files)
59300 + if (atomic_read(&pipe->files))
59301 mutex_lock_nested(&pipe->mutex, subclass);
59302 }
59303
59304 @@ -71,7 +71,7 @@ EXPORT_SYMBOL(pipe_lock);
59305
59306 void pipe_unlock(struct pipe_inode_info *pipe)
59307 {
59308 - if (pipe->files)
59309 + if (atomic_read(&pipe->files))
59310 mutex_unlock(&pipe->mutex);
59311 }
59312 EXPORT_SYMBOL(pipe_unlock);
59313 @@ -449,9 +449,9 @@ redo:
59314 }
59315 if (bufs) /* More to do? */
59316 continue;
59317 - if (!pipe->writers)
59318 + if (!atomic_read(&pipe->writers))
59319 break;
59320 - if (!pipe->waiting_writers) {
59321 + if (!atomic_read(&pipe->waiting_writers)) {
59322 /* syscall merging: Usually we must not sleep
59323 * if O_NONBLOCK is set, or if we got some data.
59324 * But if a writer sleeps in kernel space, then
59325 @@ -513,7 +513,7 @@ pipe_write(struct kiocb *iocb, const struct iovec *_iov,
59326 ret = 0;
59327 __pipe_lock(pipe);
59328
59329 - if (!pipe->readers) {
59330 + if (!atomic_read(&pipe->readers)) {
59331 send_sig(SIGPIPE, current, 0);
59332 ret = -EPIPE;
59333 goto out;
59334 @@ -562,7 +562,7 @@ redo1:
59335 for (;;) {
59336 int bufs;
59337
59338 - if (!pipe->readers) {
59339 + if (!atomic_read(&pipe->readers)) {
59340 send_sig(SIGPIPE, current, 0);
59341 if (!ret)
59342 ret = -EPIPE;
59343 @@ -653,9 +653,9 @@ redo2:
59344 kill_fasync(&pipe->fasync_readers, SIGIO, POLL_IN);
59345 do_wakeup = 0;
59346 }
59347 - pipe->waiting_writers++;
59348 + atomic_inc(&pipe->waiting_writers);
59349 pipe_wait(pipe);
59350 - pipe->waiting_writers--;
59351 + atomic_dec(&pipe->waiting_writers);
59352 }
59353 out:
59354 __pipe_unlock(pipe);
59355 @@ -709,7 +709,7 @@ pipe_poll(struct file *filp, poll_table *wait)
59356 mask = 0;
59357 if (filp->f_mode & FMODE_READ) {
59358 mask = (nrbufs > 0) ? POLLIN | POLLRDNORM : 0;
59359 - if (!pipe->writers && filp->f_version != pipe->w_counter)
59360 + if (!atomic_read(&pipe->writers) && filp->f_version != pipe->w_counter)
59361 mask |= POLLHUP;
59362 }
59363
59364 @@ -719,7 +719,7 @@ pipe_poll(struct file *filp, poll_table *wait)
59365 * Most Unices do not set POLLERR for FIFOs but on Linux they
59366 * behave exactly like pipes for poll().
59367 */
59368 - if (!pipe->readers)
59369 + if (!atomic_read(&pipe->readers))
59370 mask |= POLLERR;
59371 }
59372
59373 @@ -734,17 +734,17 @@ pipe_release(struct inode *inode, struct file *file)
59374
59375 __pipe_lock(pipe);
59376 if (file->f_mode & FMODE_READ)
59377 - pipe->readers--;
59378 + atomic_dec(&pipe->readers);
59379 if (file->f_mode & FMODE_WRITE)
59380 - pipe->writers--;
59381 + atomic_dec(&pipe->writers);
59382
59383 - if (pipe->readers || pipe->writers) {
59384 + if (atomic_read(&pipe->readers) || atomic_read(&pipe->writers)) {
59385 wake_up_interruptible_sync_poll(&pipe->wait, POLLIN | POLLOUT | POLLRDNORM | POLLWRNORM | POLLERR | POLLHUP);
59386 kill_fasync(&pipe->fasync_readers, SIGIO, POLL_IN);
59387 kill_fasync(&pipe->fasync_writers, SIGIO, POLL_OUT);
59388 }
59389 spin_lock(&inode->i_lock);
59390 - if (!--pipe->files) {
59391 + if (atomic_dec_and_test(&pipe->files)) {
59392 inode->i_pipe = NULL;
59393 kill = 1;
59394 }
59395 @@ -811,7 +811,7 @@ void free_pipe_info(struct pipe_inode_info *pipe)
59396 kfree(pipe);
59397 }
59398
59399 -static struct vfsmount *pipe_mnt __read_mostly;
59400 +struct vfsmount *pipe_mnt __read_mostly;
59401
59402 /*
59403 * pipefs_dname() is called from d_path().
59404 @@ -841,8 +841,9 @@ static struct inode * get_pipe_inode(void)
59405 goto fail_iput;
59406
59407 inode->i_pipe = pipe;
59408 - pipe->files = 2;
59409 - pipe->readers = pipe->writers = 1;
59410 + atomic_set(&pipe->files, 2);
59411 + atomic_set(&pipe->readers, 1);
59412 + atomic_set(&pipe->writers, 1);
59413 inode->i_fop = &pipefifo_fops;
59414
59415 /*
59416 @@ -1022,17 +1023,17 @@ static int fifo_open(struct inode *inode, struct file *filp)
59417 spin_lock(&inode->i_lock);
59418 if (inode->i_pipe) {
59419 pipe = inode->i_pipe;
59420 - pipe->files++;
59421 + atomic_inc(&pipe->files);
59422 spin_unlock(&inode->i_lock);
59423 } else {
59424 spin_unlock(&inode->i_lock);
59425 pipe = alloc_pipe_info();
59426 if (!pipe)
59427 return -ENOMEM;
59428 - pipe->files = 1;
59429 + atomic_set(&pipe->files, 1);
59430 spin_lock(&inode->i_lock);
59431 if (unlikely(inode->i_pipe)) {
59432 - inode->i_pipe->files++;
59433 + atomic_inc(&inode->i_pipe->files);
59434 spin_unlock(&inode->i_lock);
59435 free_pipe_info(pipe);
59436 pipe = inode->i_pipe;
59437 @@ -1057,10 +1058,10 @@ static int fifo_open(struct inode *inode, struct file *filp)
59438 * opened, even when there is no process writing the FIFO.
59439 */
59440 pipe->r_counter++;
59441 - if (pipe->readers++ == 0)
59442 + if (atomic_inc_return(&pipe->readers) == 1)
59443 wake_up_partner(pipe);
59444
59445 - if (!is_pipe && !pipe->writers) {
59446 + if (!is_pipe && !atomic_read(&pipe->writers)) {
59447 if ((filp->f_flags & O_NONBLOCK)) {
59448 /* suppress POLLHUP until we have
59449 * seen a writer */
59450 @@ -1079,14 +1080,14 @@ static int fifo_open(struct inode *inode, struct file *filp)
59451 * errno=ENXIO when there is no process reading the FIFO.
59452 */
59453 ret = -ENXIO;
59454 - if (!is_pipe && (filp->f_flags & O_NONBLOCK) && !pipe->readers)
59455 + if (!is_pipe && (filp->f_flags & O_NONBLOCK) && !atomic_read(&pipe->readers))
59456 goto err;
59457
59458 pipe->w_counter++;
59459 - if (!pipe->writers++)
59460 + if (atomic_inc_return(&pipe->writers) == 1)
59461 wake_up_partner(pipe);
59462
59463 - if (!is_pipe && !pipe->readers) {
59464 + if (!is_pipe && !atomic_read(&pipe->readers)) {
59465 if (wait_for_partner(pipe, &pipe->r_counter))
59466 goto err_wr;
59467 }
59468 @@ -1100,11 +1101,11 @@ static int fifo_open(struct inode *inode, struct file *filp)
59469 * the process can at least talk to itself.
59470 */
59471
59472 - pipe->readers++;
59473 - pipe->writers++;
59474 + atomic_inc(&pipe->readers);
59475 + atomic_inc(&pipe->writers);
59476 pipe->r_counter++;
59477 pipe->w_counter++;
59478 - if (pipe->readers == 1 || pipe->writers == 1)
59479 + if (atomic_read(&pipe->readers) == 1 || atomic_read(&pipe->writers) == 1)
59480 wake_up_partner(pipe);
59481 break;
59482
59483 @@ -1118,20 +1119,20 @@ static int fifo_open(struct inode *inode, struct file *filp)
59484 return 0;
59485
59486 err_rd:
59487 - if (!--pipe->readers)
59488 + if (atomic_dec_and_test(&pipe->readers))
59489 wake_up_interruptible(&pipe->wait);
59490 ret = -ERESTARTSYS;
59491 goto err;
59492
59493 err_wr:
59494 - if (!--pipe->writers)
59495 + if (atomic_dec_and_test(&pipe->writers))
59496 wake_up_interruptible(&pipe->wait);
59497 ret = -ERESTARTSYS;
59498 goto err;
59499
59500 err:
59501 spin_lock(&inode->i_lock);
59502 - if (!--pipe->files) {
59503 + if (atomic_dec_and_test(&pipe->files)) {
59504 inode->i_pipe = NULL;
59505 kill = 1;
59506 }
59507 diff --git a/fs/proc/Kconfig b/fs/proc/Kconfig
59508 index 15af622..0e9f4467 100644
59509 --- a/fs/proc/Kconfig
59510 +++ b/fs/proc/Kconfig
59511 @@ -30,12 +30,12 @@ config PROC_FS
59512
59513 config PROC_KCORE
59514 bool "/proc/kcore support" if !ARM
59515 - depends on PROC_FS && MMU
59516 + depends on PROC_FS && MMU && !GRKERNSEC_PROC_ADD
59517
59518 config PROC_VMCORE
59519 bool "/proc/vmcore support"
59520 - depends on PROC_FS && CRASH_DUMP
59521 - default y
59522 + depends on PROC_FS && CRASH_DUMP && !GRKERNSEC
59523 + default n
59524 help
59525 Exports the dump image of crashed kernel in ELF format.
59526
59527 @@ -59,8 +59,8 @@ config PROC_SYSCTL
59528 limited in memory.
59529
59530 config PROC_PAGE_MONITOR
59531 - default y
59532 - depends on PROC_FS && MMU
59533 + default n
59534 + depends on PROC_FS && MMU && !GRKERNSEC
59535 bool "Enable /proc page monitoring" if EXPERT
59536 help
59537 Various /proc files exist to monitor process memory utilization:
59538 diff --git a/fs/proc/array.c b/fs/proc/array.c
59539 index cbd0f1b..adec3f0 100644
59540 --- a/fs/proc/array.c
59541 +++ b/fs/proc/array.c
59542 @@ -60,6 +60,7 @@
59543 #include <linux/tty.h>
59544 #include <linux/string.h>
59545 #include <linux/mman.h>
59546 +#include <linux/grsecurity.h>
59547 #include <linux/proc_fs.h>
59548 #include <linux/ioport.h>
59549 #include <linux/uaccess.h>
59550 @@ -363,6 +364,21 @@ static void task_cpus_allowed(struct seq_file *m, struct task_struct *task)
59551 seq_putc(m, '\n');
59552 }
59553
59554 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
59555 +static inline void task_pax(struct seq_file *m, struct task_struct *p)
59556 +{
59557 + if (p->mm)
59558 + seq_printf(m, "PaX:\t%c%c%c%c%c\n",
59559 + p->mm->pax_flags & MF_PAX_PAGEEXEC ? 'P' : 'p',
59560 + p->mm->pax_flags & MF_PAX_EMUTRAMP ? 'E' : 'e',
59561 + p->mm->pax_flags & MF_PAX_MPROTECT ? 'M' : 'm',
59562 + p->mm->pax_flags & MF_PAX_RANDMMAP ? 'R' : 'r',
59563 + p->mm->pax_flags & MF_PAX_SEGMEXEC ? 'S' : 's');
59564 + else
59565 + seq_printf(m, "PaX:\t-----\n");
59566 +}
59567 +#endif
59568 +
59569 int proc_pid_status(struct seq_file *m, struct pid_namespace *ns,
59570 struct pid *pid, struct task_struct *task)
59571 {
59572 @@ -381,9 +397,24 @@ int proc_pid_status(struct seq_file *m, struct pid_namespace *ns,
59573 task_cpus_allowed(m, task);
59574 cpuset_task_status_allowed(m, task);
59575 task_context_switch_counts(m, task);
59576 +
59577 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
59578 + task_pax(m, task);
59579 +#endif
59580 +
59581 +#if defined(CONFIG_GRKERNSEC) && !defined(CONFIG_GRKERNSEC_NO_RBAC)
59582 + task_grsec_rbac(m, task);
59583 +#endif
59584 +
59585 return 0;
59586 }
59587
59588 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
59589 +#define PAX_RAND_FLAGS(_mm) (_mm != NULL && _mm != current->mm && \
59590 + (_mm->pax_flags & MF_PAX_RANDMMAP || \
59591 + _mm->pax_flags & MF_PAX_SEGMEXEC))
59592 +#endif
59593 +
59594 static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
59595 struct pid *pid, struct task_struct *task, int whole)
59596 {
59597 @@ -405,6 +436,13 @@ static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
59598 char tcomm[sizeof(task->comm)];
59599 unsigned long flags;
59600
59601 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
59602 + if (current->exec_id != m->exec_id) {
59603 + gr_log_badprocpid("stat");
59604 + return 0;
59605 + }
59606 +#endif
59607 +
59608 state = *get_task_state(task);
59609 vsize = eip = esp = 0;
59610 permitted = ptrace_may_access(task, PTRACE_MODE_READ | PTRACE_MODE_NOAUDIT);
59611 @@ -476,6 +514,19 @@ static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
59612 gtime = task_gtime(task);
59613 }
59614
59615 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
59616 + if (PAX_RAND_FLAGS(mm)) {
59617 + eip = 0;
59618 + esp = 0;
59619 + wchan = 0;
59620 + }
59621 +#endif
59622 +#ifdef CONFIG_GRKERNSEC_HIDESYM
59623 + wchan = 0;
59624 + eip =0;
59625 + esp =0;
59626 +#endif
59627 +
59628 /* scale priority and nice values from timeslices to -20..20 */
59629 /* to make it look like a "normal" Unix priority/nice value */
59630 priority = task_prio(task);
59631 @@ -512,9 +563,15 @@ static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
59632 seq_put_decimal_ull(m, ' ', vsize);
59633 seq_put_decimal_ull(m, ' ', mm ? get_mm_rss(mm) : 0);
59634 seq_put_decimal_ull(m, ' ', rsslim);
59635 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
59636 + seq_put_decimal_ull(m, ' ', PAX_RAND_FLAGS(mm) ? 1 : (mm ? (permitted ? mm->start_code : 1) : 0));
59637 + seq_put_decimal_ull(m, ' ', PAX_RAND_FLAGS(mm) ? 1 : (mm ? (permitted ? mm->end_code : 1) : 0));
59638 + seq_put_decimal_ull(m, ' ', PAX_RAND_FLAGS(mm) ? 0 : ((permitted && mm) ? mm->start_stack : 0));
59639 +#else
59640 seq_put_decimal_ull(m, ' ', mm ? (permitted ? mm->start_code : 1) : 0);
59641 seq_put_decimal_ull(m, ' ', mm ? (permitted ? mm->end_code : 1) : 0);
59642 seq_put_decimal_ull(m, ' ', (permitted && mm) ? mm->start_stack : 0);
59643 +#endif
59644 seq_put_decimal_ull(m, ' ', esp);
59645 seq_put_decimal_ull(m, ' ', eip);
59646 /* The signal information here is obsolete.
59647 @@ -536,7 +593,11 @@ static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
59648 seq_put_decimal_ull(m, ' ', cputime_to_clock_t(gtime));
59649 seq_put_decimal_ll(m, ' ', cputime_to_clock_t(cgtime));
59650
59651 - if (mm && permitted) {
59652 + if (mm && permitted
59653 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
59654 + && !PAX_RAND_FLAGS(mm)
59655 +#endif
59656 + ) {
59657 seq_put_decimal_ull(m, ' ', mm->start_data);
59658 seq_put_decimal_ull(m, ' ', mm->end_data);
59659 seq_put_decimal_ull(m, ' ', mm->start_brk);
59660 @@ -574,8 +635,15 @@ int proc_pid_statm(struct seq_file *m, struct pid_namespace *ns,
59661 struct pid *pid, struct task_struct *task)
59662 {
59663 unsigned long size = 0, resident = 0, shared = 0, text = 0, data = 0;
59664 - struct mm_struct *mm = get_task_mm(task);
59665 + struct mm_struct *mm;
59666
59667 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
59668 + if (current->exec_id != m->exec_id) {
59669 + gr_log_badprocpid("statm");
59670 + return 0;
59671 + }
59672 +#endif
59673 + mm = get_task_mm(task);
59674 if (mm) {
59675 size = task_statm(mm, &shared, &text, &data, &resident);
59676 mmput(mm);
59677 @@ -598,6 +666,13 @@ int proc_pid_statm(struct seq_file *m, struct pid_namespace *ns,
59678 return 0;
59679 }
59680
59681 +#ifdef CONFIG_GRKERNSEC_PROC_IPADDR
59682 +int proc_pid_ipaddr(struct task_struct *task, char *buffer)
59683 +{
59684 + return sprintf(buffer, "%pI4\n", &task->signal->curr_ip);
59685 +}
59686 +#endif
59687 +
59688 #ifdef CONFIG_CHECKPOINT_RESTORE
59689 static struct pid *
59690 get_children_pid(struct inode *inode, struct pid *pid_prev, loff_t pos)
59691 diff --git a/fs/proc/base.c b/fs/proc/base.c
59692 index 1485e38..8ad4236 100644
59693 --- a/fs/proc/base.c
59694 +++ b/fs/proc/base.c
59695 @@ -113,6 +113,14 @@ struct pid_entry {
59696 union proc_op op;
59697 };
59698
59699 +struct getdents_callback {
59700 + struct linux_dirent __user * current_dir;
59701 + struct linux_dirent __user * previous;
59702 + struct file * file;
59703 + int count;
59704 + int error;
59705 +};
59706 +
59707 #define NOD(NAME, MODE, IOP, FOP, OP) { \
59708 .name = (NAME), \
59709 .len = sizeof(NAME) - 1, \
59710 @@ -210,6 +218,9 @@ static int proc_pid_cmdline(struct task_struct *task, char * buffer)
59711 if (!mm->arg_end)
59712 goto out_mm; /* Shh! No looking before we're done */
59713
59714 + if (gr_acl_handle_procpidmem(task))
59715 + goto out_mm;
59716 +
59717 len = mm->arg_end - mm->arg_start;
59718
59719 if (len > PAGE_SIZE)
59720 @@ -237,12 +248,28 @@ out:
59721 return res;
59722 }
59723
59724 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
59725 +#define PAX_RAND_FLAGS(_mm) (_mm != NULL && _mm != current->mm && \
59726 + (_mm->pax_flags & MF_PAX_RANDMMAP || \
59727 + _mm->pax_flags & MF_PAX_SEGMEXEC))
59728 +#endif
59729 +
59730 static int proc_pid_auxv(struct task_struct *task, char *buffer)
59731 {
59732 struct mm_struct *mm = mm_access(task, PTRACE_MODE_READ);
59733 int res = PTR_ERR(mm);
59734 if (mm && !IS_ERR(mm)) {
59735 unsigned int nwords = 0;
59736 +
59737 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
59738 + /* allow if we're currently ptracing this task */
59739 + if (PAX_RAND_FLAGS(mm) &&
59740 + (!(task->ptrace & PT_PTRACED) || (task->parent != current))) {
59741 + mmput(mm);
59742 + return 0;
59743 + }
59744 +#endif
59745 +
59746 do {
59747 nwords += 2;
59748 } while (mm->saved_auxv[nwords - 2] != 0); /* AT_NULL */
59749 @@ -256,7 +283,7 @@ static int proc_pid_auxv(struct task_struct *task, char *buffer)
59750 }
59751
59752
59753 -#ifdef CONFIG_KALLSYMS
59754 +#if defined(CONFIG_KALLSYMS) && !defined(CONFIG_GRKERNSEC_HIDESYM)
59755 /*
59756 * Provides a wchan file via kallsyms in a proper one-value-per-file format.
59757 * Returns the resolved symbol. If that fails, simply return the address.
59758 @@ -295,7 +322,7 @@ static void unlock_trace(struct task_struct *task)
59759 mutex_unlock(&task->signal->cred_guard_mutex);
59760 }
59761
59762 -#ifdef CONFIG_STACKTRACE
59763 +#if defined(CONFIG_STACKTRACE) && !defined(CONFIG_GRKERNSEC_HIDESYM)
59764
59765 #define MAX_STACK_TRACE_DEPTH 64
59766
59767 @@ -518,7 +545,7 @@ static int proc_pid_limits(struct task_struct *task, char *buffer)
59768 return count;
59769 }
59770
59771 -#ifdef CONFIG_HAVE_ARCH_TRACEHOOK
59772 +#if defined(CONFIG_HAVE_ARCH_TRACEHOOK) && !defined(CONFIG_GRKERNSEC_PROC_MEMMAP)
59773 static int proc_pid_syscall(struct task_struct *task, char *buffer)
59774 {
59775 long nr;
59776 @@ -547,7 +574,7 @@ static int proc_pid_syscall(struct task_struct *task, char *buffer)
59777 /************************************************************************/
59778
59779 /* permission checks */
59780 -static int proc_fd_access_allowed(struct inode *inode)
59781 +static int proc_fd_access_allowed(struct inode *inode, unsigned int log)
59782 {
59783 struct task_struct *task;
59784 int allowed = 0;
59785 @@ -557,7 +584,10 @@ static int proc_fd_access_allowed(struct inode *inode)
59786 */
59787 task = get_proc_task(inode);
59788 if (task) {
59789 - allowed = ptrace_may_access(task, PTRACE_MODE_READ);
59790 + if (log)
59791 + allowed = ptrace_may_access(task, PTRACE_MODE_READ);
59792 + else
59793 + allowed = ptrace_may_access(task, PTRACE_MODE_READ | PTRACE_MODE_NOAUDIT);
59794 put_task_struct(task);
59795 }
59796 return allowed;
59797 @@ -588,10 +618,35 @@ static bool has_pid_permissions(struct pid_namespace *pid,
59798 struct task_struct *task,
59799 int hide_pid_min)
59800 {
59801 + if (gr_pid_is_chrooted(task) || gr_check_hidden_task(task))
59802 + return false;
59803 +
59804 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
59805 + rcu_read_lock();
59806 + {
59807 + const struct cred *tmpcred = current_cred();
59808 + const struct cred *cred = __task_cred(task);
59809 +
59810 + if (uid_eq(tmpcred->uid, GLOBAL_ROOT_UID) || uid_eq(tmpcred->uid, cred->uid)
59811 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
59812 + || in_group_p(grsec_proc_gid)
59813 +#endif
59814 + ) {
59815 + rcu_read_unlock();
59816 + return true;
59817 + }
59818 + }
59819 + rcu_read_unlock();
59820 +
59821 + if (!pid->hide_pid)
59822 + return false;
59823 +#endif
59824 +
59825 if (pid->hide_pid < hide_pid_min)
59826 return true;
59827 if (in_group_p(pid->pid_gid))
59828 return true;
59829 +
59830 return ptrace_may_access(task, PTRACE_MODE_READ);
59831 }
59832
59833 @@ -609,7 +664,11 @@ static int proc_pid_permission(struct inode *inode, int mask)
59834 put_task_struct(task);
59835
59836 if (!has_perms) {
59837 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
59838 + {
59839 +#else
59840 if (pid->hide_pid == 2) {
59841 +#endif
59842 /*
59843 * Let's make getdents(), stat(), and open()
59844 * consistent with each other. If a process
59845 @@ -707,6 +766,11 @@ static int __mem_open(struct inode *inode, struct file *file, unsigned int mode)
59846 if (!task)
59847 return -ESRCH;
59848
59849 + if (gr_acl_handle_procpidmem(task)) {
59850 + put_task_struct(task);
59851 + return -EPERM;
59852 + }
59853 +
59854 mm = mm_access(task, mode);
59855 put_task_struct(task);
59856
59857 @@ -722,6 +786,10 @@ static int __mem_open(struct inode *inode, struct file *file, unsigned int mode)
59858
59859 file->private_data = mm;
59860
59861 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
59862 + file->f_version = current->exec_id;
59863 +#endif
59864 +
59865 return 0;
59866 }
59867
59868 @@ -743,6 +811,17 @@ static ssize_t mem_rw(struct file *file, char __user *buf,
59869 ssize_t copied;
59870 char *page;
59871
59872 +#ifdef CONFIG_GRKERNSEC
59873 + if (write)
59874 + return -EPERM;
59875 +#endif
59876 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
59877 + if (file->f_version != current->exec_id) {
59878 + gr_log_badprocpid("mem");
59879 + return 0;
59880 + }
59881 +#endif
59882 +
59883 if (!mm)
59884 return 0;
59885
59886 @@ -755,7 +834,7 @@ static ssize_t mem_rw(struct file *file, char __user *buf,
59887 goto free;
59888
59889 while (count > 0) {
59890 - int this_len = min_t(int, count, PAGE_SIZE);
59891 + ssize_t this_len = min_t(ssize_t, count, PAGE_SIZE);
59892
59893 if (write && copy_from_user(page, buf, this_len)) {
59894 copied = -EFAULT;
59895 @@ -847,6 +926,13 @@ static ssize_t environ_read(struct file *file, char __user *buf,
59896 if (!mm)
59897 return 0;
59898
59899 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
59900 + if (file->f_version != current->exec_id) {
59901 + gr_log_badprocpid("environ");
59902 + return 0;
59903 + }
59904 +#endif
59905 +
59906 page = (char *)__get_free_page(GFP_TEMPORARY);
59907 if (!page)
59908 return -ENOMEM;
59909 @@ -856,7 +942,7 @@ static ssize_t environ_read(struct file *file, char __user *buf,
59910 goto free;
59911 while (count > 0) {
59912 size_t this_len, max_len;
59913 - int retval;
59914 + ssize_t retval;
59915
59916 if (src >= (mm->env_end - mm->env_start))
59917 break;
59918 @@ -1461,7 +1547,7 @@ static void *proc_pid_follow_link(struct dentry *dentry, struct nameidata *nd)
59919 int error = -EACCES;
59920
59921 /* Are we allowed to snoop on the tasks file descriptors? */
59922 - if (!proc_fd_access_allowed(inode))
59923 + if (!proc_fd_access_allowed(inode, 0))
59924 goto out;
59925
59926 error = PROC_I(inode)->op.proc_get_link(dentry, &path);
59927 @@ -1505,8 +1591,18 @@ static int proc_pid_readlink(struct dentry * dentry, char __user * buffer, int b
59928 struct path path;
59929
59930 /* Are we allowed to snoop on the tasks file descriptors? */
59931 - if (!proc_fd_access_allowed(inode))
59932 - goto out;
59933 + /* logging this is needed for learning on chromium to work properly,
59934 + but we don't want to flood the logs from 'ps' which does a readlink
59935 + on /proc/fd/2 of tasks in the listing, nor do we want 'ps' to learn
59936 + CAP_SYS_PTRACE as it's not necessary for its basic functionality
59937 + */
59938 + if (dentry->d_name.name[0] == '2' && dentry->d_name.name[1] == '\0') {
59939 + if (!proc_fd_access_allowed(inode,0))
59940 + goto out;
59941 + } else {
59942 + if (!proc_fd_access_allowed(inode,1))
59943 + goto out;
59944 + }
59945
59946 error = PROC_I(inode)->op.proc_get_link(dentry, &path);
59947 if (error)
59948 @@ -1556,7 +1652,11 @@ struct inode *proc_pid_make_inode(struct super_block * sb, struct task_struct *t
59949 rcu_read_lock();
59950 cred = __task_cred(task);
59951 inode->i_uid = cred->euid;
59952 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
59953 + inode->i_gid = grsec_proc_gid;
59954 +#else
59955 inode->i_gid = cred->egid;
59956 +#endif
59957 rcu_read_unlock();
59958 }
59959 security_task_to_inode(task, inode);
59960 @@ -1592,10 +1692,19 @@ int pid_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat)
59961 return -ENOENT;
59962 }
59963 if ((inode->i_mode == (S_IFDIR|S_IRUGO|S_IXUGO)) ||
59964 +#ifdef CONFIG_GRKERNSEC_PROC_USER
59965 + (inode->i_mode == (S_IFDIR|S_IRUSR|S_IXUSR)) ||
59966 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
59967 + (inode->i_mode == (S_IFDIR|S_IRUSR|S_IRGRP|S_IXUSR|S_IXGRP)) ||
59968 +#endif
59969 task_dumpable(task)) {
59970 cred = __task_cred(task);
59971 stat->uid = cred->euid;
59972 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
59973 + stat->gid = grsec_proc_gid;
59974 +#else
59975 stat->gid = cred->egid;
59976 +#endif
59977 }
59978 }
59979 rcu_read_unlock();
59980 @@ -1633,11 +1742,20 @@ int pid_revalidate(struct dentry *dentry, unsigned int flags)
59981
59982 if (task) {
59983 if ((inode->i_mode == (S_IFDIR|S_IRUGO|S_IXUGO)) ||
59984 +#ifdef CONFIG_GRKERNSEC_PROC_USER
59985 + (inode->i_mode == (S_IFDIR|S_IRUSR|S_IXUSR)) ||
59986 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
59987 + (inode->i_mode == (S_IFDIR|S_IRUSR|S_IRGRP|S_IXUSR|S_IXGRP)) ||
59988 +#endif
59989 task_dumpable(task)) {
59990 rcu_read_lock();
59991 cred = __task_cred(task);
59992 inode->i_uid = cred->euid;
59993 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
59994 + inode->i_gid = grsec_proc_gid;
59995 +#else
59996 inode->i_gid = cred->egid;
59997 +#endif
59998 rcu_read_unlock();
59999 } else {
60000 inode->i_uid = GLOBAL_ROOT_UID;
60001 @@ -2166,6 +2284,9 @@ static struct dentry *proc_pident_lookup(struct inode *dir,
60002 if (!task)
60003 goto out_no_task;
60004
60005 + if (gr_pid_is_chrooted(task) || gr_check_hidden_task(task))
60006 + goto out;
60007 +
60008 /*
60009 * Yes, it does not scale. And it should not. Don't add
60010 * new entries into /proc/<tgid>/ without very good reasons.
60011 @@ -2196,6 +2317,9 @@ static int proc_pident_readdir(struct file *file, struct dir_context *ctx,
60012 if (!task)
60013 return -ENOENT;
60014
60015 + if (gr_pid_is_chrooted(task) || gr_check_hidden_task(task))
60016 + goto out;
60017 +
60018 if (!dir_emit_dots(file, ctx))
60019 goto out;
60020
60021 @@ -2585,7 +2709,7 @@ static const struct pid_entry tgid_base_stuff[] = {
60022 REG("autogroup", S_IRUGO|S_IWUSR, proc_pid_sched_autogroup_operations),
60023 #endif
60024 REG("comm", S_IRUGO|S_IWUSR, proc_pid_set_comm_operations),
60025 -#ifdef CONFIG_HAVE_ARCH_TRACEHOOK
60026 +#if defined(CONFIG_HAVE_ARCH_TRACEHOOK) && !defined(CONFIG_GRKERNSEC_PROC_MEMMAP)
60027 INF("syscall", S_IRUGO, proc_pid_syscall),
60028 #endif
60029 INF("cmdline", S_IRUGO, proc_pid_cmdline),
60030 @@ -2610,10 +2734,10 @@ static const struct pid_entry tgid_base_stuff[] = {
60031 #ifdef CONFIG_SECURITY
60032 DIR("attr", S_IRUGO|S_IXUGO, proc_attr_dir_inode_operations, proc_attr_dir_operations),
60033 #endif
60034 -#ifdef CONFIG_KALLSYMS
60035 +#if defined(CONFIG_KALLSYMS) && !defined(CONFIG_GRKERNSEC_HIDESYM)
60036 INF("wchan", S_IRUGO, proc_pid_wchan),
60037 #endif
60038 -#ifdef CONFIG_STACKTRACE
60039 +#if defined(CONFIG_STACKTRACE) && !defined(CONFIG_GRKERNSEC_HIDESYM)
60040 ONE("stack", S_IRUGO, proc_pid_stack),
60041 #endif
60042 #ifdef CONFIG_SCHEDSTATS
60043 @@ -2647,6 +2771,9 @@ static const struct pid_entry tgid_base_stuff[] = {
60044 #ifdef CONFIG_HARDWALL
60045 INF("hardwall", S_IRUGO, proc_pid_hardwall),
60046 #endif
60047 +#ifdef CONFIG_GRKERNSEC_PROC_IPADDR
60048 + INF("ipaddr", S_IRUSR, proc_pid_ipaddr),
60049 +#endif
60050 #ifdef CONFIG_USER_NS
60051 REG("uid_map", S_IRUGO|S_IWUSR, proc_uid_map_operations),
60052 REG("gid_map", S_IRUGO|S_IWUSR, proc_gid_map_operations),
60053 @@ -2777,7 +2904,14 @@ static int proc_pid_instantiate(struct inode *dir,
60054 if (!inode)
60055 goto out;
60056
60057 +#ifdef CONFIG_GRKERNSEC_PROC_USER
60058 + inode->i_mode = S_IFDIR|S_IRUSR|S_IXUSR;
60059 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
60060 + inode->i_gid = grsec_proc_gid;
60061 + inode->i_mode = S_IFDIR|S_IRUSR|S_IRGRP|S_IXUSR|S_IXGRP;
60062 +#else
60063 inode->i_mode = S_IFDIR|S_IRUGO|S_IXUGO;
60064 +#endif
60065 inode->i_op = &proc_tgid_base_inode_operations;
60066 inode->i_fop = &proc_tgid_base_operations;
60067 inode->i_flags|=S_IMMUTABLE;
60068 @@ -2815,7 +2949,11 @@ struct dentry *proc_pid_lookup(struct inode *dir, struct dentry * dentry, unsign
60069 if (!task)
60070 goto out;
60071
60072 + if (gr_pid_is_chrooted(task) || gr_check_hidden_task(task))
60073 + goto out_put_task;
60074 +
60075 result = proc_pid_instantiate(dir, dentry, task, NULL);
60076 +out_put_task:
60077 put_task_struct(task);
60078 out:
60079 return ERR_PTR(result);
60080 @@ -2921,7 +3059,7 @@ static const struct pid_entry tid_base_stuff[] = {
60081 REG("sched", S_IRUGO|S_IWUSR, proc_pid_sched_operations),
60082 #endif
60083 REG("comm", S_IRUGO|S_IWUSR, proc_pid_set_comm_operations),
60084 -#ifdef CONFIG_HAVE_ARCH_TRACEHOOK
60085 +#if defined(CONFIG_HAVE_ARCH_TRACEHOOK) && !defined(CONFIG_GRKERNSEC_PROC_MEMMAP)
60086 INF("syscall", S_IRUGO, proc_pid_syscall),
60087 #endif
60088 INF("cmdline", S_IRUGO, proc_pid_cmdline),
60089 @@ -2948,10 +3086,10 @@ static const struct pid_entry tid_base_stuff[] = {
60090 #ifdef CONFIG_SECURITY
60091 DIR("attr", S_IRUGO|S_IXUGO, proc_attr_dir_inode_operations, proc_attr_dir_operations),
60092 #endif
60093 -#ifdef CONFIG_KALLSYMS
60094 +#if defined(CONFIG_KALLSYMS) && !defined(CONFIG_GRKERNSEC_HIDESYM)
60095 INF("wchan", S_IRUGO, proc_pid_wchan),
60096 #endif
60097 -#ifdef CONFIG_STACKTRACE
60098 +#if defined(CONFIG_STACKTRACE) && !defined(CONFIG_GRKERNSEC_HIDESYM)
60099 ONE("stack", S_IRUGO, proc_pid_stack),
60100 #endif
60101 #ifdef CONFIG_SCHEDSTATS
60102 diff --git a/fs/proc/cmdline.c b/fs/proc/cmdline.c
60103 index 82676e3..5f8518a 100644
60104 --- a/fs/proc/cmdline.c
60105 +++ b/fs/proc/cmdline.c
60106 @@ -23,7 +23,11 @@ static const struct file_operations cmdline_proc_fops = {
60107
60108 static int __init proc_cmdline_init(void)
60109 {
60110 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
60111 + proc_create_grsec("cmdline", 0, NULL, &cmdline_proc_fops);
60112 +#else
60113 proc_create("cmdline", 0, NULL, &cmdline_proc_fops);
60114 +#endif
60115 return 0;
60116 }
60117 module_init(proc_cmdline_init);
60118 diff --git a/fs/proc/devices.c b/fs/proc/devices.c
60119 index b143471..bb105e5 100644
60120 --- a/fs/proc/devices.c
60121 +++ b/fs/proc/devices.c
60122 @@ -64,7 +64,11 @@ static const struct file_operations proc_devinfo_operations = {
60123
60124 static int __init proc_devices_init(void)
60125 {
60126 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
60127 + proc_create_grsec("devices", 0, NULL, &proc_devinfo_operations);
60128 +#else
60129 proc_create("devices", 0, NULL, &proc_devinfo_operations);
60130 +#endif
60131 return 0;
60132 }
60133 module_init(proc_devices_init);
60134 diff --git a/fs/proc/fd.c b/fs/proc/fd.c
60135 index 985ea88..d118a0a 100644
60136 --- a/fs/proc/fd.c
60137 +++ b/fs/proc/fd.c
60138 @@ -25,7 +25,8 @@ static int seq_show(struct seq_file *m, void *v)
60139 if (!task)
60140 return -ENOENT;
60141
60142 - files = get_files_struct(task);
60143 + if (!gr_acl_handle_procpidmem(task))
60144 + files = get_files_struct(task);
60145 put_task_struct(task);
60146
60147 if (files) {
60148 @@ -283,11 +284,21 @@ static struct dentry *proc_lookupfd(struct inode *dir, struct dentry *dentry,
60149 */
60150 int proc_fd_permission(struct inode *inode, int mask)
60151 {
60152 + struct task_struct *task;
60153 int rv = generic_permission(inode, mask);
60154 - if (rv == 0)
60155 - return 0;
60156 +
60157 if (task_tgid(current) == proc_pid(inode))
60158 rv = 0;
60159 +
60160 + task = get_proc_task(inode);
60161 + if (task == NULL)
60162 + return rv;
60163 +
60164 + if (gr_acl_handle_procpidmem(task))
60165 + rv = -EACCES;
60166 +
60167 + put_task_struct(task);
60168 +
60169 return rv;
60170 }
60171
60172 diff --git a/fs/proc/inode.c b/fs/proc/inode.c
60173 index 8eaa1ba..cc6ff42 100644
60174 --- a/fs/proc/inode.c
60175 +++ b/fs/proc/inode.c
60176 @@ -23,11 +23,17 @@
60177 #include <linux/slab.h>
60178 #include <linux/mount.h>
60179 #include <linux/magic.h>
60180 +#include <linux/grsecurity.h>
60181
60182 #include <asm/uaccess.h>
60183
60184 #include "internal.h"
60185
60186 +#ifdef CONFIG_PROC_SYSCTL
60187 +extern const struct inode_operations proc_sys_inode_operations;
60188 +extern const struct inode_operations proc_sys_dir_operations;
60189 +#endif
60190 +
60191 static void proc_evict_inode(struct inode *inode)
60192 {
60193 struct proc_dir_entry *de;
60194 @@ -55,6 +61,13 @@ static void proc_evict_inode(struct inode *inode)
60195 ns = PROC_I(inode)->ns.ns;
60196 if (ns_ops && ns)
60197 ns_ops->put(ns);
60198 +
60199 +#ifdef CONFIG_PROC_SYSCTL
60200 + if (inode->i_op == &proc_sys_inode_operations ||
60201 + inode->i_op == &proc_sys_dir_operations)
60202 + gr_handle_delete(inode->i_ino, inode->i_sb->s_dev);
60203 +#endif
60204 +
60205 }
60206
60207 static struct kmem_cache * proc_inode_cachep;
60208 @@ -405,7 +418,11 @@ struct inode *proc_get_inode(struct super_block *sb, struct proc_dir_entry *de)
60209 if (de->mode) {
60210 inode->i_mode = de->mode;
60211 inode->i_uid = de->uid;
60212 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
60213 + inode->i_gid = grsec_proc_gid;
60214 +#else
60215 inode->i_gid = de->gid;
60216 +#endif
60217 }
60218 if (de->size)
60219 inode->i_size = de->size;
60220 diff --git a/fs/proc/internal.h b/fs/proc/internal.h
60221 index 651d09a..60c73ae 100644
60222 --- a/fs/proc/internal.h
60223 +++ b/fs/proc/internal.h
60224 @@ -155,6 +155,9 @@ extern int proc_pid_status(struct seq_file *, struct pid_namespace *,
60225 struct pid *, struct task_struct *);
60226 extern int proc_pid_statm(struct seq_file *, struct pid_namespace *,
60227 struct pid *, struct task_struct *);
60228 +#ifdef CONFIG_GRKERNSEC_PROC_IPADDR
60229 +extern int proc_pid_ipaddr(struct task_struct *task, char *buffer);
60230 +#endif
60231
60232 /*
60233 * base.c
60234 diff --git a/fs/proc/kcore.c b/fs/proc/kcore.c
60235 index 06ea155..9a798c7 100644
60236 --- a/fs/proc/kcore.c
60237 +++ b/fs/proc/kcore.c
60238 @@ -484,9 +484,10 @@ read_kcore(struct file *file, char __user *buffer, size_t buflen, loff_t *fpos)
60239 * the addresses in the elf_phdr on our list.
60240 */
60241 start = kc_offset_to_vaddr(*fpos - elf_buflen);
60242 - if ((tsz = (PAGE_SIZE - (start & ~PAGE_MASK))) > buflen)
60243 + tsz = PAGE_SIZE - (start & ~PAGE_MASK);
60244 + if (tsz > buflen)
60245 tsz = buflen;
60246 -
60247 +
60248 while (buflen) {
60249 struct kcore_list *m;
60250
60251 @@ -515,20 +516,23 @@ read_kcore(struct file *file, char __user *buffer, size_t buflen, loff_t *fpos)
60252 kfree(elf_buf);
60253 } else {
60254 if (kern_addr_valid(start)) {
60255 - unsigned long n;
60256 + char *elf_buf;
60257 + mm_segment_t oldfs;
60258
60259 - n = copy_to_user(buffer, (char *)start, tsz);
60260 - /*
60261 - * We cannot distinguish between fault on source
60262 - * and fault on destination. When this happens
60263 - * we clear too and hope it will trigger the
60264 - * EFAULT again.
60265 - */
60266 - if (n) {
60267 - if (clear_user(buffer + tsz - n,
60268 - n))
60269 + elf_buf = kmalloc(tsz, GFP_KERNEL);
60270 + if (!elf_buf)
60271 + return -ENOMEM;
60272 + oldfs = get_fs();
60273 + set_fs(KERNEL_DS);
60274 + if (!__copy_from_user(elf_buf, (const void __user *)start, tsz)) {
60275 + set_fs(oldfs);
60276 + if (copy_to_user(buffer, elf_buf, tsz)) {
60277 + kfree(elf_buf);
60278 return -EFAULT;
60279 + }
60280 }
60281 + set_fs(oldfs);
60282 + kfree(elf_buf);
60283 } else {
60284 if (clear_user(buffer, tsz))
60285 return -EFAULT;
60286 @@ -548,6 +552,9 @@ read_kcore(struct file *file, char __user *buffer, size_t buflen, loff_t *fpos)
60287
60288 static int open_kcore(struct inode *inode, struct file *filp)
60289 {
60290 +#if defined(CONFIG_GRKERNSEC_PROC_ADD) || defined(CONFIG_GRKERNSEC_HIDESYM)
60291 + return -EPERM;
60292 +#endif
60293 if (!capable(CAP_SYS_RAWIO))
60294 return -EPERM;
60295 if (kcore_need_update)
60296 diff --git a/fs/proc/meminfo.c b/fs/proc/meminfo.c
60297 index 59d85d6..ac6fc05 100644
60298 --- a/fs/proc/meminfo.c
60299 +++ b/fs/proc/meminfo.c
60300 @@ -153,7 +153,7 @@ static int meminfo_proc_show(struct seq_file *m, void *v)
60301 vmi.used >> 10,
60302 vmi.largest_chunk >> 10
60303 #ifdef CONFIG_MEMORY_FAILURE
60304 - ,atomic_long_read(&num_poisoned_pages) << (PAGE_SHIFT - 10)
60305 + ,atomic_long_read_unchecked(&num_poisoned_pages) << (PAGE_SHIFT - 10)
60306 #endif
60307 #ifdef CONFIG_TRANSPARENT_HUGEPAGE
60308 ,K(global_page_state(NR_ANON_TRANSPARENT_HUGEPAGES) *
60309 diff --git a/fs/proc/nommu.c b/fs/proc/nommu.c
60310 index ccfd99b..1b7e255 100644
60311 --- a/fs/proc/nommu.c
60312 +++ b/fs/proc/nommu.c
60313 @@ -66,7 +66,7 @@ static int nommu_region_show(struct seq_file *m, struct vm_region *region)
60314 if (len < 1)
60315 len = 1;
60316 seq_printf(m, "%*c", len, ' ');
60317 - seq_path(m, &file->f_path, "");
60318 + seq_path(m, &file->f_path, "\n\\");
60319 }
60320
60321 seq_putc(m, '\n');
60322 diff --git a/fs/proc/proc_net.c b/fs/proc/proc_net.c
60323 index 4677bb7..408e936 100644
60324 --- a/fs/proc/proc_net.c
60325 +++ b/fs/proc/proc_net.c
60326 @@ -23,6 +23,7 @@
60327 #include <linux/nsproxy.h>
60328 #include <net/net_namespace.h>
60329 #include <linux/seq_file.h>
60330 +#include <linux/grsecurity.h>
60331
60332 #include "internal.h"
60333
60334 @@ -109,6 +110,17 @@ static struct net *get_proc_task_net(struct inode *dir)
60335 struct task_struct *task;
60336 struct nsproxy *ns;
60337 struct net *net = NULL;
60338 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
60339 + const struct cred *cred = current_cred();
60340 +#endif
60341 +
60342 +#ifdef CONFIG_GRKERNSEC_PROC_USER
60343 + if (!uid_eq(cred->fsuid, GLOBAL_ROOT_UID))
60344 + return net;
60345 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
60346 + if (!uid_eq(cred->fsuid, GLOBAL_ROOT_UID) && !in_group_p(grsec_proc_gid))
60347 + return net;
60348 +#endif
60349
60350 rcu_read_lock();
60351 task = pid_task(proc_pid(dir), PIDTYPE_PID);
60352 diff --git a/fs/proc/proc_sysctl.c b/fs/proc/proc_sysctl.c
60353 index 7129046..6914844 100644
60354 --- a/fs/proc/proc_sysctl.c
60355 +++ b/fs/proc/proc_sysctl.c
60356 @@ -11,13 +11,21 @@
60357 #include <linux/namei.h>
60358 #include <linux/mm.h>
60359 #include <linux/module.h>
60360 +#include <linux/nsproxy.h>
60361 +#ifdef CONFIG_GRKERNSEC
60362 +#include <net/net_namespace.h>
60363 +#endif
60364 #include "internal.h"
60365
60366 +extern int gr_handle_chroot_sysctl(const int op);
60367 +extern int gr_handle_sysctl_mod(const char *dirname, const char *name,
60368 + const int op);
60369 +
60370 static const struct dentry_operations proc_sys_dentry_operations;
60371 static const struct file_operations proc_sys_file_operations;
60372 -static const struct inode_operations proc_sys_inode_operations;
60373 +const struct inode_operations proc_sys_inode_operations;
60374 static const struct file_operations proc_sys_dir_file_operations;
60375 -static const struct inode_operations proc_sys_dir_operations;
60376 +const struct inode_operations proc_sys_dir_operations;
60377
60378 void proc_sys_poll_notify(struct ctl_table_poll *poll)
60379 {
60380 @@ -467,6 +475,9 @@ static struct dentry *proc_sys_lookup(struct inode *dir, struct dentry *dentry,
60381
60382 err = NULL;
60383 d_set_d_op(dentry, &proc_sys_dentry_operations);
60384 +
60385 + gr_handle_proc_create(dentry, inode);
60386 +
60387 d_add(dentry, inode);
60388
60389 out:
60390 @@ -482,6 +493,7 @@ static ssize_t proc_sys_call_handler(struct file *filp, void __user *buf,
60391 struct inode *inode = file_inode(filp);
60392 struct ctl_table_header *head = grab_header(inode);
60393 struct ctl_table *table = PROC_I(inode)->sysctl_entry;
60394 + int op = write ? MAY_WRITE : MAY_READ;
60395 ssize_t error;
60396 size_t res;
60397
60398 @@ -493,7 +505,7 @@ static ssize_t proc_sys_call_handler(struct file *filp, void __user *buf,
60399 * and won't be until we finish.
60400 */
60401 error = -EPERM;
60402 - if (sysctl_perm(head, table, write ? MAY_WRITE : MAY_READ))
60403 + if (sysctl_perm(head, table, op))
60404 goto out;
60405
60406 /* if that can happen at all, it should be -EINVAL, not -EISDIR */
60407 @@ -501,6 +513,27 @@ static ssize_t proc_sys_call_handler(struct file *filp, void __user *buf,
60408 if (!table->proc_handler)
60409 goto out;
60410
60411 +#ifdef CONFIG_GRKERNSEC
60412 + error = -EPERM;
60413 + if (gr_handle_chroot_sysctl(op))
60414 + goto out;
60415 + dget(filp->f_path.dentry);
60416 + if (gr_handle_sysctl_mod(filp->f_path.dentry->d_parent->d_name.name, table->procname, op)) {
60417 + dput(filp->f_path.dentry);
60418 + goto out;
60419 + }
60420 + dput(filp->f_path.dentry);
60421 + if (!gr_acl_handle_open(filp->f_path.dentry, filp->f_path.mnt, op))
60422 + goto out;
60423 + if (write) {
60424 + if (current->nsproxy->net_ns != table->extra2) {
60425 + if (!capable(CAP_SYS_ADMIN))
60426 + goto out;
60427 + } else if (!ns_capable(current->nsproxy->net_ns->user_ns, CAP_NET_ADMIN))
60428 + goto out;
60429 + }
60430 +#endif
60431 +
60432 /* careful: calling conventions are nasty here */
60433 res = count;
60434 error = table->proc_handler(table, write, buf, &res, ppos);
60435 @@ -598,6 +631,9 @@ static bool proc_sys_fill_cache(struct file *file,
60436 return false;
60437 } else {
60438 d_set_d_op(child, &proc_sys_dentry_operations);
60439 +
60440 + gr_handle_proc_create(child, inode);
60441 +
60442 d_add(child, inode);
60443 }
60444 } else {
60445 @@ -641,6 +677,9 @@ static int scan(struct ctl_table_header *head, ctl_table *table,
60446 if ((*pos)++ < ctx->pos)
60447 return true;
60448
60449 + if (!gr_acl_handle_hidden_file(file->f_path.dentry, file->f_path.mnt))
60450 + return 0;
60451 +
60452 if (unlikely(S_ISLNK(table->mode)))
60453 res = proc_sys_link_fill_cache(file, ctx, head, table);
60454 else
60455 @@ -734,6 +773,9 @@ static int proc_sys_getattr(struct vfsmount *mnt, struct dentry *dentry, struct
60456 if (IS_ERR(head))
60457 return PTR_ERR(head);
60458
60459 + if (table && !gr_acl_handle_hidden_file(dentry, mnt))
60460 + return -ENOENT;
60461 +
60462 generic_fillattr(inode, stat);
60463 if (table)
60464 stat->mode = (stat->mode & S_IFMT) | table->mode;
60465 @@ -756,13 +798,13 @@ static const struct file_operations proc_sys_dir_file_operations = {
60466 .llseek = generic_file_llseek,
60467 };
60468
60469 -static const struct inode_operations proc_sys_inode_operations = {
60470 +const struct inode_operations proc_sys_inode_operations = {
60471 .permission = proc_sys_permission,
60472 .setattr = proc_sys_setattr,
60473 .getattr = proc_sys_getattr,
60474 };
60475
60476 -static const struct inode_operations proc_sys_dir_operations = {
60477 +const struct inode_operations proc_sys_dir_operations = {
60478 .lookup = proc_sys_lookup,
60479 .permission = proc_sys_permission,
60480 .setattr = proc_sys_setattr,
60481 @@ -839,7 +881,7 @@ static struct ctl_dir *find_subdir(struct ctl_dir *dir,
60482 static struct ctl_dir *new_dir(struct ctl_table_set *set,
60483 const char *name, int namelen)
60484 {
60485 - struct ctl_table *table;
60486 + ctl_table_no_const *table;
60487 struct ctl_dir *new;
60488 struct ctl_node *node;
60489 char *new_name;
60490 @@ -851,7 +893,7 @@ static struct ctl_dir *new_dir(struct ctl_table_set *set,
60491 return NULL;
60492
60493 node = (struct ctl_node *)(new + 1);
60494 - table = (struct ctl_table *)(node + 1);
60495 + table = (ctl_table_no_const *)(node + 1);
60496 new_name = (char *)(table + 2);
60497 memcpy(new_name, name, namelen);
60498 new_name[namelen] = '\0';
60499 @@ -1020,7 +1062,8 @@ static int sysctl_check_table(const char *path, struct ctl_table *table)
60500 static struct ctl_table_header *new_links(struct ctl_dir *dir, struct ctl_table *table,
60501 struct ctl_table_root *link_root)
60502 {
60503 - struct ctl_table *link_table, *entry, *link;
60504 + ctl_table_no_const *link_table, *link;
60505 + struct ctl_table *entry;
60506 struct ctl_table_header *links;
60507 struct ctl_node *node;
60508 char *link_name;
60509 @@ -1043,7 +1086,7 @@ static struct ctl_table_header *new_links(struct ctl_dir *dir, struct ctl_table
60510 return NULL;
60511
60512 node = (struct ctl_node *)(links + 1);
60513 - link_table = (struct ctl_table *)(node + nr_entries);
60514 + link_table = (ctl_table_no_const *)(node + nr_entries);
60515 link_name = (char *)&link_table[nr_entries + 1];
60516
60517 for (link = link_table, entry = table; entry->procname; link++, entry++) {
60518 @@ -1291,8 +1334,8 @@ static int register_leaf_sysctl_tables(const char *path, char *pos,
60519 struct ctl_table_header ***subheader, struct ctl_table_set *set,
60520 struct ctl_table *table)
60521 {
60522 - struct ctl_table *ctl_table_arg = NULL;
60523 - struct ctl_table *entry, *files;
60524 + ctl_table_no_const *ctl_table_arg = NULL, *files = NULL;
60525 + struct ctl_table *entry;
60526 int nr_files = 0;
60527 int nr_dirs = 0;
60528 int err = -ENOMEM;
60529 @@ -1304,10 +1347,9 @@ static int register_leaf_sysctl_tables(const char *path, char *pos,
60530 nr_files++;
60531 }
60532
60533 - files = table;
60534 /* If there are mixed files and directories we need a new table */
60535 if (nr_dirs && nr_files) {
60536 - struct ctl_table *new;
60537 + ctl_table_no_const *new;
60538 files = kzalloc(sizeof(struct ctl_table) * (nr_files + 1),
60539 GFP_KERNEL);
60540 if (!files)
60541 @@ -1325,7 +1367,7 @@ static int register_leaf_sysctl_tables(const char *path, char *pos,
60542 /* Register everything except a directory full of subdirectories */
60543 if (nr_files || !nr_dirs) {
60544 struct ctl_table_header *header;
60545 - header = __register_sysctl_table(set, path, files);
60546 + header = __register_sysctl_table(set, path, files ? files : table);
60547 if (!header) {
60548 kfree(ctl_table_arg);
60549 goto out;
60550 diff --git a/fs/proc/root.c b/fs/proc/root.c
60551 index 87dbcbe..55e1b4d 100644
60552 --- a/fs/proc/root.c
60553 +++ b/fs/proc/root.c
60554 @@ -186,7 +186,15 @@ void __init proc_root_init(void)
60555 #ifdef CONFIG_PROC_DEVICETREE
60556 proc_device_tree_init();
60557 #endif
60558 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
60559 +#ifdef CONFIG_GRKERNSEC_PROC_USER
60560 + proc_mkdir_mode("bus", S_IRUSR | S_IXUSR, NULL);
60561 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
60562 + proc_mkdir_mode("bus", S_IRUSR | S_IXUSR | S_IRGRP | S_IXGRP, NULL);
60563 +#endif
60564 +#else
60565 proc_mkdir("bus", NULL);
60566 +#endif
60567 proc_sys_init();
60568 }
60569
60570 diff --git a/fs/proc/self.c b/fs/proc/self.c
60571 index 6b6a993..807cccc 100644
60572 --- a/fs/proc/self.c
60573 +++ b/fs/proc/self.c
60574 @@ -39,7 +39,7 @@ static void *proc_self_follow_link(struct dentry *dentry, struct nameidata *nd)
60575 static void proc_self_put_link(struct dentry *dentry, struct nameidata *nd,
60576 void *cookie)
60577 {
60578 - char *s = nd_get_link(nd);
60579 + const char *s = nd_get_link(nd);
60580 if (!IS_ERR(s))
60581 kfree(s);
60582 }
60583 diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c
60584 index 390bdab..83c1e8a 100644
60585 --- a/fs/proc/task_mmu.c
60586 +++ b/fs/proc/task_mmu.c
60587 @@ -12,12 +12,19 @@
60588 #include <linux/swap.h>
60589 #include <linux/swapops.h>
60590 #include <linux/mmu_notifier.h>
60591 +#include <linux/grsecurity.h>
60592
60593 #include <asm/elf.h>
60594 #include <asm/uaccess.h>
60595 #include <asm/tlbflush.h>
60596 #include "internal.h"
60597
60598 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
60599 +#define PAX_RAND_FLAGS(_mm) (_mm != NULL && _mm != current->mm && \
60600 + (_mm->pax_flags & MF_PAX_RANDMMAP || \
60601 + _mm->pax_flags & MF_PAX_SEGMEXEC))
60602 +#endif
60603 +
60604 void task_mem(struct seq_file *m, struct mm_struct *mm)
60605 {
60606 unsigned long data, text, lib, swap;
60607 @@ -53,8 +60,13 @@ void task_mem(struct seq_file *m, struct mm_struct *mm)
60608 "VmExe:\t%8lu kB\n"
60609 "VmLib:\t%8lu kB\n"
60610 "VmPTE:\t%8lu kB\n"
60611 - "VmSwap:\t%8lu kB\n",
60612 - hiwater_vm << (PAGE_SHIFT-10),
60613 + "VmSwap:\t%8lu kB\n"
60614 +
60615 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
60616 + "CsBase:\t%8lx\nCsLim:\t%8lx\n"
60617 +#endif
60618 +
60619 + ,hiwater_vm << (PAGE_SHIFT-10),
60620 total_vm << (PAGE_SHIFT-10),
60621 mm->locked_vm << (PAGE_SHIFT-10),
60622 mm->pinned_vm << (PAGE_SHIFT-10),
60623 @@ -63,7 +75,19 @@ void task_mem(struct seq_file *m, struct mm_struct *mm)
60624 data << (PAGE_SHIFT-10),
60625 mm->stack_vm << (PAGE_SHIFT-10), text, lib,
60626 (PTRS_PER_PTE*sizeof(pte_t)*mm->nr_ptes) >> 10,
60627 - swap << (PAGE_SHIFT-10));
60628 + swap << (PAGE_SHIFT-10)
60629 +
60630 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
60631 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
60632 + , PAX_RAND_FLAGS(mm) ? 0 : mm->context.user_cs_base
60633 + , PAX_RAND_FLAGS(mm) ? 0 : mm->context.user_cs_limit
60634 +#else
60635 + , mm->context.user_cs_base
60636 + , mm->context.user_cs_limit
60637 +#endif
60638 +#endif
60639 +
60640 + );
60641 }
60642
60643 unsigned long task_vsize(struct mm_struct *mm)
60644 @@ -278,13 +302,13 @@ show_map_vma(struct seq_file *m, struct vm_area_struct *vma, int is_pid)
60645 pgoff = ((loff_t)vma->vm_pgoff) << PAGE_SHIFT;
60646 }
60647
60648 - /* We don't show the stack guard page in /proc/maps */
60649 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
60650 + start = PAX_RAND_FLAGS(mm) ? 0UL : vma->vm_start;
60651 + end = PAX_RAND_FLAGS(mm) ? 0UL : vma->vm_end;
60652 +#else
60653 start = vma->vm_start;
60654 - if (stack_guard_page_start(vma, start))
60655 - start += PAGE_SIZE;
60656 end = vma->vm_end;
60657 - if (stack_guard_page_end(vma, end))
60658 - end -= PAGE_SIZE;
60659 +#endif
60660
60661 seq_printf(m, "%08lx-%08lx %c%c%c%c %08llx %02x:%02x %lu %n",
60662 start,
60663 @@ -293,7 +317,11 @@ show_map_vma(struct seq_file *m, struct vm_area_struct *vma, int is_pid)
60664 flags & VM_WRITE ? 'w' : '-',
60665 flags & VM_EXEC ? 'x' : '-',
60666 flags & VM_MAYSHARE ? 's' : 'p',
60667 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
60668 + PAX_RAND_FLAGS(mm) ? 0UL : pgoff,
60669 +#else
60670 pgoff,
60671 +#endif
60672 MAJOR(dev), MINOR(dev), ino, &len);
60673
60674 /*
60675 @@ -302,7 +330,7 @@ show_map_vma(struct seq_file *m, struct vm_area_struct *vma, int is_pid)
60676 */
60677 if (file) {
60678 pad_len_spaces(m, len);
60679 - seq_path(m, &file->f_path, "\n");
60680 + seq_path(m, &file->f_path, "\n\\");
60681 goto done;
60682 }
60683
60684 @@ -328,8 +356,9 @@ show_map_vma(struct seq_file *m, struct vm_area_struct *vma, int is_pid)
60685 * Thread stack in /proc/PID/task/TID/maps or
60686 * the main process stack.
60687 */
60688 - if (!is_pid || (vma->vm_start <= mm->start_stack &&
60689 - vma->vm_end >= mm->start_stack)) {
60690 + if (!is_pid || (vma->vm_flags & (VM_GROWSDOWN | VM_GROWSUP)) ||
60691 + (vma->vm_start <= mm->start_stack &&
60692 + vma->vm_end >= mm->start_stack)) {
60693 name = "[stack]";
60694 } else {
60695 /* Thread stack in /proc/PID/maps */
60696 @@ -353,6 +382,13 @@ static int show_map(struct seq_file *m, void *v, int is_pid)
60697 struct proc_maps_private *priv = m->private;
60698 struct task_struct *task = priv->task;
60699
60700 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
60701 + if (current->exec_id != m->exec_id) {
60702 + gr_log_badprocpid("maps");
60703 + return 0;
60704 + }
60705 +#endif
60706 +
60707 show_map_vma(m, vma, is_pid);
60708
60709 if (m->count < m->size) /* vma is copied successfully */
60710 @@ -590,12 +626,23 @@ static int show_smap(struct seq_file *m, void *v, int is_pid)
60711 .private = &mss,
60712 };
60713
60714 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
60715 + if (current->exec_id != m->exec_id) {
60716 + gr_log_badprocpid("smaps");
60717 + return 0;
60718 + }
60719 +#endif
60720 memset(&mss, 0, sizeof mss);
60721 - mss.vma = vma;
60722 - /* mmap_sem is held in m_start */
60723 - if (vma->vm_mm && !is_vm_hugetlb_page(vma))
60724 - walk_page_range(vma->vm_start, vma->vm_end, &smaps_walk);
60725 -
60726 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
60727 + if (!PAX_RAND_FLAGS(vma->vm_mm)) {
60728 +#endif
60729 + mss.vma = vma;
60730 + /* mmap_sem is held in m_start */
60731 + if (vma->vm_mm && !is_vm_hugetlb_page(vma))
60732 + walk_page_range(vma->vm_start, vma->vm_end, &smaps_walk);
60733 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
60734 + }
60735 +#endif
60736 show_map_vma(m, vma, is_pid);
60737
60738 seq_printf(m,
60739 @@ -613,7 +660,11 @@ static int show_smap(struct seq_file *m, void *v, int is_pid)
60740 "KernelPageSize: %8lu kB\n"
60741 "MMUPageSize: %8lu kB\n"
60742 "Locked: %8lu kB\n",
60743 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
60744 + PAX_RAND_FLAGS(vma->vm_mm) ? 0UL : (vma->vm_end - vma->vm_start) >> 10,
60745 +#else
60746 (vma->vm_end - vma->vm_start) >> 10,
60747 +#endif
60748 mss.resident >> 10,
60749 (unsigned long)(mss.pss >> (10 + PSS_SHIFT)),
60750 mss.shared_clean >> 10,
60751 @@ -1390,6 +1441,13 @@ static int show_numa_map(struct seq_file *m, void *v, int is_pid)
60752 int n;
60753 char buffer[50];
60754
60755 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
60756 + if (current->exec_id != m->exec_id) {
60757 + gr_log_badprocpid("numa_maps");
60758 + return 0;
60759 + }
60760 +#endif
60761 +
60762 if (!mm)
60763 return 0;
60764
60765 @@ -1409,11 +1467,15 @@ static int show_numa_map(struct seq_file *m, void *v, int is_pid)
60766 if (n < 0)
60767 return n;
60768
60769 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
60770 + seq_printf(m, "%08lx %s", PAX_RAND_FLAGS(vma->vm_mm) ? 0UL : vma->vm_start, buffer);
60771 +#else
60772 seq_printf(m, "%08lx %s", vma->vm_start, buffer);
60773 +#endif
60774
60775 if (file) {
60776 seq_printf(m, " file=");
60777 - seq_path(m, &file->f_path, "\n\t= ");
60778 + seq_path(m, &file->f_path, "\n\t\\= ");
60779 } else if (vma->vm_start <= mm->brk && vma->vm_end >= mm->start_brk) {
60780 seq_printf(m, " heap");
60781 } else {
60782 diff --git a/fs/proc/task_nommu.c b/fs/proc/task_nommu.c
60783 index 56123a6..5a2f6ec 100644
60784 --- a/fs/proc/task_nommu.c
60785 +++ b/fs/proc/task_nommu.c
60786 @@ -51,7 +51,7 @@ void task_mem(struct seq_file *m, struct mm_struct *mm)
60787 else
60788 bytes += kobjsize(mm);
60789
60790 - if (current->fs && current->fs->users > 1)
60791 + if (current->fs && atomic_read(&current->fs->users) > 1)
60792 sbytes += kobjsize(current->fs);
60793 else
60794 bytes += kobjsize(current->fs);
60795 @@ -168,7 +168,7 @@ static int nommu_vma_show(struct seq_file *m, struct vm_area_struct *vma,
60796
60797 if (file) {
60798 pad_len_spaces(m, len);
60799 - seq_path(m, &file->f_path, "");
60800 + seq_path(m, &file->f_path, "\n\\");
60801 } else if (mm) {
60802 pid_t tid = vm_is_stack(priv->task, vma, is_pid);
60803
60804 diff --git a/fs/proc/vmcore.c b/fs/proc/vmcore.c
60805 index 9100d69..f1f9fc9 100644
60806 --- a/fs/proc/vmcore.c
60807 +++ b/fs/proc/vmcore.c
60808 @@ -105,9 +105,13 @@ static ssize_t read_from_oldmem(char *buf, size_t count,
60809 nr_bytes = count;
60810
60811 /* If pfn is not ram, return zeros for sparse dump files */
60812 - if (pfn_is_ram(pfn) == 0)
60813 - memset(buf, 0, nr_bytes);
60814 - else {
60815 + if (pfn_is_ram(pfn) == 0) {
60816 + if (userbuf) {
60817 + if (clear_user((char __force_user *)buf, nr_bytes))
60818 + return -EFAULT;
60819 + } else
60820 + memset(buf, 0, nr_bytes);
60821 + } else {
60822 tmp = copy_oldmem_page(pfn, buf, nr_bytes,
60823 offset, userbuf);
60824 if (tmp < 0)
60825 @@ -233,7 +237,7 @@ static ssize_t __read_vmcore(char *buffer, size_t buflen, loff_t *fpos,
60826 if (*fpos < m->offset + m->size) {
60827 tsz = min_t(size_t, m->offset + m->size - *fpos, buflen);
60828 start = m->paddr + *fpos - m->offset;
60829 - tmp = read_from_oldmem(buffer, tsz, &start, userbuf);
60830 + tmp = read_from_oldmem((char __force_kernel *)buffer, tsz, &start, userbuf);
60831 if (tmp < 0)
60832 return tmp;
60833 buflen -= tsz;
60834 diff --git a/fs/qnx6/qnx6.h b/fs/qnx6/qnx6.h
60835 index b00fcc9..e0c6381 100644
60836 --- a/fs/qnx6/qnx6.h
60837 +++ b/fs/qnx6/qnx6.h
60838 @@ -74,7 +74,7 @@ enum {
60839 BYTESEX_BE,
60840 };
60841
60842 -static inline __u64 fs64_to_cpu(struct qnx6_sb_info *sbi, __fs64 n)
60843 +static inline __u64 __intentional_overflow(-1) fs64_to_cpu(struct qnx6_sb_info *sbi, __fs64 n)
60844 {
60845 if (sbi->s_bytesex == BYTESEX_LE)
60846 return le64_to_cpu((__force __le64)n);
60847 @@ -90,7 +90,7 @@ static inline __fs64 cpu_to_fs64(struct qnx6_sb_info *sbi, __u64 n)
60848 return (__force __fs64)cpu_to_be64(n);
60849 }
60850
60851 -static inline __u32 fs32_to_cpu(struct qnx6_sb_info *sbi, __fs32 n)
60852 +static inline __u32 __intentional_overflow(-1) fs32_to_cpu(struct qnx6_sb_info *sbi, __fs32 n)
60853 {
60854 if (sbi->s_bytesex == BYTESEX_LE)
60855 return le32_to_cpu((__force __le32)n);
60856 diff --git a/fs/quota/netlink.c b/fs/quota/netlink.c
60857 index 16e8abb..2dcf914 100644
60858 --- a/fs/quota/netlink.c
60859 +++ b/fs/quota/netlink.c
60860 @@ -33,7 +33,7 @@ static struct genl_family quota_genl_family = {
60861 void quota_send_warning(struct kqid qid, dev_t dev,
60862 const char warntype)
60863 {
60864 - static atomic_t seq;
60865 + static atomic_unchecked_t seq;
60866 struct sk_buff *skb;
60867 void *msg_head;
60868 int ret;
60869 @@ -49,7 +49,7 @@ void quota_send_warning(struct kqid qid, dev_t dev,
60870 "VFS: Not enough memory to send quota warning.\n");
60871 return;
60872 }
60873 - msg_head = genlmsg_put(skb, 0, atomic_add_return(1, &seq),
60874 + msg_head = genlmsg_put(skb, 0, atomic_add_return_unchecked(1, &seq),
60875 &quota_genl_family, 0, QUOTA_NL_C_WARNING);
60876 if (!msg_head) {
60877 printk(KERN_ERR
60878 diff --git a/fs/read_write.c b/fs/read_write.c
60879 index e3cd280..a378473 100644
60880 --- a/fs/read_write.c
60881 +++ b/fs/read_write.c
60882 @@ -438,7 +438,7 @@ ssize_t __kernel_write(struct file *file, const char *buf, size_t count, loff_t
60883
60884 old_fs = get_fs();
60885 set_fs(get_ds());
60886 - p = (__force const char __user *)buf;
60887 + p = (const char __force_user *)buf;
60888 if (count > MAX_RW_COUNT)
60889 count = MAX_RW_COUNT;
60890 if (file->f_op->write)
60891 diff --git a/fs/readdir.c b/fs/readdir.c
60892 index 93d71e5..6a14be8 100644
60893 --- a/fs/readdir.c
60894 +++ b/fs/readdir.c
60895 @@ -17,6 +17,7 @@
60896 #include <linux/security.h>
60897 #include <linux/syscalls.h>
60898 #include <linux/unistd.h>
60899 +#include <linux/namei.h>
60900
60901 #include <asm/uaccess.h>
60902
60903 @@ -69,6 +70,7 @@ struct old_linux_dirent {
60904 struct readdir_callback {
60905 struct dir_context ctx;
60906 struct old_linux_dirent __user * dirent;
60907 + struct file * file;
60908 int result;
60909 };
60910
60911 @@ -86,6 +88,10 @@ static int fillonedir(void * __buf, const char * name, int namlen, loff_t offset
60912 buf->result = -EOVERFLOW;
60913 return -EOVERFLOW;
60914 }
60915 +
60916 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
60917 + return 0;
60918 +
60919 buf->result++;
60920 dirent = buf->dirent;
60921 if (!access_ok(VERIFY_WRITE, dirent,
60922 @@ -117,6 +123,7 @@ SYSCALL_DEFINE3(old_readdir, unsigned int, fd,
60923 if (!f.file)
60924 return -EBADF;
60925
60926 + buf.file = f.file;
60927 error = iterate_dir(f.file, &buf.ctx);
60928 if (buf.result)
60929 error = buf.result;
60930 @@ -142,6 +149,7 @@ struct getdents_callback {
60931 struct dir_context ctx;
60932 struct linux_dirent __user * current_dir;
60933 struct linux_dirent __user * previous;
60934 + struct file * file;
60935 int count;
60936 int error;
60937 };
60938 @@ -163,6 +171,10 @@ static int filldir(void * __buf, const char * name, int namlen, loff_t offset,
60939 buf->error = -EOVERFLOW;
60940 return -EOVERFLOW;
60941 }
60942 +
60943 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
60944 + return 0;
60945 +
60946 dirent = buf->previous;
60947 if (dirent) {
60948 if (__put_user(offset, &dirent->d_off))
60949 @@ -208,6 +220,7 @@ SYSCALL_DEFINE3(getdents, unsigned int, fd,
60950 if (!f.file)
60951 return -EBADF;
60952
60953 + buf.file = f.file;
60954 error = iterate_dir(f.file, &buf.ctx);
60955 if (error >= 0)
60956 error = buf.error;
60957 @@ -226,6 +239,7 @@ struct getdents_callback64 {
60958 struct dir_context ctx;
60959 struct linux_dirent64 __user * current_dir;
60960 struct linux_dirent64 __user * previous;
60961 + struct file *file;
60962 int count;
60963 int error;
60964 };
60965 @@ -241,6 +255,10 @@ static int filldir64(void * __buf, const char * name, int namlen, loff_t offset,
60966 buf->error = -EINVAL; /* only used if we fail.. */
60967 if (reclen > buf->count)
60968 return -EINVAL;
60969 +
60970 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
60971 + return 0;
60972 +
60973 dirent = buf->previous;
60974 if (dirent) {
60975 if (__put_user(offset, &dirent->d_off))
60976 @@ -288,6 +306,7 @@ SYSCALL_DEFINE3(getdents64, unsigned int, fd,
60977 if (!f.file)
60978 return -EBADF;
60979
60980 + buf.file = f.file;
60981 error = iterate_dir(f.file, &buf.ctx);
60982 if (error >= 0)
60983 error = buf.error;
60984 diff --git a/fs/reiserfs/do_balan.c b/fs/reiserfs/do_balan.c
60985 index 2b7882b..1c5ef48 100644
60986 --- a/fs/reiserfs/do_balan.c
60987 +++ b/fs/reiserfs/do_balan.c
60988 @@ -2051,7 +2051,7 @@ void do_balance(struct tree_balance *tb, /* tree_balance structure */
60989 return;
60990 }
60991
60992 - atomic_inc(&(fs_generation(tb->tb_sb)));
60993 + atomic_inc_unchecked(&(fs_generation(tb->tb_sb)));
60994 do_balance_starts(tb);
60995
60996 /* balance leaf returns 0 except if combining L R and S into
60997 diff --git a/fs/reiserfs/procfs.c b/fs/reiserfs/procfs.c
60998 index a958444..42b2323 100644
60999 --- a/fs/reiserfs/procfs.c
61000 +++ b/fs/reiserfs/procfs.c
61001 @@ -114,7 +114,7 @@ static int show_super(struct seq_file *m, void *unused)
61002 "SMALL_TAILS " : "NO_TAILS ",
61003 replay_only(sb) ? "REPLAY_ONLY " : "",
61004 convert_reiserfs(sb) ? "CONV " : "",
61005 - atomic_read(&r->s_generation_counter),
61006 + atomic_read_unchecked(&r->s_generation_counter),
61007 SF(s_disk_reads), SF(s_disk_writes), SF(s_fix_nodes),
61008 SF(s_do_balance), SF(s_unneeded_left_neighbor),
61009 SF(s_good_search_by_key_reada), SF(s_bmaps),
61010 diff --git a/fs/reiserfs/reiserfs.h b/fs/reiserfs/reiserfs.h
61011 index f8adaee..0eeeeca 100644
61012 --- a/fs/reiserfs/reiserfs.h
61013 +++ b/fs/reiserfs/reiserfs.h
61014 @@ -453,7 +453,7 @@ struct reiserfs_sb_info {
61015 /* Comment? -Hans */
61016 wait_queue_head_t s_wait;
61017 /* To be obsoleted soon by per buffer seals.. -Hans */
61018 - atomic_t s_generation_counter; // increased by one every time the
61019 + atomic_unchecked_t s_generation_counter; // increased by one every time the
61020 // tree gets re-balanced
61021 unsigned long s_properties; /* File system properties. Currently holds
61022 on-disk FS format */
61023 @@ -1982,7 +1982,7 @@ static inline loff_t max_reiserfs_offset(struct inode *inode)
61024 #define REISERFS_USER_MEM 1 /* reiserfs user memory mode */
61025
61026 #define fs_generation(s) (REISERFS_SB(s)->s_generation_counter)
61027 -#define get_generation(s) atomic_read (&fs_generation(s))
61028 +#define get_generation(s) atomic_read_unchecked (&fs_generation(s))
61029 #define FILESYSTEM_CHANGED_TB(tb) (get_generation((tb)->tb_sb) != (tb)->fs_gen)
61030 #define __fs_changed(gen,s) (gen != get_generation (s))
61031 #define fs_changed(gen,s) \
61032 diff --git a/fs/select.c b/fs/select.c
61033 index dfd5cb1..1754d57 100644
61034 --- a/fs/select.c
61035 +++ b/fs/select.c
61036 @@ -20,6 +20,7 @@
61037 #include <linux/export.h>
61038 #include <linux/slab.h>
61039 #include <linux/poll.h>
61040 +#include <linux/security.h>
61041 #include <linux/personality.h> /* for STICKY_TIMEOUTS */
61042 #include <linux/file.h>
61043 #include <linux/fdtable.h>
61044 @@ -880,6 +881,7 @@ int do_sys_poll(struct pollfd __user *ufds, unsigned int nfds,
61045 struct poll_list *walk = head;
61046 unsigned long todo = nfds;
61047
61048 + gr_learn_resource(current, RLIMIT_NOFILE, nfds, 1);
61049 if (nfds > rlimit(RLIMIT_NOFILE))
61050 return -EINVAL;
61051
61052 diff --git a/fs/seq_file.c b/fs/seq_file.c
61053 index a290157..ec3211a 100644
61054 --- a/fs/seq_file.c
61055 +++ b/fs/seq_file.c
61056 @@ -10,6 +10,7 @@
61057 #include <linux/seq_file.h>
61058 #include <linux/slab.h>
61059 #include <linux/cred.h>
61060 +#include <linux/sched.h>
61061
61062 #include <asm/uaccess.h>
61063 #include <asm/page.h>
61064 @@ -60,6 +61,9 @@ int seq_open(struct file *file, const struct seq_operations *op)
61065 #ifdef CONFIG_USER_NS
61066 p->user_ns = file->f_cred->user_ns;
61067 #endif
61068 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
61069 + p->exec_id = current->exec_id;
61070 +#endif
61071
61072 /*
61073 * Wrappers around seq_open(e.g. swaps_open) need to be
61074 @@ -96,7 +100,7 @@ static int traverse(struct seq_file *m, loff_t offset)
61075 return 0;
61076 }
61077 if (!m->buf) {
61078 - m->buf = kmalloc(m->size = PAGE_SIZE, GFP_KERNEL);
61079 + m->buf = kmalloc(m->size = PAGE_SIZE, GFP_KERNEL | GFP_USERCOPY);
61080 if (!m->buf)
61081 return -ENOMEM;
61082 }
61083 @@ -136,7 +140,7 @@ static int traverse(struct seq_file *m, loff_t offset)
61084 Eoverflow:
61085 m->op->stop(m, p);
61086 kfree(m->buf);
61087 - m->buf = kmalloc(m->size <<= 1, GFP_KERNEL);
61088 + m->buf = kmalloc(m->size <<= 1, GFP_KERNEL | GFP_USERCOPY);
61089 return !m->buf ? -ENOMEM : -EAGAIN;
61090 }
61091
61092 @@ -152,7 +156,7 @@ Eoverflow:
61093 ssize_t seq_read(struct file *file, char __user *buf, size_t size, loff_t *ppos)
61094 {
61095 struct seq_file *m = file->private_data;
61096 - size_t copied = 0;
61097 + ssize_t copied = 0;
61098 loff_t pos;
61099 size_t n;
61100 void *p;
61101 @@ -191,7 +195,7 @@ ssize_t seq_read(struct file *file, char __user *buf, size_t size, loff_t *ppos)
61102
61103 /* grab buffer if we didn't have one */
61104 if (!m->buf) {
61105 - m->buf = kmalloc(m->size = PAGE_SIZE, GFP_KERNEL);
61106 + m->buf = kmalloc(m->size = PAGE_SIZE, GFP_KERNEL | GFP_USERCOPY);
61107 if (!m->buf)
61108 goto Enomem;
61109 }
61110 @@ -232,7 +236,7 @@ ssize_t seq_read(struct file *file, char __user *buf, size_t size, loff_t *ppos)
61111 goto Fill;
61112 m->op->stop(m, p);
61113 kfree(m->buf);
61114 - m->buf = kmalloc(m->size <<= 1, GFP_KERNEL);
61115 + m->buf = kmalloc(m->size <<= 1, GFP_KERNEL | GFP_USERCOPY);
61116 if (!m->buf)
61117 goto Enomem;
61118 m->count = 0;
61119 @@ -583,7 +587,7 @@ static void single_stop(struct seq_file *p, void *v)
61120 int single_open(struct file *file, int (*show)(struct seq_file *, void *),
61121 void *data)
61122 {
61123 - struct seq_operations *op = kmalloc(sizeof(*op), GFP_KERNEL);
61124 + seq_operations_no_const *op = kzalloc(sizeof(*op), GFP_KERNEL);
61125 int res = -ENOMEM;
61126
61127 if (op) {
61128 diff --git a/fs/splice.c b/fs/splice.c
61129 index 3b7ee65..87fc2e4 100644
61130 --- a/fs/splice.c
61131 +++ b/fs/splice.c
61132 @@ -196,7 +196,7 @@ ssize_t splice_to_pipe(struct pipe_inode_info *pipe,
61133 pipe_lock(pipe);
61134
61135 for (;;) {
61136 - if (!pipe->readers) {
61137 + if (!atomic_read(&pipe->readers)) {
61138 send_sig(SIGPIPE, current, 0);
61139 if (!ret)
61140 ret = -EPIPE;
61141 @@ -219,7 +219,7 @@ ssize_t splice_to_pipe(struct pipe_inode_info *pipe,
61142 page_nr++;
61143 ret += buf->len;
61144
61145 - if (pipe->files)
61146 + if (atomic_read(&pipe->files))
61147 do_wakeup = 1;
61148
61149 if (!--spd->nr_pages)
61150 @@ -250,9 +250,9 @@ ssize_t splice_to_pipe(struct pipe_inode_info *pipe,
61151 do_wakeup = 0;
61152 }
61153
61154 - pipe->waiting_writers++;
61155 + atomic_inc(&pipe->waiting_writers);
61156 pipe_wait(pipe);
61157 - pipe->waiting_writers--;
61158 + atomic_dec(&pipe->waiting_writers);
61159 }
61160
61161 pipe_unlock(pipe);
61162 @@ -565,7 +565,7 @@ static ssize_t kernel_readv(struct file *file, const struct iovec *vec,
61163 old_fs = get_fs();
61164 set_fs(get_ds());
61165 /* The cast to a user pointer is valid due to the set_fs() */
61166 - res = vfs_readv(file, (const struct iovec __user *)vec, vlen, &pos);
61167 + res = vfs_readv(file, (const struct iovec __force_user *)vec, vlen, &pos);
61168 set_fs(old_fs);
61169
61170 return res;
61171 @@ -580,7 +580,7 @@ ssize_t kernel_write(struct file *file, const char *buf, size_t count,
61172 old_fs = get_fs();
61173 set_fs(get_ds());
61174 /* The cast to a user pointer is valid due to the set_fs() */
61175 - res = vfs_write(file, (__force const char __user *)buf, count, &pos);
61176 + res = vfs_write(file, (const char __force_user *)buf, count, &pos);
61177 set_fs(old_fs);
61178
61179 return res;
61180 @@ -633,7 +633,7 @@ ssize_t default_file_splice_read(struct file *in, loff_t *ppos,
61181 goto err;
61182
61183 this_len = min_t(size_t, len, PAGE_CACHE_SIZE - offset);
61184 - vec[i].iov_base = (void __user *) page_address(page);
61185 + vec[i].iov_base = (void __force_user *) page_address(page);
61186 vec[i].iov_len = this_len;
61187 spd.pages[i] = page;
61188 spd.nr_pages++;
61189 @@ -829,7 +829,7 @@ int splice_from_pipe_feed(struct pipe_inode_info *pipe, struct splice_desc *sd,
61190 ops->release(pipe, buf);
61191 pipe->curbuf = (pipe->curbuf + 1) & (pipe->buffers - 1);
61192 pipe->nrbufs--;
61193 - if (pipe->files)
61194 + if (atomic_read(&pipe->files))
61195 sd->need_wakeup = true;
61196 }
61197
61198 @@ -854,10 +854,10 @@ EXPORT_SYMBOL(splice_from_pipe_feed);
61199 int splice_from_pipe_next(struct pipe_inode_info *pipe, struct splice_desc *sd)
61200 {
61201 while (!pipe->nrbufs) {
61202 - if (!pipe->writers)
61203 + if (!atomic_read(&pipe->writers))
61204 return 0;
61205
61206 - if (!pipe->waiting_writers && sd->num_spliced)
61207 + if (!atomic_read(&pipe->waiting_writers) && sd->num_spliced)
61208 return 0;
61209
61210 if (sd->flags & SPLICE_F_NONBLOCK)
61211 @@ -1179,7 +1179,7 @@ ssize_t splice_direct_to_actor(struct file *in, struct splice_desc *sd,
61212 * out of the pipe right after the splice_to_pipe(). So set
61213 * PIPE_READERS appropriately.
61214 */
61215 - pipe->readers = 1;
61216 + atomic_set(&pipe->readers, 1);
61217
61218 current->splice_pipe = pipe;
61219 }
61220 @@ -1475,6 +1475,7 @@ static int get_iovec_page_array(const struct iovec __user *iov,
61221
61222 partial[buffers].offset = off;
61223 partial[buffers].len = plen;
61224 + partial[buffers].private = 0;
61225
61226 off = 0;
61227 len -= plen;
61228 @@ -1777,9 +1778,9 @@ static int ipipe_prep(struct pipe_inode_info *pipe, unsigned int flags)
61229 ret = -ERESTARTSYS;
61230 break;
61231 }
61232 - if (!pipe->writers)
61233 + if (!atomic_read(&pipe->writers))
61234 break;
61235 - if (!pipe->waiting_writers) {
61236 + if (!atomic_read(&pipe->waiting_writers)) {
61237 if (flags & SPLICE_F_NONBLOCK) {
61238 ret = -EAGAIN;
61239 break;
61240 @@ -1811,7 +1812,7 @@ static int opipe_prep(struct pipe_inode_info *pipe, unsigned int flags)
61241 pipe_lock(pipe);
61242
61243 while (pipe->nrbufs >= pipe->buffers) {
61244 - if (!pipe->readers) {
61245 + if (!atomic_read(&pipe->readers)) {
61246 send_sig(SIGPIPE, current, 0);
61247 ret = -EPIPE;
61248 break;
61249 @@ -1824,9 +1825,9 @@ static int opipe_prep(struct pipe_inode_info *pipe, unsigned int flags)
61250 ret = -ERESTARTSYS;
61251 break;
61252 }
61253 - pipe->waiting_writers++;
61254 + atomic_inc(&pipe->waiting_writers);
61255 pipe_wait(pipe);
61256 - pipe->waiting_writers--;
61257 + atomic_dec(&pipe->waiting_writers);
61258 }
61259
61260 pipe_unlock(pipe);
61261 @@ -1862,14 +1863,14 @@ retry:
61262 pipe_double_lock(ipipe, opipe);
61263
61264 do {
61265 - if (!opipe->readers) {
61266 + if (!atomic_read(&opipe->readers)) {
61267 send_sig(SIGPIPE, current, 0);
61268 if (!ret)
61269 ret = -EPIPE;
61270 break;
61271 }
61272
61273 - if (!ipipe->nrbufs && !ipipe->writers)
61274 + if (!ipipe->nrbufs && !atomic_read(&ipipe->writers))
61275 break;
61276
61277 /*
61278 @@ -1966,7 +1967,7 @@ static int link_pipe(struct pipe_inode_info *ipipe,
61279 pipe_double_lock(ipipe, opipe);
61280
61281 do {
61282 - if (!opipe->readers) {
61283 + if (!atomic_read(&opipe->readers)) {
61284 send_sig(SIGPIPE, current, 0);
61285 if (!ret)
61286 ret = -EPIPE;
61287 @@ -2011,7 +2012,7 @@ static int link_pipe(struct pipe_inode_info *ipipe,
61288 * return EAGAIN if we have the potential of some data in the
61289 * future, otherwise just return 0
61290 */
61291 - if (!ret && ipipe->waiting_writers && (flags & SPLICE_F_NONBLOCK))
61292 + if (!ret && atomic_read(&ipipe->waiting_writers) && (flags & SPLICE_F_NONBLOCK))
61293 ret = -EAGAIN;
61294
61295 pipe_unlock(ipipe);
61296 diff --git a/fs/stat.c b/fs/stat.c
61297 index d0ea7ef..f463f9d 100644
61298 --- a/fs/stat.c
61299 +++ b/fs/stat.c
61300 @@ -28,8 +28,13 @@ void generic_fillattr(struct inode *inode, struct kstat *stat)
61301 stat->gid = inode->i_gid;
61302 stat->rdev = inode->i_rdev;
61303 stat->size = i_size_read(inode);
61304 - stat->atime = inode->i_atime;
61305 - stat->mtime = inode->i_mtime;
61306 + if (is_sidechannel_device(inode) && !capable_nolog(CAP_MKNOD)) {
61307 + stat->atime = inode->i_ctime;
61308 + stat->mtime = inode->i_ctime;
61309 + } else {
61310 + stat->atime = inode->i_atime;
61311 + stat->mtime = inode->i_mtime;
61312 + }
61313 stat->ctime = inode->i_ctime;
61314 stat->blksize = (1 << inode->i_blkbits);
61315 stat->blocks = inode->i_blocks;
61316 @@ -46,8 +51,14 @@ int vfs_getattr(struct path *path, struct kstat *stat)
61317 if (retval)
61318 return retval;
61319
61320 - if (inode->i_op->getattr)
61321 - return inode->i_op->getattr(path->mnt, path->dentry, stat);
61322 + if (inode->i_op->getattr) {
61323 + retval = inode->i_op->getattr(path->mnt, path->dentry, stat);
61324 + if (!retval && is_sidechannel_device(inode) && !capable_nolog(CAP_MKNOD)) {
61325 + stat->atime = stat->ctime;
61326 + stat->mtime = stat->ctime;
61327 + }
61328 + return retval;
61329 + }
61330
61331 generic_fillattr(inode, stat);
61332 return 0;
61333 diff --git a/fs/sysfs/bin.c b/fs/sysfs/bin.c
61334 index c590cab..6dfd6fc 100644
61335 --- a/fs/sysfs/bin.c
61336 +++ b/fs/sysfs/bin.c
61337 @@ -234,13 +234,13 @@ static int bin_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf)
61338 return ret;
61339 }
61340
61341 -static int bin_access(struct vm_area_struct *vma, unsigned long addr,
61342 - void *buf, int len, int write)
61343 +static ssize_t bin_access(struct vm_area_struct *vma, unsigned long addr,
61344 + void *buf, size_t len, int write)
61345 {
61346 struct file *file = vma->vm_file;
61347 struct bin_buffer *bb = file->private_data;
61348 struct sysfs_dirent *attr_sd = file->f_path.dentry->d_fsdata;
61349 - int ret;
61350 + ssize_t ret;
61351
61352 if (!bb->vm_ops)
61353 return -EINVAL;
61354 diff --git a/fs/sysfs/dir.c b/fs/sysfs/dir.c
61355 index 4d83ced..049dc45 100644
61356 --- a/fs/sysfs/dir.c
61357 +++ b/fs/sysfs/dir.c
61358 @@ -40,7 +40,7 @@ static DEFINE_IDA(sysfs_ino_ida);
61359 *
61360 * Returns 31 bit hash of ns + name (so it fits in an off_t )
61361 */
61362 -static unsigned int sysfs_name_hash(const void *ns, const char *name)
61363 +static unsigned int sysfs_name_hash(const void *ns, const unsigned char *name)
61364 {
61365 unsigned long hash = init_name_hash();
61366 unsigned int len = strlen(name);
61367 @@ -675,6 +675,18 @@ static int create_dir(struct kobject *kobj, struct sysfs_dirent *parent_sd,
61368 struct sysfs_dirent *sd;
61369 int rc;
61370
61371 +#ifdef CONFIG_GRKERNSEC_SYSFS_RESTRICT
61372 + const char *parent_name = parent_sd->s_name;
61373 +
61374 + mode = S_IFDIR | S_IRWXU;
61375 +
61376 + if ((!strcmp(parent_name, "") && (!strcmp(name, "devices") || !strcmp(name, "fs"))) ||
61377 + (!strcmp(parent_name, "devices") && !strcmp(name, "system")) ||
61378 + (!strcmp(parent_name, "fs") && (!strcmp(name, "selinux") || !strcmp(name, "fuse") || !strcmp(name, "ecryptfs"))) ||
61379 + (!strcmp(parent_name, "system") && !strcmp(name, "cpu")))
61380 + mode = S_IFDIR | S_IRWXU | S_IRUGO | S_IXUGO;
61381 +#endif
61382 +
61383 /* allocate */
61384 sd = sysfs_new_dirent(name, mode, SYSFS_DIR);
61385 if (!sd)
61386 diff --git a/fs/sysfs/file.c b/fs/sysfs/file.c
61387 index 15ef5eb..e474372 100644
61388 --- a/fs/sysfs/file.c
61389 +++ b/fs/sysfs/file.c
61390 @@ -37,7 +37,7 @@ static DEFINE_SPINLOCK(sysfs_open_dirent_lock);
61391
61392 struct sysfs_open_dirent {
61393 atomic_t refcnt;
61394 - atomic_t event;
61395 + atomic_unchecked_t event;
61396 wait_queue_head_t poll;
61397 struct list_head buffers; /* goes through sysfs_buffer.list */
61398 };
61399 @@ -81,7 +81,7 @@ static int fill_read_buffer(struct dentry *dentry, struct sysfs_buffer *buffer)
61400 if (!sysfs_get_active(attr_sd))
61401 return -ENODEV;
61402
61403 - buffer->event = atomic_read(&attr_sd->s_attr.open->event);
61404 + buffer->event = atomic_read_unchecked(&attr_sd->s_attr.open->event);
61405 count = ops->show(kobj, attr_sd->s_attr.attr, buffer->page);
61406
61407 sysfs_put_active(attr_sd);
61408 @@ -284,7 +284,7 @@ static int sysfs_get_open_dirent(struct sysfs_dirent *sd,
61409 return -ENOMEM;
61410
61411 atomic_set(&new_od->refcnt, 0);
61412 - atomic_set(&new_od->event, 1);
61413 + atomic_set_unchecked(&new_od->event, 1);
61414 init_waitqueue_head(&new_od->poll);
61415 INIT_LIST_HEAD(&new_od->buffers);
61416 goto retry;
61417 @@ -430,7 +430,7 @@ static unsigned int sysfs_poll(struct file *filp, poll_table *wait)
61418
61419 sysfs_put_active(attr_sd);
61420
61421 - if (buffer->event != atomic_read(&od->event))
61422 + if (buffer->event != atomic_read_unchecked(&od->event))
61423 goto trigger;
61424
61425 return DEFAULT_POLLMASK;
61426 @@ -450,7 +450,7 @@ void sysfs_notify_dirent(struct sysfs_dirent *sd)
61427 if (!WARN_ON(sysfs_type(sd) != SYSFS_KOBJ_ATTR)) {
61428 od = sd->s_attr.open;
61429 if (od) {
61430 - atomic_inc(&od->event);
61431 + atomic_inc_unchecked(&od->event);
61432 wake_up_interruptible(&od->poll);
61433 }
61434 }
61435 diff --git a/fs/sysfs/symlink.c b/fs/sysfs/symlink.c
61436 index 2dd4507..62a215a 100644
61437 --- a/fs/sysfs/symlink.c
61438 +++ b/fs/sysfs/symlink.c
61439 @@ -308,7 +308,7 @@ static void *sysfs_follow_link(struct dentry *dentry, struct nameidata *nd)
61440 static void sysfs_put_link(struct dentry *dentry, struct nameidata *nd,
61441 void *cookie)
61442 {
61443 - char *page = nd_get_link(nd);
61444 + const char *page = nd_get_link(nd);
61445 if (!IS_ERR(page))
61446 free_page((unsigned long)page);
61447 }
61448 diff --git a/fs/sysv/sysv.h b/fs/sysv/sysv.h
61449 index 69d4889..a810bd4 100644
61450 --- a/fs/sysv/sysv.h
61451 +++ b/fs/sysv/sysv.h
61452 @@ -188,7 +188,7 @@ static inline u32 PDP_swab(u32 x)
61453 #endif
61454 }
61455
61456 -static inline __u32 fs32_to_cpu(struct sysv_sb_info *sbi, __fs32 n)
61457 +static inline __u32 __intentional_overflow(-1) fs32_to_cpu(struct sysv_sb_info *sbi, __fs32 n)
61458 {
61459 if (sbi->s_bytesex == BYTESEX_PDP)
61460 return PDP_swab((__force __u32)n);
61461 diff --git a/fs/ubifs/io.c b/fs/ubifs/io.c
61462 index e18b988..f1d4ad0f 100644
61463 --- a/fs/ubifs/io.c
61464 +++ b/fs/ubifs/io.c
61465 @@ -155,7 +155,7 @@ int ubifs_leb_change(struct ubifs_info *c, int lnum, const void *buf, int len)
61466 return err;
61467 }
61468
61469 -int ubifs_leb_unmap(struct ubifs_info *c, int lnum)
61470 +int __intentional_overflow(-1) ubifs_leb_unmap(struct ubifs_info *c, int lnum)
61471 {
61472 int err;
61473
61474 diff --git a/fs/udf/misc.c b/fs/udf/misc.c
61475 index c175b4d..8f36a16 100644
61476 --- a/fs/udf/misc.c
61477 +++ b/fs/udf/misc.c
61478 @@ -289,7 +289,7 @@ void udf_new_tag(char *data, uint16_t ident, uint16_t version, uint16_t snum,
61479
61480 u8 udf_tag_checksum(const struct tag *t)
61481 {
61482 - u8 *data = (u8 *)t;
61483 + const u8 *data = (const u8 *)t;
61484 u8 checksum = 0;
61485 int i;
61486 for (i = 0; i < sizeof(struct tag); ++i)
61487 diff --git a/fs/ufs/swab.h b/fs/ufs/swab.h
61488 index 8d974c4..b82f6ec 100644
61489 --- a/fs/ufs/swab.h
61490 +++ b/fs/ufs/swab.h
61491 @@ -22,7 +22,7 @@ enum {
61492 BYTESEX_BE
61493 };
61494
61495 -static inline u64
61496 +static inline u64 __intentional_overflow(-1)
61497 fs64_to_cpu(struct super_block *sbp, __fs64 n)
61498 {
61499 if (UFS_SB(sbp)->s_bytesex == BYTESEX_LE)
61500 @@ -40,7 +40,7 @@ cpu_to_fs64(struct super_block *sbp, u64 n)
61501 return (__force __fs64)cpu_to_be64(n);
61502 }
61503
61504 -static inline u32
61505 +static inline u32 __intentional_overflow(-1)
61506 fs32_to_cpu(struct super_block *sbp, __fs32 n)
61507 {
61508 if (UFS_SB(sbp)->s_bytesex == BYTESEX_LE)
61509 diff --git a/fs/utimes.c b/fs/utimes.c
61510 index f4fb7ec..3fe03c0 100644
61511 --- a/fs/utimes.c
61512 +++ b/fs/utimes.c
61513 @@ -1,6 +1,7 @@
61514 #include <linux/compiler.h>
61515 #include <linux/file.h>
61516 #include <linux/fs.h>
61517 +#include <linux/security.h>
61518 #include <linux/linkage.h>
61519 #include <linux/mount.h>
61520 #include <linux/namei.h>
61521 @@ -101,6 +102,12 @@ static int utimes_common(struct path *path, struct timespec *times)
61522 goto mnt_drop_write_and_out;
61523 }
61524 }
61525 +
61526 + if (!gr_acl_handle_utime(path->dentry, path->mnt)) {
61527 + error = -EACCES;
61528 + goto mnt_drop_write_and_out;
61529 + }
61530 +
61531 mutex_lock(&inode->i_mutex);
61532 error = notify_change(path->dentry, &newattrs);
61533 mutex_unlock(&inode->i_mutex);
61534 diff --git a/fs/xattr.c b/fs/xattr.c
61535 index 3377dff..4d074d9 100644
61536 --- a/fs/xattr.c
61537 +++ b/fs/xattr.c
61538 @@ -227,6 +227,27 @@ int vfs_xattr_cmp(struct dentry *dentry, const char *xattr_name,
61539 return rc;
61540 }
61541
61542 +#ifdef CONFIG_PAX_XATTR_PAX_FLAGS
61543 +ssize_t
61544 +pax_getxattr(struct dentry *dentry, void *value, size_t size)
61545 +{
61546 + struct inode *inode = dentry->d_inode;
61547 + ssize_t error;
61548 +
61549 + error = inode_permission(inode, MAY_EXEC);
61550 + if (error)
61551 + return error;
61552 +
61553 + if (inode->i_op->getxattr)
61554 + error = inode->i_op->getxattr(dentry, XATTR_NAME_PAX_FLAGS, value, size);
61555 + else
61556 + error = -EOPNOTSUPP;
61557 +
61558 + return error;
61559 +}
61560 +EXPORT_SYMBOL(pax_getxattr);
61561 +#endif
61562 +
61563 ssize_t
61564 vfs_getxattr(struct dentry *dentry, const char *name, void *value, size_t size)
61565 {
61566 @@ -319,7 +340,7 @@ EXPORT_SYMBOL_GPL(vfs_removexattr);
61567 * Extended attribute SET operations
61568 */
61569 static long
61570 -setxattr(struct dentry *d, const char __user *name, const void __user *value,
61571 +setxattr(struct path *path, const char __user *name, const void __user *value,
61572 size_t size, int flags)
61573 {
61574 int error;
61575 @@ -355,7 +376,12 @@ setxattr(struct dentry *d, const char __user *name, const void __user *value,
61576 posix_acl_fix_xattr_from_user(kvalue, size);
61577 }
61578
61579 - error = vfs_setxattr(d, kname, kvalue, size, flags);
61580 + if (!gr_acl_handle_setxattr(path->dentry, path->mnt)) {
61581 + error = -EACCES;
61582 + goto out;
61583 + }
61584 +
61585 + error = vfs_setxattr(path->dentry, kname, kvalue, size, flags);
61586 out:
61587 if (vvalue)
61588 vfree(vvalue);
61589 @@ -377,7 +403,7 @@ retry:
61590 return error;
61591 error = mnt_want_write(path.mnt);
61592 if (!error) {
61593 - error = setxattr(path.dentry, name, value, size, flags);
61594 + error = setxattr(&path, name, value, size, flags);
61595 mnt_drop_write(path.mnt);
61596 }
61597 path_put(&path);
61598 @@ -401,7 +427,7 @@ retry:
61599 return error;
61600 error = mnt_want_write(path.mnt);
61601 if (!error) {
61602 - error = setxattr(path.dentry, name, value, size, flags);
61603 + error = setxattr(&path, name, value, size, flags);
61604 mnt_drop_write(path.mnt);
61605 }
61606 path_put(&path);
61607 @@ -416,16 +442,14 @@ SYSCALL_DEFINE5(fsetxattr, int, fd, const char __user *, name,
61608 const void __user *,value, size_t, size, int, flags)
61609 {
61610 struct fd f = fdget(fd);
61611 - struct dentry *dentry;
61612 int error = -EBADF;
61613
61614 if (!f.file)
61615 return error;
61616 - dentry = f.file->f_path.dentry;
61617 - audit_inode(NULL, dentry, 0);
61618 + audit_inode(NULL, f.file->f_path.dentry, 0);
61619 error = mnt_want_write_file(f.file);
61620 if (!error) {
61621 - error = setxattr(dentry, name, value, size, flags);
61622 + error = setxattr(&f.file->f_path, name, value, size, flags);
61623 mnt_drop_write_file(f.file);
61624 }
61625 fdput(f);
61626 diff --git a/fs/xattr_acl.c b/fs/xattr_acl.c
61627 index 9fbea87..6b19972 100644
61628 --- a/fs/xattr_acl.c
61629 +++ b/fs/xattr_acl.c
61630 @@ -76,8 +76,8 @@ struct posix_acl *
61631 posix_acl_from_xattr(struct user_namespace *user_ns,
61632 const void *value, size_t size)
61633 {
61634 - posix_acl_xattr_header *header = (posix_acl_xattr_header *)value;
61635 - posix_acl_xattr_entry *entry = (posix_acl_xattr_entry *)(header+1), *end;
61636 + const posix_acl_xattr_header *header = (const posix_acl_xattr_header *)value;
61637 + const posix_acl_xattr_entry *entry = (const posix_acl_xattr_entry *)(header+1), *end;
61638 int count;
61639 struct posix_acl *acl;
61640 struct posix_acl_entry *acl_e;
61641 diff --git a/fs/xfs/xfs_bmap.c b/fs/xfs/xfs_bmap.c
61642 index f47e65c..e7125d9 100644
61643 --- a/fs/xfs/xfs_bmap.c
61644 +++ b/fs/xfs/xfs_bmap.c
61645 @@ -586,7 +586,7 @@ xfs_bmap_validate_ret(
61646
61647 #else
61648 #define xfs_bmap_check_leaf_extents(cur, ip, whichfork) do { } while (0)
61649 -#define xfs_bmap_validate_ret(bno,len,flags,mval,onmap,nmap)
61650 +#define xfs_bmap_validate_ret(bno,len,flags,mval,onmap,nmap) do { } while (0)
61651 #endif /* DEBUG */
61652
61653 /*
61654 diff --git a/fs/xfs/xfs_dir2_readdir.c b/fs/xfs/xfs_dir2_readdir.c
61655 index 8f84153..7ce60d0 100644
61656 --- a/fs/xfs/xfs_dir2_readdir.c
61657 +++ b/fs/xfs/xfs_dir2_readdir.c
61658 @@ -160,7 +160,12 @@ xfs_dir2_sf_getdents(
61659 ino = xfs_dir3_sfe_get_ino(mp, sfp, sfep);
61660 filetype = xfs_dir3_sfe_get_ftype(mp, sfp, sfep);
61661 ctx->pos = off & 0x7fffffff;
61662 - if (!dir_emit(ctx, (char *)sfep->name, sfep->namelen, ino,
61663 + if (dp->i_df.if_u1.if_data == dp->i_df.if_u2.if_inline_data) {
61664 + char name[sfep->namelen];
61665 + memcpy(name, sfep->name, sfep->namelen);
61666 + if (!dir_emit(ctx, name, sfep->namelen, ino, xfs_dir3_get_dtype(mp, filetype)))
61667 + return 0;
61668 + } else if (!dir_emit(ctx, (char *)sfep->name, sfep->namelen, ino,
61669 xfs_dir3_get_dtype(mp, filetype)))
61670 return 0;
61671 sfep = xfs_dir3_sf_nextentry(mp, sfp, sfep);
61672 diff --git a/fs/xfs/xfs_ioctl.c b/fs/xfs/xfs_ioctl.c
61673 index 2e1e6c3..689f742 100644
61674 --- a/fs/xfs/xfs_ioctl.c
61675 +++ b/fs/xfs/xfs_ioctl.c
61676 @@ -127,7 +127,7 @@ xfs_find_handle(
61677 }
61678
61679 error = -EFAULT;
61680 - if (copy_to_user(hreq->ohandle, &handle, hsize) ||
61681 + if (hsize > sizeof handle || copy_to_user(hreq->ohandle, &handle, hsize) ||
61682 copy_to_user(hreq->ohandlen, &hsize, sizeof(__s32)))
61683 goto out_put;
61684
61685 @@ -443,7 +443,8 @@ xfs_attrlist_by_handle(
61686 return -XFS_ERROR(EPERM);
61687 if (copy_from_user(&al_hreq, arg, sizeof(xfs_fsop_attrlist_handlereq_t)))
61688 return -XFS_ERROR(EFAULT);
61689 - if (al_hreq.buflen > XATTR_LIST_MAX)
61690 + if (al_hreq.buflen < sizeof(struct attrlist) ||
61691 + al_hreq.buflen > XATTR_LIST_MAX)
61692 return -XFS_ERROR(EINVAL);
61693
61694 /*
61695 diff --git a/fs/xfs/xfs_ioctl32.c b/fs/xfs/xfs_ioctl32.c
61696 index f671f7e..53365c6 100644
61697 --- a/fs/xfs/xfs_ioctl32.c
61698 +++ b/fs/xfs/xfs_ioctl32.c
61699 @@ -357,7 +357,8 @@ xfs_compat_attrlist_by_handle(
61700 if (copy_from_user(&al_hreq, arg,
61701 sizeof(compat_xfs_fsop_attrlist_handlereq_t)))
61702 return -XFS_ERROR(EFAULT);
61703 - if (al_hreq.buflen > XATTR_LIST_MAX)
61704 + if (al_hreq.buflen < sizeof(struct attrlist) ||
61705 + al_hreq.buflen > XATTR_LIST_MAX)
61706 return -XFS_ERROR(EINVAL);
61707
61708 /*
61709 diff --git a/fs/xfs/xfs_iops.c b/fs/xfs/xfs_iops.c
61710 index 2b8952d..a60c6be 100644
61711 --- a/fs/xfs/xfs_iops.c
61712 +++ b/fs/xfs/xfs_iops.c
61713 @@ -401,7 +401,7 @@ xfs_vn_put_link(
61714 struct nameidata *nd,
61715 void *p)
61716 {
61717 - char *s = nd_get_link(nd);
61718 + const char *s = nd_get_link(nd);
61719
61720 if (!IS_ERR(s))
61721 kfree(s);
61722 diff --git a/grsecurity/Kconfig b/grsecurity/Kconfig
61723 new file mode 100644
61724 index 0000000..a78d810
61725 --- /dev/null
61726 +++ b/grsecurity/Kconfig
61727 @@ -0,0 +1,1107 @@
61728 +#
61729 +# grecurity configuration
61730 +#
61731 +menu "Memory Protections"
61732 +depends on GRKERNSEC
61733 +
61734 +config GRKERNSEC_KMEM
61735 + bool "Deny reading/writing to /dev/kmem, /dev/mem, and /dev/port"
61736 + default y if GRKERNSEC_CONFIG_AUTO
61737 + select STRICT_DEVMEM if (X86 || ARM || TILE || S390)
61738 + help
61739 + If you say Y here, /dev/kmem and /dev/mem won't be allowed to
61740 + be written to or read from to modify or leak the contents of the running
61741 + kernel. /dev/port will also not be allowed to be opened, and support
61742 + for /dev/cpu/*/msr and kexec will be removed. If you have module
61743 + support disabled, enabling this will close up six ways that are
61744 + currently used to insert malicious code into the running kernel.
61745 +
61746 + Even with this feature enabled, we still highly recommend that
61747 + you use the RBAC system, as it is still possible for an attacker to
61748 + modify the running kernel through other more obscure methods.
61749 +
61750 + Enabling this feature will prevent the "cpupower" and "powertop" tools
61751 + from working.
61752 +
61753 + It is highly recommended that you say Y here if you meet all the
61754 + conditions above.
61755 +
61756 +config GRKERNSEC_VM86
61757 + bool "Restrict VM86 mode"
61758 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_SERVER)
61759 + depends on X86_32
61760 +
61761 + help
61762 + If you say Y here, only processes with CAP_SYS_RAWIO will be able to
61763 + make use of a special execution mode on 32bit x86 processors called
61764 + Virtual 8086 (VM86) mode. XFree86 may need vm86 mode for certain
61765 + video cards and will still work with this option enabled. The purpose
61766 + of the option is to prevent exploitation of emulation errors in
61767 + virtualization of vm86 mode like the one discovered in VMWare in 2009.
61768 + Nearly all users should be able to enable this option.
61769 +
61770 +config GRKERNSEC_IO
61771 + bool "Disable privileged I/O"
61772 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_SERVER)
61773 + depends on X86
61774 + select RTC_CLASS
61775 + select RTC_INTF_DEV
61776 + select RTC_DRV_CMOS
61777 +
61778 + help
61779 + If you say Y here, all ioperm and iopl calls will return an error.
61780 + Ioperm and iopl can be used to modify the running kernel.
61781 + Unfortunately, some programs need this access to operate properly,
61782 + the most notable of which are XFree86 and hwclock. hwclock can be
61783 + remedied by having RTC support in the kernel, so real-time
61784 + clock support is enabled if this option is enabled, to ensure
61785 + that hwclock operates correctly.
61786 +
61787 + If you're using XFree86 or a version of Xorg from 2012 or earlier,
61788 + you may not be able to boot into a graphical environment with this
61789 + option enabled. In this case, you should use the RBAC system instead.
61790 +
61791 +config GRKERNSEC_JIT_HARDEN
61792 + bool "Harden BPF JIT against spray attacks"
61793 + default y if GRKERNSEC_CONFIG_AUTO
61794 + depends on BPF_JIT
61795 + help
61796 + If you say Y here, the native code generated by the kernel's Berkeley
61797 + Packet Filter (BPF) JIT engine will be hardened against JIT-spraying
61798 + attacks that attempt to fit attacker-beneficial instructions in
61799 + 32bit immediate fields of JIT-generated native instructions. The
61800 + attacker will generally aim to cause an unintended instruction sequence
61801 + of JIT-generated native code to execute by jumping into the middle of
61802 + a generated instruction. This feature effectively randomizes the 32bit
61803 + immediate constants present in the generated code to thwart such attacks.
61804 +
61805 + If you're using KERNEXEC, it's recommended that you enable this option
61806 + to supplement the hardening of the kernel.
61807 +
61808 +config GRKERNSEC_PERF_HARDEN
61809 + bool "Disable unprivileged PERF_EVENTS usage by default"
61810 + default y if GRKERNSEC_CONFIG_AUTO
61811 + depends on PERF_EVENTS
61812 + help
61813 + If you say Y here, the range of acceptable values for the
61814 + /proc/sys/kernel/perf_event_paranoid sysctl will be expanded to allow and
61815 + default to a new value: 3. When the sysctl is set to this value, no
61816 + unprivileged use of the PERF_EVENTS syscall interface will be permitted.
61817 +
61818 + Though PERF_EVENTS can be used legitimately for performance monitoring
61819 + and low-level application profiling, it is forced on regardless of
61820 + configuration, has been at fault for several vulnerabilities, and
61821 + creates new opportunities for side channels and other information leaks.
61822 +
61823 + This feature puts PERF_EVENTS into a secure default state and permits
61824 + the administrator to change out of it temporarily if unprivileged
61825 + application profiling is needed.
61826 +
61827 +config GRKERNSEC_RAND_THREADSTACK
61828 + bool "Insert random gaps between thread stacks"
61829 + default y if GRKERNSEC_CONFIG_AUTO
61830 + depends on PAX_RANDMMAP && !PPC
61831 + help
61832 + If you say Y here, a random-sized gap will be enforced between allocated
61833 + thread stacks. Glibc's NPTL and other threading libraries that
61834 + pass MAP_STACK to the kernel for thread stack allocation are supported.
61835 + The implementation currently provides 8 bits of entropy for the gap.
61836 +
61837 + Many distributions do not compile threaded remote services with the
61838 + -fstack-check argument to GCC, causing the variable-sized stack-based
61839 + allocator, alloca(), to not probe the stack on allocation. This
61840 + permits an unbounded alloca() to skip over any guard page and potentially
61841 + modify another thread's stack reliably. An enforced random gap
61842 + reduces the reliability of such an attack and increases the chance
61843 + that such a read/write to another thread's stack instead lands in
61844 + an unmapped area, causing a crash and triggering grsecurity's
61845 + anti-bruteforcing logic.
61846 +
61847 +config GRKERNSEC_PROC_MEMMAP
61848 + bool "Harden ASLR against information leaks and entropy reduction"
61849 + default y if (GRKERNSEC_CONFIG_AUTO || PAX_NOEXEC || PAX_ASLR)
61850 + depends on PAX_NOEXEC || PAX_ASLR
61851 + help
61852 + If you say Y here, the /proc/<pid>/maps and /proc/<pid>/stat files will
61853 + give no information about the addresses of its mappings if
61854 + PaX features that rely on random addresses are enabled on the task.
61855 + In addition to sanitizing this information and disabling other
61856 + dangerous sources of information, this option causes reads of sensitive
61857 + /proc/<pid> entries where the file descriptor was opened in a different
61858 + task than the one performing the read. Such attempts are logged.
61859 + This option also limits argv/env strings for suid/sgid binaries
61860 + to 512KB to prevent a complete exhaustion of the stack entropy provided
61861 + by ASLR. Finally, it places an 8MB stack resource limit on suid/sgid
61862 + binaries to prevent alternative mmap layouts from being abused.
61863 +
61864 + If you use PaX it is essential that you say Y here as it closes up
61865 + several holes that make full ASLR useless locally.
61866 +
61867 +config GRKERNSEC_BRUTE
61868 + bool "Deter exploit bruteforcing"
61869 + default y if GRKERNSEC_CONFIG_AUTO
61870 + help
61871 + If you say Y here, attempts to bruteforce exploits against forking
61872 + daemons such as apache or sshd, as well as against suid/sgid binaries
61873 + will be deterred. When a child of a forking daemon is killed by PaX
61874 + or crashes due to an illegal instruction or other suspicious signal,
61875 + the parent process will be delayed 30 seconds upon every subsequent
61876 + fork until the administrator is able to assess the situation and
61877 + restart the daemon.
61878 + In the suid/sgid case, the attempt is logged, the user has all their
61879 + existing instances of the suid/sgid binary terminated and will
61880 + be unable to execute any suid/sgid binaries for 15 minutes.
61881 +
61882 + It is recommended that you also enable signal logging in the auditing
61883 + section so that logs are generated when a process triggers a suspicious
61884 + signal.
61885 + If the sysctl option is enabled, a sysctl option with name
61886 + "deter_bruteforce" is created.
61887 +
61888 +
61889 +config GRKERNSEC_MODHARDEN
61890 + bool "Harden module auto-loading"
61891 + default y if GRKERNSEC_CONFIG_AUTO
61892 + depends on MODULES
61893 + help
61894 + If you say Y here, module auto-loading in response to use of some
61895 + feature implemented by an unloaded module will be restricted to
61896 + root users. Enabling this option helps defend against attacks
61897 + by unprivileged users who abuse the auto-loading behavior to
61898 + cause a vulnerable module to load that is then exploited.
61899 +
61900 + If this option prevents a legitimate use of auto-loading for a
61901 + non-root user, the administrator can execute modprobe manually
61902 + with the exact name of the module mentioned in the alert log.
61903 + Alternatively, the administrator can add the module to the list
61904 + of modules loaded at boot by modifying init scripts.
61905 +
61906 + Modification of init scripts will most likely be needed on
61907 + Ubuntu servers with encrypted home directory support enabled,
61908 + as the first non-root user logging in will cause the ecb(aes),
61909 + ecb(aes)-all, cbc(aes), and cbc(aes)-all modules to be loaded.
61910 +
61911 +config GRKERNSEC_HIDESYM
61912 + bool "Hide kernel symbols"
61913 + default y if GRKERNSEC_CONFIG_AUTO
61914 + select PAX_USERCOPY_SLABS
61915 + help
61916 + If you say Y here, getting information on loaded modules, and
61917 + displaying all kernel symbols through a syscall will be restricted
61918 + to users with CAP_SYS_MODULE. For software compatibility reasons,
61919 + /proc/kallsyms will be restricted to the root user. The RBAC
61920 + system can hide that entry even from root.
61921 +
61922 + This option also prevents leaking of kernel addresses through
61923 + several /proc entries.
61924 +
61925 + Note that this option is only effective provided the following
61926 + conditions are met:
61927 + 1) The kernel using grsecurity is not precompiled by some distribution
61928 + 2) You have also enabled GRKERNSEC_DMESG
61929 + 3) You are using the RBAC system and hiding other files such as your
61930 + kernel image and System.map. Alternatively, enabling this option
61931 + causes the permissions on /boot, /lib/modules, and the kernel
61932 + source directory to change at compile time to prevent
61933 + reading by non-root users.
61934 + If the above conditions are met, this option will aid in providing a
61935 + useful protection against local kernel exploitation of overflows
61936 + and arbitrary read/write vulnerabilities.
61937 +
61938 + It is highly recommended that you enable GRKERNSEC_PERF_HARDEN
61939 + in addition to this feature.
61940 +
61941 +config GRKERNSEC_KERN_LOCKOUT
61942 + bool "Active kernel exploit response"
61943 + default y if GRKERNSEC_CONFIG_AUTO
61944 + depends on X86 || ARM || PPC || SPARC
61945 + help
61946 + If you say Y here, when a PaX alert is triggered due to suspicious
61947 + activity in the kernel (from KERNEXEC/UDEREF/USERCOPY)
61948 + or an OOPS occurs due to bad memory accesses, instead of just
61949 + terminating the offending process (and potentially allowing
61950 + a subsequent exploit from the same user), we will take one of two
61951 + actions:
61952 + If the user was root, we will panic the system
61953 + If the user was non-root, we will log the attempt, terminate
61954 + all processes owned by the user, then prevent them from creating
61955 + any new processes until the system is restarted
61956 + This deters repeated kernel exploitation/bruteforcing attempts
61957 + and is useful for later forensics.
61958 +
61959 +config GRKERNSEC_OLD_ARM_USERLAND
61960 + bool "Old ARM userland compatibility"
61961 + depends on ARM && (CPU_V6 || CPU_V6K || CPU_V7)
61962 + help
61963 + If you say Y here, stubs of executable code to perform such operations
61964 + as "compare-exchange" will be placed at fixed locations in the ARM vector
61965 + table. This is unfortunately needed for old ARM userland meant to run
61966 + across a wide range of processors. Without this option enabled,
61967 + the get_tls and data memory barrier stubs will be emulated by the kernel,
61968 + which is enough for Linaro userlands or other userlands designed for v6
61969 + and newer ARM CPUs. It's recommended that you try without this option enabled
61970 + first, and only enable it if your userland does not boot (it will likely fail
61971 + at init time).
61972 +
61973 +endmenu
61974 +menu "Role Based Access Control Options"
61975 +depends on GRKERNSEC
61976 +
61977 +config GRKERNSEC_RBAC_DEBUG
61978 + bool
61979 +
61980 +config GRKERNSEC_NO_RBAC
61981 + bool "Disable RBAC system"
61982 + help
61983 + If you say Y here, the /dev/grsec device will be removed from the kernel,
61984 + preventing the RBAC system from being enabled. You should only say Y
61985 + here if you have no intention of using the RBAC system, so as to prevent
61986 + an attacker with root access from misusing the RBAC system to hide files
61987 + and processes when loadable module support and /dev/[k]mem have been
61988 + locked down.
61989 +
61990 +config GRKERNSEC_ACL_HIDEKERN
61991 + bool "Hide kernel processes"
61992 + help
61993 + If you say Y here, all kernel threads will be hidden to all
61994 + processes but those whose subject has the "view hidden processes"
61995 + flag.
61996 +
61997 +config GRKERNSEC_ACL_MAXTRIES
61998 + int "Maximum tries before password lockout"
61999 + default 3
62000 + help
62001 + This option enforces the maximum number of times a user can attempt
62002 + to authorize themselves with the grsecurity RBAC system before being
62003 + denied the ability to attempt authorization again for a specified time.
62004 + The lower the number, the harder it will be to brute-force a password.
62005 +
62006 +config GRKERNSEC_ACL_TIMEOUT
62007 + int "Time to wait after max password tries, in seconds"
62008 + default 30
62009 + help
62010 + This option specifies the time the user must wait after attempting to
62011 + authorize to the RBAC system with the maximum number of invalid
62012 + passwords. The higher the number, the harder it will be to brute-force
62013 + a password.
62014 +
62015 +endmenu
62016 +menu "Filesystem Protections"
62017 +depends on GRKERNSEC
62018 +
62019 +config GRKERNSEC_PROC
62020 + bool "Proc restrictions"
62021 + default y if GRKERNSEC_CONFIG_AUTO
62022 + help
62023 + If you say Y here, the permissions of the /proc filesystem
62024 + will be altered to enhance system security and privacy. You MUST
62025 + choose either a user only restriction or a user and group restriction.
62026 + Depending upon the option you choose, you can either restrict users to
62027 + see only the processes they themselves run, or choose a group that can
62028 + view all processes and files normally restricted to root if you choose
62029 + the "restrict to user only" option. NOTE: If you're running identd or
62030 + ntpd as a non-root user, you will have to run it as the group you
62031 + specify here.
62032 +
62033 +config GRKERNSEC_PROC_USER
62034 + bool "Restrict /proc to user only"
62035 + depends on GRKERNSEC_PROC
62036 + help
62037 + If you say Y here, non-root users will only be able to view their own
62038 + processes, and restricts them from viewing network-related information,
62039 + and viewing kernel symbol and module information.
62040 +
62041 +config GRKERNSEC_PROC_USERGROUP
62042 + bool "Allow special group"
62043 + default y if GRKERNSEC_CONFIG_AUTO
62044 + depends on GRKERNSEC_PROC && !GRKERNSEC_PROC_USER
62045 + help
62046 + If you say Y here, you will be able to select a group that will be
62047 + able to view all processes and network-related information. If you've
62048 + enabled GRKERNSEC_HIDESYM, kernel and symbol information may still
62049 + remain hidden. This option is useful if you want to run identd as
62050 + a non-root user. The group you select may also be chosen at boot time
62051 + via "grsec_proc_gid=" on the kernel commandline.
62052 +
62053 +config GRKERNSEC_PROC_GID
62054 + int "GID for special group"
62055 + depends on GRKERNSEC_PROC_USERGROUP
62056 + default 1001
62057 +
62058 +config GRKERNSEC_PROC_ADD
62059 + bool "Additional restrictions"
62060 + default y if GRKERNSEC_CONFIG_AUTO
62061 + depends on GRKERNSEC_PROC_USER || GRKERNSEC_PROC_USERGROUP
62062 + help
62063 + If you say Y here, additional restrictions will be placed on
62064 + /proc that keep normal users from viewing device information and
62065 + slabinfo information that could be useful for exploits.
62066 +
62067 +config GRKERNSEC_LINK
62068 + bool "Linking restrictions"
62069 + default y if GRKERNSEC_CONFIG_AUTO
62070 + help
62071 + If you say Y here, /tmp race exploits will be prevented, since users
62072 + will no longer be able to follow symlinks owned by other users in
62073 + world-writable +t directories (e.g. /tmp), unless the owner of the
62074 + symlink is the owner of the directory. users will also not be
62075 + able to hardlink to files they do not own. If the sysctl option is
62076 + enabled, a sysctl option with name "linking_restrictions" is created.
62077 +
62078 +config GRKERNSEC_SYMLINKOWN
62079 + bool "Kernel-enforced SymlinksIfOwnerMatch"
62080 + default y if GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_SERVER
62081 + help
62082 + Apache's SymlinksIfOwnerMatch option has an inherent race condition
62083 + that prevents it from being used as a security feature. As Apache
62084 + verifies the symlink by performing a stat() against the target of
62085 + the symlink before it is followed, an attacker can setup a symlink
62086 + to point to a same-owned file, then replace the symlink with one
62087 + that targets another user's file just after Apache "validates" the
62088 + symlink -- a classic TOCTOU race. If you say Y here, a complete,
62089 + race-free replacement for Apache's "SymlinksIfOwnerMatch" option
62090 + will be in place for the group you specify. If the sysctl option
62091 + is enabled, a sysctl option with name "enforce_symlinksifowner" is
62092 + created.
62093 +
62094 +config GRKERNSEC_SYMLINKOWN_GID
62095 + int "GID for users with kernel-enforced SymlinksIfOwnerMatch"
62096 + depends on GRKERNSEC_SYMLINKOWN
62097 + default 1006
62098 + help
62099 + Setting this GID determines what group kernel-enforced
62100 + SymlinksIfOwnerMatch will be enabled for. If the sysctl option
62101 + is enabled, a sysctl option with name "symlinkown_gid" is created.
62102 +
62103 +config GRKERNSEC_FIFO
62104 + bool "FIFO restrictions"
62105 + default y if GRKERNSEC_CONFIG_AUTO
62106 + help
62107 + If you say Y here, users will not be able to write to FIFOs they don't
62108 + own in world-writable +t directories (e.g. /tmp), unless the owner of
62109 + the FIFO is the same owner of the directory it's held in. If the sysctl
62110 + option is enabled, a sysctl option with name "fifo_restrictions" is
62111 + created.
62112 +
62113 +config GRKERNSEC_SYSFS_RESTRICT
62114 + bool "Sysfs/debugfs restriction"
62115 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_SERVER)
62116 + depends on SYSFS
62117 + help
62118 + If you say Y here, sysfs (the pseudo-filesystem mounted at /sys) and
62119 + any filesystem normally mounted under it (e.g. debugfs) will be
62120 + mostly accessible only by root. These filesystems generally provide access
62121 + to hardware and debug information that isn't appropriate for unprivileged
62122 + users of the system. Sysfs and debugfs have also become a large source
62123 + of new vulnerabilities, ranging from infoleaks to local compromise.
62124 + There has been very little oversight with an eye toward security involved
62125 + in adding new exporters of information to these filesystems, so their
62126 + use is discouraged.
62127 + For reasons of compatibility, a few directories have been whitelisted
62128 + for access by non-root users:
62129 + /sys/fs/selinux
62130 + /sys/fs/fuse
62131 + /sys/devices/system/cpu
62132 +
62133 +config GRKERNSEC_ROFS
62134 + bool "Runtime read-only mount protection"
62135 + depends on SYSCTL
62136 + help
62137 + If you say Y here, a sysctl option with name "romount_protect" will
62138 + be created. By setting this option to 1 at runtime, filesystems
62139 + will be protected in the following ways:
62140 + * No new writable mounts will be allowed
62141 + * Existing read-only mounts won't be able to be remounted read/write
62142 + * Write operations will be denied on all block devices
62143 + This option acts independently of grsec_lock: once it is set to 1,
62144 + it cannot be turned off. Therefore, please be mindful of the resulting
62145 + behavior if this option is enabled in an init script on a read-only
62146 + filesystem. This feature is mainly intended for secure embedded systems.
62147 +
62148 +config GRKERNSEC_DEVICE_SIDECHANNEL
62149 + bool "Eliminate stat/notify-based device sidechannels"
62150 + default y if GRKERNSEC_CONFIG_AUTO
62151 + help
62152 + If you say Y here, timing analyses on block or character
62153 + devices like /dev/ptmx using stat or inotify/dnotify/fanotify
62154 + will be thwarted for unprivileged users. If a process without
62155 + CAP_MKNOD stats such a device, the last access and last modify times
62156 + will match the device's create time. No access or modify events
62157 + will be triggered through inotify/dnotify/fanotify for such devices.
62158 + This feature will prevent attacks that may at a minimum
62159 + allow an attacker to determine the administrator's password length.
62160 +
62161 +config GRKERNSEC_CHROOT
62162 + bool "Chroot jail restrictions"
62163 + default y if GRKERNSEC_CONFIG_AUTO
62164 + help
62165 + If you say Y here, you will be able to choose several options that will
62166 + make breaking out of a chrooted jail much more difficult. If you
62167 + encounter no software incompatibilities with the following options, it
62168 + is recommended that you enable each one.
62169 +
62170 +config GRKERNSEC_CHROOT_MOUNT
62171 + bool "Deny mounts"
62172 + default y if GRKERNSEC_CONFIG_AUTO
62173 + depends on GRKERNSEC_CHROOT
62174 + help
62175 + If you say Y here, processes inside a chroot will not be able to
62176 + mount or remount filesystems. If the sysctl option is enabled, a
62177 + sysctl option with name "chroot_deny_mount" is created.
62178 +
62179 +config GRKERNSEC_CHROOT_DOUBLE
62180 + bool "Deny double-chroots"
62181 + default y if GRKERNSEC_CONFIG_AUTO
62182 + depends on GRKERNSEC_CHROOT
62183 + help
62184 + If you say Y here, processes inside a chroot will not be able to chroot
62185 + again outside the chroot. This is a widely used method of breaking
62186 + out of a chroot jail and should not be allowed. If the sysctl
62187 + option is enabled, a sysctl option with name
62188 + "chroot_deny_chroot" is created.
62189 +
62190 +config GRKERNSEC_CHROOT_PIVOT
62191 + bool "Deny pivot_root in chroot"
62192 + default y if GRKERNSEC_CONFIG_AUTO
62193 + depends on GRKERNSEC_CHROOT
62194 + help
62195 + If you say Y here, processes inside a chroot will not be able to use
62196 + a function called pivot_root() that was introduced in Linux 2.3.41. It
62197 + works similar to chroot in that it changes the root filesystem. This
62198 + function could be misused in a chrooted process to attempt to break out
62199 + of the chroot, and therefore should not be allowed. If the sysctl
62200 + option is enabled, a sysctl option with name "chroot_deny_pivot" is
62201 + created.
62202 +
62203 +config GRKERNSEC_CHROOT_CHDIR
62204 + bool "Enforce chdir(\"/\") on all chroots"
62205 + default y if GRKERNSEC_CONFIG_AUTO
62206 + depends on GRKERNSEC_CHROOT
62207 + help
62208 + If you say Y here, the current working directory of all newly-chrooted
62209 + applications will be set to the the root directory of the chroot.
62210 + The man page on chroot(2) states:
62211 + Note that this call does not change the current working
62212 + directory, so that `.' can be outside the tree rooted at
62213 + `/'. In particular, the super-user can escape from a
62214 + `chroot jail' by doing `mkdir foo; chroot foo; cd ..'.
62215 +
62216 + It is recommended that you say Y here, since it's not known to break
62217 + any software. If the sysctl option is enabled, a sysctl option with
62218 + name "chroot_enforce_chdir" is created.
62219 +
62220 +config GRKERNSEC_CHROOT_CHMOD
62221 + bool "Deny (f)chmod +s"
62222 + default y if GRKERNSEC_CONFIG_AUTO
62223 + depends on GRKERNSEC_CHROOT
62224 + help
62225 + If you say Y here, processes inside a chroot will not be able to chmod
62226 + or fchmod files to make them have suid or sgid bits. This protects
62227 + against another published method of breaking a chroot. If the sysctl
62228 + option is enabled, a sysctl option with name "chroot_deny_chmod" is
62229 + created.
62230 +
62231 +config GRKERNSEC_CHROOT_FCHDIR
62232 + bool "Deny fchdir out of chroot"
62233 + default y if GRKERNSEC_CONFIG_AUTO
62234 + depends on GRKERNSEC_CHROOT
62235 + help
62236 + If you say Y here, a well-known method of breaking chroots by fchdir'ing
62237 + to a file descriptor of the chrooting process that points to a directory
62238 + outside the filesystem will be stopped. If the sysctl option
62239 + is enabled, a sysctl option with name "chroot_deny_fchdir" is created.
62240 +
62241 +config GRKERNSEC_CHROOT_MKNOD
62242 + bool "Deny mknod"
62243 + default y if GRKERNSEC_CONFIG_AUTO
62244 + depends on GRKERNSEC_CHROOT
62245 + help
62246 + If you say Y here, processes inside a chroot will not be allowed to
62247 + mknod. The problem with using mknod inside a chroot is that it
62248 + would allow an attacker to create a device entry that is the same
62249 + as one on the physical root of your system, which could range from
62250 + anything from the console device to a device for your harddrive (which
62251 + they could then use to wipe the drive or steal data). It is recommended
62252 + that you say Y here, unless you run into software incompatibilities.
62253 + If the sysctl option is enabled, a sysctl option with name
62254 + "chroot_deny_mknod" is created.
62255 +
62256 +config GRKERNSEC_CHROOT_SHMAT
62257 + bool "Deny shmat() out of chroot"
62258 + default y if GRKERNSEC_CONFIG_AUTO
62259 + depends on GRKERNSEC_CHROOT
62260 + help
62261 + If you say Y here, processes inside a chroot will not be able to attach
62262 + to shared memory segments that were created outside of the chroot jail.
62263 + It is recommended that you say Y here. If the sysctl option is enabled,
62264 + a sysctl option with name "chroot_deny_shmat" is created.
62265 +
62266 +config GRKERNSEC_CHROOT_UNIX
62267 + bool "Deny access to abstract AF_UNIX sockets out of chroot"
62268 + default y if GRKERNSEC_CONFIG_AUTO
62269 + depends on GRKERNSEC_CHROOT
62270 + help
62271 + If you say Y here, processes inside a chroot will not be able to
62272 + connect to abstract (meaning not belonging to a filesystem) Unix
62273 + domain sockets that were bound outside of a chroot. It is recommended
62274 + that you say Y here. If the sysctl option is enabled, a sysctl option
62275 + with name "chroot_deny_unix" is created.
62276 +
62277 +config GRKERNSEC_CHROOT_FINDTASK
62278 + bool "Protect outside processes"
62279 + default y if GRKERNSEC_CONFIG_AUTO
62280 + depends on GRKERNSEC_CHROOT
62281 + help
62282 + If you say Y here, processes inside a chroot will not be able to
62283 + kill, send signals with fcntl, ptrace, capget, getpgid, setpgid,
62284 + getsid, or view any process outside of the chroot. If the sysctl
62285 + option is enabled, a sysctl option with name "chroot_findtask" is
62286 + created.
62287 +
62288 +config GRKERNSEC_CHROOT_NICE
62289 + bool "Restrict priority changes"
62290 + default y if GRKERNSEC_CONFIG_AUTO
62291 + depends on GRKERNSEC_CHROOT
62292 + help
62293 + If you say Y here, processes inside a chroot will not be able to raise
62294 + the priority of processes in the chroot, or alter the priority of
62295 + processes outside the chroot. This provides more security than simply
62296 + removing CAP_SYS_NICE from the process' capability set. If the
62297 + sysctl option is enabled, a sysctl option with name "chroot_restrict_nice"
62298 + is created.
62299 +
62300 +config GRKERNSEC_CHROOT_SYSCTL
62301 + bool "Deny sysctl writes"
62302 + default y if GRKERNSEC_CONFIG_AUTO
62303 + depends on GRKERNSEC_CHROOT
62304 + help
62305 + If you say Y here, an attacker in a chroot will not be able to
62306 + write to sysctl entries, either by sysctl(2) or through a /proc
62307 + interface. It is strongly recommended that you say Y here. If the
62308 + sysctl option is enabled, a sysctl option with name
62309 + "chroot_deny_sysctl" is created.
62310 +
62311 +config GRKERNSEC_CHROOT_CAPS
62312 + bool "Capability restrictions"
62313 + default y if GRKERNSEC_CONFIG_AUTO
62314 + depends on GRKERNSEC_CHROOT
62315 + help
62316 + If you say Y here, the capabilities on all processes within a
62317 + chroot jail will be lowered to stop module insertion, raw i/o,
62318 + system and net admin tasks, rebooting the system, modifying immutable
62319 + files, modifying IPC owned by another, and changing the system time.
62320 + This is left an option because it can break some apps. Disable this
62321 + if your chrooted apps are having problems performing those kinds of
62322 + tasks. If the sysctl option is enabled, a sysctl option with
62323 + name "chroot_caps" is created.
62324 +
62325 +config GRKERNSEC_CHROOT_INITRD
62326 + bool "Exempt initrd tasks from restrictions"
62327 + default y if GRKERNSEC_CONFIG_AUTO
62328 + depends on GRKERNSEC_CHROOT && BLK_DEV_INITRD
62329 + help
62330 + If you say Y here, tasks started prior to init will be exempted from
62331 + grsecurity's chroot restrictions. This option is mainly meant to
62332 + resolve Plymouth's performing privileged operations unnecessarily
62333 + in a chroot.
62334 +
62335 +endmenu
62336 +menu "Kernel Auditing"
62337 +depends on GRKERNSEC
62338 +
62339 +config GRKERNSEC_AUDIT_GROUP
62340 + bool "Single group for auditing"
62341 + help
62342 + If you say Y here, the exec and chdir logging features will only operate
62343 + on a group you specify. This option is recommended if you only want to
62344 + watch certain users instead of having a large amount of logs from the
62345 + entire system. If the sysctl option is enabled, a sysctl option with
62346 + name "audit_group" is created.
62347 +
62348 +config GRKERNSEC_AUDIT_GID
62349 + int "GID for auditing"
62350 + depends on GRKERNSEC_AUDIT_GROUP
62351 + default 1007
62352 +
62353 +config GRKERNSEC_EXECLOG
62354 + bool "Exec logging"
62355 + help
62356 + If you say Y here, all execve() calls will be logged (since the
62357 + other exec*() calls are frontends to execve(), all execution
62358 + will be logged). Useful for shell-servers that like to keep track
62359 + of their users. If the sysctl option is enabled, a sysctl option with
62360 + name "exec_logging" is created.
62361 + WARNING: This option when enabled will produce a LOT of logs, especially
62362 + on an active system.
62363 +
62364 +config GRKERNSEC_RESLOG
62365 + bool "Resource logging"
62366 + default y if GRKERNSEC_CONFIG_AUTO
62367 + help
62368 + If you say Y here, all attempts to overstep resource limits will
62369 + be logged with the resource name, the requested size, and the current
62370 + limit. It is highly recommended that you say Y here. If the sysctl
62371 + option is enabled, a sysctl option with name "resource_logging" is
62372 + created. If the RBAC system is enabled, the sysctl value is ignored.
62373 +
62374 +config GRKERNSEC_CHROOT_EXECLOG
62375 + bool "Log execs within chroot"
62376 + help
62377 + If you say Y here, all executions inside a chroot jail will be logged
62378 + to syslog. This can cause a large amount of logs if certain
62379 + applications (eg. djb's daemontools) are installed on the system, and
62380 + is therefore left as an option. If the sysctl option is enabled, a
62381 + sysctl option with name "chroot_execlog" is created.
62382 +
62383 +config GRKERNSEC_AUDIT_PTRACE
62384 + bool "Ptrace logging"
62385 + help
62386 + If you say Y here, all attempts to attach to a process via ptrace
62387 + will be logged. If the sysctl option is enabled, a sysctl option
62388 + with name "audit_ptrace" is created.
62389 +
62390 +config GRKERNSEC_AUDIT_CHDIR
62391 + bool "Chdir logging"
62392 + help
62393 + If you say Y here, all chdir() calls will be logged. If the sysctl
62394 + option is enabled, a sysctl option with name "audit_chdir" is created.
62395 +
62396 +config GRKERNSEC_AUDIT_MOUNT
62397 + bool "(Un)Mount logging"
62398 + help
62399 + If you say Y here, all mounts and unmounts will be logged. If the
62400 + sysctl option is enabled, a sysctl option with name "audit_mount" is
62401 + created.
62402 +
62403 +config GRKERNSEC_SIGNAL
62404 + bool "Signal logging"
62405 + default y if GRKERNSEC_CONFIG_AUTO
62406 + help
62407 + If you say Y here, certain important signals will be logged, such as
62408 + SIGSEGV, which will as a result inform you of when a error in a program
62409 + occurred, which in some cases could mean a possible exploit attempt.
62410 + If the sysctl option is enabled, a sysctl option with name
62411 + "signal_logging" is created.
62412 +
62413 +config GRKERNSEC_FORKFAIL
62414 + bool "Fork failure logging"
62415 + help
62416 + If you say Y here, all failed fork() attempts will be logged.
62417 + This could suggest a fork bomb, or someone attempting to overstep
62418 + their process limit. If the sysctl option is enabled, a sysctl option
62419 + with name "forkfail_logging" is created.
62420 +
62421 +config GRKERNSEC_TIME
62422 + bool "Time change logging"
62423 + default y if GRKERNSEC_CONFIG_AUTO
62424 + help
62425 + If you say Y here, any changes of the system clock will be logged.
62426 + If the sysctl option is enabled, a sysctl option with name
62427 + "timechange_logging" is created.
62428 +
62429 +config GRKERNSEC_PROC_IPADDR
62430 + bool "/proc/<pid>/ipaddr support"
62431 + default y if GRKERNSEC_CONFIG_AUTO
62432 + help
62433 + If you say Y here, a new entry will be added to each /proc/<pid>
62434 + directory that contains the IP address of the person using the task.
62435 + The IP is carried across local TCP and AF_UNIX stream sockets.
62436 + This information can be useful for IDS/IPSes to perform remote response
62437 + to a local attack. The entry is readable by only the owner of the
62438 + process (and root if he has CAP_DAC_OVERRIDE, which can be removed via
62439 + the RBAC system), and thus does not create privacy concerns.
62440 +
62441 +config GRKERNSEC_RWXMAP_LOG
62442 + bool 'Denied RWX mmap/mprotect logging'
62443 + default y if GRKERNSEC_CONFIG_AUTO
62444 + depends on PAX_MPROTECT && !PAX_EMUPLT && !PAX_EMUSIGRT
62445 + help
62446 + If you say Y here, calls to mmap() and mprotect() with explicit
62447 + usage of PROT_WRITE and PROT_EXEC together will be logged when
62448 + denied by the PAX_MPROTECT feature. This feature will also
62449 + log other problematic scenarios that can occur when PAX_MPROTECT
62450 + is enabled on a binary, like textrels and PT_GNU_STACK. If the
62451 + sysctl option is enabled, a sysctl option with name "rwxmap_logging"
62452 + is created.
62453 +
62454 +endmenu
62455 +
62456 +menu "Executable Protections"
62457 +depends on GRKERNSEC
62458 +
62459 +config GRKERNSEC_DMESG
62460 + bool "Dmesg(8) restriction"
62461 + default y if GRKERNSEC_CONFIG_AUTO
62462 + help
62463 + If you say Y here, non-root users will not be able to use dmesg(8)
62464 + to view the contents of the kernel's circular log buffer.
62465 + The kernel's log buffer often contains kernel addresses and other
62466 + identifying information useful to an attacker in fingerprinting a
62467 + system for a targeted exploit.
62468 + If the sysctl option is enabled, a sysctl option with name "dmesg" is
62469 + created.
62470 +
62471 +config GRKERNSEC_HARDEN_PTRACE
62472 + bool "Deter ptrace-based process snooping"
62473 + default y if GRKERNSEC_CONFIG_AUTO
62474 + help
62475 + If you say Y here, TTY sniffers and other malicious monitoring
62476 + programs implemented through ptrace will be defeated. If you
62477 + have been using the RBAC system, this option has already been
62478 + enabled for several years for all users, with the ability to make
62479 + fine-grained exceptions.
62480 +
62481 + This option only affects the ability of non-root users to ptrace
62482 + processes that are not a descendent of the ptracing process.
62483 + This means that strace ./binary and gdb ./binary will still work,
62484 + but attaching to arbitrary processes will not. If the sysctl
62485 + option is enabled, a sysctl option with name "harden_ptrace" is
62486 + created.
62487 +
62488 +config GRKERNSEC_PTRACE_READEXEC
62489 + bool "Require read access to ptrace sensitive binaries"
62490 + default y if GRKERNSEC_CONFIG_AUTO
62491 + help
62492 + If you say Y here, unprivileged users will not be able to ptrace unreadable
62493 + binaries. This option is useful in environments that
62494 + remove the read bits (e.g. file mode 4711) from suid binaries to
62495 + prevent infoleaking of their contents. This option adds
62496 + consistency to the use of that file mode, as the binary could normally
62497 + be read out when run without privileges while ptracing.
62498 +
62499 + If the sysctl option is enabled, a sysctl option with name "ptrace_readexec"
62500 + is created.
62501 +
62502 +config GRKERNSEC_SETXID
62503 + bool "Enforce consistent multithreaded privileges"
62504 + default y if GRKERNSEC_CONFIG_AUTO
62505 + depends on (X86 || SPARC64 || PPC || ARM || MIPS)
62506 + help
62507 + If you say Y here, a change from a root uid to a non-root uid
62508 + in a multithreaded application will cause the resulting uids,
62509 + gids, supplementary groups, and capabilities in that thread
62510 + to be propagated to the other threads of the process. In most
62511 + cases this is unnecessary, as glibc will emulate this behavior
62512 + on behalf of the application. Other libcs do not act in the
62513 + same way, allowing the other threads of the process to continue
62514 + running with root privileges. If the sysctl option is enabled,
62515 + a sysctl option with name "consistent_setxid" is created.
62516 +
62517 +config GRKERNSEC_HARDEN_IPC
62518 + bool "Disallow access to world-accessible IPC objects"
62519 + default y if GRKERNSEC_CONFIG_AUTO
62520 + depends on SYSVIPC
62521 + help
62522 + If you say Y here, access to overly-permissive IPC (shared memory,
62523 + message queues, and semaphores) will be denied for processes whose
62524 + effective user or group would not grant them permission. It's a
62525 + common error to grant too much permission to these objects, with
62526 + impact ranging from denial of service and information leaking to
62527 + privilege escalation. This feature was developed in response to
62528 + research by Tim Brown:
62529 + http://labs.portcullis.co.uk/whitepapers/memory-squatting-attacks-on-system-v-shared-memory/
62530 + who found hundreds of such insecure usages. Processes with
62531 + CAP_IPC_OWNER are still permitted to access these IPC objects.
62532 + If the sysctl option is enabled, a sysctl option with name
62533 + "harden_ipc" is created.
62534 +
62535 +config GRKERNSEC_TPE
62536 + bool "Trusted Path Execution (TPE)"
62537 + default y if GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_SERVER
62538 + help
62539 + If you say Y here, you will be able to choose a gid to add to the
62540 + supplementary groups of users you want to mark as "untrusted."
62541 + These users will not be able to execute any files that are not in
62542 + root-owned directories writable only by root. If the sysctl option
62543 + is enabled, a sysctl option with name "tpe" is created.
62544 +
62545 +config GRKERNSEC_TPE_ALL
62546 + bool "Partially restrict all non-root users"
62547 + depends on GRKERNSEC_TPE
62548 + help
62549 + If you say Y here, all non-root users will be covered under
62550 + a weaker TPE restriction. This is separate from, and in addition to,
62551 + the main TPE options that you have selected elsewhere. Thus, if a
62552 + "trusted" GID is chosen, this restriction applies to even that GID.
62553 + Under this restriction, all non-root users will only be allowed to
62554 + execute files in directories they own that are not group or
62555 + world-writable, or in directories owned by root and writable only by
62556 + root. If the sysctl option is enabled, a sysctl option with name
62557 + "tpe_restrict_all" is created.
62558 +
62559 +config GRKERNSEC_TPE_INVERT
62560 + bool "Invert GID option"
62561 + depends on GRKERNSEC_TPE
62562 + help
62563 + If you say Y here, the group you specify in the TPE configuration will
62564 + decide what group TPE restrictions will be *disabled* for. This
62565 + option is useful if you want TPE restrictions to be applied to most
62566 + users on the system. If the sysctl option is enabled, a sysctl option
62567 + with name "tpe_invert" is created. Unlike other sysctl options, this
62568 + entry will default to on for backward-compatibility.
62569 +
62570 +config GRKERNSEC_TPE_GID
62571 + int
62572 + default GRKERNSEC_TPE_UNTRUSTED_GID if (GRKERNSEC_TPE && !GRKERNSEC_TPE_INVERT)
62573 + default GRKERNSEC_TPE_TRUSTED_GID if (GRKERNSEC_TPE && GRKERNSEC_TPE_INVERT)
62574 +
62575 +config GRKERNSEC_TPE_UNTRUSTED_GID
62576 + int "GID for TPE-untrusted users"
62577 + depends on GRKERNSEC_TPE && !GRKERNSEC_TPE_INVERT
62578 + default 1005
62579 + help
62580 + Setting this GID determines what group TPE restrictions will be
62581 + *enabled* for. If the sysctl option is enabled, a sysctl option
62582 + with name "tpe_gid" is created.
62583 +
62584 +config GRKERNSEC_TPE_TRUSTED_GID
62585 + int "GID for TPE-trusted users"
62586 + depends on GRKERNSEC_TPE && GRKERNSEC_TPE_INVERT
62587 + default 1005
62588 + help
62589 + Setting this GID determines what group TPE restrictions will be
62590 + *disabled* for. If the sysctl option is enabled, a sysctl option
62591 + with name "tpe_gid" is created.
62592 +
62593 +endmenu
62594 +menu "Network Protections"
62595 +depends on GRKERNSEC
62596 +
62597 +config GRKERNSEC_RANDNET
62598 + bool "Larger entropy pools"
62599 + default y if GRKERNSEC_CONFIG_AUTO
62600 + help
62601 + If you say Y here, the entropy pools used for many features of Linux
62602 + and grsecurity will be doubled in size. Since several grsecurity
62603 + features use additional randomness, it is recommended that you say Y
62604 + here. Saying Y here has a similar effect as modifying
62605 + /proc/sys/kernel/random/poolsize.
62606 +
62607 +config GRKERNSEC_BLACKHOLE
62608 + bool "TCP/UDP blackhole and LAST_ACK DoS prevention"
62609 + default y if GRKERNSEC_CONFIG_AUTO
62610 + depends on NET
62611 + help
62612 + If you say Y here, neither TCP resets nor ICMP
62613 + destination-unreachable packets will be sent in response to packets
62614 + sent to ports for which no associated listening process exists.
62615 + This feature supports both IPV4 and IPV6 and exempts the
62616 + loopback interface from blackholing. Enabling this feature
62617 + makes a host more resilient to DoS attacks and reduces network
62618 + visibility against scanners.
62619 +
62620 + The blackhole feature as-implemented is equivalent to the FreeBSD
62621 + blackhole feature, as it prevents RST responses to all packets, not
62622 + just SYNs. Under most application behavior this causes no
62623 + problems, but applications (like haproxy) may not close certain
62624 + connections in a way that cleanly terminates them on the remote
62625 + end, leaving the remote host in LAST_ACK state. Because of this
62626 + side-effect and to prevent intentional LAST_ACK DoSes, this
62627 + feature also adds automatic mitigation against such attacks.
62628 + The mitigation drastically reduces the amount of time a socket
62629 + can spend in LAST_ACK state. If you're using haproxy and not
62630 + all servers it connects to have this option enabled, consider
62631 + disabling this feature on the haproxy host.
62632 +
62633 + If the sysctl option is enabled, two sysctl options with names
62634 + "ip_blackhole" and "lastack_retries" will be created.
62635 + While "ip_blackhole" takes the standard zero/non-zero on/off
62636 + toggle, "lastack_retries" uses the same kinds of values as
62637 + "tcp_retries1" and "tcp_retries2". The default value of 4
62638 + prevents a socket from lasting more than 45 seconds in LAST_ACK
62639 + state.
62640 +
62641 +config GRKERNSEC_NO_SIMULT_CONNECT
62642 + bool "Disable TCP Simultaneous Connect"
62643 + default y if GRKERNSEC_CONFIG_AUTO
62644 + depends on NET
62645 + help
62646 + If you say Y here, a feature by Willy Tarreau will be enabled that
62647 + removes a weakness in Linux's strict implementation of TCP that
62648 + allows two clients to connect to each other without either entering
62649 + a listening state. The weakness allows an attacker to easily prevent
62650 + a client from connecting to a known server provided the source port
62651 + for the connection is guessed correctly.
62652 +
62653 + As the weakness could be used to prevent an antivirus or IPS from
62654 + fetching updates, or prevent an SSL gateway from fetching a CRL,
62655 + it should be eliminated by enabling this option. Though Linux is
62656 + one of few operating systems supporting simultaneous connect, it
62657 + has no legitimate use in practice and is rarely supported by firewalls.
62658 +
62659 +config GRKERNSEC_SOCKET
62660 + bool "Socket restrictions"
62661 + depends on NET
62662 + help
62663 + If you say Y here, you will be able to choose from several options.
62664 + If you assign a GID on your system and add it to the supplementary
62665 + groups of users you want to restrict socket access to, this patch
62666 + will perform up to three things, based on the option(s) you choose.
62667 +
62668 +config GRKERNSEC_SOCKET_ALL
62669 + bool "Deny any sockets to group"
62670 + depends on GRKERNSEC_SOCKET
62671 + help
62672 + If you say Y here, you will be able to choose a GID of whose users will
62673 + be unable to connect to other hosts from your machine or run server
62674 + applications from your machine. If the sysctl option is enabled, a
62675 + sysctl option with name "socket_all" is created.
62676 +
62677 +config GRKERNSEC_SOCKET_ALL_GID
62678 + int "GID to deny all sockets for"
62679 + depends on GRKERNSEC_SOCKET_ALL
62680 + default 1004
62681 + help
62682 + Here you can choose the GID to disable socket access for. Remember to
62683 + add the users you want socket access disabled for to the GID
62684 + specified here. If the sysctl option is enabled, a sysctl option
62685 + with name "socket_all_gid" is created.
62686 +
62687 +config GRKERNSEC_SOCKET_CLIENT
62688 + bool "Deny client sockets to group"
62689 + depends on GRKERNSEC_SOCKET
62690 + help
62691 + If you say Y here, you will be able to choose a GID of whose users will
62692 + be unable to connect to other hosts from your machine, but will be
62693 + able to run servers. If this option is enabled, all users in the group
62694 + you specify will have to use passive mode when initiating ftp transfers
62695 + from the shell on your machine. If the sysctl option is enabled, a
62696 + sysctl option with name "socket_client" is created.
62697 +
62698 +config GRKERNSEC_SOCKET_CLIENT_GID
62699 + int "GID to deny client sockets for"
62700 + depends on GRKERNSEC_SOCKET_CLIENT
62701 + default 1003
62702 + help
62703 + Here you can choose the GID to disable client socket access for.
62704 + Remember to add the users you want client socket access disabled for to
62705 + the GID specified here. If the sysctl option is enabled, a sysctl
62706 + option with name "socket_client_gid" is created.
62707 +
62708 +config GRKERNSEC_SOCKET_SERVER
62709 + bool "Deny server sockets to group"
62710 + depends on GRKERNSEC_SOCKET
62711 + help
62712 + If you say Y here, you will be able to choose a GID of whose users will
62713 + be unable to run server applications from your machine. If the sysctl
62714 + option is enabled, a sysctl option with name "socket_server" is created.
62715 +
62716 +config GRKERNSEC_SOCKET_SERVER_GID
62717 + int "GID to deny server sockets for"
62718 + depends on GRKERNSEC_SOCKET_SERVER
62719 + default 1002
62720 + help
62721 + Here you can choose the GID to disable server socket access for.
62722 + Remember to add the users you want server socket access disabled for to
62723 + the GID specified here. If the sysctl option is enabled, a sysctl
62724 + option with name "socket_server_gid" is created.
62725 +
62726 +endmenu
62727 +
62728 +menu "Physical Protections"
62729 +depends on GRKERNSEC
62730 +
62731 +config GRKERNSEC_DENYUSB
62732 + bool "Deny new USB connections after toggle"
62733 + default y if GRKERNSEC_CONFIG_AUTO
62734 + depends on SYSCTL && USB_SUPPORT
62735 + help
62736 + If you say Y here, a new sysctl option with name "deny_new_usb"
62737 + will be created. Setting its value to 1 will prevent any new
62738 + USB devices from being recognized by the OS. Any attempted USB
62739 + device insertion will be logged. This option is intended to be
62740 + used against custom USB devices designed to exploit vulnerabilities
62741 + in various USB device drivers.
62742 +
62743 + For greatest effectiveness, this sysctl should be set after any
62744 + relevant init scripts. This option is safe to enable in distros
62745 + as each user can choose whether or not to toggle the sysctl.
62746 +
62747 +config GRKERNSEC_DENYUSB_FORCE
62748 + bool "Reject all USB devices not connected at boot"
62749 + select USB
62750 + depends on GRKERNSEC_DENYUSB
62751 + help
62752 + If you say Y here, a variant of GRKERNSEC_DENYUSB will be enabled
62753 + that doesn't involve a sysctl entry. This option should only be
62754 + enabled if you're sure you want to deny all new USB connections
62755 + at runtime and don't want to modify init scripts. This should not
62756 + be enabled by distros. It forces the core USB code to be built
62757 + into the kernel image so that all devices connected at boot time
62758 + can be recognized and new USB device connections can be prevented
62759 + prior to init running.
62760 +
62761 +endmenu
62762 +
62763 +menu "Sysctl Support"
62764 +depends on GRKERNSEC && SYSCTL
62765 +
62766 +config GRKERNSEC_SYSCTL
62767 + bool "Sysctl support"
62768 + default y if GRKERNSEC_CONFIG_AUTO
62769 + help
62770 + If you say Y here, you will be able to change the options that
62771 + grsecurity runs with at bootup, without having to recompile your
62772 + kernel. You can echo values to files in /proc/sys/kernel/grsecurity
62773 + to enable (1) or disable (0) various features. All the sysctl entries
62774 + are mutable until the "grsec_lock" entry is set to a non-zero value.
62775 + All features enabled in the kernel configuration are disabled at boot
62776 + if you do not say Y to the "Turn on features by default" option.
62777 + All options should be set at startup, and the grsec_lock entry should
62778 + be set to a non-zero value after all the options are set.
62779 + *THIS IS EXTREMELY IMPORTANT*
62780 +
62781 +config GRKERNSEC_SYSCTL_DISTRO
62782 + bool "Extra sysctl support for distro makers (READ HELP)"
62783 + depends on GRKERNSEC_SYSCTL && GRKERNSEC_IO
62784 + help
62785 + If you say Y here, additional sysctl options will be created
62786 + for features that affect processes running as root. Therefore,
62787 + it is critical when using this option that the grsec_lock entry be
62788 + enabled after boot. Only distros with prebuilt kernel packages
62789 + with this option enabled that can ensure grsec_lock is enabled
62790 + after boot should use this option.
62791 + *Failure to set grsec_lock after boot makes all grsec features
62792 + this option covers useless*
62793 +
62794 + Currently this option creates the following sysctl entries:
62795 + "Disable Privileged I/O": "disable_priv_io"
62796 +
62797 +config GRKERNSEC_SYSCTL_ON
62798 + bool "Turn on features by default"
62799 + default y if GRKERNSEC_CONFIG_AUTO
62800 + depends on GRKERNSEC_SYSCTL
62801 + help
62802 + If you say Y here, instead of having all features enabled in the
62803 + kernel configuration disabled at boot time, the features will be
62804 + enabled at boot time. It is recommended you say Y here unless
62805 + there is some reason you would want all sysctl-tunable features to
62806 + be disabled by default. As mentioned elsewhere, it is important
62807 + to enable the grsec_lock entry once you have finished modifying
62808 + the sysctl entries.
62809 +
62810 +endmenu
62811 +menu "Logging Options"
62812 +depends on GRKERNSEC
62813 +
62814 +config GRKERNSEC_FLOODTIME
62815 + int "Seconds in between log messages (minimum)"
62816 + default 10
62817 + help
62818 + This option allows you to enforce the number of seconds between
62819 + grsecurity log messages. The default should be suitable for most
62820 + people, however, if you choose to change it, choose a value small enough
62821 + to allow informative logs to be produced, but large enough to
62822 + prevent flooding.
62823 +
62824 +config GRKERNSEC_FLOODBURST
62825 + int "Number of messages in a burst (maximum)"
62826 + default 6
62827 + help
62828 + This option allows you to choose the maximum number of messages allowed
62829 + within the flood time interval you chose in a separate option. The
62830 + default should be suitable for most people, however if you find that
62831 + many of your logs are being interpreted as flooding, you may want to
62832 + raise this value.
62833 +
62834 +endmenu
62835 diff --git a/grsecurity/Makefile b/grsecurity/Makefile
62836 new file mode 100644
62837 index 0000000..85beb79
62838 --- /dev/null
62839 +++ b/grsecurity/Makefile
62840 @@ -0,0 +1,43 @@
62841 +# grsecurity's ACL system was originally written in 2001 by Michael Dalton
62842 +# during 2001-2009 it has been completely redesigned by Brad Spengler
62843 +# into an RBAC system
62844 +#
62845 +# All code in this directory and various hooks inserted throughout the kernel
62846 +# are copyright Brad Spengler - Open Source Security, Inc., and released
62847 +# under the GPL v2 or higher
62848 +
62849 +KBUILD_CFLAGS += -Werror
62850 +
62851 +obj-y = grsec_chdir.o grsec_chroot.o grsec_exec.o grsec_fifo.o grsec_fork.o \
62852 + grsec_mount.o grsec_sig.o grsec_sysctl.o \
62853 + grsec_time.o grsec_tpe.o grsec_link.o grsec_pax.o grsec_ptrace.o \
62854 + grsec_usb.o grsec_ipc.o
62855 +
62856 +obj-$(CONFIG_GRKERNSEC) += grsec_init.o grsum.o gracl.o gracl_segv.o \
62857 + gracl_cap.o gracl_alloc.o gracl_shm.o grsec_mem.o gracl_fs.o \
62858 + gracl_learn.o grsec_log.o gracl_policy.o
62859 +ifdef CONFIG_COMPAT
62860 +obj-$(CONFIG_GRKERNSEC) += gracl_compat.o
62861 +endif
62862 +
62863 +obj-$(CONFIG_GRKERNSEC_RESLOG) += gracl_res.o
62864 +
62865 +ifdef CONFIG_NET
62866 +obj-y += grsec_sock.o
62867 +obj-$(CONFIG_GRKERNSEC) += gracl_ip.o
62868 +endif
62869 +
62870 +ifndef CONFIG_GRKERNSEC
62871 +obj-y += grsec_disabled.o
62872 +endif
62873 +
62874 +ifdef CONFIG_GRKERNSEC_HIDESYM
62875 +extra-y := grsec_hidesym.o
62876 +$(obj)/grsec_hidesym.o:
62877 + @-chmod -f 500 /boot
62878 + @-chmod -f 500 /lib/modules
62879 + @-chmod -f 500 /lib64/modules
62880 + @-chmod -f 500 /lib32/modules
62881 + @-chmod -f 700 .
62882 + @echo ' grsec: protected kernel image paths'
62883 +endif
62884 diff --git a/grsecurity/gracl.c b/grsecurity/gracl.c
62885 new file mode 100644
62886 index 0000000..6affeea
62887 --- /dev/null
62888 +++ b/grsecurity/gracl.c
62889 @@ -0,0 +1,2679 @@
62890 +#include <linux/kernel.h>
62891 +#include <linux/module.h>
62892 +#include <linux/sched.h>
62893 +#include <linux/mm.h>
62894 +#include <linux/file.h>
62895 +#include <linux/fs.h>
62896 +#include <linux/namei.h>
62897 +#include <linux/mount.h>
62898 +#include <linux/tty.h>
62899 +#include <linux/proc_fs.h>
62900 +#include <linux/lglock.h>
62901 +#include <linux/slab.h>
62902 +#include <linux/vmalloc.h>
62903 +#include <linux/types.h>
62904 +#include <linux/sysctl.h>
62905 +#include <linux/netdevice.h>
62906 +#include <linux/ptrace.h>
62907 +#include <linux/gracl.h>
62908 +#include <linux/gralloc.h>
62909 +#include <linux/security.h>
62910 +#include <linux/grinternal.h>
62911 +#include <linux/pid_namespace.h>
62912 +#include <linux/stop_machine.h>
62913 +#include <linux/fdtable.h>
62914 +#include <linux/percpu.h>
62915 +#include <linux/lglock.h>
62916 +#include <linux/hugetlb.h>
62917 +#include <linux/posix-timers.h>
62918 +#if defined(CONFIG_BTRFS_FS) || defined(CONFIG_BTRFS_FS_MODULE)
62919 +#include <linux/magic.h>
62920 +#include <linux/pagemap.h>
62921 +#include "../fs/btrfs/async-thread.h"
62922 +#include "../fs/btrfs/ctree.h"
62923 +#include "../fs/btrfs/btrfs_inode.h"
62924 +#endif
62925 +#include "../fs/mount.h"
62926 +
62927 +#include <asm/uaccess.h>
62928 +#include <asm/errno.h>
62929 +#include <asm/mman.h>
62930 +
62931 +#define FOR_EACH_ROLE_START(role) \
62932 + role = running_polstate.role_list; \
62933 + while (role) {
62934 +
62935 +#define FOR_EACH_ROLE_END(role) \
62936 + role = role->prev; \
62937 + }
62938 +
62939 +extern struct lglock vfsmount_lock;
62940 +
62941 +extern struct path gr_real_root;
62942 +
62943 +static struct gr_policy_state running_polstate;
62944 +struct gr_policy_state *polstate = &running_polstate;
62945 +extern struct gr_alloc_state *current_alloc_state;
62946 +
62947 +extern char *gr_shared_page[4];
62948 +DEFINE_RWLOCK(gr_inode_lock);
62949 +
62950 +static unsigned int gr_status __read_only = GR_STATUS_INIT;
62951 +
62952 +#ifdef CONFIG_NET
62953 +extern struct vfsmount *sock_mnt;
62954 +#endif
62955 +
62956 +extern struct vfsmount *pipe_mnt;
62957 +extern struct vfsmount *shm_mnt;
62958 +
62959 +#ifdef CONFIG_HUGETLBFS
62960 +extern struct vfsmount *hugetlbfs_vfsmount[HUGE_MAX_HSTATE];
62961 +#endif
62962 +
62963 +extern u16 acl_sp_role_value;
62964 +extern struct acl_object_label *fakefs_obj_rw;
62965 +extern struct acl_object_label *fakefs_obj_rwx;
62966 +
62967 +int gr_acl_is_enabled(void)
62968 +{
62969 + return (gr_status & GR_READY);
62970 +}
62971 +
62972 +void gr_enable_rbac_system(void)
62973 +{
62974 + pax_open_kernel();
62975 + gr_status |= GR_READY;
62976 + pax_close_kernel();
62977 +}
62978 +
62979 +int gr_rbac_disable(void *unused)
62980 +{
62981 + pax_open_kernel();
62982 + gr_status &= ~GR_READY;
62983 + pax_close_kernel();
62984 +
62985 + return 0;
62986 +}
62987 +
62988 +static inline dev_t __get_dev(const struct dentry *dentry)
62989 +{
62990 +#if defined(CONFIG_BTRFS_FS) || defined(CONFIG_BTRFS_FS_MODULE)
62991 + if (dentry->d_sb->s_magic == BTRFS_SUPER_MAGIC)
62992 + return BTRFS_I(dentry->d_inode)->root->anon_dev;
62993 + else
62994 +#endif
62995 + return dentry->d_sb->s_dev;
62996 +}
62997 +
62998 +dev_t gr_get_dev_from_dentry(struct dentry *dentry)
62999 +{
63000 + return __get_dev(dentry);
63001 +}
63002 +
63003 +static char gr_task_roletype_to_char(struct task_struct *task)
63004 +{
63005 + switch (task->role->roletype &
63006 + (GR_ROLE_DEFAULT | GR_ROLE_USER | GR_ROLE_GROUP |
63007 + GR_ROLE_SPECIAL)) {
63008 + case GR_ROLE_DEFAULT:
63009 + return 'D';
63010 + case GR_ROLE_USER:
63011 + return 'U';
63012 + case GR_ROLE_GROUP:
63013 + return 'G';
63014 + case GR_ROLE_SPECIAL:
63015 + return 'S';
63016 + }
63017 +
63018 + return 'X';
63019 +}
63020 +
63021 +char gr_roletype_to_char(void)
63022 +{
63023 + return gr_task_roletype_to_char(current);
63024 +}
63025 +
63026 +__inline__ int
63027 +gr_acl_tpe_check(void)
63028 +{
63029 + if (unlikely(!(gr_status & GR_READY)))
63030 + return 0;
63031 + if (current->role->roletype & GR_ROLE_TPE)
63032 + return 1;
63033 + else
63034 + return 0;
63035 +}
63036 +
63037 +int
63038 +gr_handle_rawio(const struct inode *inode)
63039 +{
63040 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
63041 + if (inode && S_ISBLK(inode->i_mode) &&
63042 + grsec_enable_chroot_caps && proc_is_chrooted(current) &&
63043 + !capable(CAP_SYS_RAWIO))
63044 + return 1;
63045 +#endif
63046 + return 0;
63047 +}
63048 +
63049 +int
63050 +gr_streq(const char *a, const char *b, const unsigned int lena, const unsigned int lenb)
63051 +{
63052 + if (likely(lena != lenb))
63053 + return 0;
63054 +
63055 + return !memcmp(a, b, lena);
63056 +}
63057 +
63058 +static int prepend(char **buffer, int *buflen, const char *str, int namelen)
63059 +{
63060 + *buflen -= namelen;
63061 + if (*buflen < 0)
63062 + return -ENAMETOOLONG;
63063 + *buffer -= namelen;
63064 + memcpy(*buffer, str, namelen);
63065 + return 0;
63066 +}
63067 +
63068 +static int prepend_name(char **buffer, int *buflen, struct qstr *name)
63069 +{
63070 + return prepend(buffer, buflen, name->name, name->len);
63071 +}
63072 +
63073 +static int prepend_path(const struct path *path, struct path *root,
63074 + char **buffer, int *buflen)
63075 +{
63076 + struct dentry *dentry = path->dentry;
63077 + struct vfsmount *vfsmnt = path->mnt;
63078 + struct mount *mnt = real_mount(vfsmnt);
63079 + bool slash = false;
63080 + int error = 0;
63081 +
63082 + while (dentry != root->dentry || vfsmnt != root->mnt) {
63083 + struct dentry * parent;
63084 +
63085 + if (dentry == vfsmnt->mnt_root || IS_ROOT(dentry)) {
63086 + /* Global root? */
63087 + if (!mnt_has_parent(mnt)) {
63088 + goto out;
63089 + }
63090 + dentry = mnt->mnt_mountpoint;
63091 + mnt = mnt->mnt_parent;
63092 + vfsmnt = &mnt->mnt;
63093 + continue;
63094 + }
63095 + parent = dentry->d_parent;
63096 + prefetch(parent);
63097 + spin_lock(&dentry->d_lock);
63098 + error = prepend_name(buffer, buflen, &dentry->d_name);
63099 + spin_unlock(&dentry->d_lock);
63100 + if (!error)
63101 + error = prepend(buffer, buflen, "/", 1);
63102 + if (error)
63103 + break;
63104 +
63105 + slash = true;
63106 + dentry = parent;
63107 + }
63108 +
63109 +out:
63110 + if (!error && !slash)
63111 + error = prepend(buffer, buflen, "/", 1);
63112 +
63113 + return error;
63114 +}
63115 +
63116 +/* this must be called with vfsmount_lock and rename_lock held */
63117 +
63118 +static char *__our_d_path(const struct path *path, struct path *root,
63119 + char *buf, int buflen)
63120 +{
63121 + char *res = buf + buflen;
63122 + int error;
63123 +
63124 + prepend(&res, &buflen, "\0", 1);
63125 + error = prepend_path(path, root, &res, &buflen);
63126 + if (error)
63127 + return ERR_PTR(error);
63128 +
63129 + return res;
63130 +}
63131 +
63132 +static char *
63133 +gen_full_path(struct path *path, struct path *root, char *buf, int buflen)
63134 +{
63135 + char *retval;
63136 +
63137 + retval = __our_d_path(path, root, buf, buflen);
63138 + if (unlikely(IS_ERR(retval)))
63139 + retval = strcpy(buf, "<path too long>");
63140 + else if (unlikely(retval[1] == '/' && retval[2] == '\0'))
63141 + retval[1] = '\0';
63142 +
63143 + return retval;
63144 +}
63145 +
63146 +static char *
63147 +__d_real_path(const struct dentry *dentry, const struct vfsmount *vfsmnt,
63148 + char *buf, int buflen)
63149 +{
63150 + struct path path;
63151 + char *res;
63152 +
63153 + path.dentry = (struct dentry *)dentry;
63154 + path.mnt = (struct vfsmount *)vfsmnt;
63155 +
63156 + /* we can use gr_real_root.dentry, gr_real_root.mnt, because this is only called
63157 + by the RBAC system */
63158 + res = gen_full_path(&path, &gr_real_root, buf, buflen);
63159 +
63160 + return res;
63161 +}
63162 +
63163 +static char *
63164 +d_real_path(const struct dentry *dentry, const struct vfsmount *vfsmnt,
63165 + char *buf, int buflen)
63166 +{
63167 + char *res;
63168 + struct path path;
63169 + struct path root;
63170 + struct task_struct *reaper = init_pid_ns.child_reaper;
63171 +
63172 + path.dentry = (struct dentry *)dentry;
63173 + path.mnt = (struct vfsmount *)vfsmnt;
63174 +
63175 + /* we can't use gr_real_root.dentry, gr_real_root.mnt, because they belong only to the RBAC system */
63176 + get_fs_root(reaper->fs, &root);
63177 +
63178 + br_read_lock(&vfsmount_lock);
63179 + write_seqlock(&rename_lock);
63180 + res = gen_full_path(&path, &root, buf, buflen);
63181 + write_sequnlock(&rename_lock);
63182 + br_read_unlock(&vfsmount_lock);
63183 +
63184 + path_put(&root);
63185 + return res;
63186 +}
63187 +
63188 +char *
63189 +gr_to_filename_rbac(const struct dentry *dentry, const struct vfsmount *mnt)
63190 +{
63191 + char *ret;
63192 + br_read_lock(&vfsmount_lock);
63193 + write_seqlock(&rename_lock);
63194 + ret = __d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[0],smp_processor_id()),
63195 + PAGE_SIZE);
63196 + write_sequnlock(&rename_lock);
63197 + br_read_unlock(&vfsmount_lock);
63198 + return ret;
63199 +}
63200 +
63201 +static char *
63202 +gr_to_proc_filename_rbac(const struct dentry *dentry, const struct vfsmount *mnt)
63203 +{
63204 + char *ret;
63205 + char *buf;
63206 + int buflen;
63207 +
63208 + br_read_lock(&vfsmount_lock);
63209 + write_seqlock(&rename_lock);
63210 + buf = per_cpu_ptr(gr_shared_page[0], smp_processor_id());
63211 + ret = __d_real_path(dentry, mnt, buf, PAGE_SIZE - 6);
63212 + buflen = (int)(ret - buf);
63213 + if (buflen >= 5)
63214 + prepend(&ret, &buflen, "/proc", 5);
63215 + else
63216 + ret = strcpy(buf, "<path too long>");
63217 + write_sequnlock(&rename_lock);
63218 + br_read_unlock(&vfsmount_lock);
63219 + return ret;
63220 +}
63221 +
63222 +char *
63223 +gr_to_filename_nolock(const struct dentry *dentry, const struct vfsmount *mnt)
63224 +{
63225 + return __d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[0],smp_processor_id()),
63226 + PAGE_SIZE);
63227 +}
63228 +
63229 +char *
63230 +gr_to_filename(const struct dentry *dentry, const struct vfsmount *mnt)
63231 +{
63232 + return d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[0], smp_processor_id()),
63233 + PAGE_SIZE);
63234 +}
63235 +
63236 +char *
63237 +gr_to_filename1(const struct dentry *dentry, const struct vfsmount *mnt)
63238 +{
63239 + return d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[1], smp_processor_id()),
63240 + PAGE_SIZE);
63241 +}
63242 +
63243 +char *
63244 +gr_to_filename2(const struct dentry *dentry, const struct vfsmount *mnt)
63245 +{
63246 + return d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[2], smp_processor_id()),
63247 + PAGE_SIZE);
63248 +}
63249 +
63250 +char *
63251 +gr_to_filename3(const struct dentry *dentry, const struct vfsmount *mnt)
63252 +{
63253 + return d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[3], smp_processor_id()),
63254 + PAGE_SIZE);
63255 +}
63256 +
63257 +__inline__ __u32
63258 +to_gr_audit(const __u32 reqmode)
63259 +{
63260 + /* masks off auditable permission flags, then shifts them to create
63261 + auditing flags, and adds the special case of append auditing if
63262 + we're requesting write */
63263 + return (((reqmode & ~GR_AUDITS) << 10) | ((reqmode & GR_WRITE) ? GR_AUDIT_APPEND : 0));
63264 +}
63265 +
63266 +struct acl_role_label *
63267 +__lookup_acl_role_label(const struct gr_policy_state *state, const struct task_struct *task, const uid_t uid,
63268 + const gid_t gid)
63269 +{
63270 + unsigned int index = gr_rhash(uid, GR_ROLE_USER, state->acl_role_set.r_size);
63271 + struct acl_role_label *match;
63272 + struct role_allowed_ip *ipp;
63273 + unsigned int x;
63274 + u32 curr_ip = task->signal->saved_ip;
63275 +
63276 + match = state->acl_role_set.r_hash[index];
63277 +
63278 + while (match) {
63279 + if ((match->roletype & (GR_ROLE_DOMAIN | GR_ROLE_USER)) == (GR_ROLE_DOMAIN | GR_ROLE_USER)) {
63280 + for (x = 0; x < match->domain_child_num; x++) {
63281 + if (match->domain_children[x] == uid)
63282 + goto found;
63283 + }
63284 + } else if (match->uidgid == uid && match->roletype & GR_ROLE_USER)
63285 + break;
63286 + match = match->next;
63287 + }
63288 +found:
63289 + if (match == NULL) {
63290 + try_group:
63291 + index = gr_rhash(gid, GR_ROLE_GROUP, state->acl_role_set.r_size);
63292 + match = state->acl_role_set.r_hash[index];
63293 +
63294 + while (match) {
63295 + if ((match->roletype & (GR_ROLE_DOMAIN | GR_ROLE_GROUP)) == (GR_ROLE_DOMAIN | GR_ROLE_GROUP)) {
63296 + for (x = 0; x < match->domain_child_num; x++) {
63297 + if (match->domain_children[x] == gid)
63298 + goto found2;
63299 + }
63300 + } else if (match->uidgid == gid && match->roletype & GR_ROLE_GROUP)
63301 + break;
63302 + match = match->next;
63303 + }
63304 +found2:
63305 + if (match == NULL)
63306 + match = state->default_role;
63307 + if (match->allowed_ips == NULL)
63308 + return match;
63309 + else {
63310 + for (ipp = match->allowed_ips; ipp; ipp = ipp->next) {
63311 + if (likely
63312 + ((ntohl(curr_ip) & ipp->netmask) ==
63313 + (ntohl(ipp->addr) & ipp->netmask)))
63314 + return match;
63315 + }
63316 + match = state->default_role;
63317 + }
63318 + } else if (match->allowed_ips == NULL) {
63319 + return match;
63320 + } else {
63321 + for (ipp = match->allowed_ips; ipp; ipp = ipp->next) {
63322 + if (likely
63323 + ((ntohl(curr_ip) & ipp->netmask) ==
63324 + (ntohl(ipp->addr) & ipp->netmask)))
63325 + return match;
63326 + }
63327 + goto try_group;
63328 + }
63329 +
63330 + return match;
63331 +}
63332 +
63333 +static struct acl_role_label *
63334 +lookup_acl_role_label(const struct task_struct *task, const uid_t uid,
63335 + const gid_t gid)
63336 +{
63337 + return __lookup_acl_role_label(&running_polstate, task, uid, gid);
63338 +}
63339 +
63340 +struct acl_subject_label *
63341 +lookup_acl_subj_label(const ino_t ino, const dev_t dev,
63342 + const struct acl_role_label *role)
63343 +{
63344 + unsigned int index = gr_fhash(ino, dev, role->subj_hash_size);
63345 + struct acl_subject_label *match;
63346 +
63347 + match = role->subj_hash[index];
63348 +
63349 + while (match && (match->inode != ino || match->device != dev ||
63350 + (match->mode & GR_DELETED))) {
63351 + match = match->next;
63352 + }
63353 +
63354 + if (match && !(match->mode & GR_DELETED))
63355 + return match;
63356 + else
63357 + return NULL;
63358 +}
63359 +
63360 +struct acl_subject_label *
63361 +lookup_acl_subj_label_deleted(const ino_t ino, const dev_t dev,
63362 + const struct acl_role_label *role)
63363 +{
63364 + unsigned int index = gr_fhash(ino, dev, role->subj_hash_size);
63365 + struct acl_subject_label *match;
63366 +
63367 + match = role->subj_hash[index];
63368 +
63369 + while (match && (match->inode != ino || match->device != dev ||
63370 + !(match->mode & GR_DELETED))) {
63371 + match = match->next;
63372 + }
63373 +
63374 + if (match && (match->mode & GR_DELETED))
63375 + return match;
63376 + else
63377 + return NULL;
63378 +}
63379 +
63380 +static struct acl_object_label *
63381 +lookup_acl_obj_label(const ino_t ino, const dev_t dev,
63382 + const struct acl_subject_label *subj)
63383 +{
63384 + unsigned int index = gr_fhash(ino, dev, subj->obj_hash_size);
63385 + struct acl_object_label *match;
63386 +
63387 + match = subj->obj_hash[index];
63388 +
63389 + while (match && (match->inode != ino || match->device != dev ||
63390 + (match->mode & GR_DELETED))) {
63391 + match = match->next;
63392 + }
63393 +
63394 + if (match && !(match->mode & GR_DELETED))
63395 + return match;
63396 + else
63397 + return NULL;
63398 +}
63399 +
63400 +static struct acl_object_label *
63401 +lookup_acl_obj_label_create(const ino_t ino, const dev_t dev,
63402 + const struct acl_subject_label *subj)
63403 +{
63404 + unsigned int index = gr_fhash(ino, dev, subj->obj_hash_size);
63405 + struct acl_object_label *match;
63406 +
63407 + match = subj->obj_hash[index];
63408 +
63409 + while (match && (match->inode != ino || match->device != dev ||
63410 + !(match->mode & GR_DELETED))) {
63411 + match = match->next;
63412 + }
63413 +
63414 + if (match && (match->mode & GR_DELETED))
63415 + return match;
63416 +
63417 + match = subj->obj_hash[index];
63418 +
63419 + while (match && (match->inode != ino || match->device != dev ||
63420 + (match->mode & GR_DELETED))) {
63421 + match = match->next;
63422 + }
63423 +
63424 + if (match && !(match->mode & GR_DELETED))
63425 + return match;
63426 + else
63427 + return NULL;
63428 +}
63429 +
63430 +struct name_entry *
63431 +__lookup_name_entry(const struct gr_policy_state *state, const char *name)
63432 +{
63433 + unsigned int len = strlen(name);
63434 + unsigned int key = full_name_hash(name, len);
63435 + unsigned int index = key % state->name_set.n_size;
63436 + struct name_entry *match;
63437 +
63438 + match = state->name_set.n_hash[index];
63439 +
63440 + while (match && (match->key != key || !gr_streq(match->name, name, match->len, len)))
63441 + match = match->next;
63442 +
63443 + return match;
63444 +}
63445 +
63446 +static struct name_entry *
63447 +lookup_name_entry(const char *name)
63448 +{
63449 + return __lookup_name_entry(&running_polstate, name);
63450 +}
63451 +
63452 +static struct name_entry *
63453 +lookup_name_entry_create(const char *name)
63454 +{
63455 + unsigned int len = strlen(name);
63456 + unsigned int key = full_name_hash(name, len);
63457 + unsigned int index = key % running_polstate.name_set.n_size;
63458 + struct name_entry *match;
63459 +
63460 + match = running_polstate.name_set.n_hash[index];
63461 +
63462 + while (match && (match->key != key || !gr_streq(match->name, name, match->len, len) ||
63463 + !match->deleted))
63464 + match = match->next;
63465 +
63466 + if (match && match->deleted)
63467 + return match;
63468 +
63469 + match = running_polstate.name_set.n_hash[index];
63470 +
63471 + while (match && (match->key != key || !gr_streq(match->name, name, match->len, len) ||
63472 + match->deleted))
63473 + match = match->next;
63474 +
63475 + if (match && !match->deleted)
63476 + return match;
63477 + else
63478 + return NULL;
63479 +}
63480 +
63481 +static struct inodev_entry *
63482 +lookup_inodev_entry(const ino_t ino, const dev_t dev)
63483 +{
63484 + unsigned int index = gr_fhash(ino, dev, running_polstate.inodev_set.i_size);
63485 + struct inodev_entry *match;
63486 +
63487 + match = running_polstate.inodev_set.i_hash[index];
63488 +
63489 + while (match && (match->nentry->inode != ino || match->nentry->device != dev))
63490 + match = match->next;
63491 +
63492 + return match;
63493 +}
63494 +
63495 +void
63496 +__insert_inodev_entry(const struct gr_policy_state *state, struct inodev_entry *entry)
63497 +{
63498 + unsigned int index = gr_fhash(entry->nentry->inode, entry->nentry->device,
63499 + state->inodev_set.i_size);
63500 + struct inodev_entry **curr;
63501 +
63502 + entry->prev = NULL;
63503 +
63504 + curr = &state->inodev_set.i_hash[index];
63505 + if (*curr != NULL)
63506 + (*curr)->prev = entry;
63507 +
63508 + entry->next = *curr;
63509 + *curr = entry;
63510 +
63511 + return;
63512 +}
63513 +
63514 +static void
63515 +insert_inodev_entry(struct inodev_entry *entry)
63516 +{
63517 + __insert_inodev_entry(&running_polstate, entry);
63518 +}
63519 +
63520 +void
63521 +insert_acl_obj_label(struct acl_object_label *obj,
63522 + struct acl_subject_label *subj)
63523 +{
63524 + unsigned int index =
63525 + gr_fhash(obj->inode, obj->device, subj->obj_hash_size);
63526 + struct acl_object_label **curr;
63527 +
63528 + obj->prev = NULL;
63529 +
63530 + curr = &subj->obj_hash[index];
63531 + if (*curr != NULL)
63532 + (*curr)->prev = obj;
63533 +
63534 + obj->next = *curr;
63535 + *curr = obj;
63536 +
63537 + return;
63538 +}
63539 +
63540 +void
63541 +insert_acl_subj_label(struct acl_subject_label *obj,
63542 + struct acl_role_label *role)
63543 +{
63544 + unsigned int index = gr_fhash(obj->inode, obj->device, role->subj_hash_size);
63545 + struct acl_subject_label **curr;
63546 +
63547 + obj->prev = NULL;
63548 +
63549 + curr = &role->subj_hash[index];
63550 + if (*curr != NULL)
63551 + (*curr)->prev = obj;
63552 +
63553 + obj->next = *curr;
63554 + *curr = obj;
63555 +
63556 + return;
63557 +}
63558 +
63559 +/* derived from glibc fnmatch() 0: match, 1: no match*/
63560 +
63561 +static int
63562 +glob_match(const char *p, const char *n)
63563 +{
63564 + char c;
63565 +
63566 + while ((c = *p++) != '\0') {
63567 + switch (c) {
63568 + case '?':
63569 + if (*n == '\0')
63570 + return 1;
63571 + else if (*n == '/')
63572 + return 1;
63573 + break;
63574 + case '\\':
63575 + if (*n != c)
63576 + return 1;
63577 + break;
63578 + case '*':
63579 + for (c = *p++; c == '?' || c == '*'; c = *p++) {
63580 + if (*n == '/')
63581 + return 1;
63582 + else if (c == '?') {
63583 + if (*n == '\0')
63584 + return 1;
63585 + else
63586 + ++n;
63587 + }
63588 + }
63589 + if (c == '\0') {
63590 + return 0;
63591 + } else {
63592 + const char *endp;
63593 +
63594 + if ((endp = strchr(n, '/')) == NULL)
63595 + endp = n + strlen(n);
63596 +
63597 + if (c == '[') {
63598 + for (--p; n < endp; ++n)
63599 + if (!glob_match(p, n))
63600 + return 0;
63601 + } else if (c == '/') {
63602 + while (*n != '\0' && *n != '/')
63603 + ++n;
63604 + if (*n == '/' && !glob_match(p, n + 1))
63605 + return 0;
63606 + } else {
63607 + for (--p; n < endp; ++n)
63608 + if (*n == c && !glob_match(p, n))
63609 + return 0;
63610 + }
63611 +
63612 + return 1;
63613 + }
63614 + case '[':
63615 + {
63616 + int not;
63617 + char cold;
63618 +
63619 + if (*n == '\0' || *n == '/')
63620 + return 1;
63621 +
63622 + not = (*p == '!' || *p == '^');
63623 + if (not)
63624 + ++p;
63625 +
63626 + c = *p++;
63627 + for (;;) {
63628 + unsigned char fn = (unsigned char)*n;
63629 +
63630 + if (c == '\0')
63631 + return 1;
63632 + else {
63633 + if (c == fn)
63634 + goto matched;
63635 + cold = c;
63636 + c = *p++;
63637 +
63638 + if (c == '-' && *p != ']') {
63639 + unsigned char cend = *p++;
63640 +
63641 + if (cend == '\0')
63642 + return 1;
63643 +
63644 + if (cold <= fn && fn <= cend)
63645 + goto matched;
63646 +
63647 + c = *p++;
63648 + }
63649 + }
63650 +
63651 + if (c == ']')
63652 + break;
63653 + }
63654 + if (!not)
63655 + return 1;
63656 + break;
63657 + matched:
63658 + while (c != ']') {
63659 + if (c == '\0')
63660 + return 1;
63661 +
63662 + c = *p++;
63663 + }
63664 + if (not)
63665 + return 1;
63666 + }
63667 + break;
63668 + default:
63669 + if (c != *n)
63670 + return 1;
63671 + }
63672 +
63673 + ++n;
63674 + }
63675 +
63676 + if (*n == '\0')
63677 + return 0;
63678 +
63679 + if (*n == '/')
63680 + return 0;
63681 +
63682 + return 1;
63683 +}
63684 +
63685 +static struct acl_object_label *
63686 +chk_glob_label(struct acl_object_label *globbed,
63687 + const struct dentry *dentry, const struct vfsmount *mnt, char **path)
63688 +{
63689 + struct acl_object_label *tmp;
63690 +
63691 + if (*path == NULL)
63692 + *path = gr_to_filename_nolock(dentry, mnt);
63693 +
63694 + tmp = globbed;
63695 +
63696 + while (tmp) {
63697 + if (!glob_match(tmp->filename, *path))
63698 + return tmp;
63699 + tmp = tmp->next;
63700 + }
63701 +
63702 + return NULL;
63703 +}
63704 +
63705 +static struct acl_object_label *
63706 +__full_lookup(const struct dentry *orig_dentry, const struct vfsmount *orig_mnt,
63707 + const ino_t curr_ino, const dev_t curr_dev,
63708 + const struct acl_subject_label *subj, char **path, const int checkglob)
63709 +{
63710 + struct acl_subject_label *tmpsubj;
63711 + struct acl_object_label *retval;
63712 + struct acl_object_label *retval2;
63713 +
63714 + tmpsubj = (struct acl_subject_label *) subj;
63715 + read_lock(&gr_inode_lock);
63716 + do {
63717 + retval = lookup_acl_obj_label(curr_ino, curr_dev, tmpsubj);
63718 + if (retval) {
63719 + if (checkglob && retval->globbed) {
63720 + retval2 = chk_glob_label(retval->globbed, orig_dentry, orig_mnt, path);
63721 + if (retval2)
63722 + retval = retval2;
63723 + }
63724 + break;
63725 + }
63726 + } while ((tmpsubj = tmpsubj->parent_subject));
63727 + read_unlock(&gr_inode_lock);
63728 +
63729 + return retval;
63730 +}
63731 +
63732 +static __inline__ struct acl_object_label *
63733 +full_lookup(const struct dentry *orig_dentry, const struct vfsmount *orig_mnt,
63734 + struct dentry *curr_dentry,
63735 + const struct acl_subject_label *subj, char **path, const int checkglob)
63736 +{
63737 + int newglob = checkglob;
63738 + ino_t inode;
63739 + dev_t device;
63740 +
63741 + /* if we aren't checking a subdirectory of the original path yet, don't do glob checking
63742 + as we don't want a / * rule to match instead of the / object
63743 + don't do this for create lookups that call this function though, since they're looking up
63744 + on the parent and thus need globbing checks on all paths
63745 + */
63746 + if (orig_dentry == curr_dentry && newglob != GR_CREATE_GLOB)
63747 + newglob = GR_NO_GLOB;
63748 +
63749 + spin_lock(&curr_dentry->d_lock);
63750 + inode = curr_dentry->d_inode->i_ino;
63751 + device = __get_dev(curr_dentry);
63752 + spin_unlock(&curr_dentry->d_lock);
63753 +
63754 + return __full_lookup(orig_dentry, orig_mnt, inode, device, subj, path, newglob);
63755 +}
63756 +
63757 +#ifdef CONFIG_HUGETLBFS
63758 +static inline bool
63759 +is_hugetlbfs_mnt(const struct vfsmount *mnt)
63760 +{
63761 + int i;
63762 + for (i = 0; i < HUGE_MAX_HSTATE; i++) {
63763 + if (unlikely(hugetlbfs_vfsmount[i] == mnt))
63764 + return true;
63765 + }
63766 +
63767 + return false;
63768 +}
63769 +#endif
63770 +
63771 +static struct acl_object_label *
63772 +__chk_obj_label(const struct dentry *l_dentry, const struct vfsmount *l_mnt,
63773 + const struct acl_subject_label *subj, char *path, const int checkglob)
63774 +{
63775 + struct dentry *dentry = (struct dentry *) l_dentry;
63776 + struct vfsmount *mnt = (struct vfsmount *) l_mnt;
63777 + struct mount *real_mnt = real_mount(mnt);
63778 + struct acl_object_label *retval;
63779 + struct dentry *parent;
63780 +
63781 + br_read_lock(&vfsmount_lock);
63782 + write_seqlock(&rename_lock);
63783 +
63784 + if (unlikely((mnt == shm_mnt && dentry->d_inode->i_nlink == 0) || mnt == pipe_mnt ||
63785 +#ifdef CONFIG_NET
63786 + mnt == sock_mnt ||
63787 +#endif
63788 +#ifdef CONFIG_HUGETLBFS
63789 + (is_hugetlbfs_mnt(mnt) && dentry->d_inode->i_nlink == 0) ||
63790 +#endif
63791 + /* ignore Eric Biederman */
63792 + IS_PRIVATE(l_dentry->d_inode))) {
63793 + retval = (subj->mode & GR_SHMEXEC) ? fakefs_obj_rwx : fakefs_obj_rw;
63794 + goto out;
63795 + }
63796 +
63797 + for (;;) {
63798 + if (dentry == gr_real_root.dentry && mnt == gr_real_root.mnt)
63799 + break;
63800 +
63801 + if (dentry == mnt->mnt_root || IS_ROOT(dentry)) {
63802 + if (!mnt_has_parent(real_mnt))
63803 + break;
63804 +
63805 + retval = full_lookup(l_dentry, l_mnt, dentry, subj, &path, checkglob);
63806 + if (retval != NULL)
63807 + goto out;
63808 +
63809 + dentry = real_mnt->mnt_mountpoint;
63810 + real_mnt = real_mnt->mnt_parent;
63811 + mnt = &real_mnt->mnt;
63812 + continue;
63813 + }
63814 +
63815 + parent = dentry->d_parent;
63816 + retval = full_lookup(l_dentry, l_mnt, dentry, subj, &path, checkglob);
63817 + if (retval != NULL)
63818 + goto out;
63819 +
63820 + dentry = parent;
63821 + }
63822 +
63823 + retval = full_lookup(l_dentry, l_mnt, dentry, subj, &path, checkglob);
63824 +
63825 + /* gr_real_root is pinned so we don't have to hold a reference */
63826 + if (retval == NULL)
63827 + retval = full_lookup(l_dentry, l_mnt, gr_real_root.dentry, subj, &path, checkglob);
63828 +out:
63829 + write_sequnlock(&rename_lock);
63830 + br_read_unlock(&vfsmount_lock);
63831 +
63832 + BUG_ON(retval == NULL);
63833 +
63834 + return retval;
63835 +}
63836 +
63837 +static __inline__ struct acl_object_label *
63838 +chk_obj_label(const struct dentry *l_dentry, const struct vfsmount *l_mnt,
63839 + const struct acl_subject_label *subj)
63840 +{
63841 + char *path = NULL;
63842 + return __chk_obj_label(l_dentry, l_mnt, subj, path, GR_REG_GLOB);
63843 +}
63844 +
63845 +static __inline__ struct acl_object_label *
63846 +chk_obj_label_noglob(const struct dentry *l_dentry, const struct vfsmount *l_mnt,
63847 + const struct acl_subject_label *subj)
63848 +{
63849 + char *path = NULL;
63850 + return __chk_obj_label(l_dentry, l_mnt, subj, path, GR_NO_GLOB);
63851 +}
63852 +
63853 +static __inline__ struct acl_object_label *
63854 +chk_obj_create_label(const struct dentry *l_dentry, const struct vfsmount *l_mnt,
63855 + const struct acl_subject_label *subj, char *path)
63856 +{
63857 + return __chk_obj_label(l_dentry, l_mnt, subj, path, GR_CREATE_GLOB);
63858 +}
63859 +
63860 +struct acl_subject_label *
63861 +chk_subj_label(const struct dentry *l_dentry, const struct vfsmount *l_mnt,
63862 + const struct acl_role_label *role)
63863 +{
63864 + struct dentry *dentry = (struct dentry *) l_dentry;
63865 + struct vfsmount *mnt = (struct vfsmount *) l_mnt;
63866 + struct mount *real_mnt = real_mount(mnt);
63867 + struct acl_subject_label *retval;
63868 + struct dentry *parent;
63869 +
63870 + br_read_lock(&vfsmount_lock);
63871 + write_seqlock(&rename_lock);
63872 +
63873 + for (;;) {
63874 + if (dentry == gr_real_root.dentry && mnt == gr_real_root.mnt)
63875 + break;
63876 + if (dentry == mnt->mnt_root || IS_ROOT(dentry)) {
63877 + if (!mnt_has_parent(real_mnt))
63878 + break;
63879 +
63880 + spin_lock(&dentry->d_lock);
63881 + read_lock(&gr_inode_lock);
63882 + retval =
63883 + lookup_acl_subj_label(dentry->d_inode->i_ino,
63884 + __get_dev(dentry), role);
63885 + read_unlock(&gr_inode_lock);
63886 + spin_unlock(&dentry->d_lock);
63887 + if (retval != NULL)
63888 + goto out;
63889 +
63890 + dentry = real_mnt->mnt_mountpoint;
63891 + real_mnt = real_mnt->mnt_parent;
63892 + mnt = &real_mnt->mnt;
63893 + continue;
63894 + }
63895 +
63896 + spin_lock(&dentry->d_lock);
63897 + read_lock(&gr_inode_lock);
63898 + retval = lookup_acl_subj_label(dentry->d_inode->i_ino,
63899 + __get_dev(dentry), role);
63900 + read_unlock(&gr_inode_lock);
63901 + parent = dentry->d_parent;
63902 + spin_unlock(&dentry->d_lock);
63903 +
63904 + if (retval != NULL)
63905 + goto out;
63906 +
63907 + dentry = parent;
63908 + }
63909 +
63910 + spin_lock(&dentry->d_lock);
63911 + read_lock(&gr_inode_lock);
63912 + retval = lookup_acl_subj_label(dentry->d_inode->i_ino,
63913 + __get_dev(dentry), role);
63914 + read_unlock(&gr_inode_lock);
63915 + spin_unlock(&dentry->d_lock);
63916 +
63917 + if (unlikely(retval == NULL)) {
63918 + /* gr_real_root is pinned, we don't need to hold a reference */
63919 + read_lock(&gr_inode_lock);
63920 + retval = lookup_acl_subj_label(gr_real_root.dentry->d_inode->i_ino,
63921 + __get_dev(gr_real_root.dentry), role);
63922 + read_unlock(&gr_inode_lock);
63923 + }
63924 +out:
63925 + write_sequnlock(&rename_lock);
63926 + br_read_unlock(&vfsmount_lock);
63927 +
63928 + BUG_ON(retval == NULL);
63929 +
63930 + return retval;
63931 +}
63932 +
63933 +void
63934 +assign_special_role(const char *rolename)
63935 +{
63936 + struct acl_object_label *obj;
63937 + struct acl_role_label *r;
63938 + struct acl_role_label *assigned = NULL;
63939 + struct task_struct *tsk;
63940 + struct file *filp;
63941 +
63942 + FOR_EACH_ROLE_START(r)
63943 + if (!strcmp(rolename, r->rolename) &&
63944 + (r->roletype & GR_ROLE_SPECIAL)) {
63945 + assigned = r;
63946 + break;
63947 + }
63948 + FOR_EACH_ROLE_END(r)
63949 +
63950 + if (!assigned)
63951 + return;
63952 +
63953 + read_lock(&tasklist_lock);
63954 + read_lock(&grsec_exec_file_lock);
63955 +
63956 + tsk = current->real_parent;
63957 + if (tsk == NULL)
63958 + goto out_unlock;
63959 +
63960 + filp = tsk->exec_file;
63961 + if (filp == NULL)
63962 + goto out_unlock;
63963 +
63964 + tsk->is_writable = 0;
63965 + tsk->inherited = 0;
63966 +
63967 + tsk->acl_sp_role = 1;
63968 + tsk->acl_role_id = ++acl_sp_role_value;
63969 + tsk->role = assigned;
63970 + tsk->acl = chk_subj_label(filp->f_path.dentry, filp->f_path.mnt, tsk->role);
63971 +
63972 + /* ignore additional mmap checks for processes that are writable
63973 + by the default ACL */
63974 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, running_polstate.default_role->root_label);
63975 + if (unlikely(obj->mode & GR_WRITE))
63976 + tsk->is_writable = 1;
63977 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, tsk->role->root_label);
63978 + if (unlikely(obj->mode & GR_WRITE))
63979 + tsk->is_writable = 1;
63980 +
63981 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
63982 + printk(KERN_ALERT "Assigning special role:%s subject:%s to process (%s:%d)\n", tsk->role->rolename,
63983 + tsk->acl->filename, tsk->comm, task_pid_nr(tsk));
63984 +#endif
63985 +
63986 +out_unlock:
63987 + read_unlock(&grsec_exec_file_lock);
63988 + read_unlock(&tasklist_lock);
63989 + return;
63990 +}
63991 +
63992 +
63993 +static void
63994 +gr_log_learn(const struct dentry *dentry, const struct vfsmount *mnt, const __u32 mode)
63995 +{
63996 + struct task_struct *task = current;
63997 + const struct cred *cred = current_cred();
63998 +
63999 + security_learn(GR_LEARN_AUDIT_MSG, task->role->rolename, task->role->roletype,
64000 + GR_GLOBAL_UID(cred->uid), GR_GLOBAL_GID(cred->gid), task->exec_file ? gr_to_filename1(task->exec_file->f_path.dentry,
64001 + task->exec_file->f_path.mnt) : task->acl->filename, task->acl->filename,
64002 + 1UL, 1UL, gr_to_filename(dentry, mnt), (unsigned long) mode, &task->signal->saved_ip);
64003 +
64004 + return;
64005 +}
64006 +
64007 +static void
64008 +gr_log_learn_uid_change(const kuid_t real, const kuid_t effective, const kuid_t fs)
64009 +{
64010 + struct task_struct *task = current;
64011 + const struct cred *cred = current_cred();
64012 +
64013 + security_learn(GR_ID_LEARN_MSG, task->role->rolename, task->role->roletype,
64014 + GR_GLOBAL_UID(cred->uid), GR_GLOBAL_GID(cred->gid), task->exec_file ? gr_to_filename1(task->exec_file->f_path.dentry,
64015 + task->exec_file->f_path.mnt) : task->acl->filename, task->acl->filename,
64016 + 'u', GR_GLOBAL_UID(real), GR_GLOBAL_UID(effective), GR_GLOBAL_UID(fs), &task->signal->saved_ip);
64017 +
64018 + return;
64019 +}
64020 +
64021 +static void
64022 +gr_log_learn_gid_change(const kgid_t real, const kgid_t effective, const kgid_t fs)
64023 +{
64024 + struct task_struct *task = current;
64025 + const struct cred *cred = current_cred();
64026 +
64027 + security_learn(GR_ID_LEARN_MSG, task->role->rolename, task->role->roletype,
64028 + GR_GLOBAL_UID(cred->uid), GR_GLOBAL_GID(cred->gid), task->exec_file ? gr_to_filename1(task->exec_file->f_path.dentry,
64029 + task->exec_file->f_path.mnt) : task->acl->filename, task->acl->filename,
64030 + 'g', GR_GLOBAL_GID(real), GR_GLOBAL_GID(effective), GR_GLOBAL_GID(fs), &task->signal->saved_ip);
64031 +
64032 + return;
64033 +}
64034 +
64035 +static void
64036 +gr_set_proc_res(struct task_struct *task)
64037 +{
64038 + struct acl_subject_label *proc;
64039 + unsigned short i;
64040 +
64041 + proc = task->acl;
64042 +
64043 + if (proc->mode & (GR_LEARN | GR_INHERITLEARN))
64044 + return;
64045 +
64046 + for (i = 0; i < RLIM_NLIMITS; i++) {
64047 + if (!(proc->resmask & (1U << i)))
64048 + continue;
64049 +
64050 + task->signal->rlim[i].rlim_cur = proc->res[i].rlim_cur;
64051 + task->signal->rlim[i].rlim_max = proc->res[i].rlim_max;
64052 +
64053 + if (i == RLIMIT_CPU)
64054 + update_rlimit_cpu(task, proc->res[i].rlim_cur);
64055 + }
64056 +
64057 + return;
64058 +}
64059 +
64060 +/* both of the below must be called with
64061 + rcu_read_lock();
64062 + read_lock(&tasklist_lock);
64063 + read_lock(&grsec_exec_file_lock);
64064 +*/
64065 +
64066 +struct acl_subject_label *__gr_get_subject_for_task(const struct gr_policy_state *state, struct task_struct *task, const char *filename)
64067 +{
64068 + char *tmpname;
64069 + struct acl_subject_label *tmpsubj;
64070 + struct file *filp;
64071 + struct name_entry *nmatch;
64072 +
64073 + filp = task->exec_file;
64074 + if (filp == NULL)
64075 + return NULL;
64076 +
64077 + /* the following is to apply the correct subject
64078 + on binaries running when the RBAC system
64079 + is enabled, when the binaries have been
64080 + replaced or deleted since their execution
64081 + -----
64082 + when the RBAC system starts, the inode/dev
64083 + from exec_file will be one the RBAC system
64084 + is unaware of. It only knows the inode/dev
64085 + of the present file on disk, or the absence
64086 + of it.
64087 + */
64088 +
64089 + if (filename)
64090 + nmatch = __lookup_name_entry(state, filename);
64091 + else {
64092 + preempt_disable();
64093 + tmpname = gr_to_filename_rbac(filp->f_path.dentry, filp->f_path.mnt);
64094 +
64095 + nmatch = __lookup_name_entry(state, tmpname);
64096 + preempt_enable();
64097 + }
64098 + tmpsubj = NULL;
64099 + if (nmatch) {
64100 + if (nmatch->deleted)
64101 + tmpsubj = lookup_acl_subj_label_deleted(nmatch->inode, nmatch->device, task->role);
64102 + else
64103 + tmpsubj = lookup_acl_subj_label(nmatch->inode, nmatch->device, task->role);
64104 + }
64105 + /* this also works for the reload case -- if we don't match a potentially inherited subject
64106 + then we fall back to a normal lookup based on the binary's ino/dev
64107 + */
64108 + if (tmpsubj == NULL)
64109 + tmpsubj = chk_subj_label(filp->f_path.dentry, filp->f_path.mnt, task->role);
64110 +
64111 + return tmpsubj;
64112 +}
64113 +
64114 +static struct acl_subject_label *gr_get_subject_for_task(struct task_struct *task, const char *filename)
64115 +{
64116 + return __gr_get_subject_for_task(&running_polstate, task, filename);
64117 +}
64118 +
64119 +void __gr_apply_subject_to_task(const struct gr_policy_state *state, struct task_struct *task, struct acl_subject_label *subj)
64120 +{
64121 + struct acl_object_label *obj;
64122 + struct file *filp;
64123 +
64124 + filp = task->exec_file;
64125 +
64126 + task->acl = subj;
64127 + task->is_writable = 0;
64128 + /* ignore additional mmap checks for processes that are writable
64129 + by the default ACL */
64130 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, state->default_role->root_label);
64131 + if (unlikely(obj->mode & GR_WRITE))
64132 + task->is_writable = 1;
64133 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, task->role->root_label);
64134 + if (unlikely(obj->mode & GR_WRITE))
64135 + task->is_writable = 1;
64136 +
64137 + gr_set_proc_res(task);
64138 +
64139 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
64140 + 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);
64141 +#endif
64142 +}
64143 +
64144 +static void gr_apply_subject_to_task(struct task_struct *task, struct acl_subject_label *subj)
64145 +{
64146 + __gr_apply_subject_to_task(&running_polstate, task, subj);
64147 +}
64148 +
64149 +__u32
64150 +gr_search_file(const struct dentry * dentry, const __u32 mode,
64151 + const struct vfsmount * mnt)
64152 +{
64153 + __u32 retval = mode;
64154 + struct acl_subject_label *curracl;
64155 + struct acl_object_label *currobj;
64156 +
64157 + if (unlikely(!(gr_status & GR_READY)))
64158 + return (mode & ~GR_AUDITS);
64159 +
64160 + curracl = current->acl;
64161 +
64162 + currobj = chk_obj_label(dentry, mnt, curracl);
64163 + retval = currobj->mode & mode;
64164 +
64165 + /* if we're opening a specified transfer file for writing
64166 + (e.g. /dev/initctl), then transfer our role to init
64167 + */
64168 + if (unlikely(currobj->mode & GR_INIT_TRANSFER && retval & GR_WRITE &&
64169 + current->role->roletype & GR_ROLE_PERSIST)) {
64170 + struct task_struct *task = init_pid_ns.child_reaper;
64171 +
64172 + if (task->role != current->role) {
64173 + struct acl_subject_label *subj;
64174 +
64175 + task->acl_sp_role = 0;
64176 + task->acl_role_id = current->acl_role_id;
64177 + task->role = current->role;
64178 + rcu_read_lock();
64179 + read_lock(&grsec_exec_file_lock);
64180 + subj = gr_get_subject_for_task(task, NULL);
64181 + gr_apply_subject_to_task(task, subj);
64182 + read_unlock(&grsec_exec_file_lock);
64183 + rcu_read_unlock();
64184 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_INIT_TRANSFER_MSG);
64185 + }
64186 + }
64187 +
64188 + if (unlikely
64189 + ((curracl->mode & (GR_LEARN | GR_INHERITLEARN)) && !(mode & GR_NOPTRACE)
64190 + && (retval != (mode & ~(GR_AUDITS | GR_SUPPRESS))))) {
64191 + __u32 new_mode = mode;
64192 +
64193 + new_mode &= ~(GR_AUDITS | GR_SUPPRESS);
64194 +
64195 + retval = new_mode;
64196 +
64197 + if (new_mode & GR_EXEC && curracl->mode & GR_INHERITLEARN)
64198 + new_mode |= GR_INHERIT;
64199 +
64200 + if (!(mode & GR_NOLEARN))
64201 + gr_log_learn(dentry, mnt, new_mode);
64202 + }
64203 +
64204 + return retval;
64205 +}
64206 +
64207 +struct acl_object_label *gr_get_create_object(const struct dentry *new_dentry,
64208 + const struct dentry *parent,
64209 + const struct vfsmount *mnt)
64210 +{
64211 + struct name_entry *match;
64212 + struct acl_object_label *matchpo;
64213 + struct acl_subject_label *curracl;
64214 + char *path;
64215 +
64216 + if (unlikely(!(gr_status & GR_READY)))
64217 + return NULL;
64218 +
64219 + preempt_disable();
64220 + path = gr_to_filename_rbac(new_dentry, mnt);
64221 + match = lookup_name_entry_create(path);
64222 +
64223 + curracl = current->acl;
64224 +
64225 + if (match) {
64226 + read_lock(&gr_inode_lock);
64227 + matchpo = lookup_acl_obj_label_create(match->inode, match->device, curracl);
64228 + read_unlock(&gr_inode_lock);
64229 +
64230 + if (matchpo) {
64231 + preempt_enable();
64232 + return matchpo;
64233 + }
64234 + }
64235 +
64236 + // lookup parent
64237 +
64238 + matchpo = chk_obj_create_label(parent, mnt, curracl, path);
64239 +
64240 + preempt_enable();
64241 + return matchpo;
64242 +}
64243 +
64244 +__u32
64245 +gr_check_create(const struct dentry * new_dentry, const struct dentry * parent,
64246 + const struct vfsmount * mnt, const __u32 mode)
64247 +{
64248 + struct acl_object_label *matchpo;
64249 + __u32 retval;
64250 +
64251 + if (unlikely(!(gr_status & GR_READY)))
64252 + return (mode & ~GR_AUDITS);
64253 +
64254 + matchpo = gr_get_create_object(new_dentry, parent, mnt);
64255 +
64256 + retval = matchpo->mode & mode;
64257 +
64258 + if ((retval != (mode & ~(GR_AUDITS | GR_SUPPRESS)))
64259 + && (current->acl->mode & (GR_LEARN | GR_INHERITLEARN))) {
64260 + __u32 new_mode = mode;
64261 +
64262 + new_mode &= ~(GR_AUDITS | GR_SUPPRESS);
64263 +
64264 + gr_log_learn(new_dentry, mnt, new_mode);
64265 + return new_mode;
64266 + }
64267 +
64268 + return retval;
64269 +}
64270 +
64271 +__u32
64272 +gr_check_link(const struct dentry * new_dentry,
64273 + const struct dentry * parent_dentry,
64274 + const struct vfsmount * parent_mnt,
64275 + const struct dentry * old_dentry, const struct vfsmount * old_mnt)
64276 +{
64277 + struct acl_object_label *obj;
64278 + __u32 oldmode, newmode;
64279 + __u32 needmode;
64280 + __u32 checkmodes = GR_FIND | GR_APPEND | GR_WRITE | GR_EXEC | GR_SETID | GR_READ |
64281 + GR_DELETE | GR_INHERIT;
64282 +
64283 + if (unlikely(!(gr_status & GR_READY)))
64284 + return (GR_CREATE | GR_LINK);
64285 +
64286 + obj = chk_obj_label(old_dentry, old_mnt, current->acl);
64287 + oldmode = obj->mode;
64288 +
64289 + obj = gr_get_create_object(new_dentry, parent_dentry, parent_mnt);
64290 + newmode = obj->mode;
64291 +
64292 + needmode = newmode & checkmodes;
64293 +
64294 + // old name for hardlink must have at least the permissions of the new name
64295 + if ((oldmode & needmode) != needmode)
64296 + goto bad;
64297 +
64298 + // if old name had restrictions/auditing, make sure the new name does as well
64299 + needmode = oldmode & (GR_NOPTRACE | GR_PTRACERD | GR_INHERIT | GR_AUDITS);
64300 +
64301 + // don't allow hardlinking of suid/sgid/fcapped files without permission
64302 + if (is_privileged_binary(old_dentry))
64303 + needmode |= GR_SETID;
64304 +
64305 + if ((newmode & needmode) != needmode)
64306 + goto bad;
64307 +
64308 + // enforce minimum permissions
64309 + if ((newmode & (GR_CREATE | GR_LINK)) == (GR_CREATE | GR_LINK))
64310 + return newmode;
64311 +bad:
64312 + needmode = oldmode;
64313 + if (is_privileged_binary(old_dentry))
64314 + needmode |= GR_SETID;
64315 +
64316 + if (current->acl->mode & (GR_LEARN | GR_INHERITLEARN)) {
64317 + gr_log_learn(old_dentry, old_mnt, needmode | GR_CREATE | GR_LINK);
64318 + return (GR_CREATE | GR_LINK);
64319 + } else if (newmode & GR_SUPPRESS)
64320 + return GR_SUPPRESS;
64321 + else
64322 + return 0;
64323 +}
64324 +
64325 +int
64326 +gr_check_hidden_task(const struct task_struct *task)
64327 +{
64328 + if (unlikely(!(gr_status & GR_READY)))
64329 + return 0;
64330 +
64331 + if (!(task->acl->mode & GR_PROCFIND) && !(current->acl->mode & GR_VIEW))
64332 + return 1;
64333 +
64334 + return 0;
64335 +}
64336 +
64337 +int
64338 +gr_check_protected_task(const struct task_struct *task)
64339 +{
64340 + if (unlikely(!(gr_status & GR_READY) || !task))
64341 + return 0;
64342 +
64343 + if ((task->acl->mode & GR_PROTECTED) && !(current->acl->mode & GR_KILL) &&
64344 + task->acl != current->acl)
64345 + return 1;
64346 +
64347 + return 0;
64348 +}
64349 +
64350 +int
64351 +gr_check_protected_task_fowner(struct pid *pid, enum pid_type type)
64352 +{
64353 + struct task_struct *p;
64354 + int ret = 0;
64355 +
64356 + if (unlikely(!(gr_status & GR_READY) || !pid))
64357 + return ret;
64358 +
64359 + read_lock(&tasklist_lock);
64360 + do_each_pid_task(pid, type, p) {
64361 + if ((p->acl->mode & GR_PROTECTED) && !(current->acl->mode & GR_KILL) &&
64362 + p->acl != current->acl) {
64363 + ret = 1;
64364 + goto out;
64365 + }
64366 + } while_each_pid_task(pid, type, p);
64367 +out:
64368 + read_unlock(&tasklist_lock);
64369 +
64370 + return ret;
64371 +}
64372 +
64373 +void
64374 +gr_copy_label(struct task_struct *tsk)
64375 +{
64376 + struct task_struct *p = current;
64377 +
64378 + tsk->inherited = p->inherited;
64379 + tsk->acl_sp_role = 0;
64380 + tsk->acl_role_id = p->acl_role_id;
64381 + tsk->acl = p->acl;
64382 + tsk->role = p->role;
64383 + tsk->signal->used_accept = 0;
64384 + tsk->signal->curr_ip = p->signal->curr_ip;
64385 + tsk->signal->saved_ip = p->signal->saved_ip;
64386 + if (p->exec_file)
64387 + get_file(p->exec_file);
64388 + tsk->exec_file = p->exec_file;
64389 + tsk->is_writable = p->is_writable;
64390 + if (unlikely(p->signal->used_accept)) {
64391 + p->signal->curr_ip = 0;
64392 + p->signal->saved_ip = 0;
64393 + }
64394 +
64395 + return;
64396 +}
64397 +
64398 +extern int gr_process_kernel_setuid_ban(struct user_struct *user);
64399 +
64400 +int
64401 +gr_check_user_change(kuid_t real, kuid_t effective, kuid_t fs)
64402 +{
64403 + unsigned int i;
64404 + __u16 num;
64405 + uid_t *uidlist;
64406 + uid_t curuid;
64407 + int realok = 0;
64408 + int effectiveok = 0;
64409 + int fsok = 0;
64410 + uid_t globalreal, globaleffective, globalfs;
64411 +
64412 +#if defined(CONFIG_GRKERNSEC_KERN_LOCKOUT)
64413 + struct user_struct *user;
64414 +
64415 + if (!uid_valid(real))
64416 + goto skipit;
64417 +
64418 + /* find user based on global namespace */
64419 +
64420 + globalreal = GR_GLOBAL_UID(real);
64421 +
64422 + user = find_user(make_kuid(&init_user_ns, globalreal));
64423 + if (user == NULL)
64424 + goto skipit;
64425 +
64426 + if (gr_process_kernel_setuid_ban(user)) {
64427 + /* for find_user */
64428 + free_uid(user);
64429 + return 1;
64430 + }
64431 +
64432 + /* for find_user */
64433 + free_uid(user);
64434 +
64435 +skipit:
64436 +#endif
64437 +
64438 + if (unlikely(!(gr_status & GR_READY)))
64439 + return 0;
64440 +
64441 + if (current->acl->mode & (GR_LEARN | GR_INHERITLEARN))
64442 + gr_log_learn_uid_change(real, effective, fs);
64443 +
64444 + num = current->acl->user_trans_num;
64445 + uidlist = current->acl->user_transitions;
64446 +
64447 + if (uidlist == NULL)
64448 + return 0;
64449 +
64450 + if (!uid_valid(real)) {
64451 + realok = 1;
64452 + globalreal = (uid_t)-1;
64453 + } else {
64454 + globalreal = GR_GLOBAL_UID(real);
64455 + }
64456 + if (!uid_valid(effective)) {
64457 + effectiveok = 1;
64458 + globaleffective = (uid_t)-1;
64459 + } else {
64460 + globaleffective = GR_GLOBAL_UID(effective);
64461 + }
64462 + if (!uid_valid(fs)) {
64463 + fsok = 1;
64464 + globalfs = (uid_t)-1;
64465 + } else {
64466 + globalfs = GR_GLOBAL_UID(fs);
64467 + }
64468 +
64469 + if (current->acl->user_trans_type & GR_ID_ALLOW) {
64470 + for (i = 0; i < num; i++) {
64471 + curuid = uidlist[i];
64472 + if (globalreal == curuid)
64473 + realok = 1;
64474 + if (globaleffective == curuid)
64475 + effectiveok = 1;
64476 + if (globalfs == curuid)
64477 + fsok = 1;
64478 + }
64479 + } else if (current->acl->user_trans_type & GR_ID_DENY) {
64480 + for (i = 0; i < num; i++) {
64481 + curuid = uidlist[i];
64482 + if (globalreal == curuid)
64483 + break;
64484 + if (globaleffective == curuid)
64485 + break;
64486 + if (globalfs == curuid)
64487 + break;
64488 + }
64489 + /* not in deny list */
64490 + if (i == num) {
64491 + realok = 1;
64492 + effectiveok = 1;
64493 + fsok = 1;
64494 + }
64495 + }
64496 +
64497 + if (realok && effectiveok && fsok)
64498 + return 0;
64499 + else {
64500 + gr_log_int(GR_DONT_AUDIT, GR_USRCHANGE_ACL_MSG, realok ? (effectiveok ? (fsok ? 0 : globalfs) : globaleffective) : globalreal);
64501 + return 1;
64502 + }
64503 +}
64504 +
64505 +int
64506 +gr_check_group_change(kgid_t real, kgid_t effective, kgid_t fs)
64507 +{
64508 + unsigned int i;
64509 + __u16 num;
64510 + gid_t *gidlist;
64511 + gid_t curgid;
64512 + int realok = 0;
64513 + int effectiveok = 0;
64514 + int fsok = 0;
64515 + gid_t globalreal, globaleffective, globalfs;
64516 +
64517 + if (unlikely(!(gr_status & GR_READY)))
64518 + return 0;
64519 +
64520 + if (current->acl->mode & (GR_LEARN | GR_INHERITLEARN))
64521 + gr_log_learn_gid_change(real, effective, fs);
64522 +
64523 + num = current->acl->group_trans_num;
64524 + gidlist = current->acl->group_transitions;
64525 +
64526 + if (gidlist == NULL)
64527 + return 0;
64528 +
64529 + if (!gid_valid(real)) {
64530 + realok = 1;
64531 + globalreal = (gid_t)-1;
64532 + } else {
64533 + globalreal = GR_GLOBAL_GID(real);
64534 + }
64535 + if (!gid_valid(effective)) {
64536 + effectiveok = 1;
64537 + globaleffective = (gid_t)-1;
64538 + } else {
64539 + globaleffective = GR_GLOBAL_GID(effective);
64540 + }
64541 + if (!gid_valid(fs)) {
64542 + fsok = 1;
64543 + globalfs = (gid_t)-1;
64544 + } else {
64545 + globalfs = GR_GLOBAL_GID(fs);
64546 + }
64547 +
64548 + if (current->acl->group_trans_type & GR_ID_ALLOW) {
64549 + for (i = 0; i < num; i++) {
64550 + curgid = gidlist[i];
64551 + if (globalreal == curgid)
64552 + realok = 1;
64553 + if (globaleffective == curgid)
64554 + effectiveok = 1;
64555 + if (globalfs == curgid)
64556 + fsok = 1;
64557 + }
64558 + } else if (current->acl->group_trans_type & GR_ID_DENY) {
64559 + for (i = 0; i < num; i++) {
64560 + curgid = gidlist[i];
64561 + if (globalreal == curgid)
64562 + break;
64563 + if (globaleffective == curgid)
64564 + break;
64565 + if (globalfs == curgid)
64566 + break;
64567 + }
64568 + /* not in deny list */
64569 + if (i == num) {
64570 + realok = 1;
64571 + effectiveok = 1;
64572 + fsok = 1;
64573 + }
64574 + }
64575 +
64576 + if (realok && effectiveok && fsok)
64577 + return 0;
64578 + else {
64579 + gr_log_int(GR_DONT_AUDIT, GR_GRPCHANGE_ACL_MSG, realok ? (effectiveok ? (fsok ? 0 : globalfs) : globaleffective) : globalreal);
64580 + return 1;
64581 + }
64582 +}
64583 +
64584 +extern int gr_acl_is_capable(const int cap);
64585 +
64586 +void
64587 +gr_set_role_label(struct task_struct *task, const kuid_t kuid, const kgid_t kgid)
64588 +{
64589 + struct acl_role_label *role = task->role;
64590 + struct acl_subject_label *subj = NULL;
64591 + struct acl_object_label *obj;
64592 + struct file *filp;
64593 + uid_t uid;
64594 + gid_t gid;
64595 +
64596 + if (unlikely(!(gr_status & GR_READY)))
64597 + return;
64598 +
64599 + uid = GR_GLOBAL_UID(kuid);
64600 + gid = GR_GLOBAL_GID(kgid);
64601 +
64602 + filp = task->exec_file;
64603 +
64604 + /* kernel process, we'll give them the kernel role */
64605 + if (unlikely(!filp)) {
64606 + task->role = running_polstate.kernel_role;
64607 + task->acl = running_polstate.kernel_role->root_label;
64608 + return;
64609 + } else if (!task->role || !(task->role->roletype & GR_ROLE_SPECIAL)) {
64610 + /* save the current ip at time of role lookup so that the proper
64611 + IP will be learned for role_allowed_ip */
64612 + task->signal->saved_ip = task->signal->curr_ip;
64613 + role = lookup_acl_role_label(task, uid, gid);
64614 + }
64615 +
64616 + /* don't change the role if we're not a privileged process */
64617 + if (role && task->role != role &&
64618 + (((role->roletype & GR_ROLE_USER) && !gr_acl_is_capable(CAP_SETUID)) ||
64619 + ((role->roletype & GR_ROLE_GROUP) && !gr_acl_is_capable(CAP_SETGID))))
64620 + return;
64621 +
64622 + /* perform subject lookup in possibly new role
64623 + we can use this result below in the case where role == task->role
64624 + */
64625 + subj = chk_subj_label(filp->f_path.dentry, filp->f_path.mnt, role);
64626 +
64627 + /* if we changed uid/gid, but result in the same role
64628 + and are using inheritance, don't lose the inherited subject
64629 + if current subject is other than what normal lookup
64630 + would result in, we arrived via inheritance, don't
64631 + lose subject
64632 + */
64633 + if (role != task->role || (!(task->acl->mode & GR_INHERITLEARN) &&
64634 + (subj == task->acl)))
64635 + task->acl = subj;
64636 +
64637 + /* leave task->inherited unaffected */
64638 +
64639 + task->role = role;
64640 +
64641 + task->is_writable = 0;
64642 +
64643 + /* ignore additional mmap checks for processes that are writable
64644 + by the default ACL */
64645 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, running_polstate.default_role->root_label);
64646 + if (unlikely(obj->mode & GR_WRITE))
64647 + task->is_writable = 1;
64648 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, task->role->root_label);
64649 + if (unlikely(obj->mode & GR_WRITE))
64650 + task->is_writable = 1;
64651 +
64652 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
64653 + 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);
64654 +#endif
64655 +
64656 + gr_set_proc_res(task);
64657 +
64658 + return;
64659 +}
64660 +
64661 +int
64662 +gr_set_proc_label(const struct dentry *dentry, const struct vfsmount *mnt,
64663 + const int unsafe_flags)
64664 +{
64665 + struct task_struct *task = current;
64666 + struct acl_subject_label *newacl;
64667 + struct acl_object_label *obj;
64668 + __u32 retmode;
64669 +
64670 + if (unlikely(!(gr_status & GR_READY)))
64671 + return 0;
64672 +
64673 + newacl = chk_subj_label(dentry, mnt, task->role);
64674 +
64675 + /* special handling for if we did an strace -f -p <pid> from an admin role, where pid then
64676 + did an exec
64677 + */
64678 + rcu_read_lock();
64679 + read_lock(&tasklist_lock);
64680 + if (task->ptrace && task->parent && ((task->parent->role->roletype & GR_ROLE_GOD) ||
64681 + (task->parent->acl->mode & GR_POVERRIDE))) {
64682 + read_unlock(&tasklist_lock);
64683 + rcu_read_unlock();
64684 + goto skip_check;
64685 + }
64686 + read_unlock(&tasklist_lock);
64687 + rcu_read_unlock();
64688 +
64689 + if (unsafe_flags && !(task->acl->mode & GR_POVERRIDE) && (task->acl != newacl) &&
64690 + !(task->role->roletype & GR_ROLE_GOD) &&
64691 + !gr_search_file(dentry, GR_PTRACERD, mnt) &&
64692 + !(task->acl->mode & (GR_LEARN | GR_INHERITLEARN))) {
64693 + if (unsafe_flags & LSM_UNSAFE_SHARE)
64694 + gr_log_fs_generic(GR_DONT_AUDIT, GR_UNSAFESHARE_EXEC_ACL_MSG, dentry, mnt);
64695 + else
64696 + gr_log_fs_generic(GR_DONT_AUDIT, GR_PTRACE_EXEC_ACL_MSG, dentry, mnt);
64697 + return -EACCES;
64698 + }
64699 +
64700 +skip_check:
64701 +
64702 + obj = chk_obj_label(dentry, mnt, task->acl);
64703 + retmode = obj->mode & (GR_INHERIT | GR_AUDIT_INHERIT);
64704 +
64705 + if (!(task->acl->mode & GR_INHERITLEARN) &&
64706 + ((newacl->mode & GR_LEARN) || !(retmode & GR_INHERIT))) {
64707 + if (obj->nested)
64708 + task->acl = obj->nested;
64709 + else
64710 + task->acl = newacl;
64711 + task->inherited = 0;
64712 + } else {
64713 + task->inherited = 1;
64714 + if (retmode & GR_INHERIT && retmode & GR_AUDIT_INHERIT)
64715 + gr_log_str_fs(GR_DO_AUDIT, GR_INHERIT_ACL_MSG, task->acl->filename, dentry, mnt);
64716 + }
64717 +
64718 + task->is_writable = 0;
64719 +
64720 + /* ignore additional mmap checks for processes that are writable
64721 + by the default ACL */
64722 + obj = chk_obj_label(dentry, mnt, running_polstate.default_role->root_label);
64723 + if (unlikely(obj->mode & GR_WRITE))
64724 + task->is_writable = 1;
64725 + obj = chk_obj_label(dentry, mnt, task->role->root_label);
64726 + if (unlikely(obj->mode & GR_WRITE))
64727 + task->is_writable = 1;
64728 +
64729 + gr_set_proc_res(task);
64730 +
64731 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
64732 + 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);
64733 +#endif
64734 + return 0;
64735 +}
64736 +
64737 +/* always called with valid inodev ptr */
64738 +static void
64739 +do_handle_delete(struct inodev_entry *inodev, const ino_t ino, const dev_t dev)
64740 +{
64741 + struct acl_object_label *matchpo;
64742 + struct acl_subject_label *matchps;
64743 + struct acl_subject_label *subj;
64744 + struct acl_role_label *role;
64745 + unsigned int x;
64746 +
64747 + FOR_EACH_ROLE_START(role)
64748 + FOR_EACH_SUBJECT_START(role, subj, x)
64749 + if ((matchpo = lookup_acl_obj_label(ino, dev, subj)) != NULL)
64750 + matchpo->mode |= GR_DELETED;
64751 + FOR_EACH_SUBJECT_END(subj,x)
64752 + FOR_EACH_NESTED_SUBJECT_START(role, subj)
64753 + /* nested subjects aren't in the role's subj_hash table */
64754 + if ((matchpo = lookup_acl_obj_label(ino, dev, subj)) != NULL)
64755 + matchpo->mode |= GR_DELETED;
64756 + FOR_EACH_NESTED_SUBJECT_END(subj)
64757 + if ((matchps = lookup_acl_subj_label(ino, dev, role)) != NULL)
64758 + matchps->mode |= GR_DELETED;
64759 + FOR_EACH_ROLE_END(role)
64760 +
64761 + inodev->nentry->deleted = 1;
64762 +
64763 + return;
64764 +}
64765 +
64766 +void
64767 +gr_handle_delete(const ino_t ino, const dev_t dev)
64768 +{
64769 + struct inodev_entry *inodev;
64770 +
64771 + if (unlikely(!(gr_status & GR_READY)))
64772 + return;
64773 +
64774 + write_lock(&gr_inode_lock);
64775 + inodev = lookup_inodev_entry(ino, dev);
64776 + if (inodev != NULL)
64777 + do_handle_delete(inodev, ino, dev);
64778 + write_unlock(&gr_inode_lock);
64779 +
64780 + return;
64781 +}
64782 +
64783 +static void
64784 +update_acl_obj_label(const ino_t oldinode, const dev_t olddevice,
64785 + const ino_t newinode, const dev_t newdevice,
64786 + struct acl_subject_label *subj)
64787 +{
64788 + unsigned int index = gr_fhash(oldinode, olddevice, subj->obj_hash_size);
64789 + struct acl_object_label *match;
64790 +
64791 + match = subj->obj_hash[index];
64792 +
64793 + while (match && (match->inode != oldinode ||
64794 + match->device != olddevice ||
64795 + !(match->mode & GR_DELETED)))
64796 + match = match->next;
64797 +
64798 + if (match && (match->inode == oldinode)
64799 + && (match->device == olddevice)
64800 + && (match->mode & GR_DELETED)) {
64801 + if (match->prev == NULL) {
64802 + subj->obj_hash[index] = match->next;
64803 + if (match->next != NULL)
64804 + match->next->prev = NULL;
64805 + } else {
64806 + match->prev->next = match->next;
64807 + if (match->next != NULL)
64808 + match->next->prev = match->prev;
64809 + }
64810 + match->prev = NULL;
64811 + match->next = NULL;
64812 + match->inode = newinode;
64813 + match->device = newdevice;
64814 + match->mode &= ~GR_DELETED;
64815 +
64816 + insert_acl_obj_label(match, subj);
64817 + }
64818 +
64819 + return;
64820 +}
64821 +
64822 +static void
64823 +update_acl_subj_label(const ino_t oldinode, const dev_t olddevice,
64824 + const ino_t newinode, const dev_t newdevice,
64825 + struct acl_role_label *role)
64826 +{
64827 + unsigned int index = gr_fhash(oldinode, olddevice, role->subj_hash_size);
64828 + struct acl_subject_label *match;
64829 +
64830 + match = role->subj_hash[index];
64831 +
64832 + while (match && (match->inode != oldinode ||
64833 + match->device != olddevice ||
64834 + !(match->mode & GR_DELETED)))
64835 + match = match->next;
64836 +
64837 + if (match && (match->inode == oldinode)
64838 + && (match->device == olddevice)
64839 + && (match->mode & GR_DELETED)) {
64840 + if (match->prev == NULL) {
64841 + role->subj_hash[index] = match->next;
64842 + if (match->next != NULL)
64843 + match->next->prev = NULL;
64844 + } else {
64845 + match->prev->next = match->next;
64846 + if (match->next != NULL)
64847 + match->next->prev = match->prev;
64848 + }
64849 + match->prev = NULL;
64850 + match->next = NULL;
64851 + match->inode = newinode;
64852 + match->device = newdevice;
64853 + match->mode &= ~GR_DELETED;
64854 +
64855 + insert_acl_subj_label(match, role);
64856 + }
64857 +
64858 + return;
64859 +}
64860 +
64861 +static void
64862 +update_inodev_entry(const ino_t oldinode, const dev_t olddevice,
64863 + const ino_t newinode, const dev_t newdevice)
64864 +{
64865 + unsigned int index = gr_fhash(oldinode, olddevice, running_polstate.inodev_set.i_size);
64866 + struct inodev_entry *match;
64867 +
64868 + match = running_polstate.inodev_set.i_hash[index];
64869 +
64870 + while (match && (match->nentry->inode != oldinode ||
64871 + match->nentry->device != olddevice || !match->nentry->deleted))
64872 + match = match->next;
64873 +
64874 + if (match && (match->nentry->inode == oldinode)
64875 + && (match->nentry->device == olddevice) &&
64876 + match->nentry->deleted) {
64877 + if (match->prev == NULL) {
64878 + running_polstate.inodev_set.i_hash[index] = match->next;
64879 + if (match->next != NULL)
64880 + match->next->prev = NULL;
64881 + } else {
64882 + match->prev->next = match->next;
64883 + if (match->next != NULL)
64884 + match->next->prev = match->prev;
64885 + }
64886 + match->prev = NULL;
64887 + match->next = NULL;
64888 + match->nentry->inode = newinode;
64889 + match->nentry->device = newdevice;
64890 + match->nentry->deleted = 0;
64891 +
64892 + insert_inodev_entry(match);
64893 + }
64894 +
64895 + return;
64896 +}
64897 +
64898 +static void
64899 +__do_handle_create(const struct name_entry *matchn, ino_t ino, dev_t dev)
64900 +{
64901 + struct acl_subject_label *subj;
64902 + struct acl_role_label *role;
64903 + unsigned int x;
64904 +
64905 + FOR_EACH_ROLE_START(role)
64906 + update_acl_subj_label(matchn->inode, matchn->device, ino, dev, role);
64907 +
64908 + FOR_EACH_NESTED_SUBJECT_START(role, subj)
64909 + if ((subj->inode == ino) && (subj->device == dev)) {
64910 + subj->inode = ino;
64911 + subj->device = dev;
64912 + }
64913 + /* nested subjects aren't in the role's subj_hash table */
64914 + update_acl_obj_label(matchn->inode, matchn->device,
64915 + ino, dev, subj);
64916 + FOR_EACH_NESTED_SUBJECT_END(subj)
64917 + FOR_EACH_SUBJECT_START(role, subj, x)
64918 + update_acl_obj_label(matchn->inode, matchn->device,
64919 + ino, dev, subj);
64920 + FOR_EACH_SUBJECT_END(subj,x)
64921 + FOR_EACH_ROLE_END(role)
64922 +
64923 + update_inodev_entry(matchn->inode, matchn->device, ino, dev);
64924 +
64925 + return;
64926 +}
64927 +
64928 +static void
64929 +do_handle_create(const struct name_entry *matchn, const struct dentry *dentry,
64930 + const struct vfsmount *mnt)
64931 +{
64932 + ino_t ino = dentry->d_inode->i_ino;
64933 + dev_t dev = __get_dev(dentry);
64934 +
64935 + __do_handle_create(matchn, ino, dev);
64936 +
64937 + return;
64938 +}
64939 +
64940 +void
64941 +gr_handle_create(const struct dentry *dentry, const struct vfsmount *mnt)
64942 +{
64943 + struct name_entry *matchn;
64944 +
64945 + if (unlikely(!(gr_status & GR_READY)))
64946 + return;
64947 +
64948 + preempt_disable();
64949 + matchn = lookup_name_entry(gr_to_filename_rbac(dentry, mnt));
64950 +
64951 + if (unlikely((unsigned long)matchn)) {
64952 + write_lock(&gr_inode_lock);
64953 + do_handle_create(matchn, dentry, mnt);
64954 + write_unlock(&gr_inode_lock);
64955 + }
64956 + preempt_enable();
64957 +
64958 + return;
64959 +}
64960 +
64961 +void
64962 +gr_handle_proc_create(const struct dentry *dentry, const struct inode *inode)
64963 +{
64964 + struct name_entry *matchn;
64965 +
64966 + if (unlikely(!(gr_status & GR_READY)))
64967 + return;
64968 +
64969 + preempt_disable();
64970 + matchn = lookup_name_entry(gr_to_proc_filename_rbac(dentry, init_pid_ns.proc_mnt));
64971 +
64972 + if (unlikely((unsigned long)matchn)) {
64973 + write_lock(&gr_inode_lock);
64974 + __do_handle_create(matchn, inode->i_ino, inode->i_sb->s_dev);
64975 + write_unlock(&gr_inode_lock);
64976 + }
64977 + preempt_enable();
64978 +
64979 + return;
64980 +}
64981 +
64982 +void
64983 +gr_handle_rename(struct inode *old_dir, struct inode *new_dir,
64984 + struct dentry *old_dentry,
64985 + struct dentry *new_dentry,
64986 + struct vfsmount *mnt, const __u8 replace)
64987 +{
64988 + struct name_entry *matchn;
64989 + struct inodev_entry *inodev;
64990 + struct inode *inode = new_dentry->d_inode;
64991 + ino_t old_ino = old_dentry->d_inode->i_ino;
64992 + dev_t old_dev = __get_dev(old_dentry);
64993 +
64994 + /* vfs_rename swaps the name and parent link for old_dentry and
64995 + new_dentry
64996 + at this point, old_dentry has the new name, parent link, and inode
64997 + for the renamed file
64998 + if a file is being replaced by a rename, new_dentry has the inode
64999 + and name for the replaced file
65000 + */
65001 +
65002 + if (unlikely(!(gr_status & GR_READY)))
65003 + return;
65004 +
65005 + preempt_disable();
65006 + matchn = lookup_name_entry(gr_to_filename_rbac(old_dentry, mnt));
65007 +
65008 + /* we wouldn't have to check d_inode if it weren't for
65009 + NFS silly-renaming
65010 + */
65011 +
65012 + write_lock(&gr_inode_lock);
65013 + if (unlikely(replace && inode)) {
65014 + ino_t new_ino = inode->i_ino;
65015 + dev_t new_dev = __get_dev(new_dentry);
65016 +
65017 + inodev = lookup_inodev_entry(new_ino, new_dev);
65018 + if (inodev != NULL && ((inode->i_nlink <= 1) || S_ISDIR(inode->i_mode)))
65019 + do_handle_delete(inodev, new_ino, new_dev);
65020 + }
65021 +
65022 + inodev = lookup_inodev_entry(old_ino, old_dev);
65023 + if (inodev != NULL && ((old_dentry->d_inode->i_nlink <= 1) || S_ISDIR(old_dentry->d_inode->i_mode)))
65024 + do_handle_delete(inodev, old_ino, old_dev);
65025 +
65026 + if (unlikely((unsigned long)matchn))
65027 + do_handle_create(matchn, old_dentry, mnt);
65028 +
65029 + write_unlock(&gr_inode_lock);
65030 + preempt_enable();
65031 +
65032 + return;
65033 +}
65034 +
65035 +#if defined(CONFIG_GRKERNSEC_RESLOG) || !defined(CONFIG_GRKERNSEC_NO_RBAC)
65036 +static const unsigned long res_learn_bumps[GR_NLIMITS] = {
65037 + [RLIMIT_CPU] = GR_RLIM_CPU_BUMP,
65038 + [RLIMIT_FSIZE] = GR_RLIM_FSIZE_BUMP,
65039 + [RLIMIT_DATA] = GR_RLIM_DATA_BUMP,
65040 + [RLIMIT_STACK] = GR_RLIM_STACK_BUMP,
65041 + [RLIMIT_CORE] = GR_RLIM_CORE_BUMP,
65042 + [RLIMIT_RSS] = GR_RLIM_RSS_BUMP,
65043 + [RLIMIT_NPROC] = GR_RLIM_NPROC_BUMP,
65044 + [RLIMIT_NOFILE] = GR_RLIM_NOFILE_BUMP,
65045 + [RLIMIT_MEMLOCK] = GR_RLIM_MEMLOCK_BUMP,
65046 + [RLIMIT_AS] = GR_RLIM_AS_BUMP,
65047 + [RLIMIT_LOCKS] = GR_RLIM_LOCKS_BUMP,
65048 + [RLIMIT_SIGPENDING] = GR_RLIM_SIGPENDING_BUMP,
65049 + [RLIMIT_MSGQUEUE] = GR_RLIM_MSGQUEUE_BUMP,
65050 + [RLIMIT_NICE] = GR_RLIM_NICE_BUMP,
65051 + [RLIMIT_RTPRIO] = GR_RLIM_RTPRIO_BUMP,
65052 + [RLIMIT_RTTIME] = GR_RLIM_RTTIME_BUMP
65053 +};
65054 +
65055 +void
65056 +gr_learn_resource(const struct task_struct *task,
65057 + const int res, const unsigned long wanted, const int gt)
65058 +{
65059 + struct acl_subject_label *acl;
65060 + const struct cred *cred;
65061 +
65062 + if (unlikely((gr_status & GR_READY) &&
65063 + task->acl && (task->acl->mode & (GR_LEARN | GR_INHERITLEARN))))
65064 + goto skip_reslog;
65065 +
65066 + gr_log_resource(task, res, wanted, gt);
65067 +skip_reslog:
65068 +
65069 + if (unlikely(!(gr_status & GR_READY) || !wanted || res >= GR_NLIMITS))
65070 + return;
65071 +
65072 + acl = task->acl;
65073 +
65074 + if (likely(!acl || !(acl->mode & (GR_LEARN | GR_INHERITLEARN)) ||
65075 + !(acl->resmask & (1U << (unsigned short) res))))
65076 + return;
65077 +
65078 + if (wanted >= acl->res[res].rlim_cur) {
65079 + unsigned long res_add;
65080 +
65081 + res_add = wanted + res_learn_bumps[res];
65082 +
65083 + acl->res[res].rlim_cur = res_add;
65084 +
65085 + if (wanted > acl->res[res].rlim_max)
65086 + acl->res[res].rlim_max = res_add;
65087 +
65088 + /* only log the subject filename, since resource logging is supported for
65089 + single-subject learning only */
65090 + rcu_read_lock();
65091 + cred = __task_cred(task);
65092 + security_learn(GR_LEARN_AUDIT_MSG, task->role->rolename,
65093 + task->role->roletype, GR_GLOBAL_UID(cred->uid), GR_GLOBAL_GID(cred->gid), acl->filename,
65094 + acl->filename, acl->res[res].rlim_cur, acl->res[res].rlim_max,
65095 + "", (unsigned long) res, &task->signal->saved_ip);
65096 + rcu_read_unlock();
65097 + }
65098 +
65099 + return;
65100 +}
65101 +EXPORT_SYMBOL(gr_learn_resource);
65102 +#endif
65103 +
65104 +#if defined(CONFIG_PAX_HAVE_ACL_FLAGS) && (defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR))
65105 +void
65106 +pax_set_initial_flags(struct linux_binprm *bprm)
65107 +{
65108 + struct task_struct *task = current;
65109 + struct acl_subject_label *proc;
65110 + unsigned long flags;
65111 +
65112 + if (unlikely(!(gr_status & GR_READY)))
65113 + return;
65114 +
65115 + flags = pax_get_flags(task);
65116 +
65117 + proc = task->acl;
65118 +
65119 + if (proc->pax_flags & GR_PAX_DISABLE_PAGEEXEC)
65120 + flags &= ~MF_PAX_PAGEEXEC;
65121 + if (proc->pax_flags & GR_PAX_DISABLE_SEGMEXEC)
65122 + flags &= ~MF_PAX_SEGMEXEC;
65123 + if (proc->pax_flags & GR_PAX_DISABLE_RANDMMAP)
65124 + flags &= ~MF_PAX_RANDMMAP;
65125 + if (proc->pax_flags & GR_PAX_DISABLE_EMUTRAMP)
65126 + flags &= ~MF_PAX_EMUTRAMP;
65127 + if (proc->pax_flags & GR_PAX_DISABLE_MPROTECT)
65128 + flags &= ~MF_PAX_MPROTECT;
65129 +
65130 + if (proc->pax_flags & GR_PAX_ENABLE_PAGEEXEC)
65131 + flags |= MF_PAX_PAGEEXEC;
65132 + if (proc->pax_flags & GR_PAX_ENABLE_SEGMEXEC)
65133 + flags |= MF_PAX_SEGMEXEC;
65134 + if (proc->pax_flags & GR_PAX_ENABLE_RANDMMAP)
65135 + flags |= MF_PAX_RANDMMAP;
65136 + if (proc->pax_flags & GR_PAX_ENABLE_EMUTRAMP)
65137 + flags |= MF_PAX_EMUTRAMP;
65138 + if (proc->pax_flags & GR_PAX_ENABLE_MPROTECT)
65139 + flags |= MF_PAX_MPROTECT;
65140 +
65141 + pax_set_flags(task, flags);
65142 +
65143 + return;
65144 +}
65145 +#endif
65146 +
65147 +int
65148 +gr_handle_proc_ptrace(struct task_struct *task)
65149 +{
65150 + struct file *filp;
65151 + struct task_struct *tmp = task;
65152 + struct task_struct *curtemp = current;
65153 + __u32 retmode;
65154 +
65155 +#ifndef CONFIG_GRKERNSEC_HARDEN_PTRACE
65156 + if (unlikely(!(gr_status & GR_READY)))
65157 + return 0;
65158 +#endif
65159 +
65160 + read_lock(&tasklist_lock);
65161 + read_lock(&grsec_exec_file_lock);
65162 + filp = task->exec_file;
65163 +
65164 + while (task_pid_nr(tmp) > 0) {
65165 + if (tmp == curtemp)
65166 + break;
65167 + tmp = tmp->real_parent;
65168 + }
65169 +
65170 + if (!filp || (task_pid_nr(tmp) == 0 && ((grsec_enable_harden_ptrace && gr_is_global_nonroot(current_uid()) && !(gr_status & GR_READY)) ||
65171 + ((gr_status & GR_READY) && !(current->acl->mode & GR_RELAXPTRACE))))) {
65172 + read_unlock(&grsec_exec_file_lock);
65173 + read_unlock(&tasklist_lock);
65174 + return 1;
65175 + }
65176 +
65177 +#ifdef CONFIG_GRKERNSEC_HARDEN_PTRACE
65178 + if (!(gr_status & GR_READY)) {
65179 + read_unlock(&grsec_exec_file_lock);
65180 + read_unlock(&tasklist_lock);
65181 + return 0;
65182 + }
65183 +#endif
65184 +
65185 + retmode = gr_search_file(filp->f_path.dentry, GR_NOPTRACE, filp->f_path.mnt);
65186 + read_unlock(&grsec_exec_file_lock);
65187 + read_unlock(&tasklist_lock);
65188 +
65189 + if (retmode & GR_NOPTRACE)
65190 + return 1;
65191 +
65192 + if (!(current->acl->mode & GR_POVERRIDE) && !(current->role->roletype & GR_ROLE_GOD)
65193 + && (current->acl != task->acl || (current->acl != current->role->root_label
65194 + && task_pid_nr(current) != task_pid_nr(task))))
65195 + return 1;
65196 +
65197 + return 0;
65198 +}
65199 +
65200 +void task_grsec_rbac(struct seq_file *m, struct task_struct *p)
65201 +{
65202 + if (unlikely(!(gr_status & GR_READY)))
65203 + return;
65204 +
65205 + if (!(current->role->roletype & GR_ROLE_GOD))
65206 + return;
65207 +
65208 + seq_printf(m, "RBAC:\t%.64s:%c:%.950s\n",
65209 + p->role->rolename, gr_task_roletype_to_char(p),
65210 + p->acl->filename);
65211 +}
65212 +
65213 +int
65214 +gr_handle_ptrace(struct task_struct *task, const long request)
65215 +{
65216 + struct task_struct *tmp = task;
65217 + struct task_struct *curtemp = current;
65218 + __u32 retmode;
65219 +
65220 +#ifndef CONFIG_GRKERNSEC_HARDEN_PTRACE
65221 + if (unlikely(!(gr_status & GR_READY)))
65222 + return 0;
65223 +#endif
65224 + if (request == PTRACE_ATTACH || request == PTRACE_SEIZE) {
65225 + read_lock(&tasklist_lock);
65226 + while (task_pid_nr(tmp) > 0) {
65227 + if (tmp == curtemp)
65228 + break;
65229 + tmp = tmp->real_parent;
65230 + }
65231 +
65232 + if (task_pid_nr(tmp) == 0 && ((grsec_enable_harden_ptrace && gr_is_global_nonroot(current_uid()) && !(gr_status & GR_READY)) ||
65233 + ((gr_status & GR_READY) && !(current->acl->mode & GR_RELAXPTRACE)))) {
65234 + read_unlock(&tasklist_lock);
65235 + gr_log_ptrace(GR_DONT_AUDIT, GR_PTRACE_ACL_MSG, task);
65236 + return 1;
65237 + }
65238 + read_unlock(&tasklist_lock);
65239 + }
65240 +
65241 +#ifdef CONFIG_GRKERNSEC_HARDEN_PTRACE
65242 + if (!(gr_status & GR_READY))
65243 + return 0;
65244 +#endif
65245 +
65246 + read_lock(&grsec_exec_file_lock);
65247 + if (unlikely(!task->exec_file)) {
65248 + read_unlock(&grsec_exec_file_lock);
65249 + return 0;
65250 + }
65251 +
65252 + retmode = gr_search_file(task->exec_file->f_path.dentry, GR_PTRACERD | GR_NOPTRACE, task->exec_file->f_path.mnt);
65253 + read_unlock(&grsec_exec_file_lock);
65254 +
65255 + if (retmode & GR_NOPTRACE) {
65256 + gr_log_ptrace(GR_DONT_AUDIT, GR_PTRACE_ACL_MSG, task);
65257 + return 1;
65258 + }
65259 +
65260 + if (retmode & GR_PTRACERD) {
65261 + switch (request) {
65262 + case PTRACE_SEIZE:
65263 + case PTRACE_POKETEXT:
65264 + case PTRACE_POKEDATA:
65265 + case PTRACE_POKEUSR:
65266 +#if !defined(CONFIG_PPC32) && !defined(CONFIG_PPC64) && !defined(CONFIG_PARISC) && !defined(CONFIG_ALPHA) && !defined(CONFIG_IA64)
65267 + case PTRACE_SETREGS:
65268 + case PTRACE_SETFPREGS:
65269 +#endif
65270 +#ifdef CONFIG_X86
65271 + case PTRACE_SETFPXREGS:
65272 +#endif
65273 +#ifdef CONFIG_ALTIVEC
65274 + case PTRACE_SETVRREGS:
65275 +#endif
65276 + return 1;
65277 + default:
65278 + return 0;
65279 + }
65280 + } else if (!(current->acl->mode & GR_POVERRIDE) &&
65281 + !(current->role->roletype & GR_ROLE_GOD) &&
65282 + (current->acl != task->acl)) {
65283 + gr_log_ptrace(GR_DONT_AUDIT, GR_PTRACE_ACL_MSG, task);
65284 + return 1;
65285 + }
65286 +
65287 + return 0;
65288 +}
65289 +
65290 +static int is_writable_mmap(const struct file *filp)
65291 +{
65292 + struct task_struct *task = current;
65293 + struct acl_object_label *obj, *obj2;
65294 +
65295 + if (gr_status & GR_READY && !(task->acl->mode & GR_OVERRIDE) &&
65296 + !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))) {
65297 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, running_polstate.default_role->root_label);
65298 + obj2 = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt,
65299 + task->role->root_label);
65300 + if (unlikely((obj->mode & GR_WRITE) || (obj2->mode & GR_WRITE))) {
65301 + gr_log_fs_generic(GR_DONT_AUDIT, GR_WRITLIB_ACL_MSG, filp->f_path.dentry, filp->f_path.mnt);
65302 + return 1;
65303 + }
65304 + }
65305 + return 0;
65306 +}
65307 +
65308 +int
65309 +gr_acl_handle_mmap(const struct file *file, const unsigned long prot)
65310 +{
65311 + __u32 mode;
65312 +
65313 + if (unlikely(!file || !(prot & PROT_EXEC)))
65314 + return 1;
65315 +
65316 + if (is_writable_mmap(file))
65317 + return 0;
65318 +
65319 + mode =
65320 + gr_search_file(file->f_path.dentry,
65321 + GR_EXEC | GR_AUDIT_EXEC | GR_SUPPRESS,
65322 + file->f_path.mnt);
65323 +
65324 + if (!gr_tpe_allow(file))
65325 + return 0;
65326 +
65327 + if (unlikely(!(mode & GR_EXEC) && !(mode & GR_SUPPRESS))) {
65328 + gr_log_fs_rbac_generic(GR_DONT_AUDIT, GR_MMAP_ACL_MSG, file->f_path.dentry, file->f_path.mnt);
65329 + return 0;
65330 + } else if (unlikely(!(mode & GR_EXEC))) {
65331 + return 0;
65332 + } else if (unlikely(mode & GR_EXEC && mode & GR_AUDIT_EXEC)) {
65333 + gr_log_fs_rbac_generic(GR_DO_AUDIT, GR_MMAP_ACL_MSG, file->f_path.dentry, file->f_path.mnt);
65334 + return 1;
65335 + }
65336 +
65337 + return 1;
65338 +}
65339 +
65340 +int
65341 +gr_acl_handle_mprotect(const struct file *file, const unsigned long prot)
65342 +{
65343 + __u32 mode;
65344 +
65345 + if (unlikely(!file || !(prot & PROT_EXEC)))
65346 + return 1;
65347 +
65348 + if (is_writable_mmap(file))
65349 + return 0;
65350 +
65351 + mode =
65352 + gr_search_file(file->f_path.dentry,
65353 + GR_EXEC | GR_AUDIT_EXEC | GR_SUPPRESS,
65354 + file->f_path.mnt);
65355 +
65356 + if (!gr_tpe_allow(file))
65357 + return 0;
65358 +
65359 + if (unlikely(!(mode & GR_EXEC) && !(mode & GR_SUPPRESS))) {
65360 + gr_log_fs_rbac_generic(GR_DONT_AUDIT, GR_MPROTECT_ACL_MSG, file->f_path.dentry, file->f_path.mnt);
65361 + return 0;
65362 + } else if (unlikely(!(mode & GR_EXEC))) {
65363 + return 0;
65364 + } else if (unlikely(mode & GR_EXEC && mode & GR_AUDIT_EXEC)) {
65365 + gr_log_fs_rbac_generic(GR_DO_AUDIT, GR_MPROTECT_ACL_MSG, file->f_path.dentry, file->f_path.mnt);
65366 + return 1;
65367 + }
65368 +
65369 + return 1;
65370 +}
65371 +
65372 +void
65373 +gr_acl_handle_psacct(struct task_struct *task, const long code)
65374 +{
65375 + unsigned long runtime;
65376 + unsigned long cputime;
65377 + unsigned int wday, cday;
65378 + __u8 whr, chr;
65379 + __u8 wmin, cmin;
65380 + __u8 wsec, csec;
65381 + struct timespec timeval;
65382 +
65383 + if (unlikely(!(gr_status & GR_READY) || !task->acl ||
65384 + !(task->acl->mode & GR_PROCACCT)))
65385 + return;
65386 +
65387 + do_posix_clock_monotonic_gettime(&timeval);
65388 + runtime = timeval.tv_sec - task->start_time.tv_sec;
65389 + wday = runtime / (3600 * 24);
65390 + runtime -= wday * (3600 * 24);
65391 + whr = runtime / 3600;
65392 + runtime -= whr * 3600;
65393 + wmin = runtime / 60;
65394 + runtime -= wmin * 60;
65395 + wsec = runtime;
65396 +
65397 + cputime = (task->utime + task->stime) / HZ;
65398 + cday = cputime / (3600 * 24);
65399 + cputime -= cday * (3600 * 24);
65400 + chr = cputime / 3600;
65401 + cputime -= chr * 3600;
65402 + cmin = cputime / 60;
65403 + cputime -= cmin * 60;
65404 + csec = cputime;
65405 +
65406 + gr_log_procacct(GR_DO_AUDIT, GR_ACL_PROCACCT_MSG, task, wday, whr, wmin, wsec, cday, chr, cmin, csec, code);
65407 +
65408 + return;
65409 +}
65410 +
65411 +#ifdef CONFIG_TASKSTATS
65412 +int gr_is_taskstats_denied(int pid)
65413 +{
65414 + struct task_struct *task;
65415 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
65416 + const struct cred *cred;
65417 +#endif
65418 + int ret = 0;
65419 +
65420 + /* restrict taskstats viewing to un-chrooted root users
65421 + who have the 'view' subject flag if the RBAC system is enabled
65422 + */
65423 +
65424 + rcu_read_lock();
65425 + read_lock(&tasklist_lock);
65426 + task = find_task_by_vpid(pid);
65427 + if (task) {
65428 +#ifdef CONFIG_GRKERNSEC_CHROOT
65429 + if (proc_is_chrooted(task))
65430 + ret = -EACCES;
65431 +#endif
65432 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
65433 + cred = __task_cred(task);
65434 +#ifdef CONFIG_GRKERNSEC_PROC_USER
65435 + if (gr_is_global_nonroot(cred->uid))
65436 + ret = -EACCES;
65437 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
65438 + if (gr_is_global_nonroot(cred->uid) && !groups_search(cred->group_info, grsec_proc_gid))
65439 + ret = -EACCES;
65440 +#endif
65441 +#endif
65442 + if (gr_status & GR_READY) {
65443 + if (!(task->acl->mode & GR_VIEW))
65444 + ret = -EACCES;
65445 + }
65446 + } else
65447 + ret = -ENOENT;
65448 +
65449 + read_unlock(&tasklist_lock);
65450 + rcu_read_unlock();
65451 +
65452 + return ret;
65453 +}
65454 +#endif
65455 +
65456 +/* AUXV entries are filled via a descendant of search_binary_handler
65457 + after we've already applied the subject for the target
65458 +*/
65459 +int gr_acl_enable_at_secure(void)
65460 +{
65461 + if (unlikely(!(gr_status & GR_READY)))
65462 + return 0;
65463 +
65464 + if (current->acl->mode & GR_ATSECURE)
65465 + return 1;
65466 +
65467 + return 0;
65468 +}
65469 +
65470 +int gr_acl_handle_filldir(const struct file *file, const char *name, const unsigned int namelen, const ino_t ino)
65471 +{
65472 + struct task_struct *task = current;
65473 + struct dentry *dentry = file->f_path.dentry;
65474 + struct vfsmount *mnt = file->f_path.mnt;
65475 + struct acl_object_label *obj, *tmp;
65476 + struct acl_subject_label *subj;
65477 + unsigned int bufsize;
65478 + int is_not_root;
65479 + char *path;
65480 + dev_t dev = __get_dev(dentry);
65481 +
65482 + if (unlikely(!(gr_status & GR_READY)))
65483 + return 1;
65484 +
65485 + if (task->acl->mode & (GR_LEARN | GR_INHERITLEARN))
65486 + return 1;
65487 +
65488 + /* ignore Eric Biederman */
65489 + if (IS_PRIVATE(dentry->d_inode))
65490 + return 1;
65491 +
65492 + subj = task->acl;
65493 + read_lock(&gr_inode_lock);
65494 + do {
65495 + obj = lookup_acl_obj_label(ino, dev, subj);
65496 + if (obj != NULL) {
65497 + read_unlock(&gr_inode_lock);
65498 + return (obj->mode & GR_FIND) ? 1 : 0;
65499 + }
65500 + } while ((subj = subj->parent_subject));
65501 + read_unlock(&gr_inode_lock);
65502 +
65503 + /* this is purely an optimization since we're looking for an object
65504 + for the directory we're doing a readdir on
65505 + if it's possible for any globbed object to match the entry we're
65506 + filling into the directory, then the object we find here will be
65507 + an anchor point with attached globbed objects
65508 + */
65509 + obj = chk_obj_label_noglob(dentry, mnt, task->acl);
65510 + if (obj->globbed == NULL)
65511 + return (obj->mode & GR_FIND) ? 1 : 0;
65512 +
65513 + is_not_root = ((obj->filename[0] == '/') &&
65514 + (obj->filename[1] == '\0')) ? 0 : 1;
65515 + bufsize = PAGE_SIZE - namelen - is_not_root;
65516 +
65517 + /* check bufsize > PAGE_SIZE || bufsize == 0 */
65518 + if (unlikely((bufsize - 1) > (PAGE_SIZE - 1)))
65519 + return 1;
65520 +
65521 + preempt_disable();
65522 + path = d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[0], smp_processor_id()),
65523 + bufsize);
65524 +
65525 + bufsize = strlen(path);
65526 +
65527 + /* if base is "/", don't append an additional slash */
65528 + if (is_not_root)
65529 + *(path + bufsize) = '/';
65530 + memcpy(path + bufsize + is_not_root, name, namelen);
65531 + *(path + bufsize + namelen + is_not_root) = '\0';
65532 +
65533 + tmp = obj->globbed;
65534 + while (tmp) {
65535 + if (!glob_match(tmp->filename, path)) {
65536 + preempt_enable();
65537 + return (tmp->mode & GR_FIND) ? 1 : 0;
65538 + }
65539 + tmp = tmp->next;
65540 + }
65541 + preempt_enable();
65542 + return (obj->mode & GR_FIND) ? 1 : 0;
65543 +}
65544 +
65545 +void gr_put_exec_file(struct task_struct *task)
65546 +{
65547 + struct file *filp;
65548 +
65549 + write_lock(&grsec_exec_file_lock);
65550 + filp = task->exec_file;
65551 + task->exec_file = NULL;
65552 + write_unlock(&grsec_exec_file_lock);
65553 +
65554 + if (filp)
65555 + fput(filp);
65556 +
65557 + return;
65558 +}
65559 +
65560 +
65561 +#ifdef CONFIG_NETFILTER_XT_MATCH_GRADM_MODULE
65562 +EXPORT_SYMBOL(gr_acl_is_enabled);
65563 +#endif
65564 +#ifdef CONFIG_SECURITY
65565 +EXPORT_SYMBOL(gr_check_user_change);
65566 +EXPORT_SYMBOL(gr_check_group_change);
65567 +#endif
65568 +
65569 diff --git a/grsecurity/gracl_alloc.c b/grsecurity/gracl_alloc.c
65570 new file mode 100644
65571 index 0000000..18ffbbd
65572 --- /dev/null
65573 +++ b/grsecurity/gracl_alloc.c
65574 @@ -0,0 +1,105 @@
65575 +#include <linux/kernel.h>
65576 +#include <linux/mm.h>
65577 +#include <linux/slab.h>
65578 +#include <linux/vmalloc.h>
65579 +#include <linux/gracl.h>
65580 +#include <linux/grsecurity.h>
65581 +
65582 +static struct gr_alloc_state __current_alloc_state = { 1, 1, NULL };
65583 +struct gr_alloc_state *current_alloc_state = &__current_alloc_state;
65584 +
65585 +static __inline__ int
65586 +alloc_pop(void)
65587 +{
65588 + if (current_alloc_state->alloc_stack_next == 1)
65589 + return 0;
65590 +
65591 + kfree(current_alloc_state->alloc_stack[current_alloc_state->alloc_stack_next - 2]);
65592 +
65593 + current_alloc_state->alloc_stack_next--;
65594 +
65595 + return 1;
65596 +}
65597 +
65598 +static __inline__ int
65599 +alloc_push(void *buf)
65600 +{
65601 + if (current_alloc_state->alloc_stack_next >= current_alloc_state->alloc_stack_size)
65602 + return 1;
65603 +
65604 + current_alloc_state->alloc_stack[current_alloc_state->alloc_stack_next - 1] = buf;
65605 +
65606 + current_alloc_state->alloc_stack_next++;
65607 +
65608 + return 0;
65609 +}
65610 +
65611 +void *
65612 +acl_alloc(unsigned long len)
65613 +{
65614 + void *ret = NULL;
65615 +
65616 + if (!len || len > PAGE_SIZE)
65617 + goto out;
65618 +
65619 + ret = kmalloc(len, GFP_KERNEL);
65620 +
65621 + if (ret) {
65622 + if (alloc_push(ret)) {
65623 + kfree(ret);
65624 + ret = NULL;
65625 + }
65626 + }
65627 +
65628 +out:
65629 + return ret;
65630 +}
65631 +
65632 +void *
65633 +acl_alloc_num(unsigned long num, unsigned long len)
65634 +{
65635 + if (!len || (num > (PAGE_SIZE / len)))
65636 + return NULL;
65637 +
65638 + return acl_alloc(num * len);
65639 +}
65640 +
65641 +void
65642 +acl_free_all(void)
65643 +{
65644 + if (!current_alloc_state->alloc_stack)
65645 + return;
65646 +
65647 + while (alloc_pop()) ;
65648 +
65649 + if (current_alloc_state->alloc_stack) {
65650 + if ((current_alloc_state->alloc_stack_size * sizeof (void *)) <= PAGE_SIZE)
65651 + kfree(current_alloc_state->alloc_stack);
65652 + else
65653 + vfree(current_alloc_state->alloc_stack);
65654 + }
65655 +
65656 + current_alloc_state->alloc_stack = NULL;
65657 + current_alloc_state->alloc_stack_size = 1;
65658 + current_alloc_state->alloc_stack_next = 1;
65659 +
65660 + return;
65661 +}
65662 +
65663 +int
65664 +acl_alloc_stack_init(unsigned long size)
65665 +{
65666 + if ((size * sizeof (void *)) <= PAGE_SIZE)
65667 + current_alloc_state->alloc_stack =
65668 + (void **) kmalloc(size * sizeof (void *), GFP_KERNEL);
65669 + else
65670 + current_alloc_state->alloc_stack = (void **) vmalloc(size * sizeof (void *));
65671 +
65672 + current_alloc_state->alloc_stack_size = size;
65673 + current_alloc_state->alloc_stack_next = 1;
65674 +
65675 + if (!current_alloc_state->alloc_stack)
65676 + return 0;
65677 + else
65678 + return 1;
65679 +}
65680 diff --git a/grsecurity/gracl_cap.c b/grsecurity/gracl_cap.c
65681 new file mode 100644
65682 index 0000000..bdd51ea
65683 --- /dev/null
65684 +++ b/grsecurity/gracl_cap.c
65685 @@ -0,0 +1,110 @@
65686 +#include <linux/kernel.h>
65687 +#include <linux/module.h>
65688 +#include <linux/sched.h>
65689 +#include <linux/gracl.h>
65690 +#include <linux/grsecurity.h>
65691 +#include <linux/grinternal.h>
65692 +
65693 +extern const char *captab_log[];
65694 +extern int captab_log_entries;
65695 +
65696 +int gr_task_acl_is_capable(const struct task_struct *task, const struct cred *cred, const int cap)
65697 +{
65698 + struct acl_subject_label *curracl;
65699 + kernel_cap_t cap_drop = __cap_empty_set, cap_mask = __cap_empty_set;
65700 + kernel_cap_t cap_audit = __cap_empty_set;
65701 +
65702 + if (!gr_acl_is_enabled())
65703 + return 1;
65704 +
65705 + curracl = task->acl;
65706 +
65707 + cap_drop = curracl->cap_lower;
65708 + cap_mask = curracl->cap_mask;
65709 + cap_audit = curracl->cap_invert_audit;
65710 +
65711 + while ((curracl = curracl->parent_subject)) {
65712 + /* if the cap isn't specified in the current computed mask but is specified in the
65713 + current level subject, and is lowered in the current level subject, then add
65714 + it to the set of dropped capabilities
65715 + otherwise, add the current level subject's mask to the current computed mask
65716 + */
65717 + if (!cap_raised(cap_mask, cap) && cap_raised(curracl->cap_mask, cap)) {
65718 + cap_raise(cap_mask, cap);
65719 + if (cap_raised(curracl->cap_lower, cap))
65720 + cap_raise(cap_drop, cap);
65721 + if (cap_raised(curracl->cap_invert_audit, cap))
65722 + cap_raise(cap_audit, cap);
65723 + }
65724 + }
65725 +
65726 + if (!cap_raised(cap_drop, cap)) {
65727 + if (cap_raised(cap_audit, cap))
65728 + gr_log_cap(GR_DO_AUDIT, GR_CAP_ACL_MSG2, task, captab_log[cap]);
65729 + return 1;
65730 + }
65731 +
65732 + curracl = task->acl;
65733 +
65734 + if ((curracl->mode & (GR_LEARN | GR_INHERITLEARN))
65735 + && cap_raised(cred->cap_effective, cap)) {
65736 + security_learn(GR_LEARN_AUDIT_MSG, task->role->rolename,
65737 + task->role->roletype, GR_GLOBAL_UID(cred->uid),
65738 + GR_GLOBAL_GID(cred->gid), task->exec_file ?
65739 + gr_to_filename(task->exec_file->f_path.dentry,
65740 + task->exec_file->f_path.mnt) : curracl->filename,
65741 + curracl->filename, 0UL,
65742 + 0UL, "", (unsigned long) cap, &task->signal->saved_ip);
65743 + return 1;
65744 + }
65745 +
65746 + if ((cap >= 0) && (cap < captab_log_entries) && cap_raised(cred->cap_effective, cap) && !cap_raised(cap_audit, cap))
65747 + gr_log_cap(GR_DONT_AUDIT, GR_CAP_ACL_MSG, task, captab_log[cap]);
65748 +
65749 + return 0;
65750 +}
65751 +
65752 +int
65753 +gr_acl_is_capable(const int cap)
65754 +{
65755 + return gr_task_acl_is_capable(current, current_cred(), cap);
65756 +}
65757 +
65758 +int gr_task_acl_is_capable_nolog(const struct task_struct *task, const int cap)
65759 +{
65760 + struct acl_subject_label *curracl;
65761 + kernel_cap_t cap_drop = __cap_empty_set, cap_mask = __cap_empty_set;
65762 +
65763 + if (!gr_acl_is_enabled())
65764 + return 1;
65765 +
65766 + curracl = task->acl;
65767 +
65768 + cap_drop = curracl->cap_lower;
65769 + cap_mask = curracl->cap_mask;
65770 +
65771 + while ((curracl = curracl->parent_subject)) {
65772 + /* if the cap isn't specified in the current computed mask but is specified in the
65773 + current level subject, and is lowered in the current level subject, then add
65774 + it to the set of dropped capabilities
65775 + otherwise, add the current level subject's mask to the current computed mask
65776 + */
65777 + if (!cap_raised(cap_mask, cap) && cap_raised(curracl->cap_mask, cap)) {
65778 + cap_raise(cap_mask, cap);
65779 + if (cap_raised(curracl->cap_lower, cap))
65780 + cap_raise(cap_drop, cap);
65781 + }
65782 + }
65783 +
65784 + if (!cap_raised(cap_drop, cap))
65785 + return 1;
65786 +
65787 + return 0;
65788 +}
65789 +
65790 +int
65791 +gr_acl_is_capable_nolog(const int cap)
65792 +{
65793 + return gr_task_acl_is_capable_nolog(current, cap);
65794 +}
65795 +
65796 diff --git a/grsecurity/gracl_compat.c b/grsecurity/gracl_compat.c
65797 new file mode 100644
65798 index 0000000..ca25605
65799 --- /dev/null
65800 +++ b/grsecurity/gracl_compat.c
65801 @@ -0,0 +1,270 @@
65802 +#include <linux/kernel.h>
65803 +#include <linux/gracl.h>
65804 +#include <linux/compat.h>
65805 +#include <linux/gracl_compat.h>
65806 +
65807 +#include <asm/uaccess.h>
65808 +
65809 +int copy_gr_arg_wrapper_compat(const char *buf, struct gr_arg_wrapper *uwrap)
65810 +{
65811 + struct gr_arg_wrapper_compat uwrapcompat;
65812 +
65813 + if (copy_from_user(&uwrapcompat, buf, sizeof(uwrapcompat)))
65814 + return -EFAULT;
65815 +
65816 + if (((uwrapcompat.version != GRSECURITY_VERSION) &&
65817 + (uwrapcompat.version != 0x2901)) ||
65818 + (uwrapcompat.size != sizeof(struct gr_arg_compat)))
65819 + return -EINVAL;
65820 +
65821 + uwrap->arg = compat_ptr(uwrapcompat.arg);
65822 + uwrap->version = uwrapcompat.version;
65823 + uwrap->size = sizeof(struct gr_arg);
65824 +
65825 + return 0;
65826 +}
65827 +
65828 +int copy_gr_arg_compat(const struct gr_arg __user *buf, struct gr_arg *arg)
65829 +{
65830 + struct gr_arg_compat argcompat;
65831 +
65832 + if (copy_from_user(&argcompat, buf, sizeof(argcompat)))
65833 + return -EFAULT;
65834 +
65835 + arg->role_db.r_table = compat_ptr(argcompat.role_db.r_table);
65836 + arg->role_db.num_pointers = argcompat.role_db.num_pointers;
65837 + arg->role_db.num_roles = argcompat.role_db.num_roles;
65838 + arg->role_db.num_domain_children = argcompat.role_db.num_domain_children;
65839 + arg->role_db.num_subjects = argcompat.role_db.num_subjects;
65840 + arg->role_db.num_objects = argcompat.role_db.num_objects;
65841 +
65842 + memcpy(&arg->pw, &argcompat.pw, sizeof(arg->pw));
65843 + memcpy(&arg->salt, &argcompat.salt, sizeof(arg->salt));
65844 + memcpy(&arg->sum, &argcompat.sum, sizeof(arg->sum));
65845 + memcpy(&arg->sp_role, &argcompat.sp_role, sizeof(arg->sp_role));
65846 + arg->sprole_pws = compat_ptr(argcompat.sprole_pws);
65847 + arg->segv_device = argcompat.segv_device;
65848 + arg->segv_inode = argcompat.segv_inode;
65849 + arg->segv_uid = argcompat.segv_uid;
65850 + arg->num_sprole_pws = argcompat.num_sprole_pws;
65851 + arg->mode = argcompat.mode;
65852 +
65853 + return 0;
65854 +}
65855 +
65856 +int copy_acl_object_label_compat(struct acl_object_label *obj, const struct acl_object_label *userp)
65857 +{
65858 + struct acl_object_label_compat objcompat;
65859 +
65860 + if (copy_from_user(&objcompat, userp, sizeof(objcompat)))
65861 + return -EFAULT;
65862 +
65863 + obj->filename = compat_ptr(objcompat.filename);
65864 + obj->inode = objcompat.inode;
65865 + obj->device = objcompat.device;
65866 + obj->mode = objcompat.mode;
65867 +
65868 + obj->nested = compat_ptr(objcompat.nested);
65869 + obj->globbed = compat_ptr(objcompat.globbed);
65870 +
65871 + obj->prev = compat_ptr(objcompat.prev);
65872 + obj->next = compat_ptr(objcompat.next);
65873 +
65874 + return 0;
65875 +}
65876 +
65877 +int copy_acl_subject_label_compat(struct acl_subject_label *subj, const struct acl_subject_label *userp)
65878 +{
65879 + unsigned int i;
65880 + struct acl_subject_label_compat subjcompat;
65881 +
65882 + if (copy_from_user(&subjcompat, userp, sizeof(subjcompat)))
65883 + return -EFAULT;
65884 +
65885 + subj->filename = compat_ptr(subjcompat.filename);
65886 + subj->inode = subjcompat.inode;
65887 + subj->device = subjcompat.device;
65888 + subj->mode = subjcompat.mode;
65889 + subj->cap_mask = subjcompat.cap_mask;
65890 + subj->cap_lower = subjcompat.cap_lower;
65891 + subj->cap_invert_audit = subjcompat.cap_invert_audit;
65892 +
65893 + for (i = 0; i < GR_NLIMITS; i++) {
65894 + if (subjcompat.res[i].rlim_cur == COMPAT_RLIM_INFINITY)
65895 + subj->res[i].rlim_cur = RLIM_INFINITY;
65896 + else
65897 + subj->res[i].rlim_cur = subjcompat.res[i].rlim_cur;
65898 + if (subjcompat.res[i].rlim_max == COMPAT_RLIM_INFINITY)
65899 + subj->res[i].rlim_max = RLIM_INFINITY;
65900 + else
65901 + subj->res[i].rlim_max = subjcompat.res[i].rlim_max;
65902 + }
65903 + subj->resmask = subjcompat.resmask;
65904 +
65905 + subj->user_trans_type = subjcompat.user_trans_type;
65906 + subj->group_trans_type = subjcompat.group_trans_type;
65907 + subj->user_transitions = compat_ptr(subjcompat.user_transitions);
65908 + subj->group_transitions = compat_ptr(subjcompat.group_transitions);
65909 + subj->user_trans_num = subjcompat.user_trans_num;
65910 + subj->group_trans_num = subjcompat.group_trans_num;
65911 +
65912 + memcpy(&subj->sock_families, &subjcompat.sock_families, sizeof(subj->sock_families));
65913 + memcpy(&subj->ip_proto, &subjcompat.ip_proto, sizeof(subj->ip_proto));
65914 + subj->ip_type = subjcompat.ip_type;
65915 + subj->ips = compat_ptr(subjcompat.ips);
65916 + subj->ip_num = subjcompat.ip_num;
65917 + subj->inaddr_any_override = subjcompat.inaddr_any_override;
65918 +
65919 + subj->crashes = subjcompat.crashes;
65920 + subj->expires = subjcompat.expires;
65921 +
65922 + subj->parent_subject = compat_ptr(subjcompat.parent_subject);
65923 + subj->hash = compat_ptr(subjcompat.hash);
65924 + subj->prev = compat_ptr(subjcompat.prev);
65925 + subj->next = compat_ptr(subjcompat.next);
65926 +
65927 + subj->obj_hash = compat_ptr(subjcompat.obj_hash);
65928 + subj->obj_hash_size = subjcompat.obj_hash_size;
65929 + subj->pax_flags = subjcompat.pax_flags;
65930 +
65931 + return 0;
65932 +}
65933 +
65934 +int copy_acl_role_label_compat(struct acl_role_label *role, const struct acl_role_label *userp)
65935 +{
65936 + struct acl_role_label_compat rolecompat;
65937 +
65938 + if (copy_from_user(&rolecompat, userp, sizeof(rolecompat)))
65939 + return -EFAULT;
65940 +
65941 + role->rolename = compat_ptr(rolecompat.rolename);
65942 + role->uidgid = rolecompat.uidgid;
65943 + role->roletype = rolecompat.roletype;
65944 +
65945 + role->auth_attempts = rolecompat.auth_attempts;
65946 + role->expires = rolecompat.expires;
65947 +
65948 + role->root_label = compat_ptr(rolecompat.root_label);
65949 + role->hash = compat_ptr(rolecompat.hash);
65950 +
65951 + role->prev = compat_ptr(rolecompat.prev);
65952 + role->next = compat_ptr(rolecompat.next);
65953 +
65954 + role->transitions = compat_ptr(rolecompat.transitions);
65955 + role->allowed_ips = compat_ptr(rolecompat.allowed_ips);
65956 + role->domain_children = compat_ptr(rolecompat.domain_children);
65957 + role->domain_child_num = rolecompat.domain_child_num;
65958 +
65959 + role->umask = rolecompat.umask;
65960 +
65961 + role->subj_hash = compat_ptr(rolecompat.subj_hash);
65962 + role->subj_hash_size = rolecompat.subj_hash_size;
65963 +
65964 + return 0;
65965 +}
65966 +
65967 +int copy_role_allowed_ip_compat(struct role_allowed_ip *roleip, const struct role_allowed_ip *userp)
65968 +{
65969 + struct role_allowed_ip_compat roleip_compat;
65970 +
65971 + if (copy_from_user(&roleip_compat, userp, sizeof(roleip_compat)))
65972 + return -EFAULT;
65973 +
65974 + roleip->addr = roleip_compat.addr;
65975 + roleip->netmask = roleip_compat.netmask;
65976 +
65977 + roleip->prev = compat_ptr(roleip_compat.prev);
65978 + roleip->next = compat_ptr(roleip_compat.next);
65979 +
65980 + return 0;
65981 +}
65982 +
65983 +int copy_role_transition_compat(struct role_transition *trans, const struct role_transition *userp)
65984 +{
65985 + struct role_transition_compat trans_compat;
65986 +
65987 + if (copy_from_user(&trans_compat, userp, sizeof(trans_compat)))
65988 + return -EFAULT;
65989 +
65990 + trans->rolename = compat_ptr(trans_compat.rolename);
65991 +
65992 + trans->prev = compat_ptr(trans_compat.prev);
65993 + trans->next = compat_ptr(trans_compat.next);
65994 +
65995 + return 0;
65996 +
65997 +}
65998 +
65999 +int copy_gr_hash_struct_compat(struct gr_hash_struct *hash, const struct gr_hash_struct *userp)
66000 +{
66001 + struct gr_hash_struct_compat hash_compat;
66002 +
66003 + if (copy_from_user(&hash_compat, userp, sizeof(hash_compat)))
66004 + return -EFAULT;
66005 +
66006 + hash->table = compat_ptr(hash_compat.table);
66007 + hash->nametable = compat_ptr(hash_compat.nametable);
66008 + hash->first = compat_ptr(hash_compat.first);
66009 +
66010 + hash->table_size = hash_compat.table_size;
66011 + hash->used_size = hash_compat.used_size;
66012 +
66013 + hash->type = hash_compat.type;
66014 +
66015 + return 0;
66016 +}
66017 +
66018 +int copy_pointer_from_array_compat(void *ptr, unsigned long idx, const void *userp)
66019 +{
66020 + compat_uptr_t ptrcompat;
66021 +
66022 + if (copy_from_user(&ptrcompat, userp + (idx * sizeof(ptrcompat)), sizeof(ptrcompat)))
66023 + return -EFAULT;
66024 +
66025 + *(void **)ptr = compat_ptr(ptrcompat);
66026 +
66027 + return 0;
66028 +}
66029 +
66030 +int copy_acl_ip_label_compat(struct acl_ip_label *ip, const struct acl_ip_label *userp)
66031 +{
66032 + struct acl_ip_label_compat ip_compat;
66033 +
66034 + if (copy_from_user(&ip_compat, userp, sizeof(ip_compat)))
66035 + return -EFAULT;
66036 +
66037 + ip->iface = compat_ptr(ip_compat.iface);
66038 + ip->addr = ip_compat.addr;
66039 + ip->netmask = ip_compat.netmask;
66040 + ip->low = ip_compat.low;
66041 + ip->high = ip_compat.high;
66042 + ip->mode = ip_compat.mode;
66043 + ip->type = ip_compat.type;
66044 +
66045 + memcpy(&ip->proto, &ip_compat.proto, sizeof(ip->proto));
66046 +
66047 + ip->prev = compat_ptr(ip_compat.prev);
66048 + ip->next = compat_ptr(ip_compat.next);
66049 +
66050 + return 0;
66051 +}
66052 +
66053 +int copy_sprole_pw_compat(struct sprole_pw *pw, unsigned long idx, const struct sprole_pw *userp)
66054 +{
66055 + struct sprole_pw_compat pw_compat;
66056 +
66057 + if (copy_from_user(&pw_compat, (const void *)userp + (sizeof(pw_compat) * idx), sizeof(pw_compat)))
66058 + return -EFAULT;
66059 +
66060 + pw->rolename = compat_ptr(pw_compat.rolename);
66061 + memcpy(&pw->salt, pw_compat.salt, sizeof(pw->salt));
66062 + memcpy(&pw->sum, pw_compat.sum, sizeof(pw->sum));
66063 +
66064 + return 0;
66065 +}
66066 +
66067 +size_t get_gr_arg_wrapper_size_compat(void)
66068 +{
66069 + return sizeof(struct gr_arg_wrapper_compat);
66070 +}
66071 +
66072 diff --git a/grsecurity/gracl_fs.c b/grsecurity/gracl_fs.c
66073 new file mode 100644
66074 index 0000000..a340c17
66075 --- /dev/null
66076 +++ b/grsecurity/gracl_fs.c
66077 @@ -0,0 +1,431 @@
66078 +#include <linux/kernel.h>
66079 +#include <linux/sched.h>
66080 +#include <linux/types.h>
66081 +#include <linux/fs.h>
66082 +#include <linux/file.h>
66083 +#include <linux/stat.h>
66084 +#include <linux/grsecurity.h>
66085 +#include <linux/grinternal.h>
66086 +#include <linux/gracl.h>
66087 +
66088 +umode_t
66089 +gr_acl_umask(void)
66090 +{
66091 + if (unlikely(!gr_acl_is_enabled()))
66092 + return 0;
66093 +
66094 + return current->role->umask;
66095 +}
66096 +
66097 +__u32
66098 +gr_acl_handle_hidden_file(const struct dentry * dentry,
66099 + const struct vfsmount * mnt)
66100 +{
66101 + __u32 mode;
66102 +
66103 + if (unlikely(!dentry->d_inode))
66104 + return GR_FIND;
66105 +
66106 + mode =
66107 + gr_search_file(dentry, GR_FIND | GR_AUDIT_FIND | GR_SUPPRESS, mnt);
66108 +
66109 + if (unlikely(mode & GR_FIND && mode & GR_AUDIT_FIND)) {
66110 + gr_log_fs_rbac_generic(GR_DO_AUDIT, GR_HIDDEN_ACL_MSG, dentry, mnt);
66111 + return mode;
66112 + } else if (unlikely(!(mode & GR_FIND) && !(mode & GR_SUPPRESS))) {
66113 + gr_log_fs_rbac_generic(GR_DONT_AUDIT, GR_HIDDEN_ACL_MSG, dentry, mnt);
66114 + return 0;
66115 + } else if (unlikely(!(mode & GR_FIND)))
66116 + return 0;
66117 +
66118 + return GR_FIND;
66119 +}
66120 +
66121 +__u32
66122 +gr_acl_handle_open(const struct dentry * dentry, const struct vfsmount * mnt,
66123 + int acc_mode)
66124 +{
66125 + __u32 reqmode = GR_FIND;
66126 + __u32 mode;
66127 +
66128 + if (unlikely(!dentry->d_inode))
66129 + return reqmode;
66130 +
66131 + if (acc_mode & MAY_APPEND)
66132 + reqmode |= GR_APPEND;
66133 + else if (acc_mode & MAY_WRITE)
66134 + reqmode |= GR_WRITE;
66135 + if ((acc_mode & MAY_READ) && !S_ISDIR(dentry->d_inode->i_mode))
66136 + reqmode |= GR_READ;
66137 +
66138 + mode =
66139 + gr_search_file(dentry, reqmode | to_gr_audit(reqmode) | GR_SUPPRESS,
66140 + mnt);
66141 +
66142 + if (unlikely(((mode & reqmode) == reqmode) && mode & GR_AUDITS)) {
66143 + gr_log_fs_rbac_mode2(GR_DO_AUDIT, GR_OPEN_ACL_MSG, dentry, mnt,
66144 + reqmode & GR_READ ? " reading" : "",
66145 + reqmode & GR_WRITE ? " writing" : reqmode &
66146 + GR_APPEND ? " appending" : "");
66147 + return reqmode;
66148 + } else
66149 + if (unlikely((mode & reqmode) != reqmode && !(mode & GR_SUPPRESS)))
66150 + {
66151 + gr_log_fs_rbac_mode2(GR_DONT_AUDIT, GR_OPEN_ACL_MSG, dentry, mnt,
66152 + reqmode & GR_READ ? " reading" : "",
66153 + reqmode & GR_WRITE ? " writing" : reqmode &
66154 + GR_APPEND ? " appending" : "");
66155 + return 0;
66156 + } else if (unlikely((mode & reqmode) != reqmode))
66157 + return 0;
66158 +
66159 + return reqmode;
66160 +}
66161 +
66162 +__u32
66163 +gr_acl_handle_creat(const struct dentry * dentry,
66164 + const struct dentry * p_dentry,
66165 + const struct vfsmount * p_mnt, int open_flags, int acc_mode,
66166 + const int imode)
66167 +{
66168 + __u32 reqmode = GR_WRITE | GR_CREATE;
66169 + __u32 mode;
66170 +
66171 + if (acc_mode & MAY_APPEND)
66172 + reqmode |= GR_APPEND;
66173 + // if a directory was required or the directory already exists, then
66174 + // don't count this open as a read
66175 + if ((acc_mode & MAY_READ) &&
66176 + !((open_flags & O_DIRECTORY) || (dentry->d_inode && S_ISDIR(dentry->d_inode->i_mode))))
66177 + reqmode |= GR_READ;
66178 + if ((open_flags & O_CREAT) &&
66179 + ((imode & S_ISUID) || ((imode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP))))
66180 + reqmode |= GR_SETID;
66181 +
66182 + mode =
66183 + gr_check_create(dentry, p_dentry, p_mnt,
66184 + reqmode | to_gr_audit(reqmode) | GR_SUPPRESS);
66185 +
66186 + if (unlikely(((mode & reqmode) == reqmode) && mode & GR_AUDITS)) {
66187 + gr_log_fs_rbac_mode2(GR_DO_AUDIT, GR_CREATE_ACL_MSG, dentry, p_mnt,
66188 + reqmode & GR_READ ? " reading" : "",
66189 + reqmode & GR_WRITE ? " writing" : reqmode &
66190 + GR_APPEND ? " appending" : "");
66191 + return reqmode;
66192 + } else
66193 + if (unlikely((mode & reqmode) != reqmode && !(mode & GR_SUPPRESS)))
66194 + {
66195 + gr_log_fs_rbac_mode2(GR_DONT_AUDIT, GR_CREATE_ACL_MSG, dentry, p_mnt,
66196 + reqmode & GR_READ ? " reading" : "",
66197 + reqmode & GR_WRITE ? " writing" : reqmode &
66198 + GR_APPEND ? " appending" : "");
66199 + return 0;
66200 + } else if (unlikely((mode & reqmode) != reqmode))
66201 + return 0;
66202 +
66203 + return reqmode;
66204 +}
66205 +
66206 +__u32
66207 +gr_acl_handle_access(const struct dentry * dentry, const struct vfsmount * mnt,
66208 + const int fmode)
66209 +{
66210 + __u32 mode, reqmode = GR_FIND;
66211 +
66212 + if ((fmode & S_IXOTH) && !S_ISDIR(dentry->d_inode->i_mode))
66213 + reqmode |= GR_EXEC;
66214 + if (fmode & S_IWOTH)
66215 + reqmode |= GR_WRITE;
66216 + if (fmode & S_IROTH)
66217 + reqmode |= GR_READ;
66218 +
66219 + mode =
66220 + gr_search_file(dentry, reqmode | to_gr_audit(reqmode) | GR_SUPPRESS,
66221 + mnt);
66222 +
66223 + if (unlikely(((mode & reqmode) == reqmode) && mode & GR_AUDITS)) {
66224 + gr_log_fs_rbac_mode3(GR_DO_AUDIT, GR_ACCESS_ACL_MSG, dentry, mnt,
66225 + reqmode & GR_READ ? " reading" : "",
66226 + reqmode & GR_WRITE ? " writing" : "",
66227 + reqmode & GR_EXEC ? " executing" : "");
66228 + return reqmode;
66229 + } else
66230 + if (unlikely((mode & reqmode) != reqmode && !(mode & GR_SUPPRESS)))
66231 + {
66232 + gr_log_fs_rbac_mode3(GR_DONT_AUDIT, GR_ACCESS_ACL_MSG, dentry, mnt,
66233 + reqmode & GR_READ ? " reading" : "",
66234 + reqmode & GR_WRITE ? " writing" : "",
66235 + reqmode & GR_EXEC ? " executing" : "");
66236 + return 0;
66237 + } else if (unlikely((mode & reqmode) != reqmode))
66238 + return 0;
66239 +
66240 + return reqmode;
66241 +}
66242 +
66243 +static __u32 generic_fs_handler(const struct dentry *dentry, const struct vfsmount *mnt, __u32 reqmode, const char *fmt)
66244 +{
66245 + __u32 mode;
66246 +
66247 + mode = gr_search_file(dentry, reqmode | to_gr_audit(reqmode) | GR_SUPPRESS, mnt);
66248 +
66249 + if (unlikely(((mode & (reqmode)) == (reqmode)) && mode & GR_AUDITS)) {
66250 + gr_log_fs_rbac_generic(GR_DO_AUDIT, fmt, dentry, mnt);
66251 + return mode;
66252 + } else if (unlikely((mode & (reqmode)) != (reqmode) && !(mode & GR_SUPPRESS))) {
66253 + gr_log_fs_rbac_generic(GR_DONT_AUDIT, fmt, dentry, mnt);
66254 + return 0;
66255 + } else if (unlikely((mode & (reqmode)) != (reqmode)))
66256 + return 0;
66257 +
66258 + return (reqmode);
66259 +}
66260 +
66261 +__u32
66262 +gr_acl_handle_rmdir(const struct dentry * dentry, const struct vfsmount * mnt)
66263 +{
66264 + return generic_fs_handler(dentry, mnt, GR_WRITE | GR_DELETE , GR_RMDIR_ACL_MSG);
66265 +}
66266 +
66267 +__u32
66268 +gr_acl_handle_unlink(const struct dentry *dentry, const struct vfsmount *mnt)
66269 +{
66270 + return generic_fs_handler(dentry, mnt, GR_WRITE | GR_DELETE , GR_UNLINK_ACL_MSG);
66271 +}
66272 +
66273 +__u32
66274 +gr_acl_handle_truncate(const struct dentry *dentry, const struct vfsmount *mnt)
66275 +{
66276 + return generic_fs_handler(dentry, mnt, GR_WRITE, GR_TRUNCATE_ACL_MSG);
66277 +}
66278 +
66279 +__u32
66280 +gr_acl_handle_utime(const struct dentry *dentry, const struct vfsmount *mnt)
66281 +{
66282 + return generic_fs_handler(dentry, mnt, GR_WRITE, GR_ATIME_ACL_MSG);
66283 +}
66284 +
66285 +__u32
66286 +gr_acl_handle_chmod(const struct dentry *dentry, const struct vfsmount *mnt,
66287 + umode_t *modeptr)
66288 +{
66289 + umode_t mode;
66290 +
66291 + *modeptr &= ~gr_acl_umask();
66292 + mode = *modeptr;
66293 +
66294 + if (unlikely(dentry->d_inode && S_ISSOCK(dentry->d_inode->i_mode)))
66295 + return 1;
66296 +
66297 + if (unlikely(dentry->d_inode && !S_ISDIR(dentry->d_inode->i_mode) &&
66298 + ((mode & S_ISUID) || ((mode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP))))) {
66299 + return generic_fs_handler(dentry, mnt, GR_WRITE | GR_SETID,
66300 + GR_CHMOD_ACL_MSG);
66301 + } else {
66302 + return generic_fs_handler(dentry, mnt, GR_WRITE, GR_CHMOD_ACL_MSG);
66303 + }
66304 +}
66305 +
66306 +__u32
66307 +gr_acl_handle_chown(const struct dentry *dentry, const struct vfsmount *mnt)
66308 +{
66309 + return generic_fs_handler(dentry, mnt, GR_WRITE, GR_CHOWN_ACL_MSG);
66310 +}
66311 +
66312 +__u32
66313 +gr_acl_handle_setxattr(const struct dentry *dentry, const struct vfsmount *mnt)
66314 +{
66315 + return generic_fs_handler(dentry, mnt, GR_WRITE, GR_SETXATTR_ACL_MSG);
66316 +}
66317 +
66318 +__u32
66319 +gr_acl_handle_execve(const struct dentry *dentry, const struct vfsmount *mnt)
66320 +{
66321 + return generic_fs_handler(dentry, mnt, GR_EXEC, GR_EXEC_ACL_MSG);
66322 +}
66323 +
66324 +__u32
66325 +gr_acl_handle_unix(const struct dentry *dentry, const struct vfsmount *mnt)
66326 +{
66327 + return generic_fs_handler(dentry, mnt, GR_READ | GR_WRITE,
66328 + GR_UNIXCONNECT_ACL_MSG);
66329 +}
66330 +
66331 +/* hardlinks require at minimum create and link permission,
66332 + any additional privilege required is based on the
66333 + privilege of the file being linked to
66334 +*/
66335 +__u32
66336 +gr_acl_handle_link(const struct dentry * new_dentry,
66337 + const struct dentry * parent_dentry,
66338 + const struct vfsmount * parent_mnt,
66339 + const struct dentry * old_dentry,
66340 + const struct vfsmount * old_mnt, const struct filename *to)
66341 +{
66342 + __u32 mode;
66343 + __u32 needmode = GR_CREATE | GR_LINK;
66344 + __u32 needaudit = GR_AUDIT_CREATE | GR_AUDIT_LINK;
66345 +
66346 + mode =
66347 + gr_check_link(new_dentry, parent_dentry, parent_mnt, old_dentry,
66348 + old_mnt);
66349 +
66350 + if (unlikely(((mode & needmode) == needmode) && (mode & needaudit))) {
66351 + gr_log_fs_rbac_str(GR_DO_AUDIT, GR_LINK_ACL_MSG, old_dentry, old_mnt, to->name);
66352 + return mode;
66353 + } else if (unlikely(((mode & needmode) != needmode) && !(mode & GR_SUPPRESS))) {
66354 + gr_log_fs_rbac_str(GR_DONT_AUDIT, GR_LINK_ACL_MSG, old_dentry, old_mnt, to->name);
66355 + return 0;
66356 + } else if (unlikely((mode & needmode) != needmode))
66357 + return 0;
66358 +
66359 + return 1;
66360 +}
66361 +
66362 +__u32
66363 +gr_acl_handle_symlink(const struct dentry * new_dentry,
66364 + const struct dentry * parent_dentry,
66365 + const struct vfsmount * parent_mnt, const struct filename *from)
66366 +{
66367 + __u32 needmode = GR_WRITE | GR_CREATE;
66368 + __u32 mode;
66369 +
66370 + mode =
66371 + gr_check_create(new_dentry, parent_dentry, parent_mnt,
66372 + GR_CREATE | GR_AUDIT_CREATE |
66373 + GR_WRITE | GR_AUDIT_WRITE | GR_SUPPRESS);
66374 +
66375 + if (unlikely(mode & GR_WRITE && mode & GR_AUDITS)) {
66376 + gr_log_fs_str_rbac(GR_DO_AUDIT, GR_SYMLINK_ACL_MSG, from->name, new_dentry, parent_mnt);
66377 + return mode;
66378 + } else if (unlikely(((mode & needmode) != needmode) && !(mode & GR_SUPPRESS))) {
66379 + gr_log_fs_str_rbac(GR_DONT_AUDIT, GR_SYMLINK_ACL_MSG, from->name, new_dentry, parent_mnt);
66380 + return 0;
66381 + } else if (unlikely((mode & needmode) != needmode))
66382 + return 0;
66383 +
66384 + return (GR_WRITE | GR_CREATE);
66385 +}
66386 +
66387 +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)
66388 +{
66389 + __u32 mode;
66390 +
66391 + mode = gr_check_create(new_dentry, parent_dentry, parent_mnt, reqmode | to_gr_audit(reqmode) | GR_SUPPRESS);
66392 +
66393 + if (unlikely(((mode & (reqmode)) == (reqmode)) && mode & GR_AUDITS)) {
66394 + gr_log_fs_rbac_generic(GR_DO_AUDIT, fmt, new_dentry, parent_mnt);
66395 + return mode;
66396 + } else if (unlikely((mode & (reqmode)) != (reqmode) && !(mode & GR_SUPPRESS))) {
66397 + gr_log_fs_rbac_generic(GR_DONT_AUDIT, fmt, new_dentry, parent_mnt);
66398 + return 0;
66399 + } else if (unlikely((mode & (reqmode)) != (reqmode)))
66400 + return 0;
66401 +
66402 + return (reqmode);
66403 +}
66404 +
66405 +__u32
66406 +gr_acl_handle_mknod(const struct dentry * new_dentry,
66407 + const struct dentry * parent_dentry,
66408 + const struct vfsmount * parent_mnt,
66409 + const int mode)
66410 +{
66411 + __u32 reqmode = GR_WRITE | GR_CREATE;
66412 + if (unlikely((mode & S_ISUID) || ((mode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP))))
66413 + reqmode |= GR_SETID;
66414 +
66415 + return generic_fs_create_handler(new_dentry, parent_dentry, parent_mnt,
66416 + reqmode, GR_MKNOD_ACL_MSG);
66417 +}
66418 +
66419 +__u32
66420 +gr_acl_handle_mkdir(const struct dentry *new_dentry,
66421 + const struct dentry *parent_dentry,
66422 + const struct vfsmount *parent_mnt)
66423 +{
66424 + return generic_fs_create_handler(new_dentry, parent_dentry, parent_mnt,
66425 + GR_WRITE | GR_CREATE, GR_MKDIR_ACL_MSG);
66426 +}
66427 +
66428 +#define RENAME_CHECK_SUCCESS(old, new) \
66429 + (((old & (GR_WRITE | GR_READ)) == (GR_WRITE | GR_READ)) && \
66430 + ((new & (GR_WRITE | GR_READ)) == (GR_WRITE | GR_READ)))
66431 +
66432 +int
66433 +gr_acl_handle_rename(struct dentry *new_dentry,
66434 + struct dentry *parent_dentry,
66435 + const struct vfsmount *parent_mnt,
66436 + struct dentry *old_dentry,
66437 + struct inode *old_parent_inode,
66438 + struct vfsmount *old_mnt, const struct filename *newname)
66439 +{
66440 + __u32 comp1, comp2;
66441 + int error = 0;
66442 +
66443 + if (unlikely(!gr_acl_is_enabled()))
66444 + return 0;
66445 +
66446 + if (!new_dentry->d_inode) {
66447 + comp1 = gr_check_create(new_dentry, parent_dentry, parent_mnt,
66448 + GR_READ | GR_WRITE | GR_CREATE | GR_AUDIT_READ |
66449 + GR_AUDIT_WRITE | GR_AUDIT_CREATE | GR_SUPPRESS);
66450 + comp2 = gr_search_file(old_dentry, GR_READ | GR_WRITE |
66451 + GR_DELETE | GR_AUDIT_DELETE |
66452 + GR_AUDIT_READ | GR_AUDIT_WRITE |
66453 + GR_SUPPRESS, old_mnt);
66454 + } else {
66455 + comp1 = gr_search_file(new_dentry, GR_READ | GR_WRITE |
66456 + GR_CREATE | GR_DELETE |
66457 + GR_AUDIT_CREATE | GR_AUDIT_DELETE |
66458 + GR_AUDIT_READ | GR_AUDIT_WRITE |
66459 + GR_SUPPRESS, parent_mnt);
66460 + comp2 =
66461 + gr_search_file(old_dentry,
66462 + GR_READ | GR_WRITE | GR_AUDIT_READ |
66463 + GR_DELETE | GR_AUDIT_DELETE |
66464 + GR_AUDIT_WRITE | GR_SUPPRESS, old_mnt);
66465 + }
66466 +
66467 + if (RENAME_CHECK_SUCCESS(comp1, comp2) &&
66468 + ((comp1 & GR_AUDITS) || (comp2 & GR_AUDITS)))
66469 + gr_log_fs_rbac_str(GR_DO_AUDIT, GR_RENAME_ACL_MSG, old_dentry, old_mnt, newname->name);
66470 + else if (!RENAME_CHECK_SUCCESS(comp1, comp2) && !(comp1 & GR_SUPPRESS)
66471 + && !(comp2 & GR_SUPPRESS)) {
66472 + gr_log_fs_rbac_str(GR_DONT_AUDIT, GR_RENAME_ACL_MSG, old_dentry, old_mnt, newname->name);
66473 + error = -EACCES;
66474 + } else if (unlikely(!RENAME_CHECK_SUCCESS(comp1, comp2)))
66475 + error = -EACCES;
66476 +
66477 + return error;
66478 +}
66479 +
66480 +void
66481 +gr_acl_handle_exit(void)
66482 +{
66483 + u16 id;
66484 + char *rolename;
66485 +
66486 + if (unlikely(current->acl_sp_role && gr_acl_is_enabled() &&
66487 + !(current->role->roletype & GR_ROLE_PERSIST))) {
66488 + id = current->acl_role_id;
66489 + rolename = current->role->rolename;
66490 + gr_set_acls(1);
66491 + gr_log_str_int(GR_DONT_AUDIT_GOOD, GR_SPROLEL_ACL_MSG, rolename, id);
66492 + }
66493 +
66494 + gr_put_exec_file(current);
66495 + return;
66496 +}
66497 +
66498 +int
66499 +gr_acl_handle_procpidmem(const struct task_struct *task)
66500 +{
66501 + if (unlikely(!gr_acl_is_enabled()))
66502 + return 0;
66503 +
66504 + if (task != current && task->acl->mode & GR_PROTPROCFD)
66505 + return -EACCES;
66506 +
66507 + return 0;
66508 +}
66509 diff --git a/grsecurity/gracl_ip.c b/grsecurity/gracl_ip.c
66510 new file mode 100644
66511 index 0000000..f056b81
66512 --- /dev/null
66513 +++ b/grsecurity/gracl_ip.c
66514 @@ -0,0 +1,386 @@
66515 +#include <linux/kernel.h>
66516 +#include <asm/uaccess.h>
66517 +#include <asm/errno.h>
66518 +#include <net/sock.h>
66519 +#include <linux/file.h>
66520 +#include <linux/fs.h>
66521 +#include <linux/net.h>
66522 +#include <linux/in.h>
66523 +#include <linux/skbuff.h>
66524 +#include <linux/ip.h>
66525 +#include <linux/udp.h>
66526 +#include <linux/types.h>
66527 +#include <linux/sched.h>
66528 +#include <linux/netdevice.h>
66529 +#include <linux/inetdevice.h>
66530 +#include <linux/gracl.h>
66531 +#include <linux/grsecurity.h>
66532 +#include <linux/grinternal.h>
66533 +
66534 +#define GR_BIND 0x01
66535 +#define GR_CONNECT 0x02
66536 +#define GR_INVERT 0x04
66537 +#define GR_BINDOVERRIDE 0x08
66538 +#define GR_CONNECTOVERRIDE 0x10
66539 +#define GR_SOCK_FAMILY 0x20
66540 +
66541 +static const char * gr_protocols[IPPROTO_MAX] = {
66542 + "ip", "icmp", "igmp", "ggp", "ipencap", "st", "tcp", "cbt",
66543 + "egp", "igp", "bbn-rcc", "nvp", "pup", "argus", "emcon", "xnet",
66544 + "chaos", "udp", "mux", "dcn", "hmp", "prm", "xns-idp", "trunk-1",
66545 + "trunk-2", "leaf-1", "leaf-2", "rdp", "irtp", "iso-tp4", "netblt", "mfe-nsp",
66546 + "merit-inp", "sep", "3pc", "idpr", "xtp", "ddp", "idpr-cmtp", "tp++",
66547 + "il", "ipv6", "sdrp", "ipv6-route", "ipv6-frag", "idrp", "rsvp", "gre",
66548 + "mhrp", "bna", "ipv6-crypt", "ipv6-auth", "i-nlsp", "swipe", "narp", "mobile",
66549 + "tlsp", "skip", "ipv6-icmp", "ipv6-nonxt", "ipv6-opts", "unknown:61", "cftp", "unknown:63",
66550 + "sat-expak", "kryptolan", "rvd", "ippc", "unknown:68", "sat-mon", "visa", "ipcv",
66551 + "cpnx", "cphb", "wsn", "pvp", "br-sat-mon", "sun-nd", "wb-mon", "wb-expak",
66552 + "iso-ip", "vmtp", "secure-vmtp", "vines", "ttp", "nfsnet-igp", "dgp", "tcf",
66553 + "eigrp", "ospf", "sprite-rpc", "larp", "mtp", "ax.25", "ipip", "micp",
66554 + "scc-sp", "etherip", "encap", "unknown:99", "gmtp", "ifmp", "pnni", "pim",
66555 + "aris", "scps", "qnx", "a/n", "ipcomp", "snp", "compaq-peer", "ipx-in-ip",
66556 + "vrrp", "pgm", "unknown:114", "l2tp", "ddx", "iatp", "stp", "srp",
66557 + "uti", "smp", "sm", "ptp", "isis", "fire", "crtp", "crdup",
66558 + "sscopmce", "iplt", "sps", "pipe", "sctp", "fc", "unkown:134", "unknown:135",
66559 + "unknown:136", "unknown:137", "unknown:138", "unknown:139", "unknown:140", "unknown:141", "unknown:142", "unknown:143",
66560 + "unknown:144", "unknown:145", "unknown:146", "unknown:147", "unknown:148", "unknown:149", "unknown:150", "unknown:151",
66561 + "unknown:152", "unknown:153", "unknown:154", "unknown:155", "unknown:156", "unknown:157", "unknown:158", "unknown:159",
66562 + "unknown:160", "unknown:161", "unknown:162", "unknown:163", "unknown:164", "unknown:165", "unknown:166", "unknown:167",
66563 + "unknown:168", "unknown:169", "unknown:170", "unknown:171", "unknown:172", "unknown:173", "unknown:174", "unknown:175",
66564 + "unknown:176", "unknown:177", "unknown:178", "unknown:179", "unknown:180", "unknown:181", "unknown:182", "unknown:183",
66565 + "unknown:184", "unknown:185", "unknown:186", "unknown:187", "unknown:188", "unknown:189", "unknown:190", "unknown:191",
66566 + "unknown:192", "unknown:193", "unknown:194", "unknown:195", "unknown:196", "unknown:197", "unknown:198", "unknown:199",
66567 + "unknown:200", "unknown:201", "unknown:202", "unknown:203", "unknown:204", "unknown:205", "unknown:206", "unknown:207",
66568 + "unknown:208", "unknown:209", "unknown:210", "unknown:211", "unknown:212", "unknown:213", "unknown:214", "unknown:215",
66569 + "unknown:216", "unknown:217", "unknown:218", "unknown:219", "unknown:220", "unknown:221", "unknown:222", "unknown:223",
66570 + "unknown:224", "unknown:225", "unknown:226", "unknown:227", "unknown:228", "unknown:229", "unknown:230", "unknown:231",
66571 + "unknown:232", "unknown:233", "unknown:234", "unknown:235", "unknown:236", "unknown:237", "unknown:238", "unknown:239",
66572 + "unknown:240", "unknown:241", "unknown:242", "unknown:243", "unknown:244", "unknown:245", "unknown:246", "unknown:247",
66573 + "unknown:248", "unknown:249", "unknown:250", "unknown:251", "unknown:252", "unknown:253", "unknown:254", "unknown:255",
66574 + };
66575 +
66576 +static const char * gr_socktypes[SOCK_MAX] = {
66577 + "unknown:0", "stream", "dgram", "raw", "rdm", "seqpacket", "unknown:6",
66578 + "unknown:7", "unknown:8", "unknown:9", "packet"
66579 + };
66580 +
66581 +static const char * gr_sockfamilies[AF_MAX+1] = {
66582 + "unspec", "unix", "inet", "ax25", "ipx", "appletalk", "netrom", "bridge", "atmpvc", "x25",
66583 + "inet6", "rose", "decnet", "netbeui", "security", "key", "netlink", "packet", "ash",
66584 + "econet", "atmsvc", "rds", "sna", "irda", "ppox", "wanpipe", "llc", "fam_27", "fam_28",
66585 + "tipc", "bluetooth", "iucv", "rxrpc", "isdn", "phonet", "ieee802154", "ciaf"
66586 + };
66587 +
66588 +const char *
66589 +gr_proto_to_name(unsigned char proto)
66590 +{
66591 + return gr_protocols[proto];
66592 +}
66593 +
66594 +const char *
66595 +gr_socktype_to_name(unsigned char type)
66596 +{
66597 + return gr_socktypes[type];
66598 +}
66599 +
66600 +const char *
66601 +gr_sockfamily_to_name(unsigned char family)
66602 +{
66603 + return gr_sockfamilies[family];
66604 +}
66605 +
66606 +extern const struct net_proto_family __rcu *net_families[NPROTO] __read_mostly;
66607 +
66608 +int
66609 +gr_search_socket(const int domain, const int type, const int protocol)
66610 +{
66611 + struct acl_subject_label *curr;
66612 + const struct cred *cred = current_cred();
66613 +
66614 + if (unlikely(!gr_acl_is_enabled()))
66615 + goto exit;
66616 +
66617 + if ((domain < 0) || (type < 0) || (protocol < 0) ||
66618 + (domain >= AF_MAX) || (type >= SOCK_MAX) || (protocol >= IPPROTO_MAX))
66619 + goto exit; // let the kernel handle it
66620 +
66621 + curr = current->acl;
66622 +
66623 + if (curr->sock_families[domain / 32] & (1U << (domain % 32))) {
66624 + /* the family is allowed, if this is PF_INET allow it only if
66625 + the extra sock type/protocol checks pass */
66626 + if (domain == PF_INET)
66627 + goto inet_check;
66628 + goto exit;
66629 + } else {
66630 + if (curr->mode & (GR_LEARN | GR_INHERITLEARN)) {
66631 + __u32 fakeip = 0;
66632 + security_learn(GR_IP_LEARN_MSG, current->role->rolename,
66633 + current->role->roletype, GR_GLOBAL_UID(cred->uid),
66634 + GR_GLOBAL_GID(cred->gid), current->exec_file ?
66635 + gr_to_filename(current->exec_file->f_path.dentry,
66636 + current->exec_file->f_path.mnt) :
66637 + curr->filename, curr->filename,
66638 + &fakeip, domain, 0, 0, GR_SOCK_FAMILY,
66639 + &current->signal->saved_ip);
66640 + goto exit;
66641 + }
66642 + goto exit_fail;
66643 + }
66644 +
66645 +inet_check:
66646 + /* the rest of this checking is for IPv4 only */
66647 + if (!curr->ips)
66648 + goto exit;
66649 +
66650 + if ((curr->ip_type & (1U << type)) &&
66651 + (curr->ip_proto[protocol / 32] & (1U << (protocol % 32))))
66652 + goto exit;
66653 +
66654 + if (curr->mode & (GR_LEARN | GR_INHERITLEARN)) {
66655 + /* we don't place acls on raw sockets , and sometimes
66656 + dgram/ip sockets are opened for ioctl and not
66657 + bind/connect, so we'll fake a bind learn log */
66658 + if (type == SOCK_RAW || type == SOCK_PACKET) {
66659 + __u32 fakeip = 0;
66660 + security_learn(GR_IP_LEARN_MSG, current->role->rolename,
66661 + current->role->roletype, GR_GLOBAL_UID(cred->uid),
66662 + GR_GLOBAL_GID(cred->gid), current->exec_file ?
66663 + gr_to_filename(current->exec_file->f_path.dentry,
66664 + current->exec_file->f_path.mnt) :
66665 + curr->filename, curr->filename,
66666 + &fakeip, 0, type,
66667 + protocol, GR_CONNECT, &current->signal->saved_ip);
66668 + } else if ((type == SOCK_DGRAM) && (protocol == IPPROTO_IP)) {
66669 + __u32 fakeip = 0;
66670 + security_learn(GR_IP_LEARN_MSG, current->role->rolename,
66671 + current->role->roletype, GR_GLOBAL_UID(cred->uid),
66672 + GR_GLOBAL_GID(cred->gid), current->exec_file ?
66673 + gr_to_filename(current->exec_file->f_path.dentry,
66674 + current->exec_file->f_path.mnt) :
66675 + curr->filename, curr->filename,
66676 + &fakeip, 0, type,
66677 + protocol, GR_BIND, &current->signal->saved_ip);
66678 + }
66679 + /* we'll log when they use connect or bind */
66680 + goto exit;
66681 + }
66682 +
66683 +exit_fail:
66684 + if (domain == PF_INET)
66685 + gr_log_str3(GR_DONT_AUDIT, GR_SOCK_MSG, gr_sockfamily_to_name(domain),
66686 + gr_socktype_to_name(type), gr_proto_to_name(protocol));
66687 + else if (rcu_access_pointer(net_families[domain]) != NULL)
66688 + gr_log_str2_int(GR_DONT_AUDIT, GR_SOCK_NOINET_MSG, gr_sockfamily_to_name(domain),
66689 + gr_socktype_to_name(type), protocol);
66690 +
66691 + return 0;
66692 +exit:
66693 + return 1;
66694 +}
66695 +
66696 +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)
66697 +{
66698 + if ((ip->mode & mode) &&
66699 + (ip_port >= ip->low) &&
66700 + (ip_port <= ip->high) &&
66701 + ((ntohl(ip_addr) & our_netmask) ==
66702 + (ntohl(our_addr) & our_netmask))
66703 + && (ip->proto[protocol / 32] & (1U << (protocol % 32)))
66704 + && (ip->type & (1U << type))) {
66705 + if (ip->mode & GR_INVERT)
66706 + return 2; // specifically denied
66707 + else
66708 + return 1; // allowed
66709 + }
66710 +
66711 + return 0; // not specifically allowed, may continue parsing
66712 +}
66713 +
66714 +static int
66715 +gr_search_connectbind(const int full_mode, struct sock *sk,
66716 + struct sockaddr_in *addr, const int type)
66717 +{
66718 + char iface[IFNAMSIZ] = {0};
66719 + struct acl_subject_label *curr;
66720 + struct acl_ip_label *ip;
66721 + struct inet_sock *isk;
66722 + struct net_device *dev;
66723 + struct in_device *idev;
66724 + unsigned long i;
66725 + int ret;
66726 + int mode = full_mode & (GR_BIND | GR_CONNECT);
66727 + __u32 ip_addr = 0;
66728 + __u32 our_addr;
66729 + __u32 our_netmask;
66730 + char *p;
66731 + __u16 ip_port = 0;
66732 + const struct cred *cred = current_cred();
66733 +
66734 + if (unlikely(!gr_acl_is_enabled() || sk->sk_family != PF_INET))
66735 + return 0;
66736 +
66737 + curr = current->acl;
66738 + isk = inet_sk(sk);
66739 +
66740 + /* INADDR_ANY overriding for binds, inaddr_any_override is already in network order */
66741 + if ((full_mode & GR_BINDOVERRIDE) && addr->sin_addr.s_addr == htonl(INADDR_ANY) && curr->inaddr_any_override != 0)
66742 + addr->sin_addr.s_addr = curr->inaddr_any_override;
66743 + if ((full_mode & GR_CONNECT) && isk->inet_saddr == htonl(INADDR_ANY) && curr->inaddr_any_override != 0) {
66744 + struct sockaddr_in saddr;
66745 + int err;
66746 +
66747 + saddr.sin_family = AF_INET;
66748 + saddr.sin_addr.s_addr = curr->inaddr_any_override;
66749 + saddr.sin_port = isk->inet_sport;
66750 +
66751 + err = security_socket_bind(sk->sk_socket, (struct sockaddr *)&saddr, sizeof(struct sockaddr_in));
66752 + if (err)
66753 + return err;
66754 +
66755 + err = sk->sk_socket->ops->bind(sk->sk_socket, (struct sockaddr *)&saddr, sizeof(struct sockaddr_in));
66756 + if (err)
66757 + return err;
66758 + }
66759 +
66760 + if (!curr->ips)
66761 + return 0;
66762 +
66763 + ip_addr = addr->sin_addr.s_addr;
66764 + ip_port = ntohs(addr->sin_port);
66765 +
66766 + if (curr->mode & (GR_LEARN | GR_INHERITLEARN)) {
66767 + security_learn(GR_IP_LEARN_MSG, current->role->rolename,
66768 + current->role->roletype, GR_GLOBAL_UID(cred->uid),
66769 + GR_GLOBAL_GID(cred->gid), current->exec_file ?
66770 + gr_to_filename(current->exec_file->f_path.dentry,
66771 + current->exec_file->f_path.mnt) :
66772 + curr->filename, curr->filename,
66773 + &ip_addr, ip_port, type,
66774 + sk->sk_protocol, mode, &current->signal->saved_ip);
66775 + return 0;
66776 + }
66777 +
66778 + for (i = 0; i < curr->ip_num; i++) {
66779 + ip = *(curr->ips + i);
66780 + if (ip->iface != NULL) {
66781 + strncpy(iface, ip->iface, IFNAMSIZ - 1);
66782 + p = strchr(iface, ':');
66783 + if (p != NULL)
66784 + *p = '\0';
66785 + dev = dev_get_by_name(sock_net(sk), iface);
66786 + if (dev == NULL)
66787 + continue;
66788 + idev = in_dev_get(dev);
66789 + if (idev == NULL) {
66790 + dev_put(dev);
66791 + continue;
66792 + }
66793 + rcu_read_lock();
66794 + for_ifa(idev) {
66795 + if (!strcmp(ip->iface, ifa->ifa_label)) {
66796 + our_addr = ifa->ifa_address;
66797 + our_netmask = 0xffffffff;
66798 + ret = check_ip_policy(ip, ip_addr, ip_port, sk->sk_protocol, mode, type, our_addr, our_netmask);
66799 + if (ret == 1) {
66800 + rcu_read_unlock();
66801 + in_dev_put(idev);
66802 + dev_put(dev);
66803 + return 0;
66804 + } else if (ret == 2) {
66805 + rcu_read_unlock();
66806 + in_dev_put(idev);
66807 + dev_put(dev);
66808 + goto denied;
66809 + }
66810 + }
66811 + } endfor_ifa(idev);
66812 + rcu_read_unlock();
66813 + in_dev_put(idev);
66814 + dev_put(dev);
66815 + } else {
66816 + our_addr = ip->addr;
66817 + our_netmask = ip->netmask;
66818 + ret = check_ip_policy(ip, ip_addr, ip_port, sk->sk_protocol, mode, type, our_addr, our_netmask);
66819 + if (ret == 1)
66820 + return 0;
66821 + else if (ret == 2)
66822 + goto denied;
66823 + }
66824 + }
66825 +
66826 +denied:
66827 + if (mode == GR_BIND)
66828 + 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));
66829 + else if (mode == GR_CONNECT)
66830 + 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));
66831 +
66832 + return -EACCES;
66833 +}
66834 +
66835 +int
66836 +gr_search_connect(struct socket *sock, struct sockaddr_in *addr)
66837 +{
66838 + /* always allow disconnection of dgram sockets with connect */
66839 + if (addr->sin_family == AF_UNSPEC)
66840 + return 0;
66841 + return gr_search_connectbind(GR_CONNECT | GR_CONNECTOVERRIDE, sock->sk, addr, sock->type);
66842 +}
66843 +
66844 +int
66845 +gr_search_bind(struct socket *sock, struct sockaddr_in *addr)
66846 +{
66847 + return gr_search_connectbind(GR_BIND | GR_BINDOVERRIDE, sock->sk, addr, sock->type);
66848 +}
66849 +
66850 +int gr_search_listen(struct socket *sock)
66851 +{
66852 + struct sock *sk = sock->sk;
66853 + struct sockaddr_in addr;
66854 +
66855 + addr.sin_addr.s_addr = inet_sk(sk)->inet_saddr;
66856 + addr.sin_port = inet_sk(sk)->inet_sport;
66857 +
66858 + return gr_search_connectbind(GR_BIND | GR_CONNECTOVERRIDE, sock->sk, &addr, sock->type);
66859 +}
66860 +
66861 +int gr_search_accept(struct socket *sock)
66862 +{
66863 + struct sock *sk = sock->sk;
66864 + struct sockaddr_in addr;
66865 +
66866 + addr.sin_addr.s_addr = inet_sk(sk)->inet_saddr;
66867 + addr.sin_port = inet_sk(sk)->inet_sport;
66868 +
66869 + return gr_search_connectbind(GR_BIND | GR_CONNECTOVERRIDE, sock->sk, &addr, sock->type);
66870 +}
66871 +
66872 +int
66873 +gr_search_udp_sendmsg(struct sock *sk, struct sockaddr_in *addr)
66874 +{
66875 + if (addr)
66876 + return gr_search_connectbind(GR_CONNECT, sk, addr, SOCK_DGRAM);
66877 + else {
66878 + struct sockaddr_in sin;
66879 + const struct inet_sock *inet = inet_sk(sk);
66880 +
66881 + sin.sin_addr.s_addr = inet->inet_daddr;
66882 + sin.sin_port = inet->inet_dport;
66883 +
66884 + return gr_search_connectbind(GR_CONNECT | GR_CONNECTOVERRIDE, sk, &sin, SOCK_DGRAM);
66885 + }
66886 +}
66887 +
66888 +int
66889 +gr_search_udp_recvmsg(struct sock *sk, const struct sk_buff *skb)
66890 +{
66891 + struct sockaddr_in sin;
66892 +
66893 + if (unlikely(skb->len < sizeof (struct udphdr)))
66894 + return 0; // skip this packet
66895 +
66896 + sin.sin_addr.s_addr = ip_hdr(skb)->saddr;
66897 + sin.sin_port = udp_hdr(skb)->source;
66898 +
66899 + return gr_search_connectbind(GR_CONNECT | GR_CONNECTOVERRIDE, sk, &sin, SOCK_DGRAM);
66900 +}
66901 diff --git a/grsecurity/gracl_learn.c b/grsecurity/gracl_learn.c
66902 new file mode 100644
66903 index 0000000..25f54ef
66904 --- /dev/null
66905 +++ b/grsecurity/gracl_learn.c
66906 @@ -0,0 +1,207 @@
66907 +#include <linux/kernel.h>
66908 +#include <linux/mm.h>
66909 +#include <linux/sched.h>
66910 +#include <linux/poll.h>
66911 +#include <linux/string.h>
66912 +#include <linux/file.h>
66913 +#include <linux/types.h>
66914 +#include <linux/vmalloc.h>
66915 +#include <linux/grinternal.h>
66916 +
66917 +extern ssize_t write_grsec_handler(struct file * file, const char __user * buf,
66918 + size_t count, loff_t *ppos);
66919 +extern int gr_acl_is_enabled(void);
66920 +
66921 +static DECLARE_WAIT_QUEUE_HEAD(learn_wait);
66922 +static int gr_learn_attached;
66923 +
66924 +/* use a 512k buffer */
66925 +#define LEARN_BUFFER_SIZE (512 * 1024)
66926 +
66927 +static DEFINE_SPINLOCK(gr_learn_lock);
66928 +static DEFINE_MUTEX(gr_learn_user_mutex);
66929 +
66930 +/* we need to maintain two buffers, so that the kernel context of grlearn
66931 + uses a semaphore around the userspace copying, and the other kernel contexts
66932 + use a spinlock when copying into the buffer, since they cannot sleep
66933 +*/
66934 +static char *learn_buffer;
66935 +static char *learn_buffer_user;
66936 +static int learn_buffer_len;
66937 +static int learn_buffer_user_len;
66938 +
66939 +static ssize_t
66940 +read_learn(struct file *file, char __user * buf, size_t count, loff_t * ppos)
66941 +{
66942 + DECLARE_WAITQUEUE(wait, current);
66943 + ssize_t retval = 0;
66944 +
66945 + add_wait_queue(&learn_wait, &wait);
66946 + set_current_state(TASK_INTERRUPTIBLE);
66947 + do {
66948 + mutex_lock(&gr_learn_user_mutex);
66949 + spin_lock(&gr_learn_lock);
66950 + if (learn_buffer_len)
66951 + break;
66952 + spin_unlock(&gr_learn_lock);
66953 + mutex_unlock(&gr_learn_user_mutex);
66954 + if (file->f_flags & O_NONBLOCK) {
66955 + retval = -EAGAIN;
66956 + goto out;
66957 + }
66958 + if (signal_pending(current)) {
66959 + retval = -ERESTARTSYS;
66960 + goto out;
66961 + }
66962 +
66963 + schedule();
66964 + } while (1);
66965 +
66966 + memcpy(learn_buffer_user, learn_buffer, learn_buffer_len);
66967 + learn_buffer_user_len = learn_buffer_len;
66968 + retval = learn_buffer_len;
66969 + learn_buffer_len = 0;
66970 +
66971 + spin_unlock(&gr_learn_lock);
66972 +
66973 + if (copy_to_user(buf, learn_buffer_user, learn_buffer_user_len))
66974 + retval = -EFAULT;
66975 +
66976 + mutex_unlock(&gr_learn_user_mutex);
66977 +out:
66978 + set_current_state(TASK_RUNNING);
66979 + remove_wait_queue(&learn_wait, &wait);
66980 + return retval;
66981 +}
66982 +
66983 +static unsigned int
66984 +poll_learn(struct file * file, poll_table * wait)
66985 +{
66986 + poll_wait(file, &learn_wait, wait);
66987 +
66988 + if (learn_buffer_len)
66989 + return (POLLIN | POLLRDNORM);
66990 +
66991 + return 0;
66992 +}
66993 +
66994 +void
66995 +gr_clear_learn_entries(void)
66996 +{
66997 + char *tmp;
66998 +
66999 + mutex_lock(&gr_learn_user_mutex);
67000 + spin_lock(&gr_learn_lock);
67001 + tmp = learn_buffer;
67002 + learn_buffer = NULL;
67003 + spin_unlock(&gr_learn_lock);
67004 + if (tmp)
67005 + vfree(tmp);
67006 + if (learn_buffer_user != NULL) {
67007 + vfree(learn_buffer_user);
67008 + learn_buffer_user = NULL;
67009 + }
67010 + learn_buffer_len = 0;
67011 + mutex_unlock(&gr_learn_user_mutex);
67012 +
67013 + return;
67014 +}
67015 +
67016 +void
67017 +gr_add_learn_entry(const char *fmt, ...)
67018 +{
67019 + va_list args;
67020 + unsigned int len;
67021 +
67022 + if (!gr_learn_attached)
67023 + return;
67024 +
67025 + spin_lock(&gr_learn_lock);
67026 +
67027 + /* leave a gap at the end so we know when it's "full" but don't have to
67028 + compute the exact length of the string we're trying to append
67029 + */
67030 + if (learn_buffer_len > LEARN_BUFFER_SIZE - 16384) {
67031 + spin_unlock(&gr_learn_lock);
67032 + wake_up_interruptible(&learn_wait);
67033 + return;
67034 + }
67035 + if (learn_buffer == NULL) {
67036 + spin_unlock(&gr_learn_lock);
67037 + return;
67038 + }
67039 +
67040 + va_start(args, fmt);
67041 + len = vsnprintf(learn_buffer + learn_buffer_len, LEARN_BUFFER_SIZE - learn_buffer_len, fmt, args);
67042 + va_end(args);
67043 +
67044 + learn_buffer_len += len + 1;
67045 +
67046 + spin_unlock(&gr_learn_lock);
67047 + wake_up_interruptible(&learn_wait);
67048 +
67049 + return;
67050 +}
67051 +
67052 +static int
67053 +open_learn(struct inode *inode, struct file *file)
67054 +{
67055 + if (file->f_mode & FMODE_READ && gr_learn_attached)
67056 + return -EBUSY;
67057 + if (file->f_mode & FMODE_READ) {
67058 + int retval = 0;
67059 + mutex_lock(&gr_learn_user_mutex);
67060 + if (learn_buffer == NULL)
67061 + learn_buffer = vmalloc(LEARN_BUFFER_SIZE);
67062 + if (learn_buffer_user == NULL)
67063 + learn_buffer_user = vmalloc(LEARN_BUFFER_SIZE);
67064 + if (learn_buffer == NULL) {
67065 + retval = -ENOMEM;
67066 + goto out_error;
67067 + }
67068 + if (learn_buffer_user == NULL) {
67069 + retval = -ENOMEM;
67070 + goto out_error;
67071 + }
67072 + learn_buffer_len = 0;
67073 + learn_buffer_user_len = 0;
67074 + gr_learn_attached = 1;
67075 +out_error:
67076 + mutex_unlock(&gr_learn_user_mutex);
67077 + return retval;
67078 + }
67079 + return 0;
67080 +}
67081 +
67082 +static int
67083 +close_learn(struct inode *inode, struct file *file)
67084 +{
67085 + if (file->f_mode & FMODE_READ) {
67086 + char *tmp = NULL;
67087 + mutex_lock(&gr_learn_user_mutex);
67088 + spin_lock(&gr_learn_lock);
67089 + tmp = learn_buffer;
67090 + learn_buffer = NULL;
67091 + spin_unlock(&gr_learn_lock);
67092 + if (tmp)
67093 + vfree(tmp);
67094 + if (learn_buffer_user != NULL) {
67095 + vfree(learn_buffer_user);
67096 + learn_buffer_user = NULL;
67097 + }
67098 + learn_buffer_len = 0;
67099 + learn_buffer_user_len = 0;
67100 + gr_learn_attached = 0;
67101 + mutex_unlock(&gr_learn_user_mutex);
67102 + }
67103 +
67104 + return 0;
67105 +}
67106 +
67107 +const struct file_operations grsec_fops = {
67108 + .read = read_learn,
67109 + .write = write_grsec_handler,
67110 + .open = open_learn,
67111 + .release = close_learn,
67112 + .poll = poll_learn,
67113 +};
67114 diff --git a/grsecurity/gracl_policy.c b/grsecurity/gracl_policy.c
67115 new file mode 100644
67116 index 0000000..36e293f
67117 --- /dev/null
67118 +++ b/grsecurity/gracl_policy.c
67119 @@ -0,0 +1,1777 @@
67120 +#include <linux/kernel.h>
67121 +#include <linux/module.h>
67122 +#include <linux/sched.h>
67123 +#include <linux/mm.h>
67124 +#include <linux/file.h>
67125 +#include <linux/fs.h>
67126 +#include <linux/namei.h>
67127 +#include <linux/mount.h>
67128 +#include <linux/tty.h>
67129 +#include <linux/proc_fs.h>
67130 +#include <linux/lglock.h>
67131 +#include <linux/slab.h>
67132 +#include <linux/vmalloc.h>
67133 +#include <linux/types.h>
67134 +#include <linux/sysctl.h>
67135 +#include <linux/netdevice.h>
67136 +#include <linux/ptrace.h>
67137 +#include <linux/gracl.h>
67138 +#include <linux/gralloc.h>
67139 +#include <linux/security.h>
67140 +#include <linux/grinternal.h>
67141 +#include <linux/pid_namespace.h>
67142 +#include <linux/stop_machine.h>
67143 +#include <linux/fdtable.h>
67144 +#include <linux/percpu.h>
67145 +#include <linux/lglock.h>
67146 +#include <linux/hugetlb.h>
67147 +#include <linux/posix-timers.h>
67148 +#include "../fs/mount.h"
67149 +
67150 +#include <asm/uaccess.h>
67151 +#include <asm/errno.h>
67152 +#include <asm/mman.h>
67153 +
67154 +extern struct gr_policy_state *polstate;
67155 +
67156 +#define FOR_EACH_ROLE_START(role) \
67157 + role = polstate->role_list; \
67158 + while (role) {
67159 +
67160 +#define FOR_EACH_ROLE_END(role) \
67161 + role = role->prev; \
67162 + }
67163 +
67164 +struct path gr_real_root;
67165 +
67166 +extern struct gr_alloc_state *current_alloc_state;
67167 +
67168 +u16 acl_sp_role_value;
67169 +
67170 +static DEFINE_MUTEX(gr_dev_mutex);
67171 +
67172 +extern int chkpw(struct gr_arg *entry, unsigned char *salt, unsigned char *sum);
67173 +extern void gr_clear_learn_entries(void);
67174 +
67175 +static struct gr_arg gr_usermode;
67176 +static unsigned char gr_system_salt[GR_SALT_LEN];
67177 +static unsigned char gr_system_sum[GR_SHA_LEN];
67178 +
67179 +static unsigned int gr_auth_attempts = 0;
67180 +static unsigned long gr_auth_expires = 0UL;
67181 +
67182 +struct acl_object_label *fakefs_obj_rw;
67183 +struct acl_object_label *fakefs_obj_rwx;
67184 +
67185 +extern int gr_init_uidset(void);
67186 +extern void gr_free_uidset(void);
67187 +extern void gr_remove_uid(uid_t uid);
67188 +extern int gr_find_uid(uid_t uid);
67189 +
67190 +extern struct acl_subject_label *__gr_get_subject_for_task(const struct gr_policy_state *state, struct task_struct *task, const char *filename);
67191 +extern void __gr_apply_subject_to_task(struct gr_policy_state *state, struct task_struct *task, struct acl_subject_label *subj);
67192 +extern int gr_streq(const char *a, const char *b, const unsigned int lena, const unsigned int lenb);
67193 +extern void __insert_inodev_entry(const struct gr_policy_state *state, struct inodev_entry *entry);
67194 +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);
67195 +extern void insert_acl_obj_label(struct acl_object_label *obj, struct acl_subject_label *subj);
67196 +extern void insert_acl_subj_label(struct acl_subject_label *obj, struct acl_role_label *role);
67197 +extern struct name_entry * __lookup_name_entry(const struct gr_policy_state *state, const char *name);
67198 +extern char *gr_to_filename_rbac(const struct dentry *dentry, const struct vfsmount *mnt);
67199 +extern struct acl_subject_label *lookup_acl_subj_label(const ino_t ino, const dev_t dev, const struct acl_role_label *role);
67200 +extern struct acl_subject_label *lookup_acl_subj_label_deleted(const ino_t ino, const dev_t dev, const struct acl_role_label *role);
67201 +extern void assign_special_role(const char *rolename);
67202 +extern struct acl_subject_label *chk_subj_label(const struct dentry *l_dentry, const struct vfsmount *l_mnt, const struct acl_role_label *role);
67203 +extern int gr_rbac_disable(void *unused);
67204 +extern void gr_enable_rbac_system(void);
67205 +
67206 +static int copy_acl_object_label_normal(struct acl_object_label *obj, const struct acl_object_label *userp)
67207 +{
67208 + if (copy_from_user(obj, userp, sizeof(struct acl_object_label)))
67209 + return -EFAULT;
67210 +
67211 + return 0;
67212 +}
67213 +
67214 +static int copy_acl_ip_label_normal(struct acl_ip_label *ip, const struct acl_ip_label *userp)
67215 +{
67216 + if (copy_from_user(ip, userp, sizeof(struct acl_ip_label)))
67217 + return -EFAULT;
67218 +
67219 + return 0;
67220 +}
67221 +
67222 +static int copy_acl_subject_label_normal(struct acl_subject_label *subj, const struct acl_subject_label *userp)
67223 +{
67224 + if (copy_from_user(subj, userp, sizeof(struct acl_subject_label)))
67225 + return -EFAULT;
67226 +
67227 + return 0;
67228 +}
67229 +
67230 +static int copy_acl_role_label_normal(struct acl_role_label *role, const struct acl_role_label *userp)
67231 +{
67232 + if (copy_from_user(role, userp, sizeof(struct acl_role_label)))
67233 + return -EFAULT;
67234 +
67235 + return 0;
67236 +}
67237 +
67238 +static int copy_role_allowed_ip_normal(struct role_allowed_ip *roleip, const struct role_allowed_ip *userp)
67239 +{
67240 + if (copy_from_user(roleip, userp, sizeof(struct role_allowed_ip)))
67241 + return -EFAULT;
67242 +
67243 + return 0;
67244 +}
67245 +
67246 +static int copy_sprole_pw_normal(struct sprole_pw *pw, unsigned long idx, const struct sprole_pw *userp)
67247 +{
67248 + if (copy_from_user(pw, userp + idx, sizeof(struct sprole_pw)))
67249 + return -EFAULT;
67250 +
67251 + return 0;
67252 +}
67253 +
67254 +static int copy_gr_hash_struct_normal(struct gr_hash_struct *hash, const struct gr_hash_struct *userp)
67255 +{
67256 + if (copy_from_user(hash, userp, sizeof(struct gr_hash_struct)))
67257 + return -EFAULT;
67258 +
67259 + return 0;
67260 +}
67261 +
67262 +static int copy_role_transition_normal(struct role_transition *trans, const struct role_transition *userp)
67263 +{
67264 + if (copy_from_user(trans, userp, sizeof(struct role_transition)))
67265 + return -EFAULT;
67266 +
67267 + return 0;
67268 +}
67269 +
67270 +int copy_pointer_from_array_normal(void *ptr, unsigned long idx, const void *userp)
67271 +{
67272 + if (copy_from_user(ptr, userp + (idx * sizeof(void *)), sizeof(void *)))
67273 + return -EFAULT;
67274 +
67275 + return 0;
67276 +}
67277 +
67278 +static int copy_gr_arg_wrapper_normal(const char __user *buf, struct gr_arg_wrapper *uwrap)
67279 +{
67280 + if (copy_from_user(uwrap, buf, sizeof (struct gr_arg_wrapper)))
67281 + return -EFAULT;
67282 +
67283 + if (((uwrap->version != GRSECURITY_VERSION) &&
67284 + (uwrap->version != 0x2901)) ||
67285 + (uwrap->size != sizeof(struct gr_arg)))
67286 + return -EINVAL;
67287 +
67288 + return 0;
67289 +}
67290 +
67291 +static int copy_gr_arg_normal(const struct gr_arg __user *buf, struct gr_arg *arg)
67292 +{
67293 + if (copy_from_user(arg, buf, sizeof (struct gr_arg)))
67294 + return -EFAULT;
67295 +
67296 + return 0;
67297 +}
67298 +
67299 +static size_t get_gr_arg_wrapper_size_normal(void)
67300 +{
67301 + return sizeof(struct gr_arg_wrapper);
67302 +}
67303 +
67304 +#ifdef CONFIG_COMPAT
67305 +extern int copy_gr_arg_wrapper_compat(const char *buf, struct gr_arg_wrapper *uwrap);
67306 +extern int copy_gr_arg_compat(const struct gr_arg __user *buf, struct gr_arg *arg);
67307 +extern int copy_acl_object_label_compat(struct acl_object_label *obj, const struct acl_object_label *userp);
67308 +extern int copy_acl_subject_label_compat(struct acl_subject_label *subj, const struct acl_subject_label *userp);
67309 +extern int copy_acl_role_label_compat(struct acl_role_label *role, const struct acl_role_label *userp);
67310 +extern int copy_role_allowed_ip_compat(struct role_allowed_ip *roleip, const struct role_allowed_ip *userp);
67311 +extern int copy_role_transition_compat(struct role_transition *trans, const struct role_transition *userp);
67312 +extern int copy_gr_hash_struct_compat(struct gr_hash_struct *hash, const struct gr_hash_struct *userp);
67313 +extern int copy_pointer_from_array_compat(void *ptr, unsigned long idx, const void *userp);
67314 +extern int copy_acl_ip_label_compat(struct acl_ip_label *ip, const struct acl_ip_label *userp);
67315 +extern int copy_sprole_pw_compat(struct sprole_pw *pw, unsigned long idx, const struct sprole_pw *userp);
67316 +extern size_t get_gr_arg_wrapper_size_compat(void);
67317 +
67318 +int (* copy_gr_arg_wrapper)(const char *buf, struct gr_arg_wrapper *uwrap) __read_only;
67319 +int (* copy_gr_arg)(const struct gr_arg *buf, struct gr_arg *arg) __read_only;
67320 +int (* copy_acl_object_label)(struct acl_object_label *obj, const struct acl_object_label *userp) __read_only;
67321 +int (* copy_acl_subject_label)(struct acl_subject_label *subj, const struct acl_subject_label *userp) __read_only;
67322 +int (* copy_acl_role_label)(struct acl_role_label *role, const struct acl_role_label *userp) __read_only;
67323 +int (* copy_acl_ip_label)(struct acl_ip_label *ip, const struct acl_ip_label *userp) __read_only;
67324 +int (* copy_pointer_from_array)(void *ptr, unsigned long idx, const void *userp) __read_only;
67325 +int (* copy_sprole_pw)(struct sprole_pw *pw, unsigned long idx, const struct sprole_pw *userp) __read_only;
67326 +int (* copy_gr_hash_struct)(struct gr_hash_struct *hash, const struct gr_hash_struct *userp) __read_only;
67327 +int (* copy_role_transition)(struct role_transition *trans, const struct role_transition *userp) __read_only;
67328 +int (* copy_role_allowed_ip)(struct role_allowed_ip *roleip, const struct role_allowed_ip *userp) __read_only;
67329 +size_t (* get_gr_arg_wrapper_size)(void) __read_only;
67330 +
67331 +#else
67332 +#define copy_gr_arg_wrapper copy_gr_arg_wrapper_normal
67333 +#define copy_gr_arg copy_gr_arg_normal
67334 +#define copy_gr_hash_struct copy_gr_hash_struct_normal
67335 +#define copy_acl_object_label copy_acl_object_label_normal
67336 +#define copy_acl_subject_label copy_acl_subject_label_normal
67337 +#define copy_acl_role_label copy_acl_role_label_normal
67338 +#define copy_acl_ip_label copy_acl_ip_label_normal
67339 +#define copy_pointer_from_array copy_pointer_from_array_normal
67340 +#define copy_sprole_pw copy_sprole_pw_normal
67341 +#define copy_role_transition copy_role_transition_normal
67342 +#define copy_role_allowed_ip copy_role_allowed_ip_normal
67343 +#define get_gr_arg_wrapper_size get_gr_arg_wrapper_size_normal
67344 +#endif
67345 +
67346 +static struct acl_subject_label *
67347 +lookup_subject_map(const struct acl_subject_label *userp)
67348 +{
67349 + unsigned int index = gr_shash(userp, polstate->subj_map_set.s_size);
67350 + struct subject_map *match;
67351 +
67352 + match = polstate->subj_map_set.s_hash[index];
67353 +
67354 + while (match && match->user != userp)
67355 + match = match->next;
67356 +
67357 + if (match != NULL)
67358 + return match->kernel;
67359 + else
67360 + return NULL;
67361 +}
67362 +
67363 +static void
67364 +insert_subj_map_entry(struct subject_map *subjmap)
67365 +{
67366 + unsigned int index = gr_shash(subjmap->user, polstate->subj_map_set.s_size);
67367 + struct subject_map **curr;
67368 +
67369 + subjmap->prev = NULL;
67370 +
67371 + curr = &polstate->subj_map_set.s_hash[index];
67372 + if (*curr != NULL)
67373 + (*curr)->prev = subjmap;
67374 +
67375 + subjmap->next = *curr;
67376 + *curr = subjmap;
67377 +
67378 + return;
67379 +}
67380 +
67381 +static void
67382 +__insert_acl_role_label(struct acl_role_label *role, uid_t uidgid)
67383 +{
67384 + unsigned int index =
67385 + gr_rhash(uidgid, role->roletype & (GR_ROLE_USER | GR_ROLE_GROUP), polstate->acl_role_set.r_size);
67386 + struct acl_role_label **curr;
67387 + struct acl_role_label *tmp, *tmp2;
67388 +
67389 + curr = &polstate->acl_role_set.r_hash[index];
67390 +
67391 + /* simple case, slot is empty, just set it to our role */
67392 + if (*curr == NULL) {
67393 + *curr = role;
67394 + } else {
67395 + /* example:
67396 + 1 -> 2 -> 3 (adding 2 -> 3 to here)
67397 + 2 -> 3
67398 + */
67399 + /* first check to see if we can already be reached via this slot */
67400 + tmp = *curr;
67401 + while (tmp && tmp != role)
67402 + tmp = tmp->next;
67403 + if (tmp == role) {
67404 + /* we don't need to add ourselves to this slot's chain */
67405 + return;
67406 + }
67407 + /* we need to add ourselves to this chain, two cases */
67408 + if (role->next == NULL) {
67409 + /* simple case, append the current chain to our role */
67410 + role->next = *curr;
67411 + *curr = role;
67412 + } else {
67413 + /* 1 -> 2 -> 3 -> 4
67414 + 2 -> 3 -> 4
67415 + 3 -> 4 (adding 1 -> 2 -> 3 -> 4 to here)
67416 + */
67417 + /* trickier case: walk our role's chain until we find
67418 + the role for the start of the current slot's chain */
67419 + tmp = role;
67420 + tmp2 = *curr;
67421 + while (tmp->next && tmp->next != tmp2)
67422 + tmp = tmp->next;
67423 + if (tmp->next == tmp2) {
67424 + /* from example above, we found 3, so just
67425 + replace this slot's chain with ours */
67426 + *curr = role;
67427 + } else {
67428 + /* we didn't find a subset of our role's chain
67429 + in the current slot's chain, so append their
67430 + chain to ours, and set us as the first role in
67431 + the slot's chain
67432 +
67433 + we could fold this case with the case above,
67434 + but making it explicit for clarity
67435 + */
67436 + tmp->next = tmp2;
67437 + *curr = role;
67438 + }
67439 + }
67440 + }
67441 +
67442 + return;
67443 +}
67444 +
67445 +static void
67446 +insert_acl_role_label(struct acl_role_label *role)
67447 +{
67448 + int i;
67449 +
67450 + if (polstate->role_list == NULL) {
67451 + polstate->role_list = role;
67452 + role->prev = NULL;
67453 + } else {
67454 + role->prev = polstate->role_list;
67455 + polstate->role_list = role;
67456 + }
67457 +
67458 + /* used for hash chains */
67459 + role->next = NULL;
67460 +
67461 + if (role->roletype & GR_ROLE_DOMAIN) {
67462 + for (i = 0; i < role->domain_child_num; i++)
67463 + __insert_acl_role_label(role, role->domain_children[i]);
67464 + } else
67465 + __insert_acl_role_label(role, role->uidgid);
67466 +}
67467 +
67468 +static int
67469 +insert_name_entry(char *name, const ino_t inode, const dev_t device, __u8 deleted)
67470 +{
67471 + struct name_entry **curr, *nentry;
67472 + struct inodev_entry *ientry;
67473 + unsigned int len = strlen(name);
67474 + unsigned int key = full_name_hash(name, len);
67475 + unsigned int index = key % polstate->name_set.n_size;
67476 +
67477 + curr = &polstate->name_set.n_hash[index];
67478 +
67479 + while (*curr && ((*curr)->key != key || !gr_streq((*curr)->name, name, (*curr)->len, len)))
67480 + curr = &((*curr)->next);
67481 +
67482 + if (*curr != NULL)
67483 + return 1;
67484 +
67485 + nentry = acl_alloc(sizeof (struct name_entry));
67486 + if (nentry == NULL)
67487 + return 0;
67488 + ientry = acl_alloc(sizeof (struct inodev_entry));
67489 + if (ientry == NULL)
67490 + return 0;
67491 + ientry->nentry = nentry;
67492 +
67493 + nentry->key = key;
67494 + nentry->name = name;
67495 + nentry->inode = inode;
67496 + nentry->device = device;
67497 + nentry->len = len;
67498 + nentry->deleted = deleted;
67499 +
67500 + nentry->prev = NULL;
67501 + curr = &polstate->name_set.n_hash[index];
67502 + if (*curr != NULL)
67503 + (*curr)->prev = nentry;
67504 + nentry->next = *curr;
67505 + *curr = nentry;
67506 +
67507 + /* insert us into the table searchable by inode/dev */
67508 + __insert_inodev_entry(polstate, ientry);
67509 +
67510 + return 1;
67511 +}
67512 +
67513 +/* allocating chained hash tables, so optimal size is where lambda ~ 1 */
67514 +
67515 +static void *
67516 +create_table(__u32 * len, int elementsize)
67517 +{
67518 + unsigned int table_sizes[] = {
67519 + 7, 13, 31, 61, 127, 251, 509, 1021, 2039, 4093, 8191, 16381,
67520 + 32749, 65521, 131071, 262139, 524287, 1048573, 2097143,
67521 + 4194301, 8388593, 16777213, 33554393, 67108859
67522 + };
67523 + void *newtable = NULL;
67524 + unsigned int pwr = 0;
67525 +
67526 + while ((pwr < ((sizeof (table_sizes) / sizeof (table_sizes[0])) - 1)) &&
67527 + table_sizes[pwr] <= *len)
67528 + pwr++;
67529 +
67530 + if (table_sizes[pwr] <= *len || (table_sizes[pwr] > ULONG_MAX / elementsize))
67531 + return newtable;
67532 +
67533 + if ((table_sizes[pwr] * elementsize) <= PAGE_SIZE)
67534 + newtable =
67535 + kmalloc(table_sizes[pwr] * elementsize, GFP_KERNEL);
67536 + else
67537 + newtable = vmalloc(table_sizes[pwr] * elementsize);
67538 +
67539 + *len = table_sizes[pwr];
67540 +
67541 + return newtable;
67542 +}
67543 +
67544 +static int
67545 +init_variables(const struct gr_arg *arg, bool reload)
67546 +{
67547 + struct task_struct *reaper = init_pid_ns.child_reaper;
67548 + unsigned int stacksize;
67549 +
67550 + polstate->subj_map_set.s_size = arg->role_db.num_subjects;
67551 + polstate->acl_role_set.r_size = arg->role_db.num_roles + arg->role_db.num_domain_children;
67552 + polstate->name_set.n_size = arg->role_db.num_objects;
67553 + polstate->inodev_set.i_size = arg->role_db.num_objects;
67554 +
67555 + if (!polstate->subj_map_set.s_size || !polstate->acl_role_set.r_size ||
67556 + !polstate->name_set.n_size || !polstate->inodev_set.i_size)
67557 + return 1;
67558 +
67559 + if (!reload) {
67560 + if (!gr_init_uidset())
67561 + return 1;
67562 + }
67563 +
67564 + /* set up the stack that holds allocation info */
67565 +
67566 + stacksize = arg->role_db.num_pointers + 5;
67567 +
67568 + if (!acl_alloc_stack_init(stacksize))
67569 + return 1;
67570 +
67571 + if (!reload) {
67572 + /* grab reference for the real root dentry and vfsmount */
67573 + get_fs_root(reaper->fs, &gr_real_root);
67574 +
67575 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
67576 + 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);
67577 +#endif
67578 +
67579 + fakefs_obj_rw = acl_alloc(sizeof(struct acl_object_label));
67580 + if (fakefs_obj_rw == NULL)
67581 + return 1;
67582 + fakefs_obj_rw->mode = GR_FIND | GR_READ | GR_WRITE;
67583 +
67584 + fakefs_obj_rwx = acl_alloc(sizeof(struct acl_object_label));
67585 + if (fakefs_obj_rwx == NULL)
67586 + return 1;
67587 + fakefs_obj_rwx->mode = GR_FIND | GR_READ | GR_WRITE | GR_EXEC;
67588 + }
67589 +
67590 + polstate->subj_map_set.s_hash =
67591 + (struct subject_map **) create_table(&polstate->subj_map_set.s_size, sizeof(void *));
67592 + polstate->acl_role_set.r_hash =
67593 + (struct acl_role_label **) create_table(&polstate->acl_role_set.r_size, sizeof(void *));
67594 + polstate->name_set.n_hash = (struct name_entry **) create_table(&polstate->name_set.n_size, sizeof(void *));
67595 + polstate->inodev_set.i_hash =
67596 + (struct inodev_entry **) create_table(&polstate->inodev_set.i_size, sizeof(void *));
67597 +
67598 + if (!polstate->subj_map_set.s_hash || !polstate->acl_role_set.r_hash ||
67599 + !polstate->name_set.n_hash || !polstate->inodev_set.i_hash)
67600 + return 1;
67601 +
67602 + memset(polstate->subj_map_set.s_hash, 0,
67603 + sizeof(struct subject_map *) * polstate->subj_map_set.s_size);
67604 + memset(polstate->acl_role_set.r_hash, 0,
67605 + sizeof (struct acl_role_label *) * polstate->acl_role_set.r_size);
67606 + memset(polstate->name_set.n_hash, 0,
67607 + sizeof (struct name_entry *) * polstate->name_set.n_size);
67608 + memset(polstate->inodev_set.i_hash, 0,
67609 + sizeof (struct inodev_entry *) * polstate->inodev_set.i_size);
67610 +
67611 + return 0;
67612 +}
67613 +
67614 +/* free information not needed after startup
67615 + currently contains user->kernel pointer mappings for subjects
67616 +*/
67617 +
67618 +static void
67619 +free_init_variables(void)
67620 +{
67621 + __u32 i;
67622 +
67623 + if (polstate->subj_map_set.s_hash) {
67624 + for (i = 0; i < polstate->subj_map_set.s_size; i++) {
67625 + if (polstate->subj_map_set.s_hash[i]) {
67626 + kfree(polstate->subj_map_set.s_hash[i]);
67627 + polstate->subj_map_set.s_hash[i] = NULL;
67628 + }
67629 + }
67630 +
67631 + if ((polstate->subj_map_set.s_size * sizeof (struct subject_map *)) <=
67632 + PAGE_SIZE)
67633 + kfree(polstate->subj_map_set.s_hash);
67634 + else
67635 + vfree(polstate->subj_map_set.s_hash);
67636 + }
67637 +
67638 + return;
67639 +}
67640 +
67641 +static void
67642 +free_variables(bool reload)
67643 +{
67644 + struct acl_subject_label *s;
67645 + struct acl_role_label *r;
67646 + struct task_struct *task, *task2;
67647 + unsigned int x;
67648 +
67649 + if (!reload) {
67650 + gr_clear_learn_entries();
67651 +
67652 + read_lock(&tasklist_lock);
67653 + do_each_thread(task2, task) {
67654 + task->acl_sp_role = 0;
67655 + task->acl_role_id = 0;
67656 + task->inherited = 0;
67657 + task->acl = NULL;
67658 + task->role = NULL;
67659 + } while_each_thread(task2, task);
67660 + read_unlock(&tasklist_lock);
67661 +
67662 + /* release the reference to the real root dentry and vfsmount */
67663 + path_put(&gr_real_root);
67664 + memset(&gr_real_root, 0, sizeof(gr_real_root));
67665 + }
67666 +
67667 + /* free all object hash tables */
67668 +
67669 + FOR_EACH_ROLE_START(r)
67670 + if (r->subj_hash == NULL)
67671 + goto next_role;
67672 + FOR_EACH_SUBJECT_START(r, s, x)
67673 + if (s->obj_hash == NULL)
67674 + break;
67675 + if ((s->obj_hash_size * sizeof (struct acl_object_label *)) <= PAGE_SIZE)
67676 + kfree(s->obj_hash);
67677 + else
67678 + vfree(s->obj_hash);
67679 + FOR_EACH_SUBJECT_END(s, x)
67680 + FOR_EACH_NESTED_SUBJECT_START(r, s)
67681 + if (s->obj_hash == NULL)
67682 + break;
67683 + if ((s->obj_hash_size * sizeof (struct acl_object_label *)) <= PAGE_SIZE)
67684 + kfree(s->obj_hash);
67685 + else
67686 + vfree(s->obj_hash);
67687 + FOR_EACH_NESTED_SUBJECT_END(s)
67688 + if ((r->subj_hash_size * sizeof (struct acl_subject_label *)) <= PAGE_SIZE)
67689 + kfree(r->subj_hash);
67690 + else
67691 + vfree(r->subj_hash);
67692 + r->subj_hash = NULL;
67693 +next_role:
67694 + FOR_EACH_ROLE_END(r)
67695 +
67696 + acl_free_all();
67697 +
67698 + if (polstate->acl_role_set.r_hash) {
67699 + if ((polstate->acl_role_set.r_size * sizeof (struct acl_role_label *)) <=
67700 + PAGE_SIZE)
67701 + kfree(polstate->acl_role_set.r_hash);
67702 + else
67703 + vfree(polstate->acl_role_set.r_hash);
67704 + }
67705 + if (polstate->name_set.n_hash) {
67706 + if ((polstate->name_set.n_size * sizeof (struct name_entry *)) <=
67707 + PAGE_SIZE)
67708 + kfree(polstate->name_set.n_hash);
67709 + else
67710 + vfree(polstate->name_set.n_hash);
67711 + }
67712 +
67713 + if (polstate->inodev_set.i_hash) {
67714 + if ((polstate->inodev_set.i_size * sizeof (struct inodev_entry *)) <=
67715 + PAGE_SIZE)
67716 + kfree(polstate->inodev_set.i_hash);
67717 + else
67718 + vfree(polstate->inodev_set.i_hash);
67719 + }
67720 +
67721 + if (!reload)
67722 + gr_free_uidset();
67723 +
67724 + memset(&polstate->name_set, 0, sizeof (struct name_db));
67725 + memset(&polstate->inodev_set, 0, sizeof (struct inodev_db));
67726 + memset(&polstate->acl_role_set, 0, sizeof (struct acl_role_db));
67727 + memset(&polstate->subj_map_set, 0, sizeof (struct acl_subj_map_db));
67728 +
67729 + polstate->default_role = NULL;
67730 + polstate->kernel_role = NULL;
67731 + polstate->role_list = NULL;
67732 +
67733 + return;
67734 +}
67735 +
67736 +static struct acl_subject_label *
67737 +do_copy_user_subj(struct acl_subject_label *userp, struct acl_role_label *role, int *already_copied);
67738 +
67739 +static int alloc_and_copy_string(char **name, unsigned int maxlen)
67740 +{
67741 + unsigned int len = strnlen_user(*name, maxlen);
67742 + char *tmp;
67743 +
67744 + if (!len || len >= maxlen)
67745 + return -EINVAL;
67746 +
67747 + if ((tmp = (char *) acl_alloc(len)) == NULL)
67748 + return -ENOMEM;
67749 +
67750 + if (copy_from_user(tmp, *name, len))
67751 + return -EFAULT;
67752 +
67753 + tmp[len-1] = '\0';
67754 + *name = tmp;
67755 +
67756 + return 0;
67757 +}
67758 +
67759 +static int
67760 +copy_user_glob(struct acl_object_label *obj)
67761 +{
67762 + struct acl_object_label *g_tmp, **guser;
67763 + int error;
67764 +
67765 + if (obj->globbed == NULL)
67766 + return 0;
67767 +
67768 + guser = &obj->globbed;
67769 + while (*guser) {
67770 + g_tmp = (struct acl_object_label *)
67771 + acl_alloc(sizeof (struct acl_object_label));
67772 + if (g_tmp == NULL)
67773 + return -ENOMEM;
67774 +
67775 + if (copy_acl_object_label(g_tmp, *guser))
67776 + return -EFAULT;
67777 +
67778 + error = alloc_and_copy_string(&g_tmp->filename, PATH_MAX);
67779 + if (error)
67780 + return error;
67781 +
67782 + *guser = g_tmp;
67783 + guser = &(g_tmp->next);
67784 + }
67785 +
67786 + return 0;
67787 +}
67788 +
67789 +static int
67790 +copy_user_objs(struct acl_object_label *userp, struct acl_subject_label *subj,
67791 + struct acl_role_label *role)
67792 +{
67793 + struct acl_object_label *o_tmp;
67794 + int ret;
67795 +
67796 + while (userp) {
67797 + if ((o_tmp = (struct acl_object_label *)
67798 + acl_alloc(sizeof (struct acl_object_label))) == NULL)
67799 + return -ENOMEM;
67800 +
67801 + if (copy_acl_object_label(o_tmp, userp))
67802 + return -EFAULT;
67803 +
67804 + userp = o_tmp->prev;
67805 +
67806 + ret = alloc_and_copy_string(&o_tmp->filename, PATH_MAX);
67807 + if (ret)
67808 + return ret;
67809 +
67810 + insert_acl_obj_label(o_tmp, subj);
67811 + if (!insert_name_entry(o_tmp->filename, o_tmp->inode,
67812 + o_tmp->device, (o_tmp->mode & GR_DELETED) ? 1 : 0))
67813 + return -ENOMEM;
67814 +
67815 + ret = copy_user_glob(o_tmp);
67816 + if (ret)
67817 + return ret;
67818 +
67819 + if (o_tmp->nested) {
67820 + int already_copied;
67821 +
67822 + o_tmp->nested = do_copy_user_subj(o_tmp->nested, role, &already_copied);
67823 + if (IS_ERR(o_tmp->nested))
67824 + return PTR_ERR(o_tmp->nested);
67825 +
67826 + /* insert into nested subject list if we haven't copied this one yet
67827 + to prevent duplicate entries */
67828 + if (!already_copied) {
67829 + o_tmp->nested->next = role->hash->first;
67830 + role->hash->first = o_tmp->nested;
67831 + }
67832 + }
67833 + }
67834 +
67835 + return 0;
67836 +}
67837 +
67838 +static __u32
67839 +count_user_subjs(struct acl_subject_label *userp)
67840 +{
67841 + struct acl_subject_label s_tmp;
67842 + __u32 num = 0;
67843 +
67844 + while (userp) {
67845 + if (copy_acl_subject_label(&s_tmp, userp))
67846 + break;
67847 +
67848 + userp = s_tmp.prev;
67849 + }
67850 +
67851 + return num;
67852 +}
67853 +
67854 +static int
67855 +copy_user_allowedips(struct acl_role_label *rolep)
67856 +{
67857 + struct role_allowed_ip *ruserip, *rtmp = NULL, *rlast;
67858 +
67859 + ruserip = rolep->allowed_ips;
67860 +
67861 + while (ruserip) {
67862 + rlast = rtmp;
67863 +
67864 + if ((rtmp = (struct role_allowed_ip *)
67865 + acl_alloc(sizeof (struct role_allowed_ip))) == NULL)
67866 + return -ENOMEM;
67867 +
67868 + if (copy_role_allowed_ip(rtmp, ruserip))
67869 + return -EFAULT;
67870 +
67871 + ruserip = rtmp->prev;
67872 +
67873 + if (!rlast) {
67874 + rtmp->prev = NULL;
67875 + rolep->allowed_ips = rtmp;
67876 + } else {
67877 + rlast->next = rtmp;
67878 + rtmp->prev = rlast;
67879 + }
67880 +
67881 + if (!ruserip)
67882 + rtmp->next = NULL;
67883 + }
67884 +
67885 + return 0;
67886 +}
67887 +
67888 +static int
67889 +copy_user_transitions(struct acl_role_label *rolep)
67890 +{
67891 + struct role_transition *rusertp, *rtmp = NULL, *rlast;
67892 + int error;
67893 +
67894 + rusertp = rolep->transitions;
67895 +
67896 + while (rusertp) {
67897 + rlast = rtmp;
67898 +
67899 + if ((rtmp = (struct role_transition *)
67900 + acl_alloc(sizeof (struct role_transition))) == NULL)
67901 + return -ENOMEM;
67902 +
67903 + if (copy_role_transition(rtmp, rusertp))
67904 + return -EFAULT;
67905 +
67906 + rusertp = rtmp->prev;
67907 +
67908 + error = alloc_and_copy_string(&rtmp->rolename, GR_SPROLE_LEN);
67909 + if (error)
67910 + return error;
67911 +
67912 + if (!rlast) {
67913 + rtmp->prev = NULL;
67914 + rolep->transitions = rtmp;
67915 + } else {
67916 + rlast->next = rtmp;
67917 + rtmp->prev = rlast;
67918 + }
67919 +
67920 + if (!rusertp)
67921 + rtmp->next = NULL;
67922 + }
67923 +
67924 + return 0;
67925 +}
67926 +
67927 +static __u32 count_user_objs(const struct acl_object_label __user *userp)
67928 +{
67929 + struct acl_object_label o_tmp;
67930 + __u32 num = 0;
67931 +
67932 + while (userp) {
67933 + if (copy_acl_object_label(&o_tmp, userp))
67934 + break;
67935 +
67936 + userp = o_tmp.prev;
67937 + num++;
67938 + }
67939 +
67940 + return num;
67941 +}
67942 +
67943 +static struct acl_subject_label *
67944 +do_copy_user_subj(struct acl_subject_label *userp, struct acl_role_label *role, int *already_copied)
67945 +{
67946 + struct acl_subject_label *s_tmp = NULL, *s_tmp2;
67947 + __u32 num_objs;
67948 + struct acl_ip_label **i_tmp, *i_utmp2;
67949 + struct gr_hash_struct ghash;
67950 + struct subject_map *subjmap;
67951 + unsigned int i_num;
67952 + int err;
67953 +
67954 + if (already_copied != NULL)
67955 + *already_copied = 0;
67956 +
67957 + s_tmp = lookup_subject_map(userp);
67958 +
67959 + /* we've already copied this subject into the kernel, just return
67960 + the reference to it, and don't copy it over again
67961 + */
67962 + if (s_tmp) {
67963 + if (already_copied != NULL)
67964 + *already_copied = 1;
67965 + return(s_tmp);
67966 + }
67967 +
67968 + if ((s_tmp = (struct acl_subject_label *)
67969 + acl_alloc(sizeof (struct acl_subject_label))) == NULL)
67970 + return ERR_PTR(-ENOMEM);
67971 +
67972 + subjmap = (struct subject_map *)kmalloc(sizeof (struct subject_map), GFP_KERNEL);
67973 + if (subjmap == NULL)
67974 + return ERR_PTR(-ENOMEM);
67975 +
67976 + subjmap->user = userp;
67977 + subjmap->kernel = s_tmp;
67978 + insert_subj_map_entry(subjmap);
67979 +
67980 + if (copy_acl_subject_label(s_tmp, userp))
67981 + return ERR_PTR(-EFAULT);
67982 +
67983 + err = alloc_and_copy_string(&s_tmp->filename, PATH_MAX);
67984 + if (err)
67985 + return ERR_PTR(err);
67986 +
67987 + if (!strcmp(s_tmp->filename, "/"))
67988 + role->root_label = s_tmp;
67989 +
67990 + if (copy_gr_hash_struct(&ghash, s_tmp->hash))
67991 + return ERR_PTR(-EFAULT);
67992 +
67993 + /* copy user and group transition tables */
67994 +
67995 + if (s_tmp->user_trans_num) {
67996 + uid_t *uidlist;
67997 +
67998 + uidlist = (uid_t *)acl_alloc_num(s_tmp->user_trans_num, sizeof(uid_t));
67999 + if (uidlist == NULL)
68000 + return ERR_PTR(-ENOMEM);
68001 + if (copy_from_user(uidlist, s_tmp->user_transitions, s_tmp->user_trans_num * sizeof(uid_t)))
68002 + return ERR_PTR(-EFAULT);
68003 +
68004 + s_tmp->user_transitions = uidlist;
68005 + }
68006 +
68007 + if (s_tmp->group_trans_num) {
68008 + gid_t *gidlist;
68009 +
68010 + gidlist = (gid_t *)acl_alloc_num(s_tmp->group_trans_num, sizeof(gid_t));
68011 + if (gidlist == NULL)
68012 + return ERR_PTR(-ENOMEM);
68013 + if (copy_from_user(gidlist, s_tmp->group_transitions, s_tmp->group_trans_num * sizeof(gid_t)))
68014 + return ERR_PTR(-EFAULT);
68015 +
68016 + s_tmp->group_transitions = gidlist;
68017 + }
68018 +
68019 + /* set up object hash table */
68020 + num_objs = count_user_objs(ghash.first);
68021 +
68022 + s_tmp->obj_hash_size = num_objs;
68023 + s_tmp->obj_hash =
68024 + (struct acl_object_label **)
68025 + create_table(&(s_tmp->obj_hash_size), sizeof(void *));
68026 +
68027 + if (!s_tmp->obj_hash)
68028 + return ERR_PTR(-ENOMEM);
68029 +
68030 + memset(s_tmp->obj_hash, 0,
68031 + s_tmp->obj_hash_size *
68032 + sizeof (struct acl_object_label *));
68033 +
68034 + /* add in objects */
68035 + err = copy_user_objs(ghash.first, s_tmp, role);
68036 +
68037 + if (err)
68038 + return ERR_PTR(err);
68039 +
68040 + /* set pointer for parent subject */
68041 + if (s_tmp->parent_subject) {
68042 + s_tmp2 = do_copy_user_subj(s_tmp->parent_subject, role, NULL);
68043 +
68044 + if (IS_ERR(s_tmp2))
68045 + return s_tmp2;
68046 +
68047 + s_tmp->parent_subject = s_tmp2;
68048 + }
68049 +
68050 + /* add in ip acls */
68051 +
68052 + if (!s_tmp->ip_num) {
68053 + s_tmp->ips = NULL;
68054 + goto insert;
68055 + }
68056 +
68057 + i_tmp =
68058 + (struct acl_ip_label **) acl_alloc_num(s_tmp->ip_num,
68059 + sizeof (struct acl_ip_label *));
68060 +
68061 + if (!i_tmp)
68062 + return ERR_PTR(-ENOMEM);
68063 +
68064 + for (i_num = 0; i_num < s_tmp->ip_num; i_num++) {
68065 + *(i_tmp + i_num) =
68066 + (struct acl_ip_label *)
68067 + acl_alloc(sizeof (struct acl_ip_label));
68068 + if (!*(i_tmp + i_num))
68069 + return ERR_PTR(-ENOMEM);
68070 +
68071 + if (copy_pointer_from_array(&i_utmp2, i_num, s_tmp->ips))
68072 + return ERR_PTR(-EFAULT);
68073 +
68074 + if (copy_acl_ip_label(*(i_tmp + i_num), i_utmp2))
68075 + return ERR_PTR(-EFAULT);
68076 +
68077 + if ((*(i_tmp + i_num))->iface == NULL)
68078 + continue;
68079 +
68080 + err = alloc_and_copy_string(&(*(i_tmp + i_num))->iface, IFNAMSIZ);
68081 + if (err)
68082 + return ERR_PTR(err);
68083 + }
68084 +
68085 + s_tmp->ips = i_tmp;
68086 +
68087 +insert:
68088 + if (!insert_name_entry(s_tmp->filename, s_tmp->inode,
68089 + s_tmp->device, (s_tmp->mode & GR_DELETED) ? 1 : 0))
68090 + return ERR_PTR(-ENOMEM);
68091 +
68092 + return s_tmp;
68093 +}
68094 +
68095 +static int
68096 +copy_user_subjs(struct acl_subject_label *userp, struct acl_role_label *role)
68097 +{
68098 + struct acl_subject_label s_pre;
68099 + struct acl_subject_label * ret;
68100 + int err;
68101 +
68102 + while (userp) {
68103 + if (copy_acl_subject_label(&s_pre, userp))
68104 + return -EFAULT;
68105 +
68106 + ret = do_copy_user_subj(userp, role, NULL);
68107 +
68108 + err = PTR_ERR(ret);
68109 + if (IS_ERR(ret))
68110 + return err;
68111 +
68112 + insert_acl_subj_label(ret, role);
68113 +
68114 + userp = s_pre.prev;
68115 + }
68116 +
68117 + return 0;
68118 +}
68119 +
68120 +static int
68121 +copy_user_acl(struct gr_arg *arg)
68122 +{
68123 + struct acl_role_label *r_tmp = NULL, **r_utmp, *r_utmp2;
68124 + struct acl_subject_label *subj_list;
68125 + struct sprole_pw *sptmp;
68126 + struct gr_hash_struct *ghash;
68127 + uid_t *domainlist;
68128 + unsigned int r_num;
68129 + int err = 0;
68130 + __u16 i;
68131 + __u32 num_subjs;
68132 +
68133 + /* we need a default and kernel role */
68134 + if (arg->role_db.num_roles < 2)
68135 + return -EINVAL;
68136 +
68137 + /* copy special role authentication info from userspace */
68138 +
68139 + polstate->num_sprole_pws = arg->num_sprole_pws;
68140 + polstate->acl_special_roles = (struct sprole_pw **) acl_alloc_num(polstate->num_sprole_pws, sizeof(struct sprole_pw *));
68141 +
68142 + if (!polstate->acl_special_roles && polstate->num_sprole_pws)
68143 + return -ENOMEM;
68144 +
68145 + for (i = 0; i < polstate->num_sprole_pws; i++) {
68146 + sptmp = (struct sprole_pw *) acl_alloc(sizeof(struct sprole_pw));
68147 + if (!sptmp)
68148 + return -ENOMEM;
68149 + if (copy_sprole_pw(sptmp, i, arg->sprole_pws))
68150 + return -EFAULT;
68151 +
68152 + err = alloc_and_copy_string((char **)&sptmp->rolename, GR_SPROLE_LEN);
68153 + if (err)
68154 + return err;
68155 +
68156 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
68157 + printk(KERN_ALERT "Copying special role %s\n", sptmp->rolename);
68158 +#endif
68159 +
68160 + polstate->acl_special_roles[i] = sptmp;
68161 + }
68162 +
68163 + r_utmp = (struct acl_role_label **) arg->role_db.r_table;
68164 +
68165 + for (r_num = 0; r_num < arg->role_db.num_roles; r_num++) {
68166 + r_tmp = acl_alloc(sizeof (struct acl_role_label));
68167 +
68168 + if (!r_tmp)
68169 + return -ENOMEM;
68170 +
68171 + if (copy_pointer_from_array(&r_utmp2, r_num, r_utmp))
68172 + return -EFAULT;
68173 +
68174 + if (copy_acl_role_label(r_tmp, r_utmp2))
68175 + return -EFAULT;
68176 +
68177 + err = alloc_and_copy_string(&r_tmp->rolename, GR_SPROLE_LEN);
68178 + if (err)
68179 + return err;
68180 +
68181 + if (!strcmp(r_tmp->rolename, "default")
68182 + && (r_tmp->roletype & GR_ROLE_DEFAULT)) {
68183 + polstate->default_role = r_tmp;
68184 + } else if (!strcmp(r_tmp->rolename, ":::kernel:::")) {
68185 + polstate->kernel_role = r_tmp;
68186 + }
68187 +
68188 + if ((ghash = (struct gr_hash_struct *) acl_alloc(sizeof(struct gr_hash_struct))) == NULL)
68189 + return -ENOMEM;
68190 +
68191 + if (copy_gr_hash_struct(ghash, r_tmp->hash))
68192 + return -EFAULT;
68193 +
68194 + r_tmp->hash = ghash;
68195 +
68196 + num_subjs = count_user_subjs(r_tmp->hash->first);
68197 +
68198 + r_tmp->subj_hash_size = num_subjs;
68199 + r_tmp->subj_hash =
68200 + (struct acl_subject_label **)
68201 + create_table(&(r_tmp->subj_hash_size), sizeof(void *));
68202 +
68203 + if (!r_tmp->subj_hash)
68204 + return -ENOMEM;
68205 +
68206 + err = copy_user_allowedips(r_tmp);
68207 + if (err)
68208 + return err;
68209 +
68210 + /* copy domain info */
68211 + if (r_tmp->domain_children != NULL) {
68212 + domainlist = acl_alloc_num(r_tmp->domain_child_num, sizeof(uid_t));
68213 + if (domainlist == NULL)
68214 + return -ENOMEM;
68215 +
68216 + if (copy_from_user(domainlist, r_tmp->domain_children, r_tmp->domain_child_num * sizeof(uid_t)))
68217 + return -EFAULT;
68218 +
68219 + r_tmp->domain_children = domainlist;
68220 + }
68221 +
68222 + err = copy_user_transitions(r_tmp);
68223 + if (err)
68224 + return err;
68225 +
68226 + memset(r_tmp->subj_hash, 0,
68227 + r_tmp->subj_hash_size *
68228 + sizeof (struct acl_subject_label *));
68229 +
68230 + /* acquire the list of subjects, then NULL out
68231 + the list prior to parsing the subjects for this role,
68232 + as during this parsing the list is replaced with a list
68233 + of *nested* subjects for the role
68234 + */
68235 + subj_list = r_tmp->hash->first;
68236 +
68237 + /* set nested subject list to null */
68238 + r_tmp->hash->first = NULL;
68239 +
68240 + err = copy_user_subjs(subj_list, r_tmp);
68241 +
68242 + if (err)
68243 + return err;
68244 +
68245 + insert_acl_role_label(r_tmp);
68246 + }
68247 +
68248 + if (polstate->default_role == NULL || polstate->kernel_role == NULL)
68249 + return -EINVAL;
68250 +
68251 + return err;
68252 +}
68253 +
68254 +static int gracl_reload_apply_policies(void *reload)
68255 +{
68256 + struct gr_reload_state *reload_state = (struct gr_reload_state *)reload;
68257 + struct task_struct *task, *task2;
68258 + struct acl_role_label *role, *rtmp;
68259 + struct acl_subject_label *subj;
68260 + const struct cred *cred;
68261 + int role_applied;
68262 + int ret = 0;
68263 +
68264 + memcpy(&reload_state->oldpolicy, reload_state->oldpolicy_ptr, sizeof(struct gr_policy_state));
68265 + memcpy(&reload_state->oldalloc, reload_state->oldalloc_ptr, sizeof(struct gr_alloc_state));
68266 +
68267 + /* first make sure we'll be able to apply the new policy cleanly */
68268 + do_each_thread(task2, task) {
68269 + if (task->exec_file == NULL)
68270 + continue;
68271 + role_applied = 0;
68272 + if (!reload_state->oldmode && task->role->roletype & GR_ROLE_SPECIAL) {
68273 + /* preserve special roles */
68274 + FOR_EACH_ROLE_START(role)
68275 + if ((role->roletype & GR_ROLE_SPECIAL) && !strcmp(task->role->rolename, role->rolename)) {
68276 + rtmp = task->role;
68277 + task->role = role;
68278 + role_applied = 1;
68279 + break;
68280 + }
68281 + FOR_EACH_ROLE_END(role)
68282 + }
68283 + if (!role_applied) {
68284 + cred = __task_cred(task);
68285 + rtmp = task->role;
68286 + task->role = __lookup_acl_role_label(polstate, task, GR_GLOBAL_UID(cred->uid), GR_GLOBAL_GID(cred->gid));
68287 + }
68288 + /* this handles non-nested inherited subjects, nested subjects will still
68289 + be dropped currently */
68290 + subj = __gr_get_subject_for_task(polstate, task, task->acl->filename);
68291 + task->tmpacl = __gr_get_subject_for_task(polstate, task, NULL);
68292 + /* change the role back so that we've made no modifications to the policy */
68293 + task->role = rtmp;
68294 +
68295 + if (subj == NULL || task->tmpacl == NULL) {
68296 + ret = -EINVAL;
68297 + goto out;
68298 + }
68299 + } while_each_thread(task2, task);
68300 +
68301 + /* now actually apply the policy */
68302 +
68303 + do_each_thread(task2, task) {
68304 + if (task->exec_file) {
68305 + role_applied = 0;
68306 + if (!reload_state->oldmode && task->role->roletype & GR_ROLE_SPECIAL) {
68307 + /* preserve special roles */
68308 + FOR_EACH_ROLE_START(role)
68309 + if ((role->roletype & GR_ROLE_SPECIAL) && !strcmp(task->role->rolename, role->rolename)) {
68310 + task->role = role;
68311 + role_applied = 1;
68312 + break;
68313 + }
68314 + FOR_EACH_ROLE_END(role)
68315 + }
68316 + if (!role_applied) {
68317 + cred = __task_cred(task);
68318 + task->role = __lookup_acl_role_label(polstate, task, GR_GLOBAL_UID(cred->uid), GR_GLOBAL_GID(cred->gid));
68319 + }
68320 + /* this handles non-nested inherited subjects, nested subjects will still
68321 + be dropped currently */
68322 + if (!reload_state->oldmode && task->inherited)
68323 + subj = __gr_get_subject_for_task(polstate, task, task->acl->filename);
68324 + else {
68325 + /* looked up and tagged to the task previously */
68326 + subj = task->tmpacl;
68327 + }
68328 + /* subj will be non-null */
68329 + __gr_apply_subject_to_task(polstate, task, subj);
68330 + if (reload_state->oldmode) {
68331 + task->acl_role_id = 0;
68332 + task->acl_sp_role = 0;
68333 + task->inherited = 0;
68334 + }
68335 + } else {
68336 + // it's a kernel process
68337 + task->role = polstate->kernel_role;
68338 + task->acl = polstate->kernel_role->root_label;
68339 +#ifdef CONFIG_GRKERNSEC_ACL_HIDEKERN
68340 + task->acl->mode &= ~GR_PROCFIND;
68341 +#endif
68342 + }
68343 + } while_each_thread(task2, task);
68344 +
68345 + memcpy(reload_state->oldpolicy_ptr, &reload_state->newpolicy, sizeof(struct gr_policy_state));
68346 + memcpy(reload_state->oldalloc_ptr, &reload_state->newalloc, sizeof(struct gr_alloc_state));
68347 +
68348 +out:
68349 +
68350 + return ret;
68351 +}
68352 +
68353 +static int gracl_reload(struct gr_arg *args, unsigned char oldmode)
68354 +{
68355 + struct gr_reload_state new_reload_state = { };
68356 + int err;
68357 +
68358 + new_reload_state.oldpolicy_ptr = polstate;
68359 + new_reload_state.oldalloc_ptr = current_alloc_state;
68360 + new_reload_state.oldmode = oldmode;
68361 +
68362 + current_alloc_state = &new_reload_state.newalloc;
68363 + polstate = &new_reload_state.newpolicy;
68364 +
68365 + /* everything relevant is now saved off, copy in the new policy */
68366 + if (init_variables(args, true)) {
68367 + gr_log_str(GR_DONT_AUDIT_GOOD, GR_INITF_ACL_MSG, GR_VERSION);
68368 + err = -ENOMEM;
68369 + goto error;
68370 + }
68371 +
68372 + err = copy_user_acl(args);
68373 + free_init_variables();
68374 + if (err)
68375 + goto error;
68376 + /* the new policy is copied in, with the old policy available via saved_state
68377 + first go through applying roles, making sure to preserve special roles
68378 + then apply new subjects, making sure to preserve inherited and nested subjects,
68379 + though currently only inherited subjects will be preserved
68380 + */
68381 + err = stop_machine(gracl_reload_apply_policies, &new_reload_state, NULL);
68382 + if (err)
68383 + goto error;
68384 +
68385 + /* we've now applied the new policy, so restore the old policy state to free it */
68386 + polstate = &new_reload_state.oldpolicy;
68387 + current_alloc_state = &new_reload_state.oldalloc;
68388 + free_variables(true);
68389 +
68390 + /* oldpolicy/oldalloc_ptr point to the new policy/alloc states as they were copied
68391 + to running_polstate/current_alloc_state inside stop_machine
68392 + */
68393 + err = 0;
68394 + goto out;
68395 +error:
68396 + /* on error of loading the new policy, we'll just keep the previous
68397 + policy set around
68398 + */
68399 + free_variables(true);
68400 +
68401 + /* doesn't affect runtime, but maintains consistent state */
68402 +out:
68403 + polstate = new_reload_state.oldpolicy_ptr;
68404 + current_alloc_state = new_reload_state.oldalloc_ptr;
68405 +
68406 + return err;
68407 +}
68408 +
68409 +static int
68410 +gracl_init(struct gr_arg *args)
68411 +{
68412 + int error = 0;
68413 +
68414 + memcpy(&gr_system_salt, args->salt, sizeof(gr_system_salt));
68415 + memcpy(&gr_system_sum, args->sum, sizeof(gr_system_sum));
68416 +
68417 + if (init_variables(args, false)) {
68418 + gr_log_str(GR_DONT_AUDIT_GOOD, GR_INITF_ACL_MSG, GR_VERSION);
68419 + error = -ENOMEM;
68420 + goto out;
68421 + }
68422 +
68423 + error = copy_user_acl(args);
68424 + free_init_variables();
68425 + if (error)
68426 + goto out;
68427 +
68428 + error = gr_set_acls(0);
68429 + if (error)
68430 + goto out;
68431 +
68432 + gr_enable_rbac_system();
68433 +
68434 + return 0;
68435 +
68436 +out:
68437 + free_variables(false);
68438 + return error;
68439 +}
68440 +
68441 +static int
68442 +lookup_special_role_auth(__u16 mode, const char *rolename, unsigned char **salt,
68443 + unsigned char **sum)
68444 +{
68445 + struct acl_role_label *r;
68446 + struct role_allowed_ip *ipp;
68447 + struct role_transition *trans;
68448 + unsigned int i;
68449 + int found = 0;
68450 + u32 curr_ip = current->signal->curr_ip;
68451 +
68452 + current->signal->saved_ip = curr_ip;
68453 +
68454 + /* check transition table */
68455 +
68456 + for (trans = current->role->transitions; trans; trans = trans->next) {
68457 + if (!strcmp(rolename, trans->rolename)) {
68458 + found = 1;
68459 + break;
68460 + }
68461 + }
68462 +
68463 + if (!found)
68464 + return 0;
68465 +
68466 + /* handle special roles that do not require authentication
68467 + and check ip */
68468 +
68469 + FOR_EACH_ROLE_START(r)
68470 + if (!strcmp(rolename, r->rolename) &&
68471 + (r->roletype & GR_ROLE_SPECIAL)) {
68472 + found = 0;
68473 + if (r->allowed_ips != NULL) {
68474 + for (ipp = r->allowed_ips; ipp; ipp = ipp->next) {
68475 + if ((ntohl(curr_ip) & ipp->netmask) ==
68476 + (ntohl(ipp->addr) & ipp->netmask))
68477 + found = 1;
68478 + }
68479 + } else
68480 + found = 2;
68481 + if (!found)
68482 + return 0;
68483 +
68484 + if (((mode == GR_SPROLE) && (r->roletype & GR_ROLE_NOPW)) ||
68485 + ((mode == GR_SPROLEPAM) && (r->roletype & GR_ROLE_PAM))) {
68486 + *salt = NULL;
68487 + *sum = NULL;
68488 + return 1;
68489 + }
68490 + }
68491 + FOR_EACH_ROLE_END(r)
68492 +
68493 + for (i = 0; i < polstate->num_sprole_pws; i++) {
68494 + if (!strcmp(rolename, polstate->acl_special_roles[i]->rolename)) {
68495 + *salt = polstate->acl_special_roles[i]->salt;
68496 + *sum = polstate->acl_special_roles[i]->sum;
68497 + return 1;
68498 + }
68499 + }
68500 +
68501 + return 0;
68502 +}
68503 +
68504 +int gr_check_secure_terminal(struct task_struct *task)
68505 +{
68506 + struct task_struct *p, *p2, *p3;
68507 + struct files_struct *files;
68508 + struct fdtable *fdt;
68509 + struct file *our_file = NULL, *file;
68510 + int i;
68511 +
68512 + if (task->signal->tty == NULL)
68513 + return 1;
68514 +
68515 + files = get_files_struct(task);
68516 + if (files != NULL) {
68517 + rcu_read_lock();
68518 + fdt = files_fdtable(files);
68519 + for (i=0; i < fdt->max_fds; i++) {
68520 + file = fcheck_files(files, i);
68521 + if (file && (our_file == NULL) && (file->private_data == task->signal->tty)) {
68522 + get_file(file);
68523 + our_file = file;
68524 + }
68525 + }
68526 + rcu_read_unlock();
68527 + put_files_struct(files);
68528 + }
68529 +
68530 + if (our_file == NULL)
68531 + return 1;
68532 +
68533 + read_lock(&tasklist_lock);
68534 + do_each_thread(p2, p) {
68535 + files = get_files_struct(p);
68536 + if (files == NULL ||
68537 + (p->signal && p->signal->tty == task->signal->tty)) {
68538 + if (files != NULL)
68539 + put_files_struct(files);
68540 + continue;
68541 + }
68542 + rcu_read_lock();
68543 + fdt = files_fdtable(files);
68544 + for (i=0; i < fdt->max_fds; i++) {
68545 + file = fcheck_files(files, i);
68546 + if (file && S_ISCHR(file->f_path.dentry->d_inode->i_mode) &&
68547 + file->f_path.dentry->d_inode->i_rdev == our_file->f_path.dentry->d_inode->i_rdev) {
68548 + p3 = task;
68549 + while (task_pid_nr(p3) > 0) {
68550 + if (p3 == p)
68551 + break;
68552 + p3 = p3->real_parent;
68553 + }
68554 + if (p3 == p)
68555 + break;
68556 + gr_log_ttysniff(GR_DONT_AUDIT_GOOD, GR_TTYSNIFF_ACL_MSG, p);
68557 + gr_handle_alertkill(p);
68558 + rcu_read_unlock();
68559 + put_files_struct(files);
68560 + read_unlock(&tasklist_lock);
68561 + fput(our_file);
68562 + return 0;
68563 + }
68564 + }
68565 + rcu_read_unlock();
68566 + put_files_struct(files);
68567 + } while_each_thread(p2, p);
68568 + read_unlock(&tasklist_lock);
68569 +
68570 + fput(our_file);
68571 + return 1;
68572 +}
68573 +
68574 +ssize_t
68575 +write_grsec_handler(struct file *file, const char __user * buf, size_t count, loff_t *ppos)
68576 +{
68577 + struct gr_arg_wrapper uwrap;
68578 + unsigned char *sprole_salt = NULL;
68579 + unsigned char *sprole_sum = NULL;
68580 + int error = 0;
68581 + int error2 = 0;
68582 + size_t req_count = 0;
68583 + unsigned char oldmode = 0;
68584 +
68585 + mutex_lock(&gr_dev_mutex);
68586 +
68587 + if (gr_acl_is_enabled() && !(current->acl->mode & GR_KERNELAUTH)) {
68588 + error = -EPERM;
68589 + goto out;
68590 + }
68591 +
68592 +#ifdef CONFIG_COMPAT
68593 + pax_open_kernel();
68594 + if (is_compat_task()) {
68595 + copy_gr_arg_wrapper = &copy_gr_arg_wrapper_compat;
68596 + copy_gr_arg = &copy_gr_arg_compat;
68597 + copy_acl_object_label = &copy_acl_object_label_compat;
68598 + copy_acl_subject_label = &copy_acl_subject_label_compat;
68599 + copy_acl_role_label = &copy_acl_role_label_compat;
68600 + copy_acl_ip_label = &copy_acl_ip_label_compat;
68601 + copy_role_allowed_ip = &copy_role_allowed_ip_compat;
68602 + copy_role_transition = &copy_role_transition_compat;
68603 + copy_sprole_pw = &copy_sprole_pw_compat;
68604 + copy_gr_hash_struct = &copy_gr_hash_struct_compat;
68605 + copy_pointer_from_array = &copy_pointer_from_array_compat;
68606 + get_gr_arg_wrapper_size = &get_gr_arg_wrapper_size_compat;
68607 + } else {
68608 + copy_gr_arg_wrapper = &copy_gr_arg_wrapper_normal;
68609 + copy_gr_arg = &copy_gr_arg_normal;
68610 + copy_acl_object_label = &copy_acl_object_label_normal;
68611 + copy_acl_subject_label = &copy_acl_subject_label_normal;
68612 + copy_acl_role_label = &copy_acl_role_label_normal;
68613 + copy_acl_ip_label = &copy_acl_ip_label_normal;
68614 + copy_role_allowed_ip = &copy_role_allowed_ip_normal;
68615 + copy_role_transition = &copy_role_transition_normal;
68616 + copy_sprole_pw = &copy_sprole_pw_normal;
68617 + copy_gr_hash_struct = &copy_gr_hash_struct_normal;
68618 + copy_pointer_from_array = &copy_pointer_from_array_normal;
68619 + get_gr_arg_wrapper_size = &get_gr_arg_wrapper_size_normal;
68620 + }
68621 + pax_close_kernel();
68622 +#endif
68623 +
68624 + req_count = get_gr_arg_wrapper_size();
68625 +
68626 + if (count != req_count) {
68627 + gr_log_int_int(GR_DONT_AUDIT_GOOD, GR_DEV_ACL_MSG, (int)count, (int)req_count);
68628 + error = -EINVAL;
68629 + goto out;
68630 + }
68631 +
68632 +
68633 + if (gr_auth_expires && time_after_eq(get_seconds(), gr_auth_expires)) {
68634 + gr_auth_expires = 0;
68635 + gr_auth_attempts = 0;
68636 + }
68637 +
68638 + error = copy_gr_arg_wrapper(buf, &uwrap);
68639 + if (error)
68640 + goto out;
68641 +
68642 + error = copy_gr_arg(uwrap.arg, &gr_usermode);
68643 + if (error)
68644 + goto out;
68645 +
68646 + if (gr_usermode.mode != GR_SPROLE && gr_usermode.mode != GR_SPROLEPAM &&
68647 + gr_auth_attempts >= CONFIG_GRKERNSEC_ACL_MAXTRIES &&
68648 + time_after(gr_auth_expires, get_seconds())) {
68649 + error = -EBUSY;
68650 + goto out;
68651 + }
68652 +
68653 + /* if non-root trying to do anything other than use a special role,
68654 + do not attempt authentication, do not count towards authentication
68655 + locking
68656 + */
68657 +
68658 + if (gr_usermode.mode != GR_SPROLE && gr_usermode.mode != GR_STATUS &&
68659 + gr_usermode.mode != GR_UNSPROLE && gr_usermode.mode != GR_SPROLEPAM &&
68660 + gr_is_global_nonroot(current_uid())) {
68661 + error = -EPERM;
68662 + goto out;
68663 + }
68664 +
68665 + /* ensure pw and special role name are null terminated */
68666 +
68667 + gr_usermode.pw[GR_PW_LEN - 1] = '\0';
68668 + gr_usermode.sp_role[GR_SPROLE_LEN - 1] = '\0';
68669 +
68670 + /* Okay.
68671 + * We have our enough of the argument structure..(we have yet
68672 + * to copy_from_user the tables themselves) . Copy the tables
68673 + * only if we need them, i.e. for loading operations. */
68674 +
68675 + switch (gr_usermode.mode) {
68676 + case GR_STATUS:
68677 + if (gr_acl_is_enabled()) {
68678 + error = 1;
68679 + if (!gr_check_secure_terminal(current))
68680 + error = 3;
68681 + } else
68682 + error = 2;
68683 + goto out;
68684 + case GR_SHUTDOWN:
68685 + if (gr_acl_is_enabled() && !(chkpw(&gr_usermode, (unsigned char *)&gr_system_salt, (unsigned char *)&gr_system_sum))) {
68686 + stop_machine(gr_rbac_disable, NULL, NULL);
68687 + free_variables(false);
68688 + memset(&gr_usermode, 0, sizeof(gr_usermode));
68689 + memset(&gr_system_salt, 0, sizeof(gr_system_salt));
68690 + memset(&gr_system_sum, 0, sizeof(gr_system_sum));
68691 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_SHUTS_ACL_MSG);
68692 + } else if (gr_acl_is_enabled()) {
68693 + gr_log_noargs(GR_DONT_AUDIT, GR_SHUTF_ACL_MSG);
68694 + error = -EPERM;
68695 + } else {
68696 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_SHUTI_ACL_MSG);
68697 + error = -EAGAIN;
68698 + }
68699 + break;
68700 + case GR_ENABLE:
68701 + if (!gr_acl_is_enabled() && !(error2 = gracl_init(&gr_usermode)))
68702 + gr_log_str(GR_DONT_AUDIT_GOOD, GR_ENABLE_ACL_MSG, GR_VERSION);
68703 + else {
68704 + if (gr_acl_is_enabled())
68705 + error = -EAGAIN;
68706 + else
68707 + error = error2;
68708 + gr_log_str(GR_DONT_AUDIT, GR_ENABLEF_ACL_MSG, GR_VERSION);
68709 + }
68710 + break;
68711 + case GR_OLDRELOAD:
68712 + oldmode = 1;
68713 + case GR_RELOAD:
68714 + if (!gr_acl_is_enabled()) {
68715 + gr_log_str(GR_DONT_AUDIT_GOOD, GR_RELOADI_ACL_MSG, GR_VERSION);
68716 + error = -EAGAIN;
68717 + } else if (!(chkpw(&gr_usermode, (unsigned char *)&gr_system_salt, (unsigned char *)&gr_system_sum))) {
68718 + error2 = gracl_reload(&gr_usermode, oldmode);
68719 + if (!error2)
68720 + gr_log_str(GR_DONT_AUDIT_GOOD, GR_RELOAD_ACL_MSG, GR_VERSION);
68721 + else {
68722 + gr_log_str(GR_DONT_AUDIT, GR_RELOADF_ACL_MSG, GR_VERSION);
68723 + error = error2;
68724 + }
68725 + } else {
68726 + gr_log_str(GR_DONT_AUDIT, GR_RELOADF_ACL_MSG, GR_VERSION);
68727 + error = -EPERM;
68728 + }
68729 + break;
68730 + case GR_SEGVMOD:
68731 + if (unlikely(!gr_acl_is_enabled())) {
68732 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_SEGVMODI_ACL_MSG);
68733 + error = -EAGAIN;
68734 + break;
68735 + }
68736 +
68737 + if (!(chkpw(&gr_usermode, (unsigned char *)&gr_system_salt, (unsigned char *)&gr_system_sum))) {
68738 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_SEGVMODS_ACL_MSG);
68739 + if (gr_usermode.segv_device && gr_usermode.segv_inode) {
68740 + struct acl_subject_label *segvacl;
68741 + segvacl =
68742 + lookup_acl_subj_label(gr_usermode.segv_inode,
68743 + gr_usermode.segv_device,
68744 + current->role);
68745 + if (segvacl) {
68746 + segvacl->crashes = 0;
68747 + segvacl->expires = 0;
68748 + }
68749 + } else if (gr_find_uid(gr_usermode.segv_uid) >= 0) {
68750 + gr_remove_uid(gr_usermode.segv_uid);
68751 + }
68752 + } else {
68753 + gr_log_noargs(GR_DONT_AUDIT, GR_SEGVMODF_ACL_MSG);
68754 + error = -EPERM;
68755 + }
68756 + break;
68757 + case GR_SPROLE:
68758 + case GR_SPROLEPAM:
68759 + if (unlikely(!gr_acl_is_enabled())) {
68760 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_SPROLEI_ACL_MSG);
68761 + error = -EAGAIN;
68762 + break;
68763 + }
68764 +
68765 + if (current->role->expires && time_after_eq(get_seconds(), current->role->expires)) {
68766 + current->role->expires = 0;
68767 + current->role->auth_attempts = 0;
68768 + }
68769 +
68770 + if (current->role->auth_attempts >= CONFIG_GRKERNSEC_ACL_MAXTRIES &&
68771 + time_after(current->role->expires, get_seconds())) {
68772 + error = -EBUSY;
68773 + goto out;
68774 + }
68775 +
68776 + if (lookup_special_role_auth
68777 + (gr_usermode.mode, gr_usermode.sp_role, &sprole_salt, &sprole_sum)
68778 + && ((!sprole_salt && !sprole_sum)
68779 + || !(chkpw(&gr_usermode, sprole_salt, sprole_sum)))) {
68780 + char *p = "";
68781 + assign_special_role(gr_usermode.sp_role);
68782 + read_lock(&tasklist_lock);
68783 + if (current->real_parent)
68784 + p = current->real_parent->role->rolename;
68785 + read_unlock(&tasklist_lock);
68786 + gr_log_str_int(GR_DONT_AUDIT_GOOD, GR_SPROLES_ACL_MSG,
68787 + p, acl_sp_role_value);
68788 + } else {
68789 + gr_log_str(GR_DONT_AUDIT, GR_SPROLEF_ACL_MSG, gr_usermode.sp_role);
68790 + error = -EPERM;
68791 + if(!(current->role->auth_attempts++))
68792 + current->role->expires = get_seconds() + CONFIG_GRKERNSEC_ACL_TIMEOUT;
68793 +
68794 + goto out;
68795 + }
68796 + break;
68797 + case GR_UNSPROLE:
68798 + if (unlikely(!gr_acl_is_enabled())) {
68799 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_UNSPROLEI_ACL_MSG);
68800 + error = -EAGAIN;
68801 + break;
68802 + }
68803 +
68804 + if (current->role->roletype & GR_ROLE_SPECIAL) {
68805 + char *p = "";
68806 + int i = 0;
68807 +
68808 + read_lock(&tasklist_lock);
68809 + if (current->real_parent) {
68810 + p = current->real_parent->role->rolename;
68811 + i = current->real_parent->acl_role_id;
68812 + }
68813 + read_unlock(&tasklist_lock);
68814 +
68815 + gr_log_str_int(GR_DONT_AUDIT_GOOD, GR_UNSPROLES_ACL_MSG, p, i);
68816 + gr_set_acls(1);
68817 + } else {
68818 + error = -EPERM;
68819 + goto out;
68820 + }
68821 + break;
68822 + default:
68823 + gr_log_int(GR_DONT_AUDIT, GR_INVMODE_ACL_MSG, gr_usermode.mode);
68824 + error = -EINVAL;
68825 + break;
68826 + }
68827 +
68828 + if (error != -EPERM)
68829 + goto out;
68830 +
68831 + if(!(gr_auth_attempts++))
68832 + gr_auth_expires = get_seconds() + CONFIG_GRKERNSEC_ACL_TIMEOUT;
68833 +
68834 + out:
68835 + mutex_unlock(&gr_dev_mutex);
68836 +
68837 + if (!error)
68838 + error = req_count;
68839 +
68840 + return error;
68841 +}
68842 +
68843 +int
68844 +gr_set_acls(const int type)
68845 +{
68846 + struct task_struct *task, *task2;
68847 + struct acl_role_label *role = current->role;
68848 + struct acl_subject_label *subj;
68849 + __u16 acl_role_id = current->acl_role_id;
68850 + const struct cred *cred;
68851 + int ret;
68852 +
68853 + rcu_read_lock();
68854 + read_lock(&tasklist_lock);
68855 + read_lock(&grsec_exec_file_lock);
68856 + do_each_thread(task2, task) {
68857 + /* check to see if we're called from the exit handler,
68858 + if so, only replace ACLs that have inherited the admin
68859 + ACL */
68860 +
68861 + if (type && (task->role != role ||
68862 + task->acl_role_id != acl_role_id))
68863 + continue;
68864 +
68865 + task->acl_role_id = 0;
68866 + task->acl_sp_role = 0;
68867 + task->inherited = 0;
68868 +
68869 + if (task->exec_file) {
68870 + cred = __task_cred(task);
68871 + task->role = __lookup_acl_role_label(polstate, task, GR_GLOBAL_UID(cred->uid), GR_GLOBAL_GID(cred->gid));
68872 + subj = __gr_get_subject_for_task(polstate, task, NULL);
68873 + if (subj == NULL) {
68874 + ret = -EINVAL;
68875 + read_unlock(&grsec_exec_file_lock);
68876 + read_unlock(&tasklist_lock);
68877 + rcu_read_unlock();
68878 + gr_log_str_int(GR_DONT_AUDIT_GOOD, GR_DEFACL_MSG, task->comm, task_pid_nr(task));
68879 + return ret;
68880 + }
68881 + __gr_apply_subject_to_task(polstate, task, subj);
68882 + } else {
68883 + // it's a kernel process
68884 + task->role = polstate->kernel_role;
68885 + task->acl = polstate->kernel_role->root_label;
68886 +#ifdef CONFIG_GRKERNSEC_ACL_HIDEKERN
68887 + task->acl->mode &= ~GR_PROCFIND;
68888 +#endif
68889 + }
68890 + } while_each_thread(task2, task);
68891 + read_unlock(&grsec_exec_file_lock);
68892 + read_unlock(&tasklist_lock);
68893 + rcu_read_unlock();
68894 +
68895 + return 0;
68896 +}
68897 diff --git a/grsecurity/gracl_res.c b/grsecurity/gracl_res.c
68898 new file mode 100644
68899 index 0000000..39645c9
68900 --- /dev/null
68901 +++ b/grsecurity/gracl_res.c
68902 @@ -0,0 +1,68 @@
68903 +#include <linux/kernel.h>
68904 +#include <linux/sched.h>
68905 +#include <linux/gracl.h>
68906 +#include <linux/grinternal.h>
68907 +
68908 +static const char *restab_log[] = {
68909 + [RLIMIT_CPU] = "RLIMIT_CPU",
68910 + [RLIMIT_FSIZE] = "RLIMIT_FSIZE",
68911 + [RLIMIT_DATA] = "RLIMIT_DATA",
68912 + [RLIMIT_STACK] = "RLIMIT_STACK",
68913 + [RLIMIT_CORE] = "RLIMIT_CORE",
68914 + [RLIMIT_RSS] = "RLIMIT_RSS",
68915 + [RLIMIT_NPROC] = "RLIMIT_NPROC",
68916 + [RLIMIT_NOFILE] = "RLIMIT_NOFILE",
68917 + [RLIMIT_MEMLOCK] = "RLIMIT_MEMLOCK",
68918 + [RLIMIT_AS] = "RLIMIT_AS",
68919 + [RLIMIT_LOCKS] = "RLIMIT_LOCKS",
68920 + [RLIMIT_SIGPENDING] = "RLIMIT_SIGPENDING",
68921 + [RLIMIT_MSGQUEUE] = "RLIMIT_MSGQUEUE",
68922 + [RLIMIT_NICE] = "RLIMIT_NICE",
68923 + [RLIMIT_RTPRIO] = "RLIMIT_RTPRIO",
68924 + [RLIMIT_RTTIME] = "RLIMIT_RTTIME",
68925 + [GR_CRASH_RES] = "RLIMIT_CRASH"
68926 +};
68927 +
68928 +void
68929 +gr_log_resource(const struct task_struct *task,
68930 + const int res, const unsigned long wanted, const int gt)
68931 +{
68932 + const struct cred *cred;
68933 + unsigned long rlim;
68934 +
68935 + if (!gr_acl_is_enabled() && !grsec_resource_logging)
68936 + return;
68937 +
68938 + // not yet supported resource
68939 + if (unlikely(!restab_log[res]))
68940 + return;
68941 +
68942 + if (res == RLIMIT_CPU || res == RLIMIT_RTTIME)
68943 + rlim = task_rlimit_max(task, res);
68944 + else
68945 + rlim = task_rlimit(task, res);
68946 +
68947 + if (likely((rlim == RLIM_INFINITY) || (gt && wanted <= rlim) || (!gt && wanted < rlim)))
68948 + return;
68949 +
68950 + rcu_read_lock();
68951 + cred = __task_cred(task);
68952 +
68953 + if (res == RLIMIT_NPROC &&
68954 + (cap_raised(cred->cap_effective, CAP_SYS_ADMIN) ||
68955 + cap_raised(cred->cap_effective, CAP_SYS_RESOURCE)))
68956 + goto out_rcu_unlock;
68957 + else if (res == RLIMIT_MEMLOCK &&
68958 + cap_raised(cred->cap_effective, CAP_IPC_LOCK))
68959 + goto out_rcu_unlock;
68960 + else if (res == RLIMIT_NICE && cap_raised(cred->cap_effective, CAP_SYS_NICE))
68961 + goto out_rcu_unlock;
68962 + rcu_read_unlock();
68963 +
68964 + gr_log_res_ulong2_str(GR_DONT_AUDIT, GR_RESOURCE_MSG, task, wanted, restab_log[res], rlim);
68965 +
68966 + return;
68967 +out_rcu_unlock:
68968 + rcu_read_unlock();
68969 + return;
68970 +}
68971 diff --git a/grsecurity/gracl_segv.c b/grsecurity/gracl_segv.c
68972 new file mode 100644
68973 index 0000000..2040e61
68974 --- /dev/null
68975 +++ b/grsecurity/gracl_segv.c
68976 @@ -0,0 +1,313 @@
68977 +#include <linux/kernel.h>
68978 +#include <linux/mm.h>
68979 +#include <asm/uaccess.h>
68980 +#include <asm/errno.h>
68981 +#include <asm/mman.h>
68982 +#include <net/sock.h>
68983 +#include <linux/file.h>
68984 +#include <linux/fs.h>
68985 +#include <linux/net.h>
68986 +#include <linux/in.h>
68987 +#include <linux/slab.h>
68988 +#include <linux/types.h>
68989 +#include <linux/sched.h>
68990 +#include <linux/timer.h>
68991 +#include <linux/gracl.h>
68992 +#include <linux/grsecurity.h>
68993 +#include <linux/grinternal.h>
68994 +#if defined(CONFIG_BTRFS_FS) || defined(CONFIG_BTRFS_FS_MODULE)
68995 +#include <linux/magic.h>
68996 +#include <linux/pagemap.h>
68997 +#include "../fs/btrfs/async-thread.h"
68998 +#include "../fs/btrfs/ctree.h"
68999 +#include "../fs/btrfs/btrfs_inode.h"
69000 +#endif
69001 +
69002 +static struct crash_uid *uid_set;
69003 +static unsigned short uid_used;
69004 +static DEFINE_SPINLOCK(gr_uid_lock);
69005 +extern rwlock_t gr_inode_lock;
69006 +extern struct acl_subject_label *
69007 + lookup_acl_subj_label(const ino_t inode, const dev_t dev,
69008 + struct acl_role_label *role);
69009 +
69010 +static inline dev_t __get_dev(const struct dentry *dentry)
69011 +{
69012 +#if defined(CONFIG_BTRFS_FS) || defined(CONFIG_BTRFS_FS_MODULE)
69013 + if (dentry->d_sb->s_magic == BTRFS_SUPER_MAGIC)
69014 + return BTRFS_I(dentry->d_inode)->root->anon_dev;
69015 + else
69016 +#endif
69017 + return dentry->d_sb->s_dev;
69018 +}
69019 +
69020 +int
69021 +gr_init_uidset(void)
69022 +{
69023 + uid_set =
69024 + kmalloc(GR_UIDTABLE_MAX * sizeof (struct crash_uid), GFP_KERNEL);
69025 + uid_used = 0;
69026 +
69027 + return uid_set ? 1 : 0;
69028 +}
69029 +
69030 +void
69031 +gr_free_uidset(void)
69032 +{
69033 + if (uid_set) {
69034 + struct crash_uid *tmpset;
69035 + spin_lock(&gr_uid_lock);
69036 + tmpset = uid_set;
69037 + uid_set = NULL;
69038 + uid_used = 0;
69039 + spin_unlock(&gr_uid_lock);
69040 + if (tmpset)
69041 + kfree(tmpset);
69042 + }
69043 +
69044 + return;
69045 +}
69046 +
69047 +int
69048 +gr_find_uid(const uid_t uid)
69049 +{
69050 + struct crash_uid *tmp = uid_set;
69051 + uid_t buid;
69052 + int low = 0, high = uid_used - 1, mid;
69053 +
69054 + while (high >= low) {
69055 + mid = (low + high) >> 1;
69056 + buid = tmp[mid].uid;
69057 + if (buid == uid)
69058 + return mid;
69059 + if (buid > uid)
69060 + high = mid - 1;
69061 + if (buid < uid)
69062 + low = mid + 1;
69063 + }
69064 +
69065 + return -1;
69066 +}
69067 +
69068 +static __inline__ void
69069 +gr_insertsort(void)
69070 +{
69071 + unsigned short i, j;
69072 + struct crash_uid index;
69073 +
69074 + for (i = 1; i < uid_used; i++) {
69075 + index = uid_set[i];
69076 + j = i;
69077 + while ((j > 0) && uid_set[j - 1].uid > index.uid) {
69078 + uid_set[j] = uid_set[j - 1];
69079 + j--;
69080 + }
69081 + uid_set[j] = index;
69082 + }
69083 +
69084 + return;
69085 +}
69086 +
69087 +static __inline__ void
69088 +gr_insert_uid(const kuid_t kuid, const unsigned long expires)
69089 +{
69090 + int loc;
69091 + uid_t uid = GR_GLOBAL_UID(kuid);
69092 +
69093 + if (uid_used == GR_UIDTABLE_MAX)
69094 + return;
69095 +
69096 + loc = gr_find_uid(uid);
69097 +
69098 + if (loc >= 0) {
69099 + uid_set[loc].expires = expires;
69100 + return;
69101 + }
69102 +
69103 + uid_set[uid_used].uid = uid;
69104 + uid_set[uid_used].expires = expires;
69105 + uid_used++;
69106 +
69107 + gr_insertsort();
69108 +
69109 + return;
69110 +}
69111 +
69112 +void
69113 +gr_remove_uid(const unsigned short loc)
69114 +{
69115 + unsigned short i;
69116 +
69117 + for (i = loc + 1; i < uid_used; i++)
69118 + uid_set[i - 1] = uid_set[i];
69119 +
69120 + uid_used--;
69121 +
69122 + return;
69123 +}
69124 +
69125 +int
69126 +gr_check_crash_uid(const kuid_t kuid)
69127 +{
69128 + int loc;
69129 + int ret = 0;
69130 + uid_t uid;
69131 +
69132 + if (unlikely(!gr_acl_is_enabled()))
69133 + return 0;
69134 +
69135 + uid = GR_GLOBAL_UID(kuid);
69136 +
69137 + spin_lock(&gr_uid_lock);
69138 + loc = gr_find_uid(uid);
69139 +
69140 + if (loc < 0)
69141 + goto out_unlock;
69142 +
69143 + if (time_before_eq(uid_set[loc].expires, get_seconds()))
69144 + gr_remove_uid(loc);
69145 + else
69146 + ret = 1;
69147 +
69148 +out_unlock:
69149 + spin_unlock(&gr_uid_lock);
69150 + return ret;
69151 +}
69152 +
69153 +static __inline__ int
69154 +proc_is_setxid(const struct cred *cred)
69155 +{
69156 + if (!uid_eq(cred->uid, cred->euid) || !uid_eq(cred->uid, cred->suid) ||
69157 + !uid_eq(cred->uid, cred->fsuid))
69158 + return 1;
69159 + if (!gid_eq(cred->gid, cred->egid) || !gid_eq(cred->gid, cred->sgid) ||
69160 + !gid_eq(cred->gid, cred->fsgid))
69161 + return 1;
69162 +
69163 + return 0;
69164 +}
69165 +
69166 +extern int gr_fake_force_sig(int sig, struct task_struct *t);
69167 +
69168 +void
69169 +gr_handle_crash(struct task_struct *task, const int sig)
69170 +{
69171 + struct acl_subject_label *curr;
69172 + struct task_struct *tsk, *tsk2;
69173 + const struct cred *cred;
69174 + const struct cred *cred2;
69175 +
69176 + if (sig != SIGSEGV && sig != SIGKILL && sig != SIGBUS && sig != SIGILL)
69177 + return;
69178 +
69179 + if (unlikely(!gr_acl_is_enabled()))
69180 + return;
69181 +
69182 + curr = task->acl;
69183 +
69184 + if (!(curr->resmask & (1U << GR_CRASH_RES)))
69185 + return;
69186 +
69187 + if (time_before_eq(curr->expires, get_seconds())) {
69188 + curr->expires = 0;
69189 + curr->crashes = 0;
69190 + }
69191 +
69192 + curr->crashes++;
69193 +
69194 + if (!curr->expires)
69195 + curr->expires = get_seconds() + curr->res[GR_CRASH_RES].rlim_max;
69196 +
69197 + if ((curr->crashes >= curr->res[GR_CRASH_RES].rlim_cur) &&
69198 + time_after(curr->expires, get_seconds())) {
69199 + rcu_read_lock();
69200 + cred = __task_cred(task);
69201 + if (gr_is_global_nonroot(cred->uid) && proc_is_setxid(cred)) {
69202 + gr_log_crash1(GR_DONT_AUDIT, GR_SEGVSTART_ACL_MSG, task, curr->res[GR_CRASH_RES].rlim_max);
69203 + spin_lock(&gr_uid_lock);
69204 + gr_insert_uid(cred->uid, curr->expires);
69205 + spin_unlock(&gr_uid_lock);
69206 + curr->expires = 0;
69207 + curr->crashes = 0;
69208 + read_lock(&tasklist_lock);
69209 + do_each_thread(tsk2, tsk) {
69210 + cred2 = __task_cred(tsk);
69211 + if (tsk != task && uid_eq(cred2->uid, cred->uid))
69212 + gr_fake_force_sig(SIGKILL, tsk);
69213 + } while_each_thread(tsk2, tsk);
69214 + read_unlock(&tasklist_lock);
69215 + } else {
69216 + gr_log_crash2(GR_DONT_AUDIT, GR_SEGVNOSUID_ACL_MSG, task, curr->res[GR_CRASH_RES].rlim_max);
69217 + read_lock(&tasklist_lock);
69218 + read_lock(&grsec_exec_file_lock);
69219 + do_each_thread(tsk2, tsk) {
69220 + if (likely(tsk != task)) {
69221 + // if this thread has the same subject as the one that triggered
69222 + // RES_CRASH and it's the same binary, kill it
69223 + if (tsk->acl == task->acl && gr_is_same_file(tsk->exec_file, task->exec_file))
69224 + gr_fake_force_sig(SIGKILL, tsk);
69225 + }
69226 + } while_each_thread(tsk2, tsk);
69227 + read_unlock(&grsec_exec_file_lock);
69228 + read_unlock(&tasklist_lock);
69229 + }
69230 + rcu_read_unlock();
69231 + }
69232 +
69233 + return;
69234 +}
69235 +
69236 +int
69237 +gr_check_crash_exec(const struct file *filp)
69238 +{
69239 + struct acl_subject_label *curr;
69240 +
69241 + if (unlikely(!gr_acl_is_enabled()))
69242 + return 0;
69243 +
69244 + read_lock(&gr_inode_lock);
69245 + curr = lookup_acl_subj_label(filp->f_path.dentry->d_inode->i_ino,
69246 + __get_dev(filp->f_path.dentry),
69247 + current->role);
69248 + read_unlock(&gr_inode_lock);
69249 +
69250 + if (!curr || !(curr->resmask & (1U << GR_CRASH_RES)) ||
69251 + (!curr->crashes && !curr->expires))
69252 + return 0;
69253 +
69254 + if ((curr->crashes >= curr->res[GR_CRASH_RES].rlim_cur) &&
69255 + time_after(curr->expires, get_seconds()))
69256 + return 1;
69257 + else if (time_before_eq(curr->expires, get_seconds())) {
69258 + curr->crashes = 0;
69259 + curr->expires = 0;
69260 + }
69261 +
69262 + return 0;
69263 +}
69264 +
69265 +void
69266 +gr_handle_alertkill(struct task_struct *task)
69267 +{
69268 + struct acl_subject_label *curracl;
69269 + __u32 curr_ip;
69270 + struct task_struct *p, *p2;
69271 +
69272 + if (unlikely(!gr_acl_is_enabled()))
69273 + return;
69274 +
69275 + curracl = task->acl;
69276 + curr_ip = task->signal->curr_ip;
69277 +
69278 + if ((curracl->mode & GR_KILLIPPROC) && curr_ip) {
69279 + read_lock(&tasklist_lock);
69280 + do_each_thread(p2, p) {
69281 + if (p->signal->curr_ip == curr_ip)
69282 + gr_fake_force_sig(SIGKILL, p);
69283 + } while_each_thread(p2, p);
69284 + read_unlock(&tasklist_lock);
69285 + } else if (curracl->mode & GR_KILLPROC)
69286 + gr_fake_force_sig(SIGKILL, task);
69287 +
69288 + return;
69289 +}
69290 diff --git a/grsecurity/gracl_shm.c b/grsecurity/gracl_shm.c
69291 new file mode 100644
69292 index 0000000..98011b0
69293 --- /dev/null
69294 +++ b/grsecurity/gracl_shm.c
69295 @@ -0,0 +1,40 @@
69296 +#include <linux/kernel.h>
69297 +#include <linux/mm.h>
69298 +#include <linux/sched.h>
69299 +#include <linux/file.h>
69300 +#include <linux/ipc.h>
69301 +#include <linux/gracl.h>
69302 +#include <linux/grsecurity.h>
69303 +#include <linux/grinternal.h>
69304 +
69305 +int
69306 +gr_handle_shmat(const pid_t shm_cprid, const pid_t shm_lapid,
69307 + const time_t shm_createtime, const kuid_t cuid, const int shmid)
69308 +{
69309 + struct task_struct *task;
69310 +
69311 + if (!gr_acl_is_enabled())
69312 + return 1;
69313 +
69314 + rcu_read_lock();
69315 + read_lock(&tasklist_lock);
69316 +
69317 + task = find_task_by_vpid(shm_cprid);
69318 +
69319 + if (unlikely(!task))
69320 + task = find_task_by_vpid(shm_lapid);
69321 +
69322 + if (unlikely(task && (time_before_eq((unsigned long)task->start_time.tv_sec, (unsigned long)shm_createtime) ||
69323 + (task_pid_nr(task) == shm_lapid)) &&
69324 + (task->acl->mode & GR_PROTSHM) &&
69325 + (task->acl != current->acl))) {
69326 + read_unlock(&tasklist_lock);
69327 + rcu_read_unlock();
69328 + gr_log_int3(GR_DONT_AUDIT, GR_SHMAT_ACL_MSG, GR_GLOBAL_UID(cuid), shm_cprid, shmid);
69329 + return 0;
69330 + }
69331 + read_unlock(&tasklist_lock);
69332 + rcu_read_unlock();
69333 +
69334 + return 1;
69335 +}
69336 diff --git a/grsecurity/grsec_chdir.c b/grsecurity/grsec_chdir.c
69337 new file mode 100644
69338 index 0000000..bc0be01
69339 --- /dev/null
69340 +++ b/grsecurity/grsec_chdir.c
69341 @@ -0,0 +1,19 @@
69342 +#include <linux/kernel.h>
69343 +#include <linux/sched.h>
69344 +#include <linux/fs.h>
69345 +#include <linux/file.h>
69346 +#include <linux/grsecurity.h>
69347 +#include <linux/grinternal.h>
69348 +
69349 +void
69350 +gr_log_chdir(const struct dentry *dentry, const struct vfsmount *mnt)
69351 +{
69352 +#ifdef CONFIG_GRKERNSEC_AUDIT_CHDIR
69353 + if ((grsec_enable_chdir && grsec_enable_group &&
69354 + in_group_p(grsec_audit_gid)) || (grsec_enable_chdir &&
69355 + !grsec_enable_group)) {
69356 + gr_log_fs_generic(GR_DO_AUDIT, GR_CHDIR_AUDIT_MSG, dentry, mnt);
69357 + }
69358 +#endif
69359 + return;
69360 +}
69361 diff --git a/grsecurity/grsec_chroot.c b/grsecurity/grsec_chroot.c
69362 new file mode 100644
69363 index 0000000..e10b319
69364 --- /dev/null
69365 +++ b/grsecurity/grsec_chroot.c
69366 @@ -0,0 +1,370 @@
69367 +#include <linux/kernel.h>
69368 +#include <linux/module.h>
69369 +#include <linux/sched.h>
69370 +#include <linux/file.h>
69371 +#include <linux/fs.h>
69372 +#include <linux/mount.h>
69373 +#include <linux/types.h>
69374 +#include "../fs/mount.h"
69375 +#include <linux/grsecurity.h>
69376 +#include <linux/grinternal.h>
69377 +
69378 +#ifdef CONFIG_GRKERNSEC_CHROOT_INITRD
69379 +int gr_init_ran;
69380 +#endif
69381 +
69382 +void gr_set_chroot_entries(struct task_struct *task, const struct path *path)
69383 +{
69384 +#ifdef CONFIG_GRKERNSEC
69385 + if (task_pid_nr(task) > 1 && path->dentry != init_task.fs->root.dentry &&
69386 + path->dentry != task->nsproxy->mnt_ns->root->mnt.mnt_root
69387 +#ifdef CONFIG_GRKERNSEC_CHROOT_INITRD
69388 + && gr_init_ran
69389 +#endif
69390 + )
69391 + task->gr_is_chrooted = 1;
69392 + else {
69393 +#ifdef CONFIG_GRKERNSEC_CHROOT_INITRD
69394 + if (task_pid_nr(task) == 1 && !gr_init_ran)
69395 + gr_init_ran = 1;
69396 +#endif
69397 + task->gr_is_chrooted = 0;
69398 + }
69399 +
69400 + task->gr_chroot_dentry = path->dentry;
69401 +#endif
69402 + return;
69403 +}
69404 +
69405 +void gr_clear_chroot_entries(struct task_struct *task)
69406 +{
69407 +#ifdef CONFIG_GRKERNSEC
69408 + task->gr_is_chrooted = 0;
69409 + task->gr_chroot_dentry = NULL;
69410 +#endif
69411 + return;
69412 +}
69413 +
69414 +int
69415 +gr_handle_chroot_unix(const pid_t pid)
69416 +{
69417 +#ifdef CONFIG_GRKERNSEC_CHROOT_UNIX
69418 + struct task_struct *p;
69419 +
69420 + if (unlikely(!grsec_enable_chroot_unix))
69421 + return 1;
69422 +
69423 + if (likely(!proc_is_chrooted(current)))
69424 + return 1;
69425 +
69426 + rcu_read_lock();
69427 + read_lock(&tasklist_lock);
69428 + p = find_task_by_vpid_unrestricted(pid);
69429 + if (unlikely(p && !have_same_root(current, p))) {
69430 + read_unlock(&tasklist_lock);
69431 + rcu_read_unlock();
69432 + gr_log_noargs(GR_DONT_AUDIT, GR_UNIX_CHROOT_MSG);
69433 + return 0;
69434 + }
69435 + read_unlock(&tasklist_lock);
69436 + rcu_read_unlock();
69437 +#endif
69438 + return 1;
69439 +}
69440 +
69441 +int
69442 +gr_handle_chroot_nice(void)
69443 +{
69444 +#ifdef CONFIG_GRKERNSEC_CHROOT_NICE
69445 + if (grsec_enable_chroot_nice && proc_is_chrooted(current)) {
69446 + gr_log_noargs(GR_DONT_AUDIT, GR_NICE_CHROOT_MSG);
69447 + return -EPERM;
69448 + }
69449 +#endif
69450 + return 0;
69451 +}
69452 +
69453 +int
69454 +gr_handle_chroot_setpriority(struct task_struct *p, const int niceval)
69455 +{
69456 +#ifdef CONFIG_GRKERNSEC_CHROOT_NICE
69457 + if (grsec_enable_chroot_nice && (niceval < task_nice(p))
69458 + && proc_is_chrooted(current)) {
69459 + gr_log_str_int(GR_DONT_AUDIT, GR_PRIORITY_CHROOT_MSG, p->comm, task_pid_nr(p));
69460 + return -EACCES;
69461 + }
69462 +#endif
69463 + return 0;
69464 +}
69465 +
69466 +int
69467 +gr_handle_chroot_fowner(struct pid *pid, enum pid_type type)
69468 +{
69469 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
69470 + struct task_struct *p;
69471 + int ret = 0;
69472 + if (!grsec_enable_chroot_findtask || !proc_is_chrooted(current) || !pid)
69473 + return ret;
69474 +
69475 + read_lock(&tasklist_lock);
69476 + do_each_pid_task(pid, type, p) {
69477 + if (!have_same_root(current, p)) {
69478 + ret = 1;
69479 + goto out;
69480 + }
69481 + } while_each_pid_task(pid, type, p);
69482 +out:
69483 + read_unlock(&tasklist_lock);
69484 + return ret;
69485 +#endif
69486 + return 0;
69487 +}
69488 +
69489 +int
69490 +gr_pid_is_chrooted(struct task_struct *p)
69491 +{
69492 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
69493 + if (!grsec_enable_chroot_findtask || !proc_is_chrooted(current) || p == NULL)
69494 + return 0;
69495 +
69496 + if ((p->exit_state & (EXIT_ZOMBIE | EXIT_DEAD)) ||
69497 + !have_same_root(current, p)) {
69498 + return 1;
69499 + }
69500 +#endif
69501 + return 0;
69502 +}
69503 +
69504 +EXPORT_SYMBOL(gr_pid_is_chrooted);
69505 +
69506 +#if defined(CONFIG_GRKERNSEC_CHROOT_DOUBLE) || defined(CONFIG_GRKERNSEC_CHROOT_FCHDIR)
69507 +int gr_is_outside_chroot(const struct dentry *u_dentry, const struct vfsmount *u_mnt)
69508 +{
69509 + struct path path, currentroot;
69510 + int ret = 0;
69511 +
69512 + path.dentry = (struct dentry *)u_dentry;
69513 + path.mnt = (struct vfsmount *)u_mnt;
69514 + get_fs_root(current->fs, &currentroot);
69515 + if (path_is_under(&path, &currentroot))
69516 + ret = 1;
69517 + path_put(&currentroot);
69518 +
69519 + return ret;
69520 +}
69521 +#endif
69522 +
69523 +int
69524 +gr_chroot_fchdir(struct dentry *u_dentry, struct vfsmount *u_mnt)
69525 +{
69526 +#ifdef CONFIG_GRKERNSEC_CHROOT_FCHDIR
69527 + if (!grsec_enable_chroot_fchdir)
69528 + return 1;
69529 +
69530 + if (!proc_is_chrooted(current))
69531 + return 1;
69532 + else if (!gr_is_outside_chroot(u_dentry, u_mnt)) {
69533 + gr_log_fs_generic(GR_DONT_AUDIT, GR_CHROOT_FCHDIR_MSG, u_dentry, u_mnt);
69534 + return 0;
69535 + }
69536 +#endif
69537 + return 1;
69538 +}
69539 +
69540 +int
69541 +gr_chroot_shmat(const pid_t shm_cprid, const pid_t shm_lapid,
69542 + const time_t shm_createtime)
69543 +{
69544 +#ifdef CONFIG_GRKERNSEC_CHROOT_SHMAT
69545 + struct task_struct *p;
69546 + time_t starttime;
69547 +
69548 + if (unlikely(!grsec_enable_chroot_shmat))
69549 + return 1;
69550 +
69551 + if (likely(!proc_is_chrooted(current)))
69552 + return 1;
69553 +
69554 + rcu_read_lock();
69555 + read_lock(&tasklist_lock);
69556 +
69557 + if ((p = find_task_by_vpid_unrestricted(shm_cprid))) {
69558 + starttime = p->start_time.tv_sec;
69559 + if (time_before_eq((unsigned long)starttime, (unsigned long)shm_createtime)) {
69560 + if (have_same_root(current, p)) {
69561 + goto allow;
69562 + } else {
69563 + read_unlock(&tasklist_lock);
69564 + rcu_read_unlock();
69565 + gr_log_noargs(GR_DONT_AUDIT, GR_SHMAT_CHROOT_MSG);
69566 + return 0;
69567 + }
69568 + }
69569 + /* creator exited, pid reuse, fall through to next check */
69570 + }
69571 + if ((p = find_task_by_vpid_unrestricted(shm_lapid))) {
69572 + if (unlikely(!have_same_root(current, p))) {
69573 + read_unlock(&tasklist_lock);
69574 + rcu_read_unlock();
69575 + gr_log_noargs(GR_DONT_AUDIT, GR_SHMAT_CHROOT_MSG);
69576 + return 0;
69577 + }
69578 + }
69579 +
69580 +allow:
69581 + read_unlock(&tasklist_lock);
69582 + rcu_read_unlock();
69583 +#endif
69584 + return 1;
69585 +}
69586 +
69587 +void
69588 +gr_log_chroot_exec(const struct dentry *dentry, const struct vfsmount *mnt)
69589 +{
69590 +#ifdef CONFIG_GRKERNSEC_CHROOT_EXECLOG
69591 + if (grsec_enable_chroot_execlog && proc_is_chrooted(current))
69592 + gr_log_fs_generic(GR_DO_AUDIT, GR_EXEC_CHROOT_MSG, dentry, mnt);
69593 +#endif
69594 + return;
69595 +}
69596 +
69597 +int
69598 +gr_handle_chroot_mknod(const struct dentry *dentry,
69599 + const struct vfsmount *mnt, const int mode)
69600 +{
69601 +#ifdef CONFIG_GRKERNSEC_CHROOT_MKNOD
69602 + if (grsec_enable_chroot_mknod && !S_ISFIFO(mode) && !S_ISREG(mode) &&
69603 + proc_is_chrooted(current)) {
69604 + gr_log_fs_generic(GR_DONT_AUDIT, GR_MKNOD_CHROOT_MSG, dentry, mnt);
69605 + return -EPERM;
69606 + }
69607 +#endif
69608 + return 0;
69609 +}
69610 +
69611 +int
69612 +gr_handle_chroot_mount(const struct dentry *dentry,
69613 + const struct vfsmount *mnt, const char *dev_name)
69614 +{
69615 +#ifdef CONFIG_GRKERNSEC_CHROOT_MOUNT
69616 + if (grsec_enable_chroot_mount && proc_is_chrooted(current)) {
69617 + gr_log_str_fs(GR_DONT_AUDIT, GR_MOUNT_CHROOT_MSG, dev_name ? dev_name : "none", dentry, mnt);
69618 + return -EPERM;
69619 + }
69620 +#endif
69621 + return 0;
69622 +}
69623 +
69624 +int
69625 +gr_handle_chroot_pivot(void)
69626 +{
69627 +#ifdef CONFIG_GRKERNSEC_CHROOT_PIVOT
69628 + if (grsec_enable_chroot_pivot && proc_is_chrooted(current)) {
69629 + gr_log_noargs(GR_DONT_AUDIT, GR_PIVOT_CHROOT_MSG);
69630 + return -EPERM;
69631 + }
69632 +#endif
69633 + return 0;
69634 +}
69635 +
69636 +int
69637 +gr_handle_chroot_chroot(const struct dentry *dentry, const struct vfsmount *mnt)
69638 +{
69639 +#ifdef CONFIG_GRKERNSEC_CHROOT_DOUBLE
69640 + if (grsec_enable_chroot_double && proc_is_chrooted(current) &&
69641 + !gr_is_outside_chroot(dentry, mnt)) {
69642 + gr_log_fs_generic(GR_DONT_AUDIT, GR_CHROOT_CHROOT_MSG, dentry, mnt);
69643 + return -EPERM;
69644 + }
69645 +#endif
69646 + return 0;
69647 +}
69648 +
69649 +extern const char *captab_log[];
69650 +extern int captab_log_entries;
69651 +
69652 +int
69653 +gr_task_chroot_is_capable(const struct task_struct *task, const struct cred *cred, const int cap)
69654 +{
69655 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
69656 + if (grsec_enable_chroot_caps && proc_is_chrooted(task)) {
69657 + kernel_cap_t chroot_caps = GR_CHROOT_CAPS;
69658 + if (cap_raised(chroot_caps, cap)) {
69659 + if (cap_raised(cred->cap_effective, cap) && cap < captab_log_entries) {
69660 + gr_log_cap(GR_DONT_AUDIT, GR_CAP_CHROOT_MSG, task, captab_log[cap]);
69661 + }
69662 + return 0;
69663 + }
69664 + }
69665 +#endif
69666 + return 1;
69667 +}
69668 +
69669 +int
69670 +gr_chroot_is_capable(const int cap)
69671 +{
69672 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
69673 + return gr_task_chroot_is_capable(current, current_cred(), cap);
69674 +#endif
69675 + return 1;
69676 +}
69677 +
69678 +int
69679 +gr_task_chroot_is_capable_nolog(const struct task_struct *task, const int cap)
69680 +{
69681 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
69682 + if (grsec_enable_chroot_caps && proc_is_chrooted(task)) {
69683 + kernel_cap_t chroot_caps = GR_CHROOT_CAPS;
69684 + if (cap_raised(chroot_caps, cap)) {
69685 + return 0;
69686 + }
69687 + }
69688 +#endif
69689 + return 1;
69690 +}
69691 +
69692 +int
69693 +gr_chroot_is_capable_nolog(const int cap)
69694 +{
69695 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
69696 + return gr_task_chroot_is_capable_nolog(current, cap);
69697 +#endif
69698 + return 1;
69699 +}
69700 +
69701 +int
69702 +gr_handle_chroot_sysctl(const int op)
69703 +{
69704 +#ifdef CONFIG_GRKERNSEC_CHROOT_SYSCTL
69705 + if (grsec_enable_chroot_sysctl && (op & MAY_WRITE) &&
69706 + proc_is_chrooted(current))
69707 + return -EACCES;
69708 +#endif
69709 + return 0;
69710 +}
69711 +
69712 +void
69713 +gr_handle_chroot_chdir(const struct path *path)
69714 +{
69715 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHDIR
69716 + if (grsec_enable_chroot_chdir)
69717 + set_fs_pwd(current->fs, path);
69718 +#endif
69719 + return;
69720 +}
69721 +
69722 +int
69723 +gr_handle_chroot_chmod(const struct dentry *dentry,
69724 + const struct vfsmount *mnt, const int mode)
69725 +{
69726 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHMOD
69727 + /* allow chmod +s on directories, but not files */
69728 + if (grsec_enable_chroot_chmod && !S_ISDIR(dentry->d_inode->i_mode) &&
69729 + ((mode & S_ISUID) || ((mode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP))) &&
69730 + proc_is_chrooted(current)) {
69731 + gr_log_fs_generic(GR_DONT_AUDIT, GR_CHMOD_CHROOT_MSG, dentry, mnt);
69732 + return -EPERM;
69733 + }
69734 +#endif
69735 + return 0;
69736 +}
69737 diff --git a/grsecurity/grsec_disabled.c b/grsecurity/grsec_disabled.c
69738 new file mode 100644
69739 index 0000000..0866ab2
69740 --- /dev/null
69741 +++ b/grsecurity/grsec_disabled.c
69742 @@ -0,0 +1,427 @@
69743 +#include <linux/kernel.h>
69744 +#include <linux/module.h>
69745 +#include <linux/sched.h>
69746 +#include <linux/file.h>
69747 +#include <linux/fs.h>
69748 +#include <linux/kdev_t.h>
69749 +#include <linux/net.h>
69750 +#include <linux/in.h>
69751 +#include <linux/ip.h>
69752 +#include <linux/skbuff.h>
69753 +#include <linux/sysctl.h>
69754 +
69755 +#ifdef CONFIG_PAX_HAVE_ACL_FLAGS
69756 +void
69757 +pax_set_initial_flags(struct linux_binprm *bprm)
69758 +{
69759 + return;
69760 +}
69761 +#endif
69762 +
69763 +#ifdef CONFIG_SYSCTL
69764 +__u32
69765 +gr_handle_sysctl(const struct ctl_table * table, const int op)
69766 +{
69767 + return 0;
69768 +}
69769 +#endif
69770 +
69771 +#ifdef CONFIG_TASKSTATS
69772 +int gr_is_taskstats_denied(int pid)
69773 +{
69774 + return 0;
69775 +}
69776 +#endif
69777 +
69778 +int
69779 +gr_acl_is_enabled(void)
69780 +{
69781 + return 0;
69782 +}
69783 +
69784 +void
69785 +gr_handle_proc_create(const struct dentry *dentry, const struct inode *inode)
69786 +{
69787 + return;
69788 +}
69789 +
69790 +int
69791 +gr_handle_rawio(const struct inode *inode)
69792 +{
69793 + return 0;
69794 +}
69795 +
69796 +void
69797 +gr_acl_handle_psacct(struct task_struct *task, const long code)
69798 +{
69799 + return;
69800 +}
69801 +
69802 +int
69803 +gr_handle_ptrace(struct task_struct *task, const long request)
69804 +{
69805 + return 0;
69806 +}
69807 +
69808 +int
69809 +gr_handle_proc_ptrace(struct task_struct *task)
69810 +{
69811 + return 0;
69812 +}
69813 +
69814 +int
69815 +gr_set_acls(const int type)
69816 +{
69817 + return 0;
69818 +}
69819 +
69820 +int
69821 +gr_check_hidden_task(const struct task_struct *tsk)
69822 +{
69823 + return 0;
69824 +}
69825 +
69826 +int
69827 +gr_check_protected_task(const struct task_struct *task)
69828 +{
69829 + return 0;
69830 +}
69831 +
69832 +int
69833 +gr_check_protected_task_fowner(struct pid *pid, enum pid_type type)
69834 +{
69835 + return 0;
69836 +}
69837 +
69838 +void
69839 +gr_copy_label(struct task_struct *tsk)
69840 +{
69841 + return;
69842 +}
69843 +
69844 +void
69845 +gr_set_pax_flags(struct task_struct *task)
69846 +{
69847 + return;
69848 +}
69849 +
69850 +int
69851 +gr_set_proc_label(const struct dentry *dentry, const struct vfsmount *mnt,
69852 + const int unsafe_share)
69853 +{
69854 + return 0;
69855 +}
69856 +
69857 +void
69858 +gr_handle_delete(const ino_t ino, const dev_t dev)
69859 +{
69860 + return;
69861 +}
69862 +
69863 +void
69864 +gr_handle_create(const struct dentry *dentry, const struct vfsmount *mnt)
69865 +{
69866 + return;
69867 +}
69868 +
69869 +void
69870 +gr_handle_crash(struct task_struct *task, const int sig)
69871 +{
69872 + return;
69873 +}
69874 +
69875 +int
69876 +gr_check_crash_exec(const struct file *filp)
69877 +{
69878 + return 0;
69879 +}
69880 +
69881 +int
69882 +gr_check_crash_uid(const kuid_t uid)
69883 +{
69884 + return 0;
69885 +}
69886 +
69887 +void
69888 +gr_handle_rename(struct inode *old_dir, struct inode *new_dir,
69889 + struct dentry *old_dentry,
69890 + struct dentry *new_dentry,
69891 + struct vfsmount *mnt, const __u8 replace)
69892 +{
69893 + return;
69894 +}
69895 +
69896 +int
69897 +gr_search_socket(const int family, const int type, const int protocol)
69898 +{
69899 + return 1;
69900 +}
69901 +
69902 +int
69903 +gr_search_connectbind(const int mode, const struct socket *sock,
69904 + const struct sockaddr_in *addr)
69905 +{
69906 + return 0;
69907 +}
69908 +
69909 +void
69910 +gr_handle_alertkill(struct task_struct *task)
69911 +{
69912 + return;
69913 +}
69914 +
69915 +__u32
69916 +gr_acl_handle_execve(const struct dentry * dentry, const struct vfsmount * mnt)
69917 +{
69918 + return 1;
69919 +}
69920 +
69921 +__u32
69922 +gr_acl_handle_hidden_file(const struct dentry * dentry,
69923 + const struct vfsmount * mnt)
69924 +{
69925 + return 1;
69926 +}
69927 +
69928 +__u32
69929 +gr_acl_handle_open(const struct dentry * dentry, const struct vfsmount * mnt,
69930 + int acc_mode)
69931 +{
69932 + return 1;
69933 +}
69934 +
69935 +__u32
69936 +gr_acl_handle_rmdir(const struct dentry * dentry, const struct vfsmount * mnt)
69937 +{
69938 + return 1;
69939 +}
69940 +
69941 +__u32
69942 +gr_acl_handle_unlink(const struct dentry * dentry, const struct vfsmount * mnt)
69943 +{
69944 + return 1;
69945 +}
69946 +
69947 +int
69948 +gr_acl_handle_mmap(const struct file *file, const unsigned long prot,
69949 + unsigned int *vm_flags)
69950 +{
69951 + return 1;
69952 +}
69953 +
69954 +__u32
69955 +gr_acl_handle_truncate(const struct dentry * dentry,
69956 + const struct vfsmount * mnt)
69957 +{
69958 + return 1;
69959 +}
69960 +
69961 +__u32
69962 +gr_acl_handle_utime(const struct dentry * dentry, const struct vfsmount * mnt)
69963 +{
69964 + return 1;
69965 +}
69966 +
69967 +__u32
69968 +gr_acl_handle_access(const struct dentry * dentry,
69969 + const struct vfsmount * mnt, const int fmode)
69970 +{
69971 + return 1;
69972 +}
69973 +
69974 +__u32
69975 +gr_acl_handle_chmod(const struct dentry * dentry, const struct vfsmount * mnt,
69976 + umode_t *mode)
69977 +{
69978 + return 1;
69979 +}
69980 +
69981 +__u32
69982 +gr_acl_handle_chown(const struct dentry * dentry, const struct vfsmount * mnt)
69983 +{
69984 + return 1;
69985 +}
69986 +
69987 +__u32
69988 +gr_acl_handle_setxattr(const struct dentry * dentry, const struct vfsmount * mnt)
69989 +{
69990 + return 1;
69991 +}
69992 +
69993 +void
69994 +grsecurity_init(void)
69995 +{
69996 + return;
69997 +}
69998 +
69999 +umode_t gr_acl_umask(void)
70000 +{
70001 + return 0;
70002 +}
70003 +
70004 +__u32
70005 +gr_acl_handle_mknod(const struct dentry * new_dentry,
70006 + const struct dentry * parent_dentry,
70007 + const struct vfsmount * parent_mnt,
70008 + const int mode)
70009 +{
70010 + return 1;
70011 +}
70012 +
70013 +__u32
70014 +gr_acl_handle_mkdir(const struct dentry * new_dentry,
70015 + const struct dentry * parent_dentry,
70016 + const struct vfsmount * parent_mnt)
70017 +{
70018 + return 1;
70019 +}
70020 +
70021 +__u32
70022 +gr_acl_handle_symlink(const struct dentry * new_dentry,
70023 + const struct dentry * parent_dentry,
70024 + const struct vfsmount * parent_mnt, const struct filename *from)
70025 +{
70026 + return 1;
70027 +}
70028 +
70029 +__u32
70030 +gr_acl_handle_link(const struct dentry * new_dentry,
70031 + const struct dentry * parent_dentry,
70032 + const struct vfsmount * parent_mnt,
70033 + const struct dentry * old_dentry,
70034 + const struct vfsmount * old_mnt, const struct filename *to)
70035 +{
70036 + return 1;
70037 +}
70038 +
70039 +int
70040 +gr_acl_handle_rename(const struct dentry *new_dentry,
70041 + const struct dentry *parent_dentry,
70042 + const struct vfsmount *parent_mnt,
70043 + const struct dentry *old_dentry,
70044 + const struct inode *old_parent_inode,
70045 + const struct vfsmount *old_mnt, const struct filename *newname)
70046 +{
70047 + return 0;
70048 +}
70049 +
70050 +int
70051 +gr_acl_handle_filldir(const struct file *file, const char *name,
70052 + const int namelen, const ino_t ino)
70053 +{
70054 + return 1;
70055 +}
70056 +
70057 +int
70058 +gr_handle_shmat(const pid_t shm_cprid, const pid_t shm_lapid,
70059 + const time_t shm_createtime, const kuid_t cuid, const int shmid)
70060 +{
70061 + return 1;
70062 +}
70063 +
70064 +int
70065 +gr_search_bind(const struct socket *sock, const struct sockaddr_in *addr)
70066 +{
70067 + return 0;
70068 +}
70069 +
70070 +int
70071 +gr_search_accept(const struct socket *sock)
70072 +{
70073 + return 0;
70074 +}
70075 +
70076 +int
70077 +gr_search_listen(const struct socket *sock)
70078 +{
70079 + return 0;
70080 +}
70081 +
70082 +int
70083 +gr_search_connect(const struct socket *sock, const struct sockaddr_in *addr)
70084 +{
70085 + return 0;
70086 +}
70087 +
70088 +__u32
70089 +gr_acl_handle_unix(const struct dentry * dentry, const struct vfsmount * mnt)
70090 +{
70091 + return 1;
70092 +}
70093 +
70094 +__u32
70095 +gr_acl_handle_creat(const struct dentry * dentry,
70096 + const struct dentry * p_dentry,
70097 + const struct vfsmount * p_mnt, int open_flags, int acc_mode,
70098 + const int imode)
70099 +{
70100 + return 1;
70101 +}
70102 +
70103 +void
70104 +gr_acl_handle_exit(void)
70105 +{
70106 + return;
70107 +}
70108 +
70109 +int
70110 +gr_acl_handle_mprotect(const struct file *file, const unsigned long prot)
70111 +{
70112 + return 1;
70113 +}
70114 +
70115 +void
70116 +gr_set_role_label(const kuid_t uid, const kgid_t gid)
70117 +{
70118 + return;
70119 +}
70120 +
70121 +int
70122 +gr_acl_handle_procpidmem(const struct task_struct *task)
70123 +{
70124 + return 0;
70125 +}
70126 +
70127 +int
70128 +gr_search_udp_recvmsg(const struct sock *sk, const struct sk_buff *skb)
70129 +{
70130 + return 0;
70131 +}
70132 +
70133 +int
70134 +gr_search_udp_sendmsg(const struct sock *sk, const struct sockaddr_in *addr)
70135 +{
70136 + return 0;
70137 +}
70138 +
70139 +int
70140 +gr_check_user_change(kuid_t real, kuid_t effective, kuid_t fs)
70141 +{
70142 + return 0;
70143 +}
70144 +
70145 +int
70146 +gr_check_group_change(kgid_t real, kgid_t effective, kgid_t fs)
70147 +{
70148 + return 0;
70149 +}
70150 +
70151 +int gr_acl_enable_at_secure(void)
70152 +{
70153 + return 0;
70154 +}
70155 +
70156 +dev_t gr_get_dev_from_dentry(struct dentry *dentry)
70157 +{
70158 + return dentry->d_sb->s_dev;
70159 +}
70160 +
70161 +void gr_put_exec_file(struct task_struct *task)
70162 +{
70163 + return;
70164 +}
70165 +
70166 +#ifdef CONFIG_SECURITY
70167 +EXPORT_SYMBOL(gr_check_user_change);
70168 +EXPORT_SYMBOL(gr_check_group_change);
70169 +#endif
70170 diff --git a/grsecurity/grsec_exec.c b/grsecurity/grsec_exec.c
70171 new file mode 100644
70172 index 0000000..387032b
70173 --- /dev/null
70174 +++ b/grsecurity/grsec_exec.c
70175 @@ -0,0 +1,187 @@
70176 +#include <linux/kernel.h>
70177 +#include <linux/sched.h>
70178 +#include <linux/file.h>
70179 +#include <linux/binfmts.h>
70180 +#include <linux/fs.h>
70181 +#include <linux/types.h>
70182 +#include <linux/grdefs.h>
70183 +#include <linux/grsecurity.h>
70184 +#include <linux/grinternal.h>
70185 +#include <linux/capability.h>
70186 +#include <linux/module.h>
70187 +#include <linux/compat.h>
70188 +
70189 +#include <asm/uaccess.h>
70190 +
70191 +#ifdef CONFIG_GRKERNSEC_EXECLOG
70192 +static char gr_exec_arg_buf[132];
70193 +static DEFINE_MUTEX(gr_exec_arg_mutex);
70194 +#endif
70195 +
70196 +struct user_arg_ptr {
70197 +#ifdef CONFIG_COMPAT
70198 + bool is_compat;
70199 +#endif
70200 + union {
70201 + const char __user *const __user *native;
70202 +#ifdef CONFIG_COMPAT
70203 + const compat_uptr_t __user *compat;
70204 +#endif
70205 + } ptr;
70206 +};
70207 +
70208 +extern const char __user *get_user_arg_ptr(struct user_arg_ptr argv, int nr);
70209 +
70210 +void
70211 +gr_handle_exec_args(struct linux_binprm *bprm, struct user_arg_ptr argv)
70212 +{
70213 +#ifdef CONFIG_GRKERNSEC_EXECLOG
70214 + char *grarg = gr_exec_arg_buf;
70215 + unsigned int i, x, execlen = 0;
70216 + char c;
70217 +
70218 + if (!((grsec_enable_execlog && grsec_enable_group &&
70219 + in_group_p(grsec_audit_gid))
70220 + || (grsec_enable_execlog && !grsec_enable_group)))
70221 + return;
70222 +
70223 + mutex_lock(&gr_exec_arg_mutex);
70224 + memset(grarg, 0, sizeof(gr_exec_arg_buf));
70225 +
70226 + for (i = 0; i < bprm->argc && execlen < 128; i++) {
70227 + const char __user *p;
70228 + unsigned int len;
70229 +
70230 + p = get_user_arg_ptr(argv, i);
70231 + if (IS_ERR(p))
70232 + goto log;
70233 +
70234 + len = strnlen_user(p, 128 - execlen);
70235 + if (len > 128 - execlen)
70236 + len = 128 - execlen;
70237 + else if (len > 0)
70238 + len--;
70239 + if (copy_from_user(grarg + execlen, p, len))
70240 + goto log;
70241 +
70242 + /* rewrite unprintable characters */
70243 + for (x = 0; x < len; x++) {
70244 + c = *(grarg + execlen + x);
70245 + if (c < 32 || c > 126)
70246 + *(grarg + execlen + x) = ' ';
70247 + }
70248 +
70249 + execlen += len;
70250 + *(grarg + execlen) = ' ';
70251 + *(grarg + execlen + 1) = '\0';
70252 + execlen++;
70253 + }
70254 +
70255 + log:
70256 + gr_log_fs_str(GR_DO_AUDIT, GR_EXEC_AUDIT_MSG, bprm->file->f_path.dentry,
70257 + bprm->file->f_path.mnt, grarg);
70258 + mutex_unlock(&gr_exec_arg_mutex);
70259 +#endif
70260 + return;
70261 +}
70262 +
70263 +#ifdef CONFIG_GRKERNSEC
70264 +extern int gr_acl_is_capable(const int cap);
70265 +extern int gr_acl_is_capable_nolog(const int cap);
70266 +extern int gr_task_acl_is_capable(const struct task_struct *task, const struct cred *cred, const int cap);
70267 +extern int gr_task_acl_is_capable_nolog(const struct task_struct *task, const int cap);
70268 +extern int gr_chroot_is_capable(const int cap);
70269 +extern int gr_chroot_is_capable_nolog(const int cap);
70270 +extern int gr_task_chroot_is_capable(const struct task_struct *task, const struct cred *cred, const int cap);
70271 +extern int gr_task_chroot_is_capable_nolog(const struct task_struct *task, const int cap);
70272 +#endif
70273 +
70274 +const char *captab_log[] = {
70275 + "CAP_CHOWN",
70276 + "CAP_DAC_OVERRIDE",
70277 + "CAP_DAC_READ_SEARCH",
70278 + "CAP_FOWNER",
70279 + "CAP_FSETID",
70280 + "CAP_KILL",
70281 + "CAP_SETGID",
70282 + "CAP_SETUID",
70283 + "CAP_SETPCAP",
70284 + "CAP_LINUX_IMMUTABLE",
70285 + "CAP_NET_BIND_SERVICE",
70286 + "CAP_NET_BROADCAST",
70287 + "CAP_NET_ADMIN",
70288 + "CAP_NET_RAW",
70289 + "CAP_IPC_LOCK",
70290 + "CAP_IPC_OWNER",
70291 + "CAP_SYS_MODULE",
70292 + "CAP_SYS_RAWIO",
70293 + "CAP_SYS_CHROOT",
70294 + "CAP_SYS_PTRACE",
70295 + "CAP_SYS_PACCT",
70296 + "CAP_SYS_ADMIN",
70297 + "CAP_SYS_BOOT",
70298 + "CAP_SYS_NICE",
70299 + "CAP_SYS_RESOURCE",
70300 + "CAP_SYS_TIME",
70301 + "CAP_SYS_TTY_CONFIG",
70302 + "CAP_MKNOD",
70303 + "CAP_LEASE",
70304 + "CAP_AUDIT_WRITE",
70305 + "CAP_AUDIT_CONTROL",
70306 + "CAP_SETFCAP",
70307 + "CAP_MAC_OVERRIDE",
70308 + "CAP_MAC_ADMIN",
70309 + "CAP_SYSLOG",
70310 + "CAP_WAKE_ALARM"
70311 +};
70312 +
70313 +int captab_log_entries = sizeof(captab_log)/sizeof(captab_log[0]);
70314 +
70315 +int gr_is_capable(const int cap)
70316 +{
70317 +#ifdef CONFIG_GRKERNSEC
70318 + if (gr_acl_is_capable(cap) && gr_chroot_is_capable(cap))
70319 + return 1;
70320 + return 0;
70321 +#else
70322 + return 1;
70323 +#endif
70324 +}
70325 +
70326 +int gr_task_is_capable(const struct task_struct *task, const struct cred *cred, const int cap)
70327 +{
70328 +#ifdef CONFIG_GRKERNSEC
70329 + if (gr_task_acl_is_capable(task, cred, cap) && gr_task_chroot_is_capable(task, cred, cap))
70330 + return 1;
70331 + return 0;
70332 +#else
70333 + return 1;
70334 +#endif
70335 +}
70336 +
70337 +int gr_is_capable_nolog(const int cap)
70338 +{
70339 +#ifdef CONFIG_GRKERNSEC
70340 + if (gr_acl_is_capable_nolog(cap) && gr_chroot_is_capable_nolog(cap))
70341 + return 1;
70342 + return 0;
70343 +#else
70344 + return 1;
70345 +#endif
70346 +}
70347 +
70348 +int gr_task_is_capable_nolog(const struct task_struct *task, const int cap)
70349 +{
70350 +#ifdef CONFIG_GRKERNSEC
70351 + if (gr_task_acl_is_capable_nolog(task, cap) && gr_task_chroot_is_capable_nolog(task, cap))
70352 + return 1;
70353 + return 0;
70354 +#else
70355 + return 1;
70356 +#endif
70357 +}
70358 +
70359 +EXPORT_SYMBOL(gr_is_capable);
70360 +EXPORT_SYMBOL(gr_is_capable_nolog);
70361 +EXPORT_SYMBOL(gr_task_is_capable);
70362 +EXPORT_SYMBOL(gr_task_is_capable_nolog);
70363 diff --git a/grsecurity/grsec_fifo.c b/grsecurity/grsec_fifo.c
70364 new file mode 100644
70365 index 0000000..06cc6ea
70366 --- /dev/null
70367 +++ b/grsecurity/grsec_fifo.c
70368 @@ -0,0 +1,24 @@
70369 +#include <linux/kernel.h>
70370 +#include <linux/sched.h>
70371 +#include <linux/fs.h>
70372 +#include <linux/file.h>
70373 +#include <linux/grinternal.h>
70374 +
70375 +int
70376 +gr_handle_fifo(const struct dentry *dentry, const struct vfsmount *mnt,
70377 + const struct dentry *dir, const int flag, const int acc_mode)
70378 +{
70379 +#ifdef CONFIG_GRKERNSEC_FIFO
70380 + const struct cred *cred = current_cred();
70381 +
70382 + if (grsec_enable_fifo && S_ISFIFO(dentry->d_inode->i_mode) &&
70383 + !(flag & O_EXCL) && (dir->d_inode->i_mode & S_ISVTX) &&
70384 + !uid_eq(dentry->d_inode->i_uid, dir->d_inode->i_uid) &&
70385 + !uid_eq(cred->fsuid, dentry->d_inode->i_uid)) {
70386 + if (!inode_permission(dentry->d_inode, acc_mode))
70387 + 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));
70388 + return -EACCES;
70389 + }
70390 +#endif
70391 + return 0;
70392 +}
70393 diff --git a/grsecurity/grsec_fork.c b/grsecurity/grsec_fork.c
70394 new file mode 100644
70395 index 0000000..8ca18bf
70396 --- /dev/null
70397 +++ b/grsecurity/grsec_fork.c
70398 @@ -0,0 +1,23 @@
70399 +#include <linux/kernel.h>
70400 +#include <linux/sched.h>
70401 +#include <linux/grsecurity.h>
70402 +#include <linux/grinternal.h>
70403 +#include <linux/errno.h>
70404 +
70405 +void
70406 +gr_log_forkfail(const int retval)
70407 +{
70408 +#ifdef CONFIG_GRKERNSEC_FORKFAIL
70409 + if (grsec_enable_forkfail && (retval == -EAGAIN || retval == -ENOMEM)) {
70410 + switch (retval) {
70411 + case -EAGAIN:
70412 + gr_log_str(GR_DONT_AUDIT, GR_FAILFORK_MSG, "EAGAIN");
70413 + break;
70414 + case -ENOMEM:
70415 + gr_log_str(GR_DONT_AUDIT, GR_FAILFORK_MSG, "ENOMEM");
70416 + break;
70417 + }
70418 + }
70419 +#endif
70420 + return;
70421 +}
70422 diff --git a/grsecurity/grsec_init.c b/grsecurity/grsec_init.c
70423 new file mode 100644
70424 index 0000000..a88e901
70425 --- /dev/null
70426 +++ b/grsecurity/grsec_init.c
70427 @@ -0,0 +1,272 @@
70428 +#include <linux/kernel.h>
70429 +#include <linux/sched.h>
70430 +#include <linux/mm.h>
70431 +#include <linux/gracl.h>
70432 +#include <linux/slab.h>
70433 +#include <linux/vmalloc.h>
70434 +#include <linux/percpu.h>
70435 +#include <linux/module.h>
70436 +
70437 +int grsec_enable_ptrace_readexec;
70438 +int grsec_enable_setxid;
70439 +int grsec_enable_symlinkown;
70440 +kgid_t grsec_symlinkown_gid;
70441 +int grsec_enable_brute;
70442 +int grsec_enable_link;
70443 +int grsec_enable_dmesg;
70444 +int grsec_enable_harden_ptrace;
70445 +int grsec_enable_harden_ipc;
70446 +int grsec_enable_fifo;
70447 +int grsec_enable_execlog;
70448 +int grsec_enable_signal;
70449 +int grsec_enable_forkfail;
70450 +int grsec_enable_audit_ptrace;
70451 +int grsec_enable_time;
70452 +int grsec_enable_group;
70453 +kgid_t grsec_audit_gid;
70454 +int grsec_enable_chdir;
70455 +int grsec_enable_mount;
70456 +int grsec_enable_rofs;
70457 +int grsec_deny_new_usb;
70458 +int grsec_enable_chroot_findtask;
70459 +int grsec_enable_chroot_mount;
70460 +int grsec_enable_chroot_shmat;
70461 +int grsec_enable_chroot_fchdir;
70462 +int grsec_enable_chroot_double;
70463 +int grsec_enable_chroot_pivot;
70464 +int grsec_enable_chroot_chdir;
70465 +int grsec_enable_chroot_chmod;
70466 +int grsec_enable_chroot_mknod;
70467 +int grsec_enable_chroot_nice;
70468 +int grsec_enable_chroot_execlog;
70469 +int grsec_enable_chroot_caps;
70470 +int grsec_enable_chroot_sysctl;
70471 +int grsec_enable_chroot_unix;
70472 +int grsec_enable_tpe;
70473 +kgid_t grsec_tpe_gid;
70474 +int grsec_enable_blackhole;
70475 +#ifdef CONFIG_IPV6_MODULE
70476 +EXPORT_SYMBOL(grsec_enable_blackhole);
70477 +#endif
70478 +int grsec_lastack_retries;
70479 +int grsec_enable_tpe_all;
70480 +int grsec_enable_tpe_invert;
70481 +int grsec_enable_socket_all;
70482 +kgid_t grsec_socket_all_gid;
70483 +int grsec_enable_socket_client;
70484 +kgid_t grsec_socket_client_gid;
70485 +int grsec_enable_socket_server;
70486 +kgid_t grsec_socket_server_gid;
70487 +int grsec_resource_logging;
70488 +int grsec_disable_privio;
70489 +int grsec_enable_log_rwxmaps;
70490 +int grsec_lock;
70491 +
70492 +DEFINE_SPINLOCK(grsec_alert_lock);
70493 +unsigned long grsec_alert_wtime = 0;
70494 +unsigned long grsec_alert_fyet = 0;
70495 +
70496 +DEFINE_SPINLOCK(grsec_audit_lock);
70497 +
70498 +DEFINE_RWLOCK(grsec_exec_file_lock);
70499 +
70500 +char *gr_shared_page[4];
70501 +
70502 +char *gr_alert_log_fmt;
70503 +char *gr_audit_log_fmt;
70504 +char *gr_alert_log_buf;
70505 +char *gr_audit_log_buf;
70506 +
70507 +void __init
70508 +grsecurity_init(void)
70509 +{
70510 + int j;
70511 + /* create the per-cpu shared pages */
70512 +
70513 +#ifdef CONFIG_X86
70514 + memset((char *)(0x41a + PAGE_OFFSET), 0, 36);
70515 +#endif
70516 +
70517 + for (j = 0; j < 4; j++) {
70518 + gr_shared_page[j] = (char *)__alloc_percpu(PAGE_SIZE, __alignof__(unsigned long long));
70519 + if (gr_shared_page[j] == NULL) {
70520 + panic("Unable to allocate grsecurity shared page");
70521 + return;
70522 + }
70523 + }
70524 +
70525 + /* allocate log buffers */
70526 + gr_alert_log_fmt = kmalloc(512, GFP_KERNEL);
70527 + if (!gr_alert_log_fmt) {
70528 + panic("Unable to allocate grsecurity alert log format buffer");
70529 + return;
70530 + }
70531 + gr_audit_log_fmt = kmalloc(512, GFP_KERNEL);
70532 + if (!gr_audit_log_fmt) {
70533 + panic("Unable to allocate grsecurity audit log format buffer");
70534 + return;
70535 + }
70536 + gr_alert_log_buf = (char *) get_zeroed_page(GFP_KERNEL);
70537 + if (!gr_alert_log_buf) {
70538 + panic("Unable to allocate grsecurity alert log buffer");
70539 + return;
70540 + }
70541 + gr_audit_log_buf = (char *) get_zeroed_page(GFP_KERNEL);
70542 + if (!gr_audit_log_buf) {
70543 + panic("Unable to allocate grsecurity audit log buffer");
70544 + return;
70545 + }
70546 +
70547 +#ifdef CONFIG_GRKERNSEC_IO
70548 +#if !defined(CONFIG_GRKERNSEC_SYSCTL_DISTRO)
70549 + grsec_disable_privio = 1;
70550 +#elif defined(CONFIG_GRKERNSEC_SYSCTL_ON)
70551 + grsec_disable_privio = 1;
70552 +#else
70553 + grsec_disable_privio = 0;
70554 +#endif
70555 +#endif
70556 +
70557 +#ifdef CONFIG_GRKERNSEC_TPE_INVERT
70558 + /* for backward compatibility, tpe_invert always defaults to on if
70559 + enabled in the kernel
70560 + */
70561 + grsec_enable_tpe_invert = 1;
70562 +#endif
70563 +
70564 +#if !defined(CONFIG_GRKERNSEC_SYSCTL) || defined(CONFIG_GRKERNSEC_SYSCTL_ON)
70565 +#ifndef CONFIG_GRKERNSEC_SYSCTL
70566 + grsec_lock = 1;
70567 +#endif
70568 +
70569 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
70570 + grsec_enable_log_rwxmaps = 1;
70571 +#endif
70572 +#ifdef CONFIG_GRKERNSEC_AUDIT_GROUP
70573 + grsec_enable_group = 1;
70574 + grsec_audit_gid = KGIDT_INIT(CONFIG_GRKERNSEC_AUDIT_GID);
70575 +#endif
70576 +#ifdef CONFIG_GRKERNSEC_PTRACE_READEXEC
70577 + grsec_enable_ptrace_readexec = 1;
70578 +#endif
70579 +#ifdef CONFIG_GRKERNSEC_AUDIT_CHDIR
70580 + grsec_enable_chdir = 1;
70581 +#endif
70582 +#ifdef CONFIG_GRKERNSEC_HARDEN_PTRACE
70583 + grsec_enable_harden_ptrace = 1;
70584 +#endif
70585 +#ifdef CONFIG_GRKERNSEC_HARDEN_IPC
70586 + grsec_enable_harden_ipc = 1;
70587 +#endif
70588 +#ifdef CONFIG_GRKERNSEC_AUDIT_MOUNT
70589 + grsec_enable_mount = 1;
70590 +#endif
70591 +#ifdef CONFIG_GRKERNSEC_LINK
70592 + grsec_enable_link = 1;
70593 +#endif
70594 +#ifdef CONFIG_GRKERNSEC_BRUTE
70595 + grsec_enable_brute = 1;
70596 +#endif
70597 +#ifdef CONFIG_GRKERNSEC_DMESG
70598 + grsec_enable_dmesg = 1;
70599 +#endif
70600 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
70601 + grsec_enable_blackhole = 1;
70602 + grsec_lastack_retries = 4;
70603 +#endif
70604 +#ifdef CONFIG_GRKERNSEC_FIFO
70605 + grsec_enable_fifo = 1;
70606 +#endif
70607 +#ifdef CONFIG_GRKERNSEC_EXECLOG
70608 + grsec_enable_execlog = 1;
70609 +#endif
70610 +#ifdef CONFIG_GRKERNSEC_SETXID
70611 + grsec_enable_setxid = 1;
70612 +#endif
70613 +#ifdef CONFIG_GRKERNSEC_SIGNAL
70614 + grsec_enable_signal = 1;
70615 +#endif
70616 +#ifdef CONFIG_GRKERNSEC_FORKFAIL
70617 + grsec_enable_forkfail = 1;
70618 +#endif
70619 +#ifdef CONFIG_GRKERNSEC_TIME
70620 + grsec_enable_time = 1;
70621 +#endif
70622 +#ifdef CONFIG_GRKERNSEC_RESLOG
70623 + grsec_resource_logging = 1;
70624 +#endif
70625 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
70626 + grsec_enable_chroot_findtask = 1;
70627 +#endif
70628 +#ifdef CONFIG_GRKERNSEC_CHROOT_UNIX
70629 + grsec_enable_chroot_unix = 1;
70630 +#endif
70631 +#ifdef CONFIG_GRKERNSEC_CHROOT_MOUNT
70632 + grsec_enable_chroot_mount = 1;
70633 +#endif
70634 +#ifdef CONFIG_GRKERNSEC_CHROOT_FCHDIR
70635 + grsec_enable_chroot_fchdir = 1;
70636 +#endif
70637 +#ifdef CONFIG_GRKERNSEC_CHROOT_SHMAT
70638 + grsec_enable_chroot_shmat = 1;
70639 +#endif
70640 +#ifdef CONFIG_GRKERNSEC_AUDIT_PTRACE
70641 + grsec_enable_audit_ptrace = 1;
70642 +#endif
70643 +#ifdef CONFIG_GRKERNSEC_CHROOT_DOUBLE
70644 + grsec_enable_chroot_double = 1;
70645 +#endif
70646 +#ifdef CONFIG_GRKERNSEC_CHROOT_PIVOT
70647 + grsec_enable_chroot_pivot = 1;
70648 +#endif
70649 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHDIR
70650 + grsec_enable_chroot_chdir = 1;
70651 +#endif
70652 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHMOD
70653 + grsec_enable_chroot_chmod = 1;
70654 +#endif
70655 +#ifdef CONFIG_GRKERNSEC_CHROOT_MKNOD
70656 + grsec_enable_chroot_mknod = 1;
70657 +#endif
70658 +#ifdef CONFIG_GRKERNSEC_CHROOT_NICE
70659 + grsec_enable_chroot_nice = 1;
70660 +#endif
70661 +#ifdef CONFIG_GRKERNSEC_CHROOT_EXECLOG
70662 + grsec_enable_chroot_execlog = 1;
70663 +#endif
70664 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
70665 + grsec_enable_chroot_caps = 1;
70666 +#endif
70667 +#ifdef CONFIG_GRKERNSEC_CHROOT_SYSCTL
70668 + grsec_enable_chroot_sysctl = 1;
70669 +#endif
70670 +#ifdef CONFIG_GRKERNSEC_SYMLINKOWN
70671 + grsec_enable_symlinkown = 1;
70672 + grsec_symlinkown_gid = KGIDT_INIT(CONFIG_GRKERNSEC_SYMLINKOWN_GID);
70673 +#endif
70674 +#ifdef CONFIG_GRKERNSEC_TPE
70675 + grsec_enable_tpe = 1;
70676 + grsec_tpe_gid = KGIDT_INIT(CONFIG_GRKERNSEC_TPE_GID);
70677 +#ifdef CONFIG_GRKERNSEC_TPE_ALL
70678 + grsec_enable_tpe_all = 1;
70679 +#endif
70680 +#endif
70681 +#ifdef CONFIG_GRKERNSEC_SOCKET_ALL
70682 + grsec_enable_socket_all = 1;
70683 + grsec_socket_all_gid = KGIDT_INIT(CONFIG_GRKERNSEC_SOCKET_ALL_GID);
70684 +#endif
70685 +#ifdef CONFIG_GRKERNSEC_SOCKET_CLIENT
70686 + grsec_enable_socket_client = 1;
70687 + grsec_socket_client_gid = KGIDT_INIT(CONFIG_GRKERNSEC_SOCKET_CLIENT_GID);
70688 +#endif
70689 +#ifdef CONFIG_GRKERNSEC_SOCKET_SERVER
70690 + grsec_enable_socket_server = 1;
70691 + grsec_socket_server_gid = KGIDT_INIT(CONFIG_GRKERNSEC_SOCKET_SERVER_GID);
70692 +#endif
70693 +#endif
70694 +#ifdef CONFIG_GRKERNSEC_DENYUSB_FORCE
70695 + grsec_deny_new_usb = 1;
70696 +#endif
70697 +
70698 + return;
70699 +}
70700 diff --git a/grsecurity/grsec_ipc.c b/grsecurity/grsec_ipc.c
70701 new file mode 100644
70702 index 0000000..f365de0
70703 --- /dev/null
70704 +++ b/grsecurity/grsec_ipc.c
70705 @@ -0,0 +1,22 @@
70706 +#include <linux/kernel.h>
70707 +#include <linux/mm.h>
70708 +#include <linux/sched.h>
70709 +#include <linux/file.h>
70710 +#include <linux/ipc.h>
70711 +#include <linux/ipc_namespace.h>
70712 +#include <linux/grsecurity.h>
70713 +#include <linux/grinternal.h>
70714 +
70715 +int
70716 +gr_ipc_permitted(struct ipc_namespace *ns, struct kern_ipc_perm *ipcp, int requested_mode, int granted_mode)
70717 +{
70718 +#ifdef CONFIG_GRKERNSEC_HARDEN_IPC
70719 + int write = (requested_mode & 00002);
70720 +
70721 + if (grsec_enable_harden_ipc && !(requested_mode & ~granted_mode & 0007) && !ns_capable_nolog(ns->user_ns, CAP_IPC_OWNER)) {
70722 + gr_log_str2_int(GR_DONT_AUDIT, GR_IPC_DENIED_MSG, write ? "write" : "read", write ? "writ" : "read", GR_GLOBAL_UID(ipcp->cuid));
70723 + return 0;
70724 + }
70725 +#endif
70726 + return 1;
70727 +}
70728 diff --git a/grsecurity/grsec_link.c b/grsecurity/grsec_link.c
70729 new file mode 100644
70730 index 0000000..5e05e20
70731 --- /dev/null
70732 +++ b/grsecurity/grsec_link.c
70733 @@ -0,0 +1,58 @@
70734 +#include <linux/kernel.h>
70735 +#include <linux/sched.h>
70736 +#include <linux/fs.h>
70737 +#include <linux/file.h>
70738 +#include <linux/grinternal.h>
70739 +
70740 +int gr_handle_symlink_owner(const struct path *link, const struct inode *target)
70741 +{
70742 +#ifdef CONFIG_GRKERNSEC_SYMLINKOWN
70743 + const struct inode *link_inode = link->dentry->d_inode;
70744 +
70745 + if (grsec_enable_symlinkown && in_group_p(grsec_symlinkown_gid) &&
70746 + /* ignore root-owned links, e.g. /proc/self */
70747 + gr_is_global_nonroot(link_inode->i_uid) && target &&
70748 + !uid_eq(link_inode->i_uid, target->i_uid)) {
70749 + gr_log_fs_int2(GR_DONT_AUDIT, GR_SYMLINKOWNER_MSG, link->dentry, link->mnt, link_inode->i_uid, target->i_uid);
70750 + return 1;
70751 + }
70752 +#endif
70753 + return 0;
70754 +}
70755 +
70756 +int
70757 +gr_handle_follow_link(const struct inode *parent,
70758 + const struct inode *inode,
70759 + const struct dentry *dentry, const struct vfsmount *mnt)
70760 +{
70761 +#ifdef CONFIG_GRKERNSEC_LINK
70762 + const struct cred *cred = current_cred();
70763 +
70764 + if (grsec_enable_link && S_ISLNK(inode->i_mode) &&
70765 + (parent->i_mode & S_ISVTX) && !uid_eq(parent->i_uid, inode->i_uid) &&
70766 + (parent->i_mode & S_IWOTH) && !uid_eq(cred->fsuid, inode->i_uid)) {
70767 + gr_log_fs_int2(GR_DONT_AUDIT, GR_SYMLINK_MSG, dentry, mnt, inode->i_uid, inode->i_gid);
70768 + return -EACCES;
70769 + }
70770 +#endif
70771 + return 0;
70772 +}
70773 +
70774 +int
70775 +gr_handle_hardlink(const struct dentry *dentry,
70776 + const struct vfsmount *mnt,
70777 + struct inode *inode, const int mode, const struct filename *to)
70778 +{
70779 +#ifdef CONFIG_GRKERNSEC_LINK
70780 + const struct cred *cred = current_cred();
70781 +
70782 + if (grsec_enable_link && !uid_eq(cred->fsuid, inode->i_uid) &&
70783 + (!S_ISREG(mode) || is_privileged_binary(dentry) ||
70784 + (inode_permission(inode, MAY_READ | MAY_WRITE))) &&
70785 + !capable(CAP_FOWNER) && gr_is_global_nonroot(cred->uid)) {
70786 + gr_log_fs_int2_str(GR_DONT_AUDIT, GR_HARDLINK_MSG, dentry, mnt, inode->i_uid, inode->i_gid, to->name);
70787 + return -EPERM;
70788 + }
70789 +#endif
70790 + return 0;
70791 +}
70792 diff --git a/grsecurity/grsec_log.c b/grsecurity/grsec_log.c
70793 new file mode 100644
70794 index 0000000..dbe0a6b
70795 --- /dev/null
70796 +++ b/grsecurity/grsec_log.c
70797 @@ -0,0 +1,341 @@
70798 +#include <linux/kernel.h>
70799 +#include <linux/sched.h>
70800 +#include <linux/file.h>
70801 +#include <linux/tty.h>
70802 +#include <linux/fs.h>
70803 +#include <linux/mm.h>
70804 +#include <linux/grinternal.h>
70805 +
70806 +#ifdef CONFIG_TREE_PREEMPT_RCU
70807 +#define DISABLE_PREEMPT() preempt_disable()
70808 +#define ENABLE_PREEMPT() preempt_enable()
70809 +#else
70810 +#define DISABLE_PREEMPT()
70811 +#define ENABLE_PREEMPT()
70812 +#endif
70813 +
70814 +#define BEGIN_LOCKS(x) \
70815 + DISABLE_PREEMPT(); \
70816 + rcu_read_lock(); \
70817 + read_lock(&tasklist_lock); \
70818 + read_lock(&grsec_exec_file_lock); \
70819 + if (x != GR_DO_AUDIT) \
70820 + spin_lock(&grsec_alert_lock); \
70821 + else \
70822 + spin_lock(&grsec_audit_lock)
70823 +
70824 +#define END_LOCKS(x) \
70825 + if (x != GR_DO_AUDIT) \
70826 + spin_unlock(&grsec_alert_lock); \
70827 + else \
70828 + spin_unlock(&grsec_audit_lock); \
70829 + read_unlock(&grsec_exec_file_lock); \
70830 + read_unlock(&tasklist_lock); \
70831 + rcu_read_unlock(); \
70832 + ENABLE_PREEMPT(); \
70833 + if (x == GR_DONT_AUDIT) \
70834 + gr_handle_alertkill(current)
70835 +
70836 +enum {
70837 + FLOODING,
70838 + NO_FLOODING
70839 +};
70840 +
70841 +extern char *gr_alert_log_fmt;
70842 +extern char *gr_audit_log_fmt;
70843 +extern char *gr_alert_log_buf;
70844 +extern char *gr_audit_log_buf;
70845 +
70846 +static int gr_log_start(int audit)
70847 +{
70848 + char *loglevel = (audit == GR_DO_AUDIT) ? KERN_INFO : KERN_ALERT;
70849 + char *fmt = (audit == GR_DO_AUDIT) ? gr_audit_log_fmt : gr_alert_log_fmt;
70850 + char *buf = (audit == GR_DO_AUDIT) ? gr_audit_log_buf : gr_alert_log_buf;
70851 +#if (CONFIG_GRKERNSEC_FLOODTIME > 0 && CONFIG_GRKERNSEC_FLOODBURST > 0)
70852 + unsigned long curr_secs = get_seconds();
70853 +
70854 + if (audit == GR_DO_AUDIT)
70855 + goto set_fmt;
70856 +
70857 + if (!grsec_alert_wtime || time_after(curr_secs, grsec_alert_wtime + CONFIG_GRKERNSEC_FLOODTIME)) {
70858 + grsec_alert_wtime = curr_secs;
70859 + grsec_alert_fyet = 0;
70860 + } else if (time_before_eq(curr_secs, grsec_alert_wtime + CONFIG_GRKERNSEC_FLOODTIME)
70861 + && (grsec_alert_fyet < CONFIG_GRKERNSEC_FLOODBURST)) {
70862 + grsec_alert_fyet++;
70863 + } else if (grsec_alert_fyet == CONFIG_GRKERNSEC_FLOODBURST) {
70864 + grsec_alert_wtime = curr_secs;
70865 + grsec_alert_fyet++;
70866 + printk(KERN_ALERT "grsec: more alerts, logging disabled for %d seconds\n", CONFIG_GRKERNSEC_FLOODTIME);
70867 + return FLOODING;
70868 + }
70869 + else return FLOODING;
70870 +
70871 +set_fmt:
70872 +#endif
70873 + memset(buf, 0, PAGE_SIZE);
70874 + if (current->signal->curr_ip && gr_acl_is_enabled()) {
70875 + sprintf(fmt, "%s%s", loglevel, "grsec: From %pI4: (%.64s:%c:%.950s) ");
70876 + snprintf(buf, PAGE_SIZE - 1, fmt, &current->signal->curr_ip, current->role->rolename, gr_roletype_to_char(), current->acl->filename);
70877 + } else if (current->signal->curr_ip) {
70878 + sprintf(fmt, "%s%s", loglevel, "grsec: From %pI4: ");
70879 + snprintf(buf, PAGE_SIZE - 1, fmt, &current->signal->curr_ip);
70880 + } else if (gr_acl_is_enabled()) {
70881 + sprintf(fmt, "%s%s", loglevel, "grsec: (%.64s:%c:%.950s) ");
70882 + snprintf(buf, PAGE_SIZE - 1, fmt, current->role->rolename, gr_roletype_to_char(), current->acl->filename);
70883 + } else {
70884 + sprintf(fmt, "%s%s", loglevel, "grsec: ");
70885 + strcpy(buf, fmt);
70886 + }
70887 +
70888 + return NO_FLOODING;
70889 +}
70890 +
70891 +static void gr_log_middle(int audit, const char *msg, va_list ap)
70892 + __attribute__ ((format (printf, 2, 0)));
70893 +
70894 +static void gr_log_middle(int audit, const char *msg, va_list ap)
70895 +{
70896 + char *buf = (audit == GR_DO_AUDIT) ? gr_audit_log_buf : gr_alert_log_buf;
70897 + unsigned int len = strlen(buf);
70898 +
70899 + vsnprintf(buf + len, PAGE_SIZE - len - 1, msg, ap);
70900 +
70901 + return;
70902 +}
70903 +
70904 +static void gr_log_middle_varargs(int audit, const char *msg, ...)
70905 + __attribute__ ((format (printf, 2, 3)));
70906 +
70907 +static void gr_log_middle_varargs(int audit, const char *msg, ...)
70908 +{
70909 + char *buf = (audit == GR_DO_AUDIT) ? gr_audit_log_buf : gr_alert_log_buf;
70910 + unsigned int len = strlen(buf);
70911 + va_list ap;
70912 +
70913 + va_start(ap, msg);
70914 + vsnprintf(buf + len, PAGE_SIZE - len - 1, msg, ap);
70915 + va_end(ap);
70916 +
70917 + return;
70918 +}
70919 +
70920 +static void gr_log_end(int audit, int append_default)
70921 +{
70922 + char *buf = (audit == GR_DO_AUDIT) ? gr_audit_log_buf : gr_alert_log_buf;
70923 + if (append_default) {
70924 + struct task_struct *task = current;
70925 + struct task_struct *parent = task->real_parent;
70926 + const struct cred *cred = __task_cred(task);
70927 + const struct cred *pcred = __task_cred(parent);
70928 + unsigned int len = strlen(buf);
70929 +
70930 + 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));
70931 + }
70932 +
70933 + printk("%s\n", buf);
70934 +
70935 + return;
70936 +}
70937 +
70938 +void gr_log_varargs(int audit, const char *msg, int argtypes, ...)
70939 +{
70940 + int logtype;
70941 + char *result = (audit == GR_DO_AUDIT) ? "successful" : "denied";
70942 + char *str1 = NULL, *str2 = NULL, *str3 = NULL;
70943 + void *voidptr = NULL;
70944 + int num1 = 0, num2 = 0;
70945 + unsigned long ulong1 = 0, ulong2 = 0;
70946 + struct dentry *dentry = NULL;
70947 + struct vfsmount *mnt = NULL;
70948 + struct file *file = NULL;
70949 + struct task_struct *task = NULL;
70950 + struct vm_area_struct *vma = NULL;
70951 + const struct cred *cred, *pcred;
70952 + va_list ap;
70953 +
70954 + BEGIN_LOCKS(audit);
70955 + logtype = gr_log_start(audit);
70956 + if (logtype == FLOODING) {
70957 + END_LOCKS(audit);
70958 + return;
70959 + }
70960 + va_start(ap, argtypes);
70961 + switch (argtypes) {
70962 + case GR_TTYSNIFF:
70963 + task = va_arg(ap, struct task_struct *);
70964 + 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));
70965 + break;
70966 + case GR_SYSCTL_HIDDEN:
70967 + str1 = va_arg(ap, char *);
70968 + gr_log_middle_varargs(audit, msg, result, str1);
70969 + break;
70970 + case GR_RBAC:
70971 + dentry = va_arg(ap, struct dentry *);
70972 + mnt = va_arg(ap, struct vfsmount *);
70973 + gr_log_middle_varargs(audit, msg, result, gr_to_filename(dentry, mnt));
70974 + break;
70975 + case GR_RBAC_STR:
70976 + dentry = va_arg(ap, struct dentry *);
70977 + mnt = va_arg(ap, struct vfsmount *);
70978 + str1 = va_arg(ap, char *);
70979 + gr_log_middle_varargs(audit, msg, result, gr_to_filename(dentry, mnt), str1);
70980 + break;
70981 + case GR_STR_RBAC:
70982 + str1 = va_arg(ap, char *);
70983 + dentry = va_arg(ap, struct dentry *);
70984 + mnt = va_arg(ap, struct vfsmount *);
70985 + gr_log_middle_varargs(audit, msg, result, str1, gr_to_filename(dentry, mnt));
70986 + break;
70987 + case GR_RBAC_MODE2:
70988 + dentry = va_arg(ap, struct dentry *);
70989 + mnt = va_arg(ap, struct vfsmount *);
70990 + str1 = va_arg(ap, char *);
70991 + str2 = va_arg(ap, char *);
70992 + gr_log_middle_varargs(audit, msg, result, gr_to_filename(dentry, mnt), str1, str2);
70993 + break;
70994 + case GR_RBAC_MODE3:
70995 + dentry = va_arg(ap, struct dentry *);
70996 + mnt = va_arg(ap, struct vfsmount *);
70997 + str1 = va_arg(ap, char *);
70998 + str2 = va_arg(ap, char *);
70999 + str3 = va_arg(ap, char *);
71000 + gr_log_middle_varargs(audit, msg, result, gr_to_filename(dentry, mnt), str1, str2, str3);
71001 + break;
71002 + case GR_FILENAME:
71003 + dentry = va_arg(ap, struct dentry *);
71004 + mnt = va_arg(ap, struct vfsmount *);
71005 + gr_log_middle_varargs(audit, msg, gr_to_filename(dentry, mnt));
71006 + break;
71007 + case GR_STR_FILENAME:
71008 + str1 = va_arg(ap, char *);
71009 + dentry = va_arg(ap, struct dentry *);
71010 + mnt = va_arg(ap, struct vfsmount *);
71011 + gr_log_middle_varargs(audit, msg, str1, gr_to_filename(dentry, mnt));
71012 + break;
71013 + case GR_FILENAME_STR:
71014 + dentry = va_arg(ap, struct dentry *);
71015 + mnt = va_arg(ap, struct vfsmount *);
71016 + str1 = va_arg(ap, char *);
71017 + gr_log_middle_varargs(audit, msg, gr_to_filename(dentry, mnt), str1);
71018 + break;
71019 + case GR_FILENAME_TWO_INT:
71020 + dentry = va_arg(ap, struct dentry *);
71021 + mnt = va_arg(ap, struct vfsmount *);
71022 + num1 = va_arg(ap, int);
71023 + num2 = va_arg(ap, int);
71024 + gr_log_middle_varargs(audit, msg, gr_to_filename(dentry, mnt), num1, num2);
71025 + break;
71026 + case GR_FILENAME_TWO_INT_STR:
71027 + dentry = va_arg(ap, struct dentry *);
71028 + mnt = va_arg(ap, struct vfsmount *);
71029 + num1 = va_arg(ap, int);
71030 + num2 = va_arg(ap, int);
71031 + str1 = va_arg(ap, char *);
71032 + gr_log_middle_varargs(audit, msg, gr_to_filename(dentry, mnt), num1, num2, str1);
71033 + break;
71034 + case GR_TEXTREL:
71035 + file = va_arg(ap, struct file *);
71036 + ulong1 = va_arg(ap, unsigned long);
71037 + ulong2 = va_arg(ap, unsigned long);
71038 + gr_log_middle_varargs(audit, msg, file ? gr_to_filename(file->f_path.dentry, file->f_path.mnt) : "<anonymous mapping>", ulong1, ulong2);
71039 + break;
71040 + case GR_PTRACE:
71041 + task = va_arg(ap, struct task_struct *);
71042 + 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));
71043 + break;
71044 + case GR_RESOURCE:
71045 + task = va_arg(ap, struct task_struct *);
71046 + cred = __task_cred(task);
71047 + pcred = __task_cred(task->real_parent);
71048 + ulong1 = va_arg(ap, unsigned long);
71049 + str1 = va_arg(ap, char *);
71050 + ulong2 = va_arg(ap, unsigned long);
71051 + 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));
71052 + break;
71053 + case GR_CAP:
71054 + task = va_arg(ap, struct task_struct *);
71055 + cred = __task_cred(task);
71056 + pcred = __task_cred(task->real_parent);
71057 + str1 = va_arg(ap, char *);
71058 + 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));
71059 + break;
71060 + case GR_SIG:
71061 + str1 = va_arg(ap, char *);
71062 + voidptr = va_arg(ap, void *);
71063 + gr_log_middle_varargs(audit, msg, str1, voidptr);
71064 + break;
71065 + case GR_SIG2:
71066 + task = va_arg(ap, struct task_struct *);
71067 + cred = __task_cred(task);
71068 + pcred = __task_cred(task->real_parent);
71069 + num1 = va_arg(ap, int);
71070 + 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));
71071 + break;
71072 + case GR_CRASH1:
71073 + task = va_arg(ap, struct task_struct *);
71074 + cred = __task_cred(task);
71075 + pcred = __task_cred(task->real_parent);
71076 + ulong1 = va_arg(ap, unsigned long);
71077 + 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);
71078 + break;
71079 + case GR_CRASH2:
71080 + task = va_arg(ap, struct task_struct *);
71081 + cred = __task_cred(task);
71082 + pcred = __task_cred(task->real_parent);
71083 + ulong1 = va_arg(ap, unsigned long);
71084 + 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);
71085 + break;
71086 + case GR_RWXMAP:
71087 + file = va_arg(ap, struct file *);
71088 + gr_log_middle_varargs(audit, msg, file ? gr_to_filename(file->f_path.dentry, file->f_path.mnt) : "<anonymous mapping>");
71089 + break;
71090 + case GR_RWXMAPVMA:
71091 + vma = va_arg(ap, struct vm_area_struct *);
71092 + if (vma->vm_file)
71093 + str1 = gr_to_filename(vma->vm_file->f_path.dentry, vma->vm_file->f_path.mnt);
71094 + else if (vma->vm_flags & (VM_GROWSDOWN | VM_GROWSUP))
71095 + str1 = "<stack>";
71096 + else if (vma->vm_start <= current->mm->brk &&
71097 + vma->vm_end >= current->mm->start_brk)
71098 + str1 = "<heap>";
71099 + else
71100 + str1 = "<anonymous mapping>";
71101 + gr_log_middle_varargs(audit, msg, str1);
71102 + break;
71103 + case GR_PSACCT:
71104 + {
71105 + unsigned int wday, cday;
71106 + __u8 whr, chr;
71107 + __u8 wmin, cmin;
71108 + __u8 wsec, csec;
71109 + char cur_tty[64] = { 0 };
71110 + char parent_tty[64] = { 0 };
71111 +
71112 + task = va_arg(ap, struct task_struct *);
71113 + wday = va_arg(ap, unsigned int);
71114 + cday = va_arg(ap, unsigned int);
71115 + whr = va_arg(ap, int);
71116 + chr = va_arg(ap, int);
71117 + wmin = va_arg(ap, int);
71118 + cmin = va_arg(ap, int);
71119 + wsec = va_arg(ap, int);
71120 + csec = va_arg(ap, int);
71121 + ulong1 = va_arg(ap, unsigned long);
71122 + cred = __task_cred(task);
71123 + pcred = __task_cred(task->real_parent);
71124 +
71125 + 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));
71126 + }
71127 + break;
71128 + default:
71129 + gr_log_middle(audit, msg, ap);
71130 + }
71131 + va_end(ap);
71132 + // these don't need DEFAULTSECARGS printed on the end
71133 + if (argtypes == GR_CRASH1 || argtypes == GR_CRASH2)
71134 + gr_log_end(audit, 0);
71135 + else
71136 + gr_log_end(audit, 1);
71137 + END_LOCKS(audit);
71138 +}
71139 diff --git a/grsecurity/grsec_mem.c b/grsecurity/grsec_mem.c
71140 new file mode 100644
71141 index 0000000..f536303
71142 --- /dev/null
71143 +++ b/grsecurity/grsec_mem.c
71144 @@ -0,0 +1,40 @@
71145 +#include <linux/kernel.h>
71146 +#include <linux/sched.h>
71147 +#include <linux/mm.h>
71148 +#include <linux/mman.h>
71149 +#include <linux/grinternal.h>
71150 +
71151 +void
71152 +gr_handle_ioperm(void)
71153 +{
71154 + gr_log_noargs(GR_DONT_AUDIT, GR_IOPERM_MSG);
71155 + return;
71156 +}
71157 +
71158 +void
71159 +gr_handle_iopl(void)
71160 +{
71161 + gr_log_noargs(GR_DONT_AUDIT, GR_IOPL_MSG);
71162 + return;
71163 +}
71164 +
71165 +void
71166 +gr_handle_mem_readwrite(u64 from, u64 to)
71167 +{
71168 + gr_log_two_u64(GR_DONT_AUDIT, GR_MEM_READWRITE_MSG, from, to);
71169 + return;
71170 +}
71171 +
71172 +void
71173 +gr_handle_vm86(void)
71174 +{
71175 + gr_log_noargs(GR_DONT_AUDIT, GR_VM86_MSG);
71176 + return;
71177 +}
71178 +
71179 +void
71180 +gr_log_badprocpid(const char *entry)
71181 +{
71182 + gr_log_str(GR_DONT_AUDIT, GR_BADPROCPID_MSG, entry);
71183 + return;
71184 +}
71185 diff --git a/grsecurity/grsec_mount.c b/grsecurity/grsec_mount.c
71186 new file mode 100644
71187 index 0000000..2131422
71188 --- /dev/null
71189 +++ b/grsecurity/grsec_mount.c
71190 @@ -0,0 +1,62 @@
71191 +#include <linux/kernel.h>
71192 +#include <linux/sched.h>
71193 +#include <linux/mount.h>
71194 +#include <linux/grsecurity.h>
71195 +#include <linux/grinternal.h>
71196 +
71197 +void
71198 +gr_log_remount(const char *devname, const int retval)
71199 +{
71200 +#ifdef CONFIG_GRKERNSEC_AUDIT_MOUNT
71201 + if (grsec_enable_mount && (retval >= 0))
71202 + gr_log_str(GR_DO_AUDIT, GR_REMOUNT_AUDIT_MSG, devname ? devname : "none");
71203 +#endif
71204 + return;
71205 +}
71206 +
71207 +void
71208 +gr_log_unmount(const char *devname, const int retval)
71209 +{
71210 +#ifdef CONFIG_GRKERNSEC_AUDIT_MOUNT
71211 + if (grsec_enable_mount && (retval >= 0))
71212 + gr_log_str(GR_DO_AUDIT, GR_UNMOUNT_AUDIT_MSG, devname ? devname : "none");
71213 +#endif
71214 + return;
71215 +}
71216 +
71217 +void
71218 +gr_log_mount(const char *from, const char *to, const int retval)
71219 +{
71220 +#ifdef CONFIG_GRKERNSEC_AUDIT_MOUNT
71221 + if (grsec_enable_mount && (retval >= 0))
71222 + gr_log_str_str(GR_DO_AUDIT, GR_MOUNT_AUDIT_MSG, from ? from : "none", to);
71223 +#endif
71224 + return;
71225 +}
71226 +
71227 +int
71228 +gr_handle_rofs_mount(struct dentry *dentry, struct vfsmount *mnt, int mnt_flags)
71229 +{
71230 +#ifdef CONFIG_GRKERNSEC_ROFS
71231 + if (grsec_enable_rofs && !(mnt_flags & MNT_READONLY)) {
71232 + gr_log_fs_generic(GR_DO_AUDIT, GR_ROFS_MOUNT_MSG, dentry, mnt);
71233 + return -EPERM;
71234 + } else
71235 + return 0;
71236 +#endif
71237 + return 0;
71238 +}
71239 +
71240 +int
71241 +gr_handle_rofs_blockwrite(struct dentry *dentry, struct vfsmount *mnt, int acc_mode)
71242 +{
71243 +#ifdef CONFIG_GRKERNSEC_ROFS
71244 + if (grsec_enable_rofs && (acc_mode & MAY_WRITE) &&
71245 + dentry->d_inode && S_ISBLK(dentry->d_inode->i_mode)) {
71246 + gr_log_fs_generic(GR_DO_AUDIT, GR_ROFS_BLOCKWRITE_MSG, dentry, mnt);
71247 + return -EPERM;
71248 + } else
71249 + return 0;
71250 +#endif
71251 + return 0;
71252 +}
71253 diff --git a/grsecurity/grsec_pax.c b/grsecurity/grsec_pax.c
71254 new file mode 100644
71255 index 0000000..6ee9d50
71256 --- /dev/null
71257 +++ b/grsecurity/grsec_pax.c
71258 @@ -0,0 +1,45 @@
71259 +#include <linux/kernel.h>
71260 +#include <linux/sched.h>
71261 +#include <linux/mm.h>
71262 +#include <linux/file.h>
71263 +#include <linux/grinternal.h>
71264 +#include <linux/grsecurity.h>
71265 +
71266 +void
71267 +gr_log_textrel(struct vm_area_struct * vma)
71268 +{
71269 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
71270 + if (grsec_enable_log_rwxmaps)
71271 + gr_log_textrel_ulong_ulong(GR_DONT_AUDIT, GR_TEXTREL_AUDIT_MSG, vma->vm_file, vma->vm_start, vma->vm_pgoff);
71272 +#endif
71273 + return;
71274 +}
71275 +
71276 +void gr_log_ptgnustack(struct file *file)
71277 +{
71278 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
71279 + if (grsec_enable_log_rwxmaps)
71280 + gr_log_rwxmap(GR_DONT_AUDIT, GR_PTGNUSTACK_MSG, file);
71281 +#endif
71282 + return;
71283 +}
71284 +
71285 +void
71286 +gr_log_rwxmmap(struct file *file)
71287 +{
71288 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
71289 + if (grsec_enable_log_rwxmaps)
71290 + gr_log_rwxmap(GR_DONT_AUDIT, GR_RWXMMAP_MSG, file);
71291 +#endif
71292 + return;
71293 +}
71294 +
71295 +void
71296 +gr_log_rwxmprotect(struct vm_area_struct *vma)
71297 +{
71298 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
71299 + if (grsec_enable_log_rwxmaps)
71300 + gr_log_rwxmap_vma(GR_DONT_AUDIT, GR_RWXMPROTECT_MSG, vma);
71301 +#endif
71302 + return;
71303 +}
71304 diff --git a/grsecurity/grsec_ptrace.c b/grsecurity/grsec_ptrace.c
71305 new file mode 100644
71306 index 0000000..f7f29aa
71307 --- /dev/null
71308 +++ b/grsecurity/grsec_ptrace.c
71309 @@ -0,0 +1,30 @@
71310 +#include <linux/kernel.h>
71311 +#include <linux/sched.h>
71312 +#include <linux/grinternal.h>
71313 +#include <linux/security.h>
71314 +
71315 +void
71316 +gr_audit_ptrace(struct task_struct *task)
71317 +{
71318 +#ifdef CONFIG_GRKERNSEC_AUDIT_PTRACE
71319 + if (grsec_enable_audit_ptrace)
71320 + gr_log_ptrace(GR_DO_AUDIT, GR_PTRACE_AUDIT_MSG, task);
71321 +#endif
71322 + return;
71323 +}
71324 +
71325 +int
71326 +gr_ptrace_readexec(struct file *file, int unsafe_flags)
71327 +{
71328 +#ifdef CONFIG_GRKERNSEC_PTRACE_READEXEC
71329 + const struct dentry *dentry = file->f_path.dentry;
71330 + const struct vfsmount *mnt = file->f_path.mnt;
71331 +
71332 + if (grsec_enable_ptrace_readexec && (unsafe_flags & LSM_UNSAFE_PTRACE) &&
71333 + (inode_permission(dentry->d_inode, MAY_READ) || !gr_acl_handle_open(dentry, mnt, MAY_READ))) {
71334 + gr_log_fs_generic(GR_DONT_AUDIT, GR_PTRACE_READEXEC_MSG, dentry, mnt);
71335 + return -EACCES;
71336 + }
71337 +#endif
71338 + return 0;
71339 +}
71340 diff --git a/grsecurity/grsec_sig.c b/grsecurity/grsec_sig.c
71341 new file mode 100644
71342 index 0000000..3860c7e
71343 --- /dev/null
71344 +++ b/grsecurity/grsec_sig.c
71345 @@ -0,0 +1,236 @@
71346 +#include <linux/kernel.h>
71347 +#include <linux/sched.h>
71348 +#include <linux/fs.h>
71349 +#include <linux/delay.h>
71350 +#include <linux/grsecurity.h>
71351 +#include <linux/grinternal.h>
71352 +#include <linux/hardirq.h>
71353 +
71354 +char *signames[] = {
71355 + [SIGSEGV] = "Segmentation fault",
71356 + [SIGILL] = "Illegal instruction",
71357 + [SIGABRT] = "Abort",
71358 + [SIGBUS] = "Invalid alignment/Bus error"
71359 +};
71360 +
71361 +void
71362 +gr_log_signal(const int sig, const void *addr, const struct task_struct *t)
71363 +{
71364 +#ifdef CONFIG_GRKERNSEC_SIGNAL
71365 + if (grsec_enable_signal && ((sig == SIGSEGV) || (sig == SIGILL) ||
71366 + (sig == SIGABRT) || (sig == SIGBUS))) {
71367 + if (task_pid_nr(t) == task_pid_nr(current)) {
71368 + gr_log_sig_addr(GR_DONT_AUDIT_GOOD, GR_UNISIGLOG_MSG, signames[sig], addr);
71369 + } else {
71370 + gr_log_sig_task(GR_DONT_AUDIT_GOOD, GR_DUALSIGLOG_MSG, t, sig);
71371 + }
71372 + }
71373 +#endif
71374 + return;
71375 +}
71376 +
71377 +int
71378 +gr_handle_signal(const struct task_struct *p, const int sig)
71379 +{
71380 +#ifdef CONFIG_GRKERNSEC
71381 + /* ignore the 0 signal for protected task checks */
71382 + if (task_pid_nr(current) > 1 && sig && gr_check_protected_task(p)) {
71383 + gr_log_sig_task(GR_DONT_AUDIT, GR_SIG_ACL_MSG, p, sig);
71384 + return -EPERM;
71385 + } else if (gr_pid_is_chrooted((struct task_struct *)p)) {
71386 + return -EPERM;
71387 + }
71388 +#endif
71389 + return 0;
71390 +}
71391 +
71392 +#ifdef CONFIG_GRKERNSEC
71393 +extern int specific_send_sig_info(int sig, struct siginfo *info, struct task_struct *t);
71394 +
71395 +int gr_fake_force_sig(int sig, struct task_struct *t)
71396 +{
71397 + unsigned long int flags;
71398 + int ret, blocked, ignored;
71399 + struct k_sigaction *action;
71400 +
71401 + spin_lock_irqsave(&t->sighand->siglock, flags);
71402 + action = &t->sighand->action[sig-1];
71403 + ignored = action->sa.sa_handler == SIG_IGN;
71404 + blocked = sigismember(&t->blocked, sig);
71405 + if (blocked || ignored) {
71406 + action->sa.sa_handler = SIG_DFL;
71407 + if (blocked) {
71408 + sigdelset(&t->blocked, sig);
71409 + recalc_sigpending_and_wake(t);
71410 + }
71411 + }
71412 + if (action->sa.sa_handler == SIG_DFL)
71413 + t->signal->flags &= ~SIGNAL_UNKILLABLE;
71414 + ret = specific_send_sig_info(sig, SEND_SIG_PRIV, t);
71415 +
71416 + spin_unlock_irqrestore(&t->sighand->siglock, flags);
71417 +
71418 + return ret;
71419 +}
71420 +#endif
71421 +
71422 +#define GR_USER_BAN_TIME (15 * 60)
71423 +#define GR_DAEMON_BRUTE_TIME (30 * 60)
71424 +
71425 +void gr_handle_brute_attach(int dumpable)
71426 +{
71427 +#ifdef CONFIG_GRKERNSEC_BRUTE
71428 + struct task_struct *p = current;
71429 + kuid_t uid = GLOBAL_ROOT_UID;
71430 + int daemon = 0;
71431 +
71432 + if (!grsec_enable_brute)
71433 + return;
71434 +
71435 + rcu_read_lock();
71436 + read_lock(&tasklist_lock);
71437 + read_lock(&grsec_exec_file_lock);
71438 + if (p->real_parent && gr_is_same_file(p->real_parent->exec_file, p->exec_file)) {
71439 + p->real_parent->brute_expires = get_seconds() + GR_DAEMON_BRUTE_TIME;
71440 + p->real_parent->brute = 1;
71441 + daemon = 1;
71442 + } else {
71443 + const struct cred *cred = __task_cred(p), *cred2;
71444 + struct task_struct *tsk, *tsk2;
71445 +
71446 + if (dumpable != SUID_DUMP_USER && gr_is_global_nonroot(cred->uid)) {
71447 + struct user_struct *user;
71448 +
71449 + uid = cred->uid;
71450 +
71451 + /* this is put upon execution past expiration */
71452 + user = find_user(uid);
71453 + if (user == NULL)
71454 + goto unlock;
71455 + user->suid_banned = 1;
71456 + user->suid_ban_expires = get_seconds() + GR_USER_BAN_TIME;
71457 + if (user->suid_ban_expires == ~0UL)
71458 + user->suid_ban_expires--;
71459 +
71460 + /* only kill other threads of the same binary, from the same user */
71461 + do_each_thread(tsk2, tsk) {
71462 + cred2 = __task_cred(tsk);
71463 + if (tsk != p && uid_eq(cred2->uid, uid) && gr_is_same_file(tsk->exec_file, p->exec_file))
71464 + gr_fake_force_sig(SIGKILL, tsk);
71465 + } while_each_thread(tsk2, tsk);
71466 + }
71467 + }
71468 +unlock:
71469 + read_unlock(&grsec_exec_file_lock);
71470 + read_unlock(&tasklist_lock);
71471 + rcu_read_unlock();
71472 +
71473 + if (gr_is_global_nonroot(uid))
71474 + 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);
71475 + else if (daemon)
71476 + gr_log_noargs(GR_DONT_AUDIT, GR_BRUTE_DAEMON_MSG);
71477 +
71478 +#endif
71479 + return;
71480 +}
71481 +
71482 +void gr_handle_brute_check(void)
71483 +{
71484 +#ifdef CONFIG_GRKERNSEC_BRUTE
71485 + struct task_struct *p = current;
71486 +
71487 + if (unlikely(p->brute)) {
71488 + if (!grsec_enable_brute)
71489 + p->brute = 0;
71490 + else if (time_before(get_seconds(), p->brute_expires))
71491 + msleep(30 * 1000);
71492 + }
71493 +#endif
71494 + return;
71495 +}
71496 +
71497 +void gr_handle_kernel_exploit(void)
71498 +{
71499 +#ifdef CONFIG_GRKERNSEC_KERN_LOCKOUT
71500 + const struct cred *cred;
71501 + struct task_struct *tsk, *tsk2;
71502 + struct user_struct *user;
71503 + kuid_t uid;
71504 +
71505 + if (in_irq() || in_serving_softirq() || in_nmi())
71506 + panic("grsec: halting the system due to suspicious kernel crash caused in interrupt context");
71507 +
71508 + uid = current_uid();
71509 +
71510 + if (gr_is_global_root(uid))
71511 + panic("grsec: halting the system due to suspicious kernel crash caused by root");
71512 + else {
71513 + /* kill all the processes of this user, hold a reference
71514 + to their creds struct, and prevent them from creating
71515 + another process until system reset
71516 + */
71517 + printk(KERN_ALERT "grsec: banning user with uid %u until system restart for suspicious kernel crash\n",
71518 + GR_GLOBAL_UID(uid));
71519 + /* we intentionally leak this ref */
71520 + user = get_uid(current->cred->user);
71521 + if (user)
71522 + user->kernel_banned = 1;
71523 +
71524 + /* kill all processes of this user */
71525 + read_lock(&tasklist_lock);
71526 + do_each_thread(tsk2, tsk) {
71527 + cred = __task_cred(tsk);
71528 + if (uid_eq(cred->uid, uid))
71529 + gr_fake_force_sig(SIGKILL, tsk);
71530 + } while_each_thread(tsk2, tsk);
71531 + read_unlock(&tasklist_lock);
71532 + }
71533 +#endif
71534 +}
71535 +
71536 +#ifdef CONFIG_GRKERNSEC_BRUTE
71537 +static bool suid_ban_expired(struct user_struct *user)
71538 +{
71539 + if (user->suid_ban_expires != ~0UL && time_after_eq(get_seconds(), user->suid_ban_expires)) {
71540 + user->suid_banned = 0;
71541 + user->suid_ban_expires = 0;
71542 + free_uid(user);
71543 + return true;
71544 + }
71545 +
71546 + return false;
71547 +}
71548 +#endif
71549 +
71550 +int gr_process_kernel_exec_ban(void)
71551 +{
71552 +#ifdef CONFIG_GRKERNSEC_KERN_LOCKOUT
71553 + if (unlikely(current->cred->user->kernel_banned))
71554 + return -EPERM;
71555 +#endif
71556 + return 0;
71557 +}
71558 +
71559 +int gr_process_kernel_setuid_ban(struct user_struct *user)
71560 +{
71561 +#ifdef CONFIG_GRKERNSEC_KERN_LOCKOUT
71562 + if (unlikely(user->kernel_banned))
71563 + gr_fake_force_sig(SIGKILL, current);
71564 +#endif
71565 + return 0;
71566 +}
71567 +
71568 +int gr_process_suid_exec_ban(const struct linux_binprm *bprm)
71569 +{
71570 +#ifdef CONFIG_GRKERNSEC_BRUTE
71571 + struct user_struct *user = current->cred->user;
71572 + if (unlikely(user->suid_banned)) {
71573 + if (suid_ban_expired(user))
71574 + return 0;
71575 + /* disallow execution of suid binaries only */
71576 + else if (!uid_eq(bprm->cred->euid, current->cred->uid))
71577 + return -EPERM;
71578 + }
71579 +#endif
71580 + return 0;
71581 +}
71582 diff --git a/grsecurity/grsec_sock.c b/grsecurity/grsec_sock.c
71583 new file mode 100644
71584 index 0000000..4030d57
71585 --- /dev/null
71586 +++ b/grsecurity/grsec_sock.c
71587 @@ -0,0 +1,244 @@
71588 +#include <linux/kernel.h>
71589 +#include <linux/module.h>
71590 +#include <linux/sched.h>
71591 +#include <linux/file.h>
71592 +#include <linux/net.h>
71593 +#include <linux/in.h>
71594 +#include <linux/ip.h>
71595 +#include <net/sock.h>
71596 +#include <net/inet_sock.h>
71597 +#include <linux/grsecurity.h>
71598 +#include <linux/grinternal.h>
71599 +#include <linux/gracl.h>
71600 +
71601 +extern int gr_search_udp_recvmsg(const struct sock *sk, const struct sk_buff *skb);
71602 +extern int gr_search_udp_sendmsg(const struct sock *sk, const struct sockaddr_in *addr);
71603 +
71604 +EXPORT_SYMBOL(gr_search_udp_recvmsg);
71605 +EXPORT_SYMBOL(gr_search_udp_sendmsg);
71606 +
71607 +#ifdef CONFIG_UNIX_MODULE
71608 +EXPORT_SYMBOL(gr_acl_handle_unix);
71609 +EXPORT_SYMBOL(gr_acl_handle_mknod);
71610 +EXPORT_SYMBOL(gr_handle_chroot_unix);
71611 +EXPORT_SYMBOL(gr_handle_create);
71612 +#endif
71613 +
71614 +#ifdef CONFIG_GRKERNSEC
71615 +#define gr_conn_table_size 32749
71616 +struct conn_table_entry {
71617 + struct conn_table_entry *next;
71618 + struct signal_struct *sig;
71619 +};
71620 +
71621 +struct conn_table_entry *gr_conn_table[gr_conn_table_size];
71622 +DEFINE_SPINLOCK(gr_conn_table_lock);
71623 +
71624 +extern const char * gr_socktype_to_name(unsigned char type);
71625 +extern const char * gr_proto_to_name(unsigned char proto);
71626 +extern const char * gr_sockfamily_to_name(unsigned char family);
71627 +
71628 +static __inline__ int
71629 +conn_hash(__u32 saddr, __u32 daddr, __u16 sport, __u16 dport, unsigned int size)
71630 +{
71631 + return ((daddr + saddr + (sport << 8) + (dport << 16)) % size);
71632 +}
71633 +
71634 +static __inline__ int
71635 +conn_match(const struct signal_struct *sig, __u32 saddr, __u32 daddr,
71636 + __u16 sport, __u16 dport)
71637 +{
71638 + if (unlikely(sig->gr_saddr == saddr && sig->gr_daddr == daddr &&
71639 + sig->gr_sport == sport && sig->gr_dport == dport))
71640 + return 1;
71641 + else
71642 + return 0;
71643 +}
71644 +
71645 +static void gr_add_to_task_ip_table_nolock(struct signal_struct *sig, struct conn_table_entry *newent)
71646 +{
71647 + struct conn_table_entry **match;
71648 + unsigned int index;
71649 +
71650 + index = conn_hash(sig->gr_saddr, sig->gr_daddr,
71651 + sig->gr_sport, sig->gr_dport,
71652 + gr_conn_table_size);
71653 +
71654 + newent->sig = sig;
71655 +
71656 + match = &gr_conn_table[index];
71657 + newent->next = *match;
71658 + *match = newent;
71659 +
71660 + return;
71661 +}
71662 +
71663 +static void gr_del_task_from_ip_table_nolock(struct signal_struct *sig)
71664 +{
71665 + struct conn_table_entry *match, *last = NULL;
71666 + unsigned int index;
71667 +
71668 + index = conn_hash(sig->gr_saddr, sig->gr_daddr,
71669 + sig->gr_sport, sig->gr_dport,
71670 + gr_conn_table_size);
71671 +
71672 + match = gr_conn_table[index];
71673 + while (match && !conn_match(match->sig,
71674 + sig->gr_saddr, sig->gr_daddr, sig->gr_sport,
71675 + sig->gr_dport)) {
71676 + last = match;
71677 + match = match->next;
71678 + }
71679 +
71680 + if (match) {
71681 + if (last)
71682 + last->next = match->next;
71683 + else
71684 + gr_conn_table[index] = NULL;
71685 + kfree(match);
71686 + }
71687 +
71688 + return;
71689 +}
71690 +
71691 +static struct signal_struct * gr_lookup_task_ip_table(__u32 saddr, __u32 daddr,
71692 + __u16 sport, __u16 dport)
71693 +{
71694 + struct conn_table_entry *match;
71695 + unsigned int index;
71696 +
71697 + index = conn_hash(saddr, daddr, sport, dport, gr_conn_table_size);
71698 +
71699 + match = gr_conn_table[index];
71700 + while (match && !conn_match(match->sig, saddr, daddr, sport, dport))
71701 + match = match->next;
71702 +
71703 + if (match)
71704 + return match->sig;
71705 + else
71706 + return NULL;
71707 +}
71708 +
71709 +#endif
71710 +
71711 +void gr_update_task_in_ip_table(struct task_struct *task, const struct inet_sock *inet)
71712 +{
71713 +#ifdef CONFIG_GRKERNSEC
71714 + struct signal_struct *sig = task->signal;
71715 + struct conn_table_entry *newent;
71716 +
71717 + newent = kmalloc(sizeof(struct conn_table_entry), GFP_ATOMIC);
71718 + if (newent == NULL)
71719 + return;
71720 + /* no bh lock needed since we are called with bh disabled */
71721 + spin_lock(&gr_conn_table_lock);
71722 + gr_del_task_from_ip_table_nolock(sig);
71723 + sig->gr_saddr = inet->inet_rcv_saddr;
71724 + sig->gr_daddr = inet->inet_daddr;
71725 + sig->gr_sport = inet->inet_sport;
71726 + sig->gr_dport = inet->inet_dport;
71727 + gr_add_to_task_ip_table_nolock(sig, newent);
71728 + spin_unlock(&gr_conn_table_lock);
71729 +#endif
71730 + return;
71731 +}
71732 +
71733 +void gr_del_task_from_ip_table(struct task_struct *task)
71734 +{
71735 +#ifdef CONFIG_GRKERNSEC
71736 + spin_lock_bh(&gr_conn_table_lock);
71737 + gr_del_task_from_ip_table_nolock(task->signal);
71738 + spin_unlock_bh(&gr_conn_table_lock);
71739 +#endif
71740 + return;
71741 +}
71742 +
71743 +void
71744 +gr_attach_curr_ip(const struct sock *sk)
71745 +{
71746 +#ifdef CONFIG_GRKERNSEC
71747 + struct signal_struct *p, *set;
71748 + const struct inet_sock *inet = inet_sk(sk);
71749 +
71750 + if (unlikely(sk->sk_protocol != IPPROTO_TCP))
71751 + return;
71752 +
71753 + set = current->signal;
71754 +
71755 + spin_lock_bh(&gr_conn_table_lock);
71756 + p = gr_lookup_task_ip_table(inet->inet_daddr, inet->inet_rcv_saddr,
71757 + inet->inet_dport, inet->inet_sport);
71758 + if (unlikely(p != NULL)) {
71759 + set->curr_ip = p->curr_ip;
71760 + set->used_accept = 1;
71761 + gr_del_task_from_ip_table_nolock(p);
71762 + spin_unlock_bh(&gr_conn_table_lock);
71763 + return;
71764 + }
71765 + spin_unlock_bh(&gr_conn_table_lock);
71766 +
71767 + set->curr_ip = inet->inet_daddr;
71768 + set->used_accept = 1;
71769 +#endif
71770 + return;
71771 +}
71772 +
71773 +int
71774 +gr_handle_sock_all(const int family, const int type, const int protocol)
71775 +{
71776 +#ifdef CONFIG_GRKERNSEC_SOCKET_ALL
71777 + if (grsec_enable_socket_all && in_group_p(grsec_socket_all_gid) &&
71778 + (family != AF_UNIX)) {
71779 + if (family == AF_INET)
71780 + gr_log_str3(GR_DONT_AUDIT, GR_SOCK_MSG, gr_sockfamily_to_name(family), gr_socktype_to_name(type), gr_proto_to_name(protocol));
71781 + else
71782 + gr_log_str2_int(GR_DONT_AUDIT, GR_SOCK_NOINET_MSG, gr_sockfamily_to_name(family), gr_socktype_to_name(type), protocol);
71783 + return -EACCES;
71784 + }
71785 +#endif
71786 + return 0;
71787 +}
71788 +
71789 +int
71790 +gr_handle_sock_server(const struct sockaddr *sck)
71791 +{
71792 +#ifdef CONFIG_GRKERNSEC_SOCKET_SERVER
71793 + if (grsec_enable_socket_server &&
71794 + in_group_p(grsec_socket_server_gid) &&
71795 + sck && (sck->sa_family != AF_UNIX) &&
71796 + (sck->sa_family != AF_LOCAL)) {
71797 + gr_log_noargs(GR_DONT_AUDIT, GR_BIND_MSG);
71798 + return -EACCES;
71799 + }
71800 +#endif
71801 + return 0;
71802 +}
71803 +
71804 +int
71805 +gr_handle_sock_server_other(const struct sock *sck)
71806 +{
71807 +#ifdef CONFIG_GRKERNSEC_SOCKET_SERVER
71808 + if (grsec_enable_socket_server &&
71809 + in_group_p(grsec_socket_server_gid) &&
71810 + sck && (sck->sk_family != AF_UNIX) &&
71811 + (sck->sk_family != AF_LOCAL)) {
71812 + gr_log_noargs(GR_DONT_AUDIT, GR_BIND_MSG);
71813 + return -EACCES;
71814 + }
71815 +#endif
71816 + return 0;
71817 +}
71818 +
71819 +int
71820 +gr_handle_sock_client(const struct sockaddr *sck)
71821 +{
71822 +#ifdef CONFIG_GRKERNSEC_SOCKET_CLIENT
71823 + if (grsec_enable_socket_client && in_group_p(grsec_socket_client_gid) &&
71824 + sck && (sck->sa_family != AF_UNIX) &&
71825 + (sck->sa_family != AF_LOCAL)) {
71826 + gr_log_noargs(GR_DONT_AUDIT, GR_CONNECT_MSG);
71827 + return -EACCES;
71828 + }
71829 +#endif
71830 + return 0;
71831 +}
71832 diff --git a/grsecurity/grsec_sysctl.c b/grsecurity/grsec_sysctl.c
71833 new file mode 100644
71834 index 0000000..8159888
71835 --- /dev/null
71836 +++ b/grsecurity/grsec_sysctl.c
71837 @@ -0,0 +1,479 @@
71838 +#include <linux/kernel.h>
71839 +#include <linux/sched.h>
71840 +#include <linux/sysctl.h>
71841 +#include <linux/grsecurity.h>
71842 +#include <linux/grinternal.h>
71843 +
71844 +int
71845 +gr_handle_sysctl_mod(const char *dirname, const char *name, const int op)
71846 +{
71847 +#ifdef CONFIG_GRKERNSEC_SYSCTL
71848 + if (dirname == NULL || name == NULL)
71849 + return 0;
71850 + if (!strcmp(dirname, "grsecurity") && grsec_lock && (op & MAY_WRITE)) {
71851 + gr_log_str(GR_DONT_AUDIT, GR_SYSCTL_MSG, name);
71852 + return -EACCES;
71853 + }
71854 +#endif
71855 + return 0;
71856 +}
71857 +
71858 +#if defined(CONFIG_GRKERNSEC_ROFS) || defined(CONFIG_GRKERNSEC_DENYUSB)
71859 +static int __maybe_unused __read_only one = 1;
71860 +#endif
71861 +
71862 +#if defined(CONFIG_GRKERNSEC_SYSCTL) || defined(CONFIG_GRKERNSEC_ROFS) || \
71863 + defined(CONFIG_GRKERNSEC_DENYUSB)
71864 +struct ctl_table grsecurity_table[] = {
71865 +#ifdef CONFIG_GRKERNSEC_SYSCTL
71866 +#ifdef CONFIG_GRKERNSEC_SYSCTL_DISTRO
71867 +#ifdef CONFIG_GRKERNSEC_IO
71868 + {
71869 + .procname = "disable_priv_io",
71870 + .data = &grsec_disable_privio,
71871 + .maxlen = sizeof(int),
71872 + .mode = 0600,
71873 + .proc_handler = &proc_dointvec,
71874 + },
71875 +#endif
71876 +#endif
71877 +#ifdef CONFIG_GRKERNSEC_LINK
71878 + {
71879 + .procname = "linking_restrictions",
71880 + .data = &grsec_enable_link,
71881 + .maxlen = sizeof(int),
71882 + .mode = 0600,
71883 + .proc_handler = &proc_dointvec,
71884 + },
71885 +#endif
71886 +#ifdef CONFIG_GRKERNSEC_SYMLINKOWN
71887 + {
71888 + .procname = "enforce_symlinksifowner",
71889 + .data = &grsec_enable_symlinkown,
71890 + .maxlen = sizeof(int),
71891 + .mode = 0600,
71892 + .proc_handler = &proc_dointvec,
71893 + },
71894 + {
71895 + .procname = "symlinkown_gid",
71896 + .data = &grsec_symlinkown_gid,
71897 + .maxlen = sizeof(int),
71898 + .mode = 0600,
71899 + .proc_handler = &proc_dointvec,
71900 + },
71901 +#endif
71902 +#ifdef CONFIG_GRKERNSEC_BRUTE
71903 + {
71904 + .procname = "deter_bruteforce",
71905 + .data = &grsec_enable_brute,
71906 + .maxlen = sizeof(int),
71907 + .mode = 0600,
71908 + .proc_handler = &proc_dointvec,
71909 + },
71910 +#endif
71911 +#ifdef CONFIG_GRKERNSEC_FIFO
71912 + {
71913 + .procname = "fifo_restrictions",
71914 + .data = &grsec_enable_fifo,
71915 + .maxlen = sizeof(int),
71916 + .mode = 0600,
71917 + .proc_handler = &proc_dointvec,
71918 + },
71919 +#endif
71920 +#ifdef CONFIG_GRKERNSEC_PTRACE_READEXEC
71921 + {
71922 + .procname = "ptrace_readexec",
71923 + .data = &grsec_enable_ptrace_readexec,
71924 + .maxlen = sizeof(int),
71925 + .mode = 0600,
71926 + .proc_handler = &proc_dointvec,
71927 + },
71928 +#endif
71929 +#ifdef CONFIG_GRKERNSEC_SETXID
71930 + {
71931 + .procname = "consistent_setxid",
71932 + .data = &grsec_enable_setxid,
71933 + .maxlen = sizeof(int),
71934 + .mode = 0600,
71935 + .proc_handler = &proc_dointvec,
71936 + },
71937 +#endif
71938 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
71939 + {
71940 + .procname = "ip_blackhole",
71941 + .data = &grsec_enable_blackhole,
71942 + .maxlen = sizeof(int),
71943 + .mode = 0600,
71944 + .proc_handler = &proc_dointvec,
71945 + },
71946 + {
71947 + .procname = "lastack_retries",
71948 + .data = &grsec_lastack_retries,
71949 + .maxlen = sizeof(int),
71950 + .mode = 0600,
71951 + .proc_handler = &proc_dointvec,
71952 + },
71953 +#endif
71954 +#ifdef CONFIG_GRKERNSEC_EXECLOG
71955 + {
71956 + .procname = "exec_logging",
71957 + .data = &grsec_enable_execlog,
71958 + .maxlen = sizeof(int),
71959 + .mode = 0600,
71960 + .proc_handler = &proc_dointvec,
71961 + },
71962 +#endif
71963 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
71964 + {
71965 + .procname = "rwxmap_logging",
71966 + .data = &grsec_enable_log_rwxmaps,
71967 + .maxlen = sizeof(int),
71968 + .mode = 0600,
71969 + .proc_handler = &proc_dointvec,
71970 + },
71971 +#endif
71972 +#ifdef CONFIG_GRKERNSEC_SIGNAL
71973 + {
71974 + .procname = "signal_logging",
71975 + .data = &grsec_enable_signal,
71976 + .maxlen = sizeof(int),
71977 + .mode = 0600,
71978 + .proc_handler = &proc_dointvec,
71979 + },
71980 +#endif
71981 +#ifdef CONFIG_GRKERNSEC_FORKFAIL
71982 + {
71983 + .procname = "forkfail_logging",
71984 + .data = &grsec_enable_forkfail,
71985 + .maxlen = sizeof(int),
71986 + .mode = 0600,
71987 + .proc_handler = &proc_dointvec,
71988 + },
71989 +#endif
71990 +#ifdef CONFIG_GRKERNSEC_TIME
71991 + {
71992 + .procname = "timechange_logging",
71993 + .data = &grsec_enable_time,
71994 + .maxlen = sizeof(int),
71995 + .mode = 0600,
71996 + .proc_handler = &proc_dointvec,
71997 + },
71998 +#endif
71999 +#ifdef CONFIG_GRKERNSEC_CHROOT_SHMAT
72000 + {
72001 + .procname = "chroot_deny_shmat",
72002 + .data = &grsec_enable_chroot_shmat,
72003 + .maxlen = sizeof(int),
72004 + .mode = 0600,
72005 + .proc_handler = &proc_dointvec,
72006 + },
72007 +#endif
72008 +#ifdef CONFIG_GRKERNSEC_CHROOT_UNIX
72009 + {
72010 + .procname = "chroot_deny_unix",
72011 + .data = &grsec_enable_chroot_unix,
72012 + .maxlen = sizeof(int),
72013 + .mode = 0600,
72014 + .proc_handler = &proc_dointvec,
72015 + },
72016 +#endif
72017 +#ifdef CONFIG_GRKERNSEC_CHROOT_MOUNT
72018 + {
72019 + .procname = "chroot_deny_mount",
72020 + .data = &grsec_enable_chroot_mount,
72021 + .maxlen = sizeof(int),
72022 + .mode = 0600,
72023 + .proc_handler = &proc_dointvec,
72024 + },
72025 +#endif
72026 +#ifdef CONFIG_GRKERNSEC_CHROOT_FCHDIR
72027 + {
72028 + .procname = "chroot_deny_fchdir",
72029 + .data = &grsec_enable_chroot_fchdir,
72030 + .maxlen = sizeof(int),
72031 + .mode = 0600,
72032 + .proc_handler = &proc_dointvec,
72033 + },
72034 +#endif
72035 +#ifdef CONFIG_GRKERNSEC_CHROOT_DOUBLE
72036 + {
72037 + .procname = "chroot_deny_chroot",
72038 + .data = &grsec_enable_chroot_double,
72039 + .maxlen = sizeof(int),
72040 + .mode = 0600,
72041 + .proc_handler = &proc_dointvec,
72042 + },
72043 +#endif
72044 +#ifdef CONFIG_GRKERNSEC_CHROOT_PIVOT
72045 + {
72046 + .procname = "chroot_deny_pivot",
72047 + .data = &grsec_enable_chroot_pivot,
72048 + .maxlen = sizeof(int),
72049 + .mode = 0600,
72050 + .proc_handler = &proc_dointvec,
72051 + },
72052 +#endif
72053 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHDIR
72054 + {
72055 + .procname = "chroot_enforce_chdir",
72056 + .data = &grsec_enable_chroot_chdir,
72057 + .maxlen = sizeof(int),
72058 + .mode = 0600,
72059 + .proc_handler = &proc_dointvec,
72060 + },
72061 +#endif
72062 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHMOD
72063 + {
72064 + .procname = "chroot_deny_chmod",
72065 + .data = &grsec_enable_chroot_chmod,
72066 + .maxlen = sizeof(int),
72067 + .mode = 0600,
72068 + .proc_handler = &proc_dointvec,
72069 + },
72070 +#endif
72071 +#ifdef CONFIG_GRKERNSEC_CHROOT_MKNOD
72072 + {
72073 + .procname = "chroot_deny_mknod",
72074 + .data = &grsec_enable_chroot_mknod,
72075 + .maxlen = sizeof(int),
72076 + .mode = 0600,
72077 + .proc_handler = &proc_dointvec,
72078 + },
72079 +#endif
72080 +#ifdef CONFIG_GRKERNSEC_CHROOT_NICE
72081 + {
72082 + .procname = "chroot_restrict_nice",
72083 + .data = &grsec_enable_chroot_nice,
72084 + .maxlen = sizeof(int),
72085 + .mode = 0600,
72086 + .proc_handler = &proc_dointvec,
72087 + },
72088 +#endif
72089 +#ifdef CONFIG_GRKERNSEC_CHROOT_EXECLOG
72090 + {
72091 + .procname = "chroot_execlog",
72092 + .data = &grsec_enable_chroot_execlog,
72093 + .maxlen = sizeof(int),
72094 + .mode = 0600,
72095 + .proc_handler = &proc_dointvec,
72096 + },
72097 +#endif
72098 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
72099 + {
72100 + .procname = "chroot_caps",
72101 + .data = &grsec_enable_chroot_caps,
72102 + .maxlen = sizeof(int),
72103 + .mode = 0600,
72104 + .proc_handler = &proc_dointvec,
72105 + },
72106 +#endif
72107 +#ifdef CONFIG_GRKERNSEC_CHROOT_SYSCTL
72108 + {
72109 + .procname = "chroot_deny_sysctl",
72110 + .data = &grsec_enable_chroot_sysctl,
72111 + .maxlen = sizeof(int),
72112 + .mode = 0600,
72113 + .proc_handler = &proc_dointvec,
72114 + },
72115 +#endif
72116 +#ifdef CONFIG_GRKERNSEC_TPE
72117 + {
72118 + .procname = "tpe",
72119 + .data = &grsec_enable_tpe,
72120 + .maxlen = sizeof(int),
72121 + .mode = 0600,
72122 + .proc_handler = &proc_dointvec,
72123 + },
72124 + {
72125 + .procname = "tpe_gid",
72126 + .data = &grsec_tpe_gid,
72127 + .maxlen = sizeof(int),
72128 + .mode = 0600,
72129 + .proc_handler = &proc_dointvec,
72130 + },
72131 +#endif
72132 +#ifdef CONFIG_GRKERNSEC_TPE_INVERT
72133 + {
72134 + .procname = "tpe_invert",
72135 + .data = &grsec_enable_tpe_invert,
72136 + .maxlen = sizeof(int),
72137 + .mode = 0600,
72138 + .proc_handler = &proc_dointvec,
72139 + },
72140 +#endif
72141 +#ifdef CONFIG_GRKERNSEC_TPE_ALL
72142 + {
72143 + .procname = "tpe_restrict_all",
72144 + .data = &grsec_enable_tpe_all,
72145 + .maxlen = sizeof(int),
72146 + .mode = 0600,
72147 + .proc_handler = &proc_dointvec,
72148 + },
72149 +#endif
72150 +#ifdef CONFIG_GRKERNSEC_SOCKET_ALL
72151 + {
72152 + .procname = "socket_all",
72153 + .data = &grsec_enable_socket_all,
72154 + .maxlen = sizeof(int),
72155 + .mode = 0600,
72156 + .proc_handler = &proc_dointvec,
72157 + },
72158 + {
72159 + .procname = "socket_all_gid",
72160 + .data = &grsec_socket_all_gid,
72161 + .maxlen = sizeof(int),
72162 + .mode = 0600,
72163 + .proc_handler = &proc_dointvec,
72164 + },
72165 +#endif
72166 +#ifdef CONFIG_GRKERNSEC_SOCKET_CLIENT
72167 + {
72168 + .procname = "socket_client",
72169 + .data = &grsec_enable_socket_client,
72170 + .maxlen = sizeof(int),
72171 + .mode = 0600,
72172 + .proc_handler = &proc_dointvec,
72173 + },
72174 + {
72175 + .procname = "socket_client_gid",
72176 + .data = &grsec_socket_client_gid,
72177 + .maxlen = sizeof(int),
72178 + .mode = 0600,
72179 + .proc_handler = &proc_dointvec,
72180 + },
72181 +#endif
72182 +#ifdef CONFIG_GRKERNSEC_SOCKET_SERVER
72183 + {
72184 + .procname = "socket_server",
72185 + .data = &grsec_enable_socket_server,
72186 + .maxlen = sizeof(int),
72187 + .mode = 0600,
72188 + .proc_handler = &proc_dointvec,
72189 + },
72190 + {
72191 + .procname = "socket_server_gid",
72192 + .data = &grsec_socket_server_gid,
72193 + .maxlen = sizeof(int),
72194 + .mode = 0600,
72195 + .proc_handler = &proc_dointvec,
72196 + },
72197 +#endif
72198 +#ifdef CONFIG_GRKERNSEC_AUDIT_GROUP
72199 + {
72200 + .procname = "audit_group",
72201 + .data = &grsec_enable_group,
72202 + .maxlen = sizeof(int),
72203 + .mode = 0600,
72204 + .proc_handler = &proc_dointvec,
72205 + },
72206 + {
72207 + .procname = "audit_gid",
72208 + .data = &grsec_audit_gid,
72209 + .maxlen = sizeof(int),
72210 + .mode = 0600,
72211 + .proc_handler = &proc_dointvec,
72212 + },
72213 +#endif
72214 +#ifdef CONFIG_GRKERNSEC_AUDIT_CHDIR
72215 + {
72216 + .procname = "audit_chdir",
72217 + .data = &grsec_enable_chdir,
72218 + .maxlen = sizeof(int),
72219 + .mode = 0600,
72220 + .proc_handler = &proc_dointvec,
72221 + },
72222 +#endif
72223 +#ifdef CONFIG_GRKERNSEC_AUDIT_MOUNT
72224 + {
72225 + .procname = "audit_mount",
72226 + .data = &grsec_enable_mount,
72227 + .maxlen = sizeof(int),
72228 + .mode = 0600,
72229 + .proc_handler = &proc_dointvec,
72230 + },
72231 +#endif
72232 +#ifdef CONFIG_GRKERNSEC_DMESG
72233 + {
72234 + .procname = "dmesg",
72235 + .data = &grsec_enable_dmesg,
72236 + .maxlen = sizeof(int),
72237 + .mode = 0600,
72238 + .proc_handler = &proc_dointvec,
72239 + },
72240 +#endif
72241 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
72242 + {
72243 + .procname = "chroot_findtask",
72244 + .data = &grsec_enable_chroot_findtask,
72245 + .maxlen = sizeof(int),
72246 + .mode = 0600,
72247 + .proc_handler = &proc_dointvec,
72248 + },
72249 +#endif
72250 +#ifdef CONFIG_GRKERNSEC_RESLOG
72251 + {
72252 + .procname = "resource_logging",
72253 + .data = &grsec_resource_logging,
72254 + .maxlen = sizeof(int),
72255 + .mode = 0600,
72256 + .proc_handler = &proc_dointvec,
72257 + },
72258 +#endif
72259 +#ifdef CONFIG_GRKERNSEC_AUDIT_PTRACE
72260 + {
72261 + .procname = "audit_ptrace",
72262 + .data = &grsec_enable_audit_ptrace,
72263 + .maxlen = sizeof(int),
72264 + .mode = 0600,
72265 + .proc_handler = &proc_dointvec,
72266 + },
72267 +#endif
72268 +#ifdef CONFIG_GRKERNSEC_HARDEN_PTRACE
72269 + {
72270 + .procname = "harden_ptrace",
72271 + .data = &grsec_enable_harden_ptrace,
72272 + .maxlen = sizeof(int),
72273 + .mode = 0600,
72274 + .proc_handler = &proc_dointvec,
72275 + },
72276 +#endif
72277 +#ifdef CONFIG_GRKERNSEC_HARDEN_IPC
72278 + {
72279 + .procname = "harden_ipc",
72280 + .data = &grsec_enable_harden_ipc,
72281 + .maxlen = sizeof(int),
72282 + .mode = 0600,
72283 + .proc_handler = &proc_dointvec,
72284 + },
72285 +#endif
72286 + {
72287 + .procname = "grsec_lock",
72288 + .data = &grsec_lock,
72289 + .maxlen = sizeof(int),
72290 + .mode = 0600,
72291 + .proc_handler = &proc_dointvec,
72292 + },
72293 +#endif
72294 +#ifdef CONFIG_GRKERNSEC_ROFS
72295 + {
72296 + .procname = "romount_protect",
72297 + .data = &grsec_enable_rofs,
72298 + .maxlen = sizeof(int),
72299 + .mode = 0600,
72300 + .proc_handler = &proc_dointvec_minmax,
72301 + .extra1 = &one,
72302 + .extra2 = &one,
72303 + },
72304 +#endif
72305 +#if defined(CONFIG_GRKERNSEC_DENYUSB) && !defined(CONFIG_GRKERNSEC_DENYUSB_FORCE)
72306 + {
72307 + .procname = "deny_new_usb",
72308 + .data = &grsec_deny_new_usb,
72309 + .maxlen = sizeof(int),
72310 + .mode = 0600,
72311 + .proc_handler = &proc_dointvec,
72312 + },
72313 +#endif
72314 + { }
72315 +};
72316 +#endif
72317 diff --git a/grsecurity/grsec_time.c b/grsecurity/grsec_time.c
72318 new file mode 100644
72319 index 0000000..0dc13c3
72320 --- /dev/null
72321 +++ b/grsecurity/grsec_time.c
72322 @@ -0,0 +1,16 @@
72323 +#include <linux/kernel.h>
72324 +#include <linux/sched.h>
72325 +#include <linux/grinternal.h>
72326 +#include <linux/module.h>
72327 +
72328 +void
72329 +gr_log_timechange(void)
72330 +{
72331 +#ifdef CONFIG_GRKERNSEC_TIME
72332 + if (grsec_enable_time)
72333 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_TIME_MSG);
72334 +#endif
72335 + return;
72336 +}
72337 +
72338 +EXPORT_SYMBOL(gr_log_timechange);
72339 diff --git a/grsecurity/grsec_tpe.c b/grsecurity/grsec_tpe.c
72340 new file mode 100644
72341 index 0000000..ee57dcf
72342 --- /dev/null
72343 +++ b/grsecurity/grsec_tpe.c
72344 @@ -0,0 +1,73 @@
72345 +#include <linux/kernel.h>
72346 +#include <linux/sched.h>
72347 +#include <linux/file.h>
72348 +#include <linux/fs.h>
72349 +#include <linux/grinternal.h>
72350 +
72351 +extern int gr_acl_tpe_check(void);
72352 +
72353 +int
72354 +gr_tpe_allow(const struct file *file)
72355 +{
72356 +#ifdef CONFIG_GRKERNSEC
72357 + struct inode *inode = file->f_path.dentry->d_parent->d_inode;
72358 + const struct cred *cred = current_cred();
72359 + char *msg = NULL;
72360 + char *msg2 = NULL;
72361 +
72362 + // never restrict root
72363 + if (gr_is_global_root(cred->uid))
72364 + return 1;
72365 +
72366 + if (grsec_enable_tpe) {
72367 +#ifdef CONFIG_GRKERNSEC_TPE_INVERT
72368 + if (grsec_enable_tpe_invert && !in_group_p(grsec_tpe_gid))
72369 + msg = "not being in trusted group";
72370 + else if (!grsec_enable_tpe_invert && in_group_p(grsec_tpe_gid))
72371 + msg = "being in untrusted group";
72372 +#else
72373 + if (in_group_p(grsec_tpe_gid))
72374 + msg = "being in untrusted group";
72375 +#endif
72376 + }
72377 + if (!msg && gr_acl_tpe_check())
72378 + msg = "being in untrusted role";
72379 +
72380 + // not in any affected group/role
72381 + if (!msg)
72382 + goto next_check;
72383 +
72384 + if (gr_is_global_nonroot(inode->i_uid))
72385 + msg2 = "file in non-root-owned directory";
72386 + else if (inode->i_mode & S_IWOTH)
72387 + msg2 = "file in world-writable directory";
72388 + else if (inode->i_mode & S_IWGRP)
72389 + msg2 = "file in group-writable directory";
72390 +
72391 + if (msg && msg2) {
72392 + char fullmsg[70] = {0};
72393 + snprintf(fullmsg, sizeof(fullmsg)-1, "%s and %s", msg, msg2);
72394 + gr_log_str_fs(GR_DONT_AUDIT, GR_EXEC_TPE_MSG, fullmsg, file->f_path.dentry, file->f_path.mnt);
72395 + return 0;
72396 + }
72397 + msg = NULL;
72398 +next_check:
72399 +#ifdef CONFIG_GRKERNSEC_TPE_ALL
72400 + if (!grsec_enable_tpe || !grsec_enable_tpe_all)
72401 + return 1;
72402 +
72403 + if (gr_is_global_nonroot(inode->i_uid) && !uid_eq(inode->i_uid, cred->uid))
72404 + msg = "directory not owned by user";
72405 + else if (inode->i_mode & S_IWOTH)
72406 + msg = "file in world-writable directory";
72407 + else if (inode->i_mode & S_IWGRP)
72408 + msg = "file in group-writable directory";
72409 +
72410 + if (msg) {
72411 + gr_log_str_fs(GR_DONT_AUDIT, GR_EXEC_TPE_MSG, msg, file->f_path.dentry, file->f_path.mnt);
72412 + return 0;
72413 + }
72414 +#endif
72415 +#endif
72416 + return 1;
72417 +}
72418 diff --git a/grsecurity/grsec_usb.c b/grsecurity/grsec_usb.c
72419 new file mode 100644
72420 index 0000000..ae02d8e
72421 --- /dev/null
72422 +++ b/grsecurity/grsec_usb.c
72423 @@ -0,0 +1,15 @@
72424 +#include <linux/kernel.h>
72425 +#include <linux/grinternal.h>
72426 +#include <linux/module.h>
72427 +
72428 +int gr_handle_new_usb(void)
72429 +{
72430 +#ifdef CONFIG_GRKERNSEC_DENYUSB
72431 + if (grsec_deny_new_usb) {
72432 + printk(KERN_ALERT "grsec: denied insert of new USB device\n");
72433 + return 1;
72434 + }
72435 +#endif
72436 + return 0;
72437 +}
72438 +EXPORT_SYMBOL_GPL(gr_handle_new_usb);
72439 diff --git a/grsecurity/grsum.c b/grsecurity/grsum.c
72440 new file mode 100644
72441 index 0000000..9f7b1ac
72442 --- /dev/null
72443 +++ b/grsecurity/grsum.c
72444 @@ -0,0 +1,61 @@
72445 +#include <linux/err.h>
72446 +#include <linux/kernel.h>
72447 +#include <linux/sched.h>
72448 +#include <linux/mm.h>
72449 +#include <linux/scatterlist.h>
72450 +#include <linux/crypto.h>
72451 +#include <linux/gracl.h>
72452 +
72453 +
72454 +#if !defined(CONFIG_CRYPTO) || defined(CONFIG_CRYPTO_MODULE) || !defined(CONFIG_CRYPTO_SHA256) || defined(CONFIG_CRYPTO_SHA256_MODULE)
72455 +#error "crypto and sha256 must be built into the kernel"
72456 +#endif
72457 +
72458 +int
72459 +chkpw(struct gr_arg *entry, unsigned char *salt, unsigned char *sum)
72460 +{
72461 + char *p;
72462 + struct crypto_hash *tfm;
72463 + struct hash_desc desc;
72464 + struct scatterlist sg;
72465 + unsigned char temp_sum[GR_SHA_LEN];
72466 + volatile int retval = 0;
72467 + volatile int dummy = 0;
72468 + unsigned int i;
72469 +
72470 + sg_init_table(&sg, 1);
72471 +
72472 + tfm = crypto_alloc_hash("sha256", 0, CRYPTO_ALG_ASYNC);
72473 + if (IS_ERR(tfm)) {
72474 + /* should never happen, since sha256 should be built in */
72475 + return 1;
72476 + }
72477 +
72478 + desc.tfm = tfm;
72479 + desc.flags = 0;
72480 +
72481 + crypto_hash_init(&desc);
72482 +
72483 + p = salt;
72484 + sg_set_buf(&sg, p, GR_SALT_LEN);
72485 + crypto_hash_update(&desc, &sg, sg.length);
72486 +
72487 + p = entry->pw;
72488 + sg_set_buf(&sg, p, strlen(p));
72489 +
72490 + crypto_hash_update(&desc, &sg, sg.length);
72491 +
72492 + crypto_hash_final(&desc, temp_sum);
72493 +
72494 + memset(entry->pw, 0, GR_PW_LEN);
72495 +
72496 + for (i = 0; i < GR_SHA_LEN; i++)
72497 + if (sum[i] != temp_sum[i])
72498 + retval = 1;
72499 + else
72500 + dummy = 1; // waste a cycle
72501 +
72502 + crypto_free_hash(tfm);
72503 +
72504 + return retval;
72505 +}
72506 diff --git a/include/asm-generic/4level-fixup.h b/include/asm-generic/4level-fixup.h
72507 index 77ff547..181834f 100644
72508 --- a/include/asm-generic/4level-fixup.h
72509 +++ b/include/asm-generic/4level-fixup.h
72510 @@ -13,8 +13,10 @@
72511 #define pmd_alloc(mm, pud, address) \
72512 ((unlikely(pgd_none(*(pud))) && __pmd_alloc(mm, pud, address))? \
72513 NULL: pmd_offset(pud, address))
72514 +#define pmd_alloc_kernel(mm, pud, address) pmd_alloc((mm), (pud), (address))
72515
72516 #define pud_alloc(mm, pgd, address) (pgd)
72517 +#define pud_alloc_kernel(mm, pgd, address) pud_alloc((mm), (pgd), (address))
72518 #define pud_offset(pgd, start) (pgd)
72519 #define pud_none(pud) 0
72520 #define pud_bad(pud) 0
72521 diff --git a/include/asm-generic/atomic-long.h b/include/asm-generic/atomic-long.h
72522 index b7babf0..04ad282 100644
72523 --- a/include/asm-generic/atomic-long.h
72524 +++ b/include/asm-generic/atomic-long.h
72525 @@ -22,6 +22,12 @@
72526
72527 typedef atomic64_t atomic_long_t;
72528
72529 +#ifdef CONFIG_PAX_REFCOUNT
72530 +typedef atomic64_unchecked_t atomic_long_unchecked_t;
72531 +#else
72532 +typedef atomic64_t atomic_long_unchecked_t;
72533 +#endif
72534 +
72535 #define ATOMIC_LONG_INIT(i) ATOMIC64_INIT(i)
72536
72537 static inline long atomic_long_read(atomic_long_t *l)
72538 @@ -31,6 +37,15 @@ static inline long atomic_long_read(atomic_long_t *l)
72539 return (long)atomic64_read(v);
72540 }
72541
72542 +#ifdef CONFIG_PAX_REFCOUNT
72543 +static inline long atomic_long_read_unchecked(atomic_long_unchecked_t *l)
72544 +{
72545 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
72546 +
72547 + return (long)atomic64_read_unchecked(v);
72548 +}
72549 +#endif
72550 +
72551 static inline void atomic_long_set(atomic_long_t *l, long i)
72552 {
72553 atomic64_t *v = (atomic64_t *)l;
72554 @@ -38,6 +53,15 @@ static inline void atomic_long_set(atomic_long_t *l, long i)
72555 atomic64_set(v, i);
72556 }
72557
72558 +#ifdef CONFIG_PAX_REFCOUNT
72559 +static inline void atomic_long_set_unchecked(atomic_long_unchecked_t *l, long i)
72560 +{
72561 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
72562 +
72563 + atomic64_set_unchecked(v, i);
72564 +}
72565 +#endif
72566 +
72567 static inline void atomic_long_inc(atomic_long_t *l)
72568 {
72569 atomic64_t *v = (atomic64_t *)l;
72570 @@ -45,6 +69,15 @@ static inline void atomic_long_inc(atomic_long_t *l)
72571 atomic64_inc(v);
72572 }
72573
72574 +#ifdef CONFIG_PAX_REFCOUNT
72575 +static inline void atomic_long_inc_unchecked(atomic_long_unchecked_t *l)
72576 +{
72577 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
72578 +
72579 + atomic64_inc_unchecked(v);
72580 +}
72581 +#endif
72582 +
72583 static inline void atomic_long_dec(atomic_long_t *l)
72584 {
72585 atomic64_t *v = (atomic64_t *)l;
72586 @@ -52,6 +85,15 @@ static inline void atomic_long_dec(atomic_long_t *l)
72587 atomic64_dec(v);
72588 }
72589
72590 +#ifdef CONFIG_PAX_REFCOUNT
72591 +static inline void atomic_long_dec_unchecked(atomic_long_unchecked_t *l)
72592 +{
72593 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
72594 +
72595 + atomic64_dec_unchecked(v);
72596 +}
72597 +#endif
72598 +
72599 static inline void atomic_long_add(long i, atomic_long_t *l)
72600 {
72601 atomic64_t *v = (atomic64_t *)l;
72602 @@ -59,6 +101,15 @@ static inline void atomic_long_add(long i, atomic_long_t *l)
72603 atomic64_add(i, v);
72604 }
72605
72606 +#ifdef CONFIG_PAX_REFCOUNT
72607 +static inline void atomic_long_add_unchecked(long i, atomic_long_unchecked_t *l)
72608 +{
72609 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
72610 +
72611 + atomic64_add_unchecked(i, v);
72612 +}
72613 +#endif
72614 +
72615 static inline void atomic_long_sub(long i, atomic_long_t *l)
72616 {
72617 atomic64_t *v = (atomic64_t *)l;
72618 @@ -66,6 +117,15 @@ static inline void atomic_long_sub(long i, atomic_long_t *l)
72619 atomic64_sub(i, v);
72620 }
72621
72622 +#ifdef CONFIG_PAX_REFCOUNT
72623 +static inline void atomic_long_sub_unchecked(long i, atomic_long_unchecked_t *l)
72624 +{
72625 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
72626 +
72627 + atomic64_sub_unchecked(i, v);
72628 +}
72629 +#endif
72630 +
72631 static inline int atomic_long_sub_and_test(long i, atomic_long_t *l)
72632 {
72633 atomic64_t *v = (atomic64_t *)l;
72634 @@ -101,6 +161,15 @@ static inline long atomic_long_add_return(long i, atomic_long_t *l)
72635 return (long)atomic64_add_return(i, v);
72636 }
72637
72638 +#ifdef CONFIG_PAX_REFCOUNT
72639 +static inline long atomic_long_add_return_unchecked(long i, atomic_long_unchecked_t *l)
72640 +{
72641 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
72642 +
72643 + return (long)atomic64_add_return_unchecked(i, v);
72644 +}
72645 +#endif
72646 +
72647 static inline long atomic_long_sub_return(long i, atomic_long_t *l)
72648 {
72649 atomic64_t *v = (atomic64_t *)l;
72650 @@ -115,6 +184,15 @@ static inline long atomic_long_inc_return(atomic_long_t *l)
72651 return (long)atomic64_inc_return(v);
72652 }
72653
72654 +#ifdef CONFIG_PAX_REFCOUNT
72655 +static inline long atomic_long_inc_return_unchecked(atomic_long_unchecked_t *l)
72656 +{
72657 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
72658 +
72659 + return (long)atomic64_inc_return_unchecked(v);
72660 +}
72661 +#endif
72662 +
72663 static inline long atomic_long_dec_return(atomic_long_t *l)
72664 {
72665 atomic64_t *v = (atomic64_t *)l;
72666 @@ -140,6 +218,12 @@ static inline long atomic_long_add_unless(atomic_long_t *l, long a, long u)
72667
72668 typedef atomic_t atomic_long_t;
72669
72670 +#ifdef CONFIG_PAX_REFCOUNT
72671 +typedef atomic_unchecked_t atomic_long_unchecked_t;
72672 +#else
72673 +typedef atomic_t atomic_long_unchecked_t;
72674 +#endif
72675 +
72676 #define ATOMIC_LONG_INIT(i) ATOMIC_INIT(i)
72677 static inline long atomic_long_read(atomic_long_t *l)
72678 {
72679 @@ -148,6 +232,15 @@ static inline long atomic_long_read(atomic_long_t *l)
72680 return (long)atomic_read(v);
72681 }
72682
72683 +#ifdef CONFIG_PAX_REFCOUNT
72684 +static inline long atomic_long_read_unchecked(atomic_long_unchecked_t *l)
72685 +{
72686 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
72687 +
72688 + return (long)atomic_read_unchecked(v);
72689 +}
72690 +#endif
72691 +
72692 static inline void atomic_long_set(atomic_long_t *l, long i)
72693 {
72694 atomic_t *v = (atomic_t *)l;
72695 @@ -155,6 +248,15 @@ static inline void atomic_long_set(atomic_long_t *l, long i)
72696 atomic_set(v, i);
72697 }
72698
72699 +#ifdef CONFIG_PAX_REFCOUNT
72700 +static inline void atomic_long_set_unchecked(atomic_long_unchecked_t *l, long i)
72701 +{
72702 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
72703 +
72704 + atomic_set_unchecked(v, i);
72705 +}
72706 +#endif
72707 +
72708 static inline void atomic_long_inc(atomic_long_t *l)
72709 {
72710 atomic_t *v = (atomic_t *)l;
72711 @@ -162,6 +264,15 @@ static inline void atomic_long_inc(atomic_long_t *l)
72712 atomic_inc(v);
72713 }
72714
72715 +#ifdef CONFIG_PAX_REFCOUNT
72716 +static inline void atomic_long_inc_unchecked(atomic_long_unchecked_t *l)
72717 +{
72718 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
72719 +
72720 + atomic_inc_unchecked(v);
72721 +}
72722 +#endif
72723 +
72724 static inline void atomic_long_dec(atomic_long_t *l)
72725 {
72726 atomic_t *v = (atomic_t *)l;
72727 @@ -169,6 +280,15 @@ static inline void atomic_long_dec(atomic_long_t *l)
72728 atomic_dec(v);
72729 }
72730
72731 +#ifdef CONFIG_PAX_REFCOUNT
72732 +static inline void atomic_long_dec_unchecked(atomic_long_unchecked_t *l)
72733 +{
72734 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
72735 +
72736 + atomic_dec_unchecked(v);
72737 +}
72738 +#endif
72739 +
72740 static inline void atomic_long_add(long i, atomic_long_t *l)
72741 {
72742 atomic_t *v = (atomic_t *)l;
72743 @@ -176,6 +296,15 @@ static inline void atomic_long_add(long i, atomic_long_t *l)
72744 atomic_add(i, v);
72745 }
72746
72747 +#ifdef CONFIG_PAX_REFCOUNT
72748 +static inline void atomic_long_add_unchecked(long i, atomic_long_unchecked_t *l)
72749 +{
72750 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
72751 +
72752 + atomic_add_unchecked(i, v);
72753 +}
72754 +#endif
72755 +
72756 static inline void atomic_long_sub(long i, atomic_long_t *l)
72757 {
72758 atomic_t *v = (atomic_t *)l;
72759 @@ -183,6 +312,15 @@ static inline void atomic_long_sub(long i, atomic_long_t *l)
72760 atomic_sub(i, v);
72761 }
72762
72763 +#ifdef CONFIG_PAX_REFCOUNT
72764 +static inline void atomic_long_sub_unchecked(long i, atomic_long_unchecked_t *l)
72765 +{
72766 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
72767 +
72768 + atomic_sub_unchecked(i, v);
72769 +}
72770 +#endif
72771 +
72772 static inline int atomic_long_sub_and_test(long i, atomic_long_t *l)
72773 {
72774 atomic_t *v = (atomic_t *)l;
72775 @@ -218,6 +356,16 @@ static inline long atomic_long_add_return(long i, atomic_long_t *l)
72776 return (long)atomic_add_return(i, v);
72777 }
72778
72779 +#ifdef CONFIG_PAX_REFCOUNT
72780 +static inline long atomic_long_add_return_unchecked(long i, atomic_long_unchecked_t *l)
72781 +{
72782 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
72783 +
72784 + return (long)atomic_add_return_unchecked(i, v);
72785 +}
72786 +
72787 +#endif
72788 +
72789 static inline long atomic_long_sub_return(long i, atomic_long_t *l)
72790 {
72791 atomic_t *v = (atomic_t *)l;
72792 @@ -232,6 +380,15 @@ static inline long atomic_long_inc_return(atomic_long_t *l)
72793 return (long)atomic_inc_return(v);
72794 }
72795
72796 +#ifdef CONFIG_PAX_REFCOUNT
72797 +static inline long atomic_long_inc_return_unchecked(atomic_long_unchecked_t *l)
72798 +{
72799 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
72800 +
72801 + return (long)atomic_inc_return_unchecked(v);
72802 +}
72803 +#endif
72804 +
72805 static inline long atomic_long_dec_return(atomic_long_t *l)
72806 {
72807 atomic_t *v = (atomic_t *)l;
72808 @@ -255,4 +412,57 @@ static inline long atomic_long_add_unless(atomic_long_t *l, long a, long u)
72809
72810 #endif /* BITS_PER_LONG == 64 */
72811
72812 +#ifdef CONFIG_PAX_REFCOUNT
72813 +static inline void pax_refcount_needs_these_functions(void)
72814 +{
72815 + atomic_read_unchecked((atomic_unchecked_t *)NULL);
72816 + atomic_set_unchecked((atomic_unchecked_t *)NULL, 0);
72817 + atomic_add_unchecked(0, (atomic_unchecked_t *)NULL);
72818 + atomic_sub_unchecked(0, (atomic_unchecked_t *)NULL);
72819 + atomic_inc_unchecked((atomic_unchecked_t *)NULL);
72820 + (void)atomic_inc_and_test_unchecked((atomic_unchecked_t *)NULL);
72821 + atomic_inc_return_unchecked((atomic_unchecked_t *)NULL);
72822 + atomic_add_return_unchecked(0, (atomic_unchecked_t *)NULL);
72823 + atomic_dec_unchecked((atomic_unchecked_t *)NULL);
72824 + atomic_cmpxchg_unchecked((atomic_unchecked_t *)NULL, 0, 0);
72825 + (void)atomic_xchg_unchecked((atomic_unchecked_t *)NULL, 0);
72826 +#ifdef CONFIG_X86
72827 + atomic_clear_mask_unchecked(0, NULL);
72828 + atomic_set_mask_unchecked(0, NULL);
72829 +#endif
72830 +
72831 + atomic_long_read_unchecked((atomic_long_unchecked_t *)NULL);
72832 + atomic_long_set_unchecked((atomic_long_unchecked_t *)NULL, 0);
72833 + atomic_long_add_unchecked(0, (atomic_long_unchecked_t *)NULL);
72834 + atomic_long_sub_unchecked(0, (atomic_long_unchecked_t *)NULL);
72835 + atomic_long_inc_unchecked((atomic_long_unchecked_t *)NULL);
72836 + atomic_long_add_return_unchecked(0, (atomic_long_unchecked_t *)NULL);
72837 + atomic_long_inc_return_unchecked((atomic_long_unchecked_t *)NULL);
72838 + atomic_long_dec_unchecked((atomic_long_unchecked_t *)NULL);
72839 +}
72840 +#else
72841 +#define atomic_read_unchecked(v) atomic_read(v)
72842 +#define atomic_set_unchecked(v, i) atomic_set((v), (i))
72843 +#define atomic_add_unchecked(i, v) atomic_add((i), (v))
72844 +#define atomic_sub_unchecked(i, v) atomic_sub((i), (v))
72845 +#define atomic_inc_unchecked(v) atomic_inc(v)
72846 +#define atomic_inc_and_test_unchecked(v) atomic_inc_and_test(v)
72847 +#define atomic_inc_return_unchecked(v) atomic_inc_return(v)
72848 +#define atomic_add_return_unchecked(i, v) atomic_add_return((i), (v))
72849 +#define atomic_dec_unchecked(v) atomic_dec(v)
72850 +#define atomic_cmpxchg_unchecked(v, o, n) atomic_cmpxchg((v), (o), (n))
72851 +#define atomic_xchg_unchecked(v, i) atomic_xchg((v), (i))
72852 +#define atomic_clear_mask_unchecked(mask, v) atomic_clear_mask((mask), (v))
72853 +#define atomic_set_mask_unchecked(mask, v) atomic_set_mask((mask), (v))
72854 +
72855 +#define atomic_long_read_unchecked(v) atomic_long_read(v)
72856 +#define atomic_long_set_unchecked(v, i) atomic_long_set((v), (i))
72857 +#define atomic_long_add_unchecked(i, v) atomic_long_add((i), (v))
72858 +#define atomic_long_sub_unchecked(i, v) atomic_long_sub((i), (v))
72859 +#define atomic_long_inc_unchecked(v) atomic_long_inc(v)
72860 +#define atomic_long_add_return_unchecked(i, v) atomic_long_add_return((i), (v))
72861 +#define atomic_long_inc_return_unchecked(v) atomic_long_inc_return(v)
72862 +#define atomic_long_dec_unchecked(v) atomic_long_dec(v)
72863 +#endif
72864 +
72865 #endif /* _ASM_GENERIC_ATOMIC_LONG_H */
72866 diff --git a/include/asm-generic/atomic.h b/include/asm-generic/atomic.h
72867 index 33bd2de..f31bff97 100644
72868 --- a/include/asm-generic/atomic.h
72869 +++ b/include/asm-generic/atomic.h
72870 @@ -153,7 +153,7 @@ static inline int __atomic_add_unless(atomic_t *v, int a, int u)
72871 * Atomically clears the bits set in @mask from @v
72872 */
72873 #ifndef atomic_clear_mask
72874 -static inline void atomic_clear_mask(unsigned long mask, atomic_t *v)
72875 +static inline void atomic_clear_mask(unsigned int mask, atomic_t *v)
72876 {
72877 unsigned long flags;
72878
72879 diff --git a/include/asm-generic/atomic64.h b/include/asm-generic/atomic64.h
72880 index b18ce4f..2ee2843 100644
72881 --- a/include/asm-generic/atomic64.h
72882 +++ b/include/asm-generic/atomic64.h
72883 @@ -16,6 +16,8 @@ typedef struct {
72884 long long counter;
72885 } atomic64_t;
72886
72887 +typedef atomic64_t atomic64_unchecked_t;
72888 +
72889 #define ATOMIC64_INIT(i) { (i) }
72890
72891 extern long long atomic64_read(const atomic64_t *v);
72892 @@ -39,4 +41,14 @@ extern int atomic64_add_unless(atomic64_t *v, long long a, long long u);
72893 #define atomic64_dec_and_test(v) (atomic64_dec_return((v)) == 0)
72894 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1LL, 0LL)
72895
72896 +#define atomic64_read_unchecked(v) atomic64_read(v)
72897 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
72898 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
72899 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
72900 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
72901 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
72902 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
72903 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
72904 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
72905 +
72906 #endif /* _ASM_GENERIC_ATOMIC64_H */
72907 diff --git a/include/asm-generic/bitops/__fls.h b/include/asm-generic/bitops/__fls.h
72908 index a60a7cc..0fe12f2 100644
72909 --- a/include/asm-generic/bitops/__fls.h
72910 +++ b/include/asm-generic/bitops/__fls.h
72911 @@ -9,7 +9,7 @@
72912 *
72913 * Undefined if no set bit exists, so code should check against 0 first.
72914 */
72915 -static __always_inline unsigned long __fls(unsigned long word)
72916 +static __always_inline unsigned long __intentional_overflow(-1) __fls(unsigned long word)
72917 {
72918 int num = BITS_PER_LONG - 1;
72919
72920 diff --git a/include/asm-generic/bitops/fls.h b/include/asm-generic/bitops/fls.h
72921 index 0576d1f..dad6c71 100644
72922 --- a/include/asm-generic/bitops/fls.h
72923 +++ b/include/asm-generic/bitops/fls.h
72924 @@ -9,7 +9,7 @@
72925 * Note fls(0) = 0, fls(1) = 1, fls(0x80000000) = 32.
72926 */
72927
72928 -static __always_inline int fls(int x)
72929 +static __always_inline int __intentional_overflow(-1) fls(int x)
72930 {
72931 int r = 32;
72932
72933 diff --git a/include/asm-generic/bitops/fls64.h b/include/asm-generic/bitops/fls64.h
72934 index b097cf8..3d40e14 100644
72935 --- a/include/asm-generic/bitops/fls64.h
72936 +++ b/include/asm-generic/bitops/fls64.h
72937 @@ -15,7 +15,7 @@
72938 * at position 64.
72939 */
72940 #if BITS_PER_LONG == 32
72941 -static __always_inline int fls64(__u64 x)
72942 +static __always_inline int __intentional_overflow(-1) fls64(__u64 x)
72943 {
72944 __u32 h = x >> 32;
72945 if (h)
72946 @@ -23,7 +23,7 @@ static __always_inline int fls64(__u64 x)
72947 return fls(x);
72948 }
72949 #elif BITS_PER_LONG == 64
72950 -static __always_inline int fls64(__u64 x)
72951 +static __always_inline int __intentional_overflow(-1) fls64(__u64 x)
72952 {
72953 if (x == 0)
72954 return 0;
72955 diff --git a/include/asm-generic/cache.h b/include/asm-generic/cache.h
72956 index 1bfcfe5..e04c5c9 100644
72957 --- a/include/asm-generic/cache.h
72958 +++ b/include/asm-generic/cache.h
72959 @@ -6,7 +6,7 @@
72960 * cache lines need to provide their own cache.h.
72961 */
72962
72963 -#define L1_CACHE_SHIFT 5
72964 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
72965 +#define L1_CACHE_SHIFT 5UL
72966 +#define L1_CACHE_BYTES (1UL << L1_CACHE_SHIFT)
72967
72968 #endif /* __ASM_GENERIC_CACHE_H */
72969 diff --git a/include/asm-generic/emergency-restart.h b/include/asm-generic/emergency-restart.h
72970 index 0d68a1e..b74a761 100644
72971 --- a/include/asm-generic/emergency-restart.h
72972 +++ b/include/asm-generic/emergency-restart.h
72973 @@ -1,7 +1,7 @@
72974 #ifndef _ASM_GENERIC_EMERGENCY_RESTART_H
72975 #define _ASM_GENERIC_EMERGENCY_RESTART_H
72976
72977 -static inline void machine_emergency_restart(void)
72978 +static inline __noreturn void machine_emergency_restart(void)
72979 {
72980 machine_restart(NULL);
72981 }
72982 diff --git a/include/asm-generic/kmap_types.h b/include/asm-generic/kmap_types.h
72983 index 90f99c7..00ce236 100644
72984 --- a/include/asm-generic/kmap_types.h
72985 +++ b/include/asm-generic/kmap_types.h
72986 @@ -2,9 +2,9 @@
72987 #define _ASM_GENERIC_KMAP_TYPES_H
72988
72989 #ifdef __WITH_KM_FENCE
72990 -# define KM_TYPE_NR 41
72991 +# define KM_TYPE_NR 42
72992 #else
72993 -# define KM_TYPE_NR 20
72994 +# define KM_TYPE_NR 21
72995 #endif
72996
72997 #endif
72998 diff --git a/include/asm-generic/local.h b/include/asm-generic/local.h
72999 index 9ceb03b..62b0b8f 100644
73000 --- a/include/asm-generic/local.h
73001 +++ b/include/asm-generic/local.h
73002 @@ -23,24 +23,37 @@ typedef struct
73003 atomic_long_t a;
73004 } local_t;
73005
73006 +typedef struct {
73007 + atomic_long_unchecked_t a;
73008 +} local_unchecked_t;
73009 +
73010 #define LOCAL_INIT(i) { ATOMIC_LONG_INIT(i) }
73011
73012 #define local_read(l) atomic_long_read(&(l)->a)
73013 +#define local_read_unchecked(l) atomic_long_read_unchecked(&(l)->a)
73014 #define local_set(l,i) atomic_long_set((&(l)->a),(i))
73015 +#define local_set_unchecked(l,i) atomic_long_set_unchecked((&(l)->a),(i))
73016 #define local_inc(l) atomic_long_inc(&(l)->a)
73017 +#define local_inc_unchecked(l) atomic_long_inc_unchecked(&(l)->a)
73018 #define local_dec(l) atomic_long_dec(&(l)->a)
73019 +#define local_dec_unchecked(l) atomic_long_dec_unchecked(&(l)->a)
73020 #define local_add(i,l) atomic_long_add((i),(&(l)->a))
73021 +#define local_add_unchecked(i,l) atomic_long_add_unchecked((i),(&(l)->a))
73022 #define local_sub(i,l) atomic_long_sub((i),(&(l)->a))
73023 +#define local_sub_unchecked(i,l) atomic_long_sub_unchecked((i),(&(l)->a))
73024
73025 #define local_sub_and_test(i, l) atomic_long_sub_and_test((i), (&(l)->a))
73026 #define local_dec_and_test(l) atomic_long_dec_and_test(&(l)->a)
73027 #define local_inc_and_test(l) atomic_long_inc_and_test(&(l)->a)
73028 #define local_add_negative(i, l) atomic_long_add_negative((i), (&(l)->a))
73029 #define local_add_return(i, l) atomic_long_add_return((i), (&(l)->a))
73030 +#define local_add_return_unchecked(i, l) atomic_long_add_return_unchecked((i), (&(l)->a))
73031 #define local_sub_return(i, l) atomic_long_sub_return((i), (&(l)->a))
73032 #define local_inc_return(l) atomic_long_inc_return(&(l)->a)
73033 +#define local_dec_return(l) atomic_long_dec_return(&(l)->a)
73034
73035 #define local_cmpxchg(l, o, n) atomic_long_cmpxchg((&(l)->a), (o), (n))
73036 +#define local_cmpxchg_unchecked(l, o, n) atomic_long_cmpxchg((&(l)->a), (o), (n))
73037 #define local_xchg(l, n) atomic_long_xchg((&(l)->a), (n))
73038 #define local_add_unless(l, _a, u) atomic_long_add_unless((&(l)->a), (_a), (u))
73039 #define local_inc_not_zero(l) atomic_long_inc_not_zero(&(l)->a)
73040 diff --git a/include/asm-generic/pgtable-nopmd.h b/include/asm-generic/pgtable-nopmd.h
73041 index 725612b..9cc513a 100644
73042 --- a/include/asm-generic/pgtable-nopmd.h
73043 +++ b/include/asm-generic/pgtable-nopmd.h
73044 @@ -1,14 +1,19 @@
73045 #ifndef _PGTABLE_NOPMD_H
73046 #define _PGTABLE_NOPMD_H
73047
73048 -#ifndef __ASSEMBLY__
73049 -
73050 #include <asm-generic/pgtable-nopud.h>
73051
73052 -struct mm_struct;
73053 -
73054 #define __PAGETABLE_PMD_FOLDED
73055
73056 +#define PMD_SHIFT PUD_SHIFT
73057 +#define PTRS_PER_PMD 1
73058 +#define PMD_SIZE (_AC(1,UL) << PMD_SHIFT)
73059 +#define PMD_MASK (~(PMD_SIZE-1))
73060 +
73061 +#ifndef __ASSEMBLY__
73062 +
73063 +struct mm_struct;
73064 +
73065 /*
73066 * Having the pmd type consist of a pud gets the size right, and allows
73067 * us to conceptually access the pud entry that this pmd is folded into
73068 @@ -16,11 +21,6 @@ struct mm_struct;
73069 */
73070 typedef struct { pud_t pud; } pmd_t;
73071
73072 -#define PMD_SHIFT PUD_SHIFT
73073 -#define PTRS_PER_PMD 1
73074 -#define PMD_SIZE (1UL << PMD_SHIFT)
73075 -#define PMD_MASK (~(PMD_SIZE-1))
73076 -
73077 /*
73078 * The "pud_xxx()" functions here are trivial for a folded two-level
73079 * setup: the pmd is never bad, and a pmd always exists (as it's folded
73080 diff --git a/include/asm-generic/pgtable-nopud.h b/include/asm-generic/pgtable-nopud.h
73081 index 810431d..0ec4804f 100644
73082 --- a/include/asm-generic/pgtable-nopud.h
73083 +++ b/include/asm-generic/pgtable-nopud.h
73084 @@ -1,10 +1,15 @@
73085 #ifndef _PGTABLE_NOPUD_H
73086 #define _PGTABLE_NOPUD_H
73087
73088 -#ifndef __ASSEMBLY__
73089 -
73090 #define __PAGETABLE_PUD_FOLDED
73091
73092 +#define PUD_SHIFT PGDIR_SHIFT
73093 +#define PTRS_PER_PUD 1
73094 +#define PUD_SIZE (_AC(1,UL) << PUD_SHIFT)
73095 +#define PUD_MASK (~(PUD_SIZE-1))
73096 +
73097 +#ifndef __ASSEMBLY__
73098 +
73099 /*
73100 * Having the pud type consist of a pgd gets the size right, and allows
73101 * us to conceptually access the pgd entry that this pud is folded into
73102 @@ -12,11 +17,6 @@
73103 */
73104 typedef struct { pgd_t pgd; } pud_t;
73105
73106 -#define PUD_SHIFT PGDIR_SHIFT
73107 -#define PTRS_PER_PUD 1
73108 -#define PUD_SIZE (1UL << PUD_SHIFT)
73109 -#define PUD_MASK (~(PUD_SIZE-1))
73110 -
73111 /*
73112 * The "pgd_xxx()" functions here are trivial for a folded two-level
73113 * setup: the pud is never bad, and a pud always exists (as it's folded
73114 @@ -29,6 +29,7 @@ static inline void pgd_clear(pgd_t *pgd) { }
73115 #define pud_ERROR(pud) (pgd_ERROR((pud).pgd))
73116
73117 #define pgd_populate(mm, pgd, pud) do { } while (0)
73118 +#define pgd_populate_kernel(mm, pgd, pud) do { } while (0)
73119 /*
73120 * (puds are folded into pgds so this doesn't get actually called,
73121 * but the define is needed for a generic inline function.)
73122 diff --git a/include/asm-generic/pgtable.h b/include/asm-generic/pgtable.h
73123 index f330d28..83ce28f 100644
73124 --- a/include/asm-generic/pgtable.h
73125 +++ b/include/asm-generic/pgtable.h
73126 @@ -737,6 +737,22 @@ static inline pmd_t pmd_mknuma(pmd_t pmd)
73127 }
73128 #endif /* CONFIG_NUMA_BALANCING */
73129
73130 +#ifndef __HAVE_ARCH_PAX_OPEN_KERNEL
73131 +#ifdef CONFIG_PAX_KERNEXEC
73132 +#error KERNEXEC requires pax_open_kernel
73133 +#else
73134 +static inline unsigned long pax_open_kernel(void) { return 0; }
73135 +#endif
73136 +#endif
73137 +
73138 +#ifndef __HAVE_ARCH_PAX_CLOSE_KERNEL
73139 +#ifdef CONFIG_PAX_KERNEXEC
73140 +#error KERNEXEC requires pax_close_kernel
73141 +#else
73142 +static inline unsigned long pax_close_kernel(void) { return 0; }
73143 +#endif
73144 +#endif
73145 +
73146 #endif /* CONFIG_MMU */
73147
73148 #endif /* !__ASSEMBLY__ */
73149 diff --git a/include/asm-generic/uaccess.h b/include/asm-generic/uaccess.h
73150 index dc1269c..48a4f51 100644
73151 --- a/include/asm-generic/uaccess.h
73152 +++ b/include/asm-generic/uaccess.h
73153 @@ -343,4 +343,20 @@ clear_user(void __user *to, unsigned long n)
73154 return __clear_user(to, n);
73155 }
73156
73157 +#ifndef __HAVE_ARCH_PAX_OPEN_USERLAND
73158 +#ifdef CONFIG_PAX_MEMORY_UDEREF
73159 +#error UDEREF requires pax_open_userland
73160 +#else
73161 +static inline unsigned long pax_open_userland(void) { return 0; }
73162 +#endif
73163 +#endif
73164 +
73165 +#ifndef __HAVE_ARCH_PAX_CLOSE_USERLAND
73166 +#ifdef CONFIG_PAX_MEMORY_UDEREF
73167 +#error UDEREF requires pax_close_userland
73168 +#else
73169 +static inline unsigned long pax_close_userland(void) { return 0; }
73170 +#endif
73171 +#endif
73172 +
73173 #endif /* __ASM_GENERIC_UACCESS_H */
73174 diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinux.lds.h
73175 index 83e2c31..eeb4a04 100644
73176 --- a/include/asm-generic/vmlinux.lds.h
73177 +++ b/include/asm-generic/vmlinux.lds.h
73178 @@ -232,6 +232,7 @@
73179 .rodata : AT(ADDR(.rodata) - LOAD_OFFSET) { \
73180 VMLINUX_SYMBOL(__start_rodata) = .; \
73181 *(.rodata) *(.rodata.*) \
73182 + *(.data..read_only) \
73183 *(__vermagic) /* Kernel version magic */ \
73184 . = ALIGN(8); \
73185 VMLINUX_SYMBOL(__start___tracepoints_ptrs) = .; \
73186 @@ -715,17 +716,18 @@
73187 * section in the linker script will go there too. @phdr should have
73188 * a leading colon.
73189 *
73190 - * Note that this macros defines __per_cpu_load as an absolute symbol.
73191 + * Note that this macros defines per_cpu_load as an absolute symbol.
73192 * If there is no need to put the percpu section at a predetermined
73193 * address, use PERCPU_SECTION.
73194 */
73195 #define PERCPU_VADDR(cacheline, vaddr, phdr) \
73196 - VMLINUX_SYMBOL(__per_cpu_load) = .; \
73197 - .data..percpu vaddr : AT(VMLINUX_SYMBOL(__per_cpu_load) \
73198 + per_cpu_load = .; \
73199 + .data..percpu vaddr : AT(VMLINUX_SYMBOL(per_cpu_load) \
73200 - LOAD_OFFSET) { \
73201 + VMLINUX_SYMBOL(__per_cpu_load) = . + per_cpu_load; \
73202 PERCPU_INPUT(cacheline) \
73203 } phdr \
73204 - . = VMLINUX_SYMBOL(__per_cpu_load) + SIZEOF(.data..percpu);
73205 + . = VMLINUX_SYMBOL(per_cpu_load) + SIZEOF(.data..percpu);
73206
73207 /**
73208 * PERCPU_SECTION - define output section for percpu area, simple version
73209 diff --git a/include/crypto/algapi.h b/include/crypto/algapi.h
73210 index 418d270..bfd2794 100644
73211 --- a/include/crypto/algapi.h
73212 +++ b/include/crypto/algapi.h
73213 @@ -34,7 +34,7 @@ struct crypto_type {
73214 unsigned int maskclear;
73215 unsigned int maskset;
73216 unsigned int tfmsize;
73217 -};
73218 +} __do_const;
73219
73220 struct crypto_instance {
73221 struct crypto_alg alg;
73222 diff --git a/include/drm/drmP.h b/include/drm/drmP.h
73223 index b46fb45..b30d6d5 100644
73224 --- a/include/drm/drmP.h
73225 +++ b/include/drm/drmP.h
73226 @@ -66,6 +66,7 @@
73227 #include <linux/workqueue.h>
73228 #include <linux/poll.h>
73229 #include <asm/pgalloc.h>
73230 +#include <asm/local.h>
73231 #include <drm/drm.h>
73232 #include <drm/drm_sarea.h>
73233 #include <drm/drm_vma_manager.h>
73234 @@ -277,10 +278,12 @@ do { \
73235 * \param cmd command.
73236 * \param arg argument.
73237 */
73238 -typedef int drm_ioctl_t(struct drm_device *dev, void *data,
73239 +typedef int (* const drm_ioctl_t)(struct drm_device *dev, void *data,
73240 + struct drm_file *file_priv);
73241 +typedef int (* drm_ioctl_no_const_t)(struct drm_device *dev, void *data,
73242 struct drm_file *file_priv);
73243
73244 -typedef int drm_ioctl_compat_t(struct file *filp, unsigned int cmd,
73245 +typedef int (* const drm_ioctl_compat_t)(struct file *filp, unsigned int cmd,
73246 unsigned long arg);
73247
73248 #define DRM_IOCTL_NR(n) _IOC_NR(n)
73249 @@ -296,10 +299,10 @@ typedef int drm_ioctl_compat_t(struct file *filp, unsigned int cmd,
73250 struct drm_ioctl_desc {
73251 unsigned int cmd;
73252 int flags;
73253 - drm_ioctl_t *func;
73254 + drm_ioctl_t func;
73255 unsigned int cmd_drv;
73256 const char *name;
73257 -};
73258 +} __do_const;
73259
73260 /**
73261 * Creates a driver or general drm_ioctl_desc array entry for the given
73262 @@ -1027,7 +1030,7 @@ struct drm_info_list {
73263 int (*show)(struct seq_file*, void*); /** show callback */
73264 u32 driver_features; /**< Required driver features for this entry */
73265 void *data;
73266 -};
73267 +} __do_const;
73268
73269 /**
73270 * debugfs node structure. This structure represents a debugfs file.
73271 @@ -1098,7 +1101,7 @@ struct drm_device {
73272
73273 /** \name Usage Counters */
73274 /*@{ */
73275 - int open_count; /**< Outstanding files open */
73276 + local_t open_count; /**< Outstanding files open */
73277 atomic_t ioctl_count; /**< Outstanding IOCTLs pending */
73278 atomic_t vma_count; /**< Outstanding vma areas open */
73279 int buf_use; /**< Buffers in use -- cannot alloc */
73280 @@ -1109,7 +1112,7 @@ struct drm_device {
73281 /*@{ */
73282 unsigned long counters;
73283 enum drm_stat_type types[15];
73284 - atomic_t counts[15];
73285 + atomic_unchecked_t counts[15];
73286 /*@} */
73287
73288 struct list_head filelist;
73289 diff --git a/include/drm/drm_crtc_helper.h b/include/drm/drm_crtc_helper.h
73290 index f43d556..94d9343 100644
73291 --- a/include/drm/drm_crtc_helper.h
73292 +++ b/include/drm/drm_crtc_helper.h
73293 @@ -109,7 +109,7 @@ struct drm_encoder_helper_funcs {
73294 struct drm_connector *connector);
73295 /* disable encoder when not in use - more explicit than dpms off */
73296 void (*disable)(struct drm_encoder *encoder);
73297 -};
73298 +} __no_const;
73299
73300 /**
73301 * drm_connector_helper_funcs - helper operations for connectors
73302 diff --git a/include/drm/i915_pciids.h b/include/drm/i915_pciids.h
73303 index 8a10f5c..5de7f5c 100644
73304 --- a/include/drm/i915_pciids.h
73305 +++ b/include/drm/i915_pciids.h
73306 @@ -37,7 +37,7 @@
73307 */
73308 #define INTEL_VGA_DEVICE(id, info) { \
73309 0x8086, id, \
73310 - ~0, ~0, \
73311 + PCI_ANY_ID, PCI_ANY_ID, \
73312 0x030000, 0xff0000, \
73313 (unsigned long) info }
73314
73315 diff --git a/include/drm/ttm/ttm_memory.h b/include/drm/ttm/ttm_memory.h
73316 index 72dcbe8..8db58d7 100644
73317 --- a/include/drm/ttm/ttm_memory.h
73318 +++ b/include/drm/ttm/ttm_memory.h
73319 @@ -48,7 +48,7 @@
73320
73321 struct ttm_mem_shrink {
73322 int (*do_shrink) (struct ttm_mem_shrink *);
73323 -};
73324 +} __no_const;
73325
73326 /**
73327 * struct ttm_mem_global - Global memory accounting structure.
73328 diff --git a/include/keys/asymmetric-subtype.h b/include/keys/asymmetric-subtype.h
73329 index 4b840e8..155d235 100644
73330 --- a/include/keys/asymmetric-subtype.h
73331 +++ b/include/keys/asymmetric-subtype.h
73332 @@ -37,7 +37,7 @@ struct asymmetric_key_subtype {
73333 /* Verify the signature on a key of this subtype (optional) */
73334 int (*verify_signature)(const struct key *key,
73335 const struct public_key_signature *sig);
73336 -};
73337 +} __do_const;
73338
73339 /**
73340 * asymmetric_key_subtype - Get the subtype from an asymmetric key
73341 diff --git a/include/linux/atmdev.h b/include/linux/atmdev.h
73342 index c1da539..1dcec55 100644
73343 --- a/include/linux/atmdev.h
73344 +++ b/include/linux/atmdev.h
73345 @@ -28,7 +28,7 @@ struct compat_atm_iobuf {
73346 #endif
73347
73348 struct k_atm_aal_stats {
73349 -#define __HANDLE_ITEM(i) atomic_t i
73350 +#define __HANDLE_ITEM(i) atomic_unchecked_t i
73351 __AAL_STAT_ITEMS
73352 #undef __HANDLE_ITEM
73353 };
73354 @@ -200,7 +200,7 @@ struct atmdev_ops { /* only send is required */
73355 int (*change_qos)(struct atm_vcc *vcc,struct atm_qos *qos,int flags);
73356 int (*proc_read)(struct atm_dev *dev,loff_t *pos,char *page);
73357 struct module *owner;
73358 -};
73359 +} __do_const ;
73360
73361 struct atmphy_ops {
73362 int (*start)(struct atm_dev *dev);
73363 diff --git a/include/linux/audit.h b/include/linux/audit.h
73364 index 729a4d1..9b304ae 100644
73365 --- a/include/linux/audit.h
73366 +++ b/include/linux/audit.h
73367 @@ -193,7 +193,7 @@ static inline void audit_ptrace(struct task_struct *t)
73368 extern unsigned int audit_serial(void);
73369 extern int auditsc_get_stamp(struct audit_context *ctx,
73370 struct timespec *t, unsigned int *serial);
73371 -extern int audit_set_loginuid(kuid_t loginuid);
73372 +extern int __intentional_overflow(-1) audit_set_loginuid(kuid_t loginuid);
73373
73374 static inline kuid_t audit_get_loginuid(struct task_struct *tsk)
73375 {
73376 diff --git a/include/linux/binfmts.h b/include/linux/binfmts.h
73377 index 7554fd4..0f86379 100644
73378 --- a/include/linux/binfmts.h
73379 +++ b/include/linux/binfmts.h
73380 @@ -73,8 +73,10 @@ struct linux_binfmt {
73381 int (*load_binary)(struct linux_binprm *);
73382 int (*load_shlib)(struct file *);
73383 int (*core_dump)(struct coredump_params *cprm);
73384 + void (*handle_mprotect)(struct vm_area_struct *vma, unsigned long newflags);
73385 + void (*handle_mmap)(struct file *);
73386 unsigned long min_coredump; /* minimal dump size */
73387 -};
73388 +} __do_const;
73389
73390 extern void __register_binfmt(struct linux_binfmt *fmt, int insert);
73391
73392 diff --git a/include/linux/bitops.h b/include/linux/bitops.h
73393 index a3b6b82..2a7d758 100644
73394 --- a/include/linux/bitops.h
73395 +++ b/include/linux/bitops.h
73396 @@ -91,7 +91,7 @@ static inline __u64 ror64(__u64 word, unsigned int shift)
73397 * @word: value to rotate
73398 * @shift: bits to roll
73399 */
73400 -static inline __u32 rol32(__u32 word, unsigned int shift)
73401 +static inline __u32 __intentional_overflow(-1) rol32(__u32 word, unsigned int shift)
73402 {
73403 return (word << shift) | (word >> (32 - shift));
73404 }
73405 @@ -101,7 +101,7 @@ static inline __u32 rol32(__u32 word, unsigned int shift)
73406 * @word: value to rotate
73407 * @shift: bits to roll
73408 */
73409 -static inline __u32 ror32(__u32 word, unsigned int shift)
73410 +static inline __u32 __intentional_overflow(-1) ror32(__u32 word, unsigned int shift)
73411 {
73412 return (word >> shift) | (word << (32 - shift));
73413 }
73414 @@ -157,7 +157,7 @@ static inline __s32 sign_extend32(__u32 value, int index)
73415 return (__s32)(value << shift) >> shift;
73416 }
73417
73418 -static inline unsigned fls_long(unsigned long l)
73419 +static inline unsigned __intentional_overflow(-1) fls_long(unsigned long l)
73420 {
73421 if (sizeof(l) == 4)
73422 return fls(l);
73423 diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
73424 index 0e6f765..885bb2b 100644
73425 --- a/include/linux/blkdev.h
73426 +++ b/include/linux/blkdev.h
73427 @@ -1537,7 +1537,7 @@ struct block_device_operations {
73428 /* this callback is with swap_lock and sometimes page table lock held */
73429 void (*swap_slot_free_notify) (struct block_device *, unsigned long);
73430 struct module *owner;
73431 -};
73432 +} __do_const;
73433
73434 extern int __blkdev_driver_ioctl(struct block_device *, fmode_t, unsigned int,
73435 unsigned long);
73436 diff --git a/include/linux/blktrace_api.h b/include/linux/blktrace_api.h
73437 index 7c2e030..b72475d 100644
73438 --- a/include/linux/blktrace_api.h
73439 +++ b/include/linux/blktrace_api.h
73440 @@ -23,7 +23,7 @@ struct blk_trace {
73441 struct dentry *dir;
73442 struct dentry *dropped_file;
73443 struct dentry *msg_file;
73444 - atomic_t dropped;
73445 + atomic_unchecked_t dropped;
73446 };
73447
73448 extern int blk_trace_ioctl(struct block_device *, unsigned, char __user *);
73449 diff --git a/include/linux/cache.h b/include/linux/cache.h
73450 index 4c57065..40346da 100644
73451 --- a/include/linux/cache.h
73452 +++ b/include/linux/cache.h
73453 @@ -16,6 +16,14 @@
73454 #define __read_mostly
73455 #endif
73456
73457 +#ifndef __read_only
73458 +#ifdef CONFIG_PAX_KERNEXEC
73459 +#error KERNEXEC requires __read_only
73460 +#else
73461 +#define __read_only __read_mostly
73462 +#endif
73463 +#endif
73464 +
73465 #ifndef ____cacheline_aligned
73466 #define ____cacheline_aligned __attribute__((__aligned__(SMP_CACHE_BYTES)))
73467 #endif
73468 diff --git a/include/linux/capability.h b/include/linux/capability.h
73469 index a6ee1f9..e1ca49d 100644
73470 --- a/include/linux/capability.h
73471 +++ b/include/linux/capability.h
73472 @@ -212,8 +212,13 @@ extern bool capable(int cap);
73473 extern bool ns_capable(struct user_namespace *ns, int cap);
73474 extern bool inode_capable(const struct inode *inode, int cap);
73475 extern bool file_ns_capable(const struct file *file, struct user_namespace *ns, int cap);
73476 +extern bool capable_nolog(int cap);
73477 +extern bool ns_capable_nolog(struct user_namespace *ns, int cap);
73478 +extern bool inode_capable_nolog(const struct inode *inode, int cap);
73479
73480 /* audit system wants to get cap info from files as well */
73481 extern int get_vfs_caps_from_disk(const struct dentry *dentry, struct cpu_vfs_cap_data *cpu_caps);
73482
73483 +extern int is_privileged_binary(const struct dentry *dentry);
73484 +
73485 #endif /* !_LINUX_CAPABILITY_H */
73486 diff --git a/include/linux/cdrom.h b/include/linux/cdrom.h
73487 index 8609d57..86e4d79 100644
73488 --- a/include/linux/cdrom.h
73489 +++ b/include/linux/cdrom.h
73490 @@ -87,7 +87,6 @@ struct cdrom_device_ops {
73491
73492 /* driver specifications */
73493 const int capability; /* capability flags */
73494 - int n_minors; /* number of active minor devices */
73495 /* handle uniform packets for scsi type devices (scsi,atapi) */
73496 int (*generic_packet) (struct cdrom_device_info *,
73497 struct packet_command *);
73498 diff --git a/include/linux/cleancache.h b/include/linux/cleancache.h
73499 index 4ce9056..86caac6 100644
73500 --- a/include/linux/cleancache.h
73501 +++ b/include/linux/cleancache.h
73502 @@ -31,7 +31,7 @@ struct cleancache_ops {
73503 void (*invalidate_page)(int, struct cleancache_filekey, pgoff_t);
73504 void (*invalidate_inode)(int, struct cleancache_filekey);
73505 void (*invalidate_fs)(int);
73506 -};
73507 +} __no_const;
73508
73509 extern struct cleancache_ops *
73510 cleancache_register_ops(struct cleancache_ops *ops);
73511 diff --git a/include/linux/clk-provider.h b/include/linux/clk-provider.h
73512 index 73bdb69..d66d47a 100644
73513 --- a/include/linux/clk-provider.h
73514 +++ b/include/linux/clk-provider.h
73515 @@ -141,6 +141,7 @@ struct clk_ops {
73516 unsigned long);
73517 void (*init)(struct clk_hw *hw);
73518 };
73519 +typedef struct clk_ops __no_const clk_ops_no_const;
73520
73521 /**
73522 * struct clk_init_data - holds init data that's common to all clocks and is
73523 diff --git a/include/linux/compat.h b/include/linux/compat.h
73524 index 345da00..b6eff26 100644
73525 --- a/include/linux/compat.h
73526 +++ b/include/linux/compat.h
73527 @@ -313,7 +313,7 @@ compat_sys_get_robust_list(int pid, compat_uptr_t __user *head_ptr,
73528 compat_size_t __user *len_ptr);
73529
73530 asmlinkage long compat_sys_ipc(u32, int, int, u32, compat_uptr_t, u32);
73531 -asmlinkage long compat_sys_shmat(int shmid, compat_uptr_t shmaddr, int shmflg);
73532 +asmlinkage long compat_sys_shmat(int shmid, compat_uptr_t shmaddr, int shmflg) __intentional_overflow(0);
73533 asmlinkage long compat_sys_semctl(int semid, int semnum, int cmd, int arg);
73534 asmlinkage long compat_sys_msgsnd(int msqid, compat_uptr_t msgp,
73535 compat_ssize_t msgsz, int msgflg);
73536 @@ -420,7 +420,7 @@ extern int compat_ptrace_request(struct task_struct *child,
73537 extern long compat_arch_ptrace(struct task_struct *child, compat_long_t request,
73538 compat_ulong_t addr, compat_ulong_t data);
73539 asmlinkage long compat_sys_ptrace(compat_long_t request, compat_long_t pid,
73540 - compat_long_t addr, compat_long_t data);
73541 + compat_ulong_t addr, compat_ulong_t data);
73542
73543 asmlinkage long compat_sys_lookup_dcookie(u32, u32, char __user *, size_t);
73544 /*
73545 diff --git a/include/linux/compiler-gcc4.h b/include/linux/compiler-gcc4.h
73546 index ded4299..da50e3b 100644
73547 --- a/include/linux/compiler-gcc4.h
73548 +++ b/include/linux/compiler-gcc4.h
73549 @@ -39,9 +39,29 @@
73550 # define __compiletime_warning(message) __attribute__((warning(message)))
73551 # define __compiletime_error(message) __attribute__((error(message)))
73552 #endif /* __CHECKER__ */
73553 +
73554 +#define __alloc_size(...) __attribute((alloc_size(__VA_ARGS__)))
73555 +#define __bos(ptr, arg) __builtin_object_size((ptr), (arg))
73556 +#define __bos0(ptr) __bos((ptr), 0)
73557 +#define __bos1(ptr) __bos((ptr), 1)
73558 #endif /* GCC_VERSION >= 40300 */
73559
73560 #if GCC_VERSION >= 40500
73561 +
73562 +#ifdef CONSTIFY_PLUGIN
73563 +#define __no_const __attribute__((no_const))
73564 +#define __do_const __attribute__((do_const))
73565 +#endif
73566 +
73567 +#ifdef SIZE_OVERFLOW_PLUGIN
73568 +#define __size_overflow(...) __attribute__((size_overflow(__VA_ARGS__)))
73569 +#define __intentional_overflow(...) __attribute__((intentional_overflow(__VA_ARGS__)))
73570 +#endif
73571 +
73572 +#ifdef LATENT_ENTROPY_PLUGIN
73573 +#define __latent_entropy __attribute__((latent_entropy))
73574 +#endif
73575 +
73576 /*
73577 * Mark a position in code as unreachable. This can be used to
73578 * suppress control flow warnings after asm blocks that transfer
73579 diff --git a/include/linux/compiler.h b/include/linux/compiler.h
73580 index 92669cd..1771a15 100644
73581 --- a/include/linux/compiler.h
73582 +++ b/include/linux/compiler.h
73583 @@ -5,11 +5,14 @@
73584
73585 #ifdef __CHECKER__
73586 # define __user __attribute__((noderef, address_space(1)))
73587 +# define __force_user __force __user
73588 # define __kernel __attribute__((address_space(0)))
73589 +# define __force_kernel __force __kernel
73590 # define __safe __attribute__((safe))
73591 # define __force __attribute__((force))
73592 # define __nocast __attribute__((nocast))
73593 # define __iomem __attribute__((noderef, address_space(2)))
73594 +# define __force_iomem __force __iomem
73595 # define __must_hold(x) __attribute__((context(x,1,1)))
73596 # define __acquires(x) __attribute__((context(x,0,1)))
73597 # define __releases(x) __attribute__((context(x,1,0)))
73598 @@ -17,20 +20,37 @@
73599 # define __release(x) __context__(x,-1)
73600 # define __cond_lock(x,c) ((c) ? ({ __acquire(x); 1; }) : 0)
73601 # define __percpu __attribute__((noderef, address_space(3)))
73602 +# define __force_percpu __force __percpu
73603 #ifdef CONFIG_SPARSE_RCU_POINTER
73604 # define __rcu __attribute__((noderef, address_space(4)))
73605 +# define __force_rcu __force __rcu
73606 #else
73607 # define __rcu
73608 +# define __force_rcu
73609 #endif
73610 extern void __chk_user_ptr(const volatile void __user *);
73611 extern void __chk_io_ptr(const volatile void __iomem *);
73612 #else
73613 -# define __user
73614 -# define __kernel
73615 +# ifdef CHECKER_PLUGIN
73616 +//# define __user
73617 +//# define __force_user
73618 +//# define __kernel
73619 +//# define __force_kernel
73620 +# else
73621 +# ifdef STRUCTLEAK_PLUGIN
73622 +# define __user __attribute__((user))
73623 +# else
73624 +# define __user
73625 +# endif
73626 +# define __force_user
73627 +# define __kernel
73628 +# define __force_kernel
73629 +# endif
73630 # define __safe
73631 # define __force
73632 # define __nocast
73633 # define __iomem
73634 +# define __force_iomem
73635 # define __chk_user_ptr(x) (void)0
73636 # define __chk_io_ptr(x) (void)0
73637 # define __builtin_warning(x, y...) (1)
73638 @@ -41,7 +61,9 @@ extern void __chk_io_ptr(const volatile void __iomem *);
73639 # define __release(x) (void)0
73640 # define __cond_lock(x,c) (c)
73641 # define __percpu
73642 +# define __force_percpu
73643 # define __rcu
73644 +# define __force_rcu
73645 #endif
73646
73647 /* Indirect macros required for expanded argument pasting, eg. __LINE__. */
73648 @@ -275,6 +297,26 @@ void ftrace_likely_update(struct ftrace_branch_data *f, int val, int expect);
73649 # define __attribute_const__ /* unimplemented */
73650 #endif
73651
73652 +#ifndef __no_const
73653 +# define __no_const
73654 +#endif
73655 +
73656 +#ifndef __do_const
73657 +# define __do_const
73658 +#endif
73659 +
73660 +#ifndef __size_overflow
73661 +# define __size_overflow(...)
73662 +#endif
73663 +
73664 +#ifndef __intentional_overflow
73665 +# define __intentional_overflow(...)
73666 +#endif
73667 +
73668 +#ifndef __latent_entropy
73669 +# define __latent_entropy
73670 +#endif
73671 +
73672 /*
73673 * Tell gcc if a function is cold. The compiler will assume any path
73674 * directly leading to the call is unlikely.
73675 @@ -284,6 +326,22 @@ void ftrace_likely_update(struct ftrace_branch_data *f, int val, int expect);
73676 #define __cold
73677 #endif
73678
73679 +#ifndef __alloc_size
73680 +#define __alloc_size(...)
73681 +#endif
73682 +
73683 +#ifndef __bos
73684 +#define __bos(ptr, arg)
73685 +#endif
73686 +
73687 +#ifndef __bos0
73688 +#define __bos0(ptr)
73689 +#endif
73690 +
73691 +#ifndef __bos1
73692 +#define __bos1(ptr)
73693 +#endif
73694 +
73695 /* Simple shorthand for a section definition */
73696 #ifndef __section
73697 # define __section(S) __attribute__ ((__section__(#S)))
73698 @@ -349,7 +407,8 @@ void ftrace_likely_update(struct ftrace_branch_data *f, int val, int expect);
73699 * use is to mediate communication between process-level code and irq/NMI
73700 * handlers, all running on the same CPU.
73701 */
73702 -#define ACCESS_ONCE(x) (*(volatile typeof(x) *)&(x))
73703 +#define ACCESS_ONCE(x) (*(volatile const typeof(x) *)&(x))
73704 +#define ACCESS_ONCE_RW(x) (*(volatile typeof(x) *)&(x))
73705
73706 /* Ignore/forbid kprobes attach on very low level functions marked by this attribute: */
73707 #ifdef CONFIG_KPROBES
73708 diff --git a/include/linux/completion.h b/include/linux/completion.h
73709 index 3cd574d..240dcb0 100644
73710 --- a/include/linux/completion.h
73711 +++ b/include/linux/completion.h
73712 @@ -78,16 +78,16 @@ static inline void init_completion(struct completion *x)
73713
73714 extern void wait_for_completion(struct completion *);
73715 extern void wait_for_completion_io(struct completion *);
73716 -extern int wait_for_completion_interruptible(struct completion *x);
73717 -extern int wait_for_completion_killable(struct completion *x);
73718 +extern int wait_for_completion_interruptible(struct completion *x) __intentional_overflow(-1);
73719 +extern int wait_for_completion_killable(struct completion *x) __intentional_overflow(-1);
73720 extern unsigned long wait_for_completion_timeout(struct completion *x,
73721 - unsigned long timeout);
73722 + unsigned long timeout) __intentional_overflow(-1);
73723 extern unsigned long wait_for_completion_io_timeout(struct completion *x,
73724 - unsigned long timeout);
73725 + unsigned long timeout) __intentional_overflow(-1);
73726 extern long wait_for_completion_interruptible_timeout(
73727 - struct completion *x, unsigned long timeout);
73728 + struct completion *x, unsigned long timeout) __intentional_overflow(-1);
73729 extern long wait_for_completion_killable_timeout(
73730 - struct completion *x, unsigned long timeout);
73731 + struct completion *x, unsigned long timeout) __intentional_overflow(-1);
73732 extern bool try_wait_for_completion(struct completion *x);
73733 extern bool completion_done(struct completion *x);
73734
73735 diff --git a/include/linux/configfs.h b/include/linux/configfs.h
73736 index 34025df..d94bbbc 100644
73737 --- a/include/linux/configfs.h
73738 +++ b/include/linux/configfs.h
73739 @@ -125,7 +125,7 @@ struct configfs_attribute {
73740 const char *ca_name;
73741 struct module *ca_owner;
73742 umode_t ca_mode;
73743 -};
73744 +} __do_const;
73745
73746 /*
73747 * Users often need to create attribute structures for their configurable
73748 diff --git a/include/linux/cpufreq.h b/include/linux/cpufreq.h
73749 index fcabc42..cba5d93 100644
73750 --- a/include/linux/cpufreq.h
73751 +++ b/include/linux/cpufreq.h
73752 @@ -167,6 +167,7 @@ struct global_attr {
73753 ssize_t (*store)(struct kobject *a, struct attribute *b,
73754 const char *c, size_t count);
73755 };
73756 +typedef struct global_attr __no_const global_attr_no_const;
73757
73758 #define define_one_global_ro(_name) \
73759 static struct global_attr _name = \
73760 @@ -208,7 +209,7 @@ struct cpufreq_driver {
73761 int (*suspend) (struct cpufreq_policy *policy);
73762 int (*resume) (struct cpufreq_policy *policy);
73763 struct freq_attr **attr;
73764 -};
73765 +} __do_const;
73766
73767 /* flags */
73768 #define CPUFREQ_STICKY 0x01 /* the driver isn't removed even if
73769 diff --git a/include/linux/cpuidle.h b/include/linux/cpuidle.h
73770 index 781addc..d1e1fe6 100644
73771 --- a/include/linux/cpuidle.h
73772 +++ b/include/linux/cpuidle.h
73773 @@ -50,7 +50,8 @@ struct cpuidle_state {
73774 int index);
73775
73776 int (*enter_dead) (struct cpuidle_device *dev, int index);
73777 -};
73778 +} __do_const;
73779 +typedef struct cpuidle_state __no_const cpuidle_state_no_const;
73780
73781 /* Idle State Flags */
73782 #define CPUIDLE_FLAG_TIME_VALID (0x01) /* is residency time measurable? */
73783 @@ -192,7 +193,7 @@ struct cpuidle_governor {
73784 void (*reflect) (struct cpuidle_device *dev, int index);
73785
73786 struct module *owner;
73787 -};
73788 +} __do_const;
73789
73790 #ifdef CONFIG_CPU_IDLE
73791
73792 diff --git a/include/linux/cpumask.h b/include/linux/cpumask.h
73793 index d08e4d2..95fad61 100644
73794 --- a/include/linux/cpumask.h
73795 +++ b/include/linux/cpumask.h
73796 @@ -118,17 +118,17 @@ static inline unsigned int cpumask_first(const struct cpumask *srcp)
73797 }
73798
73799 /* Valid inputs for n are -1 and 0. */
73800 -static inline unsigned int cpumask_next(int n, const struct cpumask *srcp)
73801 +static inline unsigned int __intentional_overflow(-1) cpumask_next(int n, const struct cpumask *srcp)
73802 {
73803 return n+1;
73804 }
73805
73806 -static inline unsigned int cpumask_next_zero(int n, const struct cpumask *srcp)
73807 +static inline unsigned int __intentional_overflow(-1) cpumask_next_zero(int n, const struct cpumask *srcp)
73808 {
73809 return n+1;
73810 }
73811
73812 -static inline unsigned int cpumask_next_and(int n,
73813 +static inline unsigned int __intentional_overflow(-1) cpumask_next_and(int n,
73814 const struct cpumask *srcp,
73815 const struct cpumask *andp)
73816 {
73817 @@ -167,7 +167,7 @@ static inline unsigned int cpumask_first(const struct cpumask *srcp)
73818 *
73819 * Returns >= nr_cpu_ids if no further cpus set.
73820 */
73821 -static inline unsigned int cpumask_next(int n, const struct cpumask *srcp)
73822 +static inline unsigned int __intentional_overflow(-1) cpumask_next(int n, const struct cpumask *srcp)
73823 {
73824 /* -1 is a legal arg here. */
73825 if (n != -1)
73826 @@ -182,7 +182,7 @@ static inline unsigned int cpumask_next(int n, const struct cpumask *srcp)
73827 *
73828 * Returns >= nr_cpu_ids if no further cpus unset.
73829 */
73830 -static inline unsigned int cpumask_next_zero(int n, const struct cpumask *srcp)
73831 +static inline unsigned int __intentional_overflow(-1) cpumask_next_zero(int n, const struct cpumask *srcp)
73832 {
73833 /* -1 is a legal arg here. */
73834 if (n != -1)
73835 @@ -190,7 +190,7 @@ static inline unsigned int cpumask_next_zero(int n, const struct cpumask *srcp)
73836 return find_next_zero_bit(cpumask_bits(srcp), nr_cpumask_bits, n+1);
73837 }
73838
73839 -int cpumask_next_and(int n, const struct cpumask *, const struct cpumask *);
73840 +int cpumask_next_and(int n, const struct cpumask *, const struct cpumask *) __intentional_overflow(-1);
73841 int cpumask_any_but(const struct cpumask *mask, unsigned int cpu);
73842
73843 /**
73844 diff --git a/include/linux/cred.h b/include/linux/cred.h
73845 index 04421e8..6bce4ef 100644
73846 --- a/include/linux/cred.h
73847 +++ b/include/linux/cred.h
73848 @@ -194,6 +194,9 @@ static inline void validate_creds_for_do_exit(struct task_struct *tsk)
73849 static inline void validate_process_creds(void)
73850 {
73851 }
73852 +static inline void validate_task_creds(struct task_struct *task)
73853 +{
73854 +}
73855 #endif
73856
73857 /**
73858 diff --git a/include/linux/crypto.h b/include/linux/crypto.h
73859 index b92eadf..b4ecdc1 100644
73860 --- a/include/linux/crypto.h
73861 +++ b/include/linux/crypto.h
73862 @@ -373,7 +373,7 @@ struct cipher_tfm {
73863 const u8 *key, unsigned int keylen);
73864 void (*cit_encrypt_one)(struct crypto_tfm *tfm, u8 *dst, const u8 *src);
73865 void (*cit_decrypt_one)(struct crypto_tfm *tfm, u8 *dst, const u8 *src);
73866 -};
73867 +} __no_const;
73868
73869 struct hash_tfm {
73870 int (*init)(struct hash_desc *desc);
73871 @@ -394,13 +394,13 @@ struct compress_tfm {
73872 int (*cot_decompress)(struct crypto_tfm *tfm,
73873 const u8 *src, unsigned int slen,
73874 u8 *dst, unsigned int *dlen);
73875 -};
73876 +} __no_const;
73877
73878 struct rng_tfm {
73879 int (*rng_gen_random)(struct crypto_rng *tfm, u8 *rdata,
73880 unsigned int dlen);
73881 int (*rng_reset)(struct crypto_rng *tfm, u8 *seed, unsigned int slen);
73882 -};
73883 +} __no_const;
73884
73885 #define crt_ablkcipher crt_u.ablkcipher
73886 #define crt_aead crt_u.aead
73887 diff --git a/include/linux/ctype.h b/include/linux/ctype.h
73888 index 653589e..4ef254a 100644
73889 --- a/include/linux/ctype.h
73890 +++ b/include/linux/ctype.h
73891 @@ -56,7 +56,7 @@ static inline unsigned char __toupper(unsigned char c)
73892 * Fast implementation of tolower() for internal usage. Do not use in your
73893 * code.
73894 */
73895 -static inline char _tolower(const char c)
73896 +static inline unsigned char _tolower(const unsigned char c)
73897 {
73898 return c | 0x20;
73899 }
73900 diff --git a/include/linux/decompress/mm.h b/include/linux/decompress/mm.h
73901 index 7925bf0..d5143d2 100644
73902 --- a/include/linux/decompress/mm.h
73903 +++ b/include/linux/decompress/mm.h
73904 @@ -77,7 +77,7 @@ static void free(void *where)
73905 * warnings when not needed (indeed large_malloc / large_free are not
73906 * needed by inflate */
73907
73908 -#define malloc(a) kmalloc(a, GFP_KERNEL)
73909 +#define malloc(a) kmalloc((a), GFP_KERNEL)
73910 #define free(a) kfree(a)
73911
73912 #define large_malloc(a) vmalloc(a)
73913 diff --git a/include/linux/devfreq.h b/include/linux/devfreq.h
73914 index 5f1ab92..39c35ae 100644
73915 --- a/include/linux/devfreq.h
73916 +++ b/include/linux/devfreq.h
73917 @@ -114,7 +114,7 @@ struct devfreq_governor {
73918 int (*get_target_freq)(struct devfreq *this, unsigned long *freq);
73919 int (*event_handler)(struct devfreq *devfreq,
73920 unsigned int event, void *data);
73921 -};
73922 +} __do_const;
73923
73924 /**
73925 * struct devfreq - Device devfreq structure
73926 diff --git a/include/linux/device.h b/include/linux/device.h
73927 index 2a9d6ed..d14551e3 100644
73928 --- a/include/linux/device.h
73929 +++ b/include/linux/device.h
73930 @@ -313,7 +313,7 @@ struct subsys_interface {
73931 struct list_head node;
73932 int (*add_dev)(struct device *dev, struct subsys_interface *sif);
73933 int (*remove_dev)(struct device *dev, struct subsys_interface *sif);
73934 -};
73935 +} __do_const;
73936
73937 int subsys_interface_register(struct subsys_interface *sif);
73938 void subsys_interface_unregister(struct subsys_interface *sif);
73939 @@ -501,7 +501,7 @@ struct device_type {
73940 void (*release)(struct device *dev);
73941
73942 const struct dev_pm_ops *pm;
73943 -};
73944 +} __do_const;
73945
73946 /* interface for exporting device attributes */
73947 struct device_attribute {
73948 @@ -511,11 +511,12 @@ struct device_attribute {
73949 ssize_t (*store)(struct device *dev, struct device_attribute *attr,
73950 const char *buf, size_t count);
73951 };
73952 +typedef struct device_attribute __no_const device_attribute_no_const;
73953
73954 struct dev_ext_attribute {
73955 struct device_attribute attr;
73956 void *var;
73957 -};
73958 +} __do_const;
73959
73960 ssize_t device_show_ulong(struct device *dev, struct device_attribute *attr,
73961 char *buf);
73962 diff --git a/include/linux/dma-mapping.h b/include/linux/dma-mapping.h
73963 index 3a8d0a2..c762be2 100644
73964 --- a/include/linux/dma-mapping.h
73965 +++ b/include/linux/dma-mapping.h
73966 @@ -54,7 +54,7 @@ struct dma_map_ops {
73967 u64 (*get_required_mask)(struct device *dev);
73968 #endif
73969 int is_phys;
73970 -};
73971 +} __do_const;
73972
73973 #define DMA_BIT_MASK(n) (((n) == 64) ? ~0ULL : ((1ULL<<(n))-1))
73974
73975 diff --git a/include/linux/dmaengine.h b/include/linux/dmaengine.h
73976 index 0bc7275..4ccbf11 100644
73977 --- a/include/linux/dmaengine.h
73978 +++ b/include/linux/dmaengine.h
73979 @@ -1078,9 +1078,9 @@ struct dma_pinned_list {
73980 struct dma_pinned_list *dma_pin_iovec_pages(struct iovec *iov, size_t len);
73981 void dma_unpin_iovec_pages(struct dma_pinned_list* pinned_list);
73982
73983 -dma_cookie_t dma_memcpy_to_iovec(struct dma_chan *chan, struct iovec *iov,
73984 +dma_cookie_t __intentional_overflow(0) dma_memcpy_to_iovec(struct dma_chan *chan, struct iovec *iov,
73985 struct dma_pinned_list *pinned_list, unsigned char *kdata, size_t len);
73986 -dma_cookie_t dma_memcpy_pg_to_iovec(struct dma_chan *chan, struct iovec *iov,
73987 +dma_cookie_t __intentional_overflow(0) dma_memcpy_pg_to_iovec(struct dma_chan *chan, struct iovec *iov,
73988 struct dma_pinned_list *pinned_list, struct page *page,
73989 unsigned int offset, size_t len);
73990
73991 diff --git a/include/linux/efi.h b/include/linux/efi.h
73992 index 5f8f176..62a0556 100644
73993 --- a/include/linux/efi.h
73994 +++ b/include/linux/efi.h
73995 @@ -745,6 +745,7 @@ struct efivar_operations {
73996 efi_set_variable_t *set_variable;
73997 efi_query_variable_store_t *query_variable_store;
73998 };
73999 +typedef struct efivar_operations __no_const efivar_operations_no_const;
74000
74001 struct efivars {
74002 /*
74003 diff --git a/include/linux/elf.h b/include/linux/elf.h
74004 index 40a3c0e..4c45a38 100644
74005 --- a/include/linux/elf.h
74006 +++ b/include/linux/elf.h
74007 @@ -24,6 +24,7 @@ extern Elf32_Dyn _DYNAMIC [];
74008 #define elf_note elf32_note
74009 #define elf_addr_t Elf32_Off
74010 #define Elf_Half Elf32_Half
74011 +#define elf_dyn Elf32_Dyn
74012
74013 #else
74014
74015 @@ -34,6 +35,7 @@ extern Elf64_Dyn _DYNAMIC [];
74016 #define elf_note elf64_note
74017 #define elf_addr_t Elf64_Off
74018 #define Elf_Half Elf64_Half
74019 +#define elf_dyn Elf64_Dyn
74020
74021 #endif
74022
74023 diff --git a/include/linux/err.h b/include/linux/err.h
74024 index 15f92e0..e825a8e 100644
74025 --- a/include/linux/err.h
74026 +++ b/include/linux/err.h
74027 @@ -19,12 +19,12 @@
74028
74029 #define IS_ERR_VALUE(x) unlikely((x) >= (unsigned long)-MAX_ERRNO)
74030
74031 -static inline void * __must_check ERR_PTR(long error)
74032 +static inline void * __must_check __intentional_overflow(-1) ERR_PTR(long error)
74033 {
74034 return (void *) error;
74035 }
74036
74037 -static inline long __must_check PTR_ERR(__force const void *ptr)
74038 +static inline long __must_check __intentional_overflow(-1) PTR_ERR(__force const void *ptr)
74039 {
74040 return (long) ptr;
74041 }
74042 diff --git a/include/linux/extcon.h b/include/linux/extcon.h
74043 index fcb51c8..bdafcf6 100644
74044 --- a/include/linux/extcon.h
74045 +++ b/include/linux/extcon.h
74046 @@ -134,7 +134,7 @@ struct extcon_dev {
74047 /* /sys/class/extcon/.../mutually_exclusive/... */
74048 struct attribute_group attr_g_muex;
74049 struct attribute **attrs_muex;
74050 - struct device_attribute *d_attrs_muex;
74051 + device_attribute_no_const *d_attrs_muex;
74052 };
74053
74054 /**
74055 diff --git a/include/linux/fb.h b/include/linux/fb.h
74056 index ffac70a..ca3e711 100644
74057 --- a/include/linux/fb.h
74058 +++ b/include/linux/fb.h
74059 @@ -304,7 +304,7 @@ struct fb_ops {
74060 /* called at KDB enter and leave time to prepare the console */
74061 int (*fb_debug_enter)(struct fb_info *info);
74062 int (*fb_debug_leave)(struct fb_info *info);
74063 -};
74064 +} __do_const;
74065
74066 #ifdef CONFIG_FB_TILEBLITTING
74067 #define FB_TILE_CURSOR_NONE 0
74068 diff --git a/include/linux/fdtable.h b/include/linux/fdtable.h
74069 index 085197b..0fa6f0b 100644
74070 --- a/include/linux/fdtable.h
74071 +++ b/include/linux/fdtable.h
74072 @@ -95,7 +95,7 @@ struct files_struct *get_files_struct(struct task_struct *);
74073 void put_files_struct(struct files_struct *fs);
74074 void reset_files_struct(struct files_struct *);
74075 int unshare_files(struct files_struct **);
74076 -struct files_struct *dup_fd(struct files_struct *, int *);
74077 +struct files_struct *dup_fd(struct files_struct *, int *) __latent_entropy;
74078 void do_close_on_exec(struct files_struct *);
74079 int iterate_fd(struct files_struct *, unsigned,
74080 int (*)(const void *, struct file *, unsigned),
74081 diff --git a/include/linux/frontswap.h b/include/linux/frontswap.h
74082 index 8293262..2b3b8bd 100644
74083 --- a/include/linux/frontswap.h
74084 +++ b/include/linux/frontswap.h
74085 @@ -11,7 +11,7 @@ struct frontswap_ops {
74086 int (*load)(unsigned, pgoff_t, struct page *);
74087 void (*invalidate_page)(unsigned, pgoff_t);
74088 void (*invalidate_area)(unsigned);
74089 -};
74090 +} __no_const;
74091
74092 extern bool frontswap_enabled;
74093 extern struct frontswap_ops *
74094 diff --git a/include/linux/fs.h b/include/linux/fs.h
74095 index fefa7b0..5e04a8b 100644
74096 --- a/include/linux/fs.h
74097 +++ b/include/linux/fs.h
74098 @@ -1552,7 +1552,8 @@ struct file_operations {
74099 long (*fallocate)(struct file *file, int mode, loff_t offset,
74100 loff_t len);
74101 int (*show_fdinfo)(struct seq_file *m, struct file *f);
74102 -};
74103 +} __do_const;
74104 +typedef struct file_operations __no_const file_operations_no_const;
74105
74106 struct inode_operations {
74107 struct dentry * (*lookup) (struct inode *,struct dentry *, unsigned int);
74108 @@ -2746,4 +2747,14 @@ static inline bool dir_relax(struct inode *inode)
74109 return !IS_DEADDIR(inode);
74110 }
74111
74112 +static inline bool is_sidechannel_device(const struct inode *inode)
74113 +{
74114 +#ifdef CONFIG_GRKERNSEC_DEVICE_SIDECHANNEL
74115 + umode_t mode = inode->i_mode;
74116 + return ((S_ISCHR(mode) || S_ISBLK(mode)) && (mode & (S_IROTH | S_IWOTH)));
74117 +#else
74118 + return false;
74119 +#endif
74120 +}
74121 +
74122 #endif /* _LINUX_FS_H */
74123 diff --git a/include/linux/fs_struct.h b/include/linux/fs_struct.h
74124 index 0efc3e6..e0e1e5f 100644
74125 --- a/include/linux/fs_struct.h
74126 +++ b/include/linux/fs_struct.h
74127 @@ -6,7 +6,7 @@
74128 #include <linux/seqlock.h>
74129
74130 struct fs_struct {
74131 - int users;
74132 + atomic_t users;
74133 spinlock_t lock;
74134 seqcount_t seq;
74135 int umask;
74136 diff --git a/include/linux/fscache-cache.h b/include/linux/fscache-cache.h
74137 index 7823e9e..56b6f2f 100644
74138 --- a/include/linux/fscache-cache.h
74139 +++ b/include/linux/fscache-cache.h
74140 @@ -113,7 +113,7 @@ struct fscache_operation {
74141 fscache_operation_release_t release;
74142 };
74143
74144 -extern atomic_t fscache_op_debug_id;
74145 +extern atomic_unchecked_t fscache_op_debug_id;
74146 extern void fscache_op_work_func(struct work_struct *work);
74147
74148 extern void fscache_enqueue_operation(struct fscache_operation *);
74149 @@ -135,7 +135,7 @@ static inline void fscache_operation_init(struct fscache_operation *op,
74150 INIT_WORK(&op->work, fscache_op_work_func);
74151 atomic_set(&op->usage, 1);
74152 op->state = FSCACHE_OP_ST_INITIALISED;
74153 - op->debug_id = atomic_inc_return(&fscache_op_debug_id);
74154 + op->debug_id = atomic_inc_return_unchecked(&fscache_op_debug_id);
74155 op->processor = processor;
74156 op->release = release;
74157 INIT_LIST_HEAD(&op->pend_link);
74158 diff --git a/include/linux/fscache.h b/include/linux/fscache.h
74159 index 19b4645..3b73dfc 100644
74160 --- a/include/linux/fscache.h
74161 +++ b/include/linux/fscache.h
74162 @@ -152,7 +152,7 @@ struct fscache_cookie_def {
74163 * - this is mandatory for any object that may have data
74164 */
74165 void (*now_uncached)(void *cookie_netfs_data);
74166 -};
74167 +} __do_const;
74168
74169 /*
74170 * fscache cached network filesystem type
74171 diff --git a/include/linux/fsnotify.h b/include/linux/fsnotify.h
74172 index 1c804b0..1432c2b 100644
74173 --- a/include/linux/fsnotify.h
74174 +++ b/include/linux/fsnotify.h
74175 @@ -195,6 +195,9 @@ static inline void fsnotify_access(struct file *file)
74176 struct inode *inode = file_inode(file);
74177 __u32 mask = FS_ACCESS;
74178
74179 + if (is_sidechannel_device(inode))
74180 + return;
74181 +
74182 if (S_ISDIR(inode->i_mode))
74183 mask |= FS_ISDIR;
74184
74185 @@ -213,6 +216,9 @@ static inline void fsnotify_modify(struct file *file)
74186 struct inode *inode = file_inode(file);
74187 __u32 mask = FS_MODIFY;
74188
74189 + if (is_sidechannel_device(inode))
74190 + return;
74191 +
74192 if (S_ISDIR(inode->i_mode))
74193 mask |= FS_ISDIR;
74194
74195 @@ -315,7 +321,7 @@ static inline void fsnotify_change(struct dentry *dentry, unsigned int ia_valid)
74196 */
74197 static inline const unsigned char *fsnotify_oldname_init(const unsigned char *name)
74198 {
74199 - return kstrdup(name, GFP_KERNEL);
74200 + return (const unsigned char *)kstrdup((const char *)name, GFP_KERNEL);
74201 }
74202
74203 /*
74204 diff --git a/include/linux/genhd.h b/include/linux/genhd.h
74205 index 9f3c275..8bdff5d 100644
74206 --- a/include/linux/genhd.h
74207 +++ b/include/linux/genhd.h
74208 @@ -194,7 +194,7 @@ struct gendisk {
74209 struct kobject *slave_dir;
74210
74211 struct timer_rand_state *random;
74212 - atomic_t sync_io; /* RAID */
74213 + atomic_unchecked_t sync_io; /* RAID */
74214 struct disk_events *ev;
74215 #ifdef CONFIG_BLK_DEV_INTEGRITY
74216 struct blk_integrity *integrity;
74217 @@ -435,7 +435,7 @@ extern void disk_flush_events(struct gendisk *disk, unsigned int mask);
74218 extern unsigned int disk_clear_events(struct gendisk *disk, unsigned int mask);
74219
74220 /* drivers/char/random.c */
74221 -extern void add_disk_randomness(struct gendisk *disk);
74222 +extern void add_disk_randomness(struct gendisk *disk) __latent_entropy;
74223 extern void rand_initialize_disk(struct gendisk *disk);
74224
74225 static inline sector_t get_start_sect(struct block_device *bdev)
74226 diff --git a/include/linux/genl_magic_func.h b/include/linux/genl_magic_func.h
74227 index 023bc34..b02b46a 100644
74228 --- a/include/linux/genl_magic_func.h
74229 +++ b/include/linux/genl_magic_func.h
74230 @@ -246,7 +246,7 @@ const char *CONCAT_(GENL_MAGIC_FAMILY, _genl_cmd_to_str)(__u8 cmd)
74231 },
74232
74233 #define ZZZ_genl_ops CONCAT_(GENL_MAGIC_FAMILY, _genl_ops)
74234 -static struct genl_ops ZZZ_genl_ops[] __read_mostly = {
74235 +static struct genl_ops ZZZ_genl_ops[] = {
74236 #include GENL_MAGIC_INCLUDE_FILE
74237 };
74238
74239 diff --git a/include/linux/gfp.h b/include/linux/gfp.h
74240 index 9b4dd49..61fd41d 100644
74241 --- a/include/linux/gfp.h
74242 +++ b/include/linux/gfp.h
74243 @@ -35,6 +35,13 @@ struct vm_area_struct;
74244 #define ___GFP_NO_KSWAPD 0x400000u
74245 #define ___GFP_OTHER_NODE 0x800000u
74246 #define ___GFP_WRITE 0x1000000u
74247 +
74248 +#ifdef CONFIG_PAX_USERCOPY_SLABS
74249 +#define ___GFP_USERCOPY 0x2000000u
74250 +#else
74251 +#define ___GFP_USERCOPY 0
74252 +#endif
74253 +
74254 /* If the above are modified, __GFP_BITS_SHIFT may need updating */
74255
74256 /*
74257 @@ -92,6 +99,7 @@ struct vm_area_struct;
74258 #define __GFP_OTHER_NODE ((__force gfp_t)___GFP_OTHER_NODE) /* On behalf of other node */
74259 #define __GFP_KMEMCG ((__force gfp_t)___GFP_KMEMCG) /* Allocation comes from a memcg-accounted resource */
74260 #define __GFP_WRITE ((__force gfp_t)___GFP_WRITE) /* Allocator intends to dirty page */
74261 +#define __GFP_USERCOPY ((__force gfp_t)___GFP_USERCOPY)/* Allocator intends to copy page to/from userland */
74262
74263 /*
74264 * This may seem redundant, but it's a way of annotating false positives vs.
74265 @@ -99,7 +107,7 @@ struct vm_area_struct;
74266 */
74267 #define __GFP_NOTRACK_FALSE_POSITIVE (__GFP_NOTRACK)
74268
74269 -#define __GFP_BITS_SHIFT 25 /* Room for N __GFP_FOO bits */
74270 +#define __GFP_BITS_SHIFT 26 /* Room for N __GFP_FOO bits */
74271 #define __GFP_BITS_MASK ((__force gfp_t)((1 << __GFP_BITS_SHIFT) - 1))
74272
74273 /* This equals 0, but use constants in case they ever change */
74274 @@ -153,6 +161,8 @@ struct vm_area_struct;
74275 /* 4GB DMA on some platforms */
74276 #define GFP_DMA32 __GFP_DMA32
74277
74278 +#define GFP_USERCOPY __GFP_USERCOPY
74279 +
74280 /* Convert GFP flags to their corresponding migrate type */
74281 static inline int allocflags_to_migratetype(gfp_t gfp_flags)
74282 {
74283 diff --git a/include/linux/gracl.h b/include/linux/gracl.h
74284 new file mode 100644
74285 index 0000000..edb2cb6
74286 --- /dev/null
74287 +++ b/include/linux/gracl.h
74288 @@ -0,0 +1,340 @@
74289 +#ifndef GR_ACL_H
74290 +#define GR_ACL_H
74291 +
74292 +#include <linux/grdefs.h>
74293 +#include <linux/resource.h>
74294 +#include <linux/capability.h>
74295 +#include <linux/dcache.h>
74296 +#include <asm/resource.h>
74297 +
74298 +/* Major status information */
74299 +
74300 +#define GR_VERSION "grsecurity 3.0"
74301 +#define GRSECURITY_VERSION 0x3000
74302 +
74303 +enum {
74304 + GR_SHUTDOWN = 0,
74305 + GR_ENABLE = 1,
74306 + GR_SPROLE = 2,
74307 + GR_OLDRELOAD = 3,
74308 + GR_SEGVMOD = 4,
74309 + GR_STATUS = 5,
74310 + GR_UNSPROLE = 6,
74311 + GR_PASSSET = 7,
74312 + GR_SPROLEPAM = 8,
74313 + GR_RELOAD = 9,
74314 +};
74315 +
74316 +/* Password setup definitions
74317 + * kernel/grhash.c */
74318 +enum {
74319 + GR_PW_LEN = 128,
74320 + GR_SALT_LEN = 16,
74321 + GR_SHA_LEN = 32,
74322 +};
74323 +
74324 +enum {
74325 + GR_SPROLE_LEN = 64,
74326 +};
74327 +
74328 +enum {
74329 + GR_NO_GLOB = 0,
74330 + GR_REG_GLOB,
74331 + GR_CREATE_GLOB
74332 +};
74333 +
74334 +#define GR_NLIMITS 32
74335 +
74336 +/* Begin Data Structures */
74337 +
74338 +struct sprole_pw {
74339 + unsigned char *rolename;
74340 + unsigned char salt[GR_SALT_LEN];
74341 + unsigned char sum[GR_SHA_LEN]; /* 256-bit SHA hash of the password */
74342 +};
74343 +
74344 +struct name_entry {
74345 + __u32 key;
74346 + ino_t inode;
74347 + dev_t device;
74348 + char *name;
74349 + __u16 len;
74350 + __u8 deleted;
74351 + struct name_entry *prev;
74352 + struct name_entry *next;
74353 +};
74354 +
74355 +struct inodev_entry {
74356 + struct name_entry *nentry;
74357 + struct inodev_entry *prev;
74358 + struct inodev_entry *next;
74359 +};
74360 +
74361 +struct acl_role_db {
74362 + struct acl_role_label **r_hash;
74363 + __u32 r_size;
74364 +};
74365 +
74366 +struct inodev_db {
74367 + struct inodev_entry **i_hash;
74368 + __u32 i_size;
74369 +};
74370 +
74371 +struct name_db {
74372 + struct name_entry **n_hash;
74373 + __u32 n_size;
74374 +};
74375 +
74376 +struct crash_uid {
74377 + uid_t uid;
74378 + unsigned long expires;
74379 +};
74380 +
74381 +struct gr_hash_struct {
74382 + void **table;
74383 + void **nametable;
74384 + void *first;
74385 + __u32 table_size;
74386 + __u32 used_size;
74387 + int type;
74388 +};
74389 +
74390 +/* Userspace Grsecurity ACL data structures */
74391 +
74392 +struct acl_subject_label {
74393 + char *filename;
74394 + ino_t inode;
74395 + dev_t device;
74396 + __u32 mode;
74397 + kernel_cap_t cap_mask;
74398 + kernel_cap_t cap_lower;
74399 + kernel_cap_t cap_invert_audit;
74400 +
74401 + struct rlimit res[GR_NLIMITS];
74402 + __u32 resmask;
74403 +
74404 + __u8 user_trans_type;
74405 + __u8 group_trans_type;
74406 + uid_t *user_transitions;
74407 + gid_t *group_transitions;
74408 + __u16 user_trans_num;
74409 + __u16 group_trans_num;
74410 +
74411 + __u32 sock_families[2];
74412 + __u32 ip_proto[8];
74413 + __u32 ip_type;
74414 + struct acl_ip_label **ips;
74415 + __u32 ip_num;
74416 + __u32 inaddr_any_override;
74417 +
74418 + __u32 crashes;
74419 + unsigned long expires;
74420 +
74421 + struct acl_subject_label *parent_subject;
74422 + struct gr_hash_struct *hash;
74423 + struct acl_subject_label *prev;
74424 + struct acl_subject_label *next;
74425 +
74426 + struct acl_object_label **obj_hash;
74427 + __u32 obj_hash_size;
74428 + __u16 pax_flags;
74429 +};
74430 +
74431 +struct role_allowed_ip {
74432 + __u32 addr;
74433 + __u32 netmask;
74434 +
74435 + struct role_allowed_ip *prev;
74436 + struct role_allowed_ip *next;
74437 +};
74438 +
74439 +struct role_transition {
74440 + char *rolename;
74441 +
74442 + struct role_transition *prev;
74443 + struct role_transition *next;
74444 +};
74445 +
74446 +struct acl_role_label {
74447 + char *rolename;
74448 + uid_t uidgid;
74449 + __u16 roletype;
74450 +
74451 + __u16 auth_attempts;
74452 + unsigned long expires;
74453 +
74454 + struct acl_subject_label *root_label;
74455 + struct gr_hash_struct *hash;
74456 +
74457 + struct acl_role_label *prev;
74458 + struct acl_role_label *next;
74459 +
74460 + struct role_transition *transitions;
74461 + struct role_allowed_ip *allowed_ips;
74462 + uid_t *domain_children;
74463 + __u16 domain_child_num;
74464 +
74465 + umode_t umask;
74466 +
74467 + struct acl_subject_label **subj_hash;
74468 + __u32 subj_hash_size;
74469 +};
74470 +
74471 +struct user_acl_role_db {
74472 + struct acl_role_label **r_table;
74473 + __u32 num_pointers; /* Number of allocations to track */
74474 + __u32 num_roles; /* Number of roles */
74475 + __u32 num_domain_children; /* Number of domain children */
74476 + __u32 num_subjects; /* Number of subjects */
74477 + __u32 num_objects; /* Number of objects */
74478 +};
74479 +
74480 +struct acl_object_label {
74481 + char *filename;
74482 + ino_t inode;
74483 + dev_t device;
74484 + __u32 mode;
74485 +
74486 + struct acl_subject_label *nested;
74487 + struct acl_object_label *globbed;
74488 +
74489 + /* next two structures not used */
74490 +
74491 + struct acl_object_label *prev;
74492 + struct acl_object_label *next;
74493 +};
74494 +
74495 +struct acl_ip_label {
74496 + char *iface;
74497 + __u32 addr;
74498 + __u32 netmask;
74499 + __u16 low, high;
74500 + __u8 mode;
74501 + __u32 type;
74502 + __u32 proto[8];
74503 +
74504 + /* next two structures not used */
74505 +
74506 + struct acl_ip_label *prev;
74507 + struct acl_ip_label *next;
74508 +};
74509 +
74510 +struct gr_arg {
74511 + struct user_acl_role_db role_db;
74512 + unsigned char pw[GR_PW_LEN];
74513 + unsigned char salt[GR_SALT_LEN];
74514 + unsigned char sum[GR_SHA_LEN];
74515 + unsigned char sp_role[GR_SPROLE_LEN];
74516 + struct sprole_pw *sprole_pws;
74517 + dev_t segv_device;
74518 + ino_t segv_inode;
74519 + uid_t segv_uid;
74520 + __u16 num_sprole_pws;
74521 + __u16 mode;
74522 +};
74523 +
74524 +struct gr_arg_wrapper {
74525 + struct gr_arg *arg;
74526 + __u32 version;
74527 + __u32 size;
74528 +};
74529 +
74530 +struct subject_map {
74531 + struct acl_subject_label *user;
74532 + struct acl_subject_label *kernel;
74533 + struct subject_map *prev;
74534 + struct subject_map *next;
74535 +};
74536 +
74537 +struct acl_subj_map_db {
74538 + struct subject_map **s_hash;
74539 + __u32 s_size;
74540 +};
74541 +
74542 +struct gr_policy_state {
74543 + struct sprole_pw **acl_special_roles;
74544 + __u16 num_sprole_pws;
74545 + struct acl_role_label *kernel_role;
74546 + struct acl_role_label *role_list;
74547 + struct acl_role_label *default_role;
74548 + struct acl_role_db acl_role_set;
74549 + struct acl_subj_map_db subj_map_set;
74550 + struct name_db name_set;
74551 + struct inodev_db inodev_set;
74552 +};
74553 +
74554 +struct gr_alloc_state {
74555 + unsigned long alloc_stack_next;
74556 + unsigned long alloc_stack_size;
74557 + void **alloc_stack;
74558 +};
74559 +
74560 +struct gr_reload_state {
74561 + struct gr_policy_state oldpolicy;
74562 + struct gr_alloc_state oldalloc;
74563 + struct gr_policy_state newpolicy;
74564 + struct gr_alloc_state newalloc;
74565 + struct gr_policy_state *oldpolicy_ptr;
74566 + struct gr_alloc_state *oldalloc_ptr;
74567 + unsigned char oldmode;
74568 +};
74569 +
74570 +/* End Data Structures Section */
74571 +
74572 +/* Hash functions generated by empirical testing by Brad Spengler
74573 + Makes good use of the low bits of the inode. Generally 0-1 times
74574 + in loop for successful match. 0-3 for unsuccessful match.
74575 + Shift/add algorithm with modulus of table size and an XOR*/
74576 +
74577 +static __inline__ unsigned int
74578 +gr_rhash(const uid_t uid, const __u16 type, const unsigned int sz)
74579 +{
74580 + return ((((uid + type) << (16 + type)) ^ uid) % sz);
74581 +}
74582 +
74583 + static __inline__ unsigned int
74584 +gr_shash(const struct acl_subject_label *userp, const unsigned int sz)
74585 +{
74586 + return ((const unsigned long)userp % sz);
74587 +}
74588 +
74589 +static __inline__ unsigned int
74590 +gr_fhash(const ino_t ino, const dev_t dev, const unsigned int sz)
74591 +{
74592 + return (((ino + dev) ^ ((ino << 13) + (ino << 23) + (dev << 9))) % sz);
74593 +}
74594 +
74595 +static __inline__ unsigned int
74596 +gr_nhash(const char *name, const __u16 len, const unsigned int sz)
74597 +{
74598 + return full_name_hash((const unsigned char *)name, len) % sz;
74599 +}
74600 +
74601 +#define FOR_EACH_SUBJECT_START(role,subj,iter) \
74602 + subj = NULL; \
74603 + iter = 0; \
74604 + while (iter < role->subj_hash_size) { \
74605 + if (subj == NULL) \
74606 + subj = role->subj_hash[iter]; \
74607 + if (subj == NULL) { \
74608 + iter++; \
74609 + continue; \
74610 + }
74611 +
74612 +#define FOR_EACH_SUBJECT_END(subj,iter) \
74613 + subj = subj->next; \
74614 + if (subj == NULL) \
74615 + iter++; \
74616 + }
74617 +
74618 +
74619 +#define FOR_EACH_NESTED_SUBJECT_START(role,subj) \
74620 + subj = role->hash->first; \
74621 + while (subj != NULL) {
74622 +
74623 +#define FOR_EACH_NESTED_SUBJECT_END(subj) \
74624 + subj = subj->next; \
74625 + }
74626 +
74627 +#endif
74628 +
74629 diff --git a/include/linux/gracl_compat.h b/include/linux/gracl_compat.h
74630 new file mode 100644
74631 index 0000000..33ebd1f
74632 --- /dev/null
74633 +++ b/include/linux/gracl_compat.h
74634 @@ -0,0 +1,156 @@
74635 +#ifndef GR_ACL_COMPAT_H
74636 +#define GR_ACL_COMPAT_H
74637 +
74638 +#include <linux/resource.h>
74639 +#include <asm/resource.h>
74640 +
74641 +struct sprole_pw_compat {
74642 + compat_uptr_t rolename;
74643 + unsigned char salt[GR_SALT_LEN];
74644 + unsigned char sum[GR_SHA_LEN];
74645 +};
74646 +
74647 +struct gr_hash_struct_compat {
74648 + compat_uptr_t table;
74649 + compat_uptr_t nametable;
74650 + compat_uptr_t first;
74651 + __u32 table_size;
74652 + __u32 used_size;
74653 + int type;
74654 +};
74655 +
74656 +struct acl_subject_label_compat {
74657 + compat_uptr_t filename;
74658 + compat_ino_t inode;
74659 + __u32 device;
74660 + __u32 mode;
74661 + kernel_cap_t cap_mask;
74662 + kernel_cap_t cap_lower;
74663 + kernel_cap_t cap_invert_audit;
74664 +
74665 + struct compat_rlimit res[GR_NLIMITS];
74666 + __u32 resmask;
74667 +
74668 + __u8 user_trans_type;
74669 + __u8 group_trans_type;
74670 + compat_uptr_t user_transitions;
74671 + compat_uptr_t group_transitions;
74672 + __u16 user_trans_num;
74673 + __u16 group_trans_num;
74674 +
74675 + __u32 sock_families[2];
74676 + __u32 ip_proto[8];
74677 + __u32 ip_type;
74678 + compat_uptr_t ips;
74679 + __u32 ip_num;
74680 + __u32 inaddr_any_override;
74681 +
74682 + __u32 crashes;
74683 + compat_ulong_t expires;
74684 +
74685 + compat_uptr_t parent_subject;
74686 + compat_uptr_t hash;
74687 + compat_uptr_t prev;
74688 + compat_uptr_t next;
74689 +
74690 + compat_uptr_t obj_hash;
74691 + __u32 obj_hash_size;
74692 + __u16 pax_flags;
74693 +};
74694 +
74695 +struct role_allowed_ip_compat {
74696 + __u32 addr;
74697 + __u32 netmask;
74698 +
74699 + compat_uptr_t prev;
74700 + compat_uptr_t next;
74701 +};
74702 +
74703 +struct role_transition_compat {
74704 + compat_uptr_t rolename;
74705 +
74706 + compat_uptr_t prev;
74707 + compat_uptr_t next;
74708 +};
74709 +
74710 +struct acl_role_label_compat {
74711 + compat_uptr_t rolename;
74712 + uid_t uidgid;
74713 + __u16 roletype;
74714 +
74715 + __u16 auth_attempts;
74716 + compat_ulong_t expires;
74717 +
74718 + compat_uptr_t root_label;
74719 + compat_uptr_t hash;
74720 +
74721 + compat_uptr_t prev;
74722 + compat_uptr_t next;
74723 +
74724 + compat_uptr_t transitions;
74725 + compat_uptr_t allowed_ips;
74726 + compat_uptr_t domain_children;
74727 + __u16 domain_child_num;
74728 +
74729 + umode_t umask;
74730 +
74731 + compat_uptr_t subj_hash;
74732 + __u32 subj_hash_size;
74733 +};
74734 +
74735 +struct user_acl_role_db_compat {
74736 + compat_uptr_t r_table;
74737 + __u32 num_pointers;
74738 + __u32 num_roles;
74739 + __u32 num_domain_children;
74740 + __u32 num_subjects;
74741 + __u32 num_objects;
74742 +};
74743 +
74744 +struct acl_object_label_compat {
74745 + compat_uptr_t filename;
74746 + compat_ino_t inode;
74747 + __u32 device;
74748 + __u32 mode;
74749 +
74750 + compat_uptr_t nested;
74751 + compat_uptr_t globbed;
74752 +
74753 + compat_uptr_t prev;
74754 + compat_uptr_t next;
74755 +};
74756 +
74757 +struct acl_ip_label_compat {
74758 + compat_uptr_t iface;
74759 + __u32 addr;
74760 + __u32 netmask;
74761 + __u16 low, high;
74762 + __u8 mode;
74763 + __u32 type;
74764 + __u32 proto[8];
74765 +
74766 + compat_uptr_t prev;
74767 + compat_uptr_t next;
74768 +};
74769 +
74770 +struct gr_arg_compat {
74771 + struct user_acl_role_db_compat role_db;
74772 + unsigned char pw[GR_PW_LEN];
74773 + unsigned char salt[GR_SALT_LEN];
74774 + unsigned char sum[GR_SHA_LEN];
74775 + unsigned char sp_role[GR_SPROLE_LEN];
74776 + compat_uptr_t sprole_pws;
74777 + __u32 segv_device;
74778 + compat_ino_t segv_inode;
74779 + uid_t segv_uid;
74780 + __u16 num_sprole_pws;
74781 + __u16 mode;
74782 +};
74783 +
74784 +struct gr_arg_wrapper_compat {
74785 + compat_uptr_t arg;
74786 + __u32 version;
74787 + __u32 size;
74788 +};
74789 +
74790 +#endif
74791 diff --git a/include/linux/gralloc.h b/include/linux/gralloc.h
74792 new file mode 100644
74793 index 0000000..323ecf2
74794 --- /dev/null
74795 +++ b/include/linux/gralloc.h
74796 @@ -0,0 +1,9 @@
74797 +#ifndef __GRALLOC_H
74798 +#define __GRALLOC_H
74799 +
74800 +void acl_free_all(void);
74801 +int acl_alloc_stack_init(unsigned long size);
74802 +void *acl_alloc(unsigned long len);
74803 +void *acl_alloc_num(unsigned long num, unsigned long len);
74804 +
74805 +#endif
74806 diff --git a/include/linux/grdefs.h b/include/linux/grdefs.h
74807 new file mode 100644
74808 index 0000000..be66033
74809 --- /dev/null
74810 +++ b/include/linux/grdefs.h
74811 @@ -0,0 +1,140 @@
74812 +#ifndef GRDEFS_H
74813 +#define GRDEFS_H
74814 +
74815 +/* Begin grsecurity status declarations */
74816 +
74817 +enum {
74818 + GR_READY = 0x01,
74819 + GR_STATUS_INIT = 0x00 // disabled state
74820 +};
74821 +
74822 +/* Begin ACL declarations */
74823 +
74824 +/* Role flags */
74825 +
74826 +enum {
74827 + GR_ROLE_USER = 0x0001,
74828 + GR_ROLE_GROUP = 0x0002,
74829 + GR_ROLE_DEFAULT = 0x0004,
74830 + GR_ROLE_SPECIAL = 0x0008,
74831 + GR_ROLE_AUTH = 0x0010,
74832 + GR_ROLE_NOPW = 0x0020,
74833 + GR_ROLE_GOD = 0x0040,
74834 + GR_ROLE_LEARN = 0x0080,
74835 + GR_ROLE_TPE = 0x0100,
74836 + GR_ROLE_DOMAIN = 0x0200,
74837 + GR_ROLE_PAM = 0x0400,
74838 + GR_ROLE_PERSIST = 0x0800
74839 +};
74840 +
74841 +/* ACL Subject and Object mode flags */
74842 +enum {
74843 + GR_DELETED = 0x80000000
74844 +};
74845 +
74846 +/* ACL Object-only mode flags */
74847 +enum {
74848 + GR_READ = 0x00000001,
74849 + GR_APPEND = 0x00000002,
74850 + GR_WRITE = 0x00000004,
74851 + GR_EXEC = 0x00000008,
74852 + GR_FIND = 0x00000010,
74853 + GR_INHERIT = 0x00000020,
74854 + GR_SETID = 0x00000040,
74855 + GR_CREATE = 0x00000080,
74856 + GR_DELETE = 0x00000100,
74857 + GR_LINK = 0x00000200,
74858 + GR_AUDIT_READ = 0x00000400,
74859 + GR_AUDIT_APPEND = 0x00000800,
74860 + GR_AUDIT_WRITE = 0x00001000,
74861 + GR_AUDIT_EXEC = 0x00002000,
74862 + GR_AUDIT_FIND = 0x00004000,
74863 + GR_AUDIT_INHERIT= 0x00008000,
74864 + GR_AUDIT_SETID = 0x00010000,
74865 + GR_AUDIT_CREATE = 0x00020000,
74866 + GR_AUDIT_DELETE = 0x00040000,
74867 + GR_AUDIT_LINK = 0x00080000,
74868 + GR_PTRACERD = 0x00100000,
74869 + GR_NOPTRACE = 0x00200000,
74870 + GR_SUPPRESS = 0x00400000,
74871 + GR_NOLEARN = 0x00800000,
74872 + GR_INIT_TRANSFER= 0x01000000
74873 +};
74874 +
74875 +#define GR_AUDITS (GR_AUDIT_READ | GR_AUDIT_WRITE | GR_AUDIT_APPEND | GR_AUDIT_EXEC | \
74876 + GR_AUDIT_FIND | GR_AUDIT_INHERIT | GR_AUDIT_SETID | \
74877 + GR_AUDIT_CREATE | GR_AUDIT_DELETE | GR_AUDIT_LINK)
74878 +
74879 +/* ACL subject-only mode flags */
74880 +enum {
74881 + GR_KILL = 0x00000001,
74882 + GR_VIEW = 0x00000002,
74883 + GR_PROTECTED = 0x00000004,
74884 + GR_LEARN = 0x00000008,
74885 + GR_OVERRIDE = 0x00000010,
74886 + /* just a placeholder, this mode is only used in userspace */
74887 + GR_DUMMY = 0x00000020,
74888 + GR_PROTSHM = 0x00000040,
74889 + GR_KILLPROC = 0x00000080,
74890 + GR_KILLIPPROC = 0x00000100,
74891 + /* just a placeholder, this mode is only used in userspace */
74892 + GR_NOTROJAN = 0x00000200,
74893 + GR_PROTPROCFD = 0x00000400,
74894 + GR_PROCACCT = 0x00000800,
74895 + GR_RELAXPTRACE = 0x00001000,
74896 + //GR_NESTED = 0x00002000,
74897 + GR_INHERITLEARN = 0x00004000,
74898 + GR_PROCFIND = 0x00008000,
74899 + GR_POVERRIDE = 0x00010000,
74900 + GR_KERNELAUTH = 0x00020000,
74901 + GR_ATSECURE = 0x00040000,
74902 + GR_SHMEXEC = 0x00080000
74903 +};
74904 +
74905 +enum {
74906 + GR_PAX_ENABLE_SEGMEXEC = 0x0001,
74907 + GR_PAX_ENABLE_PAGEEXEC = 0x0002,
74908 + GR_PAX_ENABLE_MPROTECT = 0x0004,
74909 + GR_PAX_ENABLE_RANDMMAP = 0x0008,
74910 + GR_PAX_ENABLE_EMUTRAMP = 0x0010,
74911 + GR_PAX_DISABLE_SEGMEXEC = 0x0100,
74912 + GR_PAX_DISABLE_PAGEEXEC = 0x0200,
74913 + GR_PAX_DISABLE_MPROTECT = 0x0400,
74914 + GR_PAX_DISABLE_RANDMMAP = 0x0800,
74915 + GR_PAX_DISABLE_EMUTRAMP = 0x1000,
74916 +};
74917 +
74918 +enum {
74919 + GR_ID_USER = 0x01,
74920 + GR_ID_GROUP = 0x02,
74921 +};
74922 +
74923 +enum {
74924 + GR_ID_ALLOW = 0x01,
74925 + GR_ID_DENY = 0x02,
74926 +};
74927 +
74928 +#define GR_CRASH_RES 31
74929 +#define GR_UIDTABLE_MAX 500
74930 +
74931 +/* begin resource learning section */
74932 +enum {
74933 + GR_RLIM_CPU_BUMP = 60,
74934 + GR_RLIM_FSIZE_BUMP = 50000,
74935 + GR_RLIM_DATA_BUMP = 10000,
74936 + GR_RLIM_STACK_BUMP = 1000,
74937 + GR_RLIM_CORE_BUMP = 10000,
74938 + GR_RLIM_RSS_BUMP = 500000,
74939 + GR_RLIM_NPROC_BUMP = 1,
74940 + GR_RLIM_NOFILE_BUMP = 5,
74941 + GR_RLIM_MEMLOCK_BUMP = 50000,
74942 + GR_RLIM_AS_BUMP = 500000,
74943 + GR_RLIM_LOCKS_BUMP = 2,
74944 + GR_RLIM_SIGPENDING_BUMP = 5,
74945 + GR_RLIM_MSGQUEUE_BUMP = 10000,
74946 + GR_RLIM_NICE_BUMP = 1,
74947 + GR_RLIM_RTPRIO_BUMP = 1,
74948 + GR_RLIM_RTTIME_BUMP = 1000000
74949 +};
74950 +
74951 +#endif
74952 diff --git a/include/linux/grinternal.h b/include/linux/grinternal.h
74953 new file mode 100644
74954 index 0000000..d25522e
74955 --- /dev/null
74956 +++ b/include/linux/grinternal.h
74957 @@ -0,0 +1,229 @@
74958 +#ifndef __GRINTERNAL_H
74959 +#define __GRINTERNAL_H
74960 +
74961 +#ifdef CONFIG_GRKERNSEC
74962 +
74963 +#include <linux/fs.h>
74964 +#include <linux/mnt_namespace.h>
74965 +#include <linux/nsproxy.h>
74966 +#include <linux/gracl.h>
74967 +#include <linux/grdefs.h>
74968 +#include <linux/grmsg.h>
74969 +
74970 +void gr_add_learn_entry(const char *fmt, ...)
74971 + __attribute__ ((format (printf, 1, 2)));
74972 +__u32 gr_search_file(const struct dentry *dentry, const __u32 mode,
74973 + const struct vfsmount *mnt);
74974 +__u32 gr_check_create(const struct dentry *new_dentry,
74975 + const struct dentry *parent,
74976 + const struct vfsmount *mnt, const __u32 mode);
74977 +int gr_check_protected_task(const struct task_struct *task);
74978 +__u32 to_gr_audit(const __u32 reqmode);
74979 +int gr_set_acls(const int type);
74980 +int gr_acl_is_enabled(void);
74981 +char gr_roletype_to_char(void);
74982 +
74983 +void gr_handle_alertkill(struct task_struct *task);
74984 +char *gr_to_filename(const struct dentry *dentry,
74985 + const struct vfsmount *mnt);
74986 +char *gr_to_filename1(const struct dentry *dentry,
74987 + const struct vfsmount *mnt);
74988 +char *gr_to_filename2(const struct dentry *dentry,
74989 + const struct vfsmount *mnt);
74990 +char *gr_to_filename3(const struct dentry *dentry,
74991 + const struct vfsmount *mnt);
74992 +
74993 +extern int grsec_enable_ptrace_readexec;
74994 +extern int grsec_enable_harden_ptrace;
74995 +extern int grsec_enable_link;
74996 +extern int grsec_enable_fifo;
74997 +extern int grsec_enable_execve;
74998 +extern int grsec_enable_shm;
74999 +extern int grsec_enable_execlog;
75000 +extern int grsec_enable_signal;
75001 +extern int grsec_enable_audit_ptrace;
75002 +extern int grsec_enable_forkfail;
75003 +extern int grsec_enable_time;
75004 +extern int grsec_enable_rofs;
75005 +extern int grsec_deny_new_usb;
75006 +extern int grsec_enable_chroot_shmat;
75007 +extern int grsec_enable_chroot_mount;
75008 +extern int grsec_enable_chroot_double;
75009 +extern int grsec_enable_chroot_pivot;
75010 +extern int grsec_enable_chroot_chdir;
75011 +extern int grsec_enable_chroot_chmod;
75012 +extern int grsec_enable_chroot_mknod;
75013 +extern int grsec_enable_chroot_fchdir;
75014 +extern int grsec_enable_chroot_nice;
75015 +extern int grsec_enable_chroot_execlog;
75016 +extern int grsec_enable_chroot_caps;
75017 +extern int grsec_enable_chroot_sysctl;
75018 +extern int grsec_enable_chroot_unix;
75019 +extern int grsec_enable_symlinkown;
75020 +extern kgid_t grsec_symlinkown_gid;
75021 +extern int grsec_enable_tpe;
75022 +extern kgid_t grsec_tpe_gid;
75023 +extern int grsec_enable_tpe_all;
75024 +extern int grsec_enable_tpe_invert;
75025 +extern int grsec_enable_socket_all;
75026 +extern kgid_t grsec_socket_all_gid;
75027 +extern int grsec_enable_socket_client;
75028 +extern kgid_t grsec_socket_client_gid;
75029 +extern int grsec_enable_socket_server;
75030 +extern kgid_t grsec_socket_server_gid;
75031 +extern kgid_t grsec_audit_gid;
75032 +extern int grsec_enable_group;
75033 +extern int grsec_enable_log_rwxmaps;
75034 +extern int grsec_enable_mount;
75035 +extern int grsec_enable_chdir;
75036 +extern int grsec_resource_logging;
75037 +extern int grsec_enable_blackhole;
75038 +extern int grsec_lastack_retries;
75039 +extern int grsec_enable_brute;
75040 +extern int grsec_enable_harden_ipc;
75041 +extern int grsec_lock;
75042 +
75043 +extern spinlock_t grsec_alert_lock;
75044 +extern unsigned long grsec_alert_wtime;
75045 +extern unsigned long grsec_alert_fyet;
75046 +
75047 +extern spinlock_t grsec_audit_lock;
75048 +
75049 +extern rwlock_t grsec_exec_file_lock;
75050 +
75051 +#define gr_task_fullpath(tsk) ((tsk)->exec_file ? \
75052 + gr_to_filename2((tsk)->exec_file->f_path.dentry, \
75053 + (tsk)->exec_file->f_path.mnt) : "/")
75054 +
75055 +#define gr_parent_task_fullpath(tsk) ((tsk)->real_parent->exec_file ? \
75056 + gr_to_filename3((tsk)->real_parent->exec_file->f_path.dentry, \
75057 + (tsk)->real_parent->exec_file->f_path.mnt) : "/")
75058 +
75059 +#define gr_task_fullpath0(tsk) ((tsk)->exec_file ? \
75060 + gr_to_filename((tsk)->exec_file->f_path.dentry, \
75061 + (tsk)->exec_file->f_path.mnt) : "/")
75062 +
75063 +#define gr_parent_task_fullpath0(tsk) ((tsk)->real_parent->exec_file ? \
75064 + gr_to_filename1((tsk)->real_parent->exec_file->f_path.dentry, \
75065 + (tsk)->real_parent->exec_file->f_path.mnt) : "/")
75066 +
75067 +#define proc_is_chrooted(tsk_a) ((tsk_a)->gr_is_chrooted)
75068 +
75069 +#define have_same_root(tsk_a,tsk_b) ((tsk_a)->gr_chroot_dentry == (tsk_b)->gr_chroot_dentry)
75070 +
75071 +static inline bool gr_is_same_file(const struct file *file1, const struct file *file2)
75072 +{
75073 + if (file1 && file2) {
75074 + const struct inode *inode1 = file1->f_path.dentry->d_inode;
75075 + const struct inode *inode2 = file2->f_path.dentry->d_inode;
75076 + if (inode1->i_ino == inode2->i_ino && inode1->i_sb->s_dev == inode2->i_sb->s_dev)
75077 + return true;
75078 + }
75079 +
75080 + return false;
75081 +}
75082 +
75083 +#define GR_CHROOT_CAPS {{ \
75084 + CAP_TO_MASK(CAP_LINUX_IMMUTABLE) | CAP_TO_MASK(CAP_NET_ADMIN) | \
75085 + CAP_TO_MASK(CAP_SYS_MODULE) | CAP_TO_MASK(CAP_SYS_RAWIO) | \
75086 + CAP_TO_MASK(CAP_SYS_PACCT) | CAP_TO_MASK(CAP_SYS_ADMIN) | \
75087 + CAP_TO_MASK(CAP_SYS_BOOT) | CAP_TO_MASK(CAP_SYS_TIME) | \
75088 + CAP_TO_MASK(CAP_NET_RAW) | CAP_TO_MASK(CAP_SYS_TTY_CONFIG) | \
75089 + CAP_TO_MASK(CAP_IPC_OWNER) | CAP_TO_MASK(CAP_SETFCAP), \
75090 + CAP_TO_MASK(CAP_SYSLOG) | CAP_TO_MASK(CAP_MAC_ADMIN) }}
75091 +
75092 +#define security_learn(normal_msg,args...) \
75093 +({ \
75094 + read_lock(&grsec_exec_file_lock); \
75095 + gr_add_learn_entry(normal_msg "\n", ## args); \
75096 + read_unlock(&grsec_exec_file_lock); \
75097 +})
75098 +
75099 +enum {
75100 + GR_DO_AUDIT,
75101 + GR_DONT_AUDIT,
75102 + /* used for non-audit messages that we shouldn't kill the task on */
75103 + GR_DONT_AUDIT_GOOD
75104 +};
75105 +
75106 +enum {
75107 + GR_TTYSNIFF,
75108 + GR_RBAC,
75109 + GR_RBAC_STR,
75110 + GR_STR_RBAC,
75111 + GR_RBAC_MODE2,
75112 + GR_RBAC_MODE3,
75113 + GR_FILENAME,
75114 + GR_SYSCTL_HIDDEN,
75115 + GR_NOARGS,
75116 + GR_ONE_INT,
75117 + GR_ONE_INT_TWO_STR,
75118 + GR_ONE_STR,
75119 + GR_STR_INT,
75120 + GR_TWO_STR_INT,
75121 + GR_TWO_INT,
75122 + GR_TWO_U64,
75123 + GR_THREE_INT,
75124 + GR_FIVE_INT_TWO_STR,
75125 + GR_TWO_STR,
75126 + GR_THREE_STR,
75127 + GR_FOUR_STR,
75128 + GR_STR_FILENAME,
75129 + GR_FILENAME_STR,
75130 + GR_FILENAME_TWO_INT,
75131 + GR_FILENAME_TWO_INT_STR,
75132 + GR_TEXTREL,
75133 + GR_PTRACE,
75134 + GR_RESOURCE,
75135 + GR_CAP,
75136 + GR_SIG,
75137 + GR_SIG2,
75138 + GR_CRASH1,
75139 + GR_CRASH2,
75140 + GR_PSACCT,
75141 + GR_RWXMAP,
75142 + GR_RWXMAPVMA
75143 +};
75144 +
75145 +#define gr_log_hidden_sysctl(audit, msg, str) gr_log_varargs(audit, msg, GR_SYSCTL_HIDDEN, str)
75146 +#define gr_log_ttysniff(audit, msg, task) gr_log_varargs(audit, msg, GR_TTYSNIFF, task)
75147 +#define gr_log_fs_rbac_generic(audit, msg, dentry, mnt) gr_log_varargs(audit, msg, GR_RBAC, dentry, mnt)
75148 +#define gr_log_fs_rbac_str(audit, msg, dentry, mnt, str) gr_log_varargs(audit, msg, GR_RBAC_STR, dentry, mnt, str)
75149 +#define gr_log_fs_str_rbac(audit, msg, str, dentry, mnt) gr_log_varargs(audit, msg, GR_STR_RBAC, str, dentry, mnt)
75150 +#define gr_log_fs_rbac_mode2(audit, msg, dentry, mnt, str1, str2) gr_log_varargs(audit, msg, GR_RBAC_MODE2, dentry, mnt, str1, str2)
75151 +#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)
75152 +#define gr_log_fs_generic(audit, msg, dentry, mnt) gr_log_varargs(audit, msg, GR_FILENAME, dentry, mnt)
75153 +#define gr_log_noargs(audit, msg) gr_log_varargs(audit, msg, GR_NOARGS)
75154 +#define gr_log_int(audit, msg, num) gr_log_varargs(audit, msg, GR_ONE_INT, num)
75155 +#define gr_log_int_str2(audit, msg, num, str1, str2) gr_log_varargs(audit, msg, GR_ONE_INT_TWO_STR, num, str1, str2)
75156 +#define gr_log_str(audit, msg, str) gr_log_varargs(audit, msg, GR_ONE_STR, str)
75157 +#define gr_log_str_int(audit, msg, str, num) gr_log_varargs(audit, msg, GR_STR_INT, str, num)
75158 +#define gr_log_int_int(audit, msg, num1, num2) gr_log_varargs(audit, msg, GR_TWO_INT, num1, num2)
75159 +#define gr_log_two_u64(audit, msg, num1, num2) gr_log_varargs(audit, msg, GR_TWO_U64, num1, num2)
75160 +#define gr_log_int3(audit, msg, num1, num2, num3) gr_log_varargs(audit, msg, GR_THREE_INT, num1, num2, num3)
75161 +#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)
75162 +#define gr_log_str_str(audit, msg, str1, str2) gr_log_varargs(audit, msg, GR_TWO_STR, str1, str2)
75163 +#define gr_log_str2_int(audit, msg, str1, str2, num) gr_log_varargs(audit, msg, GR_TWO_STR_INT, str1, str2, num)
75164 +#define gr_log_str3(audit, msg, str1, str2, str3) gr_log_varargs(audit, msg, GR_THREE_STR, str1, str2, str3)
75165 +#define gr_log_str4(audit, msg, str1, str2, str3, str4) gr_log_varargs(audit, msg, GR_FOUR_STR, str1, str2, str3, str4)
75166 +#define gr_log_str_fs(audit, msg, str, dentry, mnt) gr_log_varargs(audit, msg, GR_STR_FILENAME, str, dentry, mnt)
75167 +#define gr_log_fs_str(audit, msg, dentry, mnt, str) gr_log_varargs(audit, msg, GR_FILENAME_STR, dentry, mnt, str)
75168 +#define gr_log_fs_int2(audit, msg, dentry, mnt, num1, num2) gr_log_varargs(audit, msg, GR_FILENAME_TWO_INT, dentry, mnt, num1, num2)
75169 +#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)
75170 +#define gr_log_textrel_ulong_ulong(audit, msg, file, ulong1, ulong2) gr_log_varargs(audit, msg, GR_TEXTREL, file, ulong1, ulong2)
75171 +#define gr_log_ptrace(audit, msg, task) gr_log_varargs(audit, msg, GR_PTRACE, task)
75172 +#define gr_log_res_ulong2_str(audit, msg, task, ulong1, str, ulong2) gr_log_varargs(audit, msg, GR_RESOURCE, task, ulong1, str, ulong2)
75173 +#define gr_log_cap(audit, msg, task, str) gr_log_varargs(audit, msg, GR_CAP, task, str)
75174 +#define gr_log_sig_addr(audit, msg, str, addr) gr_log_varargs(audit, msg, GR_SIG, str, addr)
75175 +#define gr_log_sig_task(audit, msg, task, num) gr_log_varargs(audit, msg, GR_SIG2, task, num)
75176 +#define gr_log_crash1(audit, msg, task, ulong) gr_log_varargs(audit, msg, GR_CRASH1, task, ulong)
75177 +#define gr_log_crash2(audit, msg, task, ulong1) gr_log_varargs(audit, msg, GR_CRASH2, task, ulong1)
75178 +#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)
75179 +#define gr_log_rwxmap(audit, msg, str) gr_log_varargs(audit, msg, GR_RWXMAP, str)
75180 +#define gr_log_rwxmap_vma(audit, msg, str) gr_log_varargs(audit, msg, GR_RWXMAPVMA, str)
75181 +
75182 +void gr_log_varargs(int audit, const char *msg, int argtypes, ...);
75183 +
75184 +#endif
75185 +
75186 +#endif
75187 diff --git a/include/linux/grmsg.h b/include/linux/grmsg.h
75188 new file mode 100644
75189 index 0000000..378a81a
75190 --- /dev/null
75191 +++ b/include/linux/grmsg.h
75192 @@ -0,0 +1,114 @@
75193 +#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"
75194 +#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"
75195 +#define GR_PTRACE_ACL_MSG "denied ptrace of %.950s(%.16s:%d) by "
75196 +#define GR_STOPMOD_MSG "denied modification of module state by "
75197 +#define GR_ROFS_BLOCKWRITE_MSG "denied write to block device %.950s by "
75198 +#define GR_ROFS_MOUNT_MSG "denied writable mount of %.950s by "
75199 +#define GR_IOPERM_MSG "denied use of ioperm() by "
75200 +#define GR_IOPL_MSG "denied use of iopl() by "
75201 +#define GR_SHMAT_ACL_MSG "denied attach of shared memory of UID %u, PID %d, ID %u by "
75202 +#define GR_UNIX_CHROOT_MSG "denied connect() to abstract AF_UNIX socket outside of chroot by "
75203 +#define GR_SHMAT_CHROOT_MSG "denied attach of shared memory outside of chroot by "
75204 +#define GR_MEM_READWRITE_MSG "denied access of range %Lx -> %Lx in /dev/mem by "
75205 +#define GR_SYMLINK_MSG "not following symlink %.950s owned by %d.%d by "
75206 +#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"
75207 +#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"
75208 +#define GR_HIDDEN_ACL_MSG "%s access to hidden file %.950s by "
75209 +#define GR_OPEN_ACL_MSG "%s open of %.950s for%s%s by "
75210 +#define GR_CREATE_ACL_MSG "%s create of %.950s for%s%s by "
75211 +#define GR_FIFO_MSG "denied writing FIFO %.950s of %d.%d by "
75212 +#define GR_MKNOD_CHROOT_MSG "denied mknod of %.950s from chroot by "
75213 +#define GR_MKNOD_ACL_MSG "%s mknod of %.950s by "
75214 +#define GR_UNIXCONNECT_ACL_MSG "%s connect() to the unix domain socket %.950s by "
75215 +#define GR_TTYSNIFF_ACL_MSG "terminal being sniffed by IP:%pI4 %.480s[%.16s:%d], parent %.480s[%.16s:%d] against "
75216 +#define GR_MKDIR_ACL_MSG "%s mkdir of %.950s by "
75217 +#define GR_RMDIR_ACL_MSG "%s rmdir of %.950s by "
75218 +#define GR_UNLINK_ACL_MSG "%s unlink of %.950s by "
75219 +#define GR_SYMLINK_ACL_MSG "%s symlink from %.480s to %.480s by "
75220 +#define GR_HARDLINK_MSG "denied hardlink of %.930s (owned by %d.%d) to %.30s for "
75221 +#define GR_LINK_ACL_MSG "%s link of %.480s to %.480s by "
75222 +#define GR_INHERIT_ACL_MSG "successful inherit of %.480s's ACL for %.480s by "
75223 +#define GR_RENAME_ACL_MSG "%s rename of %.480s to %.480s by "
75224 +#define GR_UNSAFESHARE_EXEC_ACL_MSG "denied exec with cloned fs of %.950s by "
75225 +#define GR_PTRACE_EXEC_ACL_MSG "denied ptrace of %.950s by "
75226 +#define GR_EXEC_ACL_MSG "%s execution of %.950s by "
75227 +#define GR_EXEC_TPE_MSG "denied untrusted exec (due to %.70s) of %.950s by "
75228 +#define GR_SEGVSTART_ACL_MSG "possible exploit bruteforcing on " DEFAULTSECMSG " banning uid %u from login for %lu seconds"
75229 +#define GR_SEGVNOSUID_ACL_MSG "possible exploit bruteforcing on " DEFAULTSECMSG " banning execution for %lu seconds"
75230 +#define GR_MOUNT_CHROOT_MSG "denied mount of %.256s as %.930s from chroot by "
75231 +#define GR_PIVOT_CHROOT_MSG "denied pivot_root from chroot by "
75232 +#define GR_TRUNCATE_ACL_MSG "%s truncate of %.950s by "
75233 +#define GR_ATIME_ACL_MSG "%s access time change of %.950s by "
75234 +#define GR_ACCESS_ACL_MSG "%s access of %.950s for%s%s%s by "
75235 +#define GR_CHROOT_CHROOT_MSG "denied double chroot to %.950s by "
75236 +#define GR_CHMOD_CHROOT_MSG "denied chmod +s of %.950s by "
75237 +#define GR_CHMOD_ACL_MSG "%s chmod of %.950s by "
75238 +#define GR_CHROOT_FCHDIR_MSG "denied fchdir outside of chroot to %.950s by "
75239 +#define GR_CHOWN_ACL_MSG "%s chown of %.950s by "
75240 +#define GR_SETXATTR_ACL_MSG "%s setting extended attributes of %.950s by "
75241 +#define GR_WRITLIB_ACL_MSG "denied load of writable library %.950s by "
75242 +#define GR_INITF_ACL_MSG "init_variables() failed %s by "
75243 +#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"
75244 +#define GR_DEV_ACL_MSG "/dev/grsec: %d bytes sent %d required, being fed garbage by "
75245 +#define GR_SHUTS_ACL_MSG "shutdown auth success for "
75246 +#define GR_SHUTF_ACL_MSG "shutdown auth failure for "
75247 +#define GR_SHUTI_ACL_MSG "ignoring shutdown for disabled RBAC system for "
75248 +#define GR_SEGVMODS_ACL_MSG "segvmod auth success for "
75249 +#define GR_SEGVMODF_ACL_MSG "segvmod auth failure for "
75250 +#define GR_SEGVMODI_ACL_MSG "ignoring segvmod for disabled RBAC system for "
75251 +#define GR_ENABLE_ACL_MSG "%s RBAC system loaded by "
75252 +#define GR_ENABLEF_ACL_MSG "unable to load %s for "
75253 +#define GR_RELOADI_ACL_MSG "ignoring reload request for disabled RBAC system"
75254 +#define GR_RELOAD_ACL_MSG "%s RBAC system reloaded by "
75255 +#define GR_RELOADF_ACL_MSG "failed reload of %s for "
75256 +#define GR_SPROLEI_ACL_MSG "ignoring change to special role for disabled RBAC system for "
75257 +#define GR_SPROLES_ACL_MSG "successful change to special role %s (id %d) by "
75258 +#define GR_SPROLEL_ACL_MSG "special role %s (id %d) exited by "
75259 +#define GR_SPROLEF_ACL_MSG "special role %s failure for "
75260 +#define GR_UNSPROLEI_ACL_MSG "ignoring unauth of special role for disabled RBAC system for "
75261 +#define GR_UNSPROLES_ACL_MSG "successful unauth of special role %s (id %d) by "
75262 +#define GR_INVMODE_ACL_MSG "invalid mode %d by "
75263 +#define GR_PRIORITY_CHROOT_MSG "denied priority change of process (%.16s:%d) by "
75264 +#define GR_FAILFORK_MSG "failed fork with errno %s by "
75265 +#define GR_NICE_CHROOT_MSG "denied priority change by "
75266 +#define GR_UNISIGLOG_MSG "%.32s occurred at %p in "
75267 +#define GR_DUALSIGLOG_MSG "signal %d sent to " DEFAULTSECMSG " by "
75268 +#define GR_SIG_ACL_MSG "denied send of signal %d to protected task " DEFAULTSECMSG " by "
75269 +#define GR_SYSCTL_MSG "denied modification of grsecurity sysctl value : %.32s by "
75270 +#define GR_SYSCTL_ACL_MSG "%s sysctl of %.950s for%s%s by "
75271 +#define GR_TIME_MSG "time set by "
75272 +#define GR_DEFACL_MSG "fatal: unable to find subject for (%.16s:%d), loaded by "
75273 +#define GR_MMAP_ACL_MSG "%s executable mmap of %.950s by "
75274 +#define GR_MPROTECT_ACL_MSG "%s executable mprotect of %.950s by "
75275 +#define GR_SOCK_MSG "denied socket(%.16s,%.16s,%.16s) by "
75276 +#define GR_SOCK_NOINET_MSG "denied socket(%.16s,%.16s,%d) by "
75277 +#define GR_BIND_MSG "denied bind() by "
75278 +#define GR_CONNECT_MSG "denied connect() by "
75279 +#define GR_BIND_ACL_MSG "denied bind() to %pI4 port %u sock type %.16s protocol %.16s by "
75280 +#define GR_CONNECT_ACL_MSG "denied connect() to %pI4 port %u sock type %.16s protocol %.16s by "
75281 +#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"
75282 +#define GR_EXEC_CHROOT_MSG "exec of %.980s within chroot by process "
75283 +#define GR_CAP_ACL_MSG "use of %s denied for "
75284 +#define GR_CAP_CHROOT_MSG "use of %s in chroot denied for "
75285 +#define GR_CAP_ACL_MSG2 "use of %s permitted for "
75286 +#define GR_USRCHANGE_ACL_MSG "change to uid %u denied for "
75287 +#define GR_GRPCHANGE_ACL_MSG "change to gid %u denied for "
75288 +#define GR_REMOUNT_AUDIT_MSG "remount of %.256s by "
75289 +#define GR_UNMOUNT_AUDIT_MSG "unmount of %.256s by "
75290 +#define GR_MOUNT_AUDIT_MSG "mount of %.256s to %.256s by "
75291 +#define GR_CHDIR_AUDIT_MSG "chdir to %.980s by "
75292 +#define GR_EXEC_AUDIT_MSG "exec of %.930s (%.128s) by "
75293 +#define GR_RESOURCE_MSG "denied resource overstep by requesting %lu for %.16s against limit %lu for "
75294 +#define GR_RWXMMAP_MSG "denied RWX mmap of %.950s by "
75295 +#define GR_RWXMPROTECT_MSG "denied RWX mprotect of %.950s by "
75296 +#define GR_TEXTREL_AUDIT_MSG "denied text relocation in %.950s, VMA:0x%08lx 0x%08lx by "
75297 +#define GR_PTGNUSTACK_MSG "denied marking stack executable as requested by PT_GNU_STACK marking in %.950s by "
75298 +#define GR_VM86_MSG "denied use of vm86 by "
75299 +#define GR_PTRACE_AUDIT_MSG "process %.950s(%.16s:%d) attached to via ptrace by "
75300 +#define GR_PTRACE_READEXEC_MSG "denied ptrace of unreadable binary %.950s by "
75301 +#define GR_INIT_TRANSFER_MSG "persistent special role transferred privilege to init by "
75302 +#define GR_BADPROCPID_MSG "denied read of sensitive /proc/pid/%s entry via fd passed across exec by "
75303 +#define GR_SYMLINKOWNER_MSG "denied following symlink %.950s since symlink owner %u does not match target owner %u, by "
75304 +#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 "
75305 +#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 "
75306 +#define GR_IPC_DENIED_MSG "denied %s of globally-%sable IPC with creator uid %u by "
75307 diff --git a/include/linux/grsecurity.h b/include/linux/grsecurity.h
75308 new file mode 100644
75309 index 0000000..134860c
75310 --- /dev/null
75311 +++ b/include/linux/grsecurity.h
75312 @@ -0,0 +1,243 @@
75313 +#ifndef GR_SECURITY_H
75314 +#define GR_SECURITY_H
75315 +#include <linux/fs.h>
75316 +#include <linux/fs_struct.h>
75317 +#include <linux/binfmts.h>
75318 +#include <linux/gracl.h>
75319 +
75320 +/* notify of brain-dead configs */
75321 +#if defined(CONFIG_GRKERNSEC_PROC_USER) && defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
75322 +#error "CONFIG_GRKERNSEC_PROC_USER and CONFIG_GRKERNSEC_PROC_USERGROUP cannot both be enabled."
75323 +#endif
75324 +#if defined(CONFIG_PAX_NOEXEC) && !defined(CONFIG_PAX_PAGEEXEC) && !defined(CONFIG_PAX_SEGMEXEC) && !defined(CONFIG_PAX_KERNEXEC)
75325 +#error "CONFIG_PAX_NOEXEC enabled, but PAGEEXEC, SEGMEXEC, and KERNEXEC are disabled."
75326 +#endif
75327 +#if defined(CONFIG_PAX_ASLR) && !defined(CONFIG_PAX_RANDKSTACK) && !defined(CONFIG_PAX_RANDUSTACK) && !defined(CONFIG_PAX_RANDMMAP)
75328 +#error "CONFIG_PAX_ASLR enabled, but RANDKSTACK, RANDUSTACK, and RANDMMAP are disabled."
75329 +#endif
75330 +#if defined(CONFIG_PAX) && !defined(CONFIG_PAX_NOEXEC) && !defined(CONFIG_PAX_ASLR)
75331 +#error "CONFIG_PAX enabled, but no PaX options are enabled."
75332 +#endif
75333 +
75334 +int gr_handle_new_usb(void);
75335 +
75336 +void gr_handle_brute_attach(int dumpable);
75337 +void gr_handle_brute_check(void);
75338 +void gr_handle_kernel_exploit(void);
75339 +
75340 +char gr_roletype_to_char(void);
75341 +
75342 +int gr_acl_enable_at_secure(void);
75343 +
75344 +int gr_check_user_change(kuid_t real, kuid_t effective, kuid_t fs);
75345 +int gr_check_group_change(kgid_t real, kgid_t effective, kgid_t fs);
75346 +
75347 +void gr_del_task_from_ip_table(struct task_struct *p);
75348 +
75349 +int gr_pid_is_chrooted(struct task_struct *p);
75350 +int gr_handle_chroot_fowner(struct pid *pid, enum pid_type type);
75351 +int gr_handle_chroot_nice(void);
75352 +int gr_handle_chroot_sysctl(const int op);
75353 +int gr_handle_chroot_setpriority(struct task_struct *p,
75354 + const int niceval);
75355 +int gr_chroot_fchdir(struct dentry *u_dentry, struct vfsmount *u_mnt);
75356 +int gr_handle_chroot_chroot(const struct dentry *dentry,
75357 + const struct vfsmount *mnt);
75358 +void gr_handle_chroot_chdir(const struct path *path);
75359 +int gr_handle_chroot_chmod(const struct dentry *dentry,
75360 + const struct vfsmount *mnt, const int mode);
75361 +int gr_handle_chroot_mknod(const struct dentry *dentry,
75362 + const struct vfsmount *mnt, const int mode);
75363 +int gr_handle_chroot_mount(const struct dentry *dentry,
75364 + const struct vfsmount *mnt,
75365 + const char *dev_name);
75366 +int gr_handle_chroot_pivot(void);
75367 +int gr_handle_chroot_unix(const pid_t pid);
75368 +
75369 +int gr_handle_rawio(const struct inode *inode);
75370 +
75371 +void gr_handle_ioperm(void);
75372 +void gr_handle_iopl(void);
75373 +
75374 +umode_t gr_acl_umask(void);
75375 +
75376 +int gr_tpe_allow(const struct file *file);
75377 +
75378 +void gr_set_chroot_entries(struct task_struct *task, const struct path *path);
75379 +void gr_clear_chroot_entries(struct task_struct *task);
75380 +
75381 +void gr_log_forkfail(const int retval);
75382 +void gr_log_timechange(void);
75383 +void gr_log_signal(const int sig, const void *addr, const struct task_struct *t);
75384 +void gr_log_chdir(const struct dentry *dentry,
75385 + const struct vfsmount *mnt);
75386 +void gr_log_chroot_exec(const struct dentry *dentry,
75387 + const struct vfsmount *mnt);
75388 +void gr_log_remount(const char *devname, const int retval);
75389 +void gr_log_unmount(const char *devname, const int retval);
75390 +void gr_log_mount(const char *from, const char *to, const int retval);
75391 +void gr_log_textrel(struct vm_area_struct *vma);
75392 +void gr_log_ptgnustack(struct file *file);
75393 +void gr_log_rwxmmap(struct file *file);
75394 +void gr_log_rwxmprotect(struct vm_area_struct *vma);
75395 +
75396 +int gr_handle_follow_link(const struct inode *parent,
75397 + const struct inode *inode,
75398 + const struct dentry *dentry,
75399 + const struct vfsmount *mnt);
75400 +int gr_handle_fifo(const struct dentry *dentry,
75401 + const struct vfsmount *mnt,
75402 + const struct dentry *dir, const int flag,
75403 + const int acc_mode);
75404 +int gr_handle_hardlink(const struct dentry *dentry,
75405 + const struct vfsmount *mnt,
75406 + struct inode *inode,
75407 + const int mode, const struct filename *to);
75408 +
75409 +int gr_is_capable(const int cap);
75410 +int gr_is_capable_nolog(const int cap);
75411 +int gr_task_is_capable(const struct task_struct *task, const struct cred *cred, const int cap);
75412 +int gr_task_is_capable_nolog(const struct task_struct *task, const int cap);
75413 +
75414 +void gr_copy_label(struct task_struct *tsk);
75415 +void gr_handle_crash(struct task_struct *task, const int sig);
75416 +int gr_handle_signal(const struct task_struct *p, const int sig);
75417 +int gr_check_crash_uid(const kuid_t uid);
75418 +int gr_check_protected_task(const struct task_struct *task);
75419 +int gr_check_protected_task_fowner(struct pid *pid, enum pid_type type);
75420 +int gr_acl_handle_mmap(const struct file *file,
75421 + const unsigned long prot);
75422 +int gr_acl_handle_mprotect(const struct file *file,
75423 + const unsigned long prot);
75424 +int gr_check_hidden_task(const struct task_struct *tsk);
75425 +__u32 gr_acl_handle_truncate(const struct dentry *dentry,
75426 + const struct vfsmount *mnt);
75427 +__u32 gr_acl_handle_utime(const struct dentry *dentry,
75428 + const struct vfsmount *mnt);
75429 +__u32 gr_acl_handle_access(const struct dentry *dentry,
75430 + const struct vfsmount *mnt, const int fmode);
75431 +__u32 gr_acl_handle_chmod(const struct dentry *dentry,
75432 + const struct vfsmount *mnt, umode_t *mode);
75433 +__u32 gr_acl_handle_chown(const struct dentry *dentry,
75434 + const struct vfsmount *mnt);
75435 +__u32 gr_acl_handle_setxattr(const struct dentry *dentry,
75436 + const struct vfsmount *mnt);
75437 +int gr_handle_ptrace(struct task_struct *task, const long request);
75438 +int gr_handle_proc_ptrace(struct task_struct *task);
75439 +__u32 gr_acl_handle_execve(const struct dentry *dentry,
75440 + const struct vfsmount *mnt);
75441 +int gr_check_crash_exec(const struct file *filp);
75442 +int gr_acl_is_enabled(void);
75443 +void gr_set_role_label(struct task_struct *task, const kuid_t uid,
75444 + const kgid_t gid);
75445 +int gr_set_proc_label(const struct dentry *dentry,
75446 + const struct vfsmount *mnt,
75447 + const int unsafe_flags);
75448 +__u32 gr_acl_handle_hidden_file(const struct dentry *dentry,
75449 + const struct vfsmount *mnt);
75450 +__u32 gr_acl_handle_open(const struct dentry *dentry,
75451 + const struct vfsmount *mnt, int acc_mode);
75452 +__u32 gr_acl_handle_creat(const struct dentry *dentry,
75453 + const struct dentry *p_dentry,
75454 + const struct vfsmount *p_mnt,
75455 + int open_flags, int acc_mode, const int imode);
75456 +void gr_handle_create(const struct dentry *dentry,
75457 + const struct vfsmount *mnt);
75458 +void gr_handle_proc_create(const struct dentry *dentry,
75459 + const struct inode *inode);
75460 +__u32 gr_acl_handle_mknod(const struct dentry *new_dentry,
75461 + const struct dentry *parent_dentry,
75462 + const struct vfsmount *parent_mnt,
75463 + const int mode);
75464 +__u32 gr_acl_handle_mkdir(const struct dentry *new_dentry,
75465 + const struct dentry *parent_dentry,
75466 + const struct vfsmount *parent_mnt);
75467 +__u32 gr_acl_handle_rmdir(const struct dentry *dentry,
75468 + const struct vfsmount *mnt);
75469 +void gr_handle_delete(const ino_t ino, const dev_t dev);
75470 +__u32 gr_acl_handle_unlink(const struct dentry *dentry,
75471 + const struct vfsmount *mnt);
75472 +__u32 gr_acl_handle_symlink(const struct dentry *new_dentry,
75473 + const struct dentry *parent_dentry,
75474 + const struct vfsmount *parent_mnt,
75475 + const struct filename *from);
75476 +__u32 gr_acl_handle_link(const struct dentry *new_dentry,
75477 + const struct dentry *parent_dentry,
75478 + const struct vfsmount *parent_mnt,
75479 + const struct dentry *old_dentry,
75480 + const struct vfsmount *old_mnt, const struct filename *to);
75481 +int gr_handle_symlink_owner(const struct path *link, const struct inode *target);
75482 +int gr_acl_handle_rename(struct dentry *new_dentry,
75483 + struct dentry *parent_dentry,
75484 + const struct vfsmount *parent_mnt,
75485 + struct dentry *old_dentry,
75486 + struct inode *old_parent_inode,
75487 + struct vfsmount *old_mnt, const struct filename *newname);
75488 +void gr_handle_rename(struct inode *old_dir, struct inode *new_dir,
75489 + struct dentry *old_dentry,
75490 + struct dentry *new_dentry,
75491 + struct vfsmount *mnt, const __u8 replace);
75492 +__u32 gr_check_link(const struct dentry *new_dentry,
75493 + const struct dentry *parent_dentry,
75494 + const struct vfsmount *parent_mnt,
75495 + const struct dentry *old_dentry,
75496 + const struct vfsmount *old_mnt);
75497 +int gr_acl_handle_filldir(const struct file *file, const char *name,
75498 + const unsigned int namelen, const ino_t ino);
75499 +
75500 +__u32 gr_acl_handle_unix(const struct dentry *dentry,
75501 + const struct vfsmount *mnt);
75502 +void gr_acl_handle_exit(void);
75503 +void gr_acl_handle_psacct(struct task_struct *task, const long code);
75504 +int gr_acl_handle_procpidmem(const struct task_struct *task);
75505 +int gr_handle_rofs_mount(struct dentry *dentry, struct vfsmount *mnt, int mnt_flags);
75506 +int gr_handle_rofs_blockwrite(struct dentry *dentry, struct vfsmount *mnt, int acc_mode);
75507 +void gr_audit_ptrace(struct task_struct *task);
75508 +dev_t gr_get_dev_from_dentry(struct dentry *dentry);
75509 +void gr_put_exec_file(struct task_struct *task);
75510 +
75511 +int gr_ptrace_readexec(struct file *file, int unsafe_flags);
75512 +
75513 +#if defined(CONFIG_GRKERNSEC) && (defined(CONFIG_GRKERNSEC_RESLOG) || !defined(CONFIG_GRKERNSEC_NO_RBAC))
75514 +extern void gr_learn_resource(const struct task_struct *task, const int res,
75515 + const unsigned long wanted, const int gt);
75516 +#else
75517 +static inline void gr_learn_resource(const struct task_struct *task, const int res,
75518 + const unsigned long wanted, const int gt)
75519 +{
75520 +}
75521 +#endif
75522 +
75523 +#ifdef CONFIG_GRKERNSEC_RESLOG
75524 +extern void gr_log_resource(const struct task_struct *task, const int res,
75525 + const unsigned long wanted, const int gt);
75526 +#else
75527 +static inline void gr_log_resource(const struct task_struct *task, const int res,
75528 + const unsigned long wanted, const int gt)
75529 +{
75530 +}
75531 +#endif
75532 +
75533 +#ifdef CONFIG_GRKERNSEC
75534 +void task_grsec_rbac(struct seq_file *m, struct task_struct *p);
75535 +void gr_handle_vm86(void);
75536 +void gr_handle_mem_readwrite(u64 from, u64 to);
75537 +
75538 +void gr_log_badprocpid(const char *entry);
75539 +
75540 +extern int grsec_enable_dmesg;
75541 +extern int grsec_disable_privio;
75542 +
75543 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
75544 +extern kgid_t grsec_proc_gid;
75545 +#endif
75546 +
75547 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
75548 +extern int grsec_enable_chroot_findtask;
75549 +#endif
75550 +#ifdef CONFIG_GRKERNSEC_SETXID
75551 +extern int grsec_enable_setxid;
75552 +#endif
75553 +#endif
75554 +
75555 +#endif
75556 diff --git a/include/linux/grsock.h b/include/linux/grsock.h
75557 new file mode 100644
75558 index 0000000..e7ffaaf
75559 --- /dev/null
75560 +++ b/include/linux/grsock.h
75561 @@ -0,0 +1,19 @@
75562 +#ifndef __GRSOCK_H
75563 +#define __GRSOCK_H
75564 +
75565 +extern void gr_attach_curr_ip(const struct sock *sk);
75566 +extern int gr_handle_sock_all(const int family, const int type,
75567 + const int protocol);
75568 +extern int gr_handle_sock_server(const struct sockaddr *sck);
75569 +extern int gr_handle_sock_server_other(const struct sock *sck);
75570 +extern int gr_handle_sock_client(const struct sockaddr *sck);
75571 +extern int gr_search_connect(struct socket * sock,
75572 + struct sockaddr_in * addr);
75573 +extern int gr_search_bind(struct socket * sock,
75574 + struct sockaddr_in * addr);
75575 +extern int gr_search_listen(struct socket * sock);
75576 +extern int gr_search_accept(struct socket * sock);
75577 +extern int gr_search_socket(const int domain, const int type,
75578 + const int protocol);
75579 +
75580 +#endif
75581 diff --git a/include/linux/highmem.h b/include/linux/highmem.h
75582 index 7fb31da..08b5114 100644
75583 --- a/include/linux/highmem.h
75584 +++ b/include/linux/highmem.h
75585 @@ -189,6 +189,18 @@ static inline void clear_highpage(struct page *page)
75586 kunmap_atomic(kaddr);
75587 }
75588
75589 +static inline void sanitize_highpage(struct page *page)
75590 +{
75591 + void *kaddr;
75592 + unsigned long flags;
75593 +
75594 + local_irq_save(flags);
75595 + kaddr = kmap_atomic(page);
75596 + clear_page(kaddr);
75597 + kunmap_atomic(kaddr);
75598 + local_irq_restore(flags);
75599 +}
75600 +
75601 static inline void zero_user_segments(struct page *page,
75602 unsigned start1, unsigned end1,
75603 unsigned start2, unsigned end2)
75604 diff --git a/include/linux/hwmon-sysfs.h b/include/linux/hwmon-sysfs.h
75605 index 1c7b89a..7dda400 100644
75606 --- a/include/linux/hwmon-sysfs.h
75607 +++ b/include/linux/hwmon-sysfs.h
75608 @@ -25,7 +25,8 @@
75609 struct sensor_device_attribute{
75610 struct device_attribute dev_attr;
75611 int index;
75612 -};
75613 +} __do_const;
75614 +typedef struct sensor_device_attribute __no_const sensor_device_attribute_no_const;
75615 #define to_sensor_dev_attr(_dev_attr) \
75616 container_of(_dev_attr, struct sensor_device_attribute, dev_attr)
75617
75618 @@ -41,7 +42,8 @@ struct sensor_device_attribute_2 {
75619 struct device_attribute dev_attr;
75620 u8 index;
75621 u8 nr;
75622 -};
75623 +} __do_const;
75624 +typedef struct sensor_device_attribute_2 __no_const sensor_device_attribute_2_no_const;
75625 #define to_sensor_dev_attr_2(_dev_attr) \
75626 container_of(_dev_attr, struct sensor_device_attribute_2, dev_attr)
75627
75628 diff --git a/include/linux/i2c.h b/include/linux/i2c.h
75629 index 2ab11dc..663a3f2 100644
75630 --- a/include/linux/i2c.h
75631 +++ b/include/linux/i2c.h
75632 @@ -366,6 +366,7 @@ struct i2c_algorithm {
75633 /* To determine what the adapter supports */
75634 u32 (*functionality) (struct i2c_adapter *);
75635 };
75636 +typedef struct i2c_algorithm __no_const i2c_algorithm_no_const;
75637
75638 /**
75639 * struct i2c_bus_recovery_info - I2C bus recovery information
75640 diff --git a/include/linux/i2o.h b/include/linux/i2o.h
75641 index d23c3c2..eb63c81 100644
75642 --- a/include/linux/i2o.h
75643 +++ b/include/linux/i2o.h
75644 @@ -565,7 +565,7 @@ struct i2o_controller {
75645 struct i2o_device *exec; /* Executive */
75646 #if BITS_PER_LONG == 64
75647 spinlock_t context_list_lock; /* lock for context_list */
75648 - atomic_t context_list_counter; /* needed for unique contexts */
75649 + atomic_unchecked_t context_list_counter; /* needed for unique contexts */
75650 struct list_head context_list; /* list of context id's
75651 and pointers */
75652 #endif
75653 diff --git a/include/linux/if_pppox.h b/include/linux/if_pppox.h
75654 index aff7ad8..3942bbd 100644
75655 --- a/include/linux/if_pppox.h
75656 +++ b/include/linux/if_pppox.h
75657 @@ -76,7 +76,7 @@ struct pppox_proto {
75658 int (*ioctl)(struct socket *sock, unsigned int cmd,
75659 unsigned long arg);
75660 struct module *owner;
75661 -};
75662 +} __do_const;
75663
75664 extern int register_pppox_proto(int proto_num, const struct pppox_proto *pp);
75665 extern void unregister_pppox_proto(int proto_num);
75666 diff --git a/include/linux/init.h b/include/linux/init.h
75667 index f1c27a71..7d6010e 100644
75668 --- a/include/linux/init.h
75669 +++ b/include/linux/init.h
75670 @@ -39,9 +39,17 @@
75671 * Also note, that this data cannot be "const".
75672 */
75673
75674 +#define add_init_latent_entropy __latent_entropy
75675 +
75676 +#ifdef CONFIG_MEMORY_HOTPLUG
75677 +#define add_meminit_latent_entropy
75678 +#else
75679 +#define add_meminit_latent_entropy __latent_entropy
75680 +#endif
75681 +
75682 /* These are for everybody (although not all archs will actually
75683 discard it in modules) */
75684 -#define __init __section(.init.text) __cold notrace
75685 +#define __init __section(.init.text) __cold notrace add_init_latent_entropy
75686 #define __initdata __section(.init.data)
75687 #define __initconst __constsection(.init.rodata)
75688 #define __exitdata __section(.exit.data)
75689 @@ -102,7 +110,7 @@
75690 #define __cpuexitconst
75691
75692 /* Used for MEMORY_HOTPLUG */
75693 -#define __meminit __section(.meminit.text) __cold notrace
75694 +#define __meminit __section(.meminit.text) __cold notrace add_meminit_latent_entropy
75695 #define __meminitdata __section(.meminit.data)
75696 #define __meminitconst __constsection(.meminit.rodata)
75697 #define __memexit __section(.memexit.text) __exitused __cold notrace
75698 diff --git a/include/linux/init_task.h b/include/linux/init_task.h
75699 index 5cd0f09..c9f67cc 100644
75700 --- a/include/linux/init_task.h
75701 +++ b/include/linux/init_task.h
75702 @@ -154,6 +154,12 @@ extern struct task_group root_task_group;
75703
75704 #define INIT_TASK_COMM "swapper"
75705
75706 +#ifdef CONFIG_X86
75707 +#define INIT_TASK_THREAD_INFO .tinfo = INIT_THREAD_INFO,
75708 +#else
75709 +#define INIT_TASK_THREAD_INFO
75710 +#endif
75711 +
75712 /*
75713 * INIT_TASK is used to set up the first task table, touch at
75714 * your own risk!. Base=0, limit=0x1fffff (=2MB)
75715 @@ -193,6 +199,7 @@ extern struct task_group root_task_group;
75716 RCU_POINTER_INITIALIZER(cred, &init_cred), \
75717 .comm = INIT_TASK_COMM, \
75718 .thread = INIT_THREAD, \
75719 + INIT_TASK_THREAD_INFO \
75720 .fs = &init_fs, \
75721 .files = &init_files, \
75722 .signal = &init_signals, \
75723 diff --git a/include/linux/interrupt.h b/include/linux/interrupt.h
75724 index 5e865b5..71bd258 100644
75725 --- a/include/linux/interrupt.h
75726 +++ b/include/linux/interrupt.h
75727 @@ -361,7 +361,7 @@ enum
75728 /* map softirq index to softirq name. update 'softirq_to_name' in
75729 * kernel/softirq.c when adding a new softirq.
75730 */
75731 -extern char *softirq_to_name[NR_SOFTIRQS];
75732 +extern const char * const softirq_to_name[NR_SOFTIRQS];
75733
75734 /* softirq mask and active fields moved to irq_cpustat_t in
75735 * asm/hardirq.h to get better cache usage. KAO
75736 @@ -369,12 +369,12 @@ extern char *softirq_to_name[NR_SOFTIRQS];
75737
75738 struct softirq_action
75739 {
75740 - void (*action)(struct softirq_action *);
75741 -};
75742 + void (*action)(void);
75743 +} __no_const;
75744
75745 asmlinkage void do_softirq(void);
75746 asmlinkage void __do_softirq(void);
75747 -extern void open_softirq(int nr, void (*action)(struct softirq_action *));
75748 +extern void open_softirq(int nr, void (*action)(void));
75749 extern void softirq_init(void);
75750 extern void __raise_softirq_irqoff(unsigned int nr);
75751
75752 diff --git a/include/linux/iommu.h b/include/linux/iommu.h
75753 index 7ea319e..f9e971d 100644
75754 --- a/include/linux/iommu.h
75755 +++ b/include/linux/iommu.h
75756 @@ -129,7 +129,7 @@ struct iommu_ops {
75757 u32 (*domain_get_windows)(struct iommu_domain *domain);
75758
75759 unsigned long pgsize_bitmap;
75760 -};
75761 +} __do_const;
75762
75763 #define IOMMU_GROUP_NOTIFY_ADD_DEVICE 1 /* Device added */
75764 #define IOMMU_GROUP_NOTIFY_DEL_DEVICE 2 /* Pre Device removed */
75765 diff --git a/include/linux/ioport.h b/include/linux/ioport.h
75766 index 89b7c24..382af74 100644
75767 --- a/include/linux/ioport.h
75768 +++ b/include/linux/ioport.h
75769 @@ -161,7 +161,7 @@ struct resource *lookup_resource(struct resource *root, resource_size_t start);
75770 int adjust_resource(struct resource *res, resource_size_t start,
75771 resource_size_t size);
75772 resource_size_t resource_alignment(struct resource *res);
75773 -static inline resource_size_t resource_size(const struct resource *res)
75774 +static inline resource_size_t __intentional_overflow(-1) resource_size(const struct resource *res)
75775 {
75776 return res->end - res->start + 1;
75777 }
75778 diff --git a/include/linux/irq.h b/include/linux/irq.h
75779 index 56bb0dc..8ae94d62 100644
75780 --- a/include/linux/irq.h
75781 +++ b/include/linux/irq.h
75782 @@ -333,7 +333,8 @@ struct irq_chip {
75783 void (*irq_print_chip)(struct irq_data *data, struct seq_file *p);
75784
75785 unsigned long flags;
75786 -};
75787 +} __do_const;
75788 +typedef struct irq_chip __no_const irq_chip_no_const;
75789
75790 /*
75791 * irq_chip specific flags
75792 diff --git a/include/linux/irqchip/arm-gic.h b/include/linux/irqchip/arm-gic.h
75793 index 0e5d9ec..46acb3a 100644
75794 --- a/include/linux/irqchip/arm-gic.h
75795 +++ b/include/linux/irqchip/arm-gic.h
75796 @@ -59,9 +59,11 @@
75797
75798 #ifndef __ASSEMBLY__
75799
75800 +#include <linux/irq.h>
75801 +
75802 struct device_node;
75803
75804 -extern struct irq_chip gic_arch_extn;
75805 +extern irq_chip_no_const gic_arch_extn;
75806
75807 void gic_init_bases(unsigned int, int, void __iomem *, void __iomem *,
75808 u32 offset, struct device_node *);
75809 diff --git a/include/linux/jiffies.h b/include/linux/jiffies.h
75810 index d235e88..8ccbe74 100644
75811 --- a/include/linux/jiffies.h
75812 +++ b/include/linux/jiffies.h
75813 @@ -292,14 +292,14 @@ extern unsigned long preset_lpj;
75814 /*
75815 * Convert various time units to each other:
75816 */
75817 -extern unsigned int jiffies_to_msecs(const unsigned long j);
75818 -extern unsigned int jiffies_to_usecs(const unsigned long j);
75819 -extern unsigned long msecs_to_jiffies(const unsigned int m);
75820 -extern unsigned long usecs_to_jiffies(const unsigned int u);
75821 -extern unsigned long timespec_to_jiffies(const struct timespec *value);
75822 +extern unsigned int jiffies_to_msecs(const unsigned long j) __intentional_overflow(-1);
75823 +extern unsigned int jiffies_to_usecs(const unsigned long j) __intentional_overflow(-1);
75824 +extern unsigned long msecs_to_jiffies(const unsigned int m) __intentional_overflow(-1);
75825 +extern unsigned long usecs_to_jiffies(const unsigned int u) __intentional_overflow(-1);
75826 +extern unsigned long timespec_to_jiffies(const struct timespec *value) __intentional_overflow(-1);
75827 extern void jiffies_to_timespec(const unsigned long jiffies,
75828 struct timespec *value);
75829 -extern unsigned long timeval_to_jiffies(const struct timeval *value);
75830 +extern unsigned long timeval_to_jiffies(const struct timeval *value) __intentional_overflow(-1);
75831 extern void jiffies_to_timeval(const unsigned long jiffies,
75832 struct timeval *value);
75833
75834 diff --git a/include/linux/kallsyms.h b/include/linux/kallsyms.h
75835 index 6883e19..e854fcb 100644
75836 --- a/include/linux/kallsyms.h
75837 +++ b/include/linux/kallsyms.h
75838 @@ -15,7 +15,8 @@
75839
75840 struct module;
75841
75842 -#ifdef CONFIG_KALLSYMS
75843 +#if !defined(__INCLUDED_BY_HIDESYM) || !defined(CONFIG_KALLSYMS)
75844 +#if defined(CONFIG_KALLSYMS) && !defined(CONFIG_GRKERNSEC_HIDESYM)
75845 /* Lookup the address for a symbol. Returns 0 if not found. */
75846 unsigned long kallsyms_lookup_name(const char *name);
75847
75848 @@ -106,6 +107,21 @@ static inline int lookup_symbol_attrs(unsigned long addr, unsigned long *size, u
75849 /* Stupid that this does nothing, but I didn't create this mess. */
75850 #define __print_symbol(fmt, addr)
75851 #endif /*CONFIG_KALLSYMS*/
75852 +#else /* when included by kallsyms.c, vsnprintf.c, kprobes.c, or
75853 + arch/x86/kernel/dumpstack.c, with HIDESYM enabled */
75854 +extern unsigned long kallsyms_lookup_name(const char *name);
75855 +extern void __print_symbol(const char *fmt, unsigned long address);
75856 +extern int sprint_backtrace(char *buffer, unsigned long address);
75857 +extern int sprint_symbol(char *buffer, unsigned long address);
75858 +extern int sprint_symbol_no_offset(char *buffer, unsigned long address);
75859 +const char *kallsyms_lookup(unsigned long addr,
75860 + unsigned long *symbolsize,
75861 + unsigned long *offset,
75862 + char **modname, char *namebuf);
75863 +extern int kallsyms_lookup_size_offset(unsigned long addr,
75864 + unsigned long *symbolsize,
75865 + unsigned long *offset);
75866 +#endif
75867
75868 /* This macro allows us to keep printk typechecking */
75869 static __printf(1, 2)
75870 diff --git a/include/linux/key-type.h b/include/linux/key-type.h
75871 index 518a53a..5e28358 100644
75872 --- a/include/linux/key-type.h
75873 +++ b/include/linux/key-type.h
75874 @@ -125,7 +125,7 @@ struct key_type {
75875 /* internal fields */
75876 struct list_head link; /* link in types list */
75877 struct lock_class_key lock_class; /* key->sem lock class */
75878 -};
75879 +} __do_const;
75880
75881 extern struct key_type key_type_keyring;
75882
75883 diff --git a/include/linux/kgdb.h b/include/linux/kgdb.h
75884 index c6e091b..a940adf 100644
75885 --- a/include/linux/kgdb.h
75886 +++ b/include/linux/kgdb.h
75887 @@ -52,7 +52,7 @@ extern int kgdb_connected;
75888 extern int kgdb_io_module_registered;
75889
75890 extern atomic_t kgdb_setting_breakpoint;
75891 -extern atomic_t kgdb_cpu_doing_single_step;
75892 +extern atomic_unchecked_t kgdb_cpu_doing_single_step;
75893
75894 extern struct task_struct *kgdb_usethread;
75895 extern struct task_struct *kgdb_contthread;
75896 @@ -254,7 +254,7 @@ struct kgdb_arch {
75897 void (*correct_hw_break)(void);
75898
75899 void (*enable_nmi)(bool on);
75900 -};
75901 +} __do_const;
75902
75903 /**
75904 * struct kgdb_io - Describe the interface for an I/O driver to talk with KGDB.
75905 @@ -279,7 +279,7 @@ struct kgdb_io {
75906 void (*pre_exception) (void);
75907 void (*post_exception) (void);
75908 int is_console;
75909 -};
75910 +} __do_const;
75911
75912 extern struct kgdb_arch arch_kgdb_ops;
75913
75914 diff --git a/include/linux/kmod.h b/include/linux/kmod.h
75915 index 0555cc6..40116ce 100644
75916 --- a/include/linux/kmod.h
75917 +++ b/include/linux/kmod.h
75918 @@ -34,6 +34,8 @@ extern char modprobe_path[]; /* for sysctl */
75919 * usually useless though. */
75920 extern __printf(2, 3)
75921 int __request_module(bool wait, const char *name, ...);
75922 +extern __printf(3, 4)
75923 +int ___request_module(bool wait, char *param_name, const char *name, ...);
75924 #define request_module(mod...) __request_module(true, mod)
75925 #define request_module_nowait(mod...) __request_module(false, mod)
75926 #define try_then_request_module(x, mod...) \
75927 @@ -57,6 +59,9 @@ struct subprocess_info {
75928 struct work_struct work;
75929 struct completion *complete;
75930 char *path;
75931 +#ifdef CONFIG_GRKERNSEC
75932 + char *origpath;
75933 +#endif
75934 char **argv;
75935 char **envp;
75936 int wait;
75937 diff --git a/include/linux/kobject.h b/include/linux/kobject.h
75938 index de6dcbcc..4735f88 100644
75939 --- a/include/linux/kobject.h
75940 +++ b/include/linux/kobject.h
75941 @@ -115,7 +115,7 @@ struct kobj_type {
75942 struct attribute **default_attrs;
75943 const struct kobj_ns_type_operations *(*child_ns_type)(struct kobject *kobj);
75944 const void *(*namespace)(struct kobject *kobj);
75945 -};
75946 +} __do_const;
75947
75948 struct kobj_uevent_env {
75949 char *envp[UEVENT_NUM_ENVP];
75950 @@ -138,6 +138,7 @@ struct kobj_attribute {
75951 ssize_t (*store)(struct kobject *kobj, struct kobj_attribute *attr,
75952 const char *buf, size_t count);
75953 };
75954 +typedef struct kobj_attribute __no_const kobj_attribute_no_const;
75955
75956 extern const struct sysfs_ops kobj_sysfs_ops;
75957
75958 diff --git a/include/linux/kobject_ns.h b/include/linux/kobject_ns.h
75959 index df32d25..fb52e27 100644
75960 --- a/include/linux/kobject_ns.h
75961 +++ b/include/linux/kobject_ns.h
75962 @@ -44,7 +44,7 @@ struct kobj_ns_type_operations {
75963 const void *(*netlink_ns)(struct sock *sk);
75964 const void *(*initial_ns)(void);
75965 void (*drop_ns)(void *);
75966 -};
75967 +} __do_const;
75968
75969 int kobj_ns_type_register(const struct kobj_ns_type_operations *ops);
75970 int kobj_ns_type_registered(enum kobj_ns_type type);
75971 diff --git a/include/linux/kref.h b/include/linux/kref.h
75972 index 484604d..0f6c5b6 100644
75973 --- a/include/linux/kref.h
75974 +++ b/include/linux/kref.h
75975 @@ -68,7 +68,7 @@ static inline void kref_get(struct kref *kref)
75976 static inline int kref_sub(struct kref *kref, unsigned int count,
75977 void (*release)(struct kref *kref))
75978 {
75979 - WARN_ON(release == NULL);
75980 + BUG_ON(release == NULL);
75981
75982 if (atomic_sub_and_test((int) count, &kref->refcount)) {
75983 release(kref);
75984 diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h
75985 index 0fbbc7a..db081e3 100644
75986 --- a/include/linux/kvm_host.h
75987 +++ b/include/linux/kvm_host.h
75988 @@ -458,7 +458,7 @@ static inline void kvm_irqfd_exit(void)
75989 {
75990 }
75991 #endif
75992 -int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align,
75993 +int kvm_init(const void *opaque, unsigned vcpu_size, unsigned vcpu_align,
75994 struct module *module);
75995 void kvm_exit(void);
75996
75997 @@ -632,7 +632,7 @@ int kvm_arch_vcpu_ioctl_set_guest_debug(struct kvm_vcpu *vcpu,
75998 struct kvm_guest_debug *dbg);
75999 int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run);
76000
76001 -int kvm_arch_init(void *opaque);
76002 +int kvm_arch_init(const void *opaque);
76003 void kvm_arch_exit(void);
76004
76005 int kvm_arch_vcpu_init(struct kvm_vcpu *vcpu);
76006 diff --git a/include/linux/libata.h b/include/linux/libata.h
76007 index 0e23c26..6ad8c33 100644
76008 --- a/include/linux/libata.h
76009 +++ b/include/linux/libata.h
76010 @@ -972,7 +972,7 @@ struct ata_port_operations {
76011 * fields must be pointers.
76012 */
76013 const struct ata_port_operations *inherits;
76014 -};
76015 +} __do_const;
76016
76017 struct ata_port_info {
76018 unsigned long flags;
76019 diff --git a/include/linux/linkage.h b/include/linux/linkage.h
76020 index d3e8ad2..a949f68 100644
76021 --- a/include/linux/linkage.h
76022 +++ b/include/linux/linkage.h
76023 @@ -31,6 +31,7 @@
76024 #endif
76025
76026 #define __page_aligned_data __section(.data..page_aligned) __aligned(PAGE_SIZE)
76027 +#define __page_aligned_rodata __read_only __aligned(PAGE_SIZE)
76028 #define __page_aligned_bss __section(.bss..page_aligned) __aligned(PAGE_SIZE)
76029
76030 /*
76031 diff --git a/include/linux/list.h b/include/linux/list.h
76032 index f4d8a2f..38e6e46 100644
76033 --- a/include/linux/list.h
76034 +++ b/include/linux/list.h
76035 @@ -112,6 +112,19 @@ extern void __list_del_entry(struct list_head *entry);
76036 extern void list_del(struct list_head *entry);
76037 #endif
76038
76039 +extern void __pax_list_add(struct list_head *new,
76040 + struct list_head *prev,
76041 + struct list_head *next);
76042 +static inline void pax_list_add(struct list_head *new, struct list_head *head)
76043 +{
76044 + __pax_list_add(new, head, head->next);
76045 +}
76046 +static inline void pax_list_add_tail(struct list_head *new, struct list_head *head)
76047 +{
76048 + __pax_list_add(new, head->prev, head);
76049 +}
76050 +extern void pax_list_del(struct list_head *entry);
76051 +
76052 /**
76053 * list_replace - replace old entry by new one
76054 * @old : the element to be replaced
76055 @@ -145,6 +158,8 @@ static inline void list_del_init(struct list_head *entry)
76056 INIT_LIST_HEAD(entry);
76057 }
76058
76059 +extern void pax_list_del_init(struct list_head *entry);
76060 +
76061 /**
76062 * list_move - delete from one list and add as another's head
76063 * @list: the entry to move
76064 diff --git a/include/linux/math64.h b/include/linux/math64.h
76065 index 69ed5f5..243ed51 100644
76066 --- a/include/linux/math64.h
76067 +++ b/include/linux/math64.h
76068 @@ -15,7 +15,7 @@
76069 * This is commonly provided by 32bit archs to provide an optimized 64bit
76070 * divide.
76071 */
76072 -static inline u64 div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
76073 +static inline u64 __intentional_overflow(-1) div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
76074 {
76075 *remainder = dividend % divisor;
76076 return dividend / divisor;
76077 @@ -42,7 +42,7 @@ static inline u64 div64_u64_rem(u64 dividend, u64 divisor, u64 *remainder)
76078 /**
76079 * div64_u64 - unsigned 64bit divide with 64bit divisor
76080 */
76081 -static inline u64 div64_u64(u64 dividend, u64 divisor)
76082 +static inline u64 __intentional_overflow(-1) div64_u64(u64 dividend, u64 divisor)
76083 {
76084 return dividend / divisor;
76085 }
76086 @@ -61,7 +61,7 @@ static inline s64 div64_s64(s64 dividend, s64 divisor)
76087 #define div64_ul(x, y) div_u64((x), (y))
76088
76089 #ifndef div_u64_rem
76090 -static inline u64 div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
76091 +static inline u64 __intentional_overflow(-1) div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
76092 {
76093 *remainder = do_div(dividend, divisor);
76094 return dividend;
76095 @@ -77,7 +77,7 @@ extern u64 div64_u64_rem(u64 dividend, u64 divisor, u64 *remainder);
76096 #endif
76097
76098 #ifndef div64_u64
76099 -extern u64 div64_u64(u64 dividend, u64 divisor);
76100 +extern u64 __intentional_overflow(-1) div64_u64(u64 dividend, u64 divisor);
76101 #endif
76102
76103 #ifndef div64_s64
76104 @@ -94,7 +94,7 @@ extern s64 div64_s64(s64 dividend, s64 divisor);
76105 * divide.
76106 */
76107 #ifndef div_u64
76108 -static inline u64 div_u64(u64 dividend, u32 divisor)
76109 +static inline u64 __intentional_overflow(-1) div_u64(u64 dividend, u32 divisor)
76110 {
76111 u32 remainder;
76112 return div_u64_rem(dividend, divisor, &remainder);
76113 diff --git a/include/linux/mempolicy.h b/include/linux/mempolicy.h
76114 index da6716b..2e31db3 100644
76115 --- a/include/linux/mempolicy.h
76116 +++ b/include/linux/mempolicy.h
76117 @@ -91,6 +91,10 @@ static inline struct mempolicy *mpol_dup(struct mempolicy *pol)
76118 }
76119
76120 #define vma_policy(vma) ((vma)->vm_policy)
76121 +static inline void set_vma_policy(struct vm_area_struct *vma, struct mempolicy *pol)
76122 +{
76123 + vma->vm_policy = pol;
76124 +}
76125
76126 static inline void mpol_get(struct mempolicy *pol)
76127 {
76128 @@ -240,6 +244,9 @@ mpol_shared_policy_lookup(struct shared_policy *sp, unsigned long idx)
76129 }
76130
76131 #define vma_policy(vma) NULL
76132 +static inline void set_vma_policy(struct vm_area_struct *vma, struct mempolicy *pol)
76133 +{
76134 +}
76135
76136 static inline int
76137 vma_dup_policy(struct vm_area_struct *src, struct vm_area_struct *dst)
76138 diff --git a/include/linux/mm.h b/include/linux/mm.h
76139 index 8b6e55e..c4edf39 100644
76140 --- a/include/linux/mm.h
76141 +++ b/include/linux/mm.h
76142 @@ -113,6 +113,11 @@ extern unsigned int kobjsize(const void *objp);
76143 #define VM_HUGETLB 0x00400000 /* Huge TLB Page VM */
76144 #define VM_NONLINEAR 0x00800000 /* Is non-linear (remap_file_pages) */
76145 #define VM_ARCH_1 0x01000000 /* Architecture-specific flag */
76146 +
76147 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_X86_32)
76148 +#define VM_PAGEEXEC 0x02000000 /* vma->vm_page_prot needs special handling */
76149 +#endif
76150 +
76151 #define VM_DONTDUMP 0x04000000 /* Do not include in the core dump */
76152
76153 #ifdef CONFIG_MEM_SOFT_DIRTY
76154 @@ -215,8 +220,8 @@ struct vm_operations_struct {
76155 /* called by access_process_vm when get_user_pages() fails, typically
76156 * for use by special VMAs that can switch between memory and hardware
76157 */
76158 - int (*access)(struct vm_area_struct *vma, unsigned long addr,
76159 - void *buf, int len, int write);
76160 + ssize_t (*access)(struct vm_area_struct *vma, unsigned long addr,
76161 + void *buf, size_t len, int write);
76162 #ifdef CONFIG_NUMA
76163 /*
76164 * set_policy() op must add a reference to any non-NULL @new mempolicy
76165 @@ -246,6 +251,7 @@ struct vm_operations_struct {
76166 int (*remap_pages)(struct vm_area_struct *vma, unsigned long addr,
76167 unsigned long size, pgoff_t pgoff);
76168 };
76169 +typedef struct vm_operations_struct __no_const vm_operations_struct_no_const;
76170
76171 struct mmu_gather;
76172 struct inode;
76173 @@ -977,8 +983,8 @@ int follow_pfn(struct vm_area_struct *vma, unsigned long address,
76174 unsigned long *pfn);
76175 int follow_phys(struct vm_area_struct *vma, unsigned long address,
76176 unsigned int flags, unsigned long *prot, resource_size_t *phys);
76177 -int generic_access_phys(struct vm_area_struct *vma, unsigned long addr,
76178 - void *buf, int len, int write);
76179 +ssize_t generic_access_phys(struct vm_area_struct *vma, unsigned long addr,
76180 + void *buf, size_t len, int write);
76181
76182 static inline void unmap_shared_mapping_range(struct address_space *mapping,
76183 loff_t const holebegin, loff_t const holelen)
76184 @@ -1017,9 +1023,9 @@ static inline int fixup_user_fault(struct task_struct *tsk,
76185 }
76186 #endif
76187
76188 -extern int access_process_vm(struct task_struct *tsk, unsigned long addr, void *buf, int len, int write);
76189 -extern int access_remote_vm(struct mm_struct *mm, unsigned long addr,
76190 - void *buf, int len, int write);
76191 +extern ssize_t access_process_vm(struct task_struct *tsk, unsigned long addr, void *buf, size_t len, int write);
76192 +extern ssize_t access_remote_vm(struct mm_struct *mm, unsigned long addr,
76193 + void *buf, size_t len, int write);
76194
76195 long __get_user_pages(struct task_struct *tsk, struct mm_struct *mm,
76196 unsigned long start, unsigned long nr_pages,
76197 @@ -1051,34 +1057,6 @@ int set_page_dirty(struct page *page);
76198 int set_page_dirty_lock(struct page *page);
76199 int clear_page_dirty_for_io(struct page *page);
76200
76201 -/* Is the vma a continuation of the stack vma above it? */
76202 -static inline int vma_growsdown(struct vm_area_struct *vma, unsigned long addr)
76203 -{
76204 - return vma && (vma->vm_end == addr) && (vma->vm_flags & VM_GROWSDOWN);
76205 -}
76206 -
76207 -static inline int stack_guard_page_start(struct vm_area_struct *vma,
76208 - unsigned long addr)
76209 -{
76210 - return (vma->vm_flags & VM_GROWSDOWN) &&
76211 - (vma->vm_start == addr) &&
76212 - !vma_growsdown(vma->vm_prev, addr);
76213 -}
76214 -
76215 -/* Is the vma a continuation of the stack vma below it? */
76216 -static inline int vma_growsup(struct vm_area_struct *vma, unsigned long addr)
76217 -{
76218 - return vma && (vma->vm_start == addr) && (vma->vm_flags & VM_GROWSUP);
76219 -}
76220 -
76221 -static inline int stack_guard_page_end(struct vm_area_struct *vma,
76222 - unsigned long addr)
76223 -{
76224 - return (vma->vm_flags & VM_GROWSUP) &&
76225 - (vma->vm_end == addr) &&
76226 - !vma_growsup(vma->vm_next, addr);
76227 -}
76228 -
76229 extern pid_t
76230 vm_is_stack(struct task_struct *task, struct vm_area_struct *vma, int in_group);
76231
76232 @@ -1178,6 +1156,15 @@ static inline void sync_mm_rss(struct mm_struct *mm)
76233 }
76234 #endif
76235
76236 +#ifdef CONFIG_MMU
76237 +pgprot_t vm_get_page_prot(vm_flags_t vm_flags);
76238 +#else
76239 +static inline pgprot_t vm_get_page_prot(vm_flags_t vm_flags)
76240 +{
76241 + return __pgprot(0);
76242 +}
76243 +#endif
76244 +
76245 int vma_wants_writenotify(struct vm_area_struct *vma);
76246
76247 extern pte_t *__get_locked_pte(struct mm_struct *mm, unsigned long addr,
76248 @@ -1196,8 +1183,15 @@ static inline int __pud_alloc(struct mm_struct *mm, pgd_t *pgd,
76249 {
76250 return 0;
76251 }
76252 +
76253 +static inline int __pud_alloc_kernel(struct mm_struct *mm, pgd_t *pgd,
76254 + unsigned long address)
76255 +{
76256 + return 0;
76257 +}
76258 #else
76259 int __pud_alloc(struct mm_struct *mm, pgd_t *pgd, unsigned long address);
76260 +int __pud_alloc_kernel(struct mm_struct *mm, pgd_t *pgd, unsigned long address);
76261 #endif
76262
76263 #ifdef __PAGETABLE_PMD_FOLDED
76264 @@ -1206,8 +1200,15 @@ static inline int __pmd_alloc(struct mm_struct *mm, pud_t *pud,
76265 {
76266 return 0;
76267 }
76268 +
76269 +static inline int __pmd_alloc_kernel(struct mm_struct *mm, pud_t *pud,
76270 + unsigned long address)
76271 +{
76272 + return 0;
76273 +}
76274 #else
76275 int __pmd_alloc(struct mm_struct *mm, pud_t *pud, unsigned long address);
76276 +int __pmd_alloc_kernel(struct mm_struct *mm, pud_t *pud, unsigned long address);
76277 #endif
76278
76279 int __pte_alloc(struct mm_struct *mm, struct vm_area_struct *vma,
76280 @@ -1225,11 +1226,23 @@ static inline pud_t *pud_alloc(struct mm_struct *mm, pgd_t *pgd, unsigned long a
76281 NULL: pud_offset(pgd, address);
76282 }
76283
76284 +static inline pud_t *pud_alloc_kernel(struct mm_struct *mm, pgd_t *pgd, unsigned long address)
76285 +{
76286 + return (unlikely(pgd_none(*pgd)) && __pud_alloc_kernel(mm, pgd, address))?
76287 + NULL: pud_offset(pgd, address);
76288 +}
76289 +
76290 static inline pmd_t *pmd_alloc(struct mm_struct *mm, pud_t *pud, unsigned long address)
76291 {
76292 return (unlikely(pud_none(*pud)) && __pmd_alloc(mm, pud, address))?
76293 NULL: pmd_offset(pud, address);
76294 }
76295 +
76296 +static inline pmd_t *pmd_alloc_kernel(struct mm_struct *mm, pud_t *pud, unsigned long address)
76297 +{
76298 + return (unlikely(pud_none(*pud)) && __pmd_alloc_kernel(mm, pud, address))?
76299 + NULL: pmd_offset(pud, address);
76300 +}
76301 #endif /* CONFIG_MMU && !__ARCH_HAS_4LEVEL_HACK */
76302
76303 #if USE_SPLIT_PTLOCKS
76304 @@ -1517,7 +1530,7 @@ extern int install_special_mapping(struct mm_struct *mm,
76305 unsigned long addr, unsigned long len,
76306 unsigned long flags, struct page **pages);
76307
76308 -extern unsigned long get_unmapped_area(struct file *, unsigned long, unsigned long, unsigned long, unsigned long);
76309 +extern unsigned long get_unmapped_area(struct file *, unsigned long, unsigned long, unsigned long, unsigned long) __intentional_overflow(-1);
76310
76311 extern unsigned long mmap_region(struct file *file, unsigned long addr,
76312 unsigned long len, vm_flags_t vm_flags, unsigned long pgoff);
76313 @@ -1525,6 +1538,7 @@ extern unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
76314 unsigned long len, unsigned long prot, unsigned long flags,
76315 unsigned long pgoff, unsigned long *populate);
76316 extern int do_munmap(struct mm_struct *, unsigned long, size_t);
76317 +extern int __do_munmap(struct mm_struct *, unsigned long, size_t);
76318
76319 #ifdef CONFIG_MMU
76320 extern int __mm_populate(unsigned long addr, unsigned long len,
76321 @@ -1553,10 +1567,11 @@ struct vm_unmapped_area_info {
76322 unsigned long high_limit;
76323 unsigned long align_mask;
76324 unsigned long align_offset;
76325 + unsigned long threadstack_offset;
76326 };
76327
76328 -extern unsigned long unmapped_area(struct vm_unmapped_area_info *info);
76329 -extern unsigned long unmapped_area_topdown(struct vm_unmapped_area_info *info);
76330 +extern unsigned long unmapped_area(const struct vm_unmapped_area_info *info);
76331 +extern unsigned long unmapped_area_topdown(const struct vm_unmapped_area_info *info);
76332
76333 /*
76334 * Search for an unmapped address range.
76335 @@ -1568,7 +1583,7 @@ extern unsigned long unmapped_area_topdown(struct vm_unmapped_area_info *info);
76336 * - satisfies (begin_addr & align_mask) == (align_offset & align_mask)
76337 */
76338 static inline unsigned long
76339 -vm_unmapped_area(struct vm_unmapped_area_info *info)
76340 +vm_unmapped_area(const struct vm_unmapped_area_info *info)
76341 {
76342 if (!(info->flags & VM_UNMAPPED_AREA_TOPDOWN))
76343 return unmapped_area(info);
76344 @@ -1631,6 +1646,10 @@ extern struct vm_area_struct * find_vma(struct mm_struct * mm, unsigned long add
76345 extern struct vm_area_struct * find_vma_prev(struct mm_struct * mm, unsigned long addr,
76346 struct vm_area_struct **pprev);
76347
76348 +extern struct vm_area_struct *pax_find_mirror_vma(struct vm_area_struct *vma);
76349 +extern __must_check long pax_mirror_vma(struct vm_area_struct *vma_m, struct vm_area_struct *vma);
76350 +extern void pax_mirror_file_pte(struct vm_area_struct *vma, unsigned long address, struct page *page_m, spinlock_t *ptl);
76351 +
76352 /* Look up the first VMA which intersects the interval start_addr..end_addr-1,
76353 NULL if none. Assume start_addr < end_addr. */
76354 static inline struct vm_area_struct * find_vma_intersection(struct mm_struct * mm, unsigned long start_addr, unsigned long end_addr)
76355 @@ -1659,15 +1678,6 @@ static inline struct vm_area_struct *find_exact_vma(struct mm_struct *mm,
76356 return vma;
76357 }
76358
76359 -#ifdef CONFIG_MMU
76360 -pgprot_t vm_get_page_prot(unsigned long vm_flags);
76361 -#else
76362 -static inline pgprot_t vm_get_page_prot(unsigned long vm_flags)
76363 -{
76364 - return __pgprot(0);
76365 -}
76366 -#endif
76367 -
76368 #ifdef CONFIG_ARCH_USES_NUMA_PROT_NONE
76369 unsigned long change_prot_numa(struct vm_area_struct *vma,
76370 unsigned long start, unsigned long end);
76371 @@ -1719,6 +1729,11 @@ void vm_stat_account(struct mm_struct *, unsigned long, struct file *, long);
76372 static inline void vm_stat_account(struct mm_struct *mm,
76373 unsigned long flags, struct file *file, long pages)
76374 {
76375 +
76376 +#ifdef CONFIG_PAX_RANDMMAP
76377 + if (!(mm->pax_flags & MF_PAX_RANDMMAP) || (flags & (VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)))
76378 +#endif
76379 +
76380 mm->total_vm += pages;
76381 }
76382 #endif /* CONFIG_PROC_FS */
76383 @@ -1800,7 +1815,7 @@ extern int unpoison_memory(unsigned long pfn);
76384 extern int sysctl_memory_failure_early_kill;
76385 extern int sysctl_memory_failure_recovery;
76386 extern void shake_page(struct page *p, int access);
76387 -extern atomic_long_t num_poisoned_pages;
76388 +extern atomic_long_unchecked_t num_poisoned_pages;
76389 extern int soft_offline_page(struct page *page, int flags);
76390
76391 extern void dump_page(struct page *page);
76392 @@ -1837,5 +1852,11 @@ void __init setup_nr_node_ids(void);
76393 static inline void setup_nr_node_ids(void) {}
76394 #endif
76395
76396 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
76397 +extern void track_exec_limit(struct mm_struct *mm, unsigned long start, unsigned long end, unsigned long prot);
76398 +#else
76399 +static inline void track_exec_limit(struct mm_struct *mm, unsigned long start, unsigned long end, unsigned long prot) {}
76400 +#endif
76401 +
76402 #endif /* __KERNEL__ */
76403 #endif /* _LINUX_MM_H */
76404 diff --git a/include/linux/mm_types.h b/include/linux/mm_types.h
76405 index d9851ee..619492d 100644
76406 --- a/include/linux/mm_types.h
76407 +++ b/include/linux/mm_types.h
76408 @@ -289,6 +289,8 @@ struct vm_area_struct {
76409 #ifdef CONFIG_NUMA
76410 struct mempolicy *vm_policy; /* NUMA policy for the VMA */
76411 #endif
76412 +
76413 + struct vm_area_struct *vm_mirror;/* PaX: mirror vma or NULL */
76414 };
76415
76416 struct core_thread {
76417 @@ -436,6 +438,24 @@ struct mm_struct {
76418 int first_nid;
76419 #endif
76420 struct uprobes_state uprobes_state;
76421 +
76422 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
76423 + unsigned long pax_flags;
76424 +#endif
76425 +
76426 +#ifdef CONFIG_PAX_DLRESOLVE
76427 + unsigned long call_dl_resolve;
76428 +#endif
76429 +
76430 +#if defined(CONFIG_PPC32) && defined(CONFIG_PAX_EMUSIGRT)
76431 + unsigned long call_syscall;
76432 +#endif
76433 +
76434 +#ifdef CONFIG_PAX_ASLR
76435 + unsigned long delta_mmap; /* randomized offset */
76436 + unsigned long delta_stack; /* randomized offset */
76437 +#endif
76438 +
76439 };
76440
76441 /* first nid will either be a valid NID or one of these values */
76442 diff --git a/include/linux/mmiotrace.h b/include/linux/mmiotrace.h
76443 index c5d5278..f0b68c8 100644
76444 --- a/include/linux/mmiotrace.h
76445 +++ b/include/linux/mmiotrace.h
76446 @@ -46,7 +46,7 @@ extern int kmmio_handler(struct pt_regs *regs, unsigned long addr);
76447 /* Called from ioremap.c */
76448 extern void mmiotrace_ioremap(resource_size_t offset, unsigned long size,
76449 void __iomem *addr);
76450 -extern void mmiotrace_iounmap(volatile void __iomem *addr);
76451 +extern void mmiotrace_iounmap(const volatile void __iomem *addr);
76452
76453 /* For anyone to insert markers. Remember trailing newline. */
76454 extern __printf(1, 2) int mmiotrace_printk(const char *fmt, ...);
76455 @@ -66,7 +66,7 @@ static inline void mmiotrace_ioremap(resource_size_t offset,
76456 {
76457 }
76458
76459 -static inline void mmiotrace_iounmap(volatile void __iomem *addr)
76460 +static inline void mmiotrace_iounmap(const volatile void __iomem *addr)
76461 {
76462 }
76463
76464 diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h
76465 index bd791e4..8617c34f 100644
76466 --- a/include/linux/mmzone.h
76467 +++ b/include/linux/mmzone.h
76468 @@ -396,7 +396,7 @@ struct zone {
76469 unsigned long flags; /* zone flags, see below */
76470
76471 /* Zone statistics */
76472 - atomic_long_t vm_stat[NR_VM_ZONE_STAT_ITEMS];
76473 + atomic_long_unchecked_t vm_stat[NR_VM_ZONE_STAT_ITEMS];
76474
76475 /*
76476 * The target ratio of ACTIVE_ANON to INACTIVE_ANON pages on
76477 diff --git a/include/linux/mod_devicetable.h b/include/linux/mod_devicetable.h
76478 index 45e9214..a7227d6 100644
76479 --- a/include/linux/mod_devicetable.h
76480 +++ b/include/linux/mod_devicetable.h
76481 @@ -13,7 +13,7 @@
76482 typedef unsigned long kernel_ulong_t;
76483 #endif
76484
76485 -#define PCI_ANY_ID (~0)
76486 +#define PCI_ANY_ID ((__u16)~0)
76487
76488 struct pci_device_id {
76489 __u32 vendor, device; /* Vendor and device ID or PCI_ANY_ID*/
76490 @@ -139,7 +139,7 @@ struct usb_device_id {
76491 #define USB_DEVICE_ID_MATCH_INT_PROTOCOL 0x0200
76492 #define USB_DEVICE_ID_MATCH_INT_NUMBER 0x0400
76493
76494 -#define HID_ANY_ID (~0)
76495 +#define HID_ANY_ID (~0U)
76496 #define HID_BUS_ANY 0xffff
76497 #define HID_GROUP_ANY 0x0000
76498
76499 @@ -467,7 +467,7 @@ struct dmi_system_id {
76500 const char *ident;
76501 struct dmi_strmatch matches[4];
76502 void *driver_data;
76503 -};
76504 +} __do_const;
76505 /*
76506 * struct dmi_device_id appears during expansion of
76507 * "MODULE_DEVICE_TABLE(dmi, x)". Compiler doesn't look inside it
76508 diff --git a/include/linux/module.h b/include/linux/module.h
76509 index 05f2447..2aee07c 100644
76510 --- a/include/linux/module.h
76511 +++ b/include/linux/module.h
76512 @@ -17,9 +17,11 @@
76513 #include <linux/moduleparam.h>
76514 #include <linux/tracepoint.h>
76515 #include <linux/export.h>
76516 +#include <linux/fs.h>
76517
76518 #include <linux/percpu.h>
76519 #include <asm/module.h>
76520 +#include <asm/pgtable.h>
76521
76522 /* In stripped ARM and x86-64 modules, ~ is surprisingly rare. */
76523 #define MODULE_SIG_STRING "~Module signature appended~\n"
76524 @@ -55,12 +57,13 @@ struct module_attribute {
76525 int (*test)(struct module *);
76526 void (*free)(struct module *);
76527 };
76528 +typedef struct module_attribute __no_const module_attribute_no_const;
76529
76530 struct module_version_attribute {
76531 struct module_attribute mattr;
76532 const char *module_name;
76533 const char *version;
76534 -} __attribute__ ((__aligned__(sizeof(void *))));
76535 +} __do_const __attribute__ ((__aligned__(sizeof(void *))));
76536
76537 extern ssize_t __modver_version_show(struct module_attribute *,
76538 struct module_kobject *, char *);
76539 @@ -238,7 +241,7 @@ struct module
76540
76541 /* Sysfs stuff. */
76542 struct module_kobject mkobj;
76543 - struct module_attribute *modinfo_attrs;
76544 + module_attribute_no_const *modinfo_attrs;
76545 const char *version;
76546 const char *srcversion;
76547 struct kobject *holders_dir;
76548 @@ -287,19 +290,16 @@ struct module
76549 int (*init)(void);
76550
76551 /* If this is non-NULL, vfree after init() returns */
76552 - void *module_init;
76553 + void *module_init_rx, *module_init_rw;
76554
76555 /* Here is the actual code + data, vfree'd on unload. */
76556 - void *module_core;
76557 + void *module_core_rx, *module_core_rw;
76558
76559 /* Here are the sizes of the init and core sections */
76560 - unsigned int init_size, core_size;
76561 + unsigned int init_size_rw, core_size_rw;
76562
76563 /* The size of the executable code in each section. */
76564 - unsigned int init_text_size, core_text_size;
76565 -
76566 - /* Size of RO sections of the module (text+rodata) */
76567 - unsigned int init_ro_size, core_ro_size;
76568 + unsigned int init_size_rx, core_size_rx;
76569
76570 /* Arch-specific module values */
76571 struct mod_arch_specific arch;
76572 @@ -355,6 +355,10 @@ struct module
76573 #ifdef CONFIG_EVENT_TRACING
76574 struct ftrace_event_call **trace_events;
76575 unsigned int num_trace_events;
76576 + struct file_operations trace_id;
76577 + struct file_operations trace_enable;
76578 + struct file_operations trace_format;
76579 + struct file_operations trace_filter;
76580 #endif
76581 #ifdef CONFIG_FTRACE_MCOUNT_RECORD
76582 unsigned int num_ftrace_callsites;
76583 @@ -402,16 +406,46 @@ bool is_module_address(unsigned long addr);
76584 bool is_module_percpu_address(unsigned long addr);
76585 bool is_module_text_address(unsigned long addr);
76586
76587 +static inline int within_module_range(unsigned long addr, void *start, unsigned long size)
76588 +{
76589 +
76590 +#ifdef CONFIG_PAX_KERNEXEC
76591 + if (ktla_ktva(addr) >= (unsigned long)start &&
76592 + ktla_ktva(addr) < (unsigned long)start + size)
76593 + return 1;
76594 +#endif
76595 +
76596 + return ((void *)addr >= start && (void *)addr < start + size);
76597 +}
76598 +
76599 +static inline int within_module_core_rx(unsigned long addr, const struct module *mod)
76600 +{
76601 + return within_module_range(addr, mod->module_core_rx, mod->core_size_rx);
76602 +}
76603 +
76604 +static inline int within_module_core_rw(unsigned long addr, const struct module *mod)
76605 +{
76606 + return within_module_range(addr, mod->module_core_rw, mod->core_size_rw);
76607 +}
76608 +
76609 +static inline int within_module_init_rx(unsigned long addr, const struct module *mod)
76610 +{
76611 + return within_module_range(addr, mod->module_init_rx, mod->init_size_rx);
76612 +}
76613 +
76614 +static inline int within_module_init_rw(unsigned long addr, const struct module *mod)
76615 +{
76616 + return within_module_range(addr, mod->module_init_rw, mod->init_size_rw);
76617 +}
76618 +
76619 static inline int within_module_core(unsigned long addr, const struct module *mod)
76620 {
76621 - return (unsigned long)mod->module_core <= addr &&
76622 - addr < (unsigned long)mod->module_core + mod->core_size;
76623 + return within_module_core_rx(addr, mod) || within_module_core_rw(addr, mod);
76624 }
76625
76626 static inline int within_module_init(unsigned long addr, const struct module *mod)
76627 {
76628 - return (unsigned long)mod->module_init <= addr &&
76629 - addr < (unsigned long)mod->module_init + mod->init_size;
76630 + return within_module_init_rx(addr, mod) || within_module_init_rw(addr, mod);
76631 }
76632
76633 /* Search for module by name: must hold module_mutex. */
76634 diff --git a/include/linux/moduleloader.h b/include/linux/moduleloader.h
76635 index 560ca53..ef621ef 100644
76636 --- a/include/linux/moduleloader.h
76637 +++ b/include/linux/moduleloader.h
76638 @@ -25,9 +25,21 @@ unsigned int arch_mod_section_prepend(struct module *mod, unsigned int section);
76639 sections. Returns NULL on failure. */
76640 void *module_alloc(unsigned long size);
76641
76642 +#ifdef CONFIG_PAX_KERNEXEC
76643 +void *module_alloc_exec(unsigned long size);
76644 +#else
76645 +#define module_alloc_exec(x) module_alloc(x)
76646 +#endif
76647 +
76648 /* Free memory returned from module_alloc. */
76649 void module_free(struct module *mod, void *module_region);
76650
76651 +#ifdef CONFIG_PAX_KERNEXEC
76652 +void module_free_exec(struct module *mod, void *module_region);
76653 +#else
76654 +#define module_free_exec(x, y) module_free((x), (y))
76655 +#endif
76656 +
76657 /*
76658 * Apply the given relocation to the (simplified) ELF. Return -error
76659 * or 0.
76660 @@ -45,7 +57,9 @@ static inline int apply_relocate(Elf_Shdr *sechdrs,
76661 unsigned int relsec,
76662 struct module *me)
76663 {
76664 +#ifdef CONFIG_MODULES
76665 printk(KERN_ERR "module %s: REL relocation unsupported\n", me->name);
76666 +#endif
76667 return -ENOEXEC;
76668 }
76669 #endif
76670 @@ -67,7 +81,9 @@ static inline int apply_relocate_add(Elf_Shdr *sechdrs,
76671 unsigned int relsec,
76672 struct module *me)
76673 {
76674 +#ifdef CONFIG_MODULES
76675 printk(KERN_ERR "module %s: REL relocation unsupported\n", me->name);
76676 +#endif
76677 return -ENOEXEC;
76678 }
76679 #endif
76680 diff --git a/include/linux/moduleparam.h b/include/linux/moduleparam.h
76681 index c3eb102..073c4a6 100644
76682 --- a/include/linux/moduleparam.h
76683 +++ b/include/linux/moduleparam.h
76684 @@ -295,7 +295,7 @@ static inline void __kernel_param_unlock(void)
76685 * @len is usually just sizeof(string).
76686 */
76687 #define module_param_string(name, string, len, perm) \
76688 - static const struct kparam_string __param_string_##name \
76689 + static const struct kparam_string __param_string_##name __used \
76690 = { len, string }; \
76691 __module_param_call(MODULE_PARAM_PREFIX, name, \
76692 &param_ops_string, \
76693 @@ -434,7 +434,7 @@ extern int param_set_bint(const char *val, const struct kernel_param *kp);
76694 */
76695 #define module_param_array_named(name, array, type, nump, perm) \
76696 param_check_##type(name, &(array)[0]); \
76697 - static const struct kparam_array __param_arr_##name \
76698 + static const struct kparam_array __param_arr_##name __used \
76699 = { .max = ARRAY_SIZE(array), .num = nump, \
76700 .ops = &param_ops_##type, \
76701 .elemsize = sizeof(array[0]), .elem = array }; \
76702 diff --git a/include/linux/namei.h b/include/linux/namei.h
76703 index 8e47bc7..c70fd73 100644
76704 --- a/include/linux/namei.h
76705 +++ b/include/linux/namei.h
76706 @@ -19,7 +19,7 @@ struct nameidata {
76707 unsigned seq;
76708 int last_type;
76709 unsigned depth;
76710 - char *saved_names[MAX_NESTED_LINKS + 1];
76711 + const char *saved_names[MAX_NESTED_LINKS + 1];
76712 };
76713
76714 /*
76715 @@ -83,12 +83,12 @@ extern void unlock_rename(struct dentry *, struct dentry *);
76716
76717 extern void nd_jump_link(struct nameidata *nd, struct path *path);
76718
76719 -static inline void nd_set_link(struct nameidata *nd, char *path)
76720 +static inline void nd_set_link(struct nameidata *nd, const char *path)
76721 {
76722 nd->saved_names[nd->depth] = path;
76723 }
76724
76725 -static inline char *nd_get_link(struct nameidata *nd)
76726 +static inline const char *nd_get_link(const struct nameidata *nd)
76727 {
76728 return nd->saved_names[nd->depth];
76729 }
76730 diff --git a/include/linux/net.h b/include/linux/net.h
76731 index 8bd9d92..08b1c20 100644
76732 --- a/include/linux/net.h
76733 +++ b/include/linux/net.h
76734 @@ -191,7 +191,7 @@ struct net_proto_family {
76735 int (*create)(struct net *net, struct socket *sock,
76736 int protocol, int kern);
76737 struct module *owner;
76738 -};
76739 +} __do_const;
76740
76741 struct iovec;
76742 struct kvec;
76743 diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
76744 index 25f5d2d1..5cf2120 100644
76745 --- a/include/linux/netdevice.h
76746 +++ b/include/linux/netdevice.h
76747 @@ -1098,6 +1098,7 @@ struct net_device_ops {
76748 sa_family_t sa_family,
76749 __be16 port);
76750 };
76751 +typedef struct net_device_ops __no_const net_device_ops_no_const;
76752
76753 /*
76754 * The DEVICE structure.
76755 @@ -1169,7 +1170,7 @@ struct net_device {
76756 int iflink;
76757
76758 struct net_device_stats stats;
76759 - atomic_long_t rx_dropped; /* dropped packets by core network
76760 + atomic_long_unchecked_t rx_dropped; /* dropped packets by core network
76761 * Do not use this in drivers.
76762 */
76763
76764 diff --git a/include/linux/netfilter.h b/include/linux/netfilter.h
76765 index 708fe72ab9..77084a3 100644
76766 --- a/include/linux/netfilter.h
76767 +++ b/include/linux/netfilter.h
76768 @@ -82,7 +82,7 @@ struct nf_sockopt_ops {
76769 #endif
76770 /* Use the module struct to lock set/get code in place */
76771 struct module *owner;
76772 -};
76773 +} __do_const;
76774
76775 /* Function to register/unregister hook points. */
76776 int nf_register_hook(struct nf_hook_ops *reg);
76777 diff --git a/include/linux/netfilter/nfnetlink.h b/include/linux/netfilter/nfnetlink.h
76778 index cadb740..d7c37c0 100644
76779 --- a/include/linux/netfilter/nfnetlink.h
76780 +++ b/include/linux/netfilter/nfnetlink.h
76781 @@ -16,7 +16,7 @@ struct nfnl_callback {
76782 const struct nlattr * const cda[]);
76783 const struct nla_policy *policy; /* netlink attribute policy */
76784 const u_int16_t attr_count; /* number of nlattr's */
76785 -};
76786 +} __do_const;
76787
76788 struct nfnetlink_subsystem {
76789 const char *name;
76790 diff --git a/include/linux/netfilter/xt_gradm.h b/include/linux/netfilter/xt_gradm.h
76791 new file mode 100644
76792 index 0000000..33f4af8
76793 --- /dev/null
76794 +++ b/include/linux/netfilter/xt_gradm.h
76795 @@ -0,0 +1,9 @@
76796 +#ifndef _LINUX_NETFILTER_XT_GRADM_H
76797 +#define _LINUX_NETFILTER_XT_GRADM_H 1
76798 +
76799 +struct xt_gradm_mtinfo {
76800 + __u16 flags;
76801 + __u16 invflags;
76802 +};
76803 +
76804 +#endif
76805 diff --git a/include/linux/nls.h b/include/linux/nls.h
76806 index 5dc635f..35f5e11 100644
76807 --- a/include/linux/nls.h
76808 +++ b/include/linux/nls.h
76809 @@ -31,7 +31,7 @@ struct nls_table {
76810 const unsigned char *charset2upper;
76811 struct module *owner;
76812 struct nls_table *next;
76813 -};
76814 +} __do_const;
76815
76816 /* this value hold the maximum octet of charset */
76817 #define NLS_MAX_CHARSET_SIZE 6 /* for UTF-8 */
76818 diff --git a/include/linux/notifier.h b/include/linux/notifier.h
76819 index d14a4c3..a078786 100644
76820 --- a/include/linux/notifier.h
76821 +++ b/include/linux/notifier.h
76822 @@ -54,7 +54,8 @@ struct notifier_block {
76823 notifier_fn_t notifier_call;
76824 struct notifier_block __rcu *next;
76825 int priority;
76826 -};
76827 +} __do_const;
76828 +typedef struct notifier_block __no_const notifier_block_no_const;
76829
76830 struct atomic_notifier_head {
76831 spinlock_t lock;
76832 diff --git a/include/linux/oprofile.h b/include/linux/oprofile.h
76833 index b2a0f15..4d7da32 100644
76834 --- a/include/linux/oprofile.h
76835 +++ b/include/linux/oprofile.h
76836 @@ -138,9 +138,9 @@ int oprofilefs_create_ulong(struct dentry * root,
76837 int oprofilefs_create_ro_ulong(struct dentry * root,
76838 char const * name, ulong * val);
76839
76840 -/** Create a file for read-only access to an atomic_t. */
76841 +/** Create a file for read-only access to an atomic_unchecked_t. */
76842 int oprofilefs_create_ro_atomic(struct dentry * root,
76843 - char const * name, atomic_t * val);
76844 + char const * name, atomic_unchecked_t * val);
76845
76846 /** create a directory */
76847 struct dentry *oprofilefs_mkdir(struct dentry *parent, char const *name);
76848 diff --git a/include/linux/pci_hotplug.h b/include/linux/pci_hotplug.h
76849 index 430dd96..544e26e 100644
76850 --- a/include/linux/pci_hotplug.h
76851 +++ b/include/linux/pci_hotplug.h
76852 @@ -71,7 +71,8 @@ struct hotplug_slot_ops {
76853 int (*get_latch_status) (struct hotplug_slot *slot, u8 *value);
76854 int (*get_adapter_status) (struct hotplug_slot *slot, u8 *value);
76855 int (*reset_slot) (struct hotplug_slot *slot, int probe);
76856 -};
76857 +} __do_const;
76858 +typedef struct hotplug_slot_ops __no_const hotplug_slot_ops_no_const;
76859
76860 /**
76861 * struct hotplug_slot_info - used to notify the hotplug pci core of the state of the slot
76862 diff --git a/include/linux/perf_event.h b/include/linux/perf_event.h
76863 index c8ba627..24bdfa8 100644
76864 --- a/include/linux/perf_event.h
76865 +++ b/include/linux/perf_event.h
76866 @@ -327,8 +327,8 @@ struct perf_event {
76867
76868 enum perf_event_active_state state;
76869 unsigned int attach_state;
76870 - local64_t count;
76871 - atomic64_t child_count;
76872 + local64_t count; /* PaX: fix it one day */
76873 + atomic64_unchecked_t child_count;
76874
76875 /*
76876 * These are the total time in nanoseconds that the event
76877 @@ -379,8 +379,8 @@ struct perf_event {
76878 * These accumulate total time (in nanoseconds) that children
76879 * events have been enabled and running, respectively.
76880 */
76881 - atomic64_t child_total_time_enabled;
76882 - atomic64_t child_total_time_running;
76883 + atomic64_unchecked_t child_total_time_enabled;
76884 + atomic64_unchecked_t child_total_time_running;
76885
76886 /*
76887 * Protect attach/detach and child_list:
76888 @@ -702,7 +702,7 @@ static inline void perf_callchain_store(struct perf_callchain_entry *entry, u64
76889 entry->ip[entry->nr++] = ip;
76890 }
76891
76892 -extern int sysctl_perf_event_paranoid;
76893 +extern int sysctl_perf_event_legitimately_concerned;
76894 extern int sysctl_perf_event_mlock;
76895 extern int sysctl_perf_event_sample_rate;
76896 extern int sysctl_perf_cpu_time_max_percent;
76897 @@ -717,19 +717,24 @@ extern int perf_cpu_time_max_percent_handler(struct ctl_table *table, int write,
76898 loff_t *ppos);
76899
76900
76901 +static inline bool perf_paranoid_any(void)
76902 +{
76903 + return sysctl_perf_event_legitimately_concerned > 2;
76904 +}
76905 +
76906 static inline bool perf_paranoid_tracepoint_raw(void)
76907 {
76908 - return sysctl_perf_event_paranoid > -1;
76909 + return sysctl_perf_event_legitimately_concerned > -1;
76910 }
76911
76912 static inline bool perf_paranoid_cpu(void)
76913 {
76914 - return sysctl_perf_event_paranoid > 0;
76915 + return sysctl_perf_event_legitimately_concerned > 0;
76916 }
76917
76918 static inline bool perf_paranoid_kernel(void)
76919 {
76920 - return sysctl_perf_event_paranoid > 1;
76921 + return sysctl_perf_event_legitimately_concerned > 1;
76922 }
76923
76924 extern void perf_event_init(void);
76925 @@ -845,7 +850,7 @@ struct perf_pmu_events_attr {
76926 struct device_attribute attr;
76927 u64 id;
76928 const char *event_str;
76929 -};
76930 +} __do_const;
76931
76932 #define PMU_EVENT_ATTR(_name, _var, _id, _show) \
76933 static struct perf_pmu_events_attr _var = { \
76934 diff --git a/include/linux/pipe_fs_i.h b/include/linux/pipe_fs_i.h
76935 index b8809fe..ae4ccd0 100644
76936 --- a/include/linux/pipe_fs_i.h
76937 +++ b/include/linux/pipe_fs_i.h
76938 @@ -47,10 +47,10 @@ struct pipe_inode_info {
76939 struct mutex mutex;
76940 wait_queue_head_t wait;
76941 unsigned int nrbufs, curbuf, buffers;
76942 - unsigned int readers;
76943 - unsigned int writers;
76944 - unsigned int files;
76945 - unsigned int waiting_writers;
76946 + atomic_t readers;
76947 + atomic_t writers;
76948 + atomic_t files;
76949 + atomic_t waiting_writers;
76950 unsigned int r_counter;
76951 unsigned int w_counter;
76952 struct page *tmp_page;
76953 diff --git a/include/linux/platform_data/usb-ehci-s5p.h b/include/linux/platform_data/usb-ehci-s5p.h
76954 index 5f28cae..3d23723 100644
76955 --- a/include/linux/platform_data/usb-ehci-s5p.h
76956 +++ b/include/linux/platform_data/usb-ehci-s5p.h
76957 @@ -14,7 +14,7 @@
76958 struct s5p_ehci_platdata {
76959 int (*phy_init)(struct platform_device *pdev, int type);
76960 int (*phy_exit)(struct platform_device *pdev, int type);
76961 -};
76962 +} __no_const;
76963
76964 extern void s5p_ehci_set_platdata(struct s5p_ehci_platdata *pd);
76965
76966 diff --git a/include/linux/platform_data/usb-ohci-exynos.h b/include/linux/platform_data/usb-ohci-exynos.h
76967 index c256c59..8ea94c7 100644
76968 --- a/include/linux/platform_data/usb-ohci-exynos.h
76969 +++ b/include/linux/platform_data/usb-ohci-exynos.h
76970 @@ -14,7 +14,7 @@
76971 struct exynos4_ohci_platdata {
76972 int (*phy_init)(struct platform_device *pdev, int type);
76973 int (*phy_exit)(struct platform_device *pdev, int type);
76974 -};
76975 +} __no_const;
76976
76977 extern void exynos4_ohci_set_platdata(struct exynos4_ohci_platdata *pd);
76978
76979 diff --git a/include/linux/pm.h b/include/linux/pm.h
76980 index a224c7f..92d8a97 100644
76981 --- a/include/linux/pm.h
76982 +++ b/include/linux/pm.h
76983 @@ -576,6 +576,7 @@ extern int dev_pm_put_subsys_data(struct device *dev);
76984 struct dev_pm_domain {
76985 struct dev_pm_ops ops;
76986 };
76987 +typedef struct dev_pm_domain __no_const dev_pm_domain_no_const;
76988
76989 /*
76990 * The PM_EVENT_ messages are also used by drivers implementing the legacy
76991 diff --git a/include/linux/pm_domain.h b/include/linux/pm_domain.h
76992 index 7c1d252..c5c773e 100644
76993 --- a/include/linux/pm_domain.h
76994 +++ b/include/linux/pm_domain.h
76995 @@ -48,7 +48,7 @@ struct gpd_dev_ops {
76996
76997 struct gpd_cpu_data {
76998 unsigned int saved_exit_latency;
76999 - struct cpuidle_state *idle_state;
77000 + cpuidle_state_no_const *idle_state;
77001 };
77002
77003 struct generic_pm_domain {
77004 diff --git a/include/linux/pm_runtime.h b/include/linux/pm_runtime.h
77005 index 6fa7cea..7bf6415 100644
77006 --- a/include/linux/pm_runtime.h
77007 +++ b/include/linux/pm_runtime.h
77008 @@ -103,7 +103,7 @@ static inline bool pm_runtime_callbacks_present(struct device *dev)
77009
77010 static inline void pm_runtime_mark_last_busy(struct device *dev)
77011 {
77012 - ACCESS_ONCE(dev->power.last_busy) = jiffies;
77013 + ACCESS_ONCE_RW(dev->power.last_busy) = jiffies;
77014 }
77015
77016 #else /* !CONFIG_PM_RUNTIME */
77017 diff --git a/include/linux/pnp.h b/include/linux/pnp.h
77018 index 195aafc..49a7bc2 100644
77019 --- a/include/linux/pnp.h
77020 +++ b/include/linux/pnp.h
77021 @@ -297,7 +297,7 @@ static inline void pnp_set_drvdata(struct pnp_dev *pdev, void *data)
77022 struct pnp_fixup {
77023 char id[7];
77024 void (*quirk_function) (struct pnp_dev * dev); /* fixup function */
77025 -};
77026 +} __do_const;
77027
77028 /* config parameters */
77029 #define PNP_CONFIG_NORMAL 0x0001
77030 diff --git a/include/linux/poison.h b/include/linux/poison.h
77031 index 2110a81..13a11bb 100644
77032 --- a/include/linux/poison.h
77033 +++ b/include/linux/poison.h
77034 @@ -19,8 +19,8 @@
77035 * under normal circumstances, used to verify that nobody uses
77036 * non-initialized list entries.
77037 */
77038 -#define LIST_POISON1 ((void *) 0x00100100 + POISON_POINTER_DELTA)
77039 -#define LIST_POISON2 ((void *) 0x00200200 + POISON_POINTER_DELTA)
77040 +#define LIST_POISON1 ((void *) (long)0xFFFFFF01)
77041 +#define LIST_POISON2 ((void *) (long)0xFFFFFF02)
77042
77043 /********** include/linux/timer.h **********/
77044 /*
77045 diff --git a/include/linux/power/smartreflex.h b/include/linux/power/smartreflex.h
77046 index d8b187c3..9a9257a 100644
77047 --- a/include/linux/power/smartreflex.h
77048 +++ b/include/linux/power/smartreflex.h
77049 @@ -238,7 +238,7 @@ struct omap_sr_class_data {
77050 int (*notify)(struct omap_sr *sr, u32 status);
77051 u8 notify_flags;
77052 u8 class_type;
77053 -};
77054 +} __do_const;
77055
77056 /**
77057 * struct omap_sr_nvalue_table - Smartreflex n-target value info
77058 diff --git a/include/linux/ppp-comp.h b/include/linux/ppp-comp.h
77059 index 4ea1d37..80f4b33 100644
77060 --- a/include/linux/ppp-comp.h
77061 +++ b/include/linux/ppp-comp.h
77062 @@ -84,7 +84,7 @@ struct compressor {
77063 struct module *owner;
77064 /* Extra skb space needed by the compressor algorithm */
77065 unsigned int comp_extra;
77066 -};
77067 +} __do_const;
77068
77069 /*
77070 * The return value from decompress routine is the length of the
77071 diff --git a/include/linux/preempt.h b/include/linux/preempt.h
77072 index f5d4723..a6ea2fa 100644
77073 --- a/include/linux/preempt.h
77074 +++ b/include/linux/preempt.h
77075 @@ -18,8 +18,13 @@
77076 # define sub_preempt_count(val) do { preempt_count() -= (val); } while (0)
77077 #endif
77078
77079 +#define raw_add_preempt_count(val) do { preempt_count() += (val); } while (0)
77080 +#define raw_sub_preempt_count(val) do { preempt_count() -= (val); } while (0)
77081 +
77082 #define inc_preempt_count() add_preempt_count(1)
77083 +#define raw_inc_preempt_count() raw_add_preempt_count(1)
77084 #define dec_preempt_count() sub_preempt_count(1)
77085 +#define raw_dec_preempt_count() raw_sub_preempt_count(1)
77086
77087 #define preempt_count() (current_thread_info()->preempt_count)
77088
77089 @@ -64,6 +69,12 @@ do { \
77090 barrier(); \
77091 } while (0)
77092
77093 +#define raw_preempt_disable() \
77094 +do { \
77095 + raw_inc_preempt_count(); \
77096 + barrier(); \
77097 +} while (0)
77098 +
77099 #define sched_preempt_enable_no_resched() \
77100 do { \
77101 barrier(); \
77102 @@ -72,6 +83,12 @@ do { \
77103
77104 #define preempt_enable_no_resched() sched_preempt_enable_no_resched()
77105
77106 +#define raw_preempt_enable_no_resched() \
77107 +do { \
77108 + barrier(); \
77109 + raw_dec_preempt_count(); \
77110 +} while (0)
77111 +
77112 #define preempt_enable() \
77113 do { \
77114 preempt_enable_no_resched(); \
77115 @@ -116,8 +133,10 @@ do { \
77116 * region.
77117 */
77118 #define preempt_disable() barrier()
77119 +#define raw_preempt_disable() barrier()
77120 #define sched_preempt_enable_no_resched() barrier()
77121 #define preempt_enable_no_resched() barrier()
77122 +#define raw_preempt_enable_no_resched() barrier()
77123 #define preempt_enable() barrier()
77124
77125 #define preempt_disable_notrace() barrier()
77126 diff --git a/include/linux/printk.h b/include/linux/printk.h
77127 index e6131a78..8e9fb61 100644
77128 --- a/include/linux/printk.h
77129 +++ b/include/linux/printk.h
77130 @@ -106,6 +106,8 @@ static inline __printf(1, 2) __cold
77131 void early_printk(const char *s, ...) { }
77132 #endif
77133
77134 +extern int kptr_restrict;
77135 +
77136 #ifdef CONFIG_PRINTK
77137 asmlinkage __printf(5, 0)
77138 int vprintk_emit(int facility, int level,
77139 @@ -140,7 +142,6 @@ extern bool printk_timed_ratelimit(unsigned long *caller_jiffies,
77140
77141 extern int printk_delay_msec;
77142 extern int dmesg_restrict;
77143 -extern int kptr_restrict;
77144
77145 extern void wake_up_klogd(void);
77146
77147 diff --git a/include/linux/proc_fs.h b/include/linux/proc_fs.h
77148 index 608e60a..c26f864 100644
77149 --- a/include/linux/proc_fs.h
77150 +++ b/include/linux/proc_fs.h
77151 @@ -34,6 +34,19 @@ static inline struct proc_dir_entry *proc_create(
77152 return proc_create_data(name, mode, parent, proc_fops, NULL);
77153 }
77154
77155 +static inline struct proc_dir_entry *proc_create_grsec(const char *name, umode_t mode,
77156 + struct proc_dir_entry *parent, const struct file_operations *proc_fops)
77157 +{
77158 +#ifdef CONFIG_GRKERNSEC_PROC_USER
77159 + return proc_create_data(name, S_IRUSR, parent, proc_fops, NULL);
77160 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
77161 + return proc_create_data(name, S_IRUSR | S_IRGRP, parent, proc_fops, NULL);
77162 +#else
77163 + return proc_create_data(name, mode, parent, proc_fops, NULL);
77164 +#endif
77165 +}
77166 +
77167 +
77168 extern void proc_set_size(struct proc_dir_entry *, loff_t);
77169 extern void proc_set_user(struct proc_dir_entry *, kuid_t, kgid_t);
77170 extern void *PDE_DATA(const struct inode *);
77171 diff --git a/include/linux/proc_ns.h b/include/linux/proc_ns.h
77172 index 34a1e10..03a6d03 100644
77173 --- a/include/linux/proc_ns.h
77174 +++ b/include/linux/proc_ns.h
77175 @@ -14,7 +14,7 @@ struct proc_ns_operations {
77176 void (*put)(void *ns);
77177 int (*install)(struct nsproxy *nsproxy, void *ns);
77178 unsigned int (*inum)(void *ns);
77179 -};
77180 +} __do_const;
77181
77182 struct proc_ns {
77183 void *ns;
77184 diff --git a/include/linux/quota.h b/include/linux/quota.h
77185 index cc7494a..1e27036 100644
77186 --- a/include/linux/quota.h
77187 +++ b/include/linux/quota.h
77188 @@ -70,7 +70,7 @@ struct kqid { /* Type in which we store the quota identifier */
77189
77190 extern bool qid_eq(struct kqid left, struct kqid right);
77191 extern bool qid_lt(struct kqid left, struct kqid right);
77192 -extern qid_t from_kqid(struct user_namespace *to, struct kqid qid);
77193 +extern qid_t from_kqid(struct user_namespace *to, struct kqid qid) __intentional_overflow(-1);
77194 extern qid_t from_kqid_munged(struct user_namespace *to, struct kqid qid);
77195 extern bool qid_valid(struct kqid qid);
77196
77197 diff --git a/include/linux/random.h b/include/linux/random.h
77198 index bf9085e..128eade 100644
77199 --- a/include/linux/random.h
77200 +++ b/include/linux/random.h
77201 @@ -10,9 +10,19 @@
77202
77203
77204 extern void add_device_randomness(const void *, unsigned int);
77205 +
77206 +static inline void add_latent_entropy(void)
77207 +{
77208 +
77209 +#ifdef LATENT_ENTROPY_PLUGIN
77210 + add_device_randomness((const void *)&latent_entropy, sizeof(latent_entropy));
77211 +#endif
77212 +
77213 +}
77214 +
77215 extern void add_input_randomness(unsigned int type, unsigned int code,
77216 - unsigned int value);
77217 -extern void add_interrupt_randomness(int irq, int irq_flags);
77218 + unsigned int value) __latent_entropy;
77219 +extern void add_interrupt_randomness(int irq, int irq_flags) __latent_entropy;
77220
77221 extern void get_random_bytes(void *buf, int nbytes);
77222 extern void get_random_bytes_arch(void *buf, int nbytes);
77223 @@ -33,6 +43,11 @@ void prandom_seed(u32 seed);
77224 u32 prandom_u32_state(struct rnd_state *);
77225 void prandom_bytes_state(struct rnd_state *state, void *buf, int nbytes);
77226
77227 +static inline unsigned long pax_get_random_long(void)
77228 +{
77229 + return prandom_u32() + (sizeof(long) > 4 ? (unsigned long)prandom_u32() << 32 : 0);
77230 +}
77231 +
77232 /*
77233 * Handle minimum values for seeds
77234 */
77235 diff --git a/include/linux/rculist.h b/include/linux/rculist.h
77236 index 4106721..132d42c 100644
77237 --- a/include/linux/rculist.h
77238 +++ b/include/linux/rculist.h
77239 @@ -44,6 +44,9 @@ extern void __list_add_rcu(struct list_head *new,
77240 struct list_head *prev, struct list_head *next);
77241 #endif
77242
77243 +extern void __pax_list_add_rcu(struct list_head *new,
77244 + struct list_head *prev, struct list_head *next);
77245 +
77246 /**
77247 * list_add_rcu - add a new entry to rcu-protected list
77248 * @new: new entry to be added
77249 @@ -65,6 +68,11 @@ static inline void list_add_rcu(struct list_head *new, struct list_head *head)
77250 __list_add_rcu(new, head, head->next);
77251 }
77252
77253 +static inline void pax_list_add_rcu(struct list_head *new, struct list_head *head)
77254 +{
77255 + __pax_list_add_rcu(new, head, head->next);
77256 +}
77257 +
77258 /**
77259 * list_add_tail_rcu - add a new entry to rcu-protected list
77260 * @new: new entry to be added
77261 @@ -87,6 +95,12 @@ static inline void list_add_tail_rcu(struct list_head *new,
77262 __list_add_rcu(new, head->prev, head);
77263 }
77264
77265 +static inline void pax_list_add_tail_rcu(struct list_head *new,
77266 + struct list_head *head)
77267 +{
77268 + __pax_list_add_rcu(new, head->prev, head);
77269 +}
77270 +
77271 /**
77272 * list_del_rcu - deletes entry from list without re-initialization
77273 * @entry: the element to delete from the list.
77274 @@ -117,6 +131,8 @@ static inline void list_del_rcu(struct list_head *entry)
77275 entry->prev = LIST_POISON2;
77276 }
77277
77278 +extern void pax_list_del_rcu(struct list_head *entry);
77279 +
77280 /**
77281 * hlist_del_init_rcu - deletes entry from hash list with re-initialization
77282 * @n: the element to delete from the hash list.
77283 diff --git a/include/linux/reboot.h b/include/linux/reboot.h
77284 index 8e00f9f..9449b55 100644
77285 --- a/include/linux/reboot.h
77286 +++ b/include/linux/reboot.h
77287 @@ -43,9 +43,9 @@ extern int unregister_reboot_notifier(struct notifier_block *);
77288 * Architecture-specific implementations of sys_reboot commands.
77289 */
77290
77291 -extern void machine_restart(char *cmd);
77292 -extern void machine_halt(void);
77293 -extern void machine_power_off(void);
77294 +extern void machine_restart(char *cmd) __noreturn;
77295 +extern void machine_halt(void) __noreturn;
77296 +extern void machine_power_off(void) __noreturn;
77297
77298 extern void machine_shutdown(void);
77299 struct pt_regs;
77300 @@ -56,9 +56,9 @@ extern void machine_crash_shutdown(struct pt_regs *);
77301 */
77302
77303 extern void kernel_restart_prepare(char *cmd);
77304 -extern void kernel_restart(char *cmd);
77305 -extern void kernel_halt(void);
77306 -extern void kernel_power_off(void);
77307 +extern void kernel_restart(char *cmd) __noreturn;
77308 +extern void kernel_halt(void) __noreturn;
77309 +extern void kernel_power_off(void) __noreturn;
77310
77311 extern int C_A_D; /* for sysctl */
77312 void ctrl_alt_del(void);
77313 @@ -72,7 +72,7 @@ extern int orderly_poweroff(bool force);
77314 * Emergency restart, callable from an interrupt handler.
77315 */
77316
77317 -extern void emergency_restart(void);
77318 +extern void emergency_restart(void) __noreturn;
77319 #include <asm/emergency-restart.h>
77320
77321 #endif /* _LINUX_REBOOT_H */
77322 diff --git a/include/linux/regset.h b/include/linux/regset.h
77323 index 8e0c9fe..ac4d221 100644
77324 --- a/include/linux/regset.h
77325 +++ b/include/linux/regset.h
77326 @@ -161,7 +161,8 @@ struct user_regset {
77327 unsigned int align;
77328 unsigned int bias;
77329 unsigned int core_note_type;
77330 -};
77331 +} __do_const;
77332 +typedef struct user_regset __no_const user_regset_no_const;
77333
77334 /**
77335 * struct user_regset_view - available regsets
77336 diff --git a/include/linux/relay.h b/include/linux/relay.h
77337 index d7c8359..818daf5 100644
77338 --- a/include/linux/relay.h
77339 +++ b/include/linux/relay.h
77340 @@ -157,7 +157,7 @@ struct rchan_callbacks
77341 * The callback should return 0 if successful, negative if not.
77342 */
77343 int (*remove_buf_file)(struct dentry *dentry);
77344 -};
77345 +} __no_const;
77346
77347 /*
77348 * CONFIG_RELAY kernel API, kernel/relay.c
77349 diff --git a/include/linux/rio.h b/include/linux/rio.h
77350 index b71d573..2f940bd 100644
77351 --- a/include/linux/rio.h
77352 +++ b/include/linux/rio.h
77353 @@ -355,7 +355,7 @@ struct rio_ops {
77354 int (*map_inb)(struct rio_mport *mport, dma_addr_t lstart,
77355 u64 rstart, u32 size, u32 flags);
77356 void (*unmap_inb)(struct rio_mport *mport, dma_addr_t lstart);
77357 -};
77358 +} __no_const;
77359
77360 #define RIO_RESOURCE_MEM 0x00000100
77361 #define RIO_RESOURCE_DOORBELL 0x00000200
77362 diff --git a/include/linux/rmap.h b/include/linux/rmap.h
77363 index 6dacb93..6174423 100644
77364 --- a/include/linux/rmap.h
77365 +++ b/include/linux/rmap.h
77366 @@ -145,8 +145,8 @@ static inline void anon_vma_unlock_read(struct anon_vma *anon_vma)
77367 void anon_vma_init(void); /* create anon_vma_cachep */
77368 int anon_vma_prepare(struct vm_area_struct *);
77369 void unlink_anon_vmas(struct vm_area_struct *);
77370 -int anon_vma_clone(struct vm_area_struct *, struct vm_area_struct *);
77371 -int anon_vma_fork(struct vm_area_struct *, struct vm_area_struct *);
77372 +int anon_vma_clone(struct vm_area_struct *, const struct vm_area_struct *);
77373 +int anon_vma_fork(struct vm_area_struct *, const struct vm_area_struct *);
77374
77375 static inline void anon_vma_merge(struct vm_area_struct *vma,
77376 struct vm_area_struct *next)
77377 diff --git a/include/linux/sched.h b/include/linux/sched.h
77378 index b1e963e..114b8fd 100644
77379 --- a/include/linux/sched.h
77380 +++ b/include/linux/sched.h
77381 @@ -62,6 +62,7 @@ struct bio_list;
77382 struct fs_struct;
77383 struct perf_event_context;
77384 struct blk_plug;
77385 +struct linux_binprm;
77386
77387 /*
77388 * List of flags we want to share for kernel threads,
77389 @@ -295,7 +296,7 @@ extern char __sched_text_start[], __sched_text_end[];
77390 extern int in_sched_functions(unsigned long addr);
77391
77392 #define MAX_SCHEDULE_TIMEOUT LONG_MAX
77393 -extern signed long schedule_timeout(signed long timeout);
77394 +extern signed long schedule_timeout(signed long timeout) __intentional_overflow(-1);
77395 extern signed long schedule_timeout_interruptible(signed long timeout);
77396 extern signed long schedule_timeout_killable(signed long timeout);
77397 extern signed long schedule_timeout_uninterruptible(signed long timeout);
77398 @@ -306,6 +307,19 @@ struct nsproxy;
77399 struct user_namespace;
77400
77401 #ifdef CONFIG_MMU
77402 +
77403 +#ifdef CONFIG_GRKERNSEC_RAND_THREADSTACK
77404 +extern unsigned long gr_rand_threadstack_offset(const struct mm_struct *mm, const struct file *filp, unsigned long flags);
77405 +#else
77406 +static inline unsigned long gr_rand_threadstack_offset(const struct mm_struct *mm, const struct file *filp, unsigned long flags)
77407 +{
77408 + return 0;
77409 +}
77410 +#endif
77411 +
77412 +extern bool check_heap_stack_gap(const struct vm_area_struct *vma, unsigned long addr, unsigned long len, unsigned long offset);
77413 +extern unsigned long skip_heap_stack_gap(const struct vm_area_struct *vma, unsigned long len, unsigned long offset);
77414 +
77415 extern void arch_pick_mmap_layout(struct mm_struct *mm);
77416 extern unsigned long
77417 arch_get_unmapped_area(struct file *, unsigned long, unsigned long,
77418 @@ -585,6 +599,17 @@ struct signal_struct {
77419 #ifdef CONFIG_TASKSTATS
77420 struct taskstats *stats;
77421 #endif
77422 +
77423 +#ifdef CONFIG_GRKERNSEC
77424 + u32 curr_ip;
77425 + u32 saved_ip;
77426 + u32 gr_saddr;
77427 + u32 gr_daddr;
77428 + u16 gr_sport;
77429 + u16 gr_dport;
77430 + u8 used_accept:1;
77431 +#endif
77432 +
77433 #ifdef CONFIG_AUDIT
77434 unsigned audit_tty;
77435 unsigned audit_tty_log_passwd;
77436 @@ -665,6 +690,14 @@ struct user_struct {
77437 struct key *session_keyring; /* UID's default session keyring */
77438 #endif
77439
77440 +#ifdef CONFIG_GRKERNSEC_KERN_LOCKOUT
77441 + unsigned char kernel_banned;
77442 +#endif
77443 +#ifdef CONFIG_GRKERNSEC_BRUTE
77444 + unsigned char suid_banned;
77445 + unsigned long suid_ban_expires;
77446 +#endif
77447 +
77448 /* Hash table maintenance information */
77449 struct hlist_node uidhash_node;
77450 kuid_t uid;
77451 @@ -1150,8 +1183,8 @@ struct task_struct {
77452 struct list_head thread_group;
77453
77454 struct completion *vfork_done; /* for vfork() */
77455 - int __user *set_child_tid; /* CLONE_CHILD_SETTID */
77456 - int __user *clear_child_tid; /* CLONE_CHILD_CLEARTID */
77457 + pid_t __user *set_child_tid; /* CLONE_CHILD_SETTID */
77458 + pid_t __user *clear_child_tid; /* CLONE_CHILD_CLEARTID */
77459
77460 cputime_t utime, stime, utimescaled, stimescaled;
77461 cputime_t gtime;
77462 @@ -1176,11 +1209,6 @@ struct task_struct {
77463 struct task_cputime cputime_expires;
77464 struct list_head cpu_timers[3];
77465
77466 -/* process credentials */
77467 - const struct cred __rcu *real_cred; /* objective and real subjective task
77468 - * credentials (COW) */
77469 - const struct cred __rcu *cred; /* effective (overridable) subjective task
77470 - * credentials (COW) */
77471 char comm[TASK_COMM_LEN]; /* executable name excluding path
77472 - access with [gs]et_task_comm (which lock
77473 it with task_lock())
77474 @@ -1197,6 +1225,10 @@ struct task_struct {
77475 #endif
77476 /* CPU-specific state of this task */
77477 struct thread_struct thread;
77478 +/* thread_info moved to task_struct */
77479 +#ifdef CONFIG_X86
77480 + struct thread_info tinfo;
77481 +#endif
77482 /* filesystem information */
77483 struct fs_struct *fs;
77484 /* open file information */
77485 @@ -1270,6 +1302,10 @@ struct task_struct {
77486 gfp_t lockdep_reclaim_gfp;
77487 #endif
77488
77489 +/* process credentials */
77490 + const struct cred __rcu *real_cred; /* objective and real subjective task
77491 + * credentials (COW) */
77492 +
77493 /* journalling filesystem info */
77494 void *journal_info;
77495
77496 @@ -1308,6 +1344,10 @@ struct task_struct {
77497 /* cg_list protected by css_set_lock and tsk->alloc_lock */
77498 struct list_head cg_list;
77499 #endif
77500 +
77501 + const struct cred __rcu *cred; /* effective (overridable) subjective task
77502 + * credentials (COW) */
77503 +
77504 #ifdef CONFIG_FUTEX
77505 struct robust_list_head __user *robust_list;
77506 #ifdef CONFIG_COMPAT
77507 @@ -1411,8 +1451,78 @@ struct task_struct {
77508 unsigned int sequential_io;
77509 unsigned int sequential_io_avg;
77510 #endif
77511 +
77512 +#ifdef CONFIG_GRKERNSEC
77513 + /* grsecurity */
77514 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
77515 + u64 exec_id;
77516 +#endif
77517 +#ifdef CONFIG_GRKERNSEC_SETXID
77518 + const struct cred *delayed_cred;
77519 +#endif
77520 + struct dentry *gr_chroot_dentry;
77521 + struct acl_subject_label *acl;
77522 + struct acl_subject_label *tmpacl;
77523 + struct acl_role_label *role;
77524 + struct file *exec_file;
77525 + unsigned long brute_expires;
77526 + u16 acl_role_id;
77527 + u8 inherited;
77528 + /* is this the task that authenticated to the special role */
77529 + u8 acl_sp_role;
77530 + u8 is_writable;
77531 + u8 brute;
77532 + u8 gr_is_chrooted;
77533 +#endif
77534 +
77535 };
77536
77537 +#define MF_PAX_PAGEEXEC 0x01000000 /* Paging based non-executable pages */
77538 +#define MF_PAX_EMUTRAMP 0x02000000 /* Emulate trampolines */
77539 +#define MF_PAX_MPROTECT 0x04000000 /* Restrict mprotect() */
77540 +#define MF_PAX_RANDMMAP 0x08000000 /* Randomize mmap() base */
77541 +/*#define MF_PAX_RANDEXEC 0x10000000*/ /* Randomize ET_EXEC base */
77542 +#define MF_PAX_SEGMEXEC 0x20000000 /* Segmentation based non-executable pages */
77543 +
77544 +#ifdef CONFIG_PAX_SOFTMODE
77545 +extern int pax_softmode;
77546 +#endif
77547 +
77548 +extern int pax_check_flags(unsigned long *);
77549 +
77550 +/* if tsk != current then task_lock must be held on it */
77551 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
77552 +static inline unsigned long pax_get_flags(struct task_struct *tsk)
77553 +{
77554 + if (likely(tsk->mm))
77555 + return tsk->mm->pax_flags;
77556 + else
77557 + return 0UL;
77558 +}
77559 +
77560 +/* if tsk != current then task_lock must be held on it */
77561 +static inline long pax_set_flags(struct task_struct *tsk, unsigned long flags)
77562 +{
77563 + if (likely(tsk->mm)) {
77564 + tsk->mm->pax_flags = flags;
77565 + return 0;
77566 + }
77567 + return -EINVAL;
77568 +}
77569 +#endif
77570 +
77571 +#ifdef CONFIG_PAX_HAVE_ACL_FLAGS
77572 +extern void pax_set_initial_flags(struct linux_binprm *bprm);
77573 +#elif defined(CONFIG_PAX_HOOK_ACL_FLAGS)
77574 +extern void (*pax_set_initial_flags_func)(struct linux_binprm *bprm);
77575 +#endif
77576 +
77577 +struct path;
77578 +extern char *pax_get_path(const struct path *path, char *buf, int buflen);
77579 +extern void pax_report_fault(struct pt_regs *regs, void *pc, void *sp);
77580 +extern void pax_report_insns(struct pt_regs *regs, void *pc, void *sp);
77581 +extern void pax_report_refcount_overflow(struct pt_regs *regs);
77582 +
77583 /* Future-safe accessor for struct task_struct's cpus_allowed. */
77584 #define tsk_cpus_allowed(tsk) (&(tsk)->cpus_allowed)
77585
77586 @@ -1471,7 +1581,7 @@ struct pid_namespace;
77587 pid_t __task_pid_nr_ns(struct task_struct *task, enum pid_type type,
77588 struct pid_namespace *ns);
77589
77590 -static inline pid_t task_pid_nr(struct task_struct *tsk)
77591 +static inline pid_t task_pid_nr(const struct task_struct *tsk)
77592 {
77593 return tsk->pid;
77594 }
77595 @@ -1921,7 +2031,9 @@ void yield(void);
77596 extern struct exec_domain default_exec_domain;
77597
77598 union thread_union {
77599 +#ifndef CONFIG_X86
77600 struct thread_info thread_info;
77601 +#endif
77602 unsigned long stack[THREAD_SIZE/sizeof(long)];
77603 };
77604
77605 @@ -1954,6 +2066,7 @@ extern struct pid_namespace init_pid_ns;
77606 */
77607
77608 extern struct task_struct *find_task_by_vpid(pid_t nr);
77609 +extern struct task_struct *find_task_by_vpid_unrestricted(pid_t nr);
77610 extern struct task_struct *find_task_by_pid_ns(pid_t nr,
77611 struct pid_namespace *ns);
77612
77613 @@ -2118,7 +2231,7 @@ extern void __cleanup_sighand(struct sighand_struct *);
77614 extern void exit_itimers(struct signal_struct *);
77615 extern void flush_itimer_signals(void);
77616
77617 -extern void do_group_exit(int);
77618 +extern __noreturn void do_group_exit(int);
77619
77620 extern int allow_signal(int);
77621 extern int disallow_signal(int);
77622 @@ -2309,9 +2422,9 @@ static inline unsigned long *end_of_stack(struct task_struct *p)
77623
77624 #endif
77625
77626 -static inline int object_is_on_stack(void *obj)
77627 +static inline int object_starts_on_stack(void *obj)
77628 {
77629 - void *stack = task_stack_page(current);
77630 + const void *stack = task_stack_page(current);
77631
77632 return (obj >= stack) && (obj < (stack + THREAD_SIZE));
77633 }
77634 diff --git a/include/linux/sched/sysctl.h b/include/linux/sched/sysctl.h
77635 index bf8086b..962b035 100644
77636 --- a/include/linux/sched/sysctl.h
77637 +++ b/include/linux/sched/sysctl.h
77638 @@ -30,6 +30,7 @@ enum { sysctl_hung_task_timeout_secs = 0 };
77639 #define DEFAULT_MAX_MAP_COUNT (USHRT_MAX - MAPCOUNT_ELF_CORE_MARGIN)
77640
77641 extern int sysctl_max_map_count;
77642 +extern unsigned long sysctl_heap_stack_gap;
77643
77644 extern unsigned int sysctl_sched_latency;
77645 extern unsigned int sysctl_sched_min_granularity;
77646 diff --git a/include/linux/security.h b/include/linux/security.h
77647 index 9d37e2b..43368e4 100644
77648 --- a/include/linux/security.h
77649 +++ b/include/linux/security.h
77650 @@ -27,6 +27,7 @@
77651 #include <linux/slab.h>
77652 #include <linux/err.h>
77653 #include <linux/string.h>
77654 +#include <linux/grsecurity.h>
77655
77656 struct linux_binprm;
77657 struct cred;
77658 @@ -116,8 +117,6 @@ struct seq_file;
77659
77660 extern int cap_netlink_send(struct sock *sk, struct sk_buff *skb);
77661
77662 -void reset_security_ops(void);
77663 -
77664 #ifdef CONFIG_MMU
77665 extern unsigned long mmap_min_addr;
77666 extern unsigned long dac_mmap_min_addr;
77667 diff --git a/include/linux/semaphore.h b/include/linux/semaphore.h
77668 index dc368b8..e895209 100644
77669 --- a/include/linux/semaphore.h
77670 +++ b/include/linux/semaphore.h
77671 @@ -37,7 +37,7 @@ static inline void sema_init(struct semaphore *sem, int val)
77672 }
77673
77674 extern void down(struct semaphore *sem);
77675 -extern int __must_check down_interruptible(struct semaphore *sem);
77676 +extern int __must_check down_interruptible(struct semaphore *sem) __intentional_overflow(-1);
77677 extern int __must_check down_killable(struct semaphore *sem);
77678 extern int __must_check down_trylock(struct semaphore *sem);
77679 extern int __must_check down_timeout(struct semaphore *sem, long jiffies);
77680 diff --git a/include/linux/seq_file.h b/include/linux/seq_file.h
77681 index 4e32edc..f8f2d18 100644
77682 --- a/include/linux/seq_file.h
77683 +++ b/include/linux/seq_file.h
77684 @@ -26,6 +26,9 @@ struct seq_file {
77685 struct mutex lock;
77686 const struct seq_operations *op;
77687 int poll_event;
77688 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
77689 + u64 exec_id;
77690 +#endif
77691 #ifdef CONFIG_USER_NS
77692 struct user_namespace *user_ns;
77693 #endif
77694 @@ -38,6 +41,7 @@ struct seq_operations {
77695 void * (*next) (struct seq_file *m, void *v, loff_t *pos);
77696 int (*show) (struct seq_file *m, void *v);
77697 };
77698 +typedef struct seq_operations __no_const seq_operations_no_const;
77699
77700 #define SEQ_SKIP 1
77701
77702 diff --git a/include/linux/shm.h b/include/linux/shm.h
77703 index 429c199..4d42e38 100644
77704 --- a/include/linux/shm.h
77705 +++ b/include/linux/shm.h
77706 @@ -21,6 +21,10 @@ struct shmid_kernel /* private to the kernel */
77707
77708 /* The task created the shm object. NULL if the task is dead. */
77709 struct task_struct *shm_creator;
77710 +#ifdef CONFIG_GRKERNSEC
77711 + time_t shm_createtime;
77712 + pid_t shm_lapid;
77713 +#endif
77714 };
77715
77716 /* shm_mode upper byte flags */
77717 diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
77718 index f66f346..2e304d5 100644
77719 --- a/include/linux/skbuff.h
77720 +++ b/include/linux/skbuff.h
77721 @@ -639,7 +639,7 @@ extern bool skb_try_coalesce(struct sk_buff *to, struct sk_buff *from,
77722 extern struct sk_buff *__alloc_skb(unsigned int size,
77723 gfp_t priority, int flags, int node);
77724 extern struct sk_buff *build_skb(void *data, unsigned int frag_size);
77725 -static inline struct sk_buff *alloc_skb(unsigned int size,
77726 +static inline struct sk_buff * __intentional_overflow(0) alloc_skb(unsigned int size,
77727 gfp_t priority)
77728 {
77729 return __alloc_skb(size, priority, 0, NUMA_NO_NODE);
77730 @@ -755,7 +755,7 @@ static inline struct skb_shared_hwtstamps *skb_hwtstamps(struct sk_buff *skb)
77731 */
77732 static inline int skb_queue_empty(const struct sk_buff_head *list)
77733 {
77734 - return list->next == (struct sk_buff *)list;
77735 + return list->next == (const struct sk_buff *)list;
77736 }
77737
77738 /**
77739 @@ -768,7 +768,7 @@ static inline int skb_queue_empty(const struct sk_buff_head *list)
77740 static inline bool skb_queue_is_last(const struct sk_buff_head *list,
77741 const struct sk_buff *skb)
77742 {
77743 - return skb->next == (struct sk_buff *)list;
77744 + return skb->next == (const struct sk_buff *)list;
77745 }
77746
77747 /**
77748 @@ -781,7 +781,7 @@ static inline bool skb_queue_is_last(const struct sk_buff_head *list,
77749 static inline bool skb_queue_is_first(const struct sk_buff_head *list,
77750 const struct sk_buff *skb)
77751 {
77752 - return skb->prev == (struct sk_buff *)list;
77753 + return skb->prev == (const struct sk_buff *)list;
77754 }
77755
77756 /**
77757 @@ -1741,7 +1741,7 @@ static inline int pskb_network_may_pull(struct sk_buff *skb, unsigned int len)
77758 * NET_IP_ALIGN(2) + ethernet_header(14) + IP_header(20/40) + ports(8)
77759 */
77760 #ifndef NET_SKB_PAD
77761 -#define NET_SKB_PAD max(32, L1_CACHE_BYTES)
77762 +#define NET_SKB_PAD max(_AC(32,UL), L1_CACHE_BYTES)
77763 #endif
77764
77765 extern int ___pskb_trim(struct sk_buff *skb, unsigned int len);
77766 @@ -2339,7 +2339,7 @@ extern struct sk_buff *skb_recv_datagram(struct sock *sk, unsigned flags,
77767 int noblock, int *err);
77768 extern unsigned int datagram_poll(struct file *file, struct socket *sock,
77769 struct poll_table_struct *wait);
77770 -extern int skb_copy_datagram_iovec(const struct sk_buff *from,
77771 +extern int __intentional_overflow(0) skb_copy_datagram_iovec(const struct sk_buff *from,
77772 int offset, struct iovec *to,
77773 int size);
77774 extern int skb_copy_and_csum_datagram_iovec(struct sk_buff *skb,
77775 @@ -2618,6 +2618,9 @@ static inline void nf_reset(struct sk_buff *skb)
77776 nf_bridge_put(skb->nf_bridge);
77777 skb->nf_bridge = NULL;
77778 #endif
77779 +#if IS_ENABLED(CONFIG_NETFILTER_XT_TARGET_TRACE)
77780 + skb->nf_trace = 0;
77781 +#endif
77782 }
77783
77784 static inline void nf_reset_trace(struct sk_buff *skb)
77785 diff --git a/include/linux/slab.h b/include/linux/slab.h
77786 index 74f1058..914b7da 100644
77787 --- a/include/linux/slab.h
77788 +++ b/include/linux/slab.h
77789 @@ -14,15 +14,29 @@
77790 #include <linux/gfp.h>
77791 #include <linux/types.h>
77792 #include <linux/workqueue.h>
77793 -
77794 +#include <linux/err.h>
77795
77796 /*
77797 * Flags to pass to kmem_cache_create().
77798 * The ones marked DEBUG are only valid if CONFIG_SLAB_DEBUG is set.
77799 */
77800 #define SLAB_DEBUG_FREE 0x00000100UL /* DEBUG: Perform (expensive) checks on free */
77801 +
77802 +#ifdef CONFIG_PAX_USERCOPY_SLABS
77803 +#define SLAB_USERCOPY 0x00000200UL /* PaX: Allow copying objs to/from userland */
77804 +#else
77805 +#define SLAB_USERCOPY 0x00000000UL
77806 +#endif
77807 +
77808 #define SLAB_RED_ZONE 0x00000400UL /* DEBUG: Red zone objs in a cache */
77809 #define SLAB_POISON 0x00000800UL /* DEBUG: Poison objects */
77810 +
77811 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
77812 +#define SLAB_NO_SANITIZE 0x00001000UL /* PaX: Do not sanitize objs on free */
77813 +#else
77814 +#define SLAB_NO_SANITIZE 0x00000000UL
77815 +#endif
77816 +
77817 #define SLAB_HWCACHE_ALIGN 0x00002000UL /* Align objs on cache lines */
77818 #define SLAB_CACHE_DMA 0x00004000UL /* Use GFP_DMA memory */
77819 #define SLAB_STORE_USER 0x00010000UL /* DEBUG: Store the last owner for bug hunting */
77820 @@ -91,10 +105,13 @@
77821 * ZERO_SIZE_PTR can be passed to kfree though in the same way that NULL can.
77822 * Both make kfree a no-op.
77823 */
77824 -#define ZERO_SIZE_PTR ((void *)16)
77825 +#define ZERO_SIZE_PTR \
77826 +({ \
77827 + BUILD_BUG_ON(!(MAX_ERRNO & ~PAGE_MASK));\
77828 + (void *)(-MAX_ERRNO-1L); \
77829 +})
77830
77831 -#define ZERO_OR_NULL_PTR(x) ((unsigned long)(x) <= \
77832 - (unsigned long)ZERO_SIZE_PTR)
77833 +#define ZERO_OR_NULL_PTR(x) ((unsigned long)(x) - 1 >= (unsigned long)ZERO_SIZE_PTR - 1)
77834
77835 #include <linux/kmemleak.h>
77836
77837 @@ -135,6 +152,8 @@ void * __must_check krealloc(const void *, size_t, gfp_t);
77838 void kfree(const void *);
77839 void kzfree(const void *);
77840 size_t ksize(const void *);
77841 +const char *check_heap_object(const void *ptr, unsigned long n);
77842 +bool is_usercopy_object(const void *ptr);
77843
77844 /*
77845 * Some archs want to perform DMA into kmalloc caches and need a guaranteed
77846 @@ -167,7 +186,7 @@ struct kmem_cache {
77847 unsigned int align; /* Alignment as calculated */
77848 unsigned long flags; /* Active flags on the slab */
77849 const char *name; /* Slab name for sysfs */
77850 - int refcount; /* Use counter */
77851 + atomic_t refcount; /* Use counter */
77852 void (*ctor)(void *); /* Called on object slot creation */
77853 struct list_head list; /* List of all slab caches on the system */
77854 };
77855 @@ -241,6 +260,10 @@ extern struct kmem_cache *kmalloc_caches[KMALLOC_SHIFT_HIGH + 1];
77856 extern struct kmem_cache *kmalloc_dma_caches[KMALLOC_SHIFT_HIGH + 1];
77857 #endif
77858
77859 +#ifdef CONFIG_PAX_USERCOPY_SLABS
77860 +extern struct kmem_cache *kmalloc_usercopy_caches[KMALLOC_SHIFT_HIGH + 1];
77861 +#endif
77862 +
77863 /*
77864 * Figure out which kmalloc slab an allocation of a certain size
77865 * belongs to.
77866 @@ -249,7 +272,7 @@ extern struct kmem_cache *kmalloc_dma_caches[KMALLOC_SHIFT_HIGH + 1];
77867 * 2 = 120 .. 192 bytes
77868 * n = 2^(n-1) .. 2^n -1
77869 */
77870 -static __always_inline int kmalloc_index(size_t size)
77871 +static __always_inline __size_overflow(1) int kmalloc_index(size_t size)
77872 {
77873 if (!size)
77874 return 0;
77875 @@ -292,11 +315,11 @@ static __always_inline int kmalloc_index(size_t size)
77876 }
77877 #endif /* !CONFIG_SLOB */
77878
77879 -void *__kmalloc(size_t size, gfp_t flags);
77880 +void *__kmalloc(size_t size, gfp_t flags) __alloc_size(1);
77881 void *kmem_cache_alloc(struct kmem_cache *, gfp_t flags);
77882
77883 #ifdef CONFIG_NUMA
77884 -void *__kmalloc_node(size_t size, gfp_t flags, int node);
77885 +void *__kmalloc_node(size_t size, gfp_t flags, int node) __alloc_size(1);
77886 void *kmem_cache_alloc_node(struct kmem_cache *, gfp_t flags, int node);
77887 #else
77888 static __always_inline void *__kmalloc_node(size_t size, gfp_t flags, int node)
77889 diff --git a/include/linux/slab_def.h b/include/linux/slab_def.h
77890 index e9346b4..1494959 100644
77891 --- a/include/linux/slab_def.h
77892 +++ b/include/linux/slab_def.h
77893 @@ -36,7 +36,7 @@ struct kmem_cache {
77894 /* 4) cache creation/removal */
77895 const char *name;
77896 struct list_head list;
77897 - int refcount;
77898 + atomic_t refcount;
77899 int object_size;
77900 int align;
77901
77902 @@ -52,10 +52,14 @@ struct kmem_cache {
77903 unsigned long node_allocs;
77904 unsigned long node_frees;
77905 unsigned long node_overflow;
77906 - atomic_t allochit;
77907 - atomic_t allocmiss;
77908 - atomic_t freehit;
77909 - atomic_t freemiss;
77910 + atomic_unchecked_t allochit;
77911 + atomic_unchecked_t allocmiss;
77912 + atomic_unchecked_t freehit;
77913 + atomic_unchecked_t freemiss;
77914 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
77915 + atomic_unchecked_t sanitized;
77916 + atomic_unchecked_t not_sanitized;
77917 +#endif
77918
77919 /*
77920 * If debugging is enabled, then the allocator can add additional
77921 diff --git a/include/linux/slub_def.h b/include/linux/slub_def.h
77922 index cc0b67e..a0329b1 100644
77923 --- a/include/linux/slub_def.h
77924 +++ b/include/linux/slub_def.h
77925 @@ -74,7 +74,7 @@ struct kmem_cache {
77926 struct kmem_cache_order_objects max;
77927 struct kmem_cache_order_objects min;
77928 gfp_t allocflags; /* gfp flags to use on each alloc */
77929 - int refcount; /* Refcount for slab cache destroy */
77930 + atomic_t refcount; /* Refcount for slab cache destroy */
77931 void (*ctor)(void *);
77932 int inuse; /* Offset to metadata */
77933 int align; /* Alignment */
77934 diff --git a/include/linux/smp.h b/include/linux/smp.h
77935 index 731f523..3340268 100644
77936 --- a/include/linux/smp.h
77937 +++ b/include/linux/smp.h
77938 @@ -186,7 +186,9 @@ static inline void __smp_call_function_single(int cpuid,
77939 #endif
77940
77941 #define get_cpu() ({ preempt_disable(); smp_processor_id(); })
77942 +#define raw_get_cpu() ({ raw_preempt_disable(); raw_smp_processor_id(); })
77943 #define put_cpu() preempt_enable()
77944 +#define raw_put_cpu_no_resched() raw_preempt_enable_no_resched()
77945
77946 /*
77947 * Callback to arch code if there's nosmp or maxcpus=0 on the
77948 diff --git a/include/linux/sock_diag.h b/include/linux/sock_diag.h
77949 index 54f91d3..be2c379 100644
77950 --- a/include/linux/sock_diag.h
77951 +++ b/include/linux/sock_diag.h
77952 @@ -11,7 +11,7 @@ struct sock;
77953 struct sock_diag_handler {
77954 __u8 family;
77955 int (*dump)(struct sk_buff *skb, struct nlmsghdr *nlh);
77956 -};
77957 +} __do_const;
77958
77959 int sock_diag_register(const struct sock_diag_handler *h);
77960 void sock_diag_unregister(const struct sock_diag_handler *h);
77961 diff --git a/include/linux/sonet.h b/include/linux/sonet.h
77962 index 680f9a3..f13aeb0 100644
77963 --- a/include/linux/sonet.h
77964 +++ b/include/linux/sonet.h
77965 @@ -7,7 +7,7 @@
77966 #include <uapi/linux/sonet.h>
77967
77968 struct k_sonet_stats {
77969 -#define __HANDLE_ITEM(i) atomic_t i
77970 +#define __HANDLE_ITEM(i) atomic_unchecked_t i
77971 __SONET_ITEMS
77972 #undef __HANDLE_ITEM
77973 };
77974 diff --git a/include/linux/sunrpc/addr.h b/include/linux/sunrpc/addr.h
77975 index 07d8e53..dc934c9 100644
77976 --- a/include/linux/sunrpc/addr.h
77977 +++ b/include/linux/sunrpc/addr.h
77978 @@ -23,9 +23,9 @@ static inline unsigned short rpc_get_port(const struct sockaddr *sap)
77979 {
77980 switch (sap->sa_family) {
77981 case AF_INET:
77982 - return ntohs(((struct sockaddr_in *)sap)->sin_port);
77983 + return ntohs(((const struct sockaddr_in *)sap)->sin_port);
77984 case AF_INET6:
77985 - return ntohs(((struct sockaddr_in6 *)sap)->sin6_port);
77986 + return ntohs(((const struct sockaddr_in6 *)sap)->sin6_port);
77987 }
77988 return 0;
77989 }
77990 @@ -58,7 +58,7 @@ static inline bool __rpc_cmp_addr4(const struct sockaddr *sap1,
77991 static inline bool __rpc_copy_addr4(struct sockaddr *dst,
77992 const struct sockaddr *src)
77993 {
77994 - const struct sockaddr_in *ssin = (struct sockaddr_in *) src;
77995 + const struct sockaddr_in *ssin = (const struct sockaddr_in *) src;
77996 struct sockaddr_in *dsin = (struct sockaddr_in *) dst;
77997
77998 dsin->sin_family = ssin->sin_family;
77999 @@ -164,7 +164,7 @@ static inline u32 rpc_get_scope_id(const struct sockaddr *sa)
78000 if (sa->sa_family != AF_INET6)
78001 return 0;
78002
78003 - return ((struct sockaddr_in6 *) sa)->sin6_scope_id;
78004 + return ((const struct sockaddr_in6 *) sa)->sin6_scope_id;
78005 }
78006
78007 #endif /* _LINUX_SUNRPC_ADDR_H */
78008 diff --git a/include/linux/sunrpc/clnt.h b/include/linux/sunrpc/clnt.h
78009 index 6740801..c535f27 100644
78010 --- a/include/linux/sunrpc/clnt.h
78011 +++ b/include/linux/sunrpc/clnt.h
78012 @@ -96,7 +96,7 @@ struct rpc_procinfo {
78013 unsigned int p_timer; /* Which RTT timer to use */
78014 u32 p_statidx; /* Which procedure to account */
78015 const char * p_name; /* name of procedure */
78016 -};
78017 +} __do_const;
78018
78019 #ifdef __KERNEL__
78020
78021 diff --git a/include/linux/sunrpc/svc.h b/include/linux/sunrpc/svc.h
78022 index 6eecfc2..7ada79d 100644
78023 --- a/include/linux/sunrpc/svc.h
78024 +++ b/include/linux/sunrpc/svc.h
78025 @@ -410,7 +410,7 @@ struct svc_procedure {
78026 unsigned int pc_count; /* call count */
78027 unsigned int pc_cachetype; /* cache info (NFS) */
78028 unsigned int pc_xdrressize; /* maximum size of XDR reply */
78029 -};
78030 +} __do_const;
78031
78032 /*
78033 * Function prototypes.
78034 diff --git a/include/linux/sunrpc/svc_rdma.h b/include/linux/sunrpc/svc_rdma.h
78035 index 0b8e3e6..33e0a01 100644
78036 --- a/include/linux/sunrpc/svc_rdma.h
78037 +++ b/include/linux/sunrpc/svc_rdma.h
78038 @@ -53,15 +53,15 @@ extern unsigned int svcrdma_ord;
78039 extern unsigned int svcrdma_max_requests;
78040 extern unsigned int svcrdma_max_req_size;
78041
78042 -extern atomic_t rdma_stat_recv;
78043 -extern atomic_t rdma_stat_read;
78044 -extern atomic_t rdma_stat_write;
78045 -extern atomic_t rdma_stat_sq_starve;
78046 -extern atomic_t rdma_stat_rq_starve;
78047 -extern atomic_t rdma_stat_rq_poll;
78048 -extern atomic_t rdma_stat_rq_prod;
78049 -extern atomic_t rdma_stat_sq_poll;
78050 -extern atomic_t rdma_stat_sq_prod;
78051 +extern atomic_unchecked_t rdma_stat_recv;
78052 +extern atomic_unchecked_t rdma_stat_read;
78053 +extern atomic_unchecked_t rdma_stat_write;
78054 +extern atomic_unchecked_t rdma_stat_sq_starve;
78055 +extern atomic_unchecked_t rdma_stat_rq_starve;
78056 +extern atomic_unchecked_t rdma_stat_rq_poll;
78057 +extern atomic_unchecked_t rdma_stat_rq_prod;
78058 +extern atomic_unchecked_t rdma_stat_sq_poll;
78059 +extern atomic_unchecked_t rdma_stat_sq_prod;
78060
78061 #define RPCRDMA_VERSION 1
78062
78063 diff --git a/include/linux/sunrpc/svcauth.h b/include/linux/sunrpc/svcauth.h
78064 index 8d71d65..f79586e 100644
78065 --- a/include/linux/sunrpc/svcauth.h
78066 +++ b/include/linux/sunrpc/svcauth.h
78067 @@ -120,7 +120,7 @@ struct auth_ops {
78068 int (*release)(struct svc_rqst *rq);
78069 void (*domain_release)(struct auth_domain *);
78070 int (*set_client)(struct svc_rqst *rq);
78071 -};
78072 +} __do_const;
78073
78074 #define SVC_GARBAGE 1
78075 #define SVC_SYSERR 2
78076 diff --git a/include/linux/swiotlb.h b/include/linux/swiotlb.h
78077 index a5ffd32..0935dea 100644
78078 --- a/include/linux/swiotlb.h
78079 +++ b/include/linux/swiotlb.h
78080 @@ -60,7 +60,8 @@ extern void
78081
78082 extern void
78083 swiotlb_free_coherent(struct device *hwdev, size_t size,
78084 - void *vaddr, dma_addr_t dma_handle);
78085 + void *vaddr, dma_addr_t dma_handle,
78086 + struct dma_attrs *attrs);
78087
78088 extern dma_addr_t swiotlb_map_page(struct device *dev, struct page *page,
78089 unsigned long offset, size_t size,
78090 diff --git a/include/linux/syscalls.h b/include/linux/syscalls.h
78091 index 7fac04e..de57300 100644
78092 --- a/include/linux/syscalls.h
78093 +++ b/include/linux/syscalls.h
78094 @@ -97,8 +97,14 @@ struct sigaltstack;
78095 #define __MAP(n,...) __MAP##n(__VA_ARGS__)
78096
78097 #define __SC_DECL(t, a) t a
78098 +#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))
78099 #define __TYPE_IS_LL(t) (__same_type((t)0, 0LL) || __same_type((t)0, 0ULL))
78100 -#define __SC_LONG(t, a) __typeof(__builtin_choose_expr(__TYPE_IS_LL(t), 0LL, 0L)) a
78101 +#define __SC_LONG(t, a) __typeof( \
78102 + __builtin_choose_expr( \
78103 + sizeof(t) > sizeof(int), \
78104 + (t) 0, \
78105 + __builtin_choose_expr(__TYPE_IS_U(t), 0UL, 0L) \
78106 + )) a
78107 #define __SC_CAST(t, a) (t) a
78108 #define __SC_ARGS(t, a) a
78109 #define __SC_TEST(t, a) (void)BUILD_BUG_ON_ZERO(!__TYPE_IS_LL(t) && sizeof(t) > sizeof(long))
78110 @@ -363,11 +369,11 @@ asmlinkage long sys_sync(void);
78111 asmlinkage long sys_fsync(unsigned int fd);
78112 asmlinkage long sys_fdatasync(unsigned int fd);
78113 asmlinkage long sys_bdflush(int func, long data);
78114 -asmlinkage long sys_mount(char __user *dev_name, char __user *dir_name,
78115 - char __user *type, unsigned long flags,
78116 +asmlinkage long sys_mount(const char __user *dev_name, const char __user *dir_name,
78117 + const char __user *type, unsigned long flags,
78118 void __user *data);
78119 -asmlinkage long sys_umount(char __user *name, int flags);
78120 -asmlinkage long sys_oldumount(char __user *name);
78121 +asmlinkage long sys_umount(const char __user *name, int flags);
78122 +asmlinkage long sys_oldumount(const char __user *name);
78123 asmlinkage long sys_truncate(const char __user *path, long length);
78124 asmlinkage long sys_ftruncate(unsigned int fd, unsigned long length);
78125 asmlinkage long sys_stat(const char __user *filename,
78126 @@ -579,7 +585,7 @@ asmlinkage long sys_getsockname(int, struct sockaddr __user *, int __user *);
78127 asmlinkage long sys_getpeername(int, struct sockaddr __user *, int __user *);
78128 asmlinkage long sys_send(int, void __user *, size_t, unsigned);
78129 asmlinkage long sys_sendto(int, void __user *, size_t, unsigned,
78130 - struct sockaddr __user *, int);
78131 + struct sockaddr __user *, int) __intentional_overflow(0);
78132 asmlinkage long sys_sendmsg(int fd, struct msghdr __user *msg, unsigned flags);
78133 asmlinkage long sys_sendmmsg(int fd, struct mmsghdr __user *msg,
78134 unsigned int vlen, unsigned flags);
78135 diff --git a/include/linux/syscore_ops.h b/include/linux/syscore_ops.h
78136 index 27b3b0b..e093dd9 100644
78137 --- a/include/linux/syscore_ops.h
78138 +++ b/include/linux/syscore_ops.h
78139 @@ -16,7 +16,7 @@ struct syscore_ops {
78140 int (*suspend)(void);
78141 void (*resume)(void);
78142 void (*shutdown)(void);
78143 -};
78144 +} __do_const;
78145
78146 extern void register_syscore_ops(struct syscore_ops *ops);
78147 extern void unregister_syscore_ops(struct syscore_ops *ops);
78148 diff --git a/include/linux/sysctl.h b/include/linux/sysctl.h
78149 index 14a8ff2..af52bad 100644
78150 --- a/include/linux/sysctl.h
78151 +++ b/include/linux/sysctl.h
78152 @@ -34,13 +34,13 @@ struct ctl_table_root;
78153 struct ctl_table_header;
78154 struct ctl_dir;
78155
78156 -typedef struct ctl_table ctl_table;
78157 -
78158 typedef int proc_handler (struct ctl_table *ctl, int write,
78159 void __user *buffer, size_t *lenp, loff_t *ppos);
78160
78161 extern int proc_dostring(struct ctl_table *, int,
78162 void __user *, size_t *, loff_t *);
78163 +extern int proc_dostring_modpriv(struct ctl_table *, int,
78164 + void __user *, size_t *, loff_t *);
78165 extern int proc_dointvec(struct ctl_table *, int,
78166 void __user *, size_t *, loff_t *);
78167 extern int proc_dointvec_minmax(struct ctl_table *, int,
78168 @@ -115,7 +115,9 @@ struct ctl_table
78169 struct ctl_table_poll *poll;
78170 void *extra1;
78171 void *extra2;
78172 -};
78173 +} __do_const;
78174 +typedef struct ctl_table __no_const ctl_table_no_const;
78175 +typedef struct ctl_table ctl_table;
78176
78177 struct ctl_node {
78178 struct rb_node node;
78179 diff --git a/include/linux/sysfs.h b/include/linux/sysfs.h
78180 index 11baec7..706f99f 100644
78181 --- a/include/linux/sysfs.h
78182 +++ b/include/linux/sysfs.h
78183 @@ -33,7 +33,8 @@ struct attribute {
78184 struct lock_class_key *key;
78185 struct lock_class_key skey;
78186 #endif
78187 -};
78188 +} __do_const;
78189 +typedef struct attribute __no_const attribute_no_const;
78190
78191 /**
78192 * sysfs_attr_init - initialize a dynamically allocated sysfs attribute
78193 @@ -62,7 +63,8 @@ struct attribute_group {
78194 struct attribute *, int);
78195 struct attribute **attrs;
78196 struct bin_attribute **bin_attrs;
78197 -};
78198 +} __do_const;
78199 +typedef struct attribute_group __no_const attribute_group_no_const;
78200
78201 /**
78202 * Use these macros to make defining attributes easier. See include/linux/device.h
78203 @@ -126,7 +128,8 @@ struct bin_attribute {
78204 char *, loff_t, size_t);
78205 int (*mmap)(struct file *, struct kobject *, struct bin_attribute *attr,
78206 struct vm_area_struct *vma);
78207 -};
78208 +} __do_const;
78209 +typedef struct bin_attribute __no_const bin_attribute_no_const;
78210
78211 /**
78212 * sysfs_bin_attr_init - initialize a dynamically allocated bin_attribute
78213 diff --git a/include/linux/sysrq.h b/include/linux/sysrq.h
78214 index 7faf933..9b85a0c 100644
78215 --- a/include/linux/sysrq.h
78216 +++ b/include/linux/sysrq.h
78217 @@ -16,6 +16,7 @@
78218
78219 #include <linux/errno.h>
78220 #include <linux/types.h>
78221 +#include <linux/compiler.h>
78222
78223 /* Enable/disable SYSRQ support by default (0==no, 1==yes). */
78224 #define SYSRQ_DEFAULT_ENABLE 1
78225 @@ -36,7 +37,7 @@ struct sysrq_key_op {
78226 char *help_msg;
78227 char *action_msg;
78228 int enable_mask;
78229 -};
78230 +} __do_const;
78231
78232 #ifdef CONFIG_MAGIC_SYSRQ
78233
78234 diff --git a/include/linux/thread_info.h b/include/linux/thread_info.h
78235 index 4ae6f32..425d3e1 100644
78236 --- a/include/linux/thread_info.h
78237 +++ b/include/linux/thread_info.h
78238 @@ -150,6 +150,15 @@ static inline bool test_and_clear_restore_sigmask(void)
78239 #error "no set_restore_sigmask() provided and default one won't work"
78240 #endif
78241
78242 +extern void __check_object_size(const void *ptr, unsigned long n, bool to_user);
78243 +static inline void check_object_size(const void *ptr, unsigned long n, bool to_user)
78244 +{
78245 +#ifndef CONFIG_PAX_USERCOPY_DEBUG
78246 + if (!__builtin_constant_p(n))
78247 +#endif
78248 + __check_object_size(ptr, n, to_user);
78249 +}
78250 +
78251 #endif /* __KERNEL__ */
78252
78253 #endif /* _LINUX_THREAD_INFO_H */
78254 diff --git a/include/linux/tty.h b/include/linux/tty.h
78255 index 64f8646..1515fc7 100644
78256 --- a/include/linux/tty.h
78257 +++ b/include/linux/tty.h
78258 @@ -197,7 +197,7 @@ struct tty_port {
78259 const struct tty_port_operations *ops; /* Port operations */
78260 spinlock_t lock; /* Lock protecting tty field */
78261 int blocked_open; /* Waiting to open */
78262 - int count; /* Usage count */
78263 + atomic_t count; /* Usage count */
78264 wait_queue_head_t open_wait; /* Open waiters */
78265 wait_queue_head_t close_wait; /* Close waiters */
78266 wait_queue_head_t delta_msr_wait; /* Modem status change */
78267 @@ -546,7 +546,7 @@ extern int tty_port_open(struct tty_port *port,
78268 struct tty_struct *tty, struct file *filp);
78269 static inline int tty_port_users(struct tty_port *port)
78270 {
78271 - return port->count + port->blocked_open;
78272 + return atomic_read(&port->count) + port->blocked_open;
78273 }
78274
78275 extern int tty_register_ldisc(int disc, struct tty_ldisc_ops *new_ldisc);
78276 diff --git a/include/linux/tty_driver.h b/include/linux/tty_driver.h
78277 index 756a609..b302dd6 100644
78278 --- a/include/linux/tty_driver.h
78279 +++ b/include/linux/tty_driver.h
78280 @@ -285,7 +285,7 @@ struct tty_operations {
78281 void (*poll_put_char)(struct tty_driver *driver, int line, char ch);
78282 #endif
78283 const struct file_operations *proc_fops;
78284 -};
78285 +} __do_const;
78286
78287 struct tty_driver {
78288 int magic; /* magic number for this structure */
78289 diff --git a/include/linux/tty_ldisc.h b/include/linux/tty_ldisc.h
78290 index f15c898..207b7d1 100644
78291 --- a/include/linux/tty_ldisc.h
78292 +++ b/include/linux/tty_ldisc.h
78293 @@ -211,7 +211,7 @@ struct tty_ldisc_ops {
78294
78295 struct module *owner;
78296
78297 - int refcount;
78298 + atomic_t refcount;
78299 };
78300
78301 struct tty_ldisc {
78302 diff --git a/include/linux/types.h b/include/linux/types.h
78303 index 4d118ba..c3ee9bf 100644
78304 --- a/include/linux/types.h
78305 +++ b/include/linux/types.h
78306 @@ -176,10 +176,26 @@ typedef struct {
78307 int counter;
78308 } atomic_t;
78309
78310 +#ifdef CONFIG_PAX_REFCOUNT
78311 +typedef struct {
78312 + int counter;
78313 +} atomic_unchecked_t;
78314 +#else
78315 +typedef atomic_t atomic_unchecked_t;
78316 +#endif
78317 +
78318 #ifdef CONFIG_64BIT
78319 typedef struct {
78320 long counter;
78321 } atomic64_t;
78322 +
78323 +#ifdef CONFIG_PAX_REFCOUNT
78324 +typedef struct {
78325 + long counter;
78326 +} atomic64_unchecked_t;
78327 +#else
78328 +typedef atomic64_t atomic64_unchecked_t;
78329 +#endif
78330 #endif
78331
78332 struct list_head {
78333 diff --git a/include/linux/uaccess.h b/include/linux/uaccess.h
78334 index 5ca0951..ab496a5 100644
78335 --- a/include/linux/uaccess.h
78336 +++ b/include/linux/uaccess.h
78337 @@ -76,11 +76,11 @@ static inline unsigned long __copy_from_user_nocache(void *to,
78338 long ret; \
78339 mm_segment_t old_fs = get_fs(); \
78340 \
78341 - set_fs(KERNEL_DS); \
78342 pagefault_disable(); \
78343 - ret = __copy_from_user_inatomic(&(retval), (__force typeof(retval) __user *)(addr), sizeof(retval)); \
78344 - pagefault_enable(); \
78345 + set_fs(KERNEL_DS); \
78346 + ret = __copy_from_user_inatomic(&(retval), (typeof(retval) __force_user *)(addr), sizeof(retval)); \
78347 set_fs(old_fs); \
78348 + pagefault_enable(); \
78349 ret; \
78350 })
78351
78352 diff --git a/include/linux/uidgid.h b/include/linux/uidgid.h
78353 index 8e522cbc..aa8572d 100644
78354 --- a/include/linux/uidgid.h
78355 +++ b/include/linux/uidgid.h
78356 @@ -197,4 +197,9 @@ static inline bool kgid_has_mapping(struct user_namespace *ns, kgid_t gid)
78357
78358 #endif /* CONFIG_USER_NS */
78359
78360 +#define GR_GLOBAL_UID(x) from_kuid_munged(&init_user_ns, (x))
78361 +#define GR_GLOBAL_GID(x) from_kgid_munged(&init_user_ns, (x))
78362 +#define gr_is_global_root(x) uid_eq((x), GLOBAL_ROOT_UID)
78363 +#define gr_is_global_nonroot(x) (!uid_eq((x), GLOBAL_ROOT_UID))
78364 +
78365 #endif /* _LINUX_UIDGID_H */
78366 diff --git a/include/linux/unaligned/access_ok.h b/include/linux/unaligned/access_ok.h
78367 index 99c1b4d..562e6f3 100644
78368 --- a/include/linux/unaligned/access_ok.h
78369 +++ b/include/linux/unaligned/access_ok.h
78370 @@ -4,34 +4,34 @@
78371 #include <linux/kernel.h>
78372 #include <asm/byteorder.h>
78373
78374 -static inline u16 get_unaligned_le16(const void *p)
78375 +static inline u16 __intentional_overflow(-1) get_unaligned_le16(const void *p)
78376 {
78377 - return le16_to_cpup((__le16 *)p);
78378 + return le16_to_cpup((const __le16 *)p);
78379 }
78380
78381 -static inline u32 get_unaligned_le32(const void *p)
78382 +static inline u32 __intentional_overflow(-1) get_unaligned_le32(const void *p)
78383 {
78384 - return le32_to_cpup((__le32 *)p);
78385 + return le32_to_cpup((const __le32 *)p);
78386 }
78387
78388 -static inline u64 get_unaligned_le64(const void *p)
78389 +static inline u64 __intentional_overflow(-1) get_unaligned_le64(const void *p)
78390 {
78391 - return le64_to_cpup((__le64 *)p);
78392 + return le64_to_cpup((const __le64 *)p);
78393 }
78394
78395 -static inline u16 get_unaligned_be16(const void *p)
78396 +static inline u16 __intentional_overflow(-1) get_unaligned_be16(const void *p)
78397 {
78398 - return be16_to_cpup((__be16 *)p);
78399 + return be16_to_cpup((const __be16 *)p);
78400 }
78401
78402 -static inline u32 get_unaligned_be32(const void *p)
78403 +static inline u32 __intentional_overflow(-1) get_unaligned_be32(const void *p)
78404 {
78405 - return be32_to_cpup((__be32 *)p);
78406 + return be32_to_cpup((const __be32 *)p);
78407 }
78408
78409 -static inline u64 get_unaligned_be64(const void *p)
78410 +static inline u64 __intentional_overflow(-1) get_unaligned_be64(const void *p)
78411 {
78412 - return be64_to_cpup((__be64 *)p);
78413 + return be64_to_cpup((const __be64 *)p);
78414 }
78415
78416 static inline void put_unaligned_le16(u16 val, void *p)
78417 diff --git a/include/linux/usb.h b/include/linux/usb.h
78418 index 39cfa0a..d45fa38 100644
78419 --- a/include/linux/usb.h
78420 +++ b/include/linux/usb.h
78421 @@ -563,7 +563,7 @@ struct usb_device {
78422 int maxchild;
78423
78424 u32 quirks;
78425 - atomic_t urbnum;
78426 + atomic_unchecked_t urbnum;
78427
78428 unsigned long active_duration;
78429
78430 @@ -1637,7 +1637,7 @@ void usb_buffer_unmap_sg(const struct usb_device *dev, int is_in,
78431
78432 extern int usb_control_msg(struct usb_device *dev, unsigned int pipe,
78433 __u8 request, __u8 requesttype, __u16 value, __u16 index,
78434 - void *data, __u16 size, int timeout);
78435 + void *data, __u16 size, int timeout) __intentional_overflow(-1);
78436 extern int usb_interrupt_msg(struct usb_device *usb_dev, unsigned int pipe,
78437 void *data, int len, int *actual_length, int timeout);
78438 extern int usb_bulk_msg(struct usb_device *usb_dev, unsigned int pipe,
78439 diff --git a/include/linux/usb/renesas_usbhs.h b/include/linux/usb/renesas_usbhs.h
78440 index e452ba6..78f8e80 100644
78441 --- a/include/linux/usb/renesas_usbhs.h
78442 +++ b/include/linux/usb/renesas_usbhs.h
78443 @@ -39,7 +39,7 @@ enum {
78444 */
78445 struct renesas_usbhs_driver_callback {
78446 int (*notify_hotplug)(struct platform_device *pdev);
78447 -};
78448 +} __no_const;
78449
78450 /*
78451 * callback functions for platform
78452 diff --git a/include/linux/vermagic.h b/include/linux/vermagic.h
78453 index 6f8fbcf..8259001 100644
78454 --- a/include/linux/vermagic.h
78455 +++ b/include/linux/vermagic.h
78456 @@ -25,9 +25,35 @@
78457 #define MODULE_ARCH_VERMAGIC ""
78458 #endif
78459
78460 +#ifdef CONFIG_PAX_REFCOUNT
78461 +#define MODULE_PAX_REFCOUNT "REFCOUNT "
78462 +#else
78463 +#define MODULE_PAX_REFCOUNT ""
78464 +#endif
78465 +
78466 +#ifdef CONSTIFY_PLUGIN
78467 +#define MODULE_CONSTIFY_PLUGIN "CONSTIFY_PLUGIN "
78468 +#else
78469 +#define MODULE_CONSTIFY_PLUGIN ""
78470 +#endif
78471 +
78472 +#ifdef STACKLEAK_PLUGIN
78473 +#define MODULE_STACKLEAK_PLUGIN "STACKLEAK_PLUGIN "
78474 +#else
78475 +#define MODULE_STACKLEAK_PLUGIN ""
78476 +#endif
78477 +
78478 +#ifdef CONFIG_GRKERNSEC
78479 +#define MODULE_GRSEC "GRSEC "
78480 +#else
78481 +#define MODULE_GRSEC ""
78482 +#endif
78483 +
78484 #define VERMAGIC_STRING \
78485 UTS_RELEASE " " \
78486 MODULE_VERMAGIC_SMP MODULE_VERMAGIC_PREEMPT \
78487 MODULE_VERMAGIC_MODULE_UNLOAD MODULE_VERMAGIC_MODVERSIONS \
78488 - MODULE_ARCH_VERMAGIC
78489 + MODULE_ARCH_VERMAGIC \
78490 + MODULE_PAX_REFCOUNT MODULE_CONSTIFY_PLUGIN MODULE_STACKLEAK_PLUGIN \
78491 + MODULE_GRSEC
78492
78493 diff --git a/include/linux/vga_switcheroo.h b/include/linux/vga_switcheroo.h
78494 index 502073a..a7de024 100644
78495 --- a/include/linux/vga_switcheroo.h
78496 +++ b/include/linux/vga_switcheroo.h
78497 @@ -63,8 +63,8 @@ int vga_switcheroo_get_client_state(struct pci_dev *dev);
78498
78499 void vga_switcheroo_set_dynamic_switch(struct pci_dev *pdev, enum vga_switcheroo_state dynamic);
78500
78501 -int vga_switcheroo_init_domain_pm_ops(struct device *dev, struct dev_pm_domain *domain);
78502 -int vga_switcheroo_init_domain_pm_optimus_hdmi_audio(struct device *dev, struct dev_pm_domain *domain);
78503 +int vga_switcheroo_init_domain_pm_ops(struct device *dev, dev_pm_domain_no_const *domain);
78504 +int vga_switcheroo_init_domain_pm_optimus_hdmi_audio(struct device *dev, dev_pm_domain_no_const *domain);
78505 #else
78506
78507 static inline void vga_switcheroo_unregister_client(struct pci_dev *dev) {}
78508 @@ -81,8 +81,8 @@ static inline int vga_switcheroo_get_client_state(struct pci_dev *dev) { return
78509
78510 static inline void vga_switcheroo_set_dynamic_switch(struct pci_dev *pdev, enum vga_switcheroo_state dynamic) {}
78511
78512 -static inline int vga_switcheroo_init_domain_pm_ops(struct device *dev, struct dev_pm_domain *domain) { return -EINVAL; }
78513 -static inline int vga_switcheroo_init_domain_pm_optimus_hdmi_audio(struct device *dev, struct dev_pm_domain *domain) { return -EINVAL; }
78514 +static inline int vga_switcheroo_init_domain_pm_ops(struct device *dev, dev_pm_domain_no_const *domain) { return -EINVAL; }
78515 +static inline int vga_switcheroo_init_domain_pm_optimus_hdmi_audio(struct device *dev, dev_pm_domain_no_const *domain) { return -EINVAL; }
78516
78517 #endif
78518 #endif /* _LINUX_VGA_SWITCHEROO_H_ */
78519 diff --git a/include/linux/vmalloc.h b/include/linux/vmalloc.h
78520 index 4b8a891..cb8df6e 100644
78521 --- a/include/linux/vmalloc.h
78522 +++ b/include/linux/vmalloc.h
78523 @@ -16,6 +16,11 @@ struct vm_area_struct; /* vma defining user mapping in mm_types.h */
78524 #define VM_USERMAP 0x00000008 /* suitable for remap_vmalloc_range */
78525 #define VM_VPAGES 0x00000010 /* buffer for pages was vmalloc'ed */
78526 #define VM_UNINITIALIZED 0x00000020 /* vm_struct is not fully initialized */
78527 +
78528 +#if defined(CONFIG_X86) && defined(CONFIG_PAX_KERNEXEC)
78529 +#define VM_KERNEXEC 0x00000040 /* allocate from executable kernel memory range */
78530 +#endif
78531 +
78532 /* bits [20..32] reserved for arch specific ioremap internals */
78533
78534 /*
78535 @@ -142,7 +147,7 @@ extern void free_vm_area(struct vm_struct *area);
78536
78537 /* for /dev/kmem */
78538 extern long vread(char *buf, char *addr, unsigned long count);
78539 -extern long vwrite(char *buf, char *addr, unsigned long count);
78540 +extern long vwrite(char *buf, char *addr, unsigned long count) __size_overflow(3);
78541
78542 /*
78543 * Internals. Dont't use..
78544 diff --git a/include/linux/vmstat.h b/include/linux/vmstat.h
78545 index e4b9480..5a5f65a 100644
78546 --- a/include/linux/vmstat.h
78547 +++ b/include/linux/vmstat.h
78548 @@ -90,18 +90,18 @@ static inline void vm_events_fold_cpu(int cpu)
78549 /*
78550 * Zone based page accounting with per cpu differentials.
78551 */
78552 -extern atomic_long_t vm_stat[NR_VM_ZONE_STAT_ITEMS];
78553 +extern atomic_long_unchecked_t vm_stat[NR_VM_ZONE_STAT_ITEMS];
78554
78555 static inline void zone_page_state_add(long x, struct zone *zone,
78556 enum zone_stat_item item)
78557 {
78558 - atomic_long_add(x, &zone->vm_stat[item]);
78559 - atomic_long_add(x, &vm_stat[item]);
78560 + atomic_long_add_unchecked(x, &zone->vm_stat[item]);
78561 + atomic_long_add_unchecked(x, &vm_stat[item]);
78562 }
78563
78564 -static inline unsigned long global_page_state(enum zone_stat_item item)
78565 +static inline unsigned long __intentional_overflow(-1) global_page_state(enum zone_stat_item item)
78566 {
78567 - long x = atomic_long_read(&vm_stat[item]);
78568 + long x = atomic_long_read_unchecked(&vm_stat[item]);
78569 #ifdef CONFIG_SMP
78570 if (x < 0)
78571 x = 0;
78572 @@ -109,10 +109,10 @@ static inline unsigned long global_page_state(enum zone_stat_item item)
78573 return x;
78574 }
78575
78576 -static inline unsigned long zone_page_state(struct zone *zone,
78577 +static inline unsigned long __intentional_overflow(-1) zone_page_state(struct zone *zone,
78578 enum zone_stat_item item)
78579 {
78580 - long x = atomic_long_read(&zone->vm_stat[item]);
78581 + long x = atomic_long_read_unchecked(&zone->vm_stat[item]);
78582 #ifdef CONFIG_SMP
78583 if (x < 0)
78584 x = 0;
78585 @@ -129,7 +129,7 @@ static inline unsigned long zone_page_state(struct zone *zone,
78586 static inline unsigned long zone_page_state_snapshot(struct zone *zone,
78587 enum zone_stat_item item)
78588 {
78589 - long x = atomic_long_read(&zone->vm_stat[item]);
78590 + long x = atomic_long_read_unchecked(&zone->vm_stat[item]);
78591
78592 #ifdef CONFIG_SMP
78593 int cpu;
78594 @@ -220,8 +220,8 @@ static inline void __mod_zone_page_state(struct zone *zone,
78595
78596 static inline void __inc_zone_state(struct zone *zone, enum zone_stat_item item)
78597 {
78598 - atomic_long_inc(&zone->vm_stat[item]);
78599 - atomic_long_inc(&vm_stat[item]);
78600 + atomic_long_inc_unchecked(&zone->vm_stat[item]);
78601 + atomic_long_inc_unchecked(&vm_stat[item]);
78602 }
78603
78604 static inline void __inc_zone_page_state(struct page *page,
78605 @@ -232,8 +232,8 @@ static inline void __inc_zone_page_state(struct page *page,
78606
78607 static inline void __dec_zone_state(struct zone *zone, enum zone_stat_item item)
78608 {
78609 - atomic_long_dec(&zone->vm_stat[item]);
78610 - atomic_long_dec(&vm_stat[item]);
78611 + atomic_long_dec_unchecked(&zone->vm_stat[item]);
78612 + atomic_long_dec_unchecked(&vm_stat[item]);
78613 }
78614
78615 static inline void __dec_zone_page_state(struct page *page,
78616 diff --git a/include/linux/xattr.h b/include/linux/xattr.h
78617 index 91b0a68..0e9adf6 100644
78618 --- a/include/linux/xattr.h
78619 +++ b/include/linux/xattr.h
78620 @@ -28,7 +28,7 @@ struct xattr_handler {
78621 size_t size, int handler_flags);
78622 int (*set)(struct dentry *dentry, const char *name, const void *buffer,
78623 size_t size, int flags, int handler_flags);
78624 -};
78625 +} __do_const;
78626
78627 struct xattr {
78628 const char *name;
78629 @@ -37,6 +37,9 @@ struct xattr {
78630 };
78631
78632 ssize_t xattr_getsecurity(struct inode *, const char *, void *, size_t);
78633 +#ifdef CONFIG_PAX_XATTR_PAX_FLAGS
78634 +ssize_t pax_getxattr(struct dentry *, void *, size_t);
78635 +#endif
78636 ssize_t vfs_getxattr(struct dentry *, const char *, void *, size_t);
78637 ssize_t vfs_listxattr(struct dentry *d, char *list, size_t size);
78638 int __vfs_setxattr_noperm(struct dentry *, const char *, const void *, size_t, int);
78639 diff --git a/include/linux/zlib.h b/include/linux/zlib.h
78640 index 9c5a6b4..09c9438 100644
78641 --- a/include/linux/zlib.h
78642 +++ b/include/linux/zlib.h
78643 @@ -31,6 +31,7 @@
78644 #define _ZLIB_H
78645
78646 #include <linux/zconf.h>
78647 +#include <linux/compiler.h>
78648
78649 /* zlib deflate based on ZLIB_VERSION "1.1.3" */
78650 /* zlib inflate based on ZLIB_VERSION "1.2.3" */
78651 @@ -179,7 +180,7 @@ typedef z_stream *z_streamp;
78652
78653 /* basic functions */
78654
78655 -extern int zlib_deflate_workspacesize (int windowBits, int memLevel);
78656 +extern int zlib_deflate_workspacesize (int windowBits, int memLevel) __intentional_overflow(0);
78657 /*
78658 Returns the number of bytes that needs to be allocated for a per-
78659 stream workspace with the specified parameters. A pointer to this
78660 diff --git a/include/media/v4l2-dev.h b/include/media/v4l2-dev.h
78661 index c768c9f..bdcaa5a 100644
78662 --- a/include/media/v4l2-dev.h
78663 +++ b/include/media/v4l2-dev.h
78664 @@ -76,7 +76,7 @@ struct v4l2_file_operations {
78665 int (*mmap) (struct file *, struct vm_area_struct *);
78666 int (*open) (struct file *);
78667 int (*release) (struct file *);
78668 -};
78669 +} __do_const;
78670
78671 /*
78672 * Newer version of video_device, handled by videodev2.c
78673 diff --git a/include/media/v4l2-device.h b/include/media/v4l2-device.h
78674 index c9b1593..a572459 100644
78675 --- a/include/media/v4l2-device.h
78676 +++ b/include/media/v4l2-device.h
78677 @@ -95,7 +95,7 @@ int __must_check v4l2_device_register(struct device *dev, struct v4l2_device *v4
78678 this function returns 0. If the name ends with a digit (e.g. cx18),
78679 then the name will be set to cx18-0 since cx180 looks really odd. */
78680 int v4l2_device_set_name(struct v4l2_device *v4l2_dev, const char *basename,
78681 - atomic_t *instance);
78682 + atomic_unchecked_t *instance);
78683
78684 /* Set v4l2_dev->dev to NULL. Call when the USB parent disconnects.
78685 Since the parent disappears this ensures that v4l2_dev doesn't have an
78686 diff --git a/include/net/9p/transport.h b/include/net/9p/transport.h
78687 index 9a36d92..0aafe2a 100644
78688 --- a/include/net/9p/transport.h
78689 +++ b/include/net/9p/transport.h
78690 @@ -60,7 +60,7 @@ struct p9_trans_module {
78691 int (*cancel) (struct p9_client *, struct p9_req_t *req);
78692 int (*zc_request)(struct p9_client *, struct p9_req_t *,
78693 char *, char *, int , int, int, int);
78694 -};
78695 +} __do_const;
78696
78697 void v9fs_register_trans(struct p9_trans_module *m);
78698 void v9fs_unregister_trans(struct p9_trans_module *m);
78699 diff --git a/include/net/bluetooth/l2cap.h b/include/net/bluetooth/l2cap.h
78700 index 1a966af..2767cf6 100644
78701 --- a/include/net/bluetooth/l2cap.h
78702 +++ b/include/net/bluetooth/l2cap.h
78703 @@ -551,7 +551,7 @@ struct l2cap_ops {
78704 void (*defer) (struct l2cap_chan *chan);
78705 struct sk_buff *(*alloc_skb) (struct l2cap_chan *chan,
78706 unsigned long len, int nb);
78707 -};
78708 +} __do_const;
78709
78710 struct l2cap_conn {
78711 struct hci_conn *hcon;
78712 diff --git a/include/net/caif/cfctrl.h b/include/net/caif/cfctrl.h
78713 index f2ae33d..c457cf0 100644
78714 --- a/include/net/caif/cfctrl.h
78715 +++ b/include/net/caif/cfctrl.h
78716 @@ -52,7 +52,7 @@ struct cfctrl_rsp {
78717 void (*radioset_rsp)(void);
78718 void (*reject_rsp)(struct cflayer *layer, u8 linkid,
78719 struct cflayer *client_layer);
78720 -};
78721 +} __no_const;
78722
78723 /* Link Setup Parameters for CAIF-Links. */
78724 struct cfctrl_link_param {
78725 @@ -101,8 +101,8 @@ struct cfctrl_request_info {
78726 struct cfctrl {
78727 struct cfsrvl serv;
78728 struct cfctrl_rsp res;
78729 - atomic_t req_seq_no;
78730 - atomic_t rsp_seq_no;
78731 + atomic_unchecked_t req_seq_no;
78732 + atomic_unchecked_t rsp_seq_no;
78733 struct list_head list;
78734 /* Protects from simultaneous access to first_req list */
78735 spinlock_t info_list_lock;
78736 diff --git a/include/net/flow.h b/include/net/flow.h
78737 index 628e11b..4c475df 100644
78738 --- a/include/net/flow.h
78739 +++ b/include/net/flow.h
78740 @@ -221,6 +221,6 @@ extern struct flow_cache_object *flow_cache_lookup(
78741
78742 extern void flow_cache_flush(void);
78743 extern void flow_cache_flush_deferred(void);
78744 -extern atomic_t flow_cache_genid;
78745 +extern atomic_unchecked_t flow_cache_genid;
78746
78747 #endif
78748 diff --git a/include/net/genetlink.h b/include/net/genetlink.h
78749 index 8e0b6c8..73cf605 100644
78750 --- a/include/net/genetlink.h
78751 +++ b/include/net/genetlink.h
78752 @@ -120,7 +120,7 @@ struct genl_ops {
78753 struct netlink_callback *cb);
78754 int (*done)(struct netlink_callback *cb);
78755 struct list_head ops_list;
78756 -};
78757 +} __do_const;
78758
78759 extern int __genl_register_family(struct genl_family *family);
78760
78761 diff --git a/include/net/gro_cells.h b/include/net/gro_cells.h
78762 index 734d9b5..48a9a4b 100644
78763 --- a/include/net/gro_cells.h
78764 +++ b/include/net/gro_cells.h
78765 @@ -29,7 +29,7 @@ static inline void gro_cells_receive(struct gro_cells *gcells, struct sk_buff *s
78766 cell += skb_get_rx_queue(skb) & gcells->gro_cells_mask;
78767
78768 if (skb_queue_len(&cell->napi_skbs) > netdev_max_backlog) {
78769 - atomic_long_inc(&dev->rx_dropped);
78770 + atomic_long_inc_unchecked(&dev->rx_dropped);
78771 kfree_skb(skb);
78772 return;
78773 }
78774 diff --git a/include/net/inet_connection_sock.h b/include/net/inet_connection_sock.h
78775 index de2c785..0588a6b 100644
78776 --- a/include/net/inet_connection_sock.h
78777 +++ b/include/net/inet_connection_sock.h
78778 @@ -62,7 +62,7 @@ struct inet_connection_sock_af_ops {
78779 void (*addr2sockaddr)(struct sock *sk, struct sockaddr *);
78780 int (*bind_conflict)(const struct sock *sk,
78781 const struct inet_bind_bucket *tb, bool relax);
78782 -};
78783 +} __do_const;
78784
78785 /** inet_connection_sock - INET connection oriented sock
78786 *
78787 diff --git a/include/net/inetpeer.h b/include/net/inetpeer.h
78788 index 53f464d..0bd0b49 100644
78789 --- a/include/net/inetpeer.h
78790 +++ b/include/net/inetpeer.h
78791 @@ -47,8 +47,8 @@ struct inet_peer {
78792 */
78793 union {
78794 struct {
78795 - atomic_t rid; /* Frag reception counter */
78796 - atomic_t ip_id_count; /* IP ID for the next packet */
78797 + atomic_unchecked_t rid; /* Frag reception counter */
78798 + atomic_unchecked_t ip_id_count; /* IP ID for the next packet */
78799 };
78800 struct rcu_head rcu;
78801 struct inet_peer *gc_next;
78802 @@ -178,16 +178,13 @@ static inline void inet_peer_refcheck(const struct inet_peer *p)
78803 /* can be called with or without local BH being disabled */
78804 static inline int inet_getid(struct inet_peer *p, int more)
78805 {
78806 - int old, new;
78807 + int id;
78808 more++;
78809 inet_peer_refcheck(p);
78810 - do {
78811 - old = atomic_read(&p->ip_id_count);
78812 - new = old + more;
78813 - if (!new)
78814 - new = 1;
78815 - } while (atomic_cmpxchg(&p->ip_id_count, old, new) != old);
78816 - return new;
78817 + id = atomic_add_return_unchecked(more, &p->ip_id_count);
78818 + if (!id)
78819 + id = atomic_inc_return_unchecked(&p->ip_id_count);
78820 + return id;
78821 }
78822
78823 #endif /* _NET_INETPEER_H */
78824 diff --git a/include/net/ip.h b/include/net/ip.h
78825 index 301f10c..b52cdaf 100644
78826 --- a/include/net/ip.h
78827 +++ b/include/net/ip.h
78828 @@ -212,7 +212,7 @@ extern struct local_ports {
78829 } sysctl_local_ports;
78830 extern void inet_get_local_port_range(int *low, int *high);
78831
78832 -extern unsigned long *sysctl_local_reserved_ports;
78833 +extern unsigned long sysctl_local_reserved_ports[65536 / 8 / sizeof(unsigned long)];
78834 static inline int inet_is_reserved_local_port(int port)
78835 {
78836 return test_bit(port, sysctl_local_reserved_ports);
78837 diff --git a/include/net/ip_fib.h b/include/net/ip_fib.h
78838 index cbf2be3..3683f6d 100644
78839 --- a/include/net/ip_fib.h
78840 +++ b/include/net/ip_fib.h
78841 @@ -169,7 +169,7 @@ extern __be32 fib_info_update_nh_saddr(struct net *net, struct fib_nh *nh);
78842
78843 #define FIB_RES_SADDR(net, res) \
78844 ((FIB_RES_NH(res).nh_saddr_genid == \
78845 - atomic_read(&(net)->ipv4.dev_addr_genid)) ? \
78846 + atomic_read_unchecked(&(net)->ipv4.dev_addr_genid)) ? \
78847 FIB_RES_NH(res).nh_saddr : \
78848 fib_info_update_nh_saddr((net), &FIB_RES_NH(res)))
78849 #define FIB_RES_GW(res) (FIB_RES_NH(res).nh_gw)
78850 diff --git a/include/net/ip_vs.h b/include/net/ip_vs.h
78851 index 772252d..1e69799 100644
78852 --- a/include/net/ip_vs.h
78853 +++ b/include/net/ip_vs.h
78854 @@ -558,7 +558,7 @@ struct ip_vs_conn {
78855 struct ip_vs_conn *control; /* Master control connection */
78856 atomic_t n_control; /* Number of controlled ones */
78857 struct ip_vs_dest *dest; /* real server */
78858 - atomic_t in_pkts; /* incoming packet counter */
78859 + atomic_unchecked_t in_pkts; /* incoming packet counter */
78860
78861 /* packet transmitter for different forwarding methods. If it
78862 mangles the packet, it must return NF_DROP or better NF_STOLEN,
78863 @@ -705,7 +705,7 @@ struct ip_vs_dest {
78864 __be16 port; /* port number of the server */
78865 union nf_inet_addr addr; /* IP address of the server */
78866 volatile unsigned int flags; /* dest status flags */
78867 - atomic_t conn_flags; /* flags to copy to conn */
78868 + atomic_unchecked_t conn_flags; /* flags to copy to conn */
78869 atomic_t weight; /* server weight */
78870
78871 atomic_t refcnt; /* reference counter */
78872 @@ -960,11 +960,11 @@ struct netns_ipvs {
78873 /* ip_vs_lblc */
78874 int sysctl_lblc_expiration;
78875 struct ctl_table_header *lblc_ctl_header;
78876 - struct ctl_table *lblc_ctl_table;
78877 + ctl_table_no_const *lblc_ctl_table;
78878 /* ip_vs_lblcr */
78879 int sysctl_lblcr_expiration;
78880 struct ctl_table_header *lblcr_ctl_header;
78881 - struct ctl_table *lblcr_ctl_table;
78882 + ctl_table_no_const *lblcr_ctl_table;
78883 /* ip_vs_est */
78884 struct list_head est_list; /* estimator list */
78885 spinlock_t est_lock;
78886 diff --git a/include/net/irda/ircomm_tty.h b/include/net/irda/ircomm_tty.h
78887 index 80ffde3..968b0f4 100644
78888 --- a/include/net/irda/ircomm_tty.h
78889 +++ b/include/net/irda/ircomm_tty.h
78890 @@ -35,6 +35,7 @@
78891 #include <linux/termios.h>
78892 #include <linux/timer.h>
78893 #include <linux/tty.h> /* struct tty_struct */
78894 +#include <asm/local.h>
78895
78896 #include <net/irda/irias_object.h>
78897 #include <net/irda/ircomm_core.h>
78898 diff --git a/include/net/iucv/af_iucv.h b/include/net/iucv/af_iucv.h
78899 index 714cc9a..ea05f3e 100644
78900 --- a/include/net/iucv/af_iucv.h
78901 +++ b/include/net/iucv/af_iucv.h
78902 @@ -149,7 +149,7 @@ struct iucv_skb_cb {
78903 struct iucv_sock_list {
78904 struct hlist_head head;
78905 rwlock_t lock;
78906 - atomic_t autobind_name;
78907 + atomic_unchecked_t autobind_name;
78908 };
78909
78910 unsigned int iucv_sock_poll(struct file *file, struct socket *sock,
78911 diff --git a/include/net/llc_c_ac.h b/include/net/llc_c_ac.h
78912 index df83f69..9b640b8 100644
78913 --- a/include/net/llc_c_ac.h
78914 +++ b/include/net/llc_c_ac.h
78915 @@ -87,7 +87,7 @@
78916 #define LLC_CONN_AC_STOP_SENDACK_TMR 70
78917 #define LLC_CONN_AC_START_SENDACK_TMR_IF_NOT_RUNNING 71
78918
78919 -typedef int (*llc_conn_action_t)(struct sock *sk, struct sk_buff *skb);
78920 +typedef int (* const llc_conn_action_t)(struct sock *sk, struct sk_buff *skb);
78921
78922 extern int llc_conn_ac_clear_remote_busy(struct sock *sk, struct sk_buff *skb);
78923 extern int llc_conn_ac_conn_ind(struct sock *sk, struct sk_buff *skb);
78924 diff --git a/include/net/llc_c_ev.h b/include/net/llc_c_ev.h
78925 index 6ca3113..f8026dd 100644
78926 --- a/include/net/llc_c_ev.h
78927 +++ b/include/net/llc_c_ev.h
78928 @@ -125,8 +125,8 @@ static __inline__ struct llc_conn_state_ev *llc_conn_ev(struct sk_buff *skb)
78929 return (struct llc_conn_state_ev *)skb->cb;
78930 }
78931
78932 -typedef int (*llc_conn_ev_t)(struct sock *sk, struct sk_buff *skb);
78933 -typedef int (*llc_conn_ev_qfyr_t)(struct sock *sk, struct sk_buff *skb);
78934 +typedef int (* const llc_conn_ev_t)(struct sock *sk, struct sk_buff *skb);
78935 +typedef int (* const llc_conn_ev_qfyr_t)(struct sock *sk, struct sk_buff *skb);
78936
78937 extern int llc_conn_ev_conn_req(struct sock *sk, struct sk_buff *skb);
78938 extern int llc_conn_ev_data_req(struct sock *sk, struct sk_buff *skb);
78939 diff --git a/include/net/llc_c_st.h b/include/net/llc_c_st.h
78940 index 0e79cfb..f46db31 100644
78941 --- a/include/net/llc_c_st.h
78942 +++ b/include/net/llc_c_st.h
78943 @@ -37,7 +37,7 @@ struct llc_conn_state_trans {
78944 u8 next_state;
78945 llc_conn_ev_qfyr_t *ev_qualifiers;
78946 llc_conn_action_t *ev_actions;
78947 -};
78948 +} __do_const;
78949
78950 struct llc_conn_state {
78951 u8 current_state;
78952 diff --git a/include/net/llc_s_ac.h b/include/net/llc_s_ac.h
78953 index 37a3bbd..55a4241 100644
78954 --- a/include/net/llc_s_ac.h
78955 +++ b/include/net/llc_s_ac.h
78956 @@ -23,7 +23,7 @@
78957 #define SAP_ACT_TEST_IND 9
78958
78959 /* All action functions must look like this */
78960 -typedef int (*llc_sap_action_t)(struct llc_sap *sap, struct sk_buff *skb);
78961 +typedef int (* const llc_sap_action_t)(struct llc_sap *sap, struct sk_buff *skb);
78962
78963 extern int llc_sap_action_unitdata_ind(struct llc_sap *sap,
78964 struct sk_buff *skb);
78965 diff --git a/include/net/llc_s_st.h b/include/net/llc_s_st.h
78966 index 567c681..cd73ac0 100644
78967 --- a/include/net/llc_s_st.h
78968 +++ b/include/net/llc_s_st.h
78969 @@ -20,7 +20,7 @@ struct llc_sap_state_trans {
78970 llc_sap_ev_t ev;
78971 u8 next_state;
78972 llc_sap_action_t *ev_actions;
78973 -};
78974 +} __do_const;
78975
78976 struct llc_sap_state {
78977 u8 curr_state;
78978 diff --git a/include/net/mac80211.h b/include/net/mac80211.h
78979 index cc6035f..a8406fc 100644
78980 --- a/include/net/mac80211.h
78981 +++ b/include/net/mac80211.h
78982 @@ -4361,7 +4361,7 @@ struct rate_control_ops {
78983 void (*add_sta_debugfs)(void *priv, void *priv_sta,
78984 struct dentry *dir);
78985 void (*remove_sta_debugfs)(void *priv, void *priv_sta);
78986 -};
78987 +} __do_const;
78988
78989 static inline int rate_supported(struct ieee80211_sta *sta,
78990 enum ieee80211_band band,
78991 diff --git a/include/net/neighbour.h b/include/net/neighbour.h
78992 index 536501a..7c6193c 100644
78993 --- a/include/net/neighbour.h
78994 +++ b/include/net/neighbour.h
78995 @@ -123,7 +123,7 @@ struct neigh_ops {
78996 void (*error_report)(struct neighbour *, struct sk_buff *);
78997 int (*output)(struct neighbour *, struct sk_buff *);
78998 int (*connected_output)(struct neighbour *, struct sk_buff *);
78999 -};
79000 +} __do_const;
79001
79002 struct pneigh_entry {
79003 struct pneigh_entry *next;
79004 diff --git a/include/net/net_namespace.h b/include/net/net_namespace.h
79005 index 9d22f08..980fbf8 100644
79006 --- a/include/net/net_namespace.h
79007 +++ b/include/net/net_namespace.h
79008 @@ -120,7 +120,7 @@ struct net {
79009 struct netns_ipvs *ipvs;
79010 #endif
79011 struct sock *diag_nlsk;
79012 - atomic_t fnhe_genid;
79013 + atomic_unchecked_t fnhe_genid;
79014 };
79015
79016 /*
79017 @@ -277,7 +277,11 @@ static inline struct net *read_pnet(struct net * const *pnet)
79018 #define __net_init __init
79019 #define __net_exit __exit_refok
79020 #define __net_initdata __initdata
79021 +#ifdef CONSTIFY_PLUGIN
79022 #define __net_initconst __initconst
79023 +#else
79024 +#define __net_initconst __initdata
79025 +#endif
79026 #endif
79027
79028 struct pernet_operations {
79029 @@ -287,7 +291,7 @@ struct pernet_operations {
79030 void (*exit_batch)(struct list_head *net_exit_list);
79031 int *id;
79032 size_t size;
79033 -};
79034 +} __do_const;
79035
79036 /*
79037 * Use these carefully. If you implement a network device and it
79038 @@ -335,23 +339,23 @@ static inline void unregister_net_sysctl_table(struct ctl_table_header *header)
79039
79040 static inline int rt_genid_ipv4(struct net *net)
79041 {
79042 - return atomic_read(&net->ipv4.rt_genid);
79043 + return atomic_read_unchecked(&net->ipv4.rt_genid);
79044 }
79045
79046 static inline void rt_genid_bump_ipv4(struct net *net)
79047 {
79048 - atomic_inc(&net->ipv4.rt_genid);
79049 + atomic_inc_unchecked(&net->ipv4.rt_genid);
79050 }
79051
79052 #if IS_ENABLED(CONFIG_IPV6)
79053 static inline int rt_genid_ipv6(struct net *net)
79054 {
79055 - return atomic_read(&net->ipv6.rt_genid);
79056 + return atomic_read_unchecked(&net->ipv6.rt_genid);
79057 }
79058
79059 static inline void rt_genid_bump_ipv6(struct net *net)
79060 {
79061 - atomic_inc(&net->ipv6.rt_genid);
79062 + atomic_inc_unchecked(&net->ipv6.rt_genid);
79063 }
79064 #else
79065 static inline int rt_genid_ipv6(struct net *net)
79066 @@ -373,12 +377,12 @@ static inline void rt_genid_bump_all(struct net *net)
79067
79068 static inline int fnhe_genid(struct net *net)
79069 {
79070 - return atomic_read(&net->fnhe_genid);
79071 + return atomic_read_unchecked(&net->fnhe_genid);
79072 }
79073
79074 static inline void fnhe_genid_bump(struct net *net)
79075 {
79076 - atomic_inc(&net->fnhe_genid);
79077 + atomic_inc_unchecked(&net->fnhe_genid);
79078 }
79079
79080 #endif /* __NET_NET_NAMESPACE_H */
79081 diff --git a/include/net/netdma.h b/include/net/netdma.h
79082 index 8ba8ce2..99b7fff 100644
79083 --- a/include/net/netdma.h
79084 +++ b/include/net/netdma.h
79085 @@ -24,7 +24,7 @@
79086 #include <linux/dmaengine.h>
79087 #include <linux/skbuff.h>
79088
79089 -int dma_skb_copy_datagram_iovec(struct dma_chan* chan,
79090 +int __intentional_overflow(3,5) dma_skb_copy_datagram_iovec(struct dma_chan* chan,
79091 struct sk_buff *skb, int offset, struct iovec *to,
79092 size_t len, struct dma_pinned_list *pinned_list);
79093
79094 diff --git a/include/net/netlink.h b/include/net/netlink.h
79095 index 9690b0f..87aded7 100644
79096 --- a/include/net/netlink.h
79097 +++ b/include/net/netlink.h
79098 @@ -534,7 +534,7 @@ static inline void *nlmsg_get_pos(struct sk_buff *skb)
79099 static inline void nlmsg_trim(struct sk_buff *skb, const void *mark)
79100 {
79101 if (mark)
79102 - skb_trim(skb, (unsigned char *) mark - skb->data);
79103 + skb_trim(skb, (const unsigned char *) mark - skb->data);
79104 }
79105
79106 /**
79107 diff --git a/include/net/netns/conntrack.h b/include/net/netns/conntrack.h
79108 index c9c0c53..53f24c3 100644
79109 --- a/include/net/netns/conntrack.h
79110 +++ b/include/net/netns/conntrack.h
79111 @@ -12,10 +12,10 @@ struct nf_conntrack_ecache;
79112 struct nf_proto_net {
79113 #ifdef CONFIG_SYSCTL
79114 struct ctl_table_header *ctl_table_header;
79115 - struct ctl_table *ctl_table;
79116 + ctl_table_no_const *ctl_table;
79117 #ifdef CONFIG_NF_CONNTRACK_PROC_COMPAT
79118 struct ctl_table_header *ctl_compat_header;
79119 - struct ctl_table *ctl_compat_table;
79120 + ctl_table_no_const *ctl_compat_table;
79121 #endif
79122 #endif
79123 unsigned int users;
79124 @@ -58,7 +58,7 @@ struct nf_ip_net {
79125 struct nf_icmp_net icmpv6;
79126 #if defined(CONFIG_SYSCTL) && defined(CONFIG_NF_CONNTRACK_PROC_COMPAT)
79127 struct ctl_table_header *ctl_table_header;
79128 - struct ctl_table *ctl_table;
79129 + ctl_table_no_const *ctl_table;
79130 #endif
79131 };
79132
79133 diff --git a/include/net/netns/ipv4.h b/include/net/netns/ipv4.h
79134 index bf2ec22..5e7f9d9 100644
79135 --- a/include/net/netns/ipv4.h
79136 +++ b/include/net/netns/ipv4.h
79137 @@ -67,7 +67,7 @@ struct netns_ipv4 {
79138 kgid_t sysctl_ping_group_range[2];
79139 long sysctl_tcp_mem[3];
79140
79141 - atomic_t dev_addr_genid;
79142 + atomic_unchecked_t dev_addr_genid;
79143
79144 #ifdef CONFIG_IP_MROUTE
79145 #ifndef CONFIG_IP_MROUTE_MULTIPLE_TABLES
79146 @@ -77,6 +77,6 @@ struct netns_ipv4 {
79147 struct fib_rules_ops *mr_rules_ops;
79148 #endif
79149 #endif
79150 - atomic_t rt_genid;
79151 + atomic_unchecked_t rt_genid;
79152 };
79153 #endif
79154 diff --git a/include/net/netns/ipv6.h b/include/net/netns/ipv6.h
79155 index 0fb2401..477d81c 100644
79156 --- a/include/net/netns/ipv6.h
79157 +++ b/include/net/netns/ipv6.h
79158 @@ -71,8 +71,8 @@ struct netns_ipv6 {
79159 struct fib_rules_ops *mr6_rules_ops;
79160 #endif
79161 #endif
79162 - atomic_t dev_addr_genid;
79163 - atomic_t rt_genid;
79164 + atomic_unchecked_t dev_addr_genid;
79165 + atomic_unchecked_t rt_genid;
79166 };
79167
79168 #if IS_ENABLED(CONFIG_NF_DEFRAG_IPV6)
79169 diff --git a/include/net/ping.h b/include/net/ping.h
79170 index 2b496e9..935fd8d 100644
79171 --- a/include/net/ping.h
79172 +++ b/include/net/ping.h
79173 @@ -56,7 +56,7 @@ struct ping_iter_state {
79174 extern struct proto ping_prot;
79175 extern struct ping_table ping_table;
79176 #if IS_ENABLED(CONFIG_IPV6)
79177 -extern struct pingv6_ops pingv6_ops;
79178 +extern struct pingv6_ops *pingv6_ops;
79179 #endif
79180
79181 struct pingfakehdr {
79182 diff --git a/include/net/protocol.h b/include/net/protocol.h
79183 index 047c047..b9dad15 100644
79184 --- a/include/net/protocol.h
79185 +++ b/include/net/protocol.h
79186 @@ -44,7 +44,7 @@ struct net_protocol {
79187 void (*err_handler)(struct sk_buff *skb, u32 info);
79188 unsigned int no_policy:1,
79189 netns_ok:1;
79190 -};
79191 +} __do_const;
79192
79193 #if IS_ENABLED(CONFIG_IPV6)
79194 struct inet6_protocol {
79195 @@ -57,7 +57,7 @@ struct inet6_protocol {
79196 u8 type, u8 code, int offset,
79197 __be32 info);
79198 unsigned int flags; /* INET6_PROTO_xxx */
79199 -};
79200 +} __do_const;
79201
79202 #define INET6_PROTO_NOPOLICY 0x1
79203 #define INET6_PROTO_FINAL 0x2
79204 diff --git a/include/net/rtnetlink.h b/include/net/rtnetlink.h
79205 index 7026648..584cc8c 100644
79206 --- a/include/net/rtnetlink.h
79207 +++ b/include/net/rtnetlink.h
79208 @@ -81,7 +81,7 @@ struct rtnl_link_ops {
79209 const struct net_device *dev);
79210 unsigned int (*get_num_tx_queues)(void);
79211 unsigned int (*get_num_rx_queues)(void);
79212 -};
79213 +} __do_const;
79214
79215 extern int __rtnl_link_register(struct rtnl_link_ops *ops);
79216 extern void __rtnl_link_unregister(struct rtnl_link_ops *ops);
79217 diff --git a/include/net/sctp/sm.h b/include/net/sctp/sm.h
79218 index 4ef75af..5aa073a 100644
79219 --- a/include/net/sctp/sm.h
79220 +++ b/include/net/sctp/sm.h
79221 @@ -81,7 +81,7 @@ typedef void (sctp_timer_event_t) (unsigned long);
79222 typedef struct {
79223 sctp_state_fn_t *fn;
79224 const char *name;
79225 -} sctp_sm_table_entry_t;
79226 +} __do_const sctp_sm_table_entry_t;
79227
79228 /* A naming convention of "sctp_sf_xxx" applies to all the state functions
79229 * currently in use.
79230 @@ -293,7 +293,7 @@ __u32 sctp_generate_tag(const struct sctp_endpoint *);
79231 __u32 sctp_generate_tsn(const struct sctp_endpoint *);
79232
79233 /* Extern declarations for major data structures. */
79234 -extern sctp_timer_event_t *sctp_timer_events[SCTP_NUM_TIMEOUT_TYPES];
79235 +extern sctp_timer_event_t * const sctp_timer_events[SCTP_NUM_TIMEOUT_TYPES];
79236
79237
79238 /* Get the size of a DATA chunk payload. */
79239 diff --git a/include/net/sctp/structs.h b/include/net/sctp/structs.h
79240 index 2174d8d..71d5257 100644
79241 --- a/include/net/sctp/structs.h
79242 +++ b/include/net/sctp/structs.h
79243 @@ -508,7 +508,7 @@ struct sctp_pf {
79244 struct sctp_association *asoc);
79245 void (*addr_v4map) (struct sctp_sock *, union sctp_addr *);
79246 struct sctp_af *af;
79247 -};
79248 +} __do_const;
79249
79250
79251 /* Structure to track chunk fragments that have been acked, but peer
79252 diff --git a/include/net/sock.h b/include/net/sock.h
79253 index 808cbc2..8617e9c 100644
79254 --- a/include/net/sock.h
79255 +++ b/include/net/sock.h
79256 @@ -332,7 +332,7 @@ struct sock {
79257 unsigned int sk_napi_id;
79258 unsigned int sk_ll_usec;
79259 #endif
79260 - atomic_t sk_drops;
79261 + atomic_unchecked_t sk_drops;
79262 int sk_rcvbuf;
79263
79264 struct sk_filter __rcu *sk_filter;
79265 @@ -1194,7 +1194,7 @@ static inline u64 memcg_memory_allocated_read(struct cg_proto *prot)
79266 return ret >> PAGE_SHIFT;
79267 }
79268
79269 -static inline long
79270 +static inline long __intentional_overflow(-1)
79271 sk_memory_allocated(const struct sock *sk)
79272 {
79273 struct proto *prot = sk->sk_prot;
79274 @@ -1821,7 +1821,7 @@ static inline void sk_nocaps_add(struct sock *sk, netdev_features_t flags)
79275 }
79276
79277 static inline int skb_do_copy_data_nocache(struct sock *sk, struct sk_buff *skb,
79278 - char __user *from, char *to,
79279 + char __user *from, unsigned char *to,
79280 int copy, int offset)
79281 {
79282 if (skb->ip_summed == CHECKSUM_NONE) {
79283 @@ -2083,7 +2083,7 @@ static inline void sk_stream_moderate_sndbuf(struct sock *sk)
79284 }
79285 }
79286
79287 -struct sk_buff *sk_stream_alloc_skb(struct sock *sk, int size, gfp_t gfp);
79288 +struct sk_buff * __intentional_overflow(0) sk_stream_alloc_skb(struct sock *sk, int size, gfp_t gfp);
79289
79290 /**
79291 * sk_page_frag - return an appropriate page_frag
79292 diff --git a/include/net/tcp.h b/include/net/tcp.h
79293 index b1aa324..b8530ea 100644
79294 --- a/include/net/tcp.h
79295 +++ b/include/net/tcp.h
79296 @@ -527,7 +527,7 @@ extern void tcp_retransmit_timer(struct sock *sk);
79297 extern void tcp_xmit_retransmit_queue(struct sock *);
79298 extern void tcp_simple_retransmit(struct sock *);
79299 extern int tcp_trim_head(struct sock *, struct sk_buff *, u32);
79300 -extern int tcp_fragment(struct sock *, struct sk_buff *, u32, unsigned int);
79301 +extern int __intentional_overflow(3) tcp_fragment(struct sock *, struct sk_buff *, u32, unsigned int);
79302
79303 extern void tcp_send_probe0(struct sock *);
79304 extern void tcp_send_partial(struct sock *);
79305 @@ -699,8 +699,8 @@ struct tcp_skb_cb {
79306 struct inet6_skb_parm h6;
79307 #endif
79308 } header; /* For incoming frames */
79309 - __u32 seq; /* Starting sequence number */
79310 - __u32 end_seq; /* SEQ + FIN + SYN + datalen */
79311 + __u32 seq __intentional_overflow(0); /* Starting sequence number */
79312 + __u32 end_seq __intentional_overflow(0); /* SEQ + FIN + SYN + datalen */
79313 __u32 when; /* used to compute rtt's */
79314 __u8 tcp_flags; /* TCP header flags. (tcp[13]) */
79315
79316 @@ -714,7 +714,7 @@ struct tcp_skb_cb {
79317
79318 __u8 ip_dsfield; /* IPv4 tos or IPv6 dsfield */
79319 /* 1 byte hole */
79320 - __u32 ack_seq; /* Sequence number ACK'd */
79321 + __u32 ack_seq __intentional_overflow(0); /* Sequence number ACK'd */
79322 };
79323
79324 #define TCP_SKB_CB(__skb) ((struct tcp_skb_cb *)&((__skb)->cb[0]))
79325 diff --git a/include/net/xfrm.h b/include/net/xfrm.h
79326 index e253bf0..2278b4b 100644
79327 --- a/include/net/xfrm.h
79328 +++ b/include/net/xfrm.h
79329 @@ -287,7 +287,6 @@ struct xfrm_dst;
79330 struct xfrm_policy_afinfo {
79331 unsigned short family;
79332 struct dst_ops *dst_ops;
79333 - void (*garbage_collect)(struct net *net);
79334 struct dst_entry *(*dst_lookup)(struct net *net, int tos,
79335 const xfrm_address_t *saddr,
79336 const xfrm_address_t *daddr);
79337 @@ -305,7 +304,7 @@ struct xfrm_policy_afinfo {
79338 struct net_device *dev,
79339 const struct flowi *fl);
79340 struct dst_entry *(*blackhole_route)(struct net *net, struct dst_entry *orig);
79341 -};
79342 +} __do_const;
79343
79344 extern int xfrm_policy_register_afinfo(struct xfrm_policy_afinfo *afinfo);
79345 extern int xfrm_policy_unregister_afinfo(struct xfrm_policy_afinfo *afinfo);
79346 @@ -342,7 +341,7 @@ struct xfrm_state_afinfo {
79347 int (*transport_finish)(struct sk_buff *skb,
79348 int async);
79349 void (*local_error)(struct sk_buff *skb, u32 mtu);
79350 -};
79351 +} __do_const;
79352
79353 extern int xfrm_state_register_afinfo(struct xfrm_state_afinfo *afinfo);
79354 extern int xfrm_state_unregister_afinfo(struct xfrm_state_afinfo *afinfo);
79355 @@ -427,7 +426,7 @@ struct xfrm_mode {
79356 struct module *owner;
79357 unsigned int encap;
79358 int flags;
79359 -};
79360 +} __do_const;
79361
79362 /* Flags for xfrm_mode. */
79363 enum {
79364 @@ -524,7 +523,7 @@ struct xfrm_policy {
79365 struct timer_list timer;
79366
79367 struct flow_cache_object flo;
79368 - atomic_t genid;
79369 + atomic_unchecked_t genid;
79370 u32 priority;
79371 u32 index;
79372 struct xfrm_mark mark;
79373 @@ -1164,6 +1163,7 @@ static inline void xfrm_sk_free_policy(struct sock *sk)
79374 }
79375
79376 extern void xfrm_garbage_collect(struct net *net);
79377 +extern void xfrm_garbage_collect_deferred(struct net *net);
79378
79379 #else
79380
79381 @@ -1202,6 +1202,9 @@ static inline int xfrm6_policy_check_reverse(struct sock *sk, int dir,
79382 static inline void xfrm_garbage_collect(struct net *net)
79383 {
79384 }
79385 +static inline void xfrm_garbage_collect_deferred(struct net *net)
79386 +{
79387 +}
79388 #endif
79389
79390 static __inline__
79391 diff --git a/include/rdma/iw_cm.h b/include/rdma/iw_cm.h
79392 index 1017e0b..227aa4d 100644
79393 --- a/include/rdma/iw_cm.h
79394 +++ b/include/rdma/iw_cm.h
79395 @@ -122,7 +122,7 @@ struct iw_cm_verbs {
79396 int backlog);
79397
79398 int (*destroy_listen)(struct iw_cm_id *cm_id);
79399 -};
79400 +} __no_const;
79401
79402 /**
79403 * iw_create_cm_id - Create an IW CM identifier.
79404 diff --git a/include/scsi/libfc.h b/include/scsi/libfc.h
79405 index e1379b4..67eafbe 100644
79406 --- a/include/scsi/libfc.h
79407 +++ b/include/scsi/libfc.h
79408 @@ -762,6 +762,7 @@ struct libfc_function_template {
79409 */
79410 void (*disc_stop_final) (struct fc_lport *);
79411 };
79412 +typedef struct libfc_function_template __no_const libfc_function_template_no_const;
79413
79414 /**
79415 * struct fc_disc - Discovery context
79416 @@ -866,7 +867,7 @@ struct fc_lport {
79417 struct fc_vport *vport;
79418
79419 /* Operational Information */
79420 - struct libfc_function_template tt;
79421 + libfc_function_template_no_const tt;
79422 u8 link_up;
79423 u8 qfull;
79424 enum fc_lport_state state;
79425 diff --git a/include/scsi/scsi_device.h b/include/scsi/scsi_device.h
79426 index d65fbec..f80fef2 100644
79427 --- a/include/scsi/scsi_device.h
79428 +++ b/include/scsi/scsi_device.h
79429 @@ -180,9 +180,9 @@ struct scsi_device {
79430 unsigned int max_device_blocked; /* what device_blocked counts down from */
79431 #define SCSI_DEFAULT_DEVICE_BLOCKED 3
79432
79433 - atomic_t iorequest_cnt;
79434 - atomic_t iodone_cnt;
79435 - atomic_t ioerr_cnt;
79436 + atomic_unchecked_t iorequest_cnt;
79437 + atomic_unchecked_t iodone_cnt;
79438 + atomic_unchecked_t ioerr_cnt;
79439
79440 struct device sdev_gendev,
79441 sdev_dev;
79442 diff --git a/include/scsi/scsi_transport_fc.h b/include/scsi/scsi_transport_fc.h
79443 index b797e8f..8e2c3aa 100644
79444 --- a/include/scsi/scsi_transport_fc.h
79445 +++ b/include/scsi/scsi_transport_fc.h
79446 @@ -751,7 +751,8 @@ struct fc_function_template {
79447 unsigned long show_host_system_hostname:1;
79448
79449 unsigned long disable_target_scan:1;
79450 -};
79451 +} __do_const;
79452 +typedef struct fc_function_template __no_const fc_function_template_no_const;
79453
79454
79455 /**
79456 diff --git a/include/sound/compress_driver.h b/include/sound/compress_driver.h
79457 index ae6c3b8..fd748ac 100644
79458 --- a/include/sound/compress_driver.h
79459 +++ b/include/sound/compress_driver.h
79460 @@ -128,7 +128,7 @@ struct snd_compr_ops {
79461 struct snd_compr_caps *caps);
79462 int (*get_codec_caps) (struct snd_compr_stream *stream,
79463 struct snd_compr_codec_caps *codec);
79464 -};
79465 +} __no_const;
79466
79467 /**
79468 * struct snd_compr: Compressed device
79469 diff --git a/include/sound/soc.h b/include/sound/soc.h
79470 index d22cb0a..c6ba150 100644
79471 --- a/include/sound/soc.h
79472 +++ b/include/sound/soc.h
79473 @@ -780,7 +780,7 @@ struct snd_soc_codec_driver {
79474 /* probe ordering - for components with runtime dependencies */
79475 int probe_order;
79476 int remove_order;
79477 -};
79478 +} __do_const;
79479
79480 /* SoC platform interface */
79481 struct snd_soc_platform_driver {
79482 @@ -826,7 +826,7 @@ struct snd_soc_platform_driver {
79483 unsigned int (*read)(struct snd_soc_platform *, unsigned int);
79484 int (*write)(struct snd_soc_platform *, unsigned int, unsigned int);
79485 int (*bespoke_trigger)(struct snd_pcm_substream *, int);
79486 -};
79487 +} __do_const;
79488
79489 struct snd_soc_platform {
79490 const char *name;
79491 diff --git a/include/target/target_core_base.h b/include/target/target_core_base.h
79492 index 5bdb8b7..bb1096c 100644
79493 --- a/include/target/target_core_base.h
79494 +++ b/include/target/target_core_base.h
79495 @@ -663,7 +663,7 @@ struct se_device {
79496 spinlock_t stats_lock;
79497 /* Active commands on this virtual SE device */
79498 atomic_t simple_cmds;
79499 - atomic_t dev_ordered_id;
79500 + atomic_unchecked_t dev_ordered_id;
79501 atomic_t dev_ordered_sync;
79502 atomic_t dev_qf_count;
79503 int export_count;
79504 diff --git a/include/trace/events/fs.h b/include/trace/events/fs.h
79505 new file mode 100644
79506 index 0000000..fb634b7
79507 --- /dev/null
79508 +++ b/include/trace/events/fs.h
79509 @@ -0,0 +1,53 @@
79510 +#undef TRACE_SYSTEM
79511 +#define TRACE_SYSTEM fs
79512 +
79513 +#if !defined(_TRACE_FS_H) || defined(TRACE_HEADER_MULTI_READ)
79514 +#define _TRACE_FS_H
79515 +
79516 +#include <linux/fs.h>
79517 +#include <linux/tracepoint.h>
79518 +
79519 +TRACE_EVENT(do_sys_open,
79520 +
79521 + TP_PROTO(const char *filename, int flags, int mode),
79522 +
79523 + TP_ARGS(filename, flags, mode),
79524 +
79525 + TP_STRUCT__entry(
79526 + __string( filename, filename )
79527 + __field( int, flags )
79528 + __field( int, mode )
79529 + ),
79530 +
79531 + TP_fast_assign(
79532 + __assign_str(filename, filename);
79533 + __entry->flags = flags;
79534 + __entry->mode = mode;
79535 + ),
79536 +
79537 + TP_printk("\"%s\" %x %o",
79538 + __get_str(filename), __entry->flags, __entry->mode)
79539 +);
79540 +
79541 +TRACE_EVENT(open_exec,
79542 +
79543 + TP_PROTO(const char *filename),
79544 +
79545 + TP_ARGS(filename),
79546 +
79547 + TP_STRUCT__entry(
79548 + __string( filename, filename )
79549 + ),
79550 +
79551 + TP_fast_assign(
79552 + __assign_str(filename, filename);
79553 + ),
79554 +
79555 + TP_printk("\"%s\"",
79556 + __get_str(filename))
79557 +);
79558 +
79559 +#endif /* _TRACE_FS_H */
79560 +
79561 +/* This part must be outside protection */
79562 +#include <trace/define_trace.h>
79563 diff --git a/include/trace/events/irq.h b/include/trace/events/irq.h
79564 index 1c09820..7f5ec79 100644
79565 --- a/include/trace/events/irq.h
79566 +++ b/include/trace/events/irq.h
79567 @@ -36,7 +36,7 @@ struct softirq_action;
79568 */
79569 TRACE_EVENT(irq_handler_entry,
79570
79571 - TP_PROTO(int irq, struct irqaction *action),
79572 + TP_PROTO(int irq, const struct irqaction *action),
79573
79574 TP_ARGS(irq, action),
79575
79576 @@ -66,7 +66,7 @@ TRACE_EVENT(irq_handler_entry,
79577 */
79578 TRACE_EVENT(irq_handler_exit,
79579
79580 - TP_PROTO(int irq, struct irqaction *action, int ret),
79581 + TP_PROTO(int irq, const struct irqaction *action, int ret),
79582
79583 TP_ARGS(irq, action, ret),
79584
79585 diff --git a/include/uapi/linux/a.out.h b/include/uapi/linux/a.out.h
79586 index 7caf44c..23c6f27 100644
79587 --- a/include/uapi/linux/a.out.h
79588 +++ b/include/uapi/linux/a.out.h
79589 @@ -39,6 +39,14 @@ enum machine_type {
79590 M_MIPS2 = 152 /* MIPS R6000/R4000 binary */
79591 };
79592
79593 +/* Constants for the N_FLAGS field */
79594 +#define F_PAX_PAGEEXEC 1 /* Paging based non-executable pages */
79595 +#define F_PAX_EMUTRAMP 2 /* Emulate trampolines */
79596 +#define F_PAX_MPROTECT 4 /* Restrict mprotect() */
79597 +#define F_PAX_RANDMMAP 8 /* Randomize mmap() base */
79598 +/*#define F_PAX_RANDEXEC 16*/ /* Randomize ET_EXEC base */
79599 +#define F_PAX_SEGMEXEC 32 /* Segmentation based non-executable pages */
79600 +
79601 #if !defined (N_MAGIC)
79602 #define N_MAGIC(exec) ((exec).a_info & 0xffff)
79603 #endif
79604 diff --git a/include/uapi/linux/byteorder/little_endian.h b/include/uapi/linux/byteorder/little_endian.h
79605 index d876736..ccce5c0 100644
79606 --- a/include/uapi/linux/byteorder/little_endian.h
79607 +++ b/include/uapi/linux/byteorder/little_endian.h
79608 @@ -42,51 +42,51 @@
79609
79610 static inline __le64 __cpu_to_le64p(const __u64 *p)
79611 {
79612 - return (__force __le64)*p;
79613 + return (__force const __le64)*p;
79614 }
79615 -static inline __u64 __le64_to_cpup(const __le64 *p)
79616 +static inline __u64 __intentional_overflow(-1) __le64_to_cpup(const __le64 *p)
79617 {
79618 - return (__force __u64)*p;
79619 + return (__force const __u64)*p;
79620 }
79621 static inline __le32 __cpu_to_le32p(const __u32 *p)
79622 {
79623 - return (__force __le32)*p;
79624 + return (__force const __le32)*p;
79625 }
79626 static inline __u32 __le32_to_cpup(const __le32 *p)
79627 {
79628 - return (__force __u32)*p;
79629 + return (__force const __u32)*p;
79630 }
79631 static inline __le16 __cpu_to_le16p(const __u16 *p)
79632 {
79633 - return (__force __le16)*p;
79634 + return (__force const __le16)*p;
79635 }
79636 static inline __u16 __le16_to_cpup(const __le16 *p)
79637 {
79638 - return (__force __u16)*p;
79639 + return (__force const __u16)*p;
79640 }
79641 static inline __be64 __cpu_to_be64p(const __u64 *p)
79642 {
79643 - return (__force __be64)__swab64p(p);
79644 + return (__force const __be64)__swab64p(p);
79645 }
79646 static inline __u64 __be64_to_cpup(const __be64 *p)
79647 {
79648 - return __swab64p((__u64 *)p);
79649 + return __swab64p((const __u64 *)p);
79650 }
79651 static inline __be32 __cpu_to_be32p(const __u32 *p)
79652 {
79653 - return (__force __be32)__swab32p(p);
79654 + return (__force const __be32)__swab32p(p);
79655 }
79656 -static inline __u32 __be32_to_cpup(const __be32 *p)
79657 +static inline __u32 __intentional_overflow(-1) __be32_to_cpup(const __be32 *p)
79658 {
79659 - return __swab32p((__u32 *)p);
79660 + return __swab32p((const __u32 *)p);
79661 }
79662 static inline __be16 __cpu_to_be16p(const __u16 *p)
79663 {
79664 - return (__force __be16)__swab16p(p);
79665 + return (__force const __be16)__swab16p(p);
79666 }
79667 static inline __u16 __be16_to_cpup(const __be16 *p)
79668 {
79669 - return __swab16p((__u16 *)p);
79670 + return __swab16p((const __u16 *)p);
79671 }
79672 #define __cpu_to_le64s(x) do { (void)(x); } while (0)
79673 #define __le64_to_cpus(x) do { (void)(x); } while (0)
79674 diff --git a/include/uapi/linux/elf.h b/include/uapi/linux/elf.h
79675 index ef6103b..d4e65dd 100644
79676 --- a/include/uapi/linux/elf.h
79677 +++ b/include/uapi/linux/elf.h
79678 @@ -37,6 +37,17 @@ typedef __s64 Elf64_Sxword;
79679 #define PT_GNU_EH_FRAME 0x6474e550
79680
79681 #define PT_GNU_STACK (PT_LOOS + 0x474e551)
79682 +#define PT_GNU_RELRO (PT_LOOS + 0x474e552)
79683 +
79684 +#define PT_PAX_FLAGS (PT_LOOS + 0x5041580)
79685 +
79686 +/* Constants for the e_flags field */
79687 +#define EF_PAX_PAGEEXEC 1 /* Paging based non-executable pages */
79688 +#define EF_PAX_EMUTRAMP 2 /* Emulate trampolines */
79689 +#define EF_PAX_MPROTECT 4 /* Restrict mprotect() */
79690 +#define EF_PAX_RANDMMAP 8 /* Randomize mmap() base */
79691 +/*#define EF_PAX_RANDEXEC 16*/ /* Randomize ET_EXEC base */
79692 +#define EF_PAX_SEGMEXEC 32 /* Segmentation based non-executable pages */
79693
79694 /*
79695 * Extended Numbering
79696 @@ -94,6 +105,8 @@ typedef __s64 Elf64_Sxword;
79697 #define DT_DEBUG 21
79698 #define DT_TEXTREL 22
79699 #define DT_JMPREL 23
79700 +#define DT_FLAGS 30
79701 + #define DF_TEXTREL 0x00000004
79702 #define DT_ENCODING 32
79703 #define OLD_DT_LOOS 0x60000000
79704 #define DT_LOOS 0x6000000d
79705 @@ -240,6 +253,19 @@ typedef struct elf64_hdr {
79706 #define PF_W 0x2
79707 #define PF_X 0x1
79708
79709 +#define PF_PAGEEXEC (1U << 4) /* Enable PAGEEXEC */
79710 +#define PF_NOPAGEEXEC (1U << 5) /* Disable PAGEEXEC */
79711 +#define PF_SEGMEXEC (1U << 6) /* Enable SEGMEXEC */
79712 +#define PF_NOSEGMEXEC (1U << 7) /* Disable SEGMEXEC */
79713 +#define PF_MPROTECT (1U << 8) /* Enable MPROTECT */
79714 +#define PF_NOMPROTECT (1U << 9) /* Disable MPROTECT */
79715 +/*#define PF_RANDEXEC (1U << 10)*/ /* Enable RANDEXEC */
79716 +/*#define PF_NORANDEXEC (1U << 11)*/ /* Disable RANDEXEC */
79717 +#define PF_EMUTRAMP (1U << 12) /* Enable EMUTRAMP */
79718 +#define PF_NOEMUTRAMP (1U << 13) /* Disable EMUTRAMP */
79719 +#define PF_RANDMMAP (1U << 14) /* Enable RANDMMAP */
79720 +#define PF_NORANDMMAP (1U << 15) /* Disable RANDMMAP */
79721 +
79722 typedef struct elf32_phdr{
79723 Elf32_Word p_type;
79724 Elf32_Off p_offset;
79725 @@ -332,6 +358,8 @@ typedef struct elf64_shdr {
79726 #define EI_OSABI 7
79727 #define EI_PAD 8
79728
79729 +#define EI_PAX 14
79730 +
79731 #define ELFMAG0 0x7f /* EI_MAG */
79732 #define ELFMAG1 'E'
79733 #define ELFMAG2 'L'
79734 diff --git a/include/uapi/linux/personality.h b/include/uapi/linux/personality.h
79735 index aa169c4..6a2771d 100644
79736 --- a/include/uapi/linux/personality.h
79737 +++ b/include/uapi/linux/personality.h
79738 @@ -30,6 +30,7 @@ enum {
79739 #define PER_CLEAR_ON_SETID (READ_IMPLIES_EXEC | \
79740 ADDR_NO_RANDOMIZE | \
79741 ADDR_COMPAT_LAYOUT | \
79742 + ADDR_LIMIT_3GB | \
79743 MMAP_PAGE_ZERO)
79744
79745 /*
79746 diff --git a/include/uapi/linux/screen_info.h b/include/uapi/linux/screen_info.h
79747 index 7530e74..e714828 100644
79748 --- a/include/uapi/linux/screen_info.h
79749 +++ b/include/uapi/linux/screen_info.h
79750 @@ -43,7 +43,8 @@ struct screen_info {
79751 __u16 pages; /* 0x32 */
79752 __u16 vesa_attributes; /* 0x34 */
79753 __u32 capabilities; /* 0x36 */
79754 - __u8 _reserved[6]; /* 0x3a */
79755 + __u16 vesapm_size; /* 0x3a */
79756 + __u8 _reserved[4]; /* 0x3c */
79757 } __attribute__((packed));
79758
79759 #define VIDEO_TYPE_MDA 0x10 /* Monochrome Text Display */
79760 diff --git a/include/uapi/linux/swab.h b/include/uapi/linux/swab.h
79761 index 0e011eb..82681b1 100644
79762 --- a/include/uapi/linux/swab.h
79763 +++ b/include/uapi/linux/swab.h
79764 @@ -43,7 +43,7 @@
79765 * ___swab16, ___swab32, ___swab64, ___swahw32, ___swahb32
79766 */
79767
79768 -static inline __attribute_const__ __u16 __fswab16(__u16 val)
79769 +static inline __intentional_overflow(-1) __attribute_const__ __u16 __fswab16(__u16 val)
79770 {
79771 #ifdef __HAVE_BUILTIN_BSWAP16__
79772 return __builtin_bswap16(val);
79773 @@ -54,7 +54,7 @@ static inline __attribute_const__ __u16 __fswab16(__u16 val)
79774 #endif
79775 }
79776
79777 -static inline __attribute_const__ __u32 __fswab32(__u32 val)
79778 +static inline __intentional_overflow(-1) __attribute_const__ __u32 __fswab32(__u32 val)
79779 {
79780 #ifdef __HAVE_BUILTIN_BSWAP32__
79781 return __builtin_bswap32(val);
79782 @@ -65,7 +65,7 @@ static inline __attribute_const__ __u32 __fswab32(__u32 val)
79783 #endif
79784 }
79785
79786 -static inline __attribute_const__ __u64 __fswab64(__u64 val)
79787 +static inline __intentional_overflow(-1) __attribute_const__ __u64 __fswab64(__u64 val)
79788 {
79789 #ifdef __HAVE_BUILTIN_BSWAP64__
79790 return __builtin_bswap64(val);
79791 diff --git a/include/uapi/linux/sysctl.h b/include/uapi/linux/sysctl.h
79792 index 6d67213..8dab561 100644
79793 --- a/include/uapi/linux/sysctl.h
79794 +++ b/include/uapi/linux/sysctl.h
79795 @@ -155,7 +155,11 @@ enum
79796 KERN_PANIC_ON_NMI=76, /* int: whether we will panic on an unrecovered */
79797 };
79798
79799 -
79800 +#ifdef CONFIG_PAX_SOFTMODE
79801 +enum {
79802 + PAX_SOFTMODE=1 /* PaX: disable/enable soft mode */
79803 +};
79804 +#endif
79805
79806 /* CTL_VM names: */
79807 enum
79808 diff --git a/include/uapi/linux/xattr.h b/include/uapi/linux/xattr.h
79809 index e4629b9..6958086 100644
79810 --- a/include/uapi/linux/xattr.h
79811 +++ b/include/uapi/linux/xattr.h
79812 @@ -63,5 +63,9 @@
79813 #define XATTR_POSIX_ACL_DEFAULT "posix_acl_default"
79814 #define XATTR_NAME_POSIX_ACL_DEFAULT XATTR_SYSTEM_PREFIX XATTR_POSIX_ACL_DEFAULT
79815
79816 +/* User namespace */
79817 +#define XATTR_PAX_PREFIX XATTR_USER_PREFIX "pax."
79818 +#define XATTR_PAX_FLAGS_SUFFIX "flags"
79819 +#define XATTR_NAME_PAX_FLAGS XATTR_PAX_PREFIX XATTR_PAX_FLAGS_SUFFIX
79820
79821 #endif /* _UAPI_LINUX_XATTR_H */
79822 diff --git a/include/video/udlfb.h b/include/video/udlfb.h
79823 index f9466fa..f4e2b81 100644
79824 --- a/include/video/udlfb.h
79825 +++ b/include/video/udlfb.h
79826 @@ -53,10 +53,10 @@ struct dlfb_data {
79827 u32 pseudo_palette[256];
79828 int blank_mode; /*one of FB_BLANK_ */
79829 /* blit-only rendering path metrics, exposed through sysfs */
79830 - atomic_t bytes_rendered; /* raw pixel-bytes driver asked to render */
79831 - atomic_t bytes_identical; /* saved effort with backbuffer comparison */
79832 - atomic_t bytes_sent; /* to usb, after compression including overhead */
79833 - atomic_t cpu_kcycles_used; /* transpired during pixel processing */
79834 + atomic_unchecked_t bytes_rendered; /* raw pixel-bytes driver asked to render */
79835 + atomic_unchecked_t bytes_identical; /* saved effort with backbuffer comparison */
79836 + atomic_unchecked_t bytes_sent; /* to usb, after compression including overhead */
79837 + atomic_unchecked_t cpu_kcycles_used; /* transpired during pixel processing */
79838 };
79839
79840 #define NR_USB_REQUEST_I2C_SUB_IO 0x02
79841 diff --git a/include/video/uvesafb.h b/include/video/uvesafb.h
79842 index 30f5362..8ed8ac9 100644
79843 --- a/include/video/uvesafb.h
79844 +++ b/include/video/uvesafb.h
79845 @@ -122,6 +122,7 @@ struct uvesafb_par {
79846 u8 ypan; /* 0 - nothing, 1 - ypan, 2 - ywrap */
79847 u8 pmi_setpal; /* PMI for palette changes */
79848 u16 *pmi_base; /* protected mode interface location */
79849 + u8 *pmi_code; /* protected mode code location */
79850 void *pmi_start;
79851 void *pmi_pal;
79852 u8 *vbe_state_orig; /*
79853 diff --git a/init/Kconfig b/init/Kconfig
79854 index 3ecd8a1..627843f 100644
79855 --- a/init/Kconfig
79856 +++ b/init/Kconfig
79857 @@ -1086,6 +1086,7 @@ endif # CGROUPS
79858
79859 config CHECKPOINT_RESTORE
79860 bool "Checkpoint/restore support" if EXPERT
79861 + depends on !GRKERNSEC
79862 default n
79863 help
79864 Enables additional kernel features in a sake of checkpoint/restore.
79865 @@ -1557,7 +1558,7 @@ config SLUB_DEBUG
79866
79867 config COMPAT_BRK
79868 bool "Disable heap randomization"
79869 - default y
79870 + default n
79871 help
79872 Randomizing heap placement makes heap exploits harder, but it
79873 also breaks ancient binaries (including anything libc5 based).
79874 @@ -1832,7 +1833,7 @@ config INIT_ALL_POSSIBLE
79875 config STOP_MACHINE
79876 bool
79877 default y
79878 - depends on (SMP && MODULE_UNLOAD) || HOTPLUG_CPU
79879 + depends on (SMP && MODULE_UNLOAD) || HOTPLUG_CPU || GRKERNSEC
79880 help
79881 Need stop_machine() primitive.
79882
79883 diff --git a/init/Makefile b/init/Makefile
79884 index 7bc47ee..6da2dc7 100644
79885 --- a/init/Makefile
79886 +++ b/init/Makefile
79887 @@ -2,6 +2,9 @@
79888 # Makefile for the linux kernel.
79889 #
79890
79891 +ccflags-y := $(GCC_PLUGINS_CFLAGS)
79892 +asflags-y := $(GCC_PLUGINS_AFLAGS)
79893 +
79894 obj-y := main.o version.o mounts.o
79895 ifneq ($(CONFIG_BLK_DEV_INITRD),y)
79896 obj-y += noinitramfs.o
79897 diff --git a/init/do_mounts.c b/init/do_mounts.c
79898 index a51cddc..25c2768 100644
79899 --- a/init/do_mounts.c
79900 +++ b/init/do_mounts.c
79901 @@ -357,11 +357,11 @@ static void __init get_fs_names(char *page)
79902 static int __init do_mount_root(char *name, char *fs, int flags, void *data)
79903 {
79904 struct super_block *s;
79905 - int err = sys_mount(name, "/root", fs, flags, data);
79906 + int err = sys_mount((char __force_user *)name, (char __force_user *)"/root", (char __force_user *)fs, flags, (void __force_user *)data);
79907 if (err)
79908 return err;
79909
79910 - sys_chdir("/root");
79911 + sys_chdir((const char __force_user *)"/root");
79912 s = current->fs->pwd.dentry->d_sb;
79913 ROOT_DEV = s->s_dev;
79914 printk(KERN_INFO
79915 @@ -482,18 +482,18 @@ void __init change_floppy(char *fmt, ...)
79916 va_start(args, fmt);
79917 vsprintf(buf, fmt, args);
79918 va_end(args);
79919 - fd = sys_open("/dev/root", O_RDWR | O_NDELAY, 0);
79920 + fd = sys_open((char __user *)"/dev/root", O_RDWR | O_NDELAY, 0);
79921 if (fd >= 0) {
79922 sys_ioctl(fd, FDEJECT, 0);
79923 sys_close(fd);
79924 }
79925 printk(KERN_NOTICE "VFS: Insert %s and press ENTER\n", buf);
79926 - fd = sys_open("/dev/console", O_RDWR, 0);
79927 + fd = sys_open((__force const char __user *)"/dev/console", O_RDWR, 0);
79928 if (fd >= 0) {
79929 sys_ioctl(fd, TCGETS, (long)&termios);
79930 termios.c_lflag &= ~ICANON;
79931 sys_ioctl(fd, TCSETSF, (long)&termios);
79932 - sys_read(fd, &c, 1);
79933 + sys_read(fd, (char __user *)&c, 1);
79934 termios.c_lflag |= ICANON;
79935 sys_ioctl(fd, TCSETSF, (long)&termios);
79936 sys_close(fd);
79937 @@ -587,8 +587,8 @@ void __init prepare_namespace(void)
79938 mount_root();
79939 out:
79940 devtmpfs_mount("dev");
79941 - sys_mount(".", "/", NULL, MS_MOVE, NULL);
79942 - sys_chroot(".");
79943 + sys_mount((char __force_user *)".", (char __force_user *)"/", NULL, MS_MOVE, NULL);
79944 + sys_chroot((const char __force_user *)".");
79945 }
79946
79947 static bool is_tmpfs;
79948 diff --git a/init/do_mounts.h b/init/do_mounts.h
79949 index f5b978a..69dbfe8 100644
79950 --- a/init/do_mounts.h
79951 +++ b/init/do_mounts.h
79952 @@ -15,15 +15,15 @@ extern int root_mountflags;
79953
79954 static inline int create_dev(char *name, dev_t dev)
79955 {
79956 - sys_unlink(name);
79957 - return sys_mknod(name, S_IFBLK|0600, new_encode_dev(dev));
79958 + sys_unlink((char __force_user *)name);
79959 + return sys_mknod((char __force_user *)name, S_IFBLK|0600, new_encode_dev(dev));
79960 }
79961
79962 #if BITS_PER_LONG == 32
79963 static inline u32 bstat(char *name)
79964 {
79965 struct stat64 stat;
79966 - if (sys_stat64(name, &stat) != 0)
79967 + if (sys_stat64((char __force_user *)name, (struct stat64 __force_user *)&stat) != 0)
79968 return 0;
79969 if (!S_ISBLK(stat.st_mode))
79970 return 0;
79971 @@ -35,7 +35,7 @@ static inline u32 bstat(char *name)
79972 static inline u32 bstat(char *name)
79973 {
79974 struct stat stat;
79975 - if (sys_newstat(name, &stat) != 0)
79976 + if (sys_newstat((const char __force_user *)name, (struct stat __force_user *)&stat) != 0)
79977 return 0;
79978 if (!S_ISBLK(stat.st_mode))
79979 return 0;
79980 diff --git a/init/do_mounts_initrd.c b/init/do_mounts_initrd.c
79981 index 3e0878e..8a9d7a0 100644
79982 --- a/init/do_mounts_initrd.c
79983 +++ b/init/do_mounts_initrd.c
79984 @@ -37,13 +37,13 @@ static int init_linuxrc(struct subprocess_info *info, struct cred *new)
79985 {
79986 sys_unshare(CLONE_FS | CLONE_FILES);
79987 /* stdin/stdout/stderr for /linuxrc */
79988 - sys_open("/dev/console", O_RDWR, 0);
79989 + sys_open((const char __force_user *)"/dev/console", O_RDWR, 0);
79990 sys_dup(0);
79991 sys_dup(0);
79992 /* move initrd over / and chdir/chroot in initrd root */
79993 - sys_chdir("/root");
79994 - sys_mount(".", "/", NULL, MS_MOVE, NULL);
79995 - sys_chroot(".");
79996 + sys_chdir((const char __force_user *)"/root");
79997 + sys_mount((char __force_user *)".", (char __force_user *)"/", NULL, MS_MOVE, NULL);
79998 + sys_chroot((const char __force_user *)".");
79999 sys_setsid();
80000 return 0;
80001 }
80002 @@ -59,8 +59,8 @@ static void __init handle_initrd(void)
80003 create_dev("/dev/root.old", Root_RAM0);
80004 /* mount initrd on rootfs' /root */
80005 mount_block_root("/dev/root.old", root_mountflags & ~MS_RDONLY);
80006 - sys_mkdir("/old", 0700);
80007 - sys_chdir("/old");
80008 + sys_mkdir((const char __force_user *)"/old", 0700);
80009 + sys_chdir((const char __force_user *)"/old");
80010
80011 /* try loading default modules from initrd */
80012 load_default_modules();
80013 @@ -80,31 +80,31 @@ static void __init handle_initrd(void)
80014 current->flags &= ~PF_FREEZER_SKIP;
80015
80016 /* move initrd to rootfs' /old */
80017 - sys_mount("..", ".", NULL, MS_MOVE, NULL);
80018 + sys_mount((char __force_user *)"..", (char __force_user *)".", NULL, MS_MOVE, NULL);
80019 /* switch root and cwd back to / of rootfs */
80020 - sys_chroot("..");
80021 + sys_chroot((const char __force_user *)"..");
80022
80023 if (new_decode_dev(real_root_dev) == Root_RAM0) {
80024 - sys_chdir("/old");
80025 + sys_chdir((const char __force_user *)"/old");
80026 return;
80027 }
80028
80029 - sys_chdir("/");
80030 + sys_chdir((const char __force_user *)"/");
80031 ROOT_DEV = new_decode_dev(real_root_dev);
80032 mount_root();
80033
80034 printk(KERN_NOTICE "Trying to move old root to /initrd ... ");
80035 - error = sys_mount("/old", "/root/initrd", NULL, MS_MOVE, NULL);
80036 + error = sys_mount((char __force_user *)"/old", (char __force_user *)"/root/initrd", NULL, MS_MOVE, NULL);
80037 if (!error)
80038 printk("okay\n");
80039 else {
80040 - int fd = sys_open("/dev/root.old", O_RDWR, 0);
80041 + int fd = sys_open((const char __force_user *)"/dev/root.old", O_RDWR, 0);
80042 if (error == -ENOENT)
80043 printk("/initrd does not exist. Ignored.\n");
80044 else
80045 printk("failed\n");
80046 printk(KERN_NOTICE "Unmounting old root\n");
80047 - sys_umount("/old", MNT_DETACH);
80048 + sys_umount((char __force_user *)"/old", MNT_DETACH);
80049 printk(KERN_NOTICE "Trying to free ramdisk memory ... ");
80050 if (fd < 0) {
80051 error = fd;
80052 @@ -127,11 +127,11 @@ int __init initrd_load(void)
80053 * mounted in the normal path.
80054 */
80055 if (rd_load_image("/initrd.image") && ROOT_DEV != Root_RAM0) {
80056 - sys_unlink("/initrd.image");
80057 + sys_unlink((const char __force_user *)"/initrd.image");
80058 handle_initrd();
80059 return 1;
80060 }
80061 }
80062 - sys_unlink("/initrd.image");
80063 + sys_unlink((const char __force_user *)"/initrd.image");
80064 return 0;
80065 }
80066 diff --git a/init/do_mounts_md.c b/init/do_mounts_md.c
80067 index 8cb6db5..d729f50 100644
80068 --- a/init/do_mounts_md.c
80069 +++ b/init/do_mounts_md.c
80070 @@ -180,7 +180,7 @@ static void __init md_setup_drive(void)
80071 partitioned ? "_d" : "", minor,
80072 md_setup_args[ent].device_names);
80073
80074 - fd = sys_open(name, 0, 0);
80075 + fd = sys_open((char __force_user *)name, 0, 0);
80076 if (fd < 0) {
80077 printk(KERN_ERR "md: open failed - cannot start "
80078 "array %s\n", name);
80079 @@ -243,7 +243,7 @@ static void __init md_setup_drive(void)
80080 * array without it
80081 */
80082 sys_close(fd);
80083 - fd = sys_open(name, 0, 0);
80084 + fd = sys_open((char __force_user *)name, 0, 0);
80085 sys_ioctl(fd, BLKRRPART, 0);
80086 }
80087 sys_close(fd);
80088 @@ -293,7 +293,7 @@ static void __init autodetect_raid(void)
80089
80090 wait_for_device_probe();
80091
80092 - fd = sys_open("/dev/md0", 0, 0);
80093 + fd = sys_open((const char __force_user *) "/dev/md0", 0, 0);
80094 if (fd >= 0) {
80095 sys_ioctl(fd, RAID_AUTORUN, raid_autopart);
80096 sys_close(fd);
80097 diff --git a/init/init_task.c b/init/init_task.c
80098 index ba0a7f36..2bcf1d5 100644
80099 --- a/init/init_task.c
80100 +++ b/init/init_task.c
80101 @@ -22,5 +22,9 @@ EXPORT_SYMBOL(init_task);
80102 * Initial thread structure. Alignment of this is handled by a special
80103 * linker map entry.
80104 */
80105 +#ifdef CONFIG_X86
80106 +union thread_union init_thread_union __init_task_data;
80107 +#else
80108 union thread_union init_thread_union __init_task_data =
80109 { INIT_THREAD_INFO(init_task) };
80110 +#endif
80111 diff --git a/init/initramfs.c b/init/initramfs.c
80112 index a67ef9d..2d17ed9 100644
80113 --- a/init/initramfs.c
80114 +++ b/init/initramfs.c
80115 @@ -84,7 +84,7 @@ static void __init free_hash(void)
80116 }
80117 }
80118
80119 -static long __init do_utime(char *filename, time_t mtime)
80120 +static long __init do_utime(char __force_user *filename, time_t mtime)
80121 {
80122 struct timespec t[2];
80123
80124 @@ -119,7 +119,7 @@ static void __init dir_utime(void)
80125 struct dir_entry *de, *tmp;
80126 list_for_each_entry_safe(de, tmp, &dir_list, list) {
80127 list_del(&de->list);
80128 - do_utime(de->name, de->mtime);
80129 + do_utime((char __force_user *)de->name, de->mtime);
80130 kfree(de->name);
80131 kfree(de);
80132 }
80133 @@ -281,7 +281,7 @@ static int __init maybe_link(void)
80134 if (nlink >= 2) {
80135 char *old = find_link(major, minor, ino, mode, collected);
80136 if (old)
80137 - return (sys_link(old, collected) < 0) ? -1 : 1;
80138 + return (sys_link((char __force_user *)old, (char __force_user *)collected) < 0) ? -1 : 1;
80139 }
80140 return 0;
80141 }
80142 @@ -290,11 +290,11 @@ static void __init clean_path(char *path, umode_t mode)
80143 {
80144 struct stat st;
80145
80146 - if (!sys_newlstat(path, &st) && (st.st_mode^mode) & S_IFMT) {
80147 + if (!sys_newlstat((char __force_user *)path, (struct stat __force_user *)&st) && (st.st_mode^mode) & S_IFMT) {
80148 if (S_ISDIR(st.st_mode))
80149 - sys_rmdir(path);
80150 + sys_rmdir((char __force_user *)path);
80151 else
80152 - sys_unlink(path);
80153 + sys_unlink((char __force_user *)path);
80154 }
80155 }
80156
80157 @@ -315,7 +315,7 @@ static int __init do_name(void)
80158 int openflags = O_WRONLY|O_CREAT;
80159 if (ml != 1)
80160 openflags |= O_TRUNC;
80161 - wfd = sys_open(collected, openflags, mode);
80162 + wfd = sys_open((char __force_user *)collected, openflags, mode);
80163
80164 if (wfd >= 0) {
80165 sys_fchown(wfd, uid, gid);
80166 @@ -327,17 +327,17 @@ static int __init do_name(void)
80167 }
80168 }
80169 } else if (S_ISDIR(mode)) {
80170 - sys_mkdir(collected, mode);
80171 - sys_chown(collected, uid, gid);
80172 - sys_chmod(collected, mode);
80173 + sys_mkdir((char __force_user *)collected, mode);
80174 + sys_chown((char __force_user *)collected, uid, gid);
80175 + sys_chmod((char __force_user *)collected, mode);
80176 dir_add(collected, mtime);
80177 } else if (S_ISBLK(mode) || S_ISCHR(mode) ||
80178 S_ISFIFO(mode) || S_ISSOCK(mode)) {
80179 if (maybe_link() == 0) {
80180 - sys_mknod(collected, mode, rdev);
80181 - sys_chown(collected, uid, gid);
80182 - sys_chmod(collected, mode);
80183 - do_utime(collected, mtime);
80184 + sys_mknod((char __force_user *)collected, mode, rdev);
80185 + sys_chown((char __force_user *)collected, uid, gid);
80186 + sys_chmod((char __force_user *)collected, mode);
80187 + do_utime((char __force_user *)collected, mtime);
80188 }
80189 }
80190 return 0;
80191 @@ -346,15 +346,15 @@ static int __init do_name(void)
80192 static int __init do_copy(void)
80193 {
80194 if (count >= body_len) {
80195 - sys_write(wfd, victim, body_len);
80196 + sys_write(wfd, (char __force_user *)victim, body_len);
80197 sys_close(wfd);
80198 - do_utime(vcollected, mtime);
80199 + do_utime((char __force_user *)vcollected, mtime);
80200 kfree(vcollected);
80201 eat(body_len);
80202 state = SkipIt;
80203 return 0;
80204 } else {
80205 - sys_write(wfd, victim, count);
80206 + sys_write(wfd, (char __force_user *)victim, count);
80207 body_len -= count;
80208 eat(count);
80209 return 1;
80210 @@ -365,9 +365,9 @@ static int __init do_symlink(void)
80211 {
80212 collected[N_ALIGN(name_len) + body_len] = '\0';
80213 clean_path(collected, 0);
80214 - sys_symlink(collected + N_ALIGN(name_len), collected);
80215 - sys_lchown(collected, uid, gid);
80216 - do_utime(collected, mtime);
80217 + sys_symlink((char __force_user *)collected + N_ALIGN(name_len), (char __force_user *)collected);
80218 + sys_lchown((char __force_user *)collected, uid, gid);
80219 + do_utime((char __force_user *)collected, mtime);
80220 state = SkipIt;
80221 next_state = Reset;
80222 return 0;
80223 @@ -583,7 +583,7 @@ static int __init populate_rootfs(void)
80224 {
80225 char *err = unpack_to_rootfs(__initramfs_start, __initramfs_size);
80226 if (err)
80227 - panic(err); /* Failed to decompress INTERNAL initramfs */
80228 + panic("%s", err); /* Failed to decompress INTERNAL initramfs */
80229 if (initrd_start) {
80230 #ifdef CONFIG_BLK_DEV_RAM
80231 int fd;
80232 diff --git a/init/main.c b/init/main.c
80233 index 63d3e8f..50bd5f8 100644
80234 --- a/init/main.c
80235 +++ b/init/main.c
80236 @@ -103,6 +103,8 @@ static inline void mark_rodata_ro(void) { }
80237 extern void tc_init(void);
80238 #endif
80239
80240 +extern void grsecurity_init(void);
80241 +
80242 /*
80243 * Debug helper: via this flag we know that we are in 'early bootup code'
80244 * where only the boot processor is running with IRQ disabled. This means
80245 @@ -156,6 +158,75 @@ static int __init set_reset_devices(char *str)
80246
80247 __setup("reset_devices", set_reset_devices);
80248
80249 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
80250 +kgid_t grsec_proc_gid = KGIDT_INIT(CONFIG_GRKERNSEC_PROC_GID);
80251 +static int __init setup_grsec_proc_gid(char *str)
80252 +{
80253 + grsec_proc_gid = KGIDT_INIT(simple_strtol(str, NULL, 0));
80254 + return 1;
80255 +}
80256 +__setup("grsec_proc_gid=", setup_grsec_proc_gid);
80257 +#endif
80258 +
80259 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
80260 +unsigned long pax_user_shadow_base __read_only;
80261 +EXPORT_SYMBOL(pax_user_shadow_base);
80262 +extern char pax_enter_kernel_user[];
80263 +extern char pax_exit_kernel_user[];
80264 +#endif
80265 +
80266 +#if defined(CONFIG_X86) && defined(CONFIG_PAX_MEMORY_UDEREF)
80267 +static int __init setup_pax_nouderef(char *str)
80268 +{
80269 +#ifdef CONFIG_X86_32
80270 + unsigned int cpu;
80271 + struct desc_struct *gdt;
80272 +
80273 + for (cpu = 0; cpu < nr_cpu_ids; cpu++) {
80274 + gdt = get_cpu_gdt_table(cpu);
80275 + gdt[GDT_ENTRY_KERNEL_DS].type = 3;
80276 + gdt[GDT_ENTRY_KERNEL_DS].limit = 0xf;
80277 + gdt[GDT_ENTRY_DEFAULT_USER_CS].limit = 0xf;
80278 + gdt[GDT_ENTRY_DEFAULT_USER_DS].limit = 0xf;
80279 + }
80280 + loadsegment(ds, __KERNEL_DS);
80281 + loadsegment(es, __KERNEL_DS);
80282 + loadsegment(ss, __KERNEL_DS);
80283 +#else
80284 + memcpy(pax_enter_kernel_user, (unsigned char []){0xc3}, 1);
80285 + memcpy(pax_exit_kernel_user, (unsigned char []){0xc3}, 1);
80286 + clone_pgd_mask = ~(pgdval_t)0UL;
80287 + pax_user_shadow_base = 0UL;
80288 + setup_clear_cpu_cap(X86_FEATURE_PCID);
80289 + setup_clear_cpu_cap(X86_FEATURE_INVPCID);
80290 +#endif
80291 +
80292 + return 0;
80293 +}
80294 +early_param("pax_nouderef", setup_pax_nouderef);
80295 +
80296 +#ifdef CONFIG_X86_64
80297 +static int __init setup_pax_weakuderef(char *str)
80298 +{
80299 + if (clone_pgd_mask != ~(pgdval_t)0UL)
80300 + pax_user_shadow_base = 1UL << TASK_SIZE_MAX_SHIFT;
80301 + return 1;
80302 +}
80303 +__setup("pax_weakuderef", setup_pax_weakuderef);
80304 +#endif
80305 +#endif
80306 +
80307 +#ifdef CONFIG_PAX_SOFTMODE
80308 +int pax_softmode;
80309 +
80310 +static int __init setup_pax_softmode(char *str)
80311 +{
80312 + get_option(&str, &pax_softmode);
80313 + return 1;
80314 +}
80315 +__setup("pax_softmode=", setup_pax_softmode);
80316 +#endif
80317 +
80318 static const char * argv_init[MAX_INIT_ARGS+2] = { "init", NULL, };
80319 const char * envp_init[MAX_INIT_ENVS+2] = { "HOME=/", "TERM=linux", NULL, };
80320 static const char *panic_later, *panic_param;
80321 @@ -682,25 +753,24 @@ int __init_or_module do_one_initcall(initcall_t fn)
80322 {
80323 int count = preempt_count();
80324 int ret;
80325 - char msgbuf[64];
80326 + const char *msg1 = "", *msg2 = "";
80327
80328 if (initcall_debug)
80329 ret = do_one_initcall_debug(fn);
80330 else
80331 ret = fn();
80332
80333 - msgbuf[0] = 0;
80334 -
80335 if (preempt_count() != count) {
80336 - sprintf(msgbuf, "preemption imbalance ");
80337 + msg1 = " preemption imbalance";
80338 preempt_count() = count;
80339 }
80340 if (irqs_disabled()) {
80341 - strlcat(msgbuf, "disabled interrupts ", sizeof(msgbuf));
80342 + msg2 = " disabled interrupts";
80343 local_irq_enable();
80344 }
80345 - WARN(msgbuf[0], "initcall %pF returned with %s\n", fn, msgbuf);
80346 + WARN(*msg1 || *msg2, "initcall %pF returned with%s%s\n", fn, msg1, msg2);
80347
80348 + add_latent_entropy();
80349 return ret;
80350 }
80351
80352 @@ -807,10 +877,14 @@ static int run_init_process(const char *init_filename)
80353 {
80354 argv_init[0] = init_filename;
80355 return do_execve(init_filename,
80356 - (const char __user *const __user *)argv_init,
80357 - (const char __user *const __user *)envp_init);
80358 + (const char __user *const __force_user *)argv_init,
80359 + (const char __user *const __force_user *)envp_init);
80360 }
80361
80362 +#ifdef CONFIG_GRKERNSEC_CHROOT_INITRD
80363 +extern int gr_init_ran;
80364 +#endif
80365 +
80366 static noinline void __init kernel_init_freeable(void);
80367
80368 static int __ref kernel_init(void *unused)
80369 @@ -831,6 +905,11 @@ static int __ref kernel_init(void *unused)
80370 pr_err("Failed to execute %s\n", ramdisk_execute_command);
80371 }
80372
80373 +#ifdef CONFIG_GRKERNSEC_CHROOT_INITRD
80374 + /* if no initrd was used, be extra sure we enforce chroot restrictions */
80375 + gr_init_ran = 1;
80376 +#endif
80377 +
80378 /*
80379 * We try each of these until one succeeds.
80380 *
80381 @@ -885,7 +964,7 @@ static noinline void __init kernel_init_freeable(void)
80382 do_basic_setup();
80383
80384 /* Open the /dev/console on the rootfs, this should never fail */
80385 - if (sys_open((const char __user *) "/dev/console", O_RDWR, 0) < 0)
80386 + if (sys_open((const char __force_user *) "/dev/console", O_RDWR, 0) < 0)
80387 pr_err("Warning: unable to open an initial console.\n");
80388
80389 (void) sys_dup(0);
80390 @@ -898,11 +977,13 @@ static noinline void __init kernel_init_freeable(void)
80391 if (!ramdisk_execute_command)
80392 ramdisk_execute_command = "/init";
80393
80394 - if (sys_access((const char __user *) ramdisk_execute_command, 0) != 0) {
80395 + if (sys_access((const char __force_user *) ramdisk_execute_command, 0) != 0) {
80396 ramdisk_execute_command = NULL;
80397 prepare_namespace();
80398 }
80399
80400 + grsecurity_init();
80401 +
80402 /*
80403 * Ok, we have completed the initial bootup, and
80404 * we're essentially up and running. Get rid of the
80405 diff --git a/ipc/ipc_sysctl.c b/ipc/ipc_sysctl.c
80406 index b0e99de..09f385c 100644
80407 --- a/ipc/ipc_sysctl.c
80408 +++ b/ipc/ipc_sysctl.c
80409 @@ -30,7 +30,7 @@ static void *get_ipc(ctl_table *table)
80410 static int proc_ipc_dointvec(ctl_table *table, int write,
80411 void __user *buffer, size_t *lenp, loff_t *ppos)
80412 {
80413 - struct ctl_table ipc_table;
80414 + ctl_table_no_const ipc_table;
80415
80416 memcpy(&ipc_table, table, sizeof(ipc_table));
80417 ipc_table.data = get_ipc(table);
80418 @@ -41,7 +41,7 @@ static int proc_ipc_dointvec(ctl_table *table, int write,
80419 static int proc_ipc_dointvec_minmax(ctl_table *table, int write,
80420 void __user *buffer, size_t *lenp, loff_t *ppos)
80421 {
80422 - struct ctl_table ipc_table;
80423 + ctl_table_no_const ipc_table;
80424
80425 memcpy(&ipc_table, table, sizeof(ipc_table));
80426 ipc_table.data = get_ipc(table);
80427 @@ -65,7 +65,7 @@ static int proc_ipc_dointvec_minmax_orphans(ctl_table *table, int write,
80428 static int proc_ipc_callback_dointvec_minmax(ctl_table *table, int write,
80429 void __user *buffer, size_t *lenp, loff_t *ppos)
80430 {
80431 - struct ctl_table ipc_table;
80432 + ctl_table_no_const ipc_table;
80433 size_t lenp_bef = *lenp;
80434 int rc;
80435
80436 @@ -88,7 +88,7 @@ static int proc_ipc_callback_dointvec_minmax(ctl_table *table, int write,
80437 static int proc_ipc_doulongvec_minmax(ctl_table *table, int write,
80438 void __user *buffer, size_t *lenp, loff_t *ppos)
80439 {
80440 - struct ctl_table ipc_table;
80441 + ctl_table_no_const ipc_table;
80442 memcpy(&ipc_table, table, sizeof(ipc_table));
80443 ipc_table.data = get_ipc(table);
80444
80445 @@ -122,7 +122,7 @@ static void ipc_auto_callback(int val)
80446 static int proc_ipcauto_dointvec_minmax(ctl_table *table, int write,
80447 void __user *buffer, size_t *lenp, loff_t *ppos)
80448 {
80449 - struct ctl_table ipc_table;
80450 + ctl_table_no_const ipc_table;
80451 size_t lenp_bef = *lenp;
80452 int oldval;
80453 int rc;
80454 diff --git a/ipc/mq_sysctl.c b/ipc/mq_sysctl.c
80455 index 383d638..943fdbb 100644
80456 --- a/ipc/mq_sysctl.c
80457 +++ b/ipc/mq_sysctl.c
80458 @@ -25,7 +25,7 @@ static void *get_mq(ctl_table *table)
80459 static int proc_mq_dointvec_minmax(ctl_table *table, int write,
80460 void __user *buffer, size_t *lenp, loff_t *ppos)
80461 {
80462 - struct ctl_table mq_table;
80463 + ctl_table_no_const mq_table;
80464 memcpy(&mq_table, table, sizeof(mq_table));
80465 mq_table.data = get_mq(table);
80466
80467 diff --git a/ipc/mqueue.c b/ipc/mqueue.c
80468 index ae1996d..a35f2cc 100644
80469 --- a/ipc/mqueue.c
80470 +++ b/ipc/mqueue.c
80471 @@ -278,6 +278,7 @@ static struct inode *mqueue_get_inode(struct super_block *sb,
80472 mq_bytes = mq_treesize + (info->attr.mq_maxmsg *
80473 info->attr.mq_msgsize);
80474
80475 + gr_learn_resource(current, RLIMIT_MSGQUEUE, u->mq_bytes + mq_bytes, 1);
80476 spin_lock(&mq_lock);
80477 if (u->mq_bytes + mq_bytes < u->mq_bytes ||
80478 u->mq_bytes + mq_bytes > rlimit(RLIMIT_MSGQUEUE)) {
80479 diff --git a/ipc/msg.c b/ipc/msg.c
80480 index 558aa91..359e718 100644
80481 --- a/ipc/msg.c
80482 +++ b/ipc/msg.c
80483 @@ -297,18 +297,19 @@ static inline int msg_security(struct kern_ipc_perm *ipcp, int msgflg)
80484 return security_msg_queue_associate(msq, msgflg);
80485 }
80486
80487 +static struct ipc_ops msg_ops = {
80488 + .getnew = newque,
80489 + .associate = msg_security,
80490 + .more_checks = NULL
80491 +};
80492 +
80493 SYSCALL_DEFINE2(msgget, key_t, key, int, msgflg)
80494 {
80495 struct ipc_namespace *ns;
80496 - struct ipc_ops msg_ops;
80497 struct ipc_params msg_params;
80498
80499 ns = current->nsproxy->ipc_ns;
80500
80501 - msg_ops.getnew = newque;
80502 - msg_ops.associate = msg_security;
80503 - msg_ops.more_checks = NULL;
80504 -
80505 msg_params.key = key;
80506 msg_params.flg = msgflg;
80507
80508 diff --git a/ipc/sem.c b/ipc/sem.c
80509 index db9d241..bc8427c 100644
80510 --- a/ipc/sem.c
80511 +++ b/ipc/sem.c
80512 @@ -562,10 +562,15 @@ static inline int sem_more_checks(struct kern_ipc_perm *ipcp,
80513 return 0;
80514 }
80515
80516 +static struct ipc_ops sem_ops = {
80517 + .getnew = newary,
80518 + .associate = sem_security,
80519 + .more_checks = sem_more_checks
80520 +};
80521 +
80522 SYSCALL_DEFINE3(semget, key_t, key, int, nsems, int, semflg)
80523 {
80524 struct ipc_namespace *ns;
80525 - struct ipc_ops sem_ops;
80526 struct ipc_params sem_params;
80527
80528 ns = current->nsproxy->ipc_ns;
80529 @@ -573,10 +578,6 @@ SYSCALL_DEFINE3(semget, key_t, key, int, nsems, int, semflg)
80530 if (nsems < 0 || nsems > ns->sc_semmsl)
80531 return -EINVAL;
80532
80533 - sem_ops.getnew = newary;
80534 - sem_ops.associate = sem_security;
80535 - sem_ops.more_checks = sem_more_checks;
80536 -
80537 sem_params.key = key;
80538 sem_params.flg = semflg;
80539 sem_params.u.nsems = nsems;
80540 diff --git a/ipc/shm.c b/ipc/shm.c
80541 index 7a51443..3a257d8 100644
80542 --- a/ipc/shm.c
80543 +++ b/ipc/shm.c
80544 @@ -72,6 +72,14 @@ static void shm_destroy (struct ipc_namespace *ns, struct shmid_kernel *shp);
80545 static int sysvipc_shm_proc_show(struct seq_file *s, void *it);
80546 #endif
80547
80548 +#ifdef CONFIG_GRKERNSEC
80549 +extern int gr_handle_shmat(const pid_t shm_cprid, const pid_t shm_lapid,
80550 + const time_t shm_createtime, const kuid_t cuid,
80551 + const int shmid);
80552 +extern int gr_chroot_shmat(const pid_t shm_cprid, const pid_t shm_lapid,
80553 + const time_t shm_createtime);
80554 +#endif
80555 +
80556 void shm_init_ns(struct ipc_namespace *ns)
80557 {
80558 ns->shm_ctlmax = SHMMAX;
80559 @@ -554,6 +562,14 @@ static int newseg(struct ipc_namespace *ns, struct ipc_params *params)
80560 shp->shm_lprid = 0;
80561 shp->shm_atim = shp->shm_dtim = 0;
80562 shp->shm_ctim = get_seconds();
80563 +#ifdef CONFIG_GRKERNSEC
80564 + {
80565 + struct timespec timeval;
80566 + do_posix_clock_monotonic_gettime(&timeval);
80567 +
80568 + shp->shm_createtime = timeval.tv_sec;
80569 + }
80570 +#endif
80571 shp->shm_segsz = size;
80572 shp->shm_nattch = 0;
80573 shp->shm_file = file;
80574 @@ -607,18 +623,19 @@ static inline int shm_more_checks(struct kern_ipc_perm *ipcp,
80575 return 0;
80576 }
80577
80578 +static struct ipc_ops shm_ops = {
80579 + .getnew = newseg,
80580 + .associate = shm_security,
80581 + .more_checks = shm_more_checks
80582 +};
80583 +
80584 SYSCALL_DEFINE3(shmget, key_t, key, size_t, size, int, shmflg)
80585 {
80586 struct ipc_namespace *ns;
80587 - struct ipc_ops shm_ops;
80588 struct ipc_params shm_params;
80589
80590 ns = current->nsproxy->ipc_ns;
80591
80592 - shm_ops.getnew = newseg;
80593 - shm_ops.associate = shm_security;
80594 - shm_ops.more_checks = shm_more_checks;
80595 -
80596 shm_params.key = key;
80597 shm_params.flg = shmflg;
80598 shm_params.u.size = size;
80599 @@ -1089,6 +1106,12 @@ long do_shmat(int shmid, char __user *shmaddr, int shmflg, ulong *raddr,
80600 f_mode = FMODE_READ | FMODE_WRITE;
80601 }
80602 if (shmflg & SHM_EXEC) {
80603 +
80604 +#ifdef CONFIG_PAX_MPROTECT
80605 + if (current->mm->pax_flags & MF_PAX_MPROTECT)
80606 + goto out;
80607 +#endif
80608 +
80609 prot |= PROT_EXEC;
80610 acc_mode |= S_IXUGO;
80611 }
80612 @@ -1113,6 +1136,15 @@ long do_shmat(int shmid, char __user *shmaddr, int shmflg, ulong *raddr,
80613 if (err)
80614 goto out_unlock;
80615
80616 +#ifdef CONFIG_GRKERNSEC
80617 + if (!gr_handle_shmat(shp->shm_cprid, shp->shm_lapid, shp->shm_createtime,
80618 + shp->shm_perm.cuid, shmid) ||
80619 + !gr_chroot_shmat(shp->shm_cprid, shp->shm_lapid, shp->shm_createtime)) {
80620 + err = -EACCES;
80621 + goto out_unlock;
80622 + }
80623 +#endif
80624 +
80625 ipc_lock_object(&shp->shm_perm);
80626
80627 /* check if shm_destroy() is tearing down shp */
80628 @@ -1125,6 +1157,9 @@ long do_shmat(int shmid, char __user *shmaddr, int shmflg, ulong *raddr,
80629 path = shp->shm_file->f_path;
80630 path_get(&path);
80631 shp->shm_nattch++;
80632 +#ifdef CONFIG_GRKERNSEC
80633 + shp->shm_lapid = current->pid;
80634 +#endif
80635 size = i_size_read(path.dentry->d_inode);
80636 ipc_unlock_object(&shp->shm_perm);
80637 rcu_read_unlock();
80638 diff --git a/ipc/util.c b/ipc/util.c
80639 index 7684f41..f7da711 100644
80640 --- a/ipc/util.c
80641 +++ b/ipc/util.c
80642 @@ -71,6 +71,8 @@ struct ipc_proc_iface {
80643 int (*show)(struct seq_file *, void *);
80644 };
80645
80646 +extern int gr_ipc_permitted(struct ipc_namespace *ns, struct kern_ipc_perm *ipcp, int requested_mode, int granted_mode);
80647 +
80648 static void ipc_memory_notifier(struct work_struct *work)
80649 {
80650 ipcns_notify(IPCNS_MEMCHANGED);
80651 @@ -560,6 +562,9 @@ int ipcperms(struct ipc_namespace *ns, struct kern_ipc_perm *ipcp, short flag)
80652 granted_mode >>= 6;
80653 else if (in_group_p(ipcp->cgid) || in_group_p(ipcp->gid))
80654 granted_mode >>= 3;
80655 + else if (!gr_ipc_permitted(ns, ipcp, requested_mode, granted_mode))
80656 + return -1;
80657 +
80658 /* is there some bit set in requested_mode but not in granted_mode? */
80659 if ((requested_mode & ~granted_mode & 0007) &&
80660 !ns_capable(ns->user_ns, CAP_IPC_OWNER))
80661 diff --git a/kernel/acct.c b/kernel/acct.c
80662 index 8d6e145..33e0b1e 100644
80663 --- a/kernel/acct.c
80664 +++ b/kernel/acct.c
80665 @@ -556,7 +556,7 @@ static void do_acct_process(struct bsd_acct_struct *acct,
80666 */
80667 flim = current->signal->rlim[RLIMIT_FSIZE].rlim_cur;
80668 current->signal->rlim[RLIMIT_FSIZE].rlim_cur = RLIM_INFINITY;
80669 - file->f_op->write(file, (char *)&ac,
80670 + file->f_op->write(file, (char __force_user *)&ac,
80671 sizeof(acct_t), &file->f_pos);
80672 current->signal->rlim[RLIMIT_FSIZE].rlim_cur = flim;
80673 set_fs(fs);
80674 diff --git a/kernel/audit.c b/kernel/audit.c
80675 index 7ddfd8a..49766eb 100644
80676 --- a/kernel/audit.c
80677 +++ b/kernel/audit.c
80678 @@ -118,7 +118,7 @@ u32 audit_sig_sid = 0;
80679 3) suppressed due to audit_rate_limit
80680 4) suppressed due to audit_backlog_limit
80681 */
80682 -static atomic_t audit_lost = ATOMIC_INIT(0);
80683 +static atomic_unchecked_t audit_lost = ATOMIC_INIT(0);
80684
80685 /* The netlink socket. */
80686 static struct sock *audit_sock;
80687 @@ -240,7 +240,7 @@ void audit_log_lost(const char *message)
80688 unsigned long now;
80689 int print;
80690
80691 - atomic_inc(&audit_lost);
80692 + atomic_inc_unchecked(&audit_lost);
80693
80694 print = (audit_failure == AUDIT_FAIL_PANIC || !audit_rate_limit);
80695
80696 @@ -259,7 +259,7 @@ void audit_log_lost(const char *message)
80697 printk(KERN_WARNING
80698 "audit: audit_lost=%d audit_rate_limit=%d "
80699 "audit_backlog_limit=%d\n",
80700 - atomic_read(&audit_lost),
80701 + atomic_read_unchecked(&audit_lost),
80702 audit_rate_limit,
80703 audit_backlog_limit);
80704 audit_panic(message);
80705 @@ -665,7 +665,7 @@ static int audit_receive_msg(struct sk_buff *skb, struct nlmsghdr *nlh)
80706 status_set.pid = audit_pid;
80707 status_set.rate_limit = audit_rate_limit;
80708 status_set.backlog_limit = audit_backlog_limit;
80709 - status_set.lost = atomic_read(&audit_lost);
80710 + status_set.lost = atomic_read_unchecked(&audit_lost);
80711 status_set.backlog = skb_queue_len(&audit_skb_queue);
80712 audit_send_reply(NETLINK_CB(skb).portid, seq, AUDIT_GET, 0, 0,
80713 &status_set, sizeof(status_set));
80714 @@ -1252,7 +1252,7 @@ void audit_log_n_hex(struct audit_buffer *ab, const unsigned char *buf,
80715 int i, avail, new_len;
80716 unsigned char *ptr;
80717 struct sk_buff *skb;
80718 - static const unsigned char *hex = "0123456789ABCDEF";
80719 + static const unsigned char hex[] = "0123456789ABCDEF";
80720
80721 if (!ab)
80722 return;
80723 diff --git a/kernel/auditsc.c b/kernel/auditsc.c
80724 index 9845cb3..3ec9369 100644
80725 --- a/kernel/auditsc.c
80726 +++ b/kernel/auditsc.c
80727 @@ -1962,7 +1962,7 @@ int auditsc_get_stamp(struct audit_context *ctx,
80728 }
80729
80730 /* global counter which is incremented every time something logs in */
80731 -static atomic_t session_id = ATOMIC_INIT(0);
80732 +static atomic_unchecked_t session_id = ATOMIC_INIT(0);
80733
80734 /**
80735 * audit_set_loginuid - set current task's audit_context loginuid
80736 @@ -1986,7 +1986,7 @@ int audit_set_loginuid(kuid_t loginuid)
80737 return -EPERM;
80738 #endif /* CONFIG_AUDIT_LOGINUID_IMMUTABLE */
80739
80740 - sessionid = atomic_inc_return(&session_id);
80741 + sessionid = atomic_inc_return_unchecked(&session_id);
80742 if (context && context->in_syscall) {
80743 struct audit_buffer *ab;
80744
80745 diff --git a/kernel/capability.c b/kernel/capability.c
80746 index 4e66bf9..cdccecf 100644
80747 --- a/kernel/capability.c
80748 +++ b/kernel/capability.c
80749 @@ -202,6 +202,9 @@ SYSCALL_DEFINE2(capget, cap_user_header_t, header, cap_user_data_t, dataptr)
80750 * before modification is attempted and the application
80751 * fails.
80752 */
80753 + if (tocopy > ARRAY_SIZE(kdata))
80754 + return -EFAULT;
80755 +
80756 if (copy_to_user(dataptr, kdata, tocopy
80757 * sizeof(struct __user_cap_data_struct))) {
80758 return -EFAULT;
80759 @@ -303,10 +306,11 @@ bool has_ns_capability(struct task_struct *t,
80760 int ret;
80761
80762 rcu_read_lock();
80763 - ret = security_capable(__task_cred(t), ns, cap);
80764 + ret = security_capable(__task_cred(t), ns, cap) == 0 &&
80765 + gr_task_is_capable(t, __task_cred(t), cap);
80766 rcu_read_unlock();
80767
80768 - return (ret == 0);
80769 + return ret;
80770 }
80771
80772 /**
80773 @@ -343,10 +347,10 @@ bool has_ns_capability_noaudit(struct task_struct *t,
80774 int ret;
80775
80776 rcu_read_lock();
80777 - ret = security_capable_noaudit(__task_cred(t), ns, cap);
80778 + ret = security_capable_noaudit(__task_cred(t), ns, cap) == 0 && gr_task_is_capable_nolog(t, cap);
80779 rcu_read_unlock();
80780
80781 - return (ret == 0);
80782 + return ret;
80783 }
80784
80785 /**
80786 @@ -384,7 +388,7 @@ bool ns_capable(struct user_namespace *ns, int cap)
80787 BUG();
80788 }
80789
80790 - if (security_capable(current_cred(), ns, cap) == 0) {
80791 + if (security_capable(current_cred(), ns, cap) == 0 && gr_is_capable(cap)) {
80792 current->flags |= PF_SUPERPRIV;
80793 return true;
80794 }
80795 @@ -392,6 +396,21 @@ bool ns_capable(struct user_namespace *ns, int cap)
80796 }
80797 EXPORT_SYMBOL(ns_capable);
80798
80799 +bool ns_capable_nolog(struct user_namespace *ns, int cap)
80800 +{
80801 + if (unlikely(!cap_valid(cap))) {
80802 + printk(KERN_CRIT "capable_nolog() called with invalid cap=%u\n", cap);
80803 + BUG();
80804 + }
80805 +
80806 + if (security_capable_noaudit(current_cred(), ns, cap) == 0 && gr_is_capable_nolog(cap)) {
80807 + current->flags |= PF_SUPERPRIV;
80808 + return true;
80809 + }
80810 + return false;
80811 +}
80812 +EXPORT_SYMBOL(ns_capable_nolog);
80813 +
80814 /**
80815 * file_ns_capable - Determine if the file's opener had a capability in effect
80816 * @file: The file we want to check
80817 @@ -432,6 +451,12 @@ bool capable(int cap)
80818 }
80819 EXPORT_SYMBOL(capable);
80820
80821 +bool capable_nolog(int cap)
80822 +{
80823 + return ns_capable_nolog(&init_user_ns, cap);
80824 +}
80825 +EXPORT_SYMBOL(capable_nolog);
80826 +
80827 /**
80828 * inode_capable - Check superior capability over inode
80829 * @inode: The inode in question
80830 @@ -453,3 +478,11 @@ bool inode_capable(const struct inode *inode, int cap)
80831 return ns_capable(ns, cap) && kuid_has_mapping(ns, inode->i_uid);
80832 }
80833 EXPORT_SYMBOL(inode_capable);
80834 +
80835 +bool inode_capable_nolog(const struct inode *inode, int cap)
80836 +{
80837 + struct user_namespace *ns = current_user_ns();
80838 +
80839 + return ns_capable_nolog(ns, cap) && kuid_has_mapping(ns, inode->i_uid);
80840 +}
80841 +EXPORT_SYMBOL(inode_capable_nolog);
80842 diff --git a/kernel/cgroup.c b/kernel/cgroup.c
80843 index 5c9127d..f871169 100644
80844 --- a/kernel/cgroup.c
80845 +++ b/kernel/cgroup.c
80846 @@ -5844,7 +5844,7 @@ static int cgroup_css_links_read(struct cgroup_subsys_state *css,
80847 struct css_set *cset = link->cset;
80848 struct task_struct *task;
80849 int count = 0;
80850 - seq_printf(seq, "css_set %p\n", cset);
80851 + seq_printf(seq, "css_set %pK\n", cset);
80852 list_for_each_entry(task, &cset->tasks, cg_list) {
80853 if (count++ > MAX_TASKS_SHOWN_PER_CSS) {
80854 seq_puts(seq, " ...\n");
80855 diff --git a/kernel/compat.c b/kernel/compat.c
80856 index 0a09e48..f44f3f0 100644
80857 --- a/kernel/compat.c
80858 +++ b/kernel/compat.c
80859 @@ -13,6 +13,7 @@
80860
80861 #include <linux/linkage.h>
80862 #include <linux/compat.h>
80863 +#include <linux/module.h>
80864 #include <linux/errno.h>
80865 #include <linux/time.h>
80866 #include <linux/signal.h>
80867 @@ -220,7 +221,7 @@ static long compat_nanosleep_restart(struct restart_block *restart)
80868 mm_segment_t oldfs;
80869 long ret;
80870
80871 - restart->nanosleep.rmtp = (struct timespec __user *) &rmt;
80872 + restart->nanosleep.rmtp = (struct timespec __force_user *) &rmt;
80873 oldfs = get_fs();
80874 set_fs(KERNEL_DS);
80875 ret = hrtimer_nanosleep_restart(restart);
80876 @@ -252,7 +253,7 @@ asmlinkage long compat_sys_nanosleep(struct compat_timespec __user *rqtp,
80877 oldfs = get_fs();
80878 set_fs(KERNEL_DS);
80879 ret = hrtimer_nanosleep(&tu,
80880 - rmtp ? (struct timespec __user *)&rmt : NULL,
80881 + rmtp ? (struct timespec __force_user *)&rmt : NULL,
80882 HRTIMER_MODE_REL, CLOCK_MONOTONIC);
80883 set_fs(oldfs);
80884
80885 @@ -361,7 +362,7 @@ asmlinkage long compat_sys_sigpending(compat_old_sigset_t __user *set)
80886 mm_segment_t old_fs = get_fs();
80887
80888 set_fs(KERNEL_DS);
80889 - ret = sys_sigpending((old_sigset_t __user *) &s);
80890 + ret = sys_sigpending((old_sigset_t __force_user *) &s);
80891 set_fs(old_fs);
80892 if (ret == 0)
80893 ret = put_user(s, set);
80894 @@ -451,7 +452,7 @@ asmlinkage long compat_sys_old_getrlimit(unsigned int resource,
80895 mm_segment_t old_fs = get_fs();
80896
80897 set_fs(KERNEL_DS);
80898 - ret = sys_old_getrlimit(resource, &r);
80899 + ret = sys_old_getrlimit(resource, (struct rlimit __force_user *)&r);
80900 set_fs(old_fs);
80901
80902 if (!ret) {
80903 @@ -533,8 +534,8 @@ COMPAT_SYSCALL_DEFINE4(wait4,
80904 set_fs (KERNEL_DS);
80905 ret = sys_wait4(pid,
80906 (stat_addr ?
80907 - (unsigned int __user *) &status : NULL),
80908 - options, (struct rusage __user *) &r);
80909 + (unsigned int __force_user *) &status : NULL),
80910 + options, (struct rusage __force_user *) &r);
80911 set_fs (old_fs);
80912
80913 if (ret > 0) {
80914 @@ -560,8 +561,8 @@ COMPAT_SYSCALL_DEFINE5(waitid,
80915 memset(&info, 0, sizeof(info));
80916
80917 set_fs(KERNEL_DS);
80918 - ret = sys_waitid(which, pid, (siginfo_t __user *)&info, options,
80919 - uru ? (struct rusage __user *)&ru : NULL);
80920 + ret = sys_waitid(which, pid, (siginfo_t __force_user *)&info, options,
80921 + uru ? (struct rusage __force_user *)&ru : NULL);
80922 set_fs(old_fs);
80923
80924 if ((ret < 0) || (info.si_signo == 0))
80925 @@ -695,8 +696,8 @@ long compat_sys_timer_settime(timer_t timer_id, int flags,
80926 oldfs = get_fs();
80927 set_fs(KERNEL_DS);
80928 err = sys_timer_settime(timer_id, flags,
80929 - (struct itimerspec __user *) &newts,
80930 - (struct itimerspec __user *) &oldts);
80931 + (struct itimerspec __force_user *) &newts,
80932 + (struct itimerspec __force_user *) &oldts);
80933 set_fs(oldfs);
80934 if (!err && old && put_compat_itimerspec(old, &oldts))
80935 return -EFAULT;
80936 @@ -713,7 +714,7 @@ long compat_sys_timer_gettime(timer_t timer_id,
80937 oldfs = get_fs();
80938 set_fs(KERNEL_DS);
80939 err = sys_timer_gettime(timer_id,
80940 - (struct itimerspec __user *) &ts);
80941 + (struct itimerspec __force_user *) &ts);
80942 set_fs(oldfs);
80943 if (!err && put_compat_itimerspec(setting, &ts))
80944 return -EFAULT;
80945 @@ -732,7 +733,7 @@ long compat_sys_clock_settime(clockid_t which_clock,
80946 oldfs = get_fs();
80947 set_fs(KERNEL_DS);
80948 err = sys_clock_settime(which_clock,
80949 - (struct timespec __user *) &ts);
80950 + (struct timespec __force_user *) &ts);
80951 set_fs(oldfs);
80952 return err;
80953 }
80954 @@ -747,7 +748,7 @@ long compat_sys_clock_gettime(clockid_t which_clock,
80955 oldfs = get_fs();
80956 set_fs(KERNEL_DS);
80957 err = sys_clock_gettime(which_clock,
80958 - (struct timespec __user *) &ts);
80959 + (struct timespec __force_user *) &ts);
80960 set_fs(oldfs);
80961 if (!err && put_compat_timespec(&ts, tp))
80962 return -EFAULT;
80963 @@ -767,7 +768,7 @@ long compat_sys_clock_adjtime(clockid_t which_clock,
80964
80965 oldfs = get_fs();
80966 set_fs(KERNEL_DS);
80967 - ret = sys_clock_adjtime(which_clock, (struct timex __user *) &txc);
80968 + ret = sys_clock_adjtime(which_clock, (struct timex __force_user *) &txc);
80969 set_fs(oldfs);
80970
80971 err = compat_put_timex(utp, &txc);
80972 @@ -787,7 +788,7 @@ long compat_sys_clock_getres(clockid_t which_clock,
80973 oldfs = get_fs();
80974 set_fs(KERNEL_DS);
80975 err = sys_clock_getres(which_clock,
80976 - (struct timespec __user *) &ts);
80977 + (struct timespec __force_user *) &ts);
80978 set_fs(oldfs);
80979 if (!err && tp && put_compat_timespec(&ts, tp))
80980 return -EFAULT;
80981 @@ -799,9 +800,9 @@ static long compat_clock_nanosleep_restart(struct restart_block *restart)
80982 long err;
80983 mm_segment_t oldfs;
80984 struct timespec tu;
80985 - struct compat_timespec *rmtp = restart->nanosleep.compat_rmtp;
80986 + struct compat_timespec __user *rmtp = restart->nanosleep.compat_rmtp;
80987
80988 - restart->nanosleep.rmtp = (struct timespec __user *) &tu;
80989 + restart->nanosleep.rmtp = (struct timespec __force_user *) &tu;
80990 oldfs = get_fs();
80991 set_fs(KERNEL_DS);
80992 err = clock_nanosleep_restart(restart);
80993 @@ -833,8 +834,8 @@ long compat_sys_clock_nanosleep(clockid_t which_clock, int flags,
80994 oldfs = get_fs();
80995 set_fs(KERNEL_DS);
80996 err = sys_clock_nanosleep(which_clock, flags,
80997 - (struct timespec __user *) &in,
80998 - (struct timespec __user *) &out);
80999 + (struct timespec __force_user *) &in,
81000 + (struct timespec __force_user *) &out);
81001 set_fs(oldfs);
81002
81003 if ((err == -ERESTART_RESTARTBLOCK) && rmtp &&
81004 diff --git a/kernel/configs.c b/kernel/configs.c
81005 index c18b1f1..b9a0132 100644
81006 --- a/kernel/configs.c
81007 +++ b/kernel/configs.c
81008 @@ -74,8 +74,19 @@ static int __init ikconfig_init(void)
81009 struct proc_dir_entry *entry;
81010
81011 /* create the current config file */
81012 +#if defined(CONFIG_GRKERNSEC_PROC_ADD) || defined(CONFIG_GRKERNSEC_HIDESYM)
81013 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_HIDESYM)
81014 + entry = proc_create("config.gz", S_IFREG | S_IRUSR, NULL,
81015 + &ikconfig_file_ops);
81016 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
81017 + entry = proc_create("config.gz", S_IFREG | S_IRUSR | S_IRGRP, NULL,
81018 + &ikconfig_file_ops);
81019 +#endif
81020 +#else
81021 entry = proc_create("config.gz", S_IFREG | S_IRUGO, NULL,
81022 &ikconfig_file_ops);
81023 +#endif
81024 +
81025 if (!entry)
81026 return -ENOMEM;
81027
81028 diff --git a/kernel/cred.c b/kernel/cred.c
81029 index e0573a4..3874e41 100644
81030 --- a/kernel/cred.c
81031 +++ b/kernel/cred.c
81032 @@ -164,6 +164,16 @@ void exit_creds(struct task_struct *tsk)
81033 validate_creds(cred);
81034 alter_cred_subscribers(cred, -1);
81035 put_cred(cred);
81036 +
81037 +#ifdef CONFIG_GRKERNSEC_SETXID
81038 + cred = (struct cred *) tsk->delayed_cred;
81039 + if (cred != NULL) {
81040 + tsk->delayed_cred = NULL;
81041 + validate_creds(cred);
81042 + alter_cred_subscribers(cred, -1);
81043 + put_cred(cred);
81044 + }
81045 +#endif
81046 }
81047
81048 /**
81049 @@ -411,7 +421,7 @@ static bool cred_cap_issubset(const struct cred *set, const struct cred *subset)
81050 * Always returns 0 thus allowing this function to be tail-called at the end
81051 * of, say, sys_setgid().
81052 */
81053 -int commit_creds(struct cred *new)
81054 +static int __commit_creds(struct cred *new)
81055 {
81056 struct task_struct *task = current;
81057 const struct cred *old = task->real_cred;
81058 @@ -430,6 +440,8 @@ int commit_creds(struct cred *new)
81059
81060 get_cred(new); /* we will require a ref for the subj creds too */
81061
81062 + gr_set_role_label(task, new->uid, new->gid);
81063 +
81064 /* dumpability changes */
81065 if (!uid_eq(old->euid, new->euid) ||
81066 !gid_eq(old->egid, new->egid) ||
81067 @@ -479,6 +491,102 @@ int commit_creds(struct cred *new)
81068 put_cred(old);
81069 return 0;
81070 }
81071 +#ifdef CONFIG_GRKERNSEC_SETXID
81072 +extern int set_user(struct cred *new);
81073 +
81074 +void gr_delayed_cred_worker(void)
81075 +{
81076 + const struct cred *new = current->delayed_cred;
81077 + struct cred *ncred;
81078 +
81079 + current->delayed_cred = NULL;
81080 +
81081 + if (!uid_eq(current_uid(), GLOBAL_ROOT_UID) && new != NULL) {
81082 + // from doing get_cred on it when queueing this
81083 + put_cred(new);
81084 + return;
81085 + } else if (new == NULL)
81086 + return;
81087 +
81088 + ncred = prepare_creds();
81089 + if (!ncred)
81090 + goto die;
81091 + // uids
81092 + ncred->uid = new->uid;
81093 + ncred->euid = new->euid;
81094 + ncred->suid = new->suid;
81095 + ncred->fsuid = new->fsuid;
81096 + // gids
81097 + ncred->gid = new->gid;
81098 + ncred->egid = new->egid;
81099 + ncred->sgid = new->sgid;
81100 + ncred->fsgid = new->fsgid;
81101 + // groups
81102 + if (set_groups(ncred, new->group_info) < 0) {
81103 + abort_creds(ncred);
81104 + goto die;
81105 + }
81106 + // caps
81107 + ncred->securebits = new->securebits;
81108 + ncred->cap_inheritable = new->cap_inheritable;
81109 + ncred->cap_permitted = new->cap_permitted;
81110 + ncred->cap_effective = new->cap_effective;
81111 + ncred->cap_bset = new->cap_bset;
81112 +
81113 + if (set_user(ncred)) {
81114 + abort_creds(ncred);
81115 + goto die;
81116 + }
81117 +
81118 + // from doing get_cred on it when queueing this
81119 + put_cred(new);
81120 +
81121 + __commit_creds(ncred);
81122 + return;
81123 +die:
81124 + // from doing get_cred on it when queueing this
81125 + put_cred(new);
81126 + do_group_exit(SIGKILL);
81127 +}
81128 +#endif
81129 +
81130 +int commit_creds(struct cred *new)
81131 +{
81132 +#ifdef CONFIG_GRKERNSEC_SETXID
81133 + int ret;
81134 + int schedule_it = 0;
81135 + struct task_struct *t;
81136 +
81137 + /* we won't get called with tasklist_lock held for writing
81138 + and interrupts disabled as the cred struct in that case is
81139 + init_cred
81140 + */
81141 + if (grsec_enable_setxid && !current_is_single_threaded() &&
81142 + uid_eq(current_uid(), GLOBAL_ROOT_UID) &&
81143 + !uid_eq(new->uid, GLOBAL_ROOT_UID)) {
81144 + schedule_it = 1;
81145 + }
81146 + ret = __commit_creds(new);
81147 + if (schedule_it) {
81148 + rcu_read_lock();
81149 + read_lock(&tasklist_lock);
81150 + for (t = next_thread(current); t != current;
81151 + t = next_thread(t)) {
81152 + if (t->delayed_cred == NULL) {
81153 + t->delayed_cred = get_cred(new);
81154 + set_tsk_thread_flag(t, TIF_GRSEC_SETXID);
81155 + set_tsk_need_resched(t);
81156 + }
81157 + }
81158 + read_unlock(&tasklist_lock);
81159 + rcu_read_unlock();
81160 + }
81161 + return ret;
81162 +#else
81163 + return __commit_creds(new);
81164 +#endif
81165 +}
81166 +
81167 EXPORT_SYMBOL(commit_creds);
81168
81169 /**
81170 diff --git a/kernel/debug/debug_core.c b/kernel/debug/debug_core.c
81171 index 0506d44..2c20034 100644
81172 --- a/kernel/debug/debug_core.c
81173 +++ b/kernel/debug/debug_core.c
81174 @@ -123,7 +123,7 @@ static DEFINE_RAW_SPINLOCK(dbg_slave_lock);
81175 */
81176 static atomic_t masters_in_kgdb;
81177 static atomic_t slaves_in_kgdb;
81178 -static atomic_t kgdb_break_tasklet_var;
81179 +static atomic_unchecked_t kgdb_break_tasklet_var;
81180 atomic_t kgdb_setting_breakpoint;
81181
81182 struct task_struct *kgdb_usethread;
81183 @@ -133,7 +133,7 @@ int kgdb_single_step;
81184 static pid_t kgdb_sstep_pid;
81185
81186 /* to keep track of the CPU which is doing the single stepping*/
81187 -atomic_t kgdb_cpu_doing_single_step = ATOMIC_INIT(-1);
81188 +atomic_unchecked_t kgdb_cpu_doing_single_step = ATOMIC_INIT(-1);
81189
81190 /*
81191 * If you are debugging a problem where roundup (the collection of
81192 @@ -541,7 +541,7 @@ return_normal:
81193 * kernel will only try for the value of sstep_tries before
81194 * giving up and continuing on.
81195 */
81196 - if (atomic_read(&kgdb_cpu_doing_single_step) != -1 &&
81197 + if (atomic_read_unchecked(&kgdb_cpu_doing_single_step) != -1 &&
81198 (kgdb_info[cpu].task &&
81199 kgdb_info[cpu].task->pid != kgdb_sstep_pid) && --sstep_tries) {
81200 atomic_set(&kgdb_active, -1);
81201 @@ -635,8 +635,8 @@ cpu_master_loop:
81202 }
81203
81204 kgdb_restore:
81205 - if (atomic_read(&kgdb_cpu_doing_single_step) != -1) {
81206 - int sstep_cpu = atomic_read(&kgdb_cpu_doing_single_step);
81207 + if (atomic_read_unchecked(&kgdb_cpu_doing_single_step) != -1) {
81208 + int sstep_cpu = atomic_read_unchecked(&kgdb_cpu_doing_single_step);
81209 if (kgdb_info[sstep_cpu].task)
81210 kgdb_sstep_pid = kgdb_info[sstep_cpu].task->pid;
81211 else
81212 @@ -888,18 +888,18 @@ static void kgdb_unregister_callbacks(void)
81213 static void kgdb_tasklet_bpt(unsigned long ing)
81214 {
81215 kgdb_breakpoint();
81216 - atomic_set(&kgdb_break_tasklet_var, 0);
81217 + atomic_set_unchecked(&kgdb_break_tasklet_var, 0);
81218 }
81219
81220 static DECLARE_TASKLET(kgdb_tasklet_breakpoint, kgdb_tasklet_bpt, 0);
81221
81222 void kgdb_schedule_breakpoint(void)
81223 {
81224 - if (atomic_read(&kgdb_break_tasklet_var) ||
81225 + if (atomic_read_unchecked(&kgdb_break_tasklet_var) ||
81226 atomic_read(&kgdb_active) != -1 ||
81227 atomic_read(&kgdb_setting_breakpoint))
81228 return;
81229 - atomic_inc(&kgdb_break_tasklet_var);
81230 + atomic_inc_unchecked(&kgdb_break_tasklet_var);
81231 tasklet_schedule(&kgdb_tasklet_breakpoint);
81232 }
81233 EXPORT_SYMBOL_GPL(kgdb_schedule_breakpoint);
81234 diff --git a/kernel/debug/kdb/kdb_main.c b/kernel/debug/kdb/kdb_main.c
81235 index 00eb8f7..d7e3244 100644
81236 --- a/kernel/debug/kdb/kdb_main.c
81237 +++ b/kernel/debug/kdb/kdb_main.c
81238 @@ -1974,7 +1974,7 @@ static int kdb_lsmod(int argc, const char **argv)
81239 continue;
81240
81241 kdb_printf("%-20s%8u 0x%p ", mod->name,
81242 - mod->core_size, (void *)mod);
81243 + mod->core_size_rx + mod->core_size_rw, (void *)mod);
81244 #ifdef CONFIG_MODULE_UNLOAD
81245 kdb_printf("%4ld ", module_refcount(mod));
81246 #endif
81247 @@ -1984,7 +1984,7 @@ static int kdb_lsmod(int argc, const char **argv)
81248 kdb_printf(" (Loading)");
81249 else
81250 kdb_printf(" (Live)");
81251 - kdb_printf(" 0x%p", mod->module_core);
81252 + kdb_printf(" 0x%p 0x%p", mod->module_core_rx, mod->module_core_rw);
81253
81254 #ifdef CONFIG_MODULE_UNLOAD
81255 {
81256 diff --git a/kernel/events/core.c b/kernel/events/core.c
81257 index 953c143..5646bb1 100644
81258 --- a/kernel/events/core.c
81259 +++ b/kernel/events/core.c
81260 @@ -157,8 +157,15 @@ static struct srcu_struct pmus_srcu;
81261 * 0 - disallow raw tracepoint access for unpriv
81262 * 1 - disallow cpu events for unpriv
81263 * 2 - disallow kernel profiling for unpriv
81264 + * 3 - disallow all unpriv perf event use
81265 */
81266 -int sysctl_perf_event_paranoid __read_mostly = 1;
81267 +#ifdef CONFIG_GRKERNSEC_PERF_HARDEN
81268 +int sysctl_perf_event_legitimately_concerned __read_mostly = 3;
81269 +#elif defined(CONFIG_GRKERNSEC_HIDESYM)
81270 +int sysctl_perf_event_legitimately_concerned __read_mostly = 2;
81271 +#else
81272 +int sysctl_perf_event_legitimately_concerned __read_mostly = 1;
81273 +#endif
81274
81275 /* Minimum for 512 kiB + 1 user control page */
81276 int sysctl_perf_event_mlock __read_mostly = 512 + (PAGE_SIZE / 1024); /* 'free' kiB per user */
81277 @@ -271,7 +278,7 @@ void perf_sample_event_took(u64 sample_len_ns)
81278 update_perf_cpu_limits();
81279 }
81280
81281 -static atomic64_t perf_event_id;
81282 +static atomic64_unchecked_t perf_event_id;
81283
81284 static void cpu_ctx_sched_out(struct perf_cpu_context *cpuctx,
81285 enum event_type_t event_type);
81286 @@ -2940,7 +2947,7 @@ static void __perf_event_read(void *info)
81287
81288 static inline u64 perf_event_count(struct perf_event *event)
81289 {
81290 - return local64_read(&event->count) + atomic64_read(&event->child_count);
81291 + return local64_read(&event->count) + atomic64_read_unchecked(&event->child_count);
81292 }
81293
81294 static u64 perf_event_read(struct perf_event *event)
81295 @@ -3308,9 +3315,9 @@ u64 perf_event_read_value(struct perf_event *event, u64 *enabled, u64 *running)
81296 mutex_lock(&event->child_mutex);
81297 total += perf_event_read(event);
81298 *enabled += event->total_time_enabled +
81299 - atomic64_read(&event->child_total_time_enabled);
81300 + atomic64_read_unchecked(&event->child_total_time_enabled);
81301 *running += event->total_time_running +
81302 - atomic64_read(&event->child_total_time_running);
81303 + atomic64_read_unchecked(&event->child_total_time_running);
81304
81305 list_for_each_entry(child, &event->child_list, child_list) {
81306 total += perf_event_read(child);
81307 @@ -3725,10 +3732,10 @@ void perf_event_update_userpage(struct perf_event *event)
81308 userpg->offset -= local64_read(&event->hw.prev_count);
81309
81310 userpg->time_enabled = enabled +
81311 - atomic64_read(&event->child_total_time_enabled);
81312 + atomic64_read_unchecked(&event->child_total_time_enabled);
81313
81314 userpg->time_running = running +
81315 - atomic64_read(&event->child_total_time_running);
81316 + atomic64_read_unchecked(&event->child_total_time_running);
81317
81318 arch_perf_update_userpage(userpg, now);
81319
81320 @@ -4279,7 +4286,7 @@ perf_output_sample_ustack(struct perf_output_handle *handle, u64 dump_size,
81321
81322 /* Data. */
81323 sp = perf_user_stack_pointer(regs);
81324 - rem = __output_copy_user(handle, (void *) sp, dump_size);
81325 + rem = __output_copy_user(handle, (void __user *) sp, dump_size);
81326 dyn_size = dump_size - rem;
81327
81328 perf_output_skip(handle, rem);
81329 @@ -4370,11 +4377,11 @@ static void perf_output_read_one(struct perf_output_handle *handle,
81330 values[n++] = perf_event_count(event);
81331 if (read_format & PERF_FORMAT_TOTAL_TIME_ENABLED) {
81332 values[n++] = enabled +
81333 - atomic64_read(&event->child_total_time_enabled);
81334 + atomic64_read_unchecked(&event->child_total_time_enabled);
81335 }
81336 if (read_format & PERF_FORMAT_TOTAL_TIME_RUNNING) {
81337 values[n++] = running +
81338 - atomic64_read(&event->child_total_time_running);
81339 + atomic64_read_unchecked(&event->child_total_time_running);
81340 }
81341 if (read_format & PERF_FORMAT_ID)
81342 values[n++] = primary_event_id(event);
81343 @@ -5112,12 +5119,12 @@ static void perf_event_mmap_event(struct perf_mmap_event *mmap_event)
81344 * need to add enough zero bytes after the string to handle
81345 * the 64bit alignment we do later.
81346 */
81347 - buf = kzalloc(PATH_MAX + sizeof(u64), GFP_KERNEL);
81348 + buf = kzalloc(PATH_MAX, GFP_KERNEL);
81349 if (!buf) {
81350 name = strncpy(tmp, "//enomem", sizeof(tmp));
81351 goto got_name;
81352 }
81353 - name = d_path(&file->f_path, buf, PATH_MAX);
81354 + name = d_path(&file->f_path, buf, PATH_MAX - sizeof(u64));
81355 if (IS_ERR(name)) {
81356 name = strncpy(tmp, "//toolong", sizeof(tmp));
81357 goto got_name;
81358 @@ -6639,7 +6646,7 @@ perf_event_alloc(struct perf_event_attr *attr, int cpu,
81359 event->parent = parent_event;
81360
81361 event->ns = get_pid_ns(task_active_pid_ns(current));
81362 - event->id = atomic64_inc_return(&perf_event_id);
81363 + event->id = atomic64_inc_return_unchecked(&perf_event_id);
81364
81365 event->state = PERF_EVENT_STATE_INACTIVE;
81366
81367 @@ -6938,6 +6945,11 @@ SYSCALL_DEFINE5(perf_event_open,
81368 if (flags & ~PERF_FLAG_ALL)
81369 return -EINVAL;
81370
81371 +#ifdef CONFIG_GRKERNSEC_PERF_HARDEN
81372 + if (perf_paranoid_any() && !capable(CAP_SYS_ADMIN))
81373 + return -EACCES;
81374 +#endif
81375 +
81376 err = perf_copy_attr(attr_uptr, &attr);
81377 if (err)
81378 return err;
81379 @@ -7271,10 +7283,10 @@ static void sync_child_event(struct perf_event *child_event,
81380 /*
81381 * Add back the child's count to the parent's count:
81382 */
81383 - atomic64_add(child_val, &parent_event->child_count);
81384 - atomic64_add(child_event->total_time_enabled,
81385 + atomic64_add_unchecked(child_val, &parent_event->child_count);
81386 + atomic64_add_unchecked(child_event->total_time_enabled,
81387 &parent_event->child_total_time_enabled);
81388 - atomic64_add(child_event->total_time_running,
81389 + atomic64_add_unchecked(child_event->total_time_running,
81390 &parent_event->child_total_time_running);
81391
81392 /*
81393 diff --git a/kernel/events/internal.h b/kernel/events/internal.h
81394 index ca65997..60df03d 100644
81395 --- a/kernel/events/internal.h
81396 +++ b/kernel/events/internal.h
81397 @@ -81,10 +81,10 @@ static inline unsigned long perf_data_size(struct ring_buffer *rb)
81398 return rb->nr_pages << (PAGE_SHIFT + page_order(rb));
81399 }
81400
81401 -#define DEFINE_OUTPUT_COPY(func_name, memcpy_func) \
81402 -static inline unsigned int \
81403 +#define DEFINE_OUTPUT_COPY(func_name, memcpy_func, user) \
81404 +static inline unsigned long \
81405 func_name(struct perf_output_handle *handle, \
81406 - const void *buf, unsigned int len) \
81407 + const void user *buf, unsigned long len) \
81408 { \
81409 unsigned long size, written; \
81410 \
81411 @@ -116,17 +116,17 @@ static inline int memcpy_common(void *dst, const void *src, size_t n)
81412 return n;
81413 }
81414
81415 -DEFINE_OUTPUT_COPY(__output_copy, memcpy_common)
81416 +DEFINE_OUTPUT_COPY(__output_copy, memcpy_common, )
81417
81418 #define MEMCPY_SKIP(dst, src, n) (n)
81419
81420 -DEFINE_OUTPUT_COPY(__output_skip, MEMCPY_SKIP)
81421 +DEFINE_OUTPUT_COPY(__output_skip, MEMCPY_SKIP, )
81422
81423 #ifndef arch_perf_out_copy_user
81424 #define arch_perf_out_copy_user __copy_from_user_inatomic
81425 #endif
81426
81427 -DEFINE_OUTPUT_COPY(__output_copy_user, arch_perf_out_copy_user)
81428 +DEFINE_OUTPUT_COPY(__output_copy_user, arch_perf_out_copy_user, __user)
81429
81430 /* Callchain handling */
81431 extern struct perf_callchain_entry *
81432 diff --git a/kernel/events/uprobes.c b/kernel/events/uprobes.c
81433 index ad8e1bd..fed7ba9 100644
81434 --- a/kernel/events/uprobes.c
81435 +++ b/kernel/events/uprobes.c
81436 @@ -1556,7 +1556,7 @@ static int is_trap_at_addr(struct mm_struct *mm, unsigned long vaddr)
81437 {
81438 struct page *page;
81439 uprobe_opcode_t opcode;
81440 - int result;
81441 + long result;
81442
81443 pagefault_disable();
81444 result = __copy_from_user_inatomic(&opcode, (void __user*)vaddr,
81445 diff --git a/kernel/exit.c b/kernel/exit.c
81446 index a949819..a5f127d 100644
81447 --- a/kernel/exit.c
81448 +++ b/kernel/exit.c
81449 @@ -172,6 +172,10 @@ void release_task(struct task_struct * p)
81450 struct task_struct *leader;
81451 int zap_leader;
81452 repeat:
81453 +#ifdef CONFIG_NET
81454 + gr_del_task_from_ip_table(p);
81455 +#endif
81456 +
81457 /* don't need to get the RCU readlock here - the process is dead and
81458 * can't be modifying its own credentials. But shut RCU-lockdep up */
81459 rcu_read_lock();
81460 @@ -329,7 +333,7 @@ int allow_signal(int sig)
81461 * know it'll be handled, so that they don't get converted to
81462 * SIGKILL or just silently dropped.
81463 */
81464 - current->sighand->action[(sig)-1].sa.sa_handler = (void __user *)2;
81465 + current->sighand->action[(sig)-1].sa.sa_handler = (__force void __user *)2;
81466 recalc_sigpending();
81467 spin_unlock_irq(&current->sighand->siglock);
81468 return 0;
81469 @@ -698,6 +702,8 @@ void do_exit(long code)
81470 struct task_struct *tsk = current;
81471 int group_dead;
81472
81473 + set_fs(USER_DS);
81474 +
81475 profile_task_exit(tsk);
81476
81477 WARN_ON(blk_needs_flush_plug(tsk));
81478 @@ -714,7 +720,6 @@ void do_exit(long code)
81479 * mm_release()->clear_child_tid() from writing to a user-controlled
81480 * kernel address.
81481 */
81482 - set_fs(USER_DS);
81483
81484 ptrace_event(PTRACE_EVENT_EXIT, code);
81485
81486 @@ -773,6 +778,9 @@ void do_exit(long code)
81487 tsk->exit_code = code;
81488 taskstats_exit(tsk, group_dead);
81489
81490 + gr_acl_handle_psacct(tsk, code);
81491 + gr_acl_handle_exit();
81492 +
81493 exit_mm(tsk);
81494
81495 if (group_dead)
81496 @@ -894,7 +902,7 @@ SYSCALL_DEFINE1(exit, int, error_code)
81497 * Take down every thread in the group. This is called by fatal signals
81498 * as well as by sys_exit_group (below).
81499 */
81500 -void
81501 +__noreturn void
81502 do_group_exit(int exit_code)
81503 {
81504 struct signal_struct *sig = current->signal;
81505 diff --git a/kernel/fork.c b/kernel/fork.c
81506 index 086fe73..72c1122 100644
81507 --- a/kernel/fork.c
81508 +++ b/kernel/fork.c
81509 @@ -319,7 +319,7 @@ static struct task_struct *dup_task_struct(struct task_struct *orig)
81510 *stackend = STACK_END_MAGIC; /* for overflow detection */
81511
81512 #ifdef CONFIG_CC_STACKPROTECTOR
81513 - tsk->stack_canary = get_random_int();
81514 + tsk->stack_canary = pax_get_random_long();
81515 #endif
81516
81517 /*
81518 @@ -345,12 +345,80 @@ free_tsk:
81519 }
81520
81521 #ifdef CONFIG_MMU
81522 -static int dup_mmap(struct mm_struct *mm, struct mm_struct *oldmm)
81523 +static struct vm_area_struct *dup_vma(struct mm_struct *mm, struct mm_struct *oldmm, struct vm_area_struct *mpnt)
81524 +{
81525 + struct vm_area_struct *tmp;
81526 + unsigned long charge;
81527 + struct file *file;
81528 + int retval;
81529 +
81530 + charge = 0;
81531 + if (mpnt->vm_flags & VM_ACCOUNT) {
81532 + unsigned long len = vma_pages(mpnt);
81533 +
81534 + if (security_vm_enough_memory_mm(oldmm, len)) /* sic */
81535 + goto fail_nomem;
81536 + charge = len;
81537 + }
81538 + tmp = kmem_cache_alloc(vm_area_cachep, GFP_KERNEL);
81539 + if (!tmp)
81540 + goto fail_nomem;
81541 + *tmp = *mpnt;
81542 + tmp->vm_mm = mm;
81543 + INIT_LIST_HEAD(&tmp->anon_vma_chain);
81544 + retval = vma_dup_policy(mpnt, tmp);
81545 + if (retval)
81546 + goto fail_nomem_policy;
81547 + if (anon_vma_fork(tmp, mpnt))
81548 + goto fail_nomem_anon_vma_fork;
81549 + tmp->vm_flags &= ~VM_LOCKED;
81550 + tmp->vm_next = tmp->vm_prev = NULL;
81551 + tmp->vm_mirror = NULL;
81552 + file = tmp->vm_file;
81553 + if (file) {
81554 + struct inode *inode = file_inode(file);
81555 + struct address_space *mapping = file->f_mapping;
81556 +
81557 + get_file(file);
81558 + if (tmp->vm_flags & VM_DENYWRITE)
81559 + atomic_dec(&inode->i_writecount);
81560 + mutex_lock(&mapping->i_mmap_mutex);
81561 + if (tmp->vm_flags & VM_SHARED)
81562 + mapping->i_mmap_writable++;
81563 + flush_dcache_mmap_lock(mapping);
81564 + /* insert tmp into the share list, just after mpnt */
81565 + if (unlikely(tmp->vm_flags & VM_NONLINEAR))
81566 + vma_nonlinear_insert(tmp, &mapping->i_mmap_nonlinear);
81567 + else
81568 + vma_interval_tree_insert_after(tmp, mpnt, &mapping->i_mmap);
81569 + flush_dcache_mmap_unlock(mapping);
81570 + mutex_unlock(&mapping->i_mmap_mutex);
81571 + }
81572 +
81573 + /*
81574 + * Clear hugetlb-related page reserves for children. This only
81575 + * affects MAP_PRIVATE mappings. Faults generated by the child
81576 + * are not guaranteed to succeed, even if read-only
81577 + */
81578 + if (is_vm_hugetlb_page(tmp))
81579 + reset_vma_resv_huge_pages(tmp);
81580 +
81581 + return tmp;
81582 +
81583 +fail_nomem_anon_vma_fork:
81584 + mpol_put(vma_policy(tmp));
81585 +fail_nomem_policy:
81586 + kmem_cache_free(vm_area_cachep, tmp);
81587 +fail_nomem:
81588 + vm_unacct_memory(charge);
81589 + return NULL;
81590 +}
81591 +
81592 +static __latent_entropy int dup_mmap(struct mm_struct *mm, struct mm_struct *oldmm)
81593 {
81594 struct vm_area_struct *mpnt, *tmp, *prev, **pprev;
81595 struct rb_node **rb_link, *rb_parent;
81596 int retval;
81597 - unsigned long charge;
81598
81599 uprobe_start_dup_mmap();
81600 down_write(&oldmm->mmap_sem);
81601 @@ -379,55 +447,15 @@ static int dup_mmap(struct mm_struct *mm, struct mm_struct *oldmm)
81602
81603 prev = NULL;
81604 for (mpnt = oldmm->mmap; mpnt; mpnt = mpnt->vm_next) {
81605 - struct file *file;
81606 -
81607 if (mpnt->vm_flags & VM_DONTCOPY) {
81608 vm_stat_account(mm, mpnt->vm_flags, mpnt->vm_file,
81609 -vma_pages(mpnt));
81610 continue;
81611 }
81612 - charge = 0;
81613 - if (mpnt->vm_flags & VM_ACCOUNT) {
81614 - unsigned long len = vma_pages(mpnt);
81615 -
81616 - if (security_vm_enough_memory_mm(oldmm, len)) /* sic */
81617 - goto fail_nomem;
81618 - charge = len;
81619 - }
81620 - tmp = kmem_cache_alloc(vm_area_cachep, GFP_KERNEL);
81621 - if (!tmp)
81622 - goto fail_nomem;
81623 - *tmp = *mpnt;
81624 - INIT_LIST_HEAD(&tmp->anon_vma_chain);
81625 - retval = vma_dup_policy(mpnt, tmp);
81626 - if (retval)
81627 - goto fail_nomem_policy;
81628 - tmp->vm_mm = mm;
81629 - if (anon_vma_fork(tmp, mpnt))
81630 - goto fail_nomem_anon_vma_fork;
81631 - tmp->vm_flags &= ~VM_LOCKED;
81632 - tmp->vm_next = tmp->vm_prev = NULL;
81633 - file = tmp->vm_file;
81634 - if (file) {
81635 - struct inode *inode = file_inode(file);
81636 - struct address_space *mapping = file->f_mapping;
81637 -
81638 - get_file(file);
81639 - if (tmp->vm_flags & VM_DENYWRITE)
81640 - atomic_dec(&inode->i_writecount);
81641 - mutex_lock(&mapping->i_mmap_mutex);
81642 - if (tmp->vm_flags & VM_SHARED)
81643 - mapping->i_mmap_writable++;
81644 - flush_dcache_mmap_lock(mapping);
81645 - /* insert tmp into the share list, just after mpnt */
81646 - if (unlikely(tmp->vm_flags & VM_NONLINEAR))
81647 - vma_nonlinear_insert(tmp,
81648 - &mapping->i_mmap_nonlinear);
81649 - else
81650 - vma_interval_tree_insert_after(tmp, mpnt,
81651 - &mapping->i_mmap);
81652 - flush_dcache_mmap_unlock(mapping);
81653 - mutex_unlock(&mapping->i_mmap_mutex);
81654 + tmp = dup_vma(mm, oldmm, mpnt);
81655 + if (!tmp) {
81656 + retval = -ENOMEM;
81657 + goto out;
81658 }
81659
81660 /*
81661 @@ -459,6 +487,31 @@ static int dup_mmap(struct mm_struct *mm, struct mm_struct *oldmm)
81662 if (retval)
81663 goto out;
81664 }
81665 +
81666 +#ifdef CONFIG_PAX_SEGMEXEC
81667 + if (oldmm->pax_flags & MF_PAX_SEGMEXEC) {
81668 + struct vm_area_struct *mpnt_m;
81669 +
81670 + for (mpnt = oldmm->mmap, mpnt_m = mm->mmap; mpnt; mpnt = mpnt->vm_next, mpnt_m = mpnt_m->vm_next) {
81671 + BUG_ON(!mpnt_m || mpnt_m->vm_mirror || mpnt->vm_mm != oldmm || mpnt_m->vm_mm != mm);
81672 +
81673 + if (!mpnt->vm_mirror)
81674 + continue;
81675 +
81676 + if (mpnt->vm_end <= SEGMEXEC_TASK_SIZE) {
81677 + BUG_ON(mpnt->vm_mirror->vm_mirror != mpnt);
81678 + mpnt->vm_mirror = mpnt_m;
81679 + } else {
81680 + BUG_ON(mpnt->vm_mirror->vm_mirror == mpnt || mpnt->vm_mirror->vm_mirror->vm_mm != mm);
81681 + mpnt_m->vm_mirror = mpnt->vm_mirror->vm_mirror;
81682 + mpnt_m->vm_mirror->vm_mirror = mpnt_m;
81683 + mpnt->vm_mirror->vm_mirror = mpnt;
81684 + }
81685 + }
81686 + BUG_ON(mpnt_m);
81687 + }
81688 +#endif
81689 +
81690 /* a new mm has just been created */
81691 arch_dup_mmap(oldmm, mm);
81692 retval = 0;
81693 @@ -468,14 +521,6 @@ out:
81694 up_write(&oldmm->mmap_sem);
81695 uprobe_end_dup_mmap();
81696 return retval;
81697 -fail_nomem_anon_vma_fork:
81698 - mpol_put(vma_policy(tmp));
81699 -fail_nomem_policy:
81700 - kmem_cache_free(vm_area_cachep, tmp);
81701 -fail_nomem:
81702 - retval = -ENOMEM;
81703 - vm_unacct_memory(charge);
81704 - goto out;
81705 }
81706
81707 static inline int mm_alloc_pgd(struct mm_struct *mm)
81708 @@ -688,8 +733,8 @@ struct mm_struct *mm_access(struct task_struct *task, unsigned int mode)
81709 return ERR_PTR(err);
81710
81711 mm = get_task_mm(task);
81712 - if (mm && mm != current->mm &&
81713 - !ptrace_may_access(task, mode)) {
81714 + if (mm && ((mm != current->mm && !ptrace_may_access(task, mode)) ||
81715 + (mode == PTRACE_MODE_ATTACH && (gr_handle_proc_ptrace(task) || gr_acl_handle_procpidmem(task))))) {
81716 mmput(mm);
81717 mm = ERR_PTR(-EACCES);
81718 }
81719 @@ -911,13 +956,20 @@ static int copy_fs(unsigned long clone_flags, struct task_struct *tsk)
81720 spin_unlock(&fs->lock);
81721 return -EAGAIN;
81722 }
81723 - fs->users++;
81724 + atomic_inc(&fs->users);
81725 spin_unlock(&fs->lock);
81726 return 0;
81727 }
81728 tsk->fs = copy_fs_struct(fs);
81729 if (!tsk->fs)
81730 return -ENOMEM;
81731 + /* Carry through gr_chroot_dentry and is_chrooted instead
81732 + of recomputing it here. Already copied when the task struct
81733 + is duplicated. This allows pivot_root to not be treated as
81734 + a chroot
81735 + */
81736 + //gr_set_chroot_entries(tsk, &tsk->fs->root);
81737 +
81738 return 0;
81739 }
81740
81741 @@ -1128,7 +1180,7 @@ init_task_pid(struct task_struct *task, enum pid_type type, struct pid *pid)
81742 * parts of the process environment (as per the clone
81743 * flags). The actual kick-off is left to the caller.
81744 */
81745 -static struct task_struct *copy_process(unsigned long clone_flags,
81746 +static __latent_entropy struct task_struct *copy_process(unsigned long clone_flags,
81747 unsigned long stack_start,
81748 unsigned long stack_size,
81749 int __user *child_tidptr,
81750 @@ -1200,6 +1252,9 @@ static struct task_struct *copy_process(unsigned long clone_flags,
81751 DEBUG_LOCKS_WARN_ON(!p->softirqs_enabled);
81752 #endif
81753 retval = -EAGAIN;
81754 +
81755 + gr_learn_resource(p, RLIMIT_NPROC, atomic_read(&p->real_cred->user->processes), 0);
81756 +
81757 if (atomic_read(&p->real_cred->user->processes) >=
81758 task_rlimit(p, RLIMIT_NPROC)) {
81759 if (p->real_cred->user != INIT_USER &&
81760 @@ -1449,6 +1504,11 @@ static struct task_struct *copy_process(unsigned long clone_flags,
81761 goto bad_fork_free_pid;
81762 }
81763
81764 + /* synchronizes with gr_set_acls()
81765 + we need to call this past the point of no return for fork()
81766 + */
81767 + gr_copy_label(p);
81768 +
81769 if (likely(p->pid)) {
81770 ptrace_init_task(p, (clone_flags & CLONE_PTRACE) || trace);
81771
81772 @@ -1534,6 +1594,8 @@ bad_fork_cleanup_count:
81773 bad_fork_free:
81774 free_task(p);
81775 fork_out:
81776 + gr_log_forkfail(retval);
81777 +
81778 return ERR_PTR(retval);
81779 }
81780
81781 @@ -1595,6 +1657,7 @@ long do_fork(unsigned long clone_flags,
81782
81783 p = copy_process(clone_flags, stack_start, stack_size,
81784 child_tidptr, NULL, trace);
81785 + add_latent_entropy();
81786 /*
81787 * Do this prior waking up the new thread - the thread pointer
81788 * might get invalid after that point, if the thread exits quickly.
81789 @@ -1609,6 +1672,8 @@ long do_fork(unsigned long clone_flags,
81790 if (clone_flags & CLONE_PARENT_SETTID)
81791 put_user(nr, parent_tidptr);
81792
81793 + gr_handle_brute_check();
81794 +
81795 if (clone_flags & CLONE_VFORK) {
81796 p->vfork_done = &vfork;
81797 init_completion(&vfork);
81798 @@ -1725,7 +1790,7 @@ void __init proc_caches_init(void)
81799 mm_cachep = kmem_cache_create("mm_struct",
81800 sizeof(struct mm_struct), ARCH_MIN_MMSTRUCT_ALIGN,
81801 SLAB_HWCACHE_ALIGN|SLAB_PANIC|SLAB_NOTRACK, NULL);
81802 - vm_area_cachep = KMEM_CACHE(vm_area_struct, SLAB_PANIC);
81803 + vm_area_cachep = KMEM_CACHE(vm_area_struct, SLAB_PANIC | SLAB_NO_SANITIZE);
81804 mmap_init();
81805 nsproxy_cache_init();
81806 }
81807 @@ -1765,7 +1830,7 @@ static int unshare_fs(unsigned long unshare_flags, struct fs_struct **new_fsp)
81808 return 0;
81809
81810 /* don't need lock here; in the worst case we'll do useless copy */
81811 - if (fs->users == 1)
81812 + if (atomic_read(&fs->users) == 1)
81813 return 0;
81814
81815 *new_fsp = copy_fs_struct(fs);
81816 @@ -1872,7 +1937,8 @@ SYSCALL_DEFINE1(unshare, unsigned long, unshare_flags)
81817 fs = current->fs;
81818 spin_lock(&fs->lock);
81819 current->fs = new_fs;
81820 - if (--fs->users)
81821 + gr_set_chroot_entries(current, &current->fs->root);
81822 + if (atomic_dec_return(&fs->users))
81823 new_fs = NULL;
81824 else
81825 new_fs = fs;
81826 diff --git a/kernel/futex.c b/kernel/futex.c
81827 index c3a1a55..e32b4a98 100644
81828 --- a/kernel/futex.c
81829 +++ b/kernel/futex.c
81830 @@ -54,6 +54,7 @@
81831 #include <linux/mount.h>
81832 #include <linux/pagemap.h>
81833 #include <linux/syscalls.h>
81834 +#include <linux/ptrace.h>
81835 #include <linux/signal.h>
81836 #include <linux/export.h>
81837 #include <linux/magic.h>
81838 @@ -243,6 +244,11 @@ get_futex_key(u32 __user *uaddr, int fshared, union futex_key *key, int rw)
81839 struct page *page, *page_head;
81840 int err, ro = 0;
81841
81842 +#ifdef CONFIG_PAX_SEGMEXEC
81843 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && address >= SEGMEXEC_TASK_SIZE)
81844 + return -EFAULT;
81845 +#endif
81846 +
81847 /*
81848 * The futex address must be "naturally" aligned.
81849 */
81850 @@ -441,7 +447,7 @@ static int cmpxchg_futex_value_locked(u32 *curval, u32 __user *uaddr,
81851
81852 static int get_futex_value_locked(u32 *dest, u32 __user *from)
81853 {
81854 - int ret;
81855 + unsigned long ret;
81856
81857 pagefault_disable();
81858 ret = __copy_from_user_inatomic(dest, from, sizeof(u32));
81859 @@ -2734,6 +2740,7 @@ static int __init futex_init(void)
81860 {
81861 u32 curval;
81862 int i;
81863 + mm_segment_t oldfs;
81864
81865 /*
81866 * This will fail and we want it. Some arch implementations do
81867 @@ -2745,8 +2752,11 @@ static int __init futex_init(void)
81868 * implementation, the non-functional ones will return
81869 * -ENOSYS.
81870 */
81871 + oldfs = get_fs();
81872 + set_fs(USER_DS);
81873 if (cmpxchg_futex_value_locked(&curval, NULL, 0, 0) == -EFAULT)
81874 futex_cmpxchg_enabled = 1;
81875 + set_fs(oldfs);
81876
81877 for (i = 0; i < ARRAY_SIZE(futex_queues); i++) {
81878 plist_head_init(&futex_queues[i].chain);
81879 diff --git a/kernel/futex_compat.c b/kernel/futex_compat.c
81880 index f9f44fd..29885e4 100644
81881 --- a/kernel/futex_compat.c
81882 +++ b/kernel/futex_compat.c
81883 @@ -32,7 +32,7 @@ fetch_robust_entry(compat_uptr_t *uentry, struct robust_list __user **entry,
81884 return 0;
81885 }
81886
81887 -static void __user *futex_uaddr(struct robust_list __user *entry,
81888 +static void __user __intentional_overflow(-1) *futex_uaddr(struct robust_list __user *entry,
81889 compat_long_t futex_offset)
81890 {
81891 compat_uptr_t base = ptr_to_compat(entry);
81892 diff --git a/kernel/gcov/base.c b/kernel/gcov/base.c
81893 index 9b22d03..6295b62 100644
81894 --- a/kernel/gcov/base.c
81895 +++ b/kernel/gcov/base.c
81896 @@ -102,11 +102,6 @@ void gcov_enable_events(void)
81897 }
81898
81899 #ifdef CONFIG_MODULES
81900 -static inline int within(void *addr, void *start, unsigned long size)
81901 -{
81902 - return ((addr >= start) && (addr < start + size));
81903 -}
81904 -
81905 /* Update list and generate events when modules are unloaded. */
81906 static int gcov_module_notifier(struct notifier_block *nb, unsigned long event,
81907 void *data)
81908 @@ -121,7 +116,7 @@ static int gcov_module_notifier(struct notifier_block *nb, unsigned long event,
81909 prev = NULL;
81910 /* Remove entries located in module from linked list. */
81911 for (info = gcov_info_head; info; info = info->next) {
81912 - if (within(info, mod->module_core, mod->core_size)) {
81913 + if (within_module_core_rw((unsigned long)info, mod)) {
81914 if (prev)
81915 prev->next = info->next;
81916 else
81917 diff --git a/kernel/hrtimer.c b/kernel/hrtimer.c
81918 index 383319b..56ebb13 100644
81919 --- a/kernel/hrtimer.c
81920 +++ b/kernel/hrtimer.c
81921 @@ -1438,7 +1438,7 @@ void hrtimer_peek_ahead_timers(void)
81922 local_irq_restore(flags);
81923 }
81924
81925 -static void run_hrtimer_softirq(struct softirq_action *h)
81926 +static __latent_entropy void run_hrtimer_softirq(void)
81927 {
81928 hrtimer_peek_ahead_timers();
81929 }
81930 diff --git a/kernel/irq_work.c b/kernel/irq_work.c
81931 index 55fcce6..0e4cf34 100644
81932 --- a/kernel/irq_work.c
81933 +++ b/kernel/irq_work.c
81934 @@ -189,12 +189,13 @@ static int irq_work_cpu_notify(struct notifier_block *self,
81935 return NOTIFY_OK;
81936 }
81937
81938 -static struct notifier_block cpu_notify;
81939 +static struct notifier_block cpu_notify = {
81940 + .notifier_call = irq_work_cpu_notify,
81941 + .priority = 0,
81942 +};
81943
81944 static __init int irq_work_init_cpu_notifier(void)
81945 {
81946 - cpu_notify.notifier_call = irq_work_cpu_notify;
81947 - cpu_notify.priority = 0;
81948 register_cpu_notifier(&cpu_notify);
81949 return 0;
81950 }
81951 diff --git a/kernel/jump_label.c b/kernel/jump_label.c
81952 index 297a924..7290070 100644
81953 --- a/kernel/jump_label.c
81954 +++ b/kernel/jump_label.c
81955 @@ -14,6 +14,7 @@
81956 #include <linux/err.h>
81957 #include <linux/static_key.h>
81958 #include <linux/jump_label_ratelimit.h>
81959 +#include <linux/mm.h>
81960
81961 #ifdef HAVE_JUMP_LABEL
81962
81963 @@ -51,7 +52,9 @@ jump_label_sort_entries(struct jump_entry *start, struct jump_entry *stop)
81964
81965 size = (((unsigned long)stop - (unsigned long)start)
81966 / sizeof(struct jump_entry));
81967 + pax_open_kernel();
81968 sort(start, size, sizeof(struct jump_entry), jump_label_cmp, NULL);
81969 + pax_close_kernel();
81970 }
81971
81972 static void jump_label_update(struct static_key *key, int enable);
81973 @@ -358,10 +361,12 @@ static void jump_label_invalidate_module_init(struct module *mod)
81974 struct jump_entry *iter_stop = iter_start + mod->num_jump_entries;
81975 struct jump_entry *iter;
81976
81977 + pax_open_kernel();
81978 for (iter = iter_start; iter < iter_stop; iter++) {
81979 if (within_module_init(iter->code, mod))
81980 iter->code = 0;
81981 }
81982 + pax_close_kernel();
81983 }
81984
81985 static int
81986 diff --git a/kernel/kallsyms.c b/kernel/kallsyms.c
81987 index 3127ad5..159d880 100644
81988 --- a/kernel/kallsyms.c
81989 +++ b/kernel/kallsyms.c
81990 @@ -11,6 +11,9 @@
81991 * Changed the compression method from stem compression to "table lookup"
81992 * compression (see scripts/kallsyms.c for a more complete description)
81993 */
81994 +#ifdef CONFIG_GRKERNSEC_HIDESYM
81995 +#define __INCLUDED_BY_HIDESYM 1
81996 +#endif
81997 #include <linux/kallsyms.h>
81998 #include <linux/module.h>
81999 #include <linux/init.h>
82000 @@ -53,12 +56,33 @@ extern const unsigned long kallsyms_markers[] __attribute__((weak));
82001
82002 static inline int is_kernel_inittext(unsigned long addr)
82003 {
82004 + if (system_state != SYSTEM_BOOTING)
82005 + return 0;
82006 +
82007 if (addr >= (unsigned long)_sinittext
82008 && addr <= (unsigned long)_einittext)
82009 return 1;
82010 return 0;
82011 }
82012
82013 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
82014 +#ifdef CONFIG_MODULES
82015 +static inline int is_module_text(unsigned long addr)
82016 +{
82017 + if ((unsigned long)MODULES_EXEC_VADDR <= addr && addr <= (unsigned long)MODULES_EXEC_END)
82018 + return 1;
82019 +
82020 + addr = ktla_ktva(addr);
82021 + return (unsigned long)MODULES_EXEC_VADDR <= addr && addr <= (unsigned long)MODULES_EXEC_END;
82022 +}
82023 +#else
82024 +static inline int is_module_text(unsigned long addr)
82025 +{
82026 + return 0;
82027 +}
82028 +#endif
82029 +#endif
82030 +
82031 static inline int is_kernel_text(unsigned long addr)
82032 {
82033 if ((addr >= (unsigned long)_stext && addr <= (unsigned long)_etext) ||
82034 @@ -69,13 +93,28 @@ static inline int is_kernel_text(unsigned long addr)
82035
82036 static inline int is_kernel(unsigned long addr)
82037 {
82038 +
82039 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
82040 + if (is_kernel_text(addr) || is_kernel_inittext(addr))
82041 + return 1;
82042 +
82043 + if (ktla_ktva((unsigned long)_text) <= addr && addr < (unsigned long)_end)
82044 +#else
82045 if (addr >= (unsigned long)_stext && addr <= (unsigned long)_end)
82046 +#endif
82047 +
82048 return 1;
82049 return in_gate_area_no_mm(addr);
82050 }
82051
82052 static int is_ksym_addr(unsigned long addr)
82053 {
82054 +
82055 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
82056 + if (is_module_text(addr))
82057 + return 0;
82058 +#endif
82059 +
82060 if (all_var)
82061 return is_kernel(addr);
82062
82063 @@ -480,7 +519,6 @@ static unsigned long get_ksymbol_core(struct kallsym_iter *iter)
82064
82065 static void reset_iter(struct kallsym_iter *iter, loff_t new_pos)
82066 {
82067 - iter->name[0] = '\0';
82068 iter->nameoff = get_symbol_offset(new_pos);
82069 iter->pos = new_pos;
82070 }
82071 @@ -528,6 +566,11 @@ static int s_show(struct seq_file *m, void *p)
82072 {
82073 struct kallsym_iter *iter = m->private;
82074
82075 +#ifdef CONFIG_GRKERNSEC_HIDESYM
82076 + if (!uid_eq(current_uid(), GLOBAL_ROOT_UID))
82077 + return 0;
82078 +#endif
82079 +
82080 /* Some debugging symbols have no name. Ignore them. */
82081 if (!iter->name[0])
82082 return 0;
82083 @@ -541,6 +584,7 @@ static int s_show(struct seq_file *m, void *p)
82084 */
82085 type = iter->exported ? toupper(iter->type) :
82086 tolower(iter->type);
82087 +
82088 seq_printf(m, "%pK %c %s\t[%s]\n", (void *)iter->value,
82089 type, iter->name, iter->module_name);
82090 } else
82091 @@ -566,7 +610,7 @@ static int kallsyms_open(struct inode *inode, struct file *file)
82092 struct kallsym_iter *iter;
82093 int ret;
82094
82095 - iter = kmalloc(sizeof(*iter), GFP_KERNEL);
82096 + iter = kzalloc(sizeof(*iter), GFP_KERNEL);
82097 if (!iter)
82098 return -ENOMEM;
82099 reset_iter(iter, 0);
82100 diff --git a/kernel/kcmp.c b/kernel/kcmp.c
82101 index e30ac0f..3528cac 100644
82102 --- a/kernel/kcmp.c
82103 +++ b/kernel/kcmp.c
82104 @@ -99,6 +99,10 @@ SYSCALL_DEFINE5(kcmp, pid_t, pid1, pid_t, pid2, int, type,
82105 struct task_struct *task1, *task2;
82106 int ret;
82107
82108 +#ifdef CONFIG_GRKERNSEC
82109 + return -ENOSYS;
82110 +#endif
82111 +
82112 rcu_read_lock();
82113
82114 /*
82115 diff --git a/kernel/kexec.c b/kernel/kexec.c
82116 index 2a74f30..d139351 100644
82117 --- a/kernel/kexec.c
82118 +++ b/kernel/kexec.c
82119 @@ -1041,7 +1041,8 @@ asmlinkage long compat_sys_kexec_load(unsigned long entry,
82120 unsigned long flags)
82121 {
82122 struct compat_kexec_segment in;
82123 - struct kexec_segment out, __user *ksegments;
82124 + struct kexec_segment out;
82125 + struct kexec_segment __user *ksegments;
82126 unsigned long i, result;
82127
82128 /* Don't allow clients that don't understand the native
82129 diff --git a/kernel/kmod.c b/kernel/kmod.c
82130 index b086006..6d2e579 100644
82131 --- a/kernel/kmod.c
82132 +++ b/kernel/kmod.c
82133 @@ -75,7 +75,7 @@ static void free_modprobe_argv(struct subprocess_info *info)
82134 kfree(info->argv);
82135 }
82136
82137 -static int call_modprobe(char *module_name, int wait)
82138 +static int call_modprobe(char *module_name, char *module_param, int wait)
82139 {
82140 struct subprocess_info *info;
82141 static char *envp[] = {
82142 @@ -85,7 +85,7 @@ static int call_modprobe(char *module_name, int wait)
82143 NULL
82144 };
82145
82146 - char **argv = kmalloc(sizeof(char *[5]), GFP_KERNEL);
82147 + char **argv = kmalloc(sizeof(char *[6]), GFP_KERNEL);
82148 if (!argv)
82149 goto out;
82150
82151 @@ -97,7 +97,8 @@ static int call_modprobe(char *module_name, int wait)
82152 argv[1] = "-q";
82153 argv[2] = "--";
82154 argv[3] = module_name; /* check free_modprobe_argv() */
82155 - argv[4] = NULL;
82156 + argv[4] = module_param;
82157 + argv[5] = NULL;
82158
82159 info = call_usermodehelper_setup(modprobe_path, argv, envp, GFP_KERNEL,
82160 NULL, free_modprobe_argv, NULL);
82161 @@ -129,9 +130,8 @@ out:
82162 * If module auto-loading support is disabled then this function
82163 * becomes a no-operation.
82164 */
82165 -int __request_module(bool wait, const char *fmt, ...)
82166 +static int ____request_module(bool wait, char *module_param, const char *fmt, va_list ap)
82167 {
82168 - va_list args;
82169 char module_name[MODULE_NAME_LEN];
82170 unsigned int max_modprobes;
82171 int ret;
82172 @@ -150,9 +150,7 @@ int __request_module(bool wait, const char *fmt, ...)
82173 if (!modprobe_path[0])
82174 return 0;
82175
82176 - va_start(args, fmt);
82177 - ret = vsnprintf(module_name, MODULE_NAME_LEN, fmt, args);
82178 - va_end(args);
82179 + ret = vsnprintf(module_name, MODULE_NAME_LEN, fmt, ap);
82180 if (ret >= MODULE_NAME_LEN)
82181 return -ENAMETOOLONG;
82182
82183 @@ -160,6 +158,20 @@ int __request_module(bool wait, const char *fmt, ...)
82184 if (ret)
82185 return ret;
82186
82187 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
82188 + if (uid_eq(current_uid(), GLOBAL_ROOT_UID)) {
82189 + /* hack to workaround consolekit/udisks stupidity */
82190 + read_lock(&tasklist_lock);
82191 + if (!strcmp(current->comm, "mount") &&
82192 + current->real_parent && !strncmp(current->real_parent->comm, "udisk", 5)) {
82193 + read_unlock(&tasklist_lock);
82194 + printk(KERN_ALERT "grsec: denied attempt to auto-load fs module %.64s by udisks\n", module_name);
82195 + return -EPERM;
82196 + }
82197 + read_unlock(&tasklist_lock);
82198 + }
82199 +#endif
82200 +
82201 /* If modprobe needs a service that is in a module, we get a recursive
82202 * loop. Limit the number of running kmod threads to max_threads/2 or
82203 * MAX_KMOD_CONCURRENT, whichever is the smaller. A cleaner method
82204 @@ -188,11 +200,52 @@ int __request_module(bool wait, const char *fmt, ...)
82205
82206 trace_module_request(module_name, wait, _RET_IP_);
82207
82208 - ret = call_modprobe(module_name, wait ? UMH_WAIT_PROC : UMH_WAIT_EXEC);
82209 + ret = call_modprobe(module_name, module_param, wait ? UMH_WAIT_PROC : UMH_WAIT_EXEC);
82210
82211 atomic_dec(&kmod_concurrent);
82212 return ret;
82213 }
82214 +
82215 +int ___request_module(bool wait, char *module_param, const char *fmt, ...)
82216 +{
82217 + va_list args;
82218 + int ret;
82219 +
82220 + va_start(args, fmt);
82221 + ret = ____request_module(wait, module_param, fmt, args);
82222 + va_end(args);
82223 +
82224 + return ret;
82225 +}
82226 +
82227 +int __request_module(bool wait, const char *fmt, ...)
82228 +{
82229 + va_list args;
82230 + int ret;
82231 +
82232 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
82233 + if (!uid_eq(current_uid(), GLOBAL_ROOT_UID)) {
82234 + char module_param[MODULE_NAME_LEN];
82235 +
82236 + memset(module_param, 0, sizeof(module_param));
82237 +
82238 + snprintf(module_param, sizeof(module_param) - 1, "grsec_modharden_normal%u_", GR_GLOBAL_UID(current_uid()));
82239 +
82240 + va_start(args, fmt);
82241 + ret = ____request_module(wait, module_param, fmt, args);
82242 + va_end(args);
82243 +
82244 + return ret;
82245 + }
82246 +#endif
82247 +
82248 + va_start(args, fmt);
82249 + ret = ____request_module(wait, NULL, fmt, args);
82250 + va_end(args);
82251 +
82252 + return ret;
82253 +}
82254 +
82255 EXPORT_SYMBOL(__request_module);
82256 #endif /* CONFIG_MODULES */
82257
82258 @@ -218,6 +271,19 @@ static int ____call_usermodehelper(void *data)
82259 */
82260 set_user_nice(current, 0);
82261
82262 +#ifdef CONFIG_GRKERNSEC
82263 + /* this is race-free as far as userland is concerned as we copied
82264 + out the path to be used prior to this point and are now operating
82265 + on that copy
82266 + */
82267 + if ((strncmp(sub_info->path, "/sbin/", 6) && strncmp(sub_info->path, "/usr/lib/", 9) &&
82268 + strncmp(sub_info->path, "/lib/", 5) && strncmp(sub_info->path, "/lib64/", 7)) || strstr(sub_info->path, "..")) {
82269 + printk(KERN_ALERT "grsec: denied exec of usermode helper binary %.950s located outside of /sbin and system library paths\n", sub_info->path);
82270 + retval = -EPERM;
82271 + goto fail;
82272 + }
82273 +#endif
82274 +
82275 retval = -ENOMEM;
82276 new = prepare_kernel_cred(current);
82277 if (!new)
82278 @@ -260,6 +326,10 @@ static int call_helper(void *data)
82279
82280 static void call_usermodehelper_freeinfo(struct subprocess_info *info)
82281 {
82282 +#ifdef CONFIG_GRKERNSEC
82283 + kfree(info->path);
82284 + info->path = info->origpath;
82285 +#endif
82286 if (info->cleanup)
82287 (*info->cleanup)(info);
82288 kfree(info);
82289 @@ -303,7 +373,7 @@ static int wait_for_helper(void *data)
82290 *
82291 * Thus the __user pointer cast is valid here.
82292 */
82293 - sys_wait4(pid, (int __user *)&ret, 0, NULL);
82294 + sys_wait4(pid, (int __force_user *)&ret, 0, NULL);
82295
82296 /*
82297 * If ret is 0, either ____call_usermodehelper failed and the
82298 @@ -542,7 +612,12 @@ struct subprocess_info *call_usermodehelper_setup(char *path, char **argv,
82299 goto out;
82300
82301 INIT_WORK(&sub_info->work, __call_usermodehelper);
82302 +#ifdef CONFIG_GRKERNSEC
82303 + sub_info->origpath = path;
82304 + sub_info->path = kstrdup(path, gfp_mask);
82305 +#else
82306 sub_info->path = path;
82307 +#endif
82308 sub_info->argv = argv;
82309 sub_info->envp = envp;
82310
82311 @@ -650,7 +725,7 @@ EXPORT_SYMBOL(call_usermodehelper);
82312 static int proc_cap_handler(struct ctl_table *table, int write,
82313 void __user *buffer, size_t *lenp, loff_t *ppos)
82314 {
82315 - struct ctl_table t;
82316 + ctl_table_no_const t;
82317 unsigned long cap_array[_KERNEL_CAPABILITY_U32S];
82318 kernel_cap_t new_cap;
82319 int err, i;
82320 diff --git a/kernel/kprobes.c b/kernel/kprobes.c
82321 index a0d367a..11c18b6 100644
82322 --- a/kernel/kprobes.c
82323 +++ b/kernel/kprobes.c
82324 @@ -31,6 +31,9 @@
82325 * <jkenisto@us.ibm.com> and Prasanna S Panchamukhi
82326 * <prasanna@in.ibm.com> added function-return probes.
82327 */
82328 +#ifdef CONFIG_GRKERNSEC_HIDESYM
82329 +#define __INCLUDED_BY_HIDESYM 1
82330 +#endif
82331 #include <linux/kprobes.h>
82332 #include <linux/hash.h>
82333 #include <linux/init.h>
82334 @@ -135,12 +138,12 @@ enum kprobe_slot_state {
82335
82336 static void *alloc_insn_page(void)
82337 {
82338 - return module_alloc(PAGE_SIZE);
82339 + return module_alloc_exec(PAGE_SIZE);
82340 }
82341
82342 static void free_insn_page(void *page)
82343 {
82344 - module_free(NULL, page);
82345 + module_free_exec(NULL, page);
82346 }
82347
82348 struct kprobe_insn_cache kprobe_insn_slots = {
82349 @@ -2066,7 +2069,7 @@ static int __init init_kprobes(void)
82350 {
82351 int i, err = 0;
82352 unsigned long offset = 0, size = 0;
82353 - char *modname, namebuf[128];
82354 + char *modname, namebuf[KSYM_NAME_LEN];
82355 const char *symbol_name;
82356 void *addr;
82357 struct kprobe_blackpoint *kb;
82358 @@ -2151,11 +2154,11 @@ static void __kprobes report_probe(struct seq_file *pi, struct kprobe *p,
82359 kprobe_type = "k";
82360
82361 if (sym)
82362 - seq_printf(pi, "%p %s %s+0x%x %s ",
82363 + seq_printf(pi, "%pK %s %s+0x%x %s ",
82364 p->addr, kprobe_type, sym, offset,
82365 (modname ? modname : " "));
82366 else
82367 - seq_printf(pi, "%p %s %p ",
82368 + seq_printf(pi, "%pK %s %pK ",
82369 p->addr, kprobe_type, p->addr);
82370
82371 if (!pp)
82372 @@ -2192,7 +2195,7 @@ static int __kprobes show_kprobe_addr(struct seq_file *pi, void *v)
82373 const char *sym = NULL;
82374 unsigned int i = *(loff_t *) v;
82375 unsigned long offset = 0;
82376 - char *modname, namebuf[128];
82377 + char *modname, namebuf[KSYM_NAME_LEN];
82378
82379 head = &kprobe_table[i];
82380 preempt_disable();
82381 diff --git a/kernel/ksysfs.c b/kernel/ksysfs.c
82382 index 9659d38..bffd520 100644
82383 --- a/kernel/ksysfs.c
82384 +++ b/kernel/ksysfs.c
82385 @@ -46,6 +46,8 @@ static ssize_t uevent_helper_store(struct kobject *kobj,
82386 {
82387 if (count+1 > UEVENT_HELPER_PATH_LEN)
82388 return -ENOENT;
82389 + if (!capable(CAP_SYS_ADMIN))
82390 + return -EPERM;
82391 memcpy(uevent_helper, buf, count);
82392 uevent_helper[count] = '\0';
82393 if (count && uevent_helper[count-1] == '\n')
82394 @@ -172,7 +174,7 @@ static ssize_t notes_read(struct file *filp, struct kobject *kobj,
82395 return count;
82396 }
82397
82398 -static struct bin_attribute notes_attr = {
82399 +static bin_attribute_no_const notes_attr __read_only = {
82400 .attr = {
82401 .name = "notes",
82402 .mode = S_IRUGO,
82403 diff --git a/kernel/lockdep.c b/kernel/lockdep.c
82404 index e16c45b..6f49c48 100644
82405 --- a/kernel/lockdep.c
82406 +++ b/kernel/lockdep.c
82407 @@ -596,6 +596,10 @@ static int static_obj(void *obj)
82408 end = (unsigned long) &_end,
82409 addr = (unsigned long) obj;
82410
82411 +#ifdef CONFIG_PAX_KERNEXEC
82412 + start = ktla_ktva(start);
82413 +#endif
82414 +
82415 /*
82416 * static variable?
82417 */
82418 @@ -736,6 +740,7 @@ register_lock_class(struct lockdep_map *lock, unsigned int subclass, int force)
82419 if (!static_obj(lock->key)) {
82420 debug_locks_off();
82421 printk("INFO: trying to register non-static key.\n");
82422 + printk("lock:%pS key:%pS.\n", lock, lock->key);
82423 printk("the code is fine but needs lockdep annotation.\n");
82424 printk("turning off the locking correctness validator.\n");
82425 dump_stack();
82426 @@ -3080,7 +3085,7 @@ static int __lock_acquire(struct lockdep_map *lock, unsigned int subclass,
82427 if (!class)
82428 return 0;
82429 }
82430 - atomic_inc((atomic_t *)&class->ops);
82431 + atomic_inc_unchecked((atomic_unchecked_t *)&class->ops);
82432 if (very_verbose(class)) {
82433 printk("\nacquire class [%p] %s", class->key, class->name);
82434 if (class->name_version > 1)
82435 diff --git a/kernel/lockdep_proc.c b/kernel/lockdep_proc.c
82436 index b2c71c5..7b88d63 100644
82437 --- a/kernel/lockdep_proc.c
82438 +++ b/kernel/lockdep_proc.c
82439 @@ -65,7 +65,7 @@ static int l_show(struct seq_file *m, void *v)
82440 return 0;
82441 }
82442
82443 - seq_printf(m, "%p", class->key);
82444 + seq_printf(m, "%pK", class->key);
82445 #ifdef CONFIG_DEBUG_LOCKDEP
82446 seq_printf(m, " OPS:%8ld", class->ops);
82447 #endif
82448 @@ -83,7 +83,7 @@ static int l_show(struct seq_file *m, void *v)
82449
82450 list_for_each_entry(entry, &class->locks_after, entry) {
82451 if (entry->distance == 1) {
82452 - seq_printf(m, " -> [%p] ", entry->class->key);
82453 + seq_printf(m, " -> [%pK] ", entry->class->key);
82454 print_name(m, entry->class);
82455 seq_puts(m, "\n");
82456 }
82457 @@ -152,7 +152,7 @@ static int lc_show(struct seq_file *m, void *v)
82458 if (!class->key)
82459 continue;
82460
82461 - seq_printf(m, "[%p] ", class->key);
82462 + seq_printf(m, "[%pK] ", class->key);
82463 print_name(m, class);
82464 seq_puts(m, "\n");
82465 }
82466 @@ -495,7 +495,7 @@ static void seq_stats(struct seq_file *m, struct lock_stat_data *data)
82467 if (!i)
82468 seq_line(m, '-', 40-namelen, namelen);
82469
82470 - snprintf(ip, sizeof(ip), "[<%p>]",
82471 + snprintf(ip, sizeof(ip), "[<%pK>]",
82472 (void *)class->contention_point[i]);
82473 seq_printf(m, "%40s %14lu %29s %pS\n",
82474 name, stats->contention_point[i],
82475 @@ -510,7 +510,7 @@ static void seq_stats(struct seq_file *m, struct lock_stat_data *data)
82476 if (!i)
82477 seq_line(m, '-', 40-namelen, namelen);
82478
82479 - snprintf(ip, sizeof(ip), "[<%p>]",
82480 + snprintf(ip, sizeof(ip), "[<%pK>]",
82481 (void *)class->contending_point[i]);
82482 seq_printf(m, "%40s %14lu %29s %pS\n",
82483 name, stats->contending_point[i],
82484 diff --git a/kernel/module.c b/kernel/module.c
82485 index dc58274..3ddfa55 100644
82486 --- a/kernel/module.c
82487 +++ b/kernel/module.c
82488 @@ -61,6 +61,7 @@
82489 #include <linux/pfn.h>
82490 #include <linux/bsearch.h>
82491 #include <linux/fips.h>
82492 +#include <linux/grsecurity.h>
82493 #include <uapi/linux/module.h>
82494 #include "module-internal.h"
82495
82496 @@ -157,7 +158,8 @@ static BLOCKING_NOTIFIER_HEAD(module_notify_list);
82497
82498 /* Bounds of module allocation, for speeding __module_address.
82499 * Protected by module_mutex. */
82500 -static unsigned long module_addr_min = -1UL, module_addr_max = 0;
82501 +static unsigned long module_addr_min_rw = -1UL, module_addr_max_rw = 0;
82502 +static unsigned long module_addr_min_rx = -1UL, module_addr_max_rx = 0;
82503
82504 int register_module_notifier(struct notifier_block * nb)
82505 {
82506 @@ -324,7 +326,7 @@ bool each_symbol_section(bool (*fn)(const struct symsearch *arr,
82507 return true;
82508
82509 list_for_each_entry_rcu(mod, &modules, list) {
82510 - struct symsearch arr[] = {
82511 + struct symsearch modarr[] = {
82512 { mod->syms, mod->syms + mod->num_syms, mod->crcs,
82513 NOT_GPL_ONLY, false },
82514 { mod->gpl_syms, mod->gpl_syms + mod->num_gpl_syms,
82515 @@ -349,7 +351,7 @@ bool each_symbol_section(bool (*fn)(const struct symsearch *arr,
82516 if (mod->state == MODULE_STATE_UNFORMED)
82517 continue;
82518
82519 - if (each_symbol_in_section(arr, ARRAY_SIZE(arr), mod, fn, data))
82520 + if (each_symbol_in_section(modarr, ARRAY_SIZE(modarr), mod, fn, data))
82521 return true;
82522 }
82523 return false;
82524 @@ -491,7 +493,7 @@ static int percpu_modalloc(struct module *mod, struct load_info *info)
82525 if (!pcpusec->sh_size)
82526 return 0;
82527
82528 - if (align > PAGE_SIZE) {
82529 + if (align-1 >= PAGE_SIZE) {
82530 printk(KERN_WARNING "%s: per-cpu alignment %li > %li\n",
82531 mod->name, align, PAGE_SIZE);
82532 align = PAGE_SIZE;
82533 @@ -1097,7 +1099,7 @@ struct module_attribute module_uevent =
82534 static ssize_t show_coresize(struct module_attribute *mattr,
82535 struct module_kobject *mk, char *buffer)
82536 {
82537 - return sprintf(buffer, "%u\n", mk->mod->core_size);
82538 + return sprintf(buffer, "%u\n", mk->mod->core_size_rx + mk->mod->core_size_rw);
82539 }
82540
82541 static struct module_attribute modinfo_coresize =
82542 @@ -1106,7 +1108,7 @@ static struct module_attribute modinfo_coresize =
82543 static ssize_t show_initsize(struct module_attribute *mattr,
82544 struct module_kobject *mk, char *buffer)
82545 {
82546 - return sprintf(buffer, "%u\n", mk->mod->init_size);
82547 + return sprintf(buffer, "%u\n", mk->mod->init_size_rx + mk->mod->init_size_rw);
82548 }
82549
82550 static struct module_attribute modinfo_initsize =
82551 @@ -1321,7 +1323,7 @@ resolve_symbol_wait(struct module *mod,
82552 */
82553 #ifdef CONFIG_SYSFS
82554
82555 -#ifdef CONFIG_KALLSYMS
82556 +#if defined(CONFIG_KALLSYMS) && !defined(CONFIG_GRKERNSEC_HIDESYM)
82557 static inline bool sect_empty(const Elf_Shdr *sect)
82558 {
82559 return !(sect->sh_flags & SHF_ALLOC) || sect->sh_size == 0;
82560 @@ -1461,7 +1463,7 @@ static void add_notes_attrs(struct module *mod, const struct load_info *info)
82561 {
82562 unsigned int notes, loaded, i;
82563 struct module_notes_attrs *notes_attrs;
82564 - struct bin_attribute *nattr;
82565 + bin_attribute_no_const *nattr;
82566
82567 /* failed to create section attributes, so can't create notes */
82568 if (!mod->sect_attrs)
82569 @@ -1573,7 +1575,7 @@ static void del_usage_links(struct module *mod)
82570 static int module_add_modinfo_attrs(struct module *mod)
82571 {
82572 struct module_attribute *attr;
82573 - struct module_attribute *temp_attr;
82574 + module_attribute_no_const *temp_attr;
82575 int error = 0;
82576 int i;
82577
82578 @@ -1795,21 +1797,21 @@ static void set_section_ro_nx(void *base,
82579
82580 static void unset_module_core_ro_nx(struct module *mod)
82581 {
82582 - set_page_attributes(mod->module_core + mod->core_text_size,
82583 - mod->module_core + mod->core_size,
82584 + set_page_attributes(mod->module_core_rw,
82585 + mod->module_core_rw + mod->core_size_rw,
82586 set_memory_x);
82587 - set_page_attributes(mod->module_core,
82588 - mod->module_core + mod->core_ro_size,
82589 + set_page_attributes(mod->module_core_rx,
82590 + mod->module_core_rx + mod->core_size_rx,
82591 set_memory_rw);
82592 }
82593
82594 static void unset_module_init_ro_nx(struct module *mod)
82595 {
82596 - set_page_attributes(mod->module_init + mod->init_text_size,
82597 - mod->module_init + mod->init_size,
82598 + set_page_attributes(mod->module_init_rw,
82599 + mod->module_init_rw + mod->init_size_rw,
82600 set_memory_x);
82601 - set_page_attributes(mod->module_init,
82602 - mod->module_init + mod->init_ro_size,
82603 + set_page_attributes(mod->module_init_rx,
82604 + mod->module_init_rx + mod->init_size_rx,
82605 set_memory_rw);
82606 }
82607
82608 @@ -1822,14 +1824,14 @@ void set_all_modules_text_rw(void)
82609 list_for_each_entry_rcu(mod, &modules, list) {
82610 if (mod->state == MODULE_STATE_UNFORMED)
82611 continue;
82612 - if ((mod->module_core) && (mod->core_text_size)) {
82613 - set_page_attributes(mod->module_core,
82614 - mod->module_core + mod->core_text_size,
82615 + if ((mod->module_core_rx) && (mod->core_size_rx)) {
82616 + set_page_attributes(mod->module_core_rx,
82617 + mod->module_core_rx + mod->core_size_rx,
82618 set_memory_rw);
82619 }
82620 - if ((mod->module_init) && (mod->init_text_size)) {
82621 - set_page_attributes(mod->module_init,
82622 - mod->module_init + mod->init_text_size,
82623 + if ((mod->module_init_rx) && (mod->init_size_rx)) {
82624 + set_page_attributes(mod->module_init_rx,
82625 + mod->module_init_rx + mod->init_size_rx,
82626 set_memory_rw);
82627 }
82628 }
82629 @@ -1845,14 +1847,14 @@ void set_all_modules_text_ro(void)
82630 list_for_each_entry_rcu(mod, &modules, list) {
82631 if (mod->state == MODULE_STATE_UNFORMED)
82632 continue;
82633 - if ((mod->module_core) && (mod->core_text_size)) {
82634 - set_page_attributes(mod->module_core,
82635 - mod->module_core + mod->core_text_size,
82636 + if ((mod->module_core_rx) && (mod->core_size_rx)) {
82637 + set_page_attributes(mod->module_core_rx,
82638 + mod->module_core_rx + mod->core_size_rx,
82639 set_memory_ro);
82640 }
82641 - if ((mod->module_init) && (mod->init_text_size)) {
82642 - set_page_attributes(mod->module_init,
82643 - mod->module_init + mod->init_text_size,
82644 + if ((mod->module_init_rx) && (mod->init_size_rx)) {
82645 + set_page_attributes(mod->module_init_rx,
82646 + mod->module_init_rx + mod->init_size_rx,
82647 set_memory_ro);
82648 }
82649 }
82650 @@ -1903,16 +1905,19 @@ static void free_module(struct module *mod)
82651
82652 /* This may be NULL, but that's OK */
82653 unset_module_init_ro_nx(mod);
82654 - module_free(mod, mod->module_init);
82655 + module_free(mod, mod->module_init_rw);
82656 + module_free_exec(mod, mod->module_init_rx);
82657 kfree(mod->args);
82658 percpu_modfree(mod);
82659
82660 /* Free lock-classes: */
82661 - lockdep_free_key_range(mod->module_core, mod->core_size);
82662 + lockdep_free_key_range(mod->module_core_rx, mod->core_size_rx);
82663 + lockdep_free_key_range(mod->module_core_rw, mod->core_size_rw);
82664
82665 /* Finally, free the core (containing the module structure) */
82666 unset_module_core_ro_nx(mod);
82667 - module_free(mod, mod->module_core);
82668 + module_free_exec(mod, mod->module_core_rx);
82669 + module_free(mod, mod->module_core_rw);
82670
82671 #ifdef CONFIG_MPU
82672 update_protections(current->mm);
82673 @@ -1982,9 +1987,31 @@ static int simplify_symbols(struct module *mod, const struct load_info *info)
82674 int ret = 0;
82675 const struct kernel_symbol *ksym;
82676
82677 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
82678 + int is_fs_load = 0;
82679 + int register_filesystem_found = 0;
82680 + char *p;
82681 +
82682 + p = strstr(mod->args, "grsec_modharden_fs");
82683 + if (p) {
82684 + char *endptr = p + sizeof("grsec_modharden_fs") - 1;
82685 + /* copy \0 as well */
82686 + memmove(p, endptr, strlen(mod->args) - (unsigned int)(endptr - mod->args) + 1);
82687 + is_fs_load = 1;
82688 + }
82689 +#endif
82690 +
82691 for (i = 1; i < symsec->sh_size / sizeof(Elf_Sym); i++) {
82692 const char *name = info->strtab + sym[i].st_name;
82693
82694 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
82695 + /* it's a real shame this will never get ripped and copied
82696 + upstream! ;(
82697 + */
82698 + if (is_fs_load && !strcmp(name, "register_filesystem"))
82699 + register_filesystem_found = 1;
82700 +#endif
82701 +
82702 switch (sym[i].st_shndx) {
82703 case SHN_COMMON:
82704 /* We compiled with -fno-common. These are not
82705 @@ -2005,7 +2032,9 @@ static int simplify_symbols(struct module *mod, const struct load_info *info)
82706 ksym = resolve_symbol_wait(mod, info, name);
82707 /* Ok if resolved. */
82708 if (ksym && !IS_ERR(ksym)) {
82709 + pax_open_kernel();
82710 sym[i].st_value = ksym->value;
82711 + pax_close_kernel();
82712 break;
82713 }
82714
82715 @@ -2024,11 +2053,20 @@ static int simplify_symbols(struct module *mod, const struct load_info *info)
82716 secbase = (unsigned long)mod_percpu(mod);
82717 else
82718 secbase = info->sechdrs[sym[i].st_shndx].sh_addr;
82719 + pax_open_kernel();
82720 sym[i].st_value += secbase;
82721 + pax_close_kernel();
82722 break;
82723 }
82724 }
82725
82726 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
82727 + if (is_fs_load && !register_filesystem_found) {
82728 + printk(KERN_ALERT "grsec: Denied attempt to load non-fs module %.64s through mount\n", mod->name);
82729 + ret = -EPERM;
82730 + }
82731 +#endif
82732 +
82733 return ret;
82734 }
82735
82736 @@ -2112,22 +2150,12 @@ static void layout_sections(struct module *mod, struct load_info *info)
82737 || s->sh_entsize != ~0UL
82738 || strstarts(sname, ".init"))
82739 continue;
82740 - s->sh_entsize = get_offset(mod, &mod->core_size, s, i);
82741 + if ((s->sh_flags & SHF_WRITE) || !(s->sh_flags & SHF_ALLOC))
82742 + s->sh_entsize = get_offset(mod, &mod->core_size_rw, s, i);
82743 + else
82744 + s->sh_entsize = get_offset(mod, &mod->core_size_rx, s, i);
82745 pr_debug("\t%s\n", sname);
82746 }
82747 - switch (m) {
82748 - case 0: /* executable */
82749 - mod->core_size = debug_align(mod->core_size);
82750 - mod->core_text_size = mod->core_size;
82751 - break;
82752 - case 1: /* RO: text and ro-data */
82753 - mod->core_size = debug_align(mod->core_size);
82754 - mod->core_ro_size = mod->core_size;
82755 - break;
82756 - case 3: /* whole core */
82757 - mod->core_size = debug_align(mod->core_size);
82758 - break;
82759 - }
82760 }
82761
82762 pr_debug("Init section allocation order:\n");
82763 @@ -2141,23 +2169,13 @@ static void layout_sections(struct module *mod, struct load_info *info)
82764 || s->sh_entsize != ~0UL
82765 || !strstarts(sname, ".init"))
82766 continue;
82767 - s->sh_entsize = (get_offset(mod, &mod->init_size, s, i)
82768 - | INIT_OFFSET_MASK);
82769 + if ((s->sh_flags & SHF_WRITE) || !(s->sh_flags & SHF_ALLOC))
82770 + s->sh_entsize = get_offset(mod, &mod->init_size_rw, s, i);
82771 + else
82772 + s->sh_entsize = get_offset(mod, &mod->init_size_rx, s, i);
82773 + s->sh_entsize |= INIT_OFFSET_MASK;
82774 pr_debug("\t%s\n", sname);
82775 }
82776 - switch (m) {
82777 - case 0: /* executable */
82778 - mod->init_size = debug_align(mod->init_size);
82779 - mod->init_text_size = mod->init_size;
82780 - break;
82781 - case 1: /* RO: text and ro-data */
82782 - mod->init_size = debug_align(mod->init_size);
82783 - mod->init_ro_size = mod->init_size;
82784 - break;
82785 - case 3: /* whole init */
82786 - mod->init_size = debug_align(mod->init_size);
82787 - break;
82788 - }
82789 }
82790 }
82791
82792 @@ -2330,7 +2348,7 @@ static void layout_symtab(struct module *mod, struct load_info *info)
82793
82794 /* Put symbol section at end of init part of module. */
82795 symsect->sh_flags |= SHF_ALLOC;
82796 - symsect->sh_entsize = get_offset(mod, &mod->init_size, symsect,
82797 + symsect->sh_entsize = get_offset(mod, &mod->init_size_rx, symsect,
82798 info->index.sym) | INIT_OFFSET_MASK;
82799 pr_debug("\t%s\n", info->secstrings + symsect->sh_name);
82800
82801 @@ -2347,13 +2365,13 @@ static void layout_symtab(struct module *mod, struct load_info *info)
82802 }
82803
82804 /* Append room for core symbols at end of core part. */
82805 - info->symoffs = ALIGN(mod->core_size, symsect->sh_addralign ?: 1);
82806 - info->stroffs = mod->core_size = info->symoffs + ndst * sizeof(Elf_Sym);
82807 - mod->core_size += strtab_size;
82808 + info->symoffs = ALIGN(mod->core_size_rx, symsect->sh_addralign ?: 1);
82809 + info->stroffs = mod->core_size_rx = info->symoffs + ndst * sizeof(Elf_Sym);
82810 + mod->core_size_rx += strtab_size;
82811
82812 /* Put string table section at end of init part of module. */
82813 strsect->sh_flags |= SHF_ALLOC;
82814 - strsect->sh_entsize = get_offset(mod, &mod->init_size, strsect,
82815 + strsect->sh_entsize = get_offset(mod, &mod->init_size_rx, strsect,
82816 info->index.str) | INIT_OFFSET_MASK;
82817 pr_debug("\t%s\n", info->secstrings + strsect->sh_name);
82818 }
82819 @@ -2371,12 +2389,14 @@ static void add_kallsyms(struct module *mod, const struct load_info *info)
82820 /* Make sure we get permanent strtab: don't use info->strtab. */
82821 mod->strtab = (void *)info->sechdrs[info->index.str].sh_addr;
82822
82823 + pax_open_kernel();
82824 +
82825 /* Set types up while we still have access to sections. */
82826 for (i = 0; i < mod->num_symtab; i++)
82827 mod->symtab[i].st_info = elf_type(&mod->symtab[i], info);
82828
82829 - mod->core_symtab = dst = mod->module_core + info->symoffs;
82830 - mod->core_strtab = s = mod->module_core + info->stroffs;
82831 + mod->core_symtab = dst = mod->module_core_rx + info->symoffs;
82832 + mod->core_strtab = s = mod->module_core_rx + info->stroffs;
82833 src = mod->symtab;
82834 for (ndst = i = 0; i < mod->num_symtab; i++) {
82835 if (i == 0 ||
82836 @@ -2388,6 +2408,8 @@ static void add_kallsyms(struct module *mod, const struct load_info *info)
82837 }
82838 }
82839 mod->core_num_syms = ndst;
82840 +
82841 + pax_close_kernel();
82842 }
82843 #else
82844 static inline void layout_symtab(struct module *mod, struct load_info *info)
82845 @@ -2421,17 +2443,33 @@ void * __weak module_alloc(unsigned long size)
82846 return vmalloc_exec(size);
82847 }
82848
82849 -static void *module_alloc_update_bounds(unsigned long size)
82850 +static void *module_alloc_update_bounds_rw(unsigned long size)
82851 {
82852 void *ret = module_alloc(size);
82853
82854 if (ret) {
82855 mutex_lock(&module_mutex);
82856 /* Update module bounds. */
82857 - if ((unsigned long)ret < module_addr_min)
82858 - module_addr_min = (unsigned long)ret;
82859 - if ((unsigned long)ret + size > module_addr_max)
82860 - module_addr_max = (unsigned long)ret + size;
82861 + if ((unsigned long)ret < module_addr_min_rw)
82862 + module_addr_min_rw = (unsigned long)ret;
82863 + if ((unsigned long)ret + size > module_addr_max_rw)
82864 + module_addr_max_rw = (unsigned long)ret + size;
82865 + mutex_unlock(&module_mutex);
82866 + }
82867 + return ret;
82868 +}
82869 +
82870 +static void *module_alloc_update_bounds_rx(unsigned long size)
82871 +{
82872 + void *ret = module_alloc_exec(size);
82873 +
82874 + if (ret) {
82875 + mutex_lock(&module_mutex);
82876 + /* Update module bounds. */
82877 + if ((unsigned long)ret < module_addr_min_rx)
82878 + module_addr_min_rx = (unsigned long)ret;
82879 + if ((unsigned long)ret + size > module_addr_max_rx)
82880 + module_addr_max_rx = (unsigned long)ret + size;
82881 mutex_unlock(&module_mutex);
82882 }
82883 return ret;
82884 @@ -2706,8 +2744,14 @@ static struct module *setup_load_info(struct load_info *info, int flags)
82885 static int check_modinfo(struct module *mod, struct load_info *info, int flags)
82886 {
82887 const char *modmagic = get_modinfo(info, "vermagic");
82888 + const char *license = get_modinfo(info, "license");
82889 int err;
82890
82891 +#ifdef CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_OR
82892 + if (!license || !license_is_gpl_compatible(license))
82893 + return -ENOEXEC;
82894 +#endif
82895 +
82896 if (flags & MODULE_INIT_IGNORE_VERMAGIC)
82897 modmagic = NULL;
82898
82899 @@ -2733,7 +2777,7 @@ static int check_modinfo(struct module *mod, struct load_info *info, int flags)
82900 }
82901
82902 /* Set up license info based on the info section */
82903 - set_license(mod, get_modinfo(info, "license"));
82904 + set_license(mod, license);
82905
82906 return 0;
82907 }
82908 @@ -2814,7 +2858,7 @@ static int move_module(struct module *mod, struct load_info *info)
82909 void *ptr;
82910
82911 /* Do the allocs. */
82912 - ptr = module_alloc_update_bounds(mod->core_size);
82913 + ptr = module_alloc_update_bounds_rw(mod->core_size_rw);
82914 /*
82915 * The pointer to this block is stored in the module structure
82916 * which is inside the block. Just mark it as not being a
82917 @@ -2824,11 +2868,11 @@ static int move_module(struct module *mod, struct load_info *info)
82918 if (!ptr)
82919 return -ENOMEM;
82920
82921 - memset(ptr, 0, mod->core_size);
82922 - mod->module_core = ptr;
82923 + memset(ptr, 0, mod->core_size_rw);
82924 + mod->module_core_rw = ptr;
82925
82926 - if (mod->init_size) {
82927 - ptr = module_alloc_update_bounds(mod->init_size);
82928 + if (mod->init_size_rw) {
82929 + ptr = module_alloc_update_bounds_rw(mod->init_size_rw);
82930 /*
82931 * The pointer to this block is stored in the module structure
82932 * which is inside the block. This block doesn't need to be
82933 @@ -2837,13 +2881,45 @@ static int move_module(struct module *mod, struct load_info *info)
82934 */
82935 kmemleak_ignore(ptr);
82936 if (!ptr) {
82937 - module_free(mod, mod->module_core);
82938 + module_free(mod, mod->module_core_rw);
82939 return -ENOMEM;
82940 }
82941 - memset(ptr, 0, mod->init_size);
82942 - mod->module_init = ptr;
82943 + memset(ptr, 0, mod->init_size_rw);
82944 + mod->module_init_rw = ptr;
82945 } else
82946 - mod->module_init = NULL;
82947 + mod->module_init_rw = NULL;
82948 +
82949 + ptr = module_alloc_update_bounds_rx(mod->core_size_rx);
82950 + kmemleak_not_leak(ptr);
82951 + if (!ptr) {
82952 + if (mod->module_init_rw)
82953 + module_free(mod, mod->module_init_rw);
82954 + module_free(mod, mod->module_core_rw);
82955 + return -ENOMEM;
82956 + }
82957 +
82958 + pax_open_kernel();
82959 + memset(ptr, 0, mod->core_size_rx);
82960 + pax_close_kernel();
82961 + mod->module_core_rx = ptr;
82962 +
82963 + if (mod->init_size_rx) {
82964 + ptr = module_alloc_update_bounds_rx(mod->init_size_rx);
82965 + kmemleak_ignore(ptr);
82966 + if (!ptr && mod->init_size_rx) {
82967 + module_free_exec(mod, mod->module_core_rx);
82968 + if (mod->module_init_rw)
82969 + module_free(mod, mod->module_init_rw);
82970 + module_free(mod, mod->module_core_rw);
82971 + return -ENOMEM;
82972 + }
82973 +
82974 + pax_open_kernel();
82975 + memset(ptr, 0, mod->init_size_rx);
82976 + pax_close_kernel();
82977 + mod->module_init_rx = ptr;
82978 + } else
82979 + mod->module_init_rx = NULL;
82980
82981 /* Transfer each section which specifies SHF_ALLOC */
82982 pr_debug("final section addresses:\n");
82983 @@ -2854,16 +2930,45 @@ static int move_module(struct module *mod, struct load_info *info)
82984 if (!(shdr->sh_flags & SHF_ALLOC))
82985 continue;
82986
82987 - if (shdr->sh_entsize & INIT_OFFSET_MASK)
82988 - dest = mod->module_init
82989 - + (shdr->sh_entsize & ~INIT_OFFSET_MASK);
82990 - else
82991 - dest = mod->module_core + shdr->sh_entsize;
82992 + if (shdr->sh_entsize & INIT_OFFSET_MASK) {
82993 + if ((shdr->sh_flags & SHF_WRITE) || !(shdr->sh_flags & SHF_ALLOC))
82994 + dest = mod->module_init_rw
82995 + + (shdr->sh_entsize & ~INIT_OFFSET_MASK);
82996 + else
82997 + dest = mod->module_init_rx
82998 + + (shdr->sh_entsize & ~INIT_OFFSET_MASK);
82999 + } else {
83000 + if ((shdr->sh_flags & SHF_WRITE) || !(shdr->sh_flags & SHF_ALLOC))
83001 + dest = mod->module_core_rw + shdr->sh_entsize;
83002 + else
83003 + dest = mod->module_core_rx + shdr->sh_entsize;
83004 + }
83005 +
83006 + if (shdr->sh_type != SHT_NOBITS) {
83007 +
83008 +#ifdef CONFIG_PAX_KERNEXEC
83009 +#ifdef CONFIG_X86_64
83010 + if ((shdr->sh_flags & SHF_WRITE) && (shdr->sh_flags & SHF_EXECINSTR))
83011 + set_memory_x((unsigned long)dest, (shdr->sh_size + PAGE_SIZE) >> PAGE_SHIFT);
83012 +#endif
83013 + if (!(shdr->sh_flags & SHF_WRITE) && (shdr->sh_flags & SHF_ALLOC)) {
83014 + pax_open_kernel();
83015 + memcpy(dest, (void *)shdr->sh_addr, shdr->sh_size);
83016 + pax_close_kernel();
83017 + } else
83018 +#endif
83019
83020 - if (shdr->sh_type != SHT_NOBITS)
83021 memcpy(dest, (void *)shdr->sh_addr, shdr->sh_size);
83022 + }
83023 /* Update sh_addr to point to copy in image. */
83024 - shdr->sh_addr = (unsigned long)dest;
83025 +
83026 +#ifdef CONFIG_PAX_KERNEXEC
83027 + if (shdr->sh_flags & SHF_EXECINSTR)
83028 + shdr->sh_addr = ktva_ktla((unsigned long)dest);
83029 + else
83030 +#endif
83031 +
83032 + shdr->sh_addr = (unsigned long)dest;
83033 pr_debug("\t0x%lx %s\n",
83034 (long)shdr->sh_addr, info->secstrings + shdr->sh_name);
83035 }
83036 @@ -2920,12 +3025,12 @@ static void flush_module_icache(const struct module *mod)
83037 * Do it before processing of module parameters, so the module
83038 * can provide parameter accessor functions of its own.
83039 */
83040 - if (mod->module_init)
83041 - flush_icache_range((unsigned long)mod->module_init,
83042 - (unsigned long)mod->module_init
83043 - + mod->init_size);
83044 - flush_icache_range((unsigned long)mod->module_core,
83045 - (unsigned long)mod->module_core + mod->core_size);
83046 + if (mod->module_init_rx)
83047 + flush_icache_range((unsigned long)mod->module_init_rx,
83048 + (unsigned long)mod->module_init_rx
83049 + + mod->init_size_rx);
83050 + flush_icache_range((unsigned long)mod->module_core_rx,
83051 + (unsigned long)mod->module_core_rx + mod->core_size_rx);
83052
83053 set_fs(old_fs);
83054 }
83055 @@ -2982,8 +3087,10 @@ static struct module *layout_and_allocate(struct load_info *info, int flags)
83056 static void module_deallocate(struct module *mod, struct load_info *info)
83057 {
83058 percpu_modfree(mod);
83059 - module_free(mod, mod->module_init);
83060 - module_free(mod, mod->module_core);
83061 + module_free_exec(mod, mod->module_init_rx);
83062 + module_free_exec(mod, mod->module_core_rx);
83063 + module_free(mod, mod->module_init_rw);
83064 + module_free(mod, mod->module_core_rw);
83065 }
83066
83067 int __weak module_finalize(const Elf_Ehdr *hdr,
83068 @@ -2996,7 +3103,9 @@ int __weak module_finalize(const Elf_Ehdr *hdr,
83069 static int post_relocation(struct module *mod, const struct load_info *info)
83070 {
83071 /* Sort exception table now relocations are done. */
83072 + pax_open_kernel();
83073 sort_extable(mod->extable, mod->extable + mod->num_exentries);
83074 + pax_close_kernel();
83075
83076 /* Copy relocated percpu area over. */
83077 percpu_modcopy(mod, (void *)info->sechdrs[info->index.pcpu].sh_addr,
83078 @@ -3050,16 +3159,16 @@ static int do_init_module(struct module *mod)
83079 MODULE_STATE_COMING, mod);
83080
83081 /* Set RO and NX regions for core */
83082 - set_section_ro_nx(mod->module_core,
83083 - mod->core_text_size,
83084 - mod->core_ro_size,
83085 - mod->core_size);
83086 + set_section_ro_nx(mod->module_core_rx,
83087 + mod->core_size_rx,
83088 + mod->core_size_rx,
83089 + mod->core_size_rx);
83090
83091 /* Set RO and NX regions for init */
83092 - set_section_ro_nx(mod->module_init,
83093 - mod->init_text_size,
83094 - mod->init_ro_size,
83095 - mod->init_size);
83096 + set_section_ro_nx(mod->module_init_rx,
83097 + mod->init_size_rx,
83098 + mod->init_size_rx,
83099 + mod->init_size_rx);
83100
83101 do_mod_ctors(mod);
83102 /* Start the module */
83103 @@ -3121,11 +3230,12 @@ static int do_init_module(struct module *mod)
83104 mod->strtab = mod->core_strtab;
83105 #endif
83106 unset_module_init_ro_nx(mod);
83107 - module_free(mod, mod->module_init);
83108 - mod->module_init = NULL;
83109 - mod->init_size = 0;
83110 - mod->init_ro_size = 0;
83111 - mod->init_text_size = 0;
83112 + module_free(mod, mod->module_init_rw);
83113 + module_free_exec(mod, mod->module_init_rx);
83114 + mod->module_init_rw = NULL;
83115 + mod->module_init_rx = NULL;
83116 + mod->init_size_rw = 0;
83117 + mod->init_size_rx = 0;
83118 mutex_unlock(&module_mutex);
83119 wake_up_all(&module_wq);
83120
83121 @@ -3269,9 +3379,38 @@ static int load_module(struct load_info *info, const char __user *uargs,
83122 if (err)
83123 goto free_unload;
83124
83125 + /* Now copy in args */
83126 + mod->args = strndup_user(uargs, ~0UL >> 1);
83127 + if (IS_ERR(mod->args)) {
83128 + err = PTR_ERR(mod->args);
83129 + goto free_unload;
83130 + }
83131 +
83132 /* Set up MODINFO_ATTR fields */
83133 setup_modinfo(mod, info);
83134
83135 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
83136 + {
83137 + char *p, *p2;
83138 +
83139 + if (strstr(mod->args, "grsec_modharden_netdev")) {
83140 + 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);
83141 + err = -EPERM;
83142 + goto free_modinfo;
83143 + } else if ((p = strstr(mod->args, "grsec_modharden_normal"))) {
83144 + p += sizeof("grsec_modharden_normal") - 1;
83145 + p2 = strstr(p, "_");
83146 + if (p2) {
83147 + *p2 = '\0';
83148 + printk(KERN_ALERT "grsec: denied kernel module auto-load of %.64s by uid %.9s\n", mod->name, p);
83149 + *p2 = '_';
83150 + }
83151 + err = -EPERM;
83152 + goto free_modinfo;
83153 + }
83154 + }
83155 +#endif
83156 +
83157 /* Fix up syms, so that st_value is a pointer to location. */
83158 err = simplify_symbols(mod, info);
83159 if (err < 0)
83160 @@ -3287,13 +3426,6 @@ static int load_module(struct load_info *info, const char __user *uargs,
83161
83162 flush_module_icache(mod);
83163
83164 - /* Now copy in args */
83165 - mod->args = strndup_user(uargs, ~0UL >> 1);
83166 - if (IS_ERR(mod->args)) {
83167 - err = PTR_ERR(mod->args);
83168 - goto free_arch_cleanup;
83169 - }
83170 -
83171 dynamic_debug_setup(info->debug, info->num_debug);
83172
83173 /* Finally it's fully formed, ready to start executing. */
83174 @@ -3328,11 +3460,10 @@ static int load_module(struct load_info *info, const char __user *uargs,
83175 ddebug_cleanup:
83176 dynamic_debug_remove(info->debug);
83177 synchronize_sched();
83178 - kfree(mod->args);
83179 - free_arch_cleanup:
83180 module_arch_cleanup(mod);
83181 free_modinfo:
83182 free_modinfo(mod);
83183 + kfree(mod->args);
83184 free_unload:
83185 module_unload_free(mod);
83186 unlink_mod:
83187 @@ -3415,10 +3546,16 @@ static const char *get_ksymbol(struct module *mod,
83188 unsigned long nextval;
83189
83190 /* At worse, next value is at end of module */
83191 - if (within_module_init(addr, mod))
83192 - nextval = (unsigned long)mod->module_init+mod->init_text_size;
83193 + if (within_module_init_rx(addr, mod))
83194 + nextval = (unsigned long)mod->module_init_rx+mod->init_size_rx;
83195 + else if (within_module_init_rw(addr, mod))
83196 + nextval = (unsigned long)mod->module_init_rw+mod->init_size_rw;
83197 + else if (within_module_core_rx(addr, mod))
83198 + nextval = (unsigned long)mod->module_core_rx+mod->core_size_rx;
83199 + else if (within_module_core_rw(addr, mod))
83200 + nextval = (unsigned long)mod->module_core_rw+mod->core_size_rw;
83201 else
83202 - nextval = (unsigned long)mod->module_core+mod->core_text_size;
83203 + return NULL;
83204
83205 /* Scan for closest preceding symbol, and next symbol. (ELF
83206 starts real symbols at 1). */
83207 @@ -3669,7 +3806,7 @@ static int m_show(struct seq_file *m, void *p)
83208 return 0;
83209
83210 seq_printf(m, "%s %u",
83211 - mod->name, mod->init_size + mod->core_size);
83212 + mod->name, mod->init_size_rx + mod->init_size_rw + mod->core_size_rx + mod->core_size_rw);
83213 print_unload_info(m, mod);
83214
83215 /* Informative for users. */
83216 @@ -3678,7 +3815,7 @@ static int m_show(struct seq_file *m, void *p)
83217 mod->state == MODULE_STATE_COMING ? "Loading":
83218 "Live");
83219 /* Used by oprofile and other similar tools. */
83220 - seq_printf(m, " 0x%pK", mod->module_core);
83221 + seq_printf(m, " 0x%pK 0x%pK", mod->module_core_rx, mod->module_core_rw);
83222
83223 /* Taints info */
83224 if (mod->taints)
83225 @@ -3714,7 +3851,17 @@ static const struct file_operations proc_modules_operations = {
83226
83227 static int __init proc_modules_init(void)
83228 {
83229 +#ifndef CONFIG_GRKERNSEC_HIDESYM
83230 +#ifdef CONFIG_GRKERNSEC_PROC_USER
83231 + proc_create("modules", S_IRUSR, NULL, &proc_modules_operations);
83232 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
83233 + proc_create("modules", S_IRUSR | S_IRGRP, NULL, &proc_modules_operations);
83234 +#else
83235 proc_create("modules", 0, NULL, &proc_modules_operations);
83236 +#endif
83237 +#else
83238 + proc_create("modules", S_IRUSR, NULL, &proc_modules_operations);
83239 +#endif
83240 return 0;
83241 }
83242 module_init(proc_modules_init);
83243 @@ -3775,14 +3922,14 @@ struct module *__module_address(unsigned long addr)
83244 {
83245 struct module *mod;
83246
83247 - if (addr < module_addr_min || addr > module_addr_max)
83248 + if ((addr < module_addr_min_rx || addr > module_addr_max_rx) &&
83249 + (addr < module_addr_min_rw || addr > module_addr_max_rw))
83250 return NULL;
83251
83252 list_for_each_entry_rcu(mod, &modules, list) {
83253 if (mod->state == MODULE_STATE_UNFORMED)
83254 continue;
83255 - if (within_module_core(addr, mod)
83256 - || within_module_init(addr, mod))
83257 + if (within_module_init(addr, mod) || within_module_core(addr, mod))
83258 return mod;
83259 }
83260 return NULL;
83261 @@ -3817,11 +3964,20 @@ bool is_module_text_address(unsigned long addr)
83262 */
83263 struct module *__module_text_address(unsigned long addr)
83264 {
83265 - struct module *mod = __module_address(addr);
83266 + struct module *mod;
83267 +
83268 +#ifdef CONFIG_X86_32
83269 + addr = ktla_ktva(addr);
83270 +#endif
83271 +
83272 + if (addr < module_addr_min_rx || addr > module_addr_max_rx)
83273 + return NULL;
83274 +
83275 + mod = __module_address(addr);
83276 +
83277 if (mod) {
83278 /* Make sure it's within the text section. */
83279 - if (!within(addr, mod->module_init, mod->init_text_size)
83280 - && !within(addr, mod->module_core, mod->core_text_size))
83281 + if (!within_module_init_rx(addr, mod) && !within_module_core_rx(addr, mod))
83282 mod = NULL;
83283 }
83284 return mod;
83285 diff --git a/kernel/mutex-debug.c b/kernel/mutex-debug.c
83286 index 7e3443f..b2a1e6b 100644
83287 --- a/kernel/mutex-debug.c
83288 +++ b/kernel/mutex-debug.c
83289 @@ -49,21 +49,21 @@ void debug_mutex_free_waiter(struct mutex_waiter *waiter)
83290 }
83291
83292 void debug_mutex_add_waiter(struct mutex *lock, struct mutex_waiter *waiter,
83293 - struct thread_info *ti)
83294 + struct task_struct *task)
83295 {
83296 SMP_DEBUG_LOCKS_WARN_ON(!spin_is_locked(&lock->wait_lock));
83297
83298 /* Mark the current thread as blocked on the lock: */
83299 - ti->task->blocked_on = waiter;
83300 + task->blocked_on = waiter;
83301 }
83302
83303 void mutex_remove_waiter(struct mutex *lock, struct mutex_waiter *waiter,
83304 - struct thread_info *ti)
83305 + struct task_struct *task)
83306 {
83307 DEBUG_LOCKS_WARN_ON(list_empty(&waiter->list));
83308 - DEBUG_LOCKS_WARN_ON(waiter->task != ti->task);
83309 - DEBUG_LOCKS_WARN_ON(ti->task->blocked_on != waiter);
83310 - ti->task->blocked_on = NULL;
83311 + DEBUG_LOCKS_WARN_ON(waiter->task != task);
83312 + DEBUG_LOCKS_WARN_ON(task->blocked_on != waiter);
83313 + task->blocked_on = NULL;
83314
83315 list_del_init(&waiter->list);
83316 waiter->task = NULL;
83317 diff --git a/kernel/mutex-debug.h b/kernel/mutex-debug.h
83318 index 0799fd3..d06ae3b 100644
83319 --- a/kernel/mutex-debug.h
83320 +++ b/kernel/mutex-debug.h
83321 @@ -20,9 +20,9 @@ extern void debug_mutex_wake_waiter(struct mutex *lock,
83322 extern void debug_mutex_free_waiter(struct mutex_waiter *waiter);
83323 extern void debug_mutex_add_waiter(struct mutex *lock,
83324 struct mutex_waiter *waiter,
83325 - struct thread_info *ti);
83326 + struct task_struct *task);
83327 extern void mutex_remove_waiter(struct mutex *lock, struct mutex_waiter *waiter,
83328 - struct thread_info *ti);
83329 + struct task_struct *task);
83330 extern void debug_mutex_unlock(struct mutex *lock);
83331 extern void debug_mutex_init(struct mutex *lock, const char *name,
83332 struct lock_class_key *key);
83333 diff --git a/kernel/mutex.c b/kernel/mutex.c
83334 index d24105b..15648eb 100644
83335 --- a/kernel/mutex.c
83336 +++ b/kernel/mutex.c
83337 @@ -135,7 +135,7 @@ void mspin_lock(struct mspin_node **lock, struct mspin_node *node)
83338 node->locked = 1;
83339 return;
83340 }
83341 - ACCESS_ONCE(prev->next) = node;
83342 + ACCESS_ONCE_RW(prev->next) = node;
83343 smp_wmb();
83344 /* Wait until the lock holder passes the lock down */
83345 while (!ACCESS_ONCE(node->locked))
83346 @@ -156,7 +156,7 @@ static void mspin_unlock(struct mspin_node **lock, struct mspin_node *node)
83347 while (!(next = ACCESS_ONCE(node->next)))
83348 arch_mutex_cpu_relax();
83349 }
83350 - ACCESS_ONCE(next->locked) = 1;
83351 + ACCESS_ONCE_RW(next->locked) = 1;
83352 smp_wmb();
83353 }
83354
83355 @@ -520,7 +520,7 @@ slowpath:
83356 goto skip_wait;
83357
83358 debug_mutex_lock_common(lock, &waiter);
83359 - debug_mutex_add_waiter(lock, &waiter, task_thread_info(task));
83360 + debug_mutex_add_waiter(lock, &waiter, task);
83361
83362 /* add waiting tasks to the end of the waitqueue (FIFO): */
83363 list_add_tail(&waiter.list, &lock->wait_list);
83364 @@ -564,7 +564,7 @@ slowpath:
83365 schedule_preempt_disabled();
83366 spin_lock_mutex(&lock->wait_lock, flags);
83367 }
83368 - mutex_remove_waiter(lock, &waiter, current_thread_info());
83369 + mutex_remove_waiter(lock, &waiter, task);
83370 /* set it to 0 if there are no waiters left: */
83371 if (likely(list_empty(&lock->wait_list)))
83372 atomic_set(&lock->count, 0);
83373 @@ -601,7 +601,7 @@ skip_wait:
83374 return 0;
83375
83376 err:
83377 - mutex_remove_waiter(lock, &waiter, task_thread_info(task));
83378 + mutex_remove_waiter(lock, &waiter, task);
83379 spin_unlock_mutex(&lock->wait_lock, flags);
83380 debug_mutex_free_waiter(&waiter);
83381 mutex_release(&lock->dep_map, 1, ip);
83382 diff --git a/kernel/notifier.c b/kernel/notifier.c
83383 index 2d5cc4c..d9ea600 100644
83384 --- a/kernel/notifier.c
83385 +++ b/kernel/notifier.c
83386 @@ -5,6 +5,7 @@
83387 #include <linux/rcupdate.h>
83388 #include <linux/vmalloc.h>
83389 #include <linux/reboot.h>
83390 +#include <linux/mm.h>
83391
83392 /*
83393 * Notifier list for kernel code which wants to be called
83394 @@ -24,10 +25,12 @@ static int notifier_chain_register(struct notifier_block **nl,
83395 while ((*nl) != NULL) {
83396 if (n->priority > (*nl)->priority)
83397 break;
83398 - nl = &((*nl)->next);
83399 + nl = (struct notifier_block **)&((*nl)->next);
83400 }
83401 - n->next = *nl;
83402 + pax_open_kernel();
83403 + *(const void **)&n->next = *nl;
83404 rcu_assign_pointer(*nl, n);
83405 + pax_close_kernel();
83406 return 0;
83407 }
83408
83409 @@ -39,10 +42,12 @@ static int notifier_chain_cond_register(struct notifier_block **nl,
83410 return 0;
83411 if (n->priority > (*nl)->priority)
83412 break;
83413 - nl = &((*nl)->next);
83414 + nl = (struct notifier_block **)&((*nl)->next);
83415 }
83416 - n->next = *nl;
83417 + pax_open_kernel();
83418 + *(const void **)&n->next = *nl;
83419 rcu_assign_pointer(*nl, n);
83420 + pax_close_kernel();
83421 return 0;
83422 }
83423
83424 @@ -51,10 +56,12 @@ static int notifier_chain_unregister(struct notifier_block **nl,
83425 {
83426 while ((*nl) != NULL) {
83427 if ((*nl) == n) {
83428 + pax_open_kernel();
83429 rcu_assign_pointer(*nl, n->next);
83430 + pax_close_kernel();
83431 return 0;
83432 }
83433 - nl = &((*nl)->next);
83434 + nl = (struct notifier_block **)&((*nl)->next);
83435 }
83436 return -ENOENT;
83437 }
83438 diff --git a/kernel/panic.c b/kernel/panic.c
83439 index b6c482c..5578061 100644
83440 --- a/kernel/panic.c
83441 +++ b/kernel/panic.c
83442 @@ -407,7 +407,7 @@ static void warn_slowpath_common(const char *file, int line, void *caller,
83443 disable_trace_on_warning();
83444
83445 pr_warn("------------[ cut here ]------------\n");
83446 - pr_warn("WARNING: CPU: %d PID: %d at %s:%d %pS()\n",
83447 + pr_warn("WARNING: CPU: %d PID: %d at %s:%d %pA()\n",
83448 raw_smp_processor_id(), current->pid, file, line, caller);
83449
83450 if (args)
83451 @@ -461,7 +461,8 @@ EXPORT_SYMBOL(warn_slowpath_null);
83452 */
83453 void __stack_chk_fail(void)
83454 {
83455 - panic("stack-protector: Kernel stack is corrupted in: %p\n",
83456 + dump_stack();
83457 + panic("stack-protector: Kernel stack is corrupted in: %pA\n",
83458 __builtin_return_address(0));
83459 }
83460 EXPORT_SYMBOL(__stack_chk_fail);
83461 diff --git a/kernel/pid.c b/kernel/pid.c
83462 index 9b9a266..c20ef80 100644
83463 --- a/kernel/pid.c
83464 +++ b/kernel/pid.c
83465 @@ -33,6 +33,7 @@
83466 #include <linux/rculist.h>
83467 #include <linux/bootmem.h>
83468 #include <linux/hash.h>
83469 +#include <linux/security.h>
83470 #include <linux/pid_namespace.h>
83471 #include <linux/init_task.h>
83472 #include <linux/syscalls.h>
83473 @@ -47,7 +48,7 @@ struct pid init_struct_pid = INIT_STRUCT_PID;
83474
83475 int pid_max = PID_MAX_DEFAULT;
83476
83477 -#define RESERVED_PIDS 300
83478 +#define RESERVED_PIDS 500
83479
83480 int pid_max_min = RESERVED_PIDS + 1;
83481 int pid_max_max = PID_MAX_LIMIT;
83482 @@ -445,10 +446,18 @@ EXPORT_SYMBOL(pid_task);
83483 */
83484 struct task_struct *find_task_by_pid_ns(pid_t nr, struct pid_namespace *ns)
83485 {
83486 + struct task_struct *task;
83487 +
83488 rcu_lockdep_assert(rcu_read_lock_held(),
83489 "find_task_by_pid_ns() needs rcu_read_lock()"
83490 " protection");
83491 - return pid_task(find_pid_ns(nr, ns), PIDTYPE_PID);
83492 +
83493 + task = pid_task(find_pid_ns(nr, ns), PIDTYPE_PID);
83494 +
83495 + if (gr_pid_is_chrooted(task))
83496 + return NULL;
83497 +
83498 + return task;
83499 }
83500
83501 struct task_struct *find_task_by_vpid(pid_t vnr)
83502 @@ -456,6 +465,14 @@ struct task_struct *find_task_by_vpid(pid_t vnr)
83503 return find_task_by_pid_ns(vnr, task_active_pid_ns(current));
83504 }
83505
83506 +struct task_struct *find_task_by_vpid_unrestricted(pid_t vnr)
83507 +{
83508 + rcu_lockdep_assert(rcu_read_lock_held(),
83509 + "find_task_by_pid_ns() needs rcu_read_lock()"
83510 + " protection");
83511 + return pid_task(find_pid_ns(vnr, task_active_pid_ns(current)), PIDTYPE_PID);
83512 +}
83513 +
83514 struct pid *get_task_pid(struct task_struct *task, enum pid_type type)
83515 {
83516 struct pid *pid;
83517 diff --git a/kernel/pid_namespace.c b/kernel/pid_namespace.c
83518 index 4208655..19f36a5 100644
83519 --- a/kernel/pid_namespace.c
83520 +++ b/kernel/pid_namespace.c
83521 @@ -247,7 +247,7 @@ static int pid_ns_ctl_handler(struct ctl_table *table, int write,
83522 void __user *buffer, size_t *lenp, loff_t *ppos)
83523 {
83524 struct pid_namespace *pid_ns = task_active_pid_ns(current);
83525 - struct ctl_table tmp = *table;
83526 + ctl_table_no_const tmp = *table;
83527
83528 if (write && !ns_capable(pid_ns->user_ns, CAP_SYS_ADMIN))
83529 return -EPERM;
83530 diff --git a/kernel/posix-cpu-timers.c b/kernel/posix-cpu-timers.c
83531 index c7f31aa..2b44977 100644
83532 --- a/kernel/posix-cpu-timers.c
83533 +++ b/kernel/posix-cpu-timers.c
83534 @@ -1521,14 +1521,14 @@ struct k_clock clock_posix_cpu = {
83535
83536 static __init int init_posix_cpu_timers(void)
83537 {
83538 - struct k_clock process = {
83539 + static struct k_clock process = {
83540 .clock_getres = process_cpu_clock_getres,
83541 .clock_get = process_cpu_clock_get,
83542 .timer_create = process_cpu_timer_create,
83543 .nsleep = process_cpu_nsleep,
83544 .nsleep_restart = process_cpu_nsleep_restart,
83545 };
83546 - struct k_clock thread = {
83547 + static struct k_clock thread = {
83548 .clock_getres = thread_cpu_clock_getres,
83549 .clock_get = thread_cpu_clock_get,
83550 .timer_create = thread_cpu_timer_create,
83551 diff --git a/kernel/posix-timers.c b/kernel/posix-timers.c
83552 index 424c2d4..679242f 100644
83553 --- a/kernel/posix-timers.c
83554 +++ b/kernel/posix-timers.c
83555 @@ -43,6 +43,7 @@
83556 #include <linux/hash.h>
83557 #include <linux/posix-clock.h>
83558 #include <linux/posix-timers.h>
83559 +#include <linux/grsecurity.h>
83560 #include <linux/syscalls.h>
83561 #include <linux/wait.h>
83562 #include <linux/workqueue.h>
83563 @@ -122,7 +123,7 @@ static DEFINE_SPINLOCK(hash_lock);
83564 * which we beg off on and pass to do_sys_settimeofday().
83565 */
83566
83567 -static struct k_clock posix_clocks[MAX_CLOCKS];
83568 +static struct k_clock *posix_clocks[MAX_CLOCKS];
83569
83570 /*
83571 * These ones are defined below.
83572 @@ -275,7 +276,7 @@ static int posix_get_tai(clockid_t which_clock, struct timespec *tp)
83573 */
83574 static __init int init_posix_timers(void)
83575 {
83576 - struct k_clock clock_realtime = {
83577 + static struct k_clock clock_realtime = {
83578 .clock_getres = hrtimer_get_res,
83579 .clock_get = posix_clock_realtime_get,
83580 .clock_set = posix_clock_realtime_set,
83581 @@ -287,7 +288,7 @@ static __init int init_posix_timers(void)
83582 .timer_get = common_timer_get,
83583 .timer_del = common_timer_del,
83584 };
83585 - struct k_clock clock_monotonic = {
83586 + static struct k_clock clock_monotonic = {
83587 .clock_getres = hrtimer_get_res,
83588 .clock_get = posix_ktime_get_ts,
83589 .nsleep = common_nsleep,
83590 @@ -297,19 +298,19 @@ static __init int init_posix_timers(void)
83591 .timer_get = common_timer_get,
83592 .timer_del = common_timer_del,
83593 };
83594 - struct k_clock clock_monotonic_raw = {
83595 + static struct k_clock clock_monotonic_raw = {
83596 .clock_getres = hrtimer_get_res,
83597 .clock_get = posix_get_monotonic_raw,
83598 };
83599 - struct k_clock clock_realtime_coarse = {
83600 + static struct k_clock clock_realtime_coarse = {
83601 .clock_getres = posix_get_coarse_res,
83602 .clock_get = posix_get_realtime_coarse,
83603 };
83604 - struct k_clock clock_monotonic_coarse = {
83605 + static struct k_clock clock_monotonic_coarse = {
83606 .clock_getres = posix_get_coarse_res,
83607 .clock_get = posix_get_monotonic_coarse,
83608 };
83609 - struct k_clock clock_tai = {
83610 + static struct k_clock clock_tai = {
83611 .clock_getres = hrtimer_get_res,
83612 .clock_get = posix_get_tai,
83613 .nsleep = common_nsleep,
83614 @@ -319,7 +320,7 @@ static __init int init_posix_timers(void)
83615 .timer_get = common_timer_get,
83616 .timer_del = common_timer_del,
83617 };
83618 - struct k_clock clock_boottime = {
83619 + static struct k_clock clock_boottime = {
83620 .clock_getres = hrtimer_get_res,
83621 .clock_get = posix_get_boottime,
83622 .nsleep = common_nsleep,
83623 @@ -531,7 +532,7 @@ void posix_timers_register_clock(const clockid_t clock_id,
83624 return;
83625 }
83626
83627 - posix_clocks[clock_id] = *new_clock;
83628 + posix_clocks[clock_id] = new_clock;
83629 }
83630 EXPORT_SYMBOL_GPL(posix_timers_register_clock);
83631
83632 @@ -577,9 +578,9 @@ static struct k_clock *clockid_to_kclock(const clockid_t id)
83633 return (id & CLOCKFD_MASK) == CLOCKFD ?
83634 &clock_posix_dynamic : &clock_posix_cpu;
83635
83636 - if (id >= MAX_CLOCKS || !posix_clocks[id].clock_getres)
83637 + if (id >= MAX_CLOCKS || !posix_clocks[id] || !posix_clocks[id]->clock_getres)
83638 return NULL;
83639 - return &posix_clocks[id];
83640 + return posix_clocks[id];
83641 }
83642
83643 static int common_timer_create(struct k_itimer *new_timer)
83644 @@ -597,7 +598,7 @@ SYSCALL_DEFINE3(timer_create, const clockid_t, which_clock,
83645 struct k_clock *kc = clockid_to_kclock(which_clock);
83646 struct k_itimer *new_timer;
83647 int error, new_timer_id;
83648 - sigevent_t event;
83649 + sigevent_t event = { };
83650 int it_id_set = IT_ID_NOT_SET;
83651
83652 if (!kc)
83653 @@ -1011,6 +1012,13 @@ SYSCALL_DEFINE2(clock_settime, const clockid_t, which_clock,
83654 if (copy_from_user(&new_tp, tp, sizeof (*tp)))
83655 return -EFAULT;
83656
83657 + /* only the CLOCK_REALTIME clock can be set, all other clocks
83658 + have their clock_set fptr set to a nosettime dummy function
83659 + CLOCK_REALTIME has a NULL clock_set fptr which causes it to
83660 + call common_clock_set, which calls do_sys_settimeofday, which
83661 + we hook
83662 + */
83663 +
83664 return kc->clock_set(which_clock, &new_tp);
83665 }
83666
83667 diff --git a/kernel/power/process.c b/kernel/power/process.c
83668 index 06ec886..9dba35e 100644
83669 --- a/kernel/power/process.c
83670 +++ b/kernel/power/process.c
83671 @@ -34,6 +34,7 @@ static int try_to_freeze_tasks(bool user_only)
83672 unsigned int elapsed_msecs;
83673 bool wakeup = false;
83674 int sleep_usecs = USEC_PER_MSEC;
83675 + bool timedout = false;
83676
83677 do_gettimeofday(&start);
83678
83679 @@ -44,13 +45,20 @@ static int try_to_freeze_tasks(bool user_only)
83680
83681 while (true) {
83682 todo = 0;
83683 + if (time_after(jiffies, end_time))
83684 + timedout = true;
83685 read_lock(&tasklist_lock);
83686 do_each_thread(g, p) {
83687 if (p == current || !freeze_task(p))
83688 continue;
83689
83690 - if (!freezer_should_skip(p))
83691 + if (!freezer_should_skip(p)) {
83692 todo++;
83693 + if (timedout) {
83694 + printk(KERN_ERR "Task refusing to freeze:\n");
83695 + sched_show_task(p);
83696 + }
83697 + }
83698 } while_each_thread(g, p);
83699 read_unlock(&tasklist_lock);
83700
83701 @@ -59,7 +67,7 @@ static int try_to_freeze_tasks(bool user_only)
83702 todo += wq_busy;
83703 }
83704
83705 - if (!todo || time_after(jiffies, end_time))
83706 + if (!todo || timedout)
83707 break;
83708
83709 if (pm_wakeup_pending()) {
83710 diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c
83711 index b4e8500..b457a6c 100644
83712 --- a/kernel/printk/printk.c
83713 +++ b/kernel/printk/printk.c
83714 @@ -385,6 +385,11 @@ static int check_syslog_permissions(int type, bool from_file)
83715 if (from_file && type != SYSLOG_ACTION_OPEN)
83716 return 0;
83717
83718 +#ifdef CONFIG_GRKERNSEC_DMESG
83719 + if (grsec_enable_dmesg && !capable(CAP_SYSLOG) && !capable_nolog(CAP_SYS_ADMIN))
83720 + return -EPERM;
83721 +#endif
83722 +
83723 if (syslog_action_restricted(type)) {
83724 if (capable(CAP_SYSLOG))
83725 return 0;
83726 diff --git a/kernel/profile.c b/kernel/profile.c
83727 index 6631e1e..310c266 100644
83728 --- a/kernel/profile.c
83729 +++ b/kernel/profile.c
83730 @@ -37,7 +37,7 @@ struct profile_hit {
83731 #define NR_PROFILE_HIT (PAGE_SIZE/sizeof(struct profile_hit))
83732 #define NR_PROFILE_GRP (NR_PROFILE_HIT/PROFILE_GRPSZ)
83733
83734 -static atomic_t *prof_buffer;
83735 +static atomic_unchecked_t *prof_buffer;
83736 static unsigned long prof_len, prof_shift;
83737
83738 int prof_on __read_mostly;
83739 @@ -260,7 +260,7 @@ static void profile_flip_buffers(void)
83740 hits[i].pc = 0;
83741 continue;
83742 }
83743 - atomic_add(hits[i].hits, &prof_buffer[hits[i].pc]);
83744 + atomic_add_unchecked(hits[i].hits, &prof_buffer[hits[i].pc]);
83745 hits[i].hits = hits[i].pc = 0;
83746 }
83747 }
83748 @@ -321,9 +321,9 @@ static void do_profile_hits(int type, void *__pc, unsigned int nr_hits)
83749 * Add the current hit(s) and flush the write-queue out
83750 * to the global buffer:
83751 */
83752 - atomic_add(nr_hits, &prof_buffer[pc]);
83753 + atomic_add_unchecked(nr_hits, &prof_buffer[pc]);
83754 for (i = 0; i < NR_PROFILE_HIT; ++i) {
83755 - atomic_add(hits[i].hits, &prof_buffer[hits[i].pc]);
83756 + atomic_add_unchecked(hits[i].hits, &prof_buffer[hits[i].pc]);
83757 hits[i].pc = hits[i].hits = 0;
83758 }
83759 out:
83760 @@ -398,7 +398,7 @@ static void do_profile_hits(int type, void *__pc, unsigned int nr_hits)
83761 {
83762 unsigned long pc;
83763 pc = ((unsigned long)__pc - (unsigned long)_stext) >> prof_shift;
83764 - atomic_add(nr_hits, &prof_buffer[min(pc, prof_len - 1)]);
83765 + atomic_add_unchecked(nr_hits, &prof_buffer[min(pc, prof_len - 1)]);
83766 }
83767 #endif /* !CONFIG_SMP */
83768
83769 @@ -494,7 +494,7 @@ read_profile(struct file *file, char __user *buf, size_t count, loff_t *ppos)
83770 return -EFAULT;
83771 buf++; p++; count--; read++;
83772 }
83773 - pnt = (char *)prof_buffer + p - sizeof(atomic_t);
83774 + pnt = (char *)prof_buffer + p - sizeof(atomic_unchecked_t);
83775 if (copy_to_user(buf, (void *)pnt, count))
83776 return -EFAULT;
83777 read += count;
83778 @@ -525,7 +525,7 @@ static ssize_t write_profile(struct file *file, const char __user *buf,
83779 }
83780 #endif
83781 profile_discard_flip_buffers();
83782 - memset(prof_buffer, 0, prof_len * sizeof(atomic_t));
83783 + memset(prof_buffer, 0, prof_len * sizeof(atomic_unchecked_t));
83784 return count;
83785 }
83786
83787 diff --git a/kernel/ptrace.c b/kernel/ptrace.c
83788 index 1f4bcb3..99cf7ab 100644
83789 --- a/kernel/ptrace.c
83790 +++ b/kernel/ptrace.c
83791 @@ -327,7 +327,7 @@ static int ptrace_attach(struct task_struct *task, long request,
83792 if (seize)
83793 flags |= PT_SEIZED;
83794 rcu_read_lock();
83795 - if (ns_capable(__task_cred(task)->user_ns, CAP_SYS_PTRACE))
83796 + if (ns_capable_nolog(__task_cred(task)->user_ns, CAP_SYS_PTRACE))
83797 flags |= PT_PTRACE_CAP;
83798 rcu_read_unlock();
83799 task->ptrace = flags;
83800 @@ -538,7 +538,7 @@ int ptrace_readdata(struct task_struct *tsk, unsigned long src, char __user *dst
83801 break;
83802 return -EIO;
83803 }
83804 - if (copy_to_user(dst, buf, retval))
83805 + if (retval > sizeof(buf) || copy_to_user(dst, buf, retval))
83806 return -EFAULT;
83807 copied += retval;
83808 src += retval;
83809 @@ -806,7 +806,7 @@ int ptrace_request(struct task_struct *child, long request,
83810 bool seized = child->ptrace & PT_SEIZED;
83811 int ret = -EIO;
83812 siginfo_t siginfo, *si;
83813 - void __user *datavp = (void __user *) data;
83814 + void __user *datavp = (__force void __user *) data;
83815 unsigned long __user *datalp = datavp;
83816 unsigned long flags;
83817
83818 @@ -1052,14 +1052,21 @@ SYSCALL_DEFINE4(ptrace, long, request, long, pid, unsigned long, addr,
83819 goto out;
83820 }
83821
83822 + if (gr_handle_ptrace(child, request)) {
83823 + ret = -EPERM;
83824 + goto out_put_task_struct;
83825 + }
83826 +
83827 if (request == PTRACE_ATTACH || request == PTRACE_SEIZE) {
83828 ret = ptrace_attach(child, request, addr, data);
83829 /*
83830 * Some architectures need to do book-keeping after
83831 * a ptrace attach.
83832 */
83833 - if (!ret)
83834 + if (!ret) {
83835 arch_ptrace_attach(child);
83836 + gr_audit_ptrace(child);
83837 + }
83838 goto out_put_task_struct;
83839 }
83840
83841 @@ -1087,7 +1094,7 @@ int generic_ptrace_peekdata(struct task_struct *tsk, unsigned long addr,
83842 copied = access_process_vm(tsk, addr, &tmp, sizeof(tmp), 0);
83843 if (copied != sizeof(tmp))
83844 return -EIO;
83845 - return put_user(tmp, (unsigned long __user *)data);
83846 + return put_user(tmp, (__force unsigned long __user *)data);
83847 }
83848
83849 int generic_ptrace_pokedata(struct task_struct *tsk, unsigned long addr,
83850 @@ -1181,7 +1188,7 @@ int compat_ptrace_request(struct task_struct *child, compat_long_t request,
83851 }
83852
83853 asmlinkage long compat_sys_ptrace(compat_long_t request, compat_long_t pid,
83854 - compat_long_t addr, compat_long_t data)
83855 + compat_ulong_t addr, compat_ulong_t data)
83856 {
83857 struct task_struct *child;
83858 long ret;
83859 @@ -1197,14 +1204,21 @@ asmlinkage long compat_sys_ptrace(compat_long_t request, compat_long_t pid,
83860 goto out;
83861 }
83862
83863 + if (gr_handle_ptrace(child, request)) {
83864 + ret = -EPERM;
83865 + goto out_put_task_struct;
83866 + }
83867 +
83868 if (request == PTRACE_ATTACH || request == PTRACE_SEIZE) {
83869 ret = ptrace_attach(child, request, addr, data);
83870 /*
83871 * Some architectures need to do book-keeping after
83872 * a ptrace attach.
83873 */
83874 - if (!ret)
83875 + if (!ret) {
83876 arch_ptrace_attach(child);
83877 + gr_audit_ptrace(child);
83878 + }
83879 goto out_put_task_struct;
83880 }
83881
83882 diff --git a/kernel/rcupdate.c b/kernel/rcupdate.c
83883 index b02a339..ce2d20c 100644
83884 --- a/kernel/rcupdate.c
83885 +++ b/kernel/rcupdate.c
83886 @@ -312,10 +312,10 @@ int rcu_jiffies_till_stall_check(void)
83887 * for CONFIG_RCU_CPU_STALL_TIMEOUT.
83888 */
83889 if (till_stall_check < 3) {
83890 - ACCESS_ONCE(rcu_cpu_stall_timeout) = 3;
83891 + ACCESS_ONCE_RW(rcu_cpu_stall_timeout) = 3;
83892 till_stall_check = 3;
83893 } else if (till_stall_check > 300) {
83894 - ACCESS_ONCE(rcu_cpu_stall_timeout) = 300;
83895 + ACCESS_ONCE_RW(rcu_cpu_stall_timeout) = 300;
83896 till_stall_check = 300;
83897 }
83898 return till_stall_check * HZ + RCU_STALL_DELAY_DELTA;
83899 diff --git a/kernel/rcutiny.c b/kernel/rcutiny.c
83900 index 9ed6075..c9e8a63 100644
83901 --- a/kernel/rcutiny.c
83902 +++ b/kernel/rcutiny.c
83903 @@ -45,7 +45,7 @@
83904 /* Forward declarations for rcutiny_plugin.h. */
83905 struct rcu_ctrlblk;
83906 static void __rcu_process_callbacks(struct rcu_ctrlblk *rcp);
83907 -static void rcu_process_callbacks(struct softirq_action *unused);
83908 +static void rcu_process_callbacks(void);
83909 static void __call_rcu(struct rcu_head *head,
83910 void (*func)(struct rcu_head *rcu),
83911 struct rcu_ctrlblk *rcp);
83912 @@ -309,7 +309,7 @@ static void __rcu_process_callbacks(struct rcu_ctrlblk *rcp)
83913 false));
83914 }
83915
83916 -static void rcu_process_callbacks(struct softirq_action *unused)
83917 +static __latent_entropy void rcu_process_callbacks(void)
83918 {
83919 __rcu_process_callbacks(&rcu_sched_ctrlblk);
83920 __rcu_process_callbacks(&rcu_bh_ctrlblk);
83921 diff --git a/kernel/rcutorture.c b/kernel/rcutorture.c
83922 index be63101..05cf721 100644
83923 --- a/kernel/rcutorture.c
83924 +++ b/kernel/rcutorture.c
83925 @@ -170,12 +170,12 @@ static DEFINE_PER_CPU(long [RCU_TORTURE_PIPE_LEN + 1], rcu_torture_count) =
83926 { 0 };
83927 static DEFINE_PER_CPU(long [RCU_TORTURE_PIPE_LEN + 1], rcu_torture_batch) =
83928 { 0 };
83929 -static atomic_t rcu_torture_wcount[RCU_TORTURE_PIPE_LEN + 1];
83930 -static atomic_t n_rcu_torture_alloc;
83931 -static atomic_t n_rcu_torture_alloc_fail;
83932 -static atomic_t n_rcu_torture_free;
83933 -static atomic_t n_rcu_torture_mberror;
83934 -static atomic_t n_rcu_torture_error;
83935 +static atomic_unchecked_t rcu_torture_wcount[RCU_TORTURE_PIPE_LEN + 1];
83936 +static atomic_unchecked_t n_rcu_torture_alloc;
83937 +static atomic_unchecked_t n_rcu_torture_alloc_fail;
83938 +static atomic_unchecked_t n_rcu_torture_free;
83939 +static atomic_unchecked_t n_rcu_torture_mberror;
83940 +static atomic_unchecked_t n_rcu_torture_error;
83941 static long n_rcu_torture_barrier_error;
83942 static long n_rcu_torture_boost_ktrerror;
83943 static long n_rcu_torture_boost_rterror;
83944 @@ -293,11 +293,11 @@ rcu_torture_alloc(void)
83945
83946 spin_lock_bh(&rcu_torture_lock);
83947 if (list_empty(&rcu_torture_freelist)) {
83948 - atomic_inc(&n_rcu_torture_alloc_fail);
83949 + atomic_inc_unchecked(&n_rcu_torture_alloc_fail);
83950 spin_unlock_bh(&rcu_torture_lock);
83951 return NULL;
83952 }
83953 - atomic_inc(&n_rcu_torture_alloc);
83954 + atomic_inc_unchecked(&n_rcu_torture_alloc);
83955 p = rcu_torture_freelist.next;
83956 list_del_init(p);
83957 spin_unlock_bh(&rcu_torture_lock);
83958 @@ -310,7 +310,7 @@ rcu_torture_alloc(void)
83959 static void
83960 rcu_torture_free(struct rcu_torture *p)
83961 {
83962 - atomic_inc(&n_rcu_torture_free);
83963 + atomic_inc_unchecked(&n_rcu_torture_free);
83964 spin_lock_bh(&rcu_torture_lock);
83965 list_add_tail(&p->rtort_free, &rcu_torture_freelist);
83966 spin_unlock_bh(&rcu_torture_lock);
83967 @@ -431,7 +431,7 @@ rcu_torture_cb(struct rcu_head *p)
83968 i = rp->rtort_pipe_count;
83969 if (i > RCU_TORTURE_PIPE_LEN)
83970 i = RCU_TORTURE_PIPE_LEN;
83971 - atomic_inc(&rcu_torture_wcount[i]);
83972 + atomic_inc_unchecked(&rcu_torture_wcount[i]);
83973 if (++rp->rtort_pipe_count >= RCU_TORTURE_PIPE_LEN) {
83974 rp->rtort_mbtest = 0;
83975 rcu_torture_free(rp);
83976 @@ -821,7 +821,7 @@ rcu_torture_writer(void *arg)
83977 i = old_rp->rtort_pipe_count;
83978 if (i > RCU_TORTURE_PIPE_LEN)
83979 i = RCU_TORTURE_PIPE_LEN;
83980 - atomic_inc(&rcu_torture_wcount[i]);
83981 + atomic_inc_unchecked(&rcu_torture_wcount[i]);
83982 old_rp->rtort_pipe_count++;
83983 if (gp_normal == gp_exp)
83984 exp = !!(rcu_random(&rand) & 0x80);
83985 @@ -839,7 +839,7 @@ rcu_torture_writer(void *arg)
83986 i = rp->rtort_pipe_count;
83987 if (i > RCU_TORTURE_PIPE_LEN)
83988 i = RCU_TORTURE_PIPE_LEN;
83989 - atomic_inc(&rcu_torture_wcount[i]);
83990 + atomic_inc_unchecked(&rcu_torture_wcount[i]);
83991 if (++rp->rtort_pipe_count >=
83992 RCU_TORTURE_PIPE_LEN) {
83993 rp->rtort_mbtest = 0;
83994 @@ -938,7 +938,7 @@ static void rcu_torture_timer(unsigned long unused)
83995 return;
83996 }
83997 if (p->rtort_mbtest == 0)
83998 - atomic_inc(&n_rcu_torture_mberror);
83999 + atomic_inc_unchecked(&n_rcu_torture_mberror);
84000 spin_lock(&rand_lock);
84001 cur_ops->read_delay(&rand);
84002 n_rcu_torture_timers++;
84003 @@ -1008,7 +1008,7 @@ rcu_torture_reader(void *arg)
84004 continue;
84005 }
84006 if (p->rtort_mbtest == 0)
84007 - atomic_inc(&n_rcu_torture_mberror);
84008 + atomic_inc_unchecked(&n_rcu_torture_mberror);
84009 cur_ops->read_delay(&rand);
84010 preempt_disable();
84011 pipe_count = p->rtort_pipe_count;
84012 @@ -1071,11 +1071,11 @@ rcu_torture_printk(char *page)
84013 rcu_torture_current,
84014 rcu_torture_current_version,
84015 list_empty(&rcu_torture_freelist),
84016 - atomic_read(&n_rcu_torture_alloc),
84017 - atomic_read(&n_rcu_torture_alloc_fail),
84018 - atomic_read(&n_rcu_torture_free));
84019 + atomic_read_unchecked(&n_rcu_torture_alloc),
84020 + atomic_read_unchecked(&n_rcu_torture_alloc_fail),
84021 + atomic_read_unchecked(&n_rcu_torture_free));
84022 cnt += sprintf(&page[cnt], "rtmbe: %d rtbke: %ld rtbre: %ld ",
84023 - atomic_read(&n_rcu_torture_mberror),
84024 + atomic_read_unchecked(&n_rcu_torture_mberror),
84025 n_rcu_torture_boost_ktrerror,
84026 n_rcu_torture_boost_rterror);
84027 cnt += sprintf(&page[cnt], "rtbf: %ld rtb: %ld nt: %ld ",
84028 @@ -1094,14 +1094,14 @@ rcu_torture_printk(char *page)
84029 n_barrier_attempts,
84030 n_rcu_torture_barrier_error);
84031 cnt += sprintf(&page[cnt], "\n%s%s ", torture_type, TORTURE_FLAG);
84032 - if (atomic_read(&n_rcu_torture_mberror) != 0 ||
84033 + if (atomic_read_unchecked(&n_rcu_torture_mberror) != 0 ||
84034 n_rcu_torture_barrier_error != 0 ||
84035 n_rcu_torture_boost_ktrerror != 0 ||
84036 n_rcu_torture_boost_rterror != 0 ||
84037 n_rcu_torture_boost_failure != 0 ||
84038 i > 1) {
84039 cnt += sprintf(&page[cnt], "!!! ");
84040 - atomic_inc(&n_rcu_torture_error);
84041 + atomic_inc_unchecked(&n_rcu_torture_error);
84042 WARN_ON_ONCE(1);
84043 }
84044 cnt += sprintf(&page[cnt], "Reader Pipe: ");
84045 @@ -1115,7 +1115,7 @@ rcu_torture_printk(char *page)
84046 cnt += sprintf(&page[cnt], "Free-Block Circulation: ");
84047 for (i = 0; i < RCU_TORTURE_PIPE_LEN + 1; i++) {
84048 cnt += sprintf(&page[cnt], " %d",
84049 - atomic_read(&rcu_torture_wcount[i]));
84050 + atomic_read_unchecked(&rcu_torture_wcount[i]));
84051 }
84052 cnt += sprintf(&page[cnt], "\n");
84053 if (cur_ops->stats)
84054 @@ -1830,7 +1830,7 @@ rcu_torture_cleanup(void)
84055
84056 rcu_torture_stats_print(); /* -After- the stats thread is stopped! */
84057
84058 - if (atomic_read(&n_rcu_torture_error) || n_rcu_torture_barrier_error)
84059 + if (atomic_read_unchecked(&n_rcu_torture_error) || n_rcu_torture_barrier_error)
84060 rcu_torture_print_module_parms(cur_ops, "End of test: FAILURE");
84061 else if (n_online_successes != n_online_attempts ||
84062 n_offline_successes != n_offline_attempts)
84063 @@ -1952,18 +1952,18 @@ rcu_torture_init(void)
84064
84065 rcu_torture_current = NULL;
84066 rcu_torture_current_version = 0;
84067 - atomic_set(&n_rcu_torture_alloc, 0);
84068 - atomic_set(&n_rcu_torture_alloc_fail, 0);
84069 - atomic_set(&n_rcu_torture_free, 0);
84070 - atomic_set(&n_rcu_torture_mberror, 0);
84071 - atomic_set(&n_rcu_torture_error, 0);
84072 + atomic_set_unchecked(&n_rcu_torture_alloc, 0);
84073 + atomic_set_unchecked(&n_rcu_torture_alloc_fail, 0);
84074 + atomic_set_unchecked(&n_rcu_torture_free, 0);
84075 + atomic_set_unchecked(&n_rcu_torture_mberror, 0);
84076 + atomic_set_unchecked(&n_rcu_torture_error, 0);
84077 n_rcu_torture_barrier_error = 0;
84078 n_rcu_torture_boost_ktrerror = 0;
84079 n_rcu_torture_boost_rterror = 0;
84080 n_rcu_torture_boost_failure = 0;
84081 n_rcu_torture_boosts = 0;
84082 for (i = 0; i < RCU_TORTURE_PIPE_LEN + 1; i++)
84083 - atomic_set(&rcu_torture_wcount[i], 0);
84084 + atomic_set_unchecked(&rcu_torture_wcount[i], 0);
84085 for_each_possible_cpu(cpu) {
84086 for (i = 0; i < RCU_TORTURE_PIPE_LEN + 1; i++) {
84087 per_cpu(rcu_torture_count, cpu)[i] = 0;
84088 diff --git a/kernel/rcutree.c b/kernel/rcutree.c
84089 index 32618b3..c1fb822 100644
84090 --- a/kernel/rcutree.c
84091 +++ b/kernel/rcutree.c
84092 @@ -382,9 +382,9 @@ static void rcu_eqs_enter_common(struct rcu_dynticks *rdtp, long long oldval,
84093 rcu_prepare_for_idle(smp_processor_id());
84094 /* CPUs seeing atomic_inc() must see prior RCU read-side crit sects */
84095 smp_mb__before_atomic_inc(); /* See above. */
84096 - atomic_inc(&rdtp->dynticks);
84097 + atomic_inc_unchecked(&rdtp->dynticks);
84098 smp_mb__after_atomic_inc(); /* Force ordering with next sojourn. */
84099 - WARN_ON_ONCE(atomic_read(&rdtp->dynticks) & 0x1);
84100 + WARN_ON_ONCE(atomic_read_unchecked(&rdtp->dynticks) & 0x1);
84101
84102 /*
84103 * It is illegal to enter an extended quiescent state while
84104 @@ -501,10 +501,10 @@ static void rcu_eqs_exit_common(struct rcu_dynticks *rdtp, long long oldval,
84105 int user)
84106 {
84107 smp_mb__before_atomic_inc(); /* Force ordering w/previous sojourn. */
84108 - atomic_inc(&rdtp->dynticks);
84109 + atomic_inc_unchecked(&rdtp->dynticks);
84110 /* CPUs seeing atomic_inc() must see later RCU read-side crit sects */
84111 smp_mb__after_atomic_inc(); /* See above. */
84112 - WARN_ON_ONCE(!(atomic_read(&rdtp->dynticks) & 0x1));
84113 + WARN_ON_ONCE(!(atomic_read_unchecked(&rdtp->dynticks) & 0x1));
84114 rcu_cleanup_after_idle(smp_processor_id());
84115 trace_rcu_dyntick(TPS("End"), oldval, rdtp->dynticks_nesting);
84116 if (!user && !is_idle_task(current)) {
84117 @@ -623,14 +623,14 @@ void rcu_nmi_enter(void)
84118 struct rcu_dynticks *rdtp = &__get_cpu_var(rcu_dynticks);
84119
84120 if (rdtp->dynticks_nmi_nesting == 0 &&
84121 - (atomic_read(&rdtp->dynticks) & 0x1))
84122 + (atomic_read_unchecked(&rdtp->dynticks) & 0x1))
84123 return;
84124 rdtp->dynticks_nmi_nesting++;
84125 smp_mb__before_atomic_inc(); /* Force delay from prior write. */
84126 - atomic_inc(&rdtp->dynticks);
84127 + atomic_inc_unchecked(&rdtp->dynticks);
84128 /* CPUs seeing atomic_inc() must see later RCU read-side crit sects */
84129 smp_mb__after_atomic_inc(); /* See above. */
84130 - WARN_ON_ONCE(!(atomic_read(&rdtp->dynticks) & 0x1));
84131 + WARN_ON_ONCE(!(atomic_read_unchecked(&rdtp->dynticks) & 0x1));
84132 }
84133
84134 /**
84135 @@ -649,9 +649,9 @@ void rcu_nmi_exit(void)
84136 return;
84137 /* CPUs seeing atomic_inc() must see prior RCU read-side crit sects */
84138 smp_mb__before_atomic_inc(); /* See above. */
84139 - atomic_inc(&rdtp->dynticks);
84140 + atomic_inc_unchecked(&rdtp->dynticks);
84141 smp_mb__after_atomic_inc(); /* Force delay to next write. */
84142 - WARN_ON_ONCE(atomic_read(&rdtp->dynticks) & 0x1);
84143 + WARN_ON_ONCE(atomic_read_unchecked(&rdtp->dynticks) & 0x1);
84144 }
84145
84146 /**
84147 @@ -665,7 +665,7 @@ int rcu_is_cpu_idle(void)
84148 int ret;
84149
84150 preempt_disable();
84151 - ret = (atomic_read(&__get_cpu_var(rcu_dynticks).dynticks) & 0x1) == 0;
84152 + ret = (atomic_read_unchecked(&__get_cpu_var(rcu_dynticks).dynticks) & 0x1) == 0;
84153 preempt_enable();
84154 return ret;
84155 }
84156 @@ -734,7 +734,7 @@ static int rcu_is_cpu_rrupt_from_idle(void)
84157 static int dyntick_save_progress_counter(struct rcu_data *rdp,
84158 bool *isidle, unsigned long *maxj)
84159 {
84160 - rdp->dynticks_snap = atomic_add_return(0, &rdp->dynticks->dynticks);
84161 + rdp->dynticks_snap = atomic_add_return_unchecked(0, &rdp->dynticks->dynticks);
84162 rcu_sysidle_check_cpu(rdp, isidle, maxj);
84163 return (rdp->dynticks_snap & 0x1) == 0;
84164 }
84165 @@ -751,7 +751,7 @@ static int rcu_implicit_dynticks_qs(struct rcu_data *rdp,
84166 unsigned int curr;
84167 unsigned int snap;
84168
84169 - curr = (unsigned int)atomic_add_return(0, &rdp->dynticks->dynticks);
84170 + curr = (unsigned int)atomic_add_return_unchecked(0, &rdp->dynticks->dynticks);
84171 snap = (unsigned int)rdp->dynticks_snap;
84172
84173 /*
84174 @@ -1341,9 +1341,9 @@ static int rcu_gp_init(struct rcu_state *rsp)
84175 rdp = this_cpu_ptr(rsp->rda);
84176 rcu_preempt_check_blocked_tasks(rnp);
84177 rnp->qsmask = rnp->qsmaskinit;
84178 - ACCESS_ONCE(rnp->gpnum) = rsp->gpnum;
84179 + ACCESS_ONCE_RW(rnp->gpnum) = rsp->gpnum;
84180 WARN_ON_ONCE(rnp->completed != rsp->completed);
84181 - ACCESS_ONCE(rnp->completed) = rsp->completed;
84182 + ACCESS_ONCE_RW(rnp->completed) = rsp->completed;
84183 if (rnp == rdp->mynode)
84184 __note_gp_changes(rsp, rnp, rdp);
84185 rcu_preempt_boost_start_gp(rnp);
84186 @@ -1434,7 +1434,7 @@ static void rcu_gp_cleanup(struct rcu_state *rsp)
84187 */
84188 rcu_for_each_node_breadth_first(rsp, rnp) {
84189 raw_spin_lock_irq(&rnp->lock);
84190 - ACCESS_ONCE(rnp->completed) = rsp->gpnum;
84191 + ACCESS_ONCE_RW(rnp->completed) = rsp->gpnum;
84192 rdp = this_cpu_ptr(rsp->rda);
84193 if (rnp == rdp->mynode)
84194 __note_gp_changes(rsp, rnp, rdp);
84195 @@ -1766,7 +1766,7 @@ rcu_send_cbs_to_orphanage(int cpu, struct rcu_state *rsp,
84196 rsp->qlen += rdp->qlen;
84197 rdp->n_cbs_orphaned += rdp->qlen;
84198 rdp->qlen_lazy = 0;
84199 - ACCESS_ONCE(rdp->qlen) = 0;
84200 + ACCESS_ONCE_RW(rdp->qlen) = 0;
84201 }
84202
84203 /*
84204 @@ -2012,7 +2012,7 @@ static void rcu_do_batch(struct rcu_state *rsp, struct rcu_data *rdp)
84205 }
84206 smp_mb(); /* List handling before counting for rcu_barrier(). */
84207 rdp->qlen_lazy -= count_lazy;
84208 - ACCESS_ONCE(rdp->qlen) -= count;
84209 + ACCESS_ONCE_RW(rdp->qlen) -= count;
84210 rdp->n_cbs_invoked += count;
84211
84212 /* Reinstate batch limit if we have worked down the excess. */
84213 @@ -2209,7 +2209,7 @@ __rcu_process_callbacks(struct rcu_state *rsp)
84214 /*
84215 * Do RCU core processing for the current CPU.
84216 */
84217 -static void rcu_process_callbacks(struct softirq_action *unused)
84218 +static __latent_entropy void rcu_process_callbacks(void)
84219 {
84220 struct rcu_state *rsp;
84221
84222 @@ -2316,7 +2316,7 @@ __call_rcu(struct rcu_head *head, void (*func)(struct rcu_head *rcu),
84223 WARN_ON_ONCE((unsigned long)head & 0x3); /* Misaligned rcu_head! */
84224 if (debug_rcu_head_queue(head)) {
84225 /* Probable double call_rcu(), so leak the callback. */
84226 - ACCESS_ONCE(head->func) = rcu_leak_callback;
84227 + ACCESS_ONCE_RW(head->func) = rcu_leak_callback;
84228 WARN_ONCE(1, "__call_rcu(): Leaked duplicate callback\n");
84229 return;
84230 }
84231 @@ -2344,7 +2344,7 @@ __call_rcu(struct rcu_head *head, void (*func)(struct rcu_head *rcu),
84232 local_irq_restore(flags);
84233 return;
84234 }
84235 - ACCESS_ONCE(rdp->qlen)++;
84236 + ACCESS_ONCE_RW(rdp->qlen)++;
84237 if (lazy)
84238 rdp->qlen_lazy++;
84239 else
84240 @@ -2553,11 +2553,11 @@ void synchronize_sched_expedited(void)
84241 * counter wrap on a 32-bit system. Quite a few more CPUs would of
84242 * course be required on a 64-bit system.
84243 */
84244 - if (ULONG_CMP_GE((ulong)atomic_long_read(&rsp->expedited_start),
84245 + if (ULONG_CMP_GE((ulong)atomic_long_read_unchecked(&rsp->expedited_start),
84246 (ulong)atomic_long_read(&rsp->expedited_done) +
84247 ULONG_MAX / 8)) {
84248 synchronize_sched();
84249 - atomic_long_inc(&rsp->expedited_wrap);
84250 + atomic_long_inc_unchecked(&rsp->expedited_wrap);
84251 return;
84252 }
84253
84254 @@ -2565,7 +2565,7 @@ void synchronize_sched_expedited(void)
84255 * Take a ticket. Note that atomic_inc_return() implies a
84256 * full memory barrier.
84257 */
84258 - snap = atomic_long_inc_return(&rsp->expedited_start);
84259 + snap = atomic_long_inc_return_unchecked(&rsp->expedited_start);
84260 firstsnap = snap;
84261 get_online_cpus();
84262 WARN_ON_ONCE(cpu_is_offline(raw_smp_processor_id()));
84263 @@ -2578,14 +2578,14 @@ void synchronize_sched_expedited(void)
84264 synchronize_sched_expedited_cpu_stop,
84265 NULL) == -EAGAIN) {
84266 put_online_cpus();
84267 - atomic_long_inc(&rsp->expedited_tryfail);
84268 + atomic_long_inc_unchecked(&rsp->expedited_tryfail);
84269
84270 /* Check to see if someone else did our work for us. */
84271 s = atomic_long_read(&rsp->expedited_done);
84272 if (ULONG_CMP_GE((ulong)s, (ulong)firstsnap)) {
84273 /* ensure test happens before caller kfree */
84274 smp_mb__before_atomic_inc(); /* ^^^ */
84275 - atomic_long_inc(&rsp->expedited_workdone1);
84276 + atomic_long_inc_unchecked(&rsp->expedited_workdone1);
84277 return;
84278 }
84279
84280 @@ -2594,7 +2594,7 @@ void synchronize_sched_expedited(void)
84281 udelay(trycount * num_online_cpus());
84282 } else {
84283 wait_rcu_gp(call_rcu_sched);
84284 - atomic_long_inc(&rsp->expedited_normal);
84285 + atomic_long_inc_unchecked(&rsp->expedited_normal);
84286 return;
84287 }
84288
84289 @@ -2603,7 +2603,7 @@ void synchronize_sched_expedited(void)
84290 if (ULONG_CMP_GE((ulong)s, (ulong)firstsnap)) {
84291 /* ensure test happens before caller kfree */
84292 smp_mb__before_atomic_inc(); /* ^^^ */
84293 - atomic_long_inc(&rsp->expedited_workdone2);
84294 + atomic_long_inc_unchecked(&rsp->expedited_workdone2);
84295 return;
84296 }
84297
84298 @@ -2615,10 +2615,10 @@ void synchronize_sched_expedited(void)
84299 * period works for us.
84300 */
84301 get_online_cpus();
84302 - snap = atomic_long_read(&rsp->expedited_start);
84303 + snap = atomic_long_read_unchecked(&rsp->expedited_start);
84304 smp_mb(); /* ensure read is before try_stop_cpus(). */
84305 }
84306 - atomic_long_inc(&rsp->expedited_stoppedcpus);
84307 + atomic_long_inc_unchecked(&rsp->expedited_stoppedcpus);
84308
84309 /*
84310 * Everyone up to our most recent fetch is covered by our grace
84311 @@ -2627,16 +2627,16 @@ void synchronize_sched_expedited(void)
84312 * than we did already did their update.
84313 */
84314 do {
84315 - atomic_long_inc(&rsp->expedited_done_tries);
84316 + atomic_long_inc_unchecked(&rsp->expedited_done_tries);
84317 s = atomic_long_read(&rsp->expedited_done);
84318 if (ULONG_CMP_GE((ulong)s, (ulong)snap)) {
84319 /* ensure test happens before caller kfree */
84320 smp_mb__before_atomic_inc(); /* ^^^ */
84321 - atomic_long_inc(&rsp->expedited_done_lost);
84322 + atomic_long_inc_unchecked(&rsp->expedited_done_lost);
84323 break;
84324 }
84325 } while (atomic_long_cmpxchg(&rsp->expedited_done, s, snap) != s);
84326 - atomic_long_inc(&rsp->expedited_done_exit);
84327 + atomic_long_inc_unchecked(&rsp->expedited_done_exit);
84328
84329 put_online_cpus();
84330 }
84331 @@ -2829,7 +2829,7 @@ static void _rcu_barrier(struct rcu_state *rsp)
84332 * ACCESS_ONCE() to prevent the compiler from speculating
84333 * the increment to precede the early-exit check.
84334 */
84335 - ACCESS_ONCE(rsp->n_barrier_done)++;
84336 + ACCESS_ONCE_RW(rsp->n_barrier_done)++;
84337 WARN_ON_ONCE((rsp->n_barrier_done & 0x1) != 1);
84338 _rcu_barrier_trace(rsp, "Inc1", -1, rsp->n_barrier_done);
84339 smp_mb(); /* Order ->n_barrier_done increment with below mechanism. */
84340 @@ -2879,7 +2879,7 @@ static void _rcu_barrier(struct rcu_state *rsp)
84341
84342 /* Increment ->n_barrier_done to prevent duplicate work. */
84343 smp_mb(); /* Keep increment after above mechanism. */
84344 - ACCESS_ONCE(rsp->n_barrier_done)++;
84345 + ACCESS_ONCE_RW(rsp->n_barrier_done)++;
84346 WARN_ON_ONCE((rsp->n_barrier_done & 0x1) != 0);
84347 _rcu_barrier_trace(rsp, "Inc2", -1, rsp->n_barrier_done);
84348 smp_mb(); /* Keep increment before caller's subsequent code. */
84349 @@ -2924,10 +2924,10 @@ rcu_boot_init_percpu_data(int cpu, struct rcu_state *rsp)
84350 rdp->grpmask = 1UL << (cpu - rdp->mynode->grplo);
84351 init_callback_list(rdp);
84352 rdp->qlen_lazy = 0;
84353 - ACCESS_ONCE(rdp->qlen) = 0;
84354 + ACCESS_ONCE_RW(rdp->qlen) = 0;
84355 rdp->dynticks = &per_cpu(rcu_dynticks, cpu);
84356 WARN_ON_ONCE(rdp->dynticks->dynticks_nesting != DYNTICK_TASK_EXIT_IDLE);
84357 - WARN_ON_ONCE(atomic_read(&rdp->dynticks->dynticks) != 1);
84358 + WARN_ON_ONCE(atomic_read_unchecked(&rdp->dynticks->dynticks) != 1);
84359 rdp->cpu = cpu;
84360 rdp->rsp = rsp;
84361 rcu_boot_init_nocb_percpu_data(rdp);
84362 @@ -2961,8 +2961,8 @@ rcu_init_percpu_data(int cpu, struct rcu_state *rsp, int preemptible)
84363 init_callback_list(rdp); /* Re-enable callbacks on this CPU. */
84364 rdp->dynticks->dynticks_nesting = DYNTICK_TASK_EXIT_IDLE;
84365 rcu_sysidle_init_percpu_data(rdp->dynticks);
84366 - atomic_set(&rdp->dynticks->dynticks,
84367 - (atomic_read(&rdp->dynticks->dynticks) & ~0x1) + 1);
84368 + atomic_set_unchecked(&rdp->dynticks->dynticks,
84369 + (atomic_read_unchecked(&rdp->dynticks->dynticks) & ~0x1) + 1);
84370 raw_spin_unlock(&rnp->lock); /* irqs remain disabled. */
84371
84372 /* Add CPU to rcu_node bitmasks. */
84373 diff --git a/kernel/rcutree.h b/kernel/rcutree.h
84374 index 5f97eab..db8f687 100644
84375 --- a/kernel/rcutree.h
84376 +++ b/kernel/rcutree.h
84377 @@ -87,11 +87,11 @@ struct rcu_dynticks {
84378 long long dynticks_nesting; /* Track irq/process nesting level. */
84379 /* Process level is worth LLONG_MAX/2. */
84380 int dynticks_nmi_nesting; /* Track NMI nesting level. */
84381 - atomic_t dynticks; /* Even value for idle, else odd. */
84382 + atomic_unchecked_t dynticks;/* Even value for idle, else odd. */
84383 #ifdef CONFIG_NO_HZ_FULL_SYSIDLE
84384 long long dynticks_idle_nesting;
84385 /* irq/process nesting level from idle. */
84386 - atomic_t dynticks_idle; /* Even value for idle, else odd. */
84387 + atomic_unchecked_t dynticks_idle; /* Even value for idle, else odd. */
84388 /* "Idle" excludes userspace execution. */
84389 unsigned long dynticks_idle_jiffies;
84390 /* End of last non-NMI non-idle period. */
84391 @@ -427,17 +427,17 @@ struct rcu_state {
84392 /* _rcu_barrier(). */
84393 /* End of fields guarded by barrier_mutex. */
84394
84395 - atomic_long_t expedited_start; /* Starting ticket. */
84396 - atomic_long_t expedited_done; /* Done ticket. */
84397 - atomic_long_t expedited_wrap; /* # near-wrap incidents. */
84398 - atomic_long_t expedited_tryfail; /* # acquisition failures. */
84399 - atomic_long_t expedited_workdone1; /* # done by others #1. */
84400 - atomic_long_t expedited_workdone2; /* # done by others #2. */
84401 - atomic_long_t expedited_normal; /* # fallbacks to normal. */
84402 - atomic_long_t expedited_stoppedcpus; /* # successful stop_cpus. */
84403 - atomic_long_t expedited_done_tries; /* # tries to update _done. */
84404 - atomic_long_t expedited_done_lost; /* # times beaten to _done. */
84405 - atomic_long_t expedited_done_exit; /* # times exited _done loop. */
84406 + atomic_long_unchecked_t expedited_start; /* Starting ticket. */
84407 + atomic_long_t expedited_done; /* Done ticket. */
84408 + atomic_long_unchecked_t expedited_wrap; /* # near-wrap incidents. */
84409 + atomic_long_unchecked_t expedited_tryfail; /* # acquisition failures. */
84410 + atomic_long_unchecked_t expedited_workdone1; /* # done by others #1. */
84411 + atomic_long_unchecked_t expedited_workdone2; /* # done by others #2. */
84412 + atomic_long_unchecked_t expedited_normal; /* # fallbacks to normal. */
84413 + atomic_long_unchecked_t expedited_stoppedcpus; /* # successful stop_cpus. */
84414 + atomic_long_unchecked_t expedited_done_tries; /* # tries to update _done. */
84415 + atomic_long_unchecked_t expedited_done_lost; /* # times beaten to _done. */
84416 + atomic_long_unchecked_t expedited_done_exit; /* # times exited _done loop. */
84417
84418 unsigned long jiffies_force_qs; /* Time at which to invoke */
84419 /* force_quiescent_state(). */
84420 diff --git a/kernel/rcutree_plugin.h b/kernel/rcutree_plugin.h
84421 index 130c97b..bcbe7f7 100644
84422 --- a/kernel/rcutree_plugin.h
84423 +++ b/kernel/rcutree_plugin.h
84424 @@ -744,7 +744,7 @@ static int rcu_preempted_readers_exp(struct rcu_node *rnp)
84425 static int sync_rcu_preempt_exp_done(struct rcu_node *rnp)
84426 {
84427 return !rcu_preempted_readers_exp(rnp) &&
84428 - ACCESS_ONCE(rnp->expmask) == 0;
84429 + ACCESS_ONCE_RW(rnp->expmask) == 0;
84430 }
84431
84432 /*
84433 @@ -900,7 +900,7 @@ void synchronize_rcu_expedited(void)
84434
84435 /* Clean up and exit. */
84436 smp_mb(); /* ensure expedited GP seen before counter increment. */
84437 - ACCESS_ONCE(sync_rcu_preempt_exp_count)++;
84438 + ACCESS_ONCE_RW(sync_rcu_preempt_exp_count)++;
84439 unlock_mb_ret:
84440 mutex_unlock(&sync_rcu_preempt_exp_mutex);
84441 mb_ret:
84442 @@ -1474,7 +1474,7 @@ static void rcu_boost_kthread_setaffinity(struct rcu_node *rnp, int outgoingcpu)
84443 free_cpumask_var(cm);
84444 }
84445
84446 -static struct smp_hotplug_thread rcu_cpu_thread_spec = {
84447 +static struct smp_hotplug_thread rcu_cpu_thread_spec __read_only = {
84448 .store = &rcu_cpu_kthread_task,
84449 .thread_should_run = rcu_cpu_kthread_should_run,
84450 .thread_fn = rcu_cpu_kthread,
84451 @@ -1939,7 +1939,7 @@ static void print_cpu_stall_info(struct rcu_state *rsp, int cpu)
84452 print_cpu_stall_fast_no_hz(fast_no_hz, cpu);
84453 pr_err("\t%d: (%lu %s) idle=%03x/%llx/%d softirq=%u/%u %s\n",
84454 cpu, ticks_value, ticks_title,
84455 - atomic_read(&rdtp->dynticks) & 0xfff,
84456 + atomic_read_unchecked(&rdtp->dynticks) & 0xfff,
84457 rdtp->dynticks_nesting, rdtp->dynticks_nmi_nesting,
84458 rdp->softirq_snap, kstat_softirqs_cpu(RCU_SOFTIRQ, cpu),
84459 fast_no_hz);
84460 @@ -2102,7 +2102,7 @@ static void __call_rcu_nocb_enqueue(struct rcu_data *rdp,
84461
84462 /* Enqueue the callback on the nocb list and update counts. */
84463 old_rhpp = xchg(&rdp->nocb_tail, rhtp);
84464 - ACCESS_ONCE(*old_rhpp) = rhp;
84465 + ACCESS_ONCE_RW(*old_rhpp) = rhp;
84466 atomic_long_add(rhcount, &rdp->nocb_q_count);
84467 atomic_long_add(rhcount_lazy, &rdp->nocb_q_count_lazy);
84468
84469 @@ -2242,12 +2242,12 @@ static int rcu_nocb_kthread(void *arg)
84470 * Extract queued callbacks, update counts, and wait
84471 * for a grace period to elapse.
84472 */
84473 - ACCESS_ONCE(rdp->nocb_head) = NULL;
84474 + ACCESS_ONCE_RW(rdp->nocb_head) = NULL;
84475 tail = xchg(&rdp->nocb_tail, &rdp->nocb_head);
84476 c = atomic_long_xchg(&rdp->nocb_q_count, 0);
84477 cl = atomic_long_xchg(&rdp->nocb_q_count_lazy, 0);
84478 - ACCESS_ONCE(rdp->nocb_p_count) += c;
84479 - ACCESS_ONCE(rdp->nocb_p_count_lazy) += cl;
84480 + ACCESS_ONCE_RW(rdp->nocb_p_count) += c;
84481 + ACCESS_ONCE_RW(rdp->nocb_p_count_lazy) += cl;
84482 rcu_nocb_wait_gp(rdp);
84483
84484 /* Each pass through the following loop invokes a callback. */
84485 @@ -2269,8 +2269,8 @@ static int rcu_nocb_kthread(void *arg)
84486 list = next;
84487 }
84488 trace_rcu_batch_end(rdp->rsp->name, c, !!list, 0, 0, 1);
84489 - ACCESS_ONCE(rdp->nocb_p_count) -= c;
84490 - ACCESS_ONCE(rdp->nocb_p_count_lazy) -= cl;
84491 + ACCESS_ONCE_RW(rdp->nocb_p_count) -= c;
84492 + ACCESS_ONCE_RW(rdp->nocb_p_count_lazy) -= cl;
84493 rdp->n_nocbs_invoked += c;
84494 }
84495 return 0;
84496 @@ -2297,7 +2297,7 @@ static void __init rcu_spawn_nocb_kthreads(struct rcu_state *rsp)
84497 t = kthread_run(rcu_nocb_kthread, rdp,
84498 "rcuo%c/%d", rsp->abbr, cpu);
84499 BUG_ON(IS_ERR(t));
84500 - ACCESS_ONCE(rdp->nocb_kthread) = t;
84501 + ACCESS_ONCE_RW(rdp->nocb_kthread) = t;
84502 }
84503 }
84504
84505 @@ -2423,11 +2423,11 @@ static void rcu_sysidle_enter(struct rcu_dynticks *rdtp, int irq)
84506
84507 /* Record start of fully idle period. */
84508 j = jiffies;
84509 - ACCESS_ONCE(rdtp->dynticks_idle_jiffies) = j;
84510 + ACCESS_ONCE_RW(rdtp->dynticks_idle_jiffies) = j;
84511 smp_mb__before_atomic_inc();
84512 - atomic_inc(&rdtp->dynticks_idle);
84513 + atomic_inc_unchecked(&rdtp->dynticks_idle);
84514 smp_mb__after_atomic_inc();
84515 - WARN_ON_ONCE(atomic_read(&rdtp->dynticks_idle) & 0x1);
84516 + WARN_ON_ONCE(atomic_read_unchecked(&rdtp->dynticks_idle) & 0x1);
84517 }
84518
84519 /*
84520 @@ -2492,9 +2492,9 @@ static void rcu_sysidle_exit(struct rcu_dynticks *rdtp, int irq)
84521
84522 /* Record end of idle period. */
84523 smp_mb__before_atomic_inc();
84524 - atomic_inc(&rdtp->dynticks_idle);
84525 + atomic_inc_unchecked(&rdtp->dynticks_idle);
84526 smp_mb__after_atomic_inc();
84527 - WARN_ON_ONCE(!(atomic_read(&rdtp->dynticks_idle) & 0x1));
84528 + WARN_ON_ONCE(!(atomic_read_unchecked(&rdtp->dynticks_idle) & 0x1));
84529
84530 /*
84531 * If we are the timekeeping CPU, we are permitted to be non-idle
84532 @@ -2535,7 +2535,7 @@ static void rcu_sysidle_check_cpu(struct rcu_data *rdp, bool *isidle,
84533 WARN_ON_ONCE(smp_processor_id() != tick_do_timer_cpu);
84534
84535 /* Pick up current idle and NMI-nesting counter and check. */
84536 - cur = atomic_read(&rdtp->dynticks_idle);
84537 + cur = atomic_read_unchecked(&rdtp->dynticks_idle);
84538 if (cur & 0x1) {
84539 *isidle = false; /* We are not idle! */
84540 return;
84541 @@ -2598,7 +2598,7 @@ static void rcu_sysidle(unsigned long j)
84542 case RCU_SYSIDLE_NOT:
84543
84544 /* First time all are idle, so note a short idle period. */
84545 - ACCESS_ONCE(full_sysidle_state) = RCU_SYSIDLE_SHORT;
84546 + ACCESS_ONCE_RW(full_sysidle_state) = RCU_SYSIDLE_SHORT;
84547 break;
84548
84549 case RCU_SYSIDLE_SHORT:
84550 @@ -2635,7 +2635,7 @@ static void rcu_sysidle(unsigned long j)
84551 static void rcu_sysidle_cancel(void)
84552 {
84553 smp_mb();
84554 - ACCESS_ONCE(full_sysidle_state) = RCU_SYSIDLE_NOT;
84555 + ACCESS_ONCE_RW(full_sysidle_state) = RCU_SYSIDLE_NOT;
84556 }
84557
84558 /*
84559 @@ -2683,7 +2683,7 @@ static void rcu_sysidle_cb(struct rcu_head *rhp)
84560 smp_mb(); /* grace period precedes setting inuse. */
84561
84562 rshp = container_of(rhp, struct rcu_sysidle_head, rh);
84563 - ACCESS_ONCE(rshp->inuse) = 0;
84564 + ACCESS_ONCE_RW(rshp->inuse) = 0;
84565 }
84566
84567 /*
84568 diff --git a/kernel/rcutree_trace.c b/kernel/rcutree_trace.c
84569 index cf6c174..a8f4b50 100644
84570 --- a/kernel/rcutree_trace.c
84571 +++ b/kernel/rcutree_trace.c
84572 @@ -121,7 +121,7 @@ static void print_one_rcu_data(struct seq_file *m, struct rcu_data *rdp)
84573 ulong2long(rdp->completed), ulong2long(rdp->gpnum),
84574 rdp->passed_quiesce, rdp->qs_pending);
84575 seq_printf(m, " dt=%d/%llx/%d df=%lu",
84576 - atomic_read(&rdp->dynticks->dynticks),
84577 + atomic_read_unchecked(&rdp->dynticks->dynticks),
84578 rdp->dynticks->dynticks_nesting,
84579 rdp->dynticks->dynticks_nmi_nesting,
84580 rdp->dynticks_fqs);
84581 @@ -182,17 +182,17 @@ static int show_rcuexp(struct seq_file *m, void *v)
84582 struct rcu_state *rsp = (struct rcu_state *)m->private;
84583
84584 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",
84585 - atomic_long_read(&rsp->expedited_start),
84586 + atomic_long_read_unchecked(&rsp->expedited_start),
84587 atomic_long_read(&rsp->expedited_done),
84588 - atomic_long_read(&rsp->expedited_wrap),
84589 - atomic_long_read(&rsp->expedited_tryfail),
84590 - atomic_long_read(&rsp->expedited_workdone1),
84591 - atomic_long_read(&rsp->expedited_workdone2),
84592 - atomic_long_read(&rsp->expedited_normal),
84593 - atomic_long_read(&rsp->expedited_stoppedcpus),
84594 - atomic_long_read(&rsp->expedited_done_tries),
84595 - atomic_long_read(&rsp->expedited_done_lost),
84596 - atomic_long_read(&rsp->expedited_done_exit));
84597 + atomic_long_read_unchecked(&rsp->expedited_wrap),
84598 + atomic_long_read_unchecked(&rsp->expedited_tryfail),
84599 + atomic_long_read_unchecked(&rsp->expedited_workdone1),
84600 + atomic_long_read_unchecked(&rsp->expedited_workdone2),
84601 + atomic_long_read_unchecked(&rsp->expedited_normal),
84602 + atomic_long_read_unchecked(&rsp->expedited_stoppedcpus),
84603 + atomic_long_read_unchecked(&rsp->expedited_done_tries),
84604 + atomic_long_read_unchecked(&rsp->expedited_done_lost),
84605 + atomic_long_read_unchecked(&rsp->expedited_done_exit));
84606 return 0;
84607 }
84608
84609 diff --git a/kernel/resource.c b/kernel/resource.c
84610 index 3f285dc..5755f62 100644
84611 --- a/kernel/resource.c
84612 +++ b/kernel/resource.c
84613 @@ -152,8 +152,18 @@ static const struct file_operations proc_iomem_operations = {
84614
84615 static int __init ioresources_init(void)
84616 {
84617 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
84618 +#ifdef CONFIG_GRKERNSEC_PROC_USER
84619 + proc_create("ioports", S_IRUSR, NULL, &proc_ioports_operations);
84620 + proc_create("iomem", S_IRUSR, NULL, &proc_iomem_operations);
84621 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
84622 + proc_create("ioports", S_IRUSR | S_IRGRP, NULL, &proc_ioports_operations);
84623 + proc_create("iomem", S_IRUSR | S_IRGRP, NULL, &proc_iomem_operations);
84624 +#endif
84625 +#else
84626 proc_create("ioports", 0, NULL, &proc_ioports_operations);
84627 proc_create("iomem", 0, NULL, &proc_iomem_operations);
84628 +#endif
84629 return 0;
84630 }
84631 __initcall(ioresources_init);
84632 diff --git a/kernel/rtmutex-tester.c b/kernel/rtmutex-tester.c
84633 index 1d96dd0..994ff19 100644
84634 --- a/kernel/rtmutex-tester.c
84635 +++ b/kernel/rtmutex-tester.c
84636 @@ -22,7 +22,7 @@
84637 #define MAX_RT_TEST_MUTEXES 8
84638
84639 static spinlock_t rttest_lock;
84640 -static atomic_t rttest_event;
84641 +static atomic_unchecked_t rttest_event;
84642
84643 struct test_thread_data {
84644 int opcode;
84645 @@ -63,7 +63,7 @@ static int handle_op(struct test_thread_data *td, int lockwakeup)
84646
84647 case RTTEST_LOCKCONT:
84648 td->mutexes[td->opdata] = 1;
84649 - td->event = atomic_add_return(1, &rttest_event);
84650 + td->event = atomic_add_return_unchecked(1, &rttest_event);
84651 return 0;
84652
84653 case RTTEST_RESET:
84654 @@ -76,7 +76,7 @@ static int handle_op(struct test_thread_data *td, int lockwakeup)
84655 return 0;
84656
84657 case RTTEST_RESETEVENT:
84658 - atomic_set(&rttest_event, 0);
84659 + atomic_set_unchecked(&rttest_event, 0);
84660 return 0;
84661
84662 default:
84663 @@ -93,9 +93,9 @@ static int handle_op(struct test_thread_data *td, int lockwakeup)
84664 return ret;
84665
84666 td->mutexes[id] = 1;
84667 - td->event = atomic_add_return(1, &rttest_event);
84668 + td->event = atomic_add_return_unchecked(1, &rttest_event);
84669 rt_mutex_lock(&mutexes[id]);
84670 - td->event = atomic_add_return(1, &rttest_event);
84671 + td->event = atomic_add_return_unchecked(1, &rttest_event);
84672 td->mutexes[id] = 4;
84673 return 0;
84674
84675 @@ -106,9 +106,9 @@ static int handle_op(struct test_thread_data *td, int lockwakeup)
84676 return ret;
84677
84678 td->mutexes[id] = 1;
84679 - td->event = atomic_add_return(1, &rttest_event);
84680 + td->event = atomic_add_return_unchecked(1, &rttest_event);
84681 ret = rt_mutex_lock_interruptible(&mutexes[id], 0);
84682 - td->event = atomic_add_return(1, &rttest_event);
84683 + td->event = atomic_add_return_unchecked(1, &rttest_event);
84684 td->mutexes[id] = ret ? 0 : 4;
84685 return ret ? -EINTR : 0;
84686
84687 @@ -117,9 +117,9 @@ static int handle_op(struct test_thread_data *td, int lockwakeup)
84688 if (id < 0 || id >= MAX_RT_TEST_MUTEXES || td->mutexes[id] != 4)
84689 return ret;
84690
84691 - td->event = atomic_add_return(1, &rttest_event);
84692 + td->event = atomic_add_return_unchecked(1, &rttest_event);
84693 rt_mutex_unlock(&mutexes[id]);
84694 - td->event = atomic_add_return(1, &rttest_event);
84695 + td->event = atomic_add_return_unchecked(1, &rttest_event);
84696 td->mutexes[id] = 0;
84697 return 0;
84698
84699 @@ -166,7 +166,7 @@ void schedule_rt_mutex_test(struct rt_mutex *mutex)
84700 break;
84701
84702 td->mutexes[dat] = 2;
84703 - td->event = atomic_add_return(1, &rttest_event);
84704 + td->event = atomic_add_return_unchecked(1, &rttest_event);
84705 break;
84706
84707 default:
84708 @@ -186,7 +186,7 @@ void schedule_rt_mutex_test(struct rt_mutex *mutex)
84709 return;
84710
84711 td->mutexes[dat] = 3;
84712 - td->event = atomic_add_return(1, &rttest_event);
84713 + td->event = atomic_add_return_unchecked(1, &rttest_event);
84714 break;
84715
84716 case RTTEST_LOCKNOWAIT:
84717 @@ -198,7 +198,7 @@ void schedule_rt_mutex_test(struct rt_mutex *mutex)
84718 return;
84719
84720 td->mutexes[dat] = 1;
84721 - td->event = atomic_add_return(1, &rttest_event);
84722 + td->event = atomic_add_return_unchecked(1, &rttest_event);
84723 return;
84724
84725 default:
84726 diff --git a/kernel/sched/auto_group.c b/kernel/sched/auto_group.c
84727 index 4a07353..66b5291 100644
84728 --- a/kernel/sched/auto_group.c
84729 +++ b/kernel/sched/auto_group.c
84730 @@ -11,7 +11,7 @@
84731
84732 unsigned int __read_mostly sysctl_sched_autogroup_enabled = 1;
84733 static struct autogroup autogroup_default;
84734 -static atomic_t autogroup_seq_nr;
84735 +static atomic_unchecked_t autogroup_seq_nr;
84736
84737 void __init autogroup_init(struct task_struct *init_task)
84738 {
84739 @@ -79,7 +79,7 @@ static inline struct autogroup *autogroup_create(void)
84740
84741 kref_init(&ag->kref);
84742 init_rwsem(&ag->lock);
84743 - ag->id = atomic_inc_return(&autogroup_seq_nr);
84744 + ag->id = atomic_inc_return_unchecked(&autogroup_seq_nr);
84745 ag->tg = tg;
84746 #ifdef CONFIG_RT_GROUP_SCHED
84747 /*
84748 diff --git a/kernel/sched/core.c b/kernel/sched/core.c
84749 index 5ac63c9..d912786 100644
84750 --- a/kernel/sched/core.c
84751 +++ b/kernel/sched/core.c
84752 @@ -2868,7 +2868,7 @@ EXPORT_SYMBOL(wait_for_completion_interruptible);
84753 * Return: -ERESTARTSYS if interrupted, 0 if timed out, positive (at least 1,
84754 * or number of jiffies left till timeout) if completed.
84755 */
84756 -long __sched
84757 +long __sched __intentional_overflow(-1)
84758 wait_for_completion_interruptible_timeout(struct completion *x,
84759 unsigned long timeout)
84760 {
84761 @@ -2885,7 +2885,7 @@ EXPORT_SYMBOL(wait_for_completion_interruptible_timeout);
84762 *
84763 * Return: -ERESTARTSYS if interrupted, 0 if completed.
84764 */
84765 -int __sched wait_for_completion_killable(struct completion *x)
84766 +int __sched __intentional_overflow(-1) wait_for_completion_killable(struct completion *x)
84767 {
84768 long t = wait_for_common(x, MAX_SCHEDULE_TIMEOUT, TASK_KILLABLE);
84769 if (t == -ERESTARTSYS)
84770 @@ -2906,7 +2906,7 @@ EXPORT_SYMBOL(wait_for_completion_killable);
84771 * Return: -ERESTARTSYS if interrupted, 0 if timed out, positive (at least 1,
84772 * or number of jiffies left till timeout) if completed.
84773 */
84774 -long __sched
84775 +long __sched __intentional_overflow(-1)
84776 wait_for_completion_killable_timeout(struct completion *x,
84777 unsigned long timeout)
84778 {
84779 @@ -3132,6 +3132,8 @@ int can_nice(const struct task_struct *p, const int nice)
84780 /* convert nice value [19,-20] to rlimit style value [1,40] */
84781 int nice_rlim = 20 - nice;
84782
84783 + gr_learn_resource(p, RLIMIT_NICE, nice_rlim, 1);
84784 +
84785 return (nice_rlim <= task_rlimit(p, RLIMIT_NICE) ||
84786 capable(CAP_SYS_NICE));
84787 }
84788 @@ -3165,7 +3167,8 @@ SYSCALL_DEFINE1(nice, int, increment)
84789 if (nice > 19)
84790 nice = 19;
84791
84792 - if (increment < 0 && !can_nice(current, nice))
84793 + if (increment < 0 && (!can_nice(current, nice) ||
84794 + gr_handle_chroot_nice()))
84795 return -EPERM;
84796
84797 retval = security_task_setnice(current, nice);
84798 @@ -3327,6 +3330,7 @@ recheck:
84799 unsigned long rlim_rtprio =
84800 task_rlimit(p, RLIMIT_RTPRIO);
84801
84802 + gr_learn_resource(p, RLIMIT_RTPRIO, param->sched_priority, 1);
84803 /* can't set/change the rt policy */
84804 if (policy != p->policy && !rlim_rtprio)
84805 return -EPERM;
84806 @@ -4456,7 +4460,7 @@ static void migrate_tasks(unsigned int dead_cpu)
84807
84808 #if defined(CONFIG_SCHED_DEBUG) && defined(CONFIG_SYSCTL)
84809
84810 -static struct ctl_table sd_ctl_dir[] = {
84811 +static ctl_table_no_const sd_ctl_dir[] __read_only = {
84812 {
84813 .procname = "sched_domain",
84814 .mode = 0555,
84815 @@ -4473,17 +4477,17 @@ static struct ctl_table sd_ctl_root[] = {
84816 {}
84817 };
84818
84819 -static struct ctl_table *sd_alloc_ctl_entry(int n)
84820 +static ctl_table_no_const *sd_alloc_ctl_entry(int n)
84821 {
84822 - struct ctl_table *entry =
84823 + ctl_table_no_const *entry =
84824 kcalloc(n, sizeof(struct ctl_table), GFP_KERNEL);
84825
84826 return entry;
84827 }
84828
84829 -static void sd_free_ctl_entry(struct ctl_table **tablep)
84830 +static void sd_free_ctl_entry(ctl_table_no_const *tablep)
84831 {
84832 - struct ctl_table *entry;
84833 + ctl_table_no_const *entry;
84834
84835 /*
84836 * In the intermediate directories, both the child directory and
84837 @@ -4491,22 +4495,25 @@ static void sd_free_ctl_entry(struct ctl_table **tablep)
84838 * will always be set. In the lowest directory the names are
84839 * static strings and all have proc handlers.
84840 */
84841 - for (entry = *tablep; entry->mode; entry++) {
84842 - if (entry->child)
84843 - sd_free_ctl_entry(&entry->child);
84844 + for (entry = tablep; entry->mode; entry++) {
84845 + if (entry->child) {
84846 + sd_free_ctl_entry(entry->child);
84847 + pax_open_kernel();
84848 + entry->child = NULL;
84849 + pax_close_kernel();
84850 + }
84851 if (entry->proc_handler == NULL)
84852 kfree(entry->procname);
84853 }
84854
84855 - kfree(*tablep);
84856 - *tablep = NULL;
84857 + kfree(tablep);
84858 }
84859
84860 static int min_load_idx = 0;
84861 static int max_load_idx = CPU_LOAD_IDX_MAX-1;
84862
84863 static void
84864 -set_table_entry(struct ctl_table *entry,
84865 +set_table_entry(ctl_table_no_const *entry,
84866 const char *procname, void *data, int maxlen,
84867 umode_t mode, proc_handler *proc_handler,
84868 bool load_idx)
84869 @@ -4526,7 +4533,7 @@ set_table_entry(struct ctl_table *entry,
84870 static struct ctl_table *
84871 sd_alloc_ctl_domain_table(struct sched_domain *sd)
84872 {
84873 - struct ctl_table *table = sd_alloc_ctl_entry(13);
84874 + ctl_table_no_const *table = sd_alloc_ctl_entry(13);
84875
84876 if (table == NULL)
84877 return NULL;
84878 @@ -4561,9 +4568,9 @@ sd_alloc_ctl_domain_table(struct sched_domain *sd)
84879 return table;
84880 }
84881
84882 -static struct ctl_table *sd_alloc_ctl_cpu_table(int cpu)
84883 +static ctl_table_no_const *sd_alloc_ctl_cpu_table(int cpu)
84884 {
84885 - struct ctl_table *entry, *table;
84886 + ctl_table_no_const *entry, *table;
84887 struct sched_domain *sd;
84888 int domain_num = 0, i;
84889 char buf[32];
84890 @@ -4590,11 +4597,13 @@ static struct ctl_table_header *sd_sysctl_header;
84891 static void register_sched_domain_sysctl(void)
84892 {
84893 int i, cpu_num = num_possible_cpus();
84894 - struct ctl_table *entry = sd_alloc_ctl_entry(cpu_num + 1);
84895 + ctl_table_no_const *entry = sd_alloc_ctl_entry(cpu_num + 1);
84896 char buf[32];
84897
84898 WARN_ON(sd_ctl_dir[0].child);
84899 + pax_open_kernel();
84900 sd_ctl_dir[0].child = entry;
84901 + pax_close_kernel();
84902
84903 if (entry == NULL)
84904 return;
84905 @@ -4617,8 +4626,12 @@ static void unregister_sched_domain_sysctl(void)
84906 if (sd_sysctl_header)
84907 unregister_sysctl_table(sd_sysctl_header);
84908 sd_sysctl_header = NULL;
84909 - if (sd_ctl_dir[0].child)
84910 - sd_free_ctl_entry(&sd_ctl_dir[0].child);
84911 + if (sd_ctl_dir[0].child) {
84912 + sd_free_ctl_entry(sd_ctl_dir[0].child);
84913 + pax_open_kernel();
84914 + sd_ctl_dir[0].child = NULL;
84915 + pax_close_kernel();
84916 + }
84917 }
84918 #else
84919 static void register_sched_domain_sysctl(void)
84920 diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
84921 index 7c70201..23f52b6 100644
84922 --- a/kernel/sched/fair.c
84923 +++ b/kernel/sched/fair.c
84924 @@ -869,7 +869,7 @@ void task_numa_fault(int node, int pages, bool migrated)
84925
84926 static void reset_ptenuma_scan(struct task_struct *p)
84927 {
84928 - ACCESS_ONCE(p->mm->numa_scan_seq)++;
84929 + ACCESS_ONCE_RW(p->mm->numa_scan_seq)++;
84930 p->mm->numa_scan_offset = 0;
84931 }
84932
84933 @@ -5838,7 +5838,7 @@ static void nohz_idle_balance(int this_cpu, enum cpu_idle_type idle) { }
84934 * run_rebalance_domains is triggered when needed from the scheduler tick.
84935 * Also triggered for nohz idle balancing (with nohz_balancing_kick set).
84936 */
84937 -static void run_rebalance_domains(struct softirq_action *h)
84938 +static __latent_entropy void run_rebalance_domains(void)
84939 {
84940 int this_cpu = smp_processor_id();
84941 struct rq *this_rq = cpu_rq(this_cpu);
84942 diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h
84943 index b3c5653..a4d192a 100644
84944 --- a/kernel/sched/sched.h
84945 +++ b/kernel/sched/sched.h
84946 @@ -1004,7 +1004,7 @@ struct sched_class {
84947 #ifdef CONFIG_FAIR_GROUP_SCHED
84948 void (*task_move_group) (struct task_struct *p, int on_rq);
84949 #endif
84950 -};
84951 +} __do_const;
84952
84953 #define sched_class_highest (&stop_sched_class)
84954 #define for_each_class(class) \
84955 diff --git a/kernel/signal.c b/kernel/signal.c
84956 index ded28b9..6886c08 100644
84957 --- a/kernel/signal.c
84958 +++ b/kernel/signal.c
84959 @@ -51,12 +51,12 @@ static struct kmem_cache *sigqueue_cachep;
84960
84961 int print_fatal_signals __read_mostly;
84962
84963 -static void __user *sig_handler(struct task_struct *t, int sig)
84964 +static __sighandler_t sig_handler(struct task_struct *t, int sig)
84965 {
84966 return t->sighand->action[sig - 1].sa.sa_handler;
84967 }
84968
84969 -static int sig_handler_ignored(void __user *handler, int sig)
84970 +static int sig_handler_ignored(__sighandler_t handler, int sig)
84971 {
84972 /* Is it explicitly or implicitly ignored? */
84973 return handler == SIG_IGN ||
84974 @@ -65,7 +65,7 @@ static int sig_handler_ignored(void __user *handler, int sig)
84975
84976 static int sig_task_ignored(struct task_struct *t, int sig, bool force)
84977 {
84978 - void __user *handler;
84979 + __sighandler_t handler;
84980
84981 handler = sig_handler(t, sig);
84982
84983 @@ -369,6 +369,9 @@ __sigqueue_alloc(int sig, struct task_struct *t, gfp_t flags, int override_rlimi
84984 atomic_inc(&user->sigpending);
84985 rcu_read_unlock();
84986
84987 + if (!override_rlimit)
84988 + gr_learn_resource(t, RLIMIT_SIGPENDING, atomic_read(&user->sigpending), 1);
84989 +
84990 if (override_rlimit ||
84991 atomic_read(&user->sigpending) <=
84992 task_rlimit(t, RLIMIT_SIGPENDING)) {
84993 @@ -496,7 +499,7 @@ flush_signal_handlers(struct task_struct *t, int force_default)
84994
84995 int unhandled_signal(struct task_struct *tsk, int sig)
84996 {
84997 - void __user *handler = tsk->sighand->action[sig-1].sa.sa_handler;
84998 + __sighandler_t handler = tsk->sighand->action[sig-1].sa.sa_handler;
84999 if (is_global_init(tsk))
85000 return 1;
85001 if (handler != SIG_IGN && handler != SIG_DFL)
85002 @@ -816,6 +819,13 @@ static int check_kill_permission(int sig, struct siginfo *info,
85003 }
85004 }
85005
85006 + /* allow glibc communication via tgkill to other threads in our
85007 + thread group */
85008 + if ((info == SEND_SIG_NOINFO || info->si_code != SI_TKILL ||
85009 + sig != (SIGRTMIN+1) || task_tgid_vnr(t) != info->si_pid)
85010 + && gr_handle_signal(t, sig))
85011 + return -EPERM;
85012 +
85013 return security_task_kill(t, info, sig, 0);
85014 }
85015
85016 @@ -1199,7 +1209,7 @@ __group_send_sig_info(int sig, struct siginfo *info, struct task_struct *p)
85017 return send_signal(sig, info, p, 1);
85018 }
85019
85020 -static int
85021 +int
85022 specific_send_sig_info(int sig, struct siginfo *info, struct task_struct *t)
85023 {
85024 return send_signal(sig, info, t, 0);
85025 @@ -1236,6 +1246,7 @@ force_sig_info(int sig, struct siginfo *info, struct task_struct *t)
85026 unsigned long int flags;
85027 int ret, blocked, ignored;
85028 struct k_sigaction *action;
85029 + int is_unhandled = 0;
85030
85031 spin_lock_irqsave(&t->sighand->siglock, flags);
85032 action = &t->sighand->action[sig-1];
85033 @@ -1250,9 +1261,18 @@ force_sig_info(int sig, struct siginfo *info, struct task_struct *t)
85034 }
85035 if (action->sa.sa_handler == SIG_DFL)
85036 t->signal->flags &= ~SIGNAL_UNKILLABLE;
85037 + if (action->sa.sa_handler == SIG_IGN || action->sa.sa_handler == SIG_DFL)
85038 + is_unhandled = 1;
85039 ret = specific_send_sig_info(sig, info, t);
85040 spin_unlock_irqrestore(&t->sighand->siglock, flags);
85041
85042 + /* only deal with unhandled signals, java etc trigger SIGSEGV during
85043 + normal operation */
85044 + if (is_unhandled) {
85045 + gr_log_signal(sig, !is_si_special(info) ? info->si_addr : NULL, t);
85046 + gr_handle_crash(t, sig);
85047 + }
85048 +
85049 return ret;
85050 }
85051
85052 @@ -1319,8 +1339,11 @@ int group_send_sig_info(int sig, struct siginfo *info, struct task_struct *p)
85053 ret = check_kill_permission(sig, info, p);
85054 rcu_read_unlock();
85055
85056 - if (!ret && sig)
85057 + if (!ret && sig) {
85058 ret = do_send_sig_info(sig, info, p, true);
85059 + if (!ret)
85060 + gr_log_signal(sig, !is_si_special(info) ? info->si_addr : NULL, p);
85061 + }
85062
85063 return ret;
85064 }
85065 @@ -2926,7 +2949,15 @@ do_send_specific(pid_t tgid, pid_t pid, int sig, struct siginfo *info)
85066 int error = -ESRCH;
85067
85068 rcu_read_lock();
85069 - p = find_task_by_vpid(pid);
85070 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
85071 + /* allow glibc communication via tgkill to other threads in our
85072 + thread group */
85073 + if (grsec_enable_chroot_findtask && info->si_code == SI_TKILL &&
85074 + sig == (SIGRTMIN+1) && tgid == info->si_pid)
85075 + p = find_task_by_vpid_unrestricted(pid);
85076 + else
85077 +#endif
85078 + p = find_task_by_vpid(pid);
85079 if (p && (tgid <= 0 || task_tgid_vnr(p) == tgid)) {
85080 error = check_kill_permission(sig, info, p);
85081 /*
85082 @@ -3240,8 +3271,8 @@ COMPAT_SYSCALL_DEFINE2(sigaltstack,
85083 }
85084 seg = get_fs();
85085 set_fs(KERNEL_DS);
85086 - ret = do_sigaltstack((stack_t __force __user *) (uss_ptr ? &uss : NULL),
85087 - (stack_t __force __user *) &uoss,
85088 + ret = do_sigaltstack((stack_t __force_user *) (uss_ptr ? &uss : NULL),
85089 + (stack_t __force_user *) &uoss,
85090 compat_user_stack_pointer());
85091 set_fs(seg);
85092 if (ret >= 0 && uoss_ptr) {
85093 diff --git a/kernel/smpboot.c b/kernel/smpboot.c
85094 index eb89e18..a4e6792 100644
85095 --- a/kernel/smpboot.c
85096 +++ b/kernel/smpboot.c
85097 @@ -288,7 +288,7 @@ int smpboot_register_percpu_thread(struct smp_hotplug_thread *plug_thread)
85098 }
85099 smpboot_unpark_thread(plug_thread, cpu);
85100 }
85101 - list_add(&plug_thread->list, &hotplug_threads);
85102 + pax_list_add(&plug_thread->list, &hotplug_threads);
85103 out:
85104 mutex_unlock(&smpboot_threads_lock);
85105 return ret;
85106 @@ -305,7 +305,7 @@ void smpboot_unregister_percpu_thread(struct smp_hotplug_thread *plug_thread)
85107 {
85108 get_online_cpus();
85109 mutex_lock(&smpboot_threads_lock);
85110 - list_del(&plug_thread->list);
85111 + pax_list_del(&plug_thread->list);
85112 smpboot_destroy_threads(plug_thread);
85113 mutex_unlock(&smpboot_threads_lock);
85114 put_online_cpus();
85115 diff --git a/kernel/softirq.c b/kernel/softirq.c
85116 index d7d498d..94fe0f7 100644
85117 --- a/kernel/softirq.c
85118 +++ b/kernel/softirq.c
85119 @@ -53,11 +53,11 @@ irq_cpustat_t irq_stat[NR_CPUS] ____cacheline_aligned;
85120 EXPORT_SYMBOL(irq_stat);
85121 #endif
85122
85123 -static struct softirq_action softirq_vec[NR_SOFTIRQS] __cacheline_aligned_in_smp;
85124 +static struct softirq_action softirq_vec[NR_SOFTIRQS] __read_only __aligned(PAGE_SIZE);
85125
85126 DEFINE_PER_CPU(struct task_struct *, ksoftirqd);
85127
85128 -char *softirq_to_name[NR_SOFTIRQS] = {
85129 +const char * const softirq_to_name[NR_SOFTIRQS] = {
85130 "HI", "TIMER", "NET_TX", "NET_RX", "BLOCK", "BLOCK_IOPOLL",
85131 "TASKLET", "SCHED", "HRTIMER", "RCU"
85132 };
85133 @@ -248,7 +248,7 @@ restart:
85134 kstat_incr_softirqs_this_cpu(vec_nr);
85135
85136 trace_softirq_entry(vec_nr);
85137 - h->action(h);
85138 + h->action();
85139 trace_softirq_exit(vec_nr);
85140 if (unlikely(prev_count != preempt_count())) {
85141 printk(KERN_ERR "huh, entered softirq %u %s %p"
85142 @@ -412,7 +412,7 @@ void __raise_softirq_irqoff(unsigned int nr)
85143 or_softirq_pending(1UL << nr);
85144 }
85145
85146 -void open_softirq(int nr, void (*action)(struct softirq_action *))
85147 +void __init open_softirq(int nr, void (*action)(void))
85148 {
85149 softirq_vec[nr].action = action;
85150 }
85151 @@ -468,7 +468,7 @@ void __tasklet_hi_schedule_first(struct tasklet_struct *t)
85152
85153 EXPORT_SYMBOL(__tasklet_hi_schedule_first);
85154
85155 -static void tasklet_action(struct softirq_action *a)
85156 +static __latent_entropy void tasklet_action(void)
85157 {
85158 struct tasklet_struct *list;
85159
85160 @@ -503,7 +503,7 @@ static void tasklet_action(struct softirq_action *a)
85161 }
85162 }
85163
85164 -static void tasklet_hi_action(struct softirq_action *a)
85165 +static __latent_entropy void tasklet_hi_action(void)
85166 {
85167 struct tasklet_struct *list;
85168
85169 @@ -858,7 +858,7 @@ static struct notifier_block cpu_nfb = {
85170 .notifier_call = cpu_callback
85171 };
85172
85173 -static struct smp_hotplug_thread softirq_threads = {
85174 +static struct smp_hotplug_thread softirq_threads __read_only = {
85175 .store = &ksoftirqd,
85176 .thread_should_run = ksoftirqd_should_run,
85177 .thread_fn = run_ksoftirqd,
85178 diff --git a/kernel/srcu.c b/kernel/srcu.c
85179 index 01d5ccb..cdcbee6 100644
85180 --- a/kernel/srcu.c
85181 +++ b/kernel/srcu.c
85182 @@ -300,9 +300,9 @@ int __srcu_read_lock(struct srcu_struct *sp)
85183
85184 idx = ACCESS_ONCE(sp->completed) & 0x1;
85185 preempt_disable();
85186 - ACCESS_ONCE(this_cpu_ptr(sp->per_cpu_ref)->c[idx]) += 1;
85187 + ACCESS_ONCE_RW(this_cpu_ptr(sp->per_cpu_ref)->c[idx]) += 1;
85188 smp_mb(); /* B */ /* Avoid leaking the critical section. */
85189 - ACCESS_ONCE(this_cpu_ptr(sp->per_cpu_ref)->seq[idx]) += 1;
85190 + ACCESS_ONCE_RW(this_cpu_ptr(sp->per_cpu_ref)->seq[idx]) += 1;
85191 preempt_enable();
85192 return idx;
85193 }
85194 diff --git a/kernel/sys.c b/kernel/sys.c
85195 index c18ecca..b3c2dd2 100644
85196 --- a/kernel/sys.c
85197 +++ b/kernel/sys.c
85198 @@ -149,6 +149,12 @@ static int set_one_prio(struct task_struct *p, int niceval, int error)
85199 error = -EACCES;
85200 goto out;
85201 }
85202 +
85203 + if (gr_handle_chroot_setpriority(p, niceval)) {
85204 + error = -EACCES;
85205 + goto out;
85206 + }
85207 +
85208 no_nice = security_task_setnice(p, niceval);
85209 if (no_nice) {
85210 error = no_nice;
85211 @@ -352,6 +358,9 @@ SYSCALL_DEFINE2(setregid, gid_t, rgid, gid_t, egid)
85212 goto error;
85213 }
85214
85215 + if (gr_check_group_change(new->gid, new->egid, INVALID_GID))
85216 + goto error;
85217 +
85218 if (rgid != (gid_t) -1 ||
85219 (egid != (gid_t) -1 && !gid_eq(kegid, old->gid)))
85220 new->sgid = new->egid;
85221 @@ -387,6 +396,10 @@ SYSCALL_DEFINE1(setgid, gid_t, gid)
85222 old = current_cred();
85223
85224 retval = -EPERM;
85225 +
85226 + if (gr_check_group_change(kgid, kgid, kgid))
85227 + goto error;
85228 +
85229 if (ns_capable(old->user_ns, CAP_SETGID))
85230 new->gid = new->egid = new->sgid = new->fsgid = kgid;
85231 else if (gid_eq(kgid, old->gid) || gid_eq(kgid, old->sgid))
85232 @@ -404,7 +417,7 @@ error:
85233 /*
85234 * change the user struct in a credentials set to match the new UID
85235 */
85236 -static int set_user(struct cred *new)
85237 +int set_user(struct cred *new)
85238 {
85239 struct user_struct *new_user;
85240
85241 @@ -484,6 +497,9 @@ SYSCALL_DEFINE2(setreuid, uid_t, ruid, uid_t, euid)
85242 goto error;
85243 }
85244
85245 + if (gr_check_user_change(new->uid, new->euid, INVALID_UID))
85246 + goto error;
85247 +
85248 if (!uid_eq(new->uid, old->uid)) {
85249 retval = set_user(new);
85250 if (retval < 0)
85251 @@ -534,6 +550,12 @@ SYSCALL_DEFINE1(setuid, uid_t, uid)
85252 old = current_cred();
85253
85254 retval = -EPERM;
85255 +
85256 + if (gr_check_crash_uid(kuid))
85257 + goto error;
85258 + if (gr_check_user_change(kuid, kuid, kuid))
85259 + goto error;
85260 +
85261 if (ns_capable(old->user_ns, CAP_SETUID)) {
85262 new->suid = new->uid = kuid;
85263 if (!uid_eq(kuid, old->uid)) {
85264 @@ -603,6 +625,9 @@ SYSCALL_DEFINE3(setresuid, uid_t, ruid, uid_t, euid, uid_t, suid)
85265 goto error;
85266 }
85267
85268 + if (gr_check_user_change(kruid, keuid, INVALID_UID))
85269 + goto error;
85270 +
85271 if (ruid != (uid_t) -1) {
85272 new->uid = kruid;
85273 if (!uid_eq(kruid, old->uid)) {
85274 @@ -685,6 +710,9 @@ SYSCALL_DEFINE3(setresgid, gid_t, rgid, gid_t, egid, gid_t, sgid)
85275 goto error;
85276 }
85277
85278 + if (gr_check_group_change(krgid, kegid, INVALID_GID))
85279 + goto error;
85280 +
85281 if (rgid != (gid_t) -1)
85282 new->gid = krgid;
85283 if (egid != (gid_t) -1)
85284 @@ -746,12 +774,16 @@ SYSCALL_DEFINE1(setfsuid, uid_t, uid)
85285 uid_eq(kuid, old->suid) || uid_eq(kuid, old->fsuid) ||
85286 ns_capable(old->user_ns, CAP_SETUID)) {
85287 if (!uid_eq(kuid, old->fsuid)) {
85288 + if (gr_check_user_change(INVALID_UID, INVALID_UID, kuid))
85289 + goto error;
85290 +
85291 new->fsuid = kuid;
85292 if (security_task_fix_setuid(new, old, LSM_SETID_FS) == 0)
85293 goto change_okay;
85294 }
85295 }
85296
85297 +error:
85298 abort_creds(new);
85299 return old_fsuid;
85300
85301 @@ -784,12 +816,16 @@ SYSCALL_DEFINE1(setfsgid, gid_t, gid)
85302 if (gid_eq(kgid, old->gid) || gid_eq(kgid, old->egid) ||
85303 gid_eq(kgid, old->sgid) || gid_eq(kgid, old->fsgid) ||
85304 ns_capable(old->user_ns, CAP_SETGID)) {
85305 + if (gr_check_group_change(INVALID_GID, INVALID_GID, kgid))
85306 + goto error;
85307 +
85308 if (!gid_eq(kgid, old->fsgid)) {
85309 new->fsgid = kgid;
85310 goto change_okay;
85311 }
85312 }
85313
85314 +error:
85315 abort_creds(new);
85316 return old_fsgid;
85317
85318 @@ -1169,19 +1205,19 @@ SYSCALL_DEFINE1(olduname, struct oldold_utsname __user *, name)
85319 return -EFAULT;
85320
85321 down_read(&uts_sem);
85322 - error = __copy_to_user(&name->sysname, &utsname()->sysname,
85323 + error = __copy_to_user(name->sysname, &utsname()->sysname,
85324 __OLD_UTS_LEN);
85325 error |= __put_user(0, name->sysname + __OLD_UTS_LEN);
85326 - error |= __copy_to_user(&name->nodename, &utsname()->nodename,
85327 + error |= __copy_to_user(name->nodename, &utsname()->nodename,
85328 __OLD_UTS_LEN);
85329 error |= __put_user(0, name->nodename + __OLD_UTS_LEN);
85330 - error |= __copy_to_user(&name->release, &utsname()->release,
85331 + error |= __copy_to_user(name->release, &utsname()->release,
85332 __OLD_UTS_LEN);
85333 error |= __put_user(0, name->release + __OLD_UTS_LEN);
85334 - error |= __copy_to_user(&name->version, &utsname()->version,
85335 + error |= __copy_to_user(name->version, &utsname()->version,
85336 __OLD_UTS_LEN);
85337 error |= __put_user(0, name->version + __OLD_UTS_LEN);
85338 - error |= __copy_to_user(&name->machine, &utsname()->machine,
85339 + error |= __copy_to_user(name->machine, &utsname()->machine,
85340 __OLD_UTS_LEN);
85341 error |= __put_user(0, name->machine + __OLD_UTS_LEN);
85342 up_read(&uts_sem);
85343 @@ -1383,6 +1419,13 @@ int do_prlimit(struct task_struct *tsk, unsigned int resource,
85344 */
85345 new_rlim->rlim_cur = 1;
85346 }
85347 + /* Handle the case where a fork and setuid occur and then RLIMIT_NPROC
85348 + is changed to a lower value. Since tasks can be created by the same
85349 + user in between this limit change and an execve by this task, force
85350 + a recheck only for this task by setting PF_NPROC_EXCEEDED
85351 + */
85352 + if (resource == RLIMIT_NPROC && tsk->real_cred->user != INIT_USER)
85353 + tsk->flags |= PF_NPROC_EXCEEDED;
85354 }
85355 if (!retval) {
85356 if (old_rlim)
85357 diff --git a/kernel/sysctl.c b/kernel/sysctl.c
85358 index b2f06f3..e6354ab 100644
85359 --- a/kernel/sysctl.c
85360 +++ b/kernel/sysctl.c
85361 @@ -93,7 +93,6 @@
85362
85363
85364 #if defined(CONFIG_SYSCTL)
85365 -
85366 /* External variables not in a header file. */
85367 extern int sysctl_overcommit_memory;
85368 extern int sysctl_overcommit_ratio;
85369 @@ -119,17 +118,18 @@ extern int blk_iopoll_enabled;
85370
85371 /* Constants used for minimum and maximum */
85372 #ifdef CONFIG_LOCKUP_DETECTOR
85373 -static int sixty = 60;
85374 +static int sixty __read_only = 60;
85375 #endif
85376
85377 -static int zero;
85378 -static int __maybe_unused one = 1;
85379 -static int __maybe_unused two = 2;
85380 -static int __maybe_unused three = 3;
85381 -static unsigned long one_ul = 1;
85382 -static int one_hundred = 100;
85383 +static int neg_one __read_only = -1;
85384 +static int zero __read_only = 0;
85385 +static int __maybe_unused one __read_only = 1;
85386 +static int __maybe_unused two __read_only = 2;
85387 +static int __maybe_unused three __read_only = 3;
85388 +static unsigned long one_ul __read_only = 1;
85389 +static int one_hundred __read_only = 100;
85390 #ifdef CONFIG_PRINTK
85391 -static int ten_thousand = 10000;
85392 +static int ten_thousand __read_only = 10000;
85393 #endif
85394
85395 /* this is needed for the proc_doulongvec_minmax of vm_dirty_bytes */
85396 @@ -176,10 +176,8 @@ static int proc_taint(struct ctl_table *table, int write,
85397 void __user *buffer, size_t *lenp, loff_t *ppos);
85398 #endif
85399
85400 -#ifdef CONFIG_PRINTK
85401 static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write,
85402 void __user *buffer, size_t *lenp, loff_t *ppos);
85403 -#endif
85404
85405 static int proc_dointvec_minmax_coredump(struct ctl_table *table, int write,
85406 void __user *buffer, size_t *lenp, loff_t *ppos);
85407 @@ -210,6 +208,8 @@ static int sysrq_sysctl_handler(ctl_table *table, int write,
85408
85409 #endif
85410
85411 +extern struct ctl_table grsecurity_table[];
85412 +
85413 static struct ctl_table kern_table[];
85414 static struct ctl_table vm_table[];
85415 static struct ctl_table fs_table[];
85416 @@ -224,6 +224,20 @@ extern struct ctl_table epoll_table[];
85417 int sysctl_legacy_va_layout;
85418 #endif
85419
85420 +#ifdef CONFIG_PAX_SOFTMODE
85421 +static ctl_table pax_table[] = {
85422 + {
85423 + .procname = "softmode",
85424 + .data = &pax_softmode,
85425 + .maxlen = sizeof(unsigned int),
85426 + .mode = 0600,
85427 + .proc_handler = &proc_dointvec,
85428 + },
85429 +
85430 + { }
85431 +};
85432 +#endif
85433 +
85434 /* The default sysctl tables: */
85435
85436 static struct ctl_table sysctl_base_table[] = {
85437 @@ -272,6 +286,22 @@ static int max_extfrag_threshold = 1000;
85438 #endif
85439
85440 static struct ctl_table kern_table[] = {
85441 +#if defined(CONFIG_GRKERNSEC_SYSCTL) || defined(CONFIG_GRKERNSEC_ROFS)
85442 + {
85443 + .procname = "grsecurity",
85444 + .mode = 0500,
85445 + .child = grsecurity_table,
85446 + },
85447 +#endif
85448 +
85449 +#ifdef CONFIG_PAX_SOFTMODE
85450 + {
85451 + .procname = "pax",
85452 + .mode = 0500,
85453 + .child = pax_table,
85454 + },
85455 +#endif
85456 +
85457 {
85458 .procname = "sched_child_runs_first",
85459 .data = &sysctl_sched_child_runs_first,
85460 @@ -613,7 +643,7 @@ static struct ctl_table kern_table[] = {
85461 .data = &modprobe_path,
85462 .maxlen = KMOD_PATH_LEN,
85463 .mode = 0644,
85464 - .proc_handler = proc_dostring,
85465 + .proc_handler = proc_dostring_modpriv,
85466 },
85467 {
85468 .procname = "modules_disabled",
85469 @@ -780,16 +810,20 @@ static struct ctl_table kern_table[] = {
85470 .extra1 = &zero,
85471 .extra2 = &one,
85472 },
85473 +#endif
85474 {
85475 .procname = "kptr_restrict",
85476 .data = &kptr_restrict,
85477 .maxlen = sizeof(int),
85478 .mode = 0644,
85479 .proc_handler = proc_dointvec_minmax_sysadmin,
85480 +#ifdef CONFIG_GRKERNSEC_HIDESYM
85481 + .extra1 = &two,
85482 +#else
85483 .extra1 = &zero,
85484 +#endif
85485 .extra2 = &two,
85486 },
85487 -#endif
85488 {
85489 .procname = "ngroups_max",
85490 .data = &ngroups_max,
85491 @@ -1031,10 +1065,17 @@ static struct ctl_table kern_table[] = {
85492 */
85493 {
85494 .procname = "perf_event_paranoid",
85495 - .data = &sysctl_perf_event_paranoid,
85496 - .maxlen = sizeof(sysctl_perf_event_paranoid),
85497 + .data = &sysctl_perf_event_legitimately_concerned,
85498 + .maxlen = sizeof(sysctl_perf_event_legitimately_concerned),
85499 .mode = 0644,
85500 - .proc_handler = proc_dointvec,
85501 + /* go ahead, be a hero */
85502 + .proc_handler = proc_dointvec_minmax_sysadmin,
85503 + .extra1 = &neg_one,
85504 +#ifdef CONFIG_GRKERNSEC_PERF_HARDEN
85505 + .extra2 = &three,
85506 +#else
85507 + .extra2 = &two,
85508 +#endif
85509 },
85510 {
85511 .procname = "perf_event_mlock_kb",
85512 @@ -1297,6 +1338,13 @@ static struct ctl_table vm_table[] = {
85513 .proc_handler = proc_dointvec_minmax,
85514 .extra1 = &zero,
85515 },
85516 + {
85517 + .procname = "heap_stack_gap",
85518 + .data = &sysctl_heap_stack_gap,
85519 + .maxlen = sizeof(sysctl_heap_stack_gap),
85520 + .mode = 0644,
85521 + .proc_handler = proc_doulongvec_minmax,
85522 + },
85523 #else
85524 {
85525 .procname = "nr_trim_pages",
85526 @@ -1761,6 +1809,16 @@ int proc_dostring(struct ctl_table *table, int write,
85527 buffer, lenp, ppos);
85528 }
85529
85530 +int proc_dostring_modpriv(struct ctl_table *table, int write,
85531 + void __user *buffer, size_t *lenp, loff_t *ppos)
85532 +{
85533 + if (write && !capable(CAP_SYS_MODULE))
85534 + return -EPERM;
85535 +
85536 + return _proc_do_string(table->data, table->maxlen, write,
85537 + buffer, lenp, ppos);
85538 +}
85539 +
85540 static size_t proc_skip_spaces(char **buf)
85541 {
85542 size_t ret;
85543 @@ -1866,6 +1924,8 @@ static int proc_put_long(void __user **buf, size_t *size, unsigned long val,
85544 len = strlen(tmp);
85545 if (len > *size)
85546 len = *size;
85547 + if (len > sizeof(tmp))
85548 + len = sizeof(tmp);
85549 if (copy_to_user(*buf, tmp, len))
85550 return -EFAULT;
85551 *size -= len;
85552 @@ -2030,7 +2090,7 @@ int proc_dointvec(struct ctl_table *table, int write,
85553 static int proc_taint(struct ctl_table *table, int write,
85554 void __user *buffer, size_t *lenp, loff_t *ppos)
85555 {
85556 - struct ctl_table t;
85557 + ctl_table_no_const t;
85558 unsigned long tmptaint = get_taint();
85559 int err;
85560
85561 @@ -2058,7 +2118,6 @@ static int proc_taint(struct ctl_table *table, int write,
85562 return err;
85563 }
85564
85565 -#ifdef CONFIG_PRINTK
85566 static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write,
85567 void __user *buffer, size_t *lenp, loff_t *ppos)
85568 {
85569 @@ -2067,7 +2126,6 @@ static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write,
85570
85571 return proc_dointvec_minmax(table, write, buffer, lenp, ppos);
85572 }
85573 -#endif
85574
85575 struct do_proc_dointvec_minmax_conv_param {
85576 int *min;
85577 @@ -2214,8 +2272,11 @@ static int __do_proc_doulongvec_minmax(void *data, struct ctl_table *table, int
85578 *i = val;
85579 } else {
85580 val = convdiv * (*i) / convmul;
85581 - if (!first)
85582 + if (!first) {
85583 err = proc_put_char(&buffer, &left, '\t');
85584 + if (err)
85585 + break;
85586 + }
85587 err = proc_put_long(&buffer, &left, val, false);
85588 if (err)
85589 break;
85590 @@ -2611,6 +2672,12 @@ int proc_dostring(struct ctl_table *table, int write,
85591 return -ENOSYS;
85592 }
85593
85594 +int proc_dostring_modpriv(struct ctl_table *table, int write,
85595 + void __user *buffer, size_t *lenp, loff_t *ppos)
85596 +{
85597 + return -ENOSYS;
85598 +}
85599 +
85600 int proc_dointvec(struct ctl_table *table, int write,
85601 void __user *buffer, size_t *lenp, loff_t *ppos)
85602 {
85603 @@ -2667,5 +2734,6 @@ EXPORT_SYMBOL(proc_dointvec_minmax);
85604 EXPORT_SYMBOL(proc_dointvec_userhz_jiffies);
85605 EXPORT_SYMBOL(proc_dointvec_ms_jiffies);
85606 EXPORT_SYMBOL(proc_dostring);
85607 +EXPORT_SYMBOL(proc_dostring_modpriv);
85608 EXPORT_SYMBOL(proc_doulongvec_minmax);
85609 EXPORT_SYMBOL(proc_doulongvec_ms_jiffies_minmax);
85610 diff --git a/kernel/taskstats.c b/kernel/taskstats.c
85611 index 145bb4d..b2aa969 100644
85612 --- a/kernel/taskstats.c
85613 +++ b/kernel/taskstats.c
85614 @@ -28,9 +28,12 @@
85615 #include <linux/fs.h>
85616 #include <linux/file.h>
85617 #include <linux/pid_namespace.h>
85618 +#include <linux/grsecurity.h>
85619 #include <net/genetlink.h>
85620 #include <linux/atomic.h>
85621
85622 +extern int gr_is_taskstats_denied(int pid);
85623 +
85624 /*
85625 * Maximum length of a cpumask that can be specified in
85626 * the TASKSTATS_CMD_ATTR_REGISTER/DEREGISTER_CPUMASK attribute
85627 @@ -570,6 +573,9 @@ err:
85628
85629 static int taskstats_user_cmd(struct sk_buff *skb, struct genl_info *info)
85630 {
85631 + if (gr_is_taskstats_denied(current->pid))
85632 + return -EACCES;
85633 +
85634 if (info->attrs[TASKSTATS_CMD_ATTR_REGISTER_CPUMASK])
85635 return cmd_attr_register_cpumask(info);
85636 else if (info->attrs[TASKSTATS_CMD_ATTR_DEREGISTER_CPUMASK])
85637 diff --git a/kernel/time.c b/kernel/time.c
85638 index 7c7964c..2a0d412 100644
85639 --- a/kernel/time.c
85640 +++ b/kernel/time.c
85641 @@ -172,6 +172,11 @@ int do_sys_settimeofday(const struct timespec *tv, const struct timezone *tz)
85642 return error;
85643
85644 if (tz) {
85645 + /* we log in do_settimeofday called below, so don't log twice
85646 + */
85647 + if (!tv)
85648 + gr_log_timechange();
85649 +
85650 sys_tz = *tz;
85651 update_vsyscall_tz();
85652 if (firsttime) {
85653 diff --git a/kernel/time/alarmtimer.c b/kernel/time/alarmtimer.c
85654 index 88c9c65..7497ebc 100644
85655 --- a/kernel/time/alarmtimer.c
85656 +++ b/kernel/time/alarmtimer.c
85657 @@ -795,7 +795,7 @@ static int __init alarmtimer_init(void)
85658 struct platform_device *pdev;
85659 int error = 0;
85660 int i;
85661 - struct k_clock alarm_clock = {
85662 + static struct k_clock alarm_clock = {
85663 .clock_getres = alarm_clock_getres,
85664 .clock_get = alarm_clock_get,
85665 .timer_create = alarm_timer_create,
85666 diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c
85667 index 947ba25..20cbade 100644
85668 --- a/kernel/time/timekeeping.c
85669 +++ b/kernel/time/timekeeping.c
85670 @@ -15,6 +15,7 @@
85671 #include <linux/init.h>
85672 #include <linux/mm.h>
85673 #include <linux/sched.h>
85674 +#include <linux/grsecurity.h>
85675 #include <linux/syscore_ops.h>
85676 #include <linux/clocksource.h>
85677 #include <linux/jiffies.h>
85678 @@ -500,6 +501,8 @@ int do_settimeofday(const struct timespec *tv)
85679 if (!timespec_valid_strict(tv))
85680 return -EINVAL;
85681
85682 + gr_log_timechange();
85683 +
85684 raw_spin_lock_irqsave(&timekeeper_lock, flags);
85685 write_seqcount_begin(&timekeeper_seq);
85686
85687 diff --git a/kernel/time/timer_list.c b/kernel/time/timer_list.c
85688 index 61ed862..3b52c65 100644
85689 --- a/kernel/time/timer_list.c
85690 +++ b/kernel/time/timer_list.c
85691 @@ -45,12 +45,16 @@ DECLARE_PER_CPU(struct hrtimer_cpu_base, hrtimer_bases);
85692
85693 static void print_name_offset(struct seq_file *m, void *sym)
85694 {
85695 +#ifdef CONFIG_GRKERNSEC_HIDESYM
85696 + SEQ_printf(m, "<%p>", NULL);
85697 +#else
85698 char symname[KSYM_NAME_LEN];
85699
85700 if (lookup_symbol_name((unsigned long)sym, symname) < 0)
85701 SEQ_printf(m, "<%pK>", sym);
85702 else
85703 SEQ_printf(m, "%s", symname);
85704 +#endif
85705 }
85706
85707 static void
85708 @@ -119,7 +123,11 @@ next_one:
85709 static void
85710 print_base(struct seq_file *m, struct hrtimer_clock_base *base, u64 now)
85711 {
85712 +#ifdef CONFIG_GRKERNSEC_HIDESYM
85713 + SEQ_printf(m, " .base: %p\n", NULL);
85714 +#else
85715 SEQ_printf(m, " .base: %pK\n", base);
85716 +#endif
85717 SEQ_printf(m, " .index: %d\n",
85718 base->index);
85719 SEQ_printf(m, " .resolution: %Lu nsecs\n",
85720 @@ -362,7 +370,11 @@ static int __init init_timer_list_procfs(void)
85721 {
85722 struct proc_dir_entry *pe;
85723
85724 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
85725 + pe = proc_create("timer_list", 0400, NULL, &timer_list_fops);
85726 +#else
85727 pe = proc_create("timer_list", 0444, NULL, &timer_list_fops);
85728 +#endif
85729 if (!pe)
85730 return -ENOMEM;
85731 return 0;
85732 diff --git a/kernel/time/timer_stats.c b/kernel/time/timer_stats.c
85733 index 0b537f2..40d6c20 100644
85734 --- a/kernel/time/timer_stats.c
85735 +++ b/kernel/time/timer_stats.c
85736 @@ -116,7 +116,7 @@ static ktime_t time_start, time_stop;
85737 static unsigned long nr_entries;
85738 static struct entry entries[MAX_ENTRIES];
85739
85740 -static atomic_t overflow_count;
85741 +static atomic_unchecked_t overflow_count;
85742
85743 /*
85744 * The entries are in a hash-table, for fast lookup:
85745 @@ -140,7 +140,7 @@ static void reset_entries(void)
85746 nr_entries = 0;
85747 memset(entries, 0, sizeof(entries));
85748 memset(tstat_hash_table, 0, sizeof(tstat_hash_table));
85749 - atomic_set(&overflow_count, 0);
85750 + atomic_set_unchecked(&overflow_count, 0);
85751 }
85752
85753 static struct entry *alloc_entry(void)
85754 @@ -261,7 +261,7 @@ void timer_stats_update_stats(void *timer, pid_t pid, void *startf,
85755 if (likely(entry))
85756 entry->count++;
85757 else
85758 - atomic_inc(&overflow_count);
85759 + atomic_inc_unchecked(&overflow_count);
85760
85761 out_unlock:
85762 raw_spin_unlock_irqrestore(lock, flags);
85763 @@ -269,12 +269,16 @@ void timer_stats_update_stats(void *timer, pid_t pid, void *startf,
85764
85765 static void print_name_offset(struct seq_file *m, unsigned long addr)
85766 {
85767 +#ifdef CONFIG_GRKERNSEC_HIDESYM
85768 + seq_printf(m, "<%p>", NULL);
85769 +#else
85770 char symname[KSYM_NAME_LEN];
85771
85772 if (lookup_symbol_name(addr, symname) < 0)
85773 - seq_printf(m, "<%p>", (void *)addr);
85774 + seq_printf(m, "<%pK>", (void *)addr);
85775 else
85776 seq_printf(m, "%s", symname);
85777 +#endif
85778 }
85779
85780 static int tstats_show(struct seq_file *m, void *v)
85781 @@ -300,9 +304,9 @@ static int tstats_show(struct seq_file *m, void *v)
85782
85783 seq_puts(m, "Timer Stats Version: v0.2\n");
85784 seq_printf(m, "Sample period: %ld.%03ld s\n", period.tv_sec, ms);
85785 - if (atomic_read(&overflow_count))
85786 + if (atomic_read_unchecked(&overflow_count))
85787 seq_printf(m, "Overflow: %d entries\n",
85788 - atomic_read(&overflow_count));
85789 + atomic_read_unchecked(&overflow_count));
85790
85791 for (i = 0; i < nr_entries; i++) {
85792 entry = entries + i;
85793 @@ -417,7 +421,11 @@ static int __init init_tstats_procfs(void)
85794 {
85795 struct proc_dir_entry *pe;
85796
85797 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
85798 + pe = proc_create("timer_stats", 0600, NULL, &tstats_fops);
85799 +#else
85800 pe = proc_create("timer_stats", 0644, NULL, &tstats_fops);
85801 +#endif
85802 if (!pe)
85803 return -ENOMEM;
85804 return 0;
85805 diff --git a/kernel/timer.c b/kernel/timer.c
85806 index 4296d13..0164b04 100644
85807 --- a/kernel/timer.c
85808 +++ b/kernel/timer.c
85809 @@ -1366,7 +1366,7 @@ void update_process_times(int user_tick)
85810 /*
85811 * This function runs timers and the timer-tq in bottom half context.
85812 */
85813 -static void run_timer_softirq(struct softirq_action *h)
85814 +static __latent_entropy void run_timer_softirq(void)
85815 {
85816 struct tvec_base *base = __this_cpu_read(tvec_bases);
85817
85818 @@ -1429,7 +1429,7 @@ static void process_timeout(unsigned long __data)
85819 *
85820 * In all cases the return value is guaranteed to be non-negative.
85821 */
85822 -signed long __sched schedule_timeout(signed long timeout)
85823 +signed long __sched __intentional_overflow(-1) schedule_timeout(signed long timeout)
85824 {
85825 struct timer_list timer;
85826 unsigned long expire;
85827 diff --git a/kernel/trace/blktrace.c b/kernel/trace/blktrace.c
85828 index b8b8560..75b1a09 100644
85829 --- a/kernel/trace/blktrace.c
85830 +++ b/kernel/trace/blktrace.c
85831 @@ -317,7 +317,7 @@ static ssize_t blk_dropped_read(struct file *filp, char __user *buffer,
85832 struct blk_trace *bt = filp->private_data;
85833 char buf[16];
85834
85835 - snprintf(buf, sizeof(buf), "%u\n", atomic_read(&bt->dropped));
85836 + snprintf(buf, sizeof(buf), "%u\n", atomic_read_unchecked(&bt->dropped));
85837
85838 return simple_read_from_buffer(buffer, count, ppos, buf, strlen(buf));
85839 }
85840 @@ -375,7 +375,7 @@ static int blk_subbuf_start_callback(struct rchan_buf *buf, void *subbuf,
85841 return 1;
85842
85843 bt = buf->chan->private_data;
85844 - atomic_inc(&bt->dropped);
85845 + atomic_inc_unchecked(&bt->dropped);
85846 return 0;
85847 }
85848
85849 @@ -476,7 +476,7 @@ int do_blk_trace_setup(struct request_queue *q, char *name, dev_t dev,
85850
85851 bt->dir = dir;
85852 bt->dev = dev;
85853 - atomic_set(&bt->dropped, 0);
85854 + atomic_set_unchecked(&bt->dropped, 0);
85855
85856 ret = -EIO;
85857 bt->dropped_file = debugfs_create_file("dropped", 0444, dir, bt,
85858 diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
85859 index f3bd09ee..9bb9586 100644
85860 --- a/kernel/trace/ftrace.c
85861 +++ b/kernel/trace/ftrace.c
85862 @@ -1944,12 +1944,17 @@ ftrace_code_disable(struct module *mod, struct dyn_ftrace *rec)
85863 if (unlikely(ftrace_disabled))
85864 return 0;
85865
85866 + ret = ftrace_arch_code_modify_prepare();
85867 + FTRACE_WARN_ON(ret);
85868 + if (ret)
85869 + return 0;
85870 +
85871 ret = ftrace_make_nop(mod, rec, MCOUNT_ADDR);
85872 + FTRACE_WARN_ON(ftrace_arch_code_modify_post_process());
85873 if (ret) {
85874 ftrace_bug(ret, ip);
85875 - return 0;
85876 }
85877 - return 1;
85878 + return ret ? 0 : 1;
85879 }
85880
85881 /*
85882 @@ -4043,8 +4048,10 @@ static int ftrace_process_locs(struct module *mod,
85883 if (!count)
85884 return 0;
85885
85886 + pax_open_kernel();
85887 sort(start, count, sizeof(*start),
85888 ftrace_cmp_ips, ftrace_swap_ips);
85889 + pax_close_kernel();
85890
85891 start_pg = ftrace_allocate_pages(count);
85892 if (!start_pg)
85893 @@ -4766,8 +4773,6 @@ ftrace_enable_sysctl(struct ctl_table *table, int write,
85894 #ifdef CONFIG_FUNCTION_GRAPH_TRACER
85895
85896 static int ftrace_graph_active;
85897 -static struct notifier_block ftrace_suspend_notifier;
85898 -
85899 int ftrace_graph_entry_stub(struct ftrace_graph_ent *trace)
85900 {
85901 return 0;
85902 @@ -4918,6 +4923,10 @@ static struct ftrace_ops fgraph_ops __read_mostly = {
85903 FTRACE_OPS_FL_RECURSION_SAFE,
85904 };
85905
85906 +static struct notifier_block ftrace_suspend_notifier = {
85907 + .notifier_call = ftrace_suspend_notifier_call
85908 +};
85909 +
85910 int register_ftrace_graph(trace_func_graph_ret_t retfunc,
85911 trace_func_graph_ent_t entryfunc)
85912 {
85913 @@ -4931,7 +4940,6 @@ int register_ftrace_graph(trace_func_graph_ret_t retfunc,
85914 goto out;
85915 }
85916
85917 - ftrace_suspend_notifier.notifier_call = ftrace_suspend_notifier_call;
85918 register_pm_notifier(&ftrace_suspend_notifier);
85919
85920 ftrace_graph_active++;
85921 diff --git a/kernel/trace/ring_buffer.c b/kernel/trace/ring_buffer.c
85922 index cc2f66f..05edd54 100644
85923 --- a/kernel/trace/ring_buffer.c
85924 +++ b/kernel/trace/ring_buffer.c
85925 @@ -352,9 +352,9 @@ struct buffer_data_page {
85926 */
85927 struct buffer_page {
85928 struct list_head list; /* list of buffer pages */
85929 - local_t write; /* index for next write */
85930 + local_unchecked_t write; /* index for next write */
85931 unsigned read; /* index for next read */
85932 - local_t entries; /* entries on this page */
85933 + local_unchecked_t entries; /* entries on this page */
85934 unsigned long real_end; /* real end of data */
85935 struct buffer_data_page *page; /* Actual data page */
85936 };
85937 @@ -473,8 +473,8 @@ struct ring_buffer_per_cpu {
85938 unsigned long last_overrun;
85939 local_t entries_bytes;
85940 local_t entries;
85941 - local_t overrun;
85942 - local_t commit_overrun;
85943 + local_unchecked_t overrun;
85944 + local_unchecked_t commit_overrun;
85945 local_t dropped_events;
85946 local_t committing;
85947 local_t commits;
85948 @@ -992,8 +992,8 @@ static int rb_tail_page_update(struct ring_buffer_per_cpu *cpu_buffer,
85949 *
85950 * We add a counter to the write field to denote this.
85951 */
85952 - old_write = local_add_return(RB_WRITE_INTCNT, &next_page->write);
85953 - old_entries = local_add_return(RB_WRITE_INTCNT, &next_page->entries);
85954 + old_write = local_add_return_unchecked(RB_WRITE_INTCNT, &next_page->write);
85955 + old_entries = local_add_return_unchecked(RB_WRITE_INTCNT, &next_page->entries);
85956
85957 /*
85958 * Just make sure we have seen our old_write and synchronize
85959 @@ -1021,8 +1021,8 @@ static int rb_tail_page_update(struct ring_buffer_per_cpu *cpu_buffer,
85960 * cmpxchg to only update if an interrupt did not already
85961 * do it for us. If the cmpxchg fails, we don't care.
85962 */
85963 - (void)local_cmpxchg(&next_page->write, old_write, val);
85964 - (void)local_cmpxchg(&next_page->entries, old_entries, eval);
85965 + (void)local_cmpxchg_unchecked(&next_page->write, old_write, val);
85966 + (void)local_cmpxchg_unchecked(&next_page->entries, old_entries, eval);
85967
85968 /*
85969 * No need to worry about races with clearing out the commit.
85970 @@ -1386,12 +1386,12 @@ static void rb_reset_cpu(struct ring_buffer_per_cpu *cpu_buffer);
85971
85972 static inline unsigned long rb_page_entries(struct buffer_page *bpage)
85973 {
85974 - return local_read(&bpage->entries) & RB_WRITE_MASK;
85975 + return local_read_unchecked(&bpage->entries) & RB_WRITE_MASK;
85976 }
85977
85978 static inline unsigned long rb_page_write(struct buffer_page *bpage)
85979 {
85980 - return local_read(&bpage->write) & RB_WRITE_MASK;
85981 + return local_read_unchecked(&bpage->write) & RB_WRITE_MASK;
85982 }
85983
85984 static int
85985 @@ -1486,7 +1486,7 @@ rb_remove_pages(struct ring_buffer_per_cpu *cpu_buffer, unsigned int nr_pages)
85986 * bytes consumed in ring buffer from here.
85987 * Increment overrun to account for the lost events.
85988 */
85989 - local_add(page_entries, &cpu_buffer->overrun);
85990 + local_add_unchecked(page_entries, &cpu_buffer->overrun);
85991 local_sub(BUF_PAGE_SIZE, &cpu_buffer->entries_bytes);
85992 }
85993
85994 @@ -2064,7 +2064,7 @@ rb_handle_head_page(struct ring_buffer_per_cpu *cpu_buffer,
85995 * it is our responsibility to update
85996 * the counters.
85997 */
85998 - local_add(entries, &cpu_buffer->overrun);
85999 + local_add_unchecked(entries, &cpu_buffer->overrun);
86000 local_sub(BUF_PAGE_SIZE, &cpu_buffer->entries_bytes);
86001
86002 /*
86003 @@ -2214,7 +2214,7 @@ rb_reset_tail(struct ring_buffer_per_cpu *cpu_buffer,
86004 if (tail == BUF_PAGE_SIZE)
86005 tail_page->real_end = 0;
86006
86007 - local_sub(length, &tail_page->write);
86008 + local_sub_unchecked(length, &tail_page->write);
86009 return;
86010 }
86011
86012 @@ -2249,7 +2249,7 @@ rb_reset_tail(struct ring_buffer_per_cpu *cpu_buffer,
86013 rb_event_set_padding(event);
86014
86015 /* Set the write back to the previous setting */
86016 - local_sub(length, &tail_page->write);
86017 + local_sub_unchecked(length, &tail_page->write);
86018 return;
86019 }
86020
86021 @@ -2261,7 +2261,7 @@ rb_reset_tail(struct ring_buffer_per_cpu *cpu_buffer,
86022
86023 /* Set write to end of buffer */
86024 length = (tail + length) - BUF_PAGE_SIZE;
86025 - local_sub(length, &tail_page->write);
86026 + local_sub_unchecked(length, &tail_page->write);
86027 }
86028
86029 /*
86030 @@ -2287,7 +2287,7 @@ rb_move_tail(struct ring_buffer_per_cpu *cpu_buffer,
86031 * about it.
86032 */
86033 if (unlikely(next_page == commit_page)) {
86034 - local_inc(&cpu_buffer->commit_overrun);
86035 + local_inc_unchecked(&cpu_buffer->commit_overrun);
86036 goto out_reset;
86037 }
86038
86039 @@ -2343,7 +2343,7 @@ rb_move_tail(struct ring_buffer_per_cpu *cpu_buffer,
86040 cpu_buffer->tail_page) &&
86041 (cpu_buffer->commit_page ==
86042 cpu_buffer->reader_page))) {
86043 - local_inc(&cpu_buffer->commit_overrun);
86044 + local_inc_unchecked(&cpu_buffer->commit_overrun);
86045 goto out_reset;
86046 }
86047 }
86048 @@ -2391,7 +2391,7 @@ __rb_reserve_next(struct ring_buffer_per_cpu *cpu_buffer,
86049 length += RB_LEN_TIME_EXTEND;
86050
86051 tail_page = cpu_buffer->tail_page;
86052 - write = local_add_return(length, &tail_page->write);
86053 + write = local_add_return_unchecked(length, &tail_page->write);
86054
86055 /* set write to only the index of the write */
86056 write &= RB_WRITE_MASK;
86057 @@ -2408,7 +2408,7 @@ __rb_reserve_next(struct ring_buffer_per_cpu *cpu_buffer,
86058 kmemcheck_annotate_bitfield(event, bitfield);
86059 rb_update_event(cpu_buffer, event, length, add_timestamp, delta);
86060
86061 - local_inc(&tail_page->entries);
86062 + local_inc_unchecked(&tail_page->entries);
86063
86064 /*
86065 * If this is the first commit on the page, then update
86066 @@ -2441,7 +2441,7 @@ rb_try_to_discard(struct ring_buffer_per_cpu *cpu_buffer,
86067
86068 if (bpage->page == (void *)addr && rb_page_write(bpage) == old_index) {
86069 unsigned long write_mask =
86070 - local_read(&bpage->write) & ~RB_WRITE_MASK;
86071 + local_read_unchecked(&bpage->write) & ~RB_WRITE_MASK;
86072 unsigned long event_length = rb_event_length(event);
86073 /*
86074 * This is on the tail page. It is possible that
86075 @@ -2451,7 +2451,7 @@ rb_try_to_discard(struct ring_buffer_per_cpu *cpu_buffer,
86076 */
86077 old_index += write_mask;
86078 new_index += write_mask;
86079 - index = local_cmpxchg(&bpage->write, old_index, new_index);
86080 + index = local_cmpxchg_unchecked(&bpage->write, old_index, new_index);
86081 if (index == old_index) {
86082 /* update counters */
86083 local_sub(event_length, &cpu_buffer->entries_bytes);
86084 @@ -2843,7 +2843,7 @@ rb_decrement_entry(struct ring_buffer_per_cpu *cpu_buffer,
86085
86086 /* Do the likely case first */
86087 if (likely(bpage->page == (void *)addr)) {
86088 - local_dec(&bpage->entries);
86089 + local_dec_unchecked(&bpage->entries);
86090 return;
86091 }
86092
86093 @@ -2855,7 +2855,7 @@ rb_decrement_entry(struct ring_buffer_per_cpu *cpu_buffer,
86094 start = bpage;
86095 do {
86096 if (bpage->page == (void *)addr) {
86097 - local_dec(&bpage->entries);
86098 + local_dec_unchecked(&bpage->entries);
86099 return;
86100 }
86101 rb_inc_page(cpu_buffer, &bpage);
86102 @@ -3139,7 +3139,7 @@ static inline unsigned long
86103 rb_num_of_entries(struct ring_buffer_per_cpu *cpu_buffer)
86104 {
86105 return local_read(&cpu_buffer->entries) -
86106 - (local_read(&cpu_buffer->overrun) + cpu_buffer->read);
86107 + (local_read_unchecked(&cpu_buffer->overrun) + cpu_buffer->read);
86108 }
86109
86110 /**
86111 @@ -3228,7 +3228,7 @@ unsigned long ring_buffer_overrun_cpu(struct ring_buffer *buffer, int cpu)
86112 return 0;
86113
86114 cpu_buffer = buffer->buffers[cpu];
86115 - ret = local_read(&cpu_buffer->overrun);
86116 + ret = local_read_unchecked(&cpu_buffer->overrun);
86117
86118 return ret;
86119 }
86120 @@ -3251,7 +3251,7 @@ ring_buffer_commit_overrun_cpu(struct ring_buffer *buffer, int cpu)
86121 return 0;
86122
86123 cpu_buffer = buffer->buffers[cpu];
86124 - ret = local_read(&cpu_buffer->commit_overrun);
86125 + ret = local_read_unchecked(&cpu_buffer->commit_overrun);
86126
86127 return ret;
86128 }
86129 @@ -3336,7 +3336,7 @@ unsigned long ring_buffer_overruns(struct ring_buffer *buffer)
86130 /* if you care about this being correct, lock the buffer */
86131 for_each_buffer_cpu(buffer, cpu) {
86132 cpu_buffer = buffer->buffers[cpu];
86133 - overruns += local_read(&cpu_buffer->overrun);
86134 + overruns += local_read_unchecked(&cpu_buffer->overrun);
86135 }
86136
86137 return overruns;
86138 @@ -3512,8 +3512,8 @@ rb_get_reader_page(struct ring_buffer_per_cpu *cpu_buffer)
86139 /*
86140 * Reset the reader page to size zero.
86141 */
86142 - local_set(&cpu_buffer->reader_page->write, 0);
86143 - local_set(&cpu_buffer->reader_page->entries, 0);
86144 + local_set_unchecked(&cpu_buffer->reader_page->write, 0);
86145 + local_set_unchecked(&cpu_buffer->reader_page->entries, 0);
86146 local_set(&cpu_buffer->reader_page->page->commit, 0);
86147 cpu_buffer->reader_page->real_end = 0;
86148
86149 @@ -3547,7 +3547,7 @@ rb_get_reader_page(struct ring_buffer_per_cpu *cpu_buffer)
86150 * want to compare with the last_overrun.
86151 */
86152 smp_mb();
86153 - overwrite = local_read(&(cpu_buffer->overrun));
86154 + overwrite = local_read_unchecked(&(cpu_buffer->overrun));
86155
86156 /*
86157 * Here's the tricky part.
86158 @@ -4117,8 +4117,8 @@ rb_reset_cpu(struct ring_buffer_per_cpu *cpu_buffer)
86159
86160 cpu_buffer->head_page
86161 = list_entry(cpu_buffer->pages, struct buffer_page, list);
86162 - local_set(&cpu_buffer->head_page->write, 0);
86163 - local_set(&cpu_buffer->head_page->entries, 0);
86164 + local_set_unchecked(&cpu_buffer->head_page->write, 0);
86165 + local_set_unchecked(&cpu_buffer->head_page->entries, 0);
86166 local_set(&cpu_buffer->head_page->page->commit, 0);
86167
86168 cpu_buffer->head_page->read = 0;
86169 @@ -4128,14 +4128,14 @@ rb_reset_cpu(struct ring_buffer_per_cpu *cpu_buffer)
86170
86171 INIT_LIST_HEAD(&cpu_buffer->reader_page->list);
86172 INIT_LIST_HEAD(&cpu_buffer->new_pages);
86173 - local_set(&cpu_buffer->reader_page->write, 0);
86174 - local_set(&cpu_buffer->reader_page->entries, 0);
86175 + local_set_unchecked(&cpu_buffer->reader_page->write, 0);
86176 + local_set_unchecked(&cpu_buffer->reader_page->entries, 0);
86177 local_set(&cpu_buffer->reader_page->page->commit, 0);
86178 cpu_buffer->reader_page->read = 0;
86179
86180 local_set(&cpu_buffer->entries_bytes, 0);
86181 - local_set(&cpu_buffer->overrun, 0);
86182 - local_set(&cpu_buffer->commit_overrun, 0);
86183 + local_set_unchecked(&cpu_buffer->overrun, 0);
86184 + local_set_unchecked(&cpu_buffer->commit_overrun, 0);
86185 local_set(&cpu_buffer->dropped_events, 0);
86186 local_set(&cpu_buffer->entries, 0);
86187 local_set(&cpu_buffer->committing, 0);
86188 @@ -4540,8 +4540,8 @@ int ring_buffer_read_page(struct ring_buffer *buffer,
86189 rb_init_page(bpage);
86190 bpage = reader->page;
86191 reader->page = *data_page;
86192 - local_set(&reader->write, 0);
86193 - local_set(&reader->entries, 0);
86194 + local_set_unchecked(&reader->write, 0);
86195 + local_set_unchecked(&reader->entries, 0);
86196 reader->read = 0;
86197 *data_page = bpage;
86198
86199 diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
86200 index b778e96..4e84621 100644
86201 --- a/kernel/trace/trace.c
86202 +++ b/kernel/trace/trace.c
86203 @@ -3335,7 +3335,7 @@ int trace_keep_overwrite(struct tracer *tracer, u32 mask, int set)
86204 return 0;
86205 }
86206
86207 -int set_tracer_flag(struct trace_array *tr, unsigned int mask, int enabled)
86208 +int set_tracer_flag(struct trace_array *tr, unsigned long mask, int enabled)
86209 {
86210 /* do nothing if flag is already set */
86211 if (!!(trace_flags & mask) == !!enabled)
86212 diff --git a/kernel/trace/trace.h b/kernel/trace/trace.h
86213 index 10c86fb..645ab0a 100644
86214 --- a/kernel/trace/trace.h
86215 +++ b/kernel/trace/trace.h
86216 @@ -1029,7 +1029,7 @@ extern const char *__stop___tracepoint_str[];
86217 void trace_printk_init_buffers(void);
86218 void trace_printk_start_comm(void);
86219 int trace_keep_overwrite(struct tracer *tracer, u32 mask, int set);
86220 -int set_tracer_flag(struct trace_array *tr, unsigned int mask, int enabled);
86221 +int set_tracer_flag(struct trace_array *tr, unsigned long mask, int enabled);
86222
86223 /*
86224 * Normal trace_printk() and friends allocates special buffers
86225 diff --git a/kernel/trace/trace_clock.c b/kernel/trace/trace_clock.c
86226 index 26dc348..8708ca7 100644
86227 --- a/kernel/trace/trace_clock.c
86228 +++ b/kernel/trace/trace_clock.c
86229 @@ -123,7 +123,7 @@ u64 notrace trace_clock_global(void)
86230 return now;
86231 }
86232
86233 -static atomic64_t trace_counter;
86234 +static atomic64_unchecked_t trace_counter;
86235
86236 /*
86237 * trace_clock_counter(): simply an atomic counter.
86238 @@ -132,5 +132,5 @@ static atomic64_t trace_counter;
86239 */
86240 u64 notrace trace_clock_counter(void)
86241 {
86242 - return atomic64_add_return(1, &trace_counter);
86243 + return atomic64_inc_return_unchecked(&trace_counter);
86244 }
86245 diff --git a/kernel/trace/trace_events.c b/kernel/trace/trace_events.c
86246 index 368a4d5..7b6d1d5 100644
86247 --- a/kernel/trace/trace_events.c
86248 +++ b/kernel/trace/trace_events.c
86249 @@ -1673,7 +1673,6 @@ __trace_early_add_new_event(struct ftrace_event_call *call,
86250 return 0;
86251 }
86252
86253 -struct ftrace_module_file_ops;
86254 static void __add_event_to_tracers(struct ftrace_event_call *call);
86255
86256 /* Add an additional event_call dynamically */
86257 diff --git a/kernel/trace/trace_mmiotrace.c b/kernel/trace/trace_mmiotrace.c
86258 index b3dcfb2..ebee344 100644
86259 --- a/kernel/trace/trace_mmiotrace.c
86260 +++ b/kernel/trace/trace_mmiotrace.c
86261 @@ -24,7 +24,7 @@ struct header_iter {
86262 static struct trace_array *mmio_trace_array;
86263 static bool overrun_detected;
86264 static unsigned long prev_overruns;
86265 -static atomic_t dropped_count;
86266 +static atomic_unchecked_t dropped_count;
86267
86268 static void mmio_reset_data(struct trace_array *tr)
86269 {
86270 @@ -127,7 +127,7 @@ static void mmio_close(struct trace_iterator *iter)
86271
86272 static unsigned long count_overruns(struct trace_iterator *iter)
86273 {
86274 - unsigned long cnt = atomic_xchg(&dropped_count, 0);
86275 + unsigned long cnt = atomic_xchg_unchecked(&dropped_count, 0);
86276 unsigned long over = ring_buffer_overruns(iter->trace_buffer->buffer);
86277
86278 if (over > prev_overruns)
86279 @@ -317,7 +317,7 @@ static void __trace_mmiotrace_rw(struct trace_array *tr,
86280 event = trace_buffer_lock_reserve(buffer, TRACE_MMIO_RW,
86281 sizeof(*entry), 0, pc);
86282 if (!event) {
86283 - atomic_inc(&dropped_count);
86284 + atomic_inc_unchecked(&dropped_count);
86285 return;
86286 }
86287 entry = ring_buffer_event_data(event);
86288 @@ -347,7 +347,7 @@ static void __trace_mmiotrace_map(struct trace_array *tr,
86289 event = trace_buffer_lock_reserve(buffer, TRACE_MMIO_MAP,
86290 sizeof(*entry), 0, pc);
86291 if (!event) {
86292 - atomic_inc(&dropped_count);
86293 + atomic_inc_unchecked(&dropped_count);
86294 return;
86295 }
86296 entry = ring_buffer_event_data(event);
86297 diff --git a/kernel/trace/trace_output.c b/kernel/trace/trace_output.c
86298 index 34e7cba..6f9a729 100644
86299 --- a/kernel/trace/trace_output.c
86300 +++ b/kernel/trace/trace_output.c
86301 @@ -294,7 +294,7 @@ int trace_seq_path(struct trace_seq *s, const struct path *path)
86302
86303 p = d_path(path, s->buffer + s->len, PAGE_SIZE - s->len);
86304 if (!IS_ERR(p)) {
86305 - p = mangle_path(s->buffer + s->len, p, "\n");
86306 + p = mangle_path(s->buffer + s->len, p, "\n\\");
86307 if (p) {
86308 s->len = p - s->buffer;
86309 return 1;
86310 @@ -893,14 +893,16 @@ int register_ftrace_event(struct trace_event *event)
86311 goto out;
86312 }
86313
86314 + pax_open_kernel();
86315 if (event->funcs->trace == NULL)
86316 - event->funcs->trace = trace_nop_print;
86317 + *(void **)&event->funcs->trace = trace_nop_print;
86318 if (event->funcs->raw == NULL)
86319 - event->funcs->raw = trace_nop_print;
86320 + *(void **)&event->funcs->raw = trace_nop_print;
86321 if (event->funcs->hex == NULL)
86322 - event->funcs->hex = trace_nop_print;
86323 + *(void **)&event->funcs->hex = trace_nop_print;
86324 if (event->funcs->binary == NULL)
86325 - event->funcs->binary = trace_nop_print;
86326 + *(void **)&event->funcs->binary = trace_nop_print;
86327 + pax_close_kernel();
86328
86329 key = event->type & (EVENT_HASHSIZE - 1);
86330
86331 diff --git a/kernel/trace/trace_stack.c b/kernel/trace/trace_stack.c
86332 index b20428c..4845a10 100644
86333 --- a/kernel/trace/trace_stack.c
86334 +++ b/kernel/trace/trace_stack.c
86335 @@ -68,7 +68,7 @@ check_stack(unsigned long ip, unsigned long *stack)
86336 return;
86337
86338 /* we do not handle interrupt stacks yet */
86339 - if (!object_is_on_stack(stack))
86340 + if (!object_starts_on_stack(stack))
86341 return;
86342
86343 local_irq_save(flags);
86344 diff --git a/kernel/user_namespace.c b/kernel/user_namespace.c
86345 index 13fb113..a6ced3f 100644
86346 --- a/kernel/user_namespace.c
86347 +++ b/kernel/user_namespace.c
86348 @@ -82,6 +82,21 @@ int create_user_ns(struct cred *new)
86349 !kgid_has_mapping(parent_ns, group))
86350 return -EPERM;
86351
86352 +#ifdef CONFIG_GRKERNSEC
86353 + /*
86354 + * This doesn't really inspire confidence:
86355 + * http://marc.info/?l=linux-kernel&m=135543612731939&w=2
86356 + * http://marc.info/?l=linux-kernel&m=135545831607095&w=2
86357 + * Increases kernel attack surface in areas developers
86358 + * previously cared little about ("low importance due
86359 + * to requiring "root" capability")
86360 + * To be removed when this code receives *proper* review
86361 + */
86362 + if (!capable(CAP_SYS_ADMIN) || !capable(CAP_SETUID) ||
86363 + !capable(CAP_SETGID))
86364 + return -EPERM;
86365 +#endif
86366 +
86367 ns = kmem_cache_zalloc(user_ns_cachep, GFP_KERNEL);
86368 if (!ns)
86369 return -ENOMEM;
86370 @@ -860,7 +875,7 @@ static int userns_install(struct nsproxy *nsproxy, void *ns)
86371 if (atomic_read(&current->mm->mm_users) > 1)
86372 return -EINVAL;
86373
86374 - if (current->fs->users != 1)
86375 + if (atomic_read(&current->fs->users) != 1)
86376 return -EINVAL;
86377
86378 if (!ns_capable(user_ns, CAP_SYS_ADMIN))
86379 diff --git a/kernel/utsname_sysctl.c b/kernel/utsname_sysctl.c
86380 index 4f69f9a..7c6f8f8 100644
86381 --- a/kernel/utsname_sysctl.c
86382 +++ b/kernel/utsname_sysctl.c
86383 @@ -47,7 +47,7 @@ static void put_uts(ctl_table *table, int write, void *which)
86384 static int proc_do_uts_string(ctl_table *table, int write,
86385 void __user *buffer, size_t *lenp, loff_t *ppos)
86386 {
86387 - struct ctl_table uts_table;
86388 + ctl_table_no_const uts_table;
86389 int r;
86390 memcpy(&uts_table, table, sizeof(uts_table));
86391 uts_table.data = get_uts(table, write);
86392 diff --git a/kernel/watchdog.c b/kernel/watchdog.c
86393 index 4431610..4265616 100644
86394 --- a/kernel/watchdog.c
86395 +++ b/kernel/watchdog.c
86396 @@ -475,7 +475,7 @@ static int watchdog_nmi_enable(unsigned int cpu) { return 0; }
86397 static void watchdog_nmi_disable(unsigned int cpu) { return; }
86398 #endif /* CONFIG_HARDLOCKUP_DETECTOR */
86399
86400 -static struct smp_hotplug_thread watchdog_threads = {
86401 +static struct smp_hotplug_thread watchdog_threads __read_only = {
86402 .store = &softlockup_watchdog,
86403 .thread_should_run = watchdog_should_run,
86404 .thread_fn = watchdog,
86405 diff --git a/kernel/workqueue.c b/kernel/workqueue.c
86406 index 93c2652..66a1cfd 100644
86407 --- a/kernel/workqueue.c
86408 +++ b/kernel/workqueue.c
86409 @@ -4668,7 +4668,7 @@ static void rebind_workers(struct worker_pool *pool)
86410 WARN_ON_ONCE(!(worker_flags & WORKER_UNBOUND));
86411 worker_flags |= WORKER_REBOUND;
86412 worker_flags &= ~WORKER_UNBOUND;
86413 - ACCESS_ONCE(worker->flags) = worker_flags;
86414 + ACCESS_ONCE_RW(worker->flags) = worker_flags;
86415 }
86416
86417 spin_unlock_irq(&pool->lock);
86418 diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug
86419 index 094f315..244a824 100644
86420 --- a/lib/Kconfig.debug
86421 +++ b/lib/Kconfig.debug
86422 @@ -836,7 +836,7 @@ config DEBUG_MUTEXES
86423
86424 config DEBUG_WW_MUTEX_SLOWPATH
86425 bool "Wait/wound mutex debugging: Slowpath testing"
86426 - depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT
86427 + depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT && !PAX_CONSTIFY_PLUGIN
86428 select DEBUG_LOCK_ALLOC
86429 select DEBUG_SPINLOCK
86430 select DEBUG_MUTEXES
86431 @@ -849,7 +849,7 @@ config DEBUG_WW_MUTEX_SLOWPATH
86432
86433 config DEBUG_LOCK_ALLOC
86434 bool "Lock debugging: detect incorrect freeing of live locks"
86435 - depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT
86436 + depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT && !PAX_CONSTIFY_PLUGIN
86437 select DEBUG_SPINLOCK
86438 select DEBUG_MUTEXES
86439 select LOCKDEP
86440 @@ -863,7 +863,7 @@ config DEBUG_LOCK_ALLOC
86441
86442 config PROVE_LOCKING
86443 bool "Lock debugging: prove locking correctness"
86444 - depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT
86445 + depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT && !PAX_CONSTIFY_PLUGIN
86446 select LOCKDEP
86447 select DEBUG_SPINLOCK
86448 select DEBUG_MUTEXES
86449 @@ -914,7 +914,7 @@ config LOCKDEP
86450
86451 config LOCK_STAT
86452 bool "Lock usage statistics"
86453 - depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT
86454 + depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT && !PAX_CONSTIFY_PLUGIN
86455 select LOCKDEP
86456 select DEBUG_SPINLOCK
86457 select DEBUG_MUTEXES
86458 @@ -1376,6 +1376,7 @@ config LATENCYTOP
86459 depends on DEBUG_KERNEL
86460 depends on STACKTRACE_SUPPORT
86461 depends on PROC_FS
86462 + depends on !GRKERNSEC_HIDESYM
86463 select FRAME_POINTER if !MIPS && !PPC && !S390 && !MICROBLAZE && !ARM_UNWIND && !ARC
86464 select KALLSYMS
86465 select KALLSYMS_ALL
86466 @@ -1392,7 +1393,7 @@ config ARCH_HAS_DEBUG_STRICT_USER_COPY_CHECKS
86467 config DEBUG_STRICT_USER_COPY_CHECKS
86468 bool "Strict user copy size checks"
86469 depends on ARCH_HAS_DEBUG_STRICT_USER_COPY_CHECKS
86470 - depends on DEBUG_KERNEL && !TRACE_BRANCH_PROFILING
86471 + depends on DEBUG_KERNEL && !TRACE_BRANCH_PROFILING && !PAX_SIZE_OVERFLOW
86472 help
86473 Enabling this option turns a certain set of sanity checks for user
86474 copy operations into compile time failures.
86475 @@ -1502,7 +1503,7 @@ endmenu # runtime tests
86476
86477 config PROVIDE_OHCI1394_DMA_INIT
86478 bool "Remote debugging over FireWire early on boot"
86479 - depends on PCI && X86
86480 + depends on PCI && X86 && !GRKERNSEC
86481 help
86482 If you want to debug problems which hang or crash the kernel early
86483 on boot and the crashing machine has a FireWire port, you can use
86484 @@ -1531,7 +1532,7 @@ config PROVIDE_OHCI1394_DMA_INIT
86485
86486 config FIREWIRE_OHCI_REMOTE_DMA
86487 bool "Remote debugging over FireWire with firewire-ohci"
86488 - depends on FIREWIRE_OHCI
86489 + depends on FIREWIRE_OHCI && !GRKERNSEC
86490 help
86491 This option lets you use the FireWire bus for remote debugging
86492 with help of the firewire-ohci driver. It enables unfiltered
86493 diff --git a/lib/Makefile b/lib/Makefile
86494 index f3bb2cb..b358ace 100644
86495 --- a/lib/Makefile
86496 +++ b/lib/Makefile
86497 @@ -52,7 +52,7 @@ obj-$(CONFIG_GENERIC_HWEIGHT) += hweight.o
86498
86499 obj-$(CONFIG_BTREE) += btree.o
86500 obj-$(CONFIG_DEBUG_PREEMPT) += smp_processor_id.o
86501 -obj-$(CONFIG_DEBUG_LIST) += list_debug.o
86502 +obj-y += list_debug.o
86503 obj-$(CONFIG_DEBUG_OBJECTS) += debugobjects.o
86504
86505 ifneq ($(CONFIG_HAVE_DEC_LOCK),y)
86506 diff --git a/lib/bitmap.c b/lib/bitmap.c
86507 index 06f7e4f..f3cf2b0 100644
86508 --- a/lib/bitmap.c
86509 +++ b/lib/bitmap.c
86510 @@ -422,7 +422,7 @@ int __bitmap_parse(const char *buf, unsigned int buflen,
86511 {
86512 int c, old_c, totaldigits, ndigits, nchunks, nbits;
86513 u32 chunk;
86514 - const char __user __force *ubuf = (const char __user __force *)buf;
86515 + const char __user *ubuf = (const char __force_user *)buf;
86516
86517 bitmap_zero(maskp, nmaskbits);
86518
86519 @@ -507,7 +507,7 @@ int bitmap_parse_user(const char __user *ubuf,
86520 {
86521 if (!access_ok(VERIFY_READ, ubuf, ulen))
86522 return -EFAULT;
86523 - return __bitmap_parse((const char __force *)ubuf,
86524 + return __bitmap_parse((const char __force_kernel *)ubuf,
86525 ulen, 1, maskp, nmaskbits);
86526
86527 }
86528 @@ -598,7 +598,7 @@ static int __bitmap_parselist(const char *buf, unsigned int buflen,
86529 {
86530 unsigned a, b;
86531 int c, old_c, totaldigits;
86532 - const char __user __force *ubuf = (const char __user __force *)buf;
86533 + const char __user *ubuf = (const char __force_user *)buf;
86534 int exp_digit, in_range;
86535
86536 totaldigits = c = 0;
86537 @@ -698,7 +698,7 @@ int bitmap_parselist_user(const char __user *ubuf,
86538 {
86539 if (!access_ok(VERIFY_READ, ubuf, ulen))
86540 return -EFAULT;
86541 - return __bitmap_parselist((const char __force *)ubuf,
86542 + return __bitmap_parselist((const char __force_kernel *)ubuf,
86543 ulen, 1, maskp, nmaskbits);
86544 }
86545 EXPORT_SYMBOL(bitmap_parselist_user);
86546 diff --git a/lib/bug.c b/lib/bug.c
86547 index 1686034..a9c00c8 100644
86548 --- a/lib/bug.c
86549 +++ b/lib/bug.c
86550 @@ -134,6 +134,8 @@ enum bug_trap_type report_bug(unsigned long bugaddr, struct pt_regs *regs)
86551 return BUG_TRAP_TYPE_NONE;
86552
86553 bug = find_bug(bugaddr);
86554 + if (!bug)
86555 + return BUG_TRAP_TYPE_NONE;
86556
86557 file = NULL;
86558 line = 0;
86559 diff --git a/lib/debugobjects.c b/lib/debugobjects.c
86560 index bf2c8b1..1d00ccf 100644
86561 --- a/lib/debugobjects.c
86562 +++ b/lib/debugobjects.c
86563 @@ -286,7 +286,7 @@ static void debug_object_is_on_stack(void *addr, int onstack)
86564 if (limit > 4)
86565 return;
86566
86567 - is_on_stack = object_is_on_stack(addr);
86568 + is_on_stack = object_starts_on_stack(addr);
86569 if (is_on_stack == onstack)
86570 return;
86571
86572 diff --git a/lib/devres.c b/lib/devres.c
86573 index 8235331..5881053 100644
86574 --- a/lib/devres.c
86575 +++ b/lib/devres.c
86576 @@ -81,7 +81,7 @@ EXPORT_SYMBOL(devm_ioremap_nocache);
86577 void devm_iounmap(struct device *dev, void __iomem *addr)
86578 {
86579 WARN_ON(devres_destroy(dev, devm_ioremap_release, devm_ioremap_match,
86580 - (void *)addr));
86581 + (void __force *)addr));
86582 iounmap(addr);
86583 }
86584 EXPORT_SYMBOL(devm_iounmap);
86585 @@ -224,7 +224,7 @@ void devm_ioport_unmap(struct device *dev, void __iomem *addr)
86586 {
86587 ioport_unmap(addr);
86588 WARN_ON(devres_destroy(dev, devm_ioport_map_release,
86589 - devm_ioport_map_match, (void *)addr));
86590 + devm_ioport_map_match, (void __force *)addr));
86591 }
86592 EXPORT_SYMBOL(devm_ioport_unmap);
86593 #endif /* CONFIG_HAS_IOPORT */
86594 diff --git a/lib/div64.c b/lib/div64.c
86595 index 4382ad7..08aa558 100644
86596 --- a/lib/div64.c
86597 +++ b/lib/div64.c
86598 @@ -59,7 +59,7 @@ uint32_t __attribute__((weak)) __div64_32(uint64_t *n, uint32_t base)
86599 EXPORT_SYMBOL(__div64_32);
86600
86601 #ifndef div_s64_rem
86602 -s64 div_s64_rem(s64 dividend, s32 divisor, s32 *remainder)
86603 +s64 __intentional_overflow(-1) div_s64_rem(s64 dividend, s32 divisor, s32 *remainder)
86604 {
86605 u64 quotient;
86606
86607 @@ -130,7 +130,7 @@ EXPORT_SYMBOL(div64_u64_rem);
86608 * 'http://www.hackersdelight.org/HDcode/newCode/divDouble.c.txt'
86609 */
86610 #ifndef div64_u64
86611 -u64 div64_u64(u64 dividend, u64 divisor)
86612 +u64 __intentional_overflow(-1) div64_u64(u64 dividend, u64 divisor)
86613 {
86614 u32 high = divisor >> 32;
86615 u64 quot;
86616 diff --git a/lib/dma-debug.c b/lib/dma-debug.c
86617 index d87a17a..ac0d79a 100644
86618 --- a/lib/dma-debug.c
86619 +++ b/lib/dma-debug.c
86620 @@ -768,7 +768,7 @@ static int dma_debug_device_change(struct notifier_block *nb, unsigned long acti
86621
86622 void dma_debug_add_bus(struct bus_type *bus)
86623 {
86624 - struct notifier_block *nb;
86625 + notifier_block_no_const *nb;
86626
86627 if (global_disable)
86628 return;
86629 @@ -945,7 +945,7 @@ static void check_unmap(struct dma_debug_entry *ref)
86630
86631 static void check_for_stack(struct device *dev, void *addr)
86632 {
86633 - if (object_is_on_stack(addr))
86634 + if (object_starts_on_stack(addr))
86635 err_printk(dev, NULL, "DMA-API: device driver maps memory from"
86636 "stack [addr=%p]\n", addr);
86637 }
86638 diff --git a/lib/inflate.c b/lib/inflate.c
86639 index 013a761..c28f3fc 100644
86640 --- a/lib/inflate.c
86641 +++ b/lib/inflate.c
86642 @@ -269,7 +269,7 @@ static void free(void *where)
86643 malloc_ptr = free_mem_ptr;
86644 }
86645 #else
86646 -#define malloc(a) kmalloc(a, GFP_KERNEL)
86647 +#define malloc(a) kmalloc((a), GFP_KERNEL)
86648 #define free(a) kfree(a)
86649 #endif
86650
86651 diff --git a/lib/ioremap.c b/lib/ioremap.c
86652 index 0c9216c..863bd89 100644
86653 --- a/lib/ioremap.c
86654 +++ b/lib/ioremap.c
86655 @@ -38,7 +38,7 @@ static inline int ioremap_pmd_range(pud_t *pud, unsigned long addr,
86656 unsigned long next;
86657
86658 phys_addr -= addr;
86659 - pmd = pmd_alloc(&init_mm, pud, addr);
86660 + pmd = pmd_alloc_kernel(&init_mm, pud, addr);
86661 if (!pmd)
86662 return -ENOMEM;
86663 do {
86664 @@ -56,7 +56,7 @@ static inline int ioremap_pud_range(pgd_t *pgd, unsigned long addr,
86665 unsigned long next;
86666
86667 phys_addr -= addr;
86668 - pud = pud_alloc(&init_mm, pgd, addr);
86669 + pud = pud_alloc_kernel(&init_mm, pgd, addr);
86670 if (!pud)
86671 return -ENOMEM;
86672 do {
86673 diff --git a/lib/is_single_threaded.c b/lib/is_single_threaded.c
86674 index bd2bea9..6b3c95e 100644
86675 --- a/lib/is_single_threaded.c
86676 +++ b/lib/is_single_threaded.c
86677 @@ -22,6 +22,9 @@ bool current_is_single_threaded(void)
86678 struct task_struct *p, *t;
86679 bool ret;
86680
86681 + if (!mm)
86682 + return true;
86683 +
86684 if (atomic_read(&task->signal->live) != 1)
86685 return false;
86686
86687 diff --git a/lib/kobject.c b/lib/kobject.c
86688 index 084f7b1..d265b8a 100644
86689 --- a/lib/kobject.c
86690 +++ b/lib/kobject.c
86691 @@ -875,9 +875,9 @@ EXPORT_SYMBOL_GPL(kset_create_and_add);
86692
86693
86694 static DEFINE_SPINLOCK(kobj_ns_type_lock);
86695 -static const struct kobj_ns_type_operations *kobj_ns_ops_tbl[KOBJ_NS_TYPES];
86696 +static const struct kobj_ns_type_operations *kobj_ns_ops_tbl[KOBJ_NS_TYPES] __read_only;
86697
86698 -int kobj_ns_type_register(const struct kobj_ns_type_operations *ops)
86699 +int __init kobj_ns_type_register(const struct kobj_ns_type_operations *ops)
86700 {
86701 enum kobj_ns_type type = ops->type;
86702 int error;
86703 diff --git a/lib/list_debug.c b/lib/list_debug.c
86704 index c24c2f7..f0296f4 100644
86705 --- a/lib/list_debug.c
86706 +++ b/lib/list_debug.c
86707 @@ -11,7 +11,9 @@
86708 #include <linux/bug.h>
86709 #include <linux/kernel.h>
86710 #include <linux/rculist.h>
86711 +#include <linux/mm.h>
86712
86713 +#ifdef CONFIG_DEBUG_LIST
86714 /*
86715 * Insert a new entry between two known consecutive entries.
86716 *
86717 @@ -19,21 +21,40 @@
86718 * the prev/next entries already!
86719 */
86720
86721 +static bool __list_add_debug(struct list_head *new,
86722 + struct list_head *prev,
86723 + struct list_head *next)
86724 +{
86725 + if (unlikely(next->prev != prev)) {
86726 + printk(KERN_ERR "list_add corruption. next->prev should be "
86727 + "prev (%p), but was %p. (next=%p).\n",
86728 + prev, next->prev, next);
86729 + BUG();
86730 + return false;
86731 + }
86732 + if (unlikely(prev->next != next)) {
86733 + printk(KERN_ERR "list_add corruption. prev->next should be "
86734 + "next (%p), but was %p. (prev=%p).\n",
86735 + next, prev->next, prev);
86736 + BUG();
86737 + return false;
86738 + }
86739 + if (unlikely(new == prev || new == next)) {
86740 + printk(KERN_ERR "list_add double add: new=%p, prev=%p, next=%p.\n",
86741 + new, prev, next);
86742 + BUG();
86743 + return false;
86744 + }
86745 + return true;
86746 +}
86747 +
86748 void __list_add(struct list_head *new,
86749 - struct list_head *prev,
86750 - struct list_head *next)
86751 + struct list_head *prev,
86752 + struct list_head *next)
86753 {
86754 - WARN(next->prev != prev,
86755 - "list_add corruption. next->prev should be "
86756 - "prev (%p), but was %p. (next=%p).\n",
86757 - prev, next->prev, next);
86758 - WARN(prev->next != next,
86759 - "list_add corruption. prev->next should be "
86760 - "next (%p), but was %p. (prev=%p).\n",
86761 - next, prev->next, prev);
86762 - WARN(new == prev || new == next,
86763 - "list_add double add: new=%p, prev=%p, next=%p.\n",
86764 - new, prev, next);
86765 + if (!__list_add_debug(new, prev, next))
86766 + return;
86767 +
86768 next->prev = new;
86769 new->next = next;
86770 new->prev = prev;
86771 @@ -41,28 +62,46 @@ void __list_add(struct list_head *new,
86772 }
86773 EXPORT_SYMBOL(__list_add);
86774
86775 -void __list_del_entry(struct list_head *entry)
86776 +static bool __list_del_entry_debug(struct list_head *entry)
86777 {
86778 struct list_head *prev, *next;
86779
86780 prev = entry->prev;
86781 next = entry->next;
86782
86783 - if (WARN(next == LIST_POISON1,
86784 - "list_del corruption, %p->next is LIST_POISON1 (%p)\n",
86785 - entry, LIST_POISON1) ||
86786 - WARN(prev == LIST_POISON2,
86787 - "list_del corruption, %p->prev is LIST_POISON2 (%p)\n",
86788 - entry, LIST_POISON2) ||
86789 - WARN(prev->next != entry,
86790 - "list_del corruption. prev->next should be %p, "
86791 - "but was %p\n", entry, prev->next) ||
86792 - WARN(next->prev != entry,
86793 - "list_del corruption. next->prev should be %p, "
86794 - "but was %p\n", entry, next->prev))
86795 + if (unlikely(next == LIST_POISON1)) {
86796 + printk(KERN_ERR "list_del corruption, %p->next is LIST_POISON1 (%p)\n",
86797 + entry, LIST_POISON1);
86798 + BUG();
86799 + return false;
86800 + }
86801 + if (unlikely(prev == LIST_POISON2)) {
86802 + printk(KERN_ERR "list_del corruption, %p->prev is LIST_POISON2 (%p)\n",
86803 + entry, LIST_POISON2);
86804 + BUG();
86805 + return false;
86806 + }
86807 + if (unlikely(entry->prev->next != entry)) {
86808 + printk(KERN_ERR "list_del corruption. prev->next should be %p, "
86809 + "but was %p\n", entry, prev->next);
86810 + BUG();
86811 + return false;
86812 + }
86813 + if (unlikely(entry->next->prev != entry)) {
86814 + printk(KERN_ERR "list_del corruption. next->prev should be %p, "
86815 + "but was %p\n", entry, next->prev);
86816 + BUG();
86817 + return false;
86818 + }
86819 + return true;
86820 +}
86821 +
86822 +void __list_del_entry(struct list_head *entry)
86823 +{
86824 + if (!__list_del_entry_debug(entry))
86825 return;
86826
86827 - __list_del(prev, next);
86828 + __list_del(entry->prev, entry->next);
86829 }
86830 EXPORT_SYMBOL(__list_del_entry);
86831
86832 @@ -86,15 +125,85 @@ EXPORT_SYMBOL(list_del);
86833 void __list_add_rcu(struct list_head *new,
86834 struct list_head *prev, struct list_head *next)
86835 {
86836 - WARN(next->prev != prev,
86837 - "list_add_rcu corruption. next->prev should be prev (%p), but was %p. (next=%p).\n",
86838 - prev, next->prev, next);
86839 - WARN(prev->next != next,
86840 - "list_add_rcu corruption. prev->next should be next (%p), but was %p. (prev=%p).\n",
86841 - next, prev->next, prev);
86842 + if (!__list_add_debug(new, prev, next))
86843 + return;
86844 +
86845 new->next = next;
86846 new->prev = prev;
86847 rcu_assign_pointer(list_next_rcu(prev), new);
86848 next->prev = new;
86849 }
86850 EXPORT_SYMBOL(__list_add_rcu);
86851 +#endif
86852 +
86853 +void __pax_list_add(struct list_head *new, struct list_head *prev, struct list_head *next)
86854 +{
86855 +#ifdef CONFIG_DEBUG_LIST
86856 + if (!__list_add_debug(new, prev, next))
86857 + return;
86858 +#endif
86859 +
86860 + pax_open_kernel();
86861 + next->prev = new;
86862 + new->next = next;
86863 + new->prev = prev;
86864 + prev->next = new;
86865 + pax_close_kernel();
86866 +}
86867 +EXPORT_SYMBOL(__pax_list_add);
86868 +
86869 +void pax_list_del(struct list_head *entry)
86870 +{
86871 +#ifdef CONFIG_DEBUG_LIST
86872 + if (!__list_del_entry_debug(entry))
86873 + return;
86874 +#endif
86875 +
86876 + pax_open_kernel();
86877 + __list_del(entry->prev, entry->next);
86878 + entry->next = LIST_POISON1;
86879 + entry->prev = LIST_POISON2;
86880 + pax_close_kernel();
86881 +}
86882 +EXPORT_SYMBOL(pax_list_del);
86883 +
86884 +void pax_list_del_init(struct list_head *entry)
86885 +{
86886 + pax_open_kernel();
86887 + __list_del(entry->prev, entry->next);
86888 + INIT_LIST_HEAD(entry);
86889 + pax_close_kernel();
86890 +}
86891 +EXPORT_SYMBOL(pax_list_del_init);
86892 +
86893 +void __pax_list_add_rcu(struct list_head *new,
86894 + struct list_head *prev, struct list_head *next)
86895 +{
86896 +#ifdef CONFIG_DEBUG_LIST
86897 + if (!__list_add_debug(new, prev, next))
86898 + return;
86899 +#endif
86900 +
86901 + pax_open_kernel();
86902 + new->next = next;
86903 + new->prev = prev;
86904 + rcu_assign_pointer(list_next_rcu(prev), new);
86905 + next->prev = new;
86906 + pax_close_kernel();
86907 +}
86908 +EXPORT_SYMBOL(__pax_list_add_rcu);
86909 +
86910 +void pax_list_del_rcu(struct list_head *entry)
86911 +{
86912 +#ifdef CONFIG_DEBUG_LIST
86913 + if (!__list_del_entry_debug(entry))
86914 + return;
86915 +#endif
86916 +
86917 + pax_open_kernel();
86918 + __list_del(entry->prev, entry->next);
86919 + entry->next = LIST_POISON1;
86920 + entry->prev = LIST_POISON2;
86921 + pax_close_kernel();
86922 +}
86923 +EXPORT_SYMBOL(pax_list_del_rcu);
86924 diff --git a/lib/percpu-refcount.c b/lib/percpu-refcount.c
86925 index 1a53d49..ace934c 100644
86926 --- a/lib/percpu-refcount.c
86927 +++ b/lib/percpu-refcount.c
86928 @@ -29,7 +29,7 @@
86929 * can't hit 0 before we've added up all the percpu refs.
86930 */
86931
86932 -#define PCPU_COUNT_BIAS (1U << 31)
86933 +#define PCPU_COUNT_BIAS (1U << 30)
86934
86935 /**
86936 * percpu_ref_init - initialize a percpu refcount
86937 diff --git a/lib/radix-tree.c b/lib/radix-tree.c
86938 index 7811ed3..f80ca19 100644
86939 --- a/lib/radix-tree.c
86940 +++ b/lib/radix-tree.c
86941 @@ -93,7 +93,7 @@ struct radix_tree_preload {
86942 int nr;
86943 struct radix_tree_node *nodes[RADIX_TREE_PRELOAD_SIZE];
86944 };
86945 -static DEFINE_PER_CPU(struct radix_tree_preload, radix_tree_preloads) = { 0, };
86946 +static DEFINE_PER_CPU(struct radix_tree_preload, radix_tree_preloads);
86947
86948 static inline void *ptr_to_indirect(void *ptr)
86949 {
86950 diff --git a/lib/strncpy_from_user.c b/lib/strncpy_from_user.c
86951 index bb2b201..46abaf9 100644
86952 --- a/lib/strncpy_from_user.c
86953 +++ b/lib/strncpy_from_user.c
86954 @@ -21,7 +21,7 @@
86955 */
86956 static inline long do_strncpy_from_user(char *dst, const char __user *src, long count, unsigned long max)
86957 {
86958 - const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
86959 + static const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
86960 long res = 0;
86961
86962 /*
86963 diff --git a/lib/strnlen_user.c b/lib/strnlen_user.c
86964 index a28df52..3d55877 100644
86965 --- a/lib/strnlen_user.c
86966 +++ b/lib/strnlen_user.c
86967 @@ -26,7 +26,7 @@
86968 */
86969 static inline long do_strnlen_user(const char __user *src, unsigned long count, unsigned long max)
86970 {
86971 - const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
86972 + static const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
86973 long align, res = 0;
86974 unsigned long c;
86975
86976 diff --git a/lib/swiotlb.c b/lib/swiotlb.c
86977 index 4e8686c..3e8c92f 100644
86978 --- a/lib/swiotlb.c
86979 +++ b/lib/swiotlb.c
86980 @@ -664,7 +664,7 @@ EXPORT_SYMBOL(swiotlb_alloc_coherent);
86981
86982 void
86983 swiotlb_free_coherent(struct device *hwdev, size_t size, void *vaddr,
86984 - dma_addr_t dev_addr)
86985 + dma_addr_t dev_addr, struct dma_attrs *attrs)
86986 {
86987 phys_addr_t paddr = dma_to_phys(hwdev, dev_addr);
86988
86989 diff --git a/lib/usercopy.c b/lib/usercopy.c
86990 index 4f5b1dd..7cab418 100644
86991 --- a/lib/usercopy.c
86992 +++ b/lib/usercopy.c
86993 @@ -7,3 +7,9 @@ void copy_from_user_overflow(void)
86994 WARN(1, "Buffer overflow detected!\n");
86995 }
86996 EXPORT_SYMBOL(copy_from_user_overflow);
86997 +
86998 +void copy_to_user_overflow(void)
86999 +{
87000 + WARN(1, "Buffer overflow detected!\n");
87001 +}
87002 +EXPORT_SYMBOL(copy_to_user_overflow);
87003 diff --git a/lib/vsprintf.c b/lib/vsprintf.c
87004 index d76555c..62d4bfe 100644
87005 --- a/lib/vsprintf.c
87006 +++ b/lib/vsprintf.c
87007 @@ -16,6 +16,9 @@
87008 * - scnprintf and vscnprintf
87009 */
87010
87011 +#ifdef CONFIG_GRKERNSEC_HIDESYM
87012 +#define __INCLUDED_BY_HIDESYM 1
87013 +#endif
87014 #include <stdarg.h>
87015 #include <linux/module.h> /* for KSYM_SYMBOL_LEN */
87016 #include <linux/types.h>
87017 @@ -1155,7 +1158,11 @@ char *netdev_feature_string(char *buf, char *end, const u8 *addr,
87018 return number(buf, end, *(const netdev_features_t *)addr, spec);
87019 }
87020
87021 +#ifdef CONFIG_GRKERNSEC_HIDESYM
87022 +int kptr_restrict __read_mostly = 2;
87023 +#else
87024 int kptr_restrict __read_mostly;
87025 +#endif
87026
87027 /*
87028 * Show a '%p' thing. A kernel extension is that the '%p' is followed
87029 @@ -1168,6 +1175,7 @@ int kptr_restrict __read_mostly;
87030 * - 'f' For simple symbolic function names without offset
87031 * - 'S' For symbolic direct pointers with offset
87032 * - 's' For symbolic direct pointers without offset
87033 + * - 'A' For symbolic direct pointers with offset approved for use with GRKERNSEC_HIDESYM
87034 * - '[FfSs]R' as above with __builtin_extract_return_addr() translation
87035 * - 'B' For backtraced symbolic direct pointers with offset
87036 * - 'R' For decoded struct resource, e.g., [mem 0x0-0x1f 64bit pref]
87037 @@ -1232,12 +1240,12 @@ char *pointer(const char *fmt, char *buf, char *end, void *ptr,
87038
87039 if (!ptr && *fmt != 'K') {
87040 /*
87041 - * Print (null) with the same width as a pointer so it makes
87042 + * Print (nil) with the same width as a pointer so it makes
87043 * tabular output look nice.
87044 */
87045 if (spec.field_width == -1)
87046 spec.field_width = default_width;
87047 - return string(buf, end, "(null)", spec);
87048 + return string(buf, end, "(nil)", spec);
87049 }
87050
87051 switch (*fmt) {
87052 @@ -1247,6 +1255,12 @@ char *pointer(const char *fmt, char *buf, char *end, void *ptr,
87053 /* Fallthrough */
87054 case 'S':
87055 case 's':
87056 +#ifdef CONFIG_GRKERNSEC_HIDESYM
87057 + break;
87058 +#else
87059 + return symbol_string(buf, end, ptr, spec, fmt);
87060 +#endif
87061 + case 'A':
87062 case 'B':
87063 return symbol_string(buf, end, ptr, spec, fmt);
87064 case 'R':
87065 @@ -1302,6 +1316,8 @@ char *pointer(const char *fmt, char *buf, char *end, void *ptr,
87066 va_end(va);
87067 return buf;
87068 }
87069 + case 'P':
87070 + break;
87071 case 'K':
87072 /*
87073 * %pK cannot be used in IRQ context because its test
87074 @@ -1363,6 +1379,21 @@ char *pointer(const char *fmt, char *buf, char *end, void *ptr,
87075 ((const struct file *)ptr)->f_path.dentry,
87076 spec, fmt);
87077 }
87078 +
87079 +#ifdef CONFIG_GRKERNSEC_HIDESYM
87080 + /* 'P' = approved pointers to copy to userland,
87081 + as in the /proc/kallsyms case, as we make it display nothing
87082 + for non-root users, and the real contents for root users
87083 + Also ignore 'K' pointers, since we force their NULLing for non-root users
87084 + above
87085 + */
87086 + if ((unsigned long)ptr > TASK_SIZE && *fmt != 'P' && *fmt != 'K' && is_usercopy_object(buf)) {
87087 + printk(KERN_ALERT "grsec: kernel infoleak detected! Please report this log to spender@grsecurity.net.\n");
87088 + dump_stack();
87089 + ptr = NULL;
87090 + }
87091 +#endif
87092 +
87093 spec.flags |= SMALL;
87094 if (spec.field_width == -1) {
87095 spec.field_width = default_width;
87096 @@ -2086,11 +2117,11 @@ int bstr_printf(char *buf, size_t size, const char *fmt, const u32 *bin_buf)
87097 typeof(type) value; \
87098 if (sizeof(type) == 8) { \
87099 args = PTR_ALIGN(args, sizeof(u32)); \
87100 - *(u32 *)&value = *(u32 *)args; \
87101 - *((u32 *)&value + 1) = *(u32 *)(args + 4); \
87102 + *(u32 *)&value = *(const u32 *)args; \
87103 + *((u32 *)&value + 1) = *(const u32 *)(args + 4); \
87104 } else { \
87105 args = PTR_ALIGN(args, sizeof(type)); \
87106 - value = *(typeof(type) *)args; \
87107 + value = *(const typeof(type) *)args; \
87108 } \
87109 args += sizeof(type); \
87110 value; \
87111 @@ -2153,7 +2184,7 @@ int bstr_printf(char *buf, size_t size, const char *fmt, const u32 *bin_buf)
87112 case FORMAT_TYPE_STR: {
87113 const char *str_arg = args;
87114 args += strlen(str_arg) + 1;
87115 - str = string(str, end, (char *)str_arg, spec);
87116 + str = string(str, end, str_arg, spec);
87117 break;
87118 }
87119
87120 diff --git a/localversion-grsec b/localversion-grsec
87121 new file mode 100644
87122 index 0000000..7cd6065
87123 --- /dev/null
87124 +++ b/localversion-grsec
87125 @@ -0,0 +1 @@
87126 +-grsec
87127 diff --git a/mm/Kconfig b/mm/Kconfig
87128 index 394838f..0e5f816 100644
87129 --- a/mm/Kconfig
87130 +++ b/mm/Kconfig
87131 @@ -317,10 +317,11 @@ config KSM
87132 root has set /sys/kernel/mm/ksm/run to 1 (if CONFIG_SYSFS is set).
87133
87134 config DEFAULT_MMAP_MIN_ADDR
87135 - int "Low address space to protect from user allocation"
87136 + int "Low address space to protect from user allocation"
87137 depends on MMU
87138 - default 4096
87139 - help
87140 + default 32768 if ALPHA || ARM || PARISC || SPARC32
87141 + default 65536
87142 + help
87143 This is the portion of low virtual memory which should be protected
87144 from userspace allocation. Keeping a user from writing to low pages
87145 can help reduce the impact of kernel NULL pointer bugs.
87146 @@ -351,7 +352,7 @@ config MEMORY_FAILURE
87147
87148 config HWPOISON_INJECT
87149 tristate "HWPoison pages injector"
87150 - depends on MEMORY_FAILURE && DEBUG_KERNEL && PROC_FS
87151 + depends on MEMORY_FAILURE && DEBUG_KERNEL && PROC_FS && !GRKERNSEC
87152 select PROC_PAGE_MONITOR
87153
87154 config NOMMU_INITIAL_TRIM_EXCESS
87155 diff --git a/mm/backing-dev.c b/mm/backing-dev.c
87156 index ce682f7..1fb54f9 100644
87157 --- a/mm/backing-dev.c
87158 +++ b/mm/backing-dev.c
87159 @@ -12,7 +12,7 @@
87160 #include <linux/device.h>
87161 #include <trace/events/writeback.h>
87162
87163 -static atomic_long_t bdi_seq = ATOMIC_LONG_INIT(0);
87164 +static atomic_long_unchecked_t bdi_seq = ATOMIC_LONG_INIT(0);
87165
87166 struct backing_dev_info default_backing_dev_info = {
87167 .name = "default",
87168 @@ -525,7 +525,7 @@ int bdi_setup_and_register(struct backing_dev_info *bdi, char *name,
87169 return err;
87170
87171 err = bdi_register(bdi, NULL, "%.28s-%ld", name,
87172 - atomic_long_inc_return(&bdi_seq));
87173 + atomic_long_inc_return_unchecked(&bdi_seq));
87174 if (err) {
87175 bdi_destroy(bdi);
87176 return err;
87177 diff --git a/mm/filemap.c b/mm/filemap.c
87178 index ae4846f..b0acebe 100644
87179 --- a/mm/filemap.c
87180 +++ b/mm/filemap.c
87181 @@ -1768,7 +1768,7 @@ int generic_file_mmap(struct file * file, struct vm_area_struct * vma)
87182 struct address_space *mapping = file->f_mapping;
87183
87184 if (!mapping->a_ops->readpage)
87185 - return -ENOEXEC;
87186 + return -ENODEV;
87187 file_accessed(file);
87188 vma->vm_ops = &generic_file_vm_ops;
87189 return 0;
87190 @@ -1950,7 +1950,7 @@ static size_t __iovec_copy_from_user_inatomic(char *vaddr,
87191
87192 while (bytes) {
87193 char __user *buf = iov->iov_base + base;
87194 - int copy = min(bytes, iov->iov_len - base);
87195 + size_t copy = min(bytes, iov->iov_len - base);
87196
87197 base = 0;
87198 left = __copy_from_user_inatomic(vaddr, buf, copy);
87199 @@ -1979,7 +1979,7 @@ size_t iov_iter_copy_from_user_atomic(struct page *page,
87200 BUG_ON(!in_atomic());
87201 kaddr = kmap_atomic(page);
87202 if (likely(i->nr_segs == 1)) {
87203 - int left;
87204 + size_t left;
87205 char __user *buf = i->iov->iov_base + i->iov_offset;
87206 left = __copy_from_user_inatomic(kaddr + offset, buf, bytes);
87207 copied = bytes - left;
87208 @@ -2007,7 +2007,7 @@ size_t iov_iter_copy_from_user(struct page *page,
87209
87210 kaddr = kmap(page);
87211 if (likely(i->nr_segs == 1)) {
87212 - int left;
87213 + size_t left;
87214 char __user *buf = i->iov->iov_base + i->iov_offset;
87215 left = __copy_from_user(kaddr + offset, buf, bytes);
87216 copied = bytes - left;
87217 @@ -2037,7 +2037,7 @@ void iov_iter_advance(struct iov_iter *i, size_t bytes)
87218 * zero-length segments (without overruning the iovec).
87219 */
87220 while (bytes || unlikely(i->count && !iov->iov_len)) {
87221 - int copy;
87222 + size_t copy;
87223
87224 copy = min(bytes, iov->iov_len - base);
87225 BUG_ON(!i->count || i->count < copy);
87226 @@ -2108,6 +2108,7 @@ inline int generic_write_checks(struct file *file, loff_t *pos, size_t *count, i
87227 *pos = i_size_read(inode);
87228
87229 if (limit != RLIM_INFINITY) {
87230 + gr_learn_resource(current, RLIMIT_FSIZE,*pos, 0);
87231 if (*pos >= limit) {
87232 send_sig(SIGXFSZ, current, 0);
87233 return -EFBIG;
87234 diff --git a/mm/fremap.c b/mm/fremap.c
87235 index 5bff081..d8189a9 100644
87236 --- a/mm/fremap.c
87237 +++ b/mm/fremap.c
87238 @@ -163,6 +163,11 @@ SYSCALL_DEFINE5(remap_file_pages, unsigned long, start, unsigned long, size,
87239 retry:
87240 vma = find_vma(mm, start);
87241
87242 +#ifdef CONFIG_PAX_SEGMEXEC
87243 + if (vma && (mm->pax_flags & MF_PAX_SEGMEXEC) && (vma->vm_flags & VM_MAYEXEC))
87244 + goto out;
87245 +#endif
87246 +
87247 /*
87248 * Make sure the vma is shared, that it supports prefaulting,
87249 * and that the remapped range is valid and fully within
87250 diff --git a/mm/highmem.c b/mm/highmem.c
87251 index b32b70c..e512eb0 100644
87252 --- a/mm/highmem.c
87253 +++ b/mm/highmem.c
87254 @@ -138,8 +138,9 @@ static void flush_all_zero_pkmaps(void)
87255 * So no dangers, even with speculative execution.
87256 */
87257 page = pte_page(pkmap_page_table[i]);
87258 + pax_open_kernel();
87259 pte_clear(&init_mm, PKMAP_ADDR(i), &pkmap_page_table[i]);
87260 -
87261 + pax_close_kernel();
87262 set_page_address(page, NULL);
87263 need_flush = 1;
87264 }
87265 @@ -198,9 +199,11 @@ start:
87266 }
87267 }
87268 vaddr = PKMAP_ADDR(last_pkmap_nr);
87269 +
87270 + pax_open_kernel();
87271 set_pte_at(&init_mm, vaddr,
87272 &(pkmap_page_table[last_pkmap_nr]), mk_pte(page, kmap_prot));
87273 -
87274 + pax_close_kernel();
87275 pkmap_count[last_pkmap_nr] = 1;
87276 set_page_address(page, (void *)vaddr);
87277
87278 diff --git a/mm/hugetlb.c b/mm/hugetlb.c
87279 index 0b7656e..d21cefc 100644
87280 --- a/mm/hugetlb.c
87281 +++ b/mm/hugetlb.c
87282 @@ -2094,15 +2094,17 @@ static int hugetlb_sysctl_handler_common(bool obey_mempolicy,
87283 struct hstate *h = &default_hstate;
87284 unsigned long tmp;
87285 int ret;
87286 + ctl_table_no_const hugetlb_table;
87287
87288 tmp = h->max_huge_pages;
87289
87290 if (write && h->order >= MAX_ORDER)
87291 return -EINVAL;
87292
87293 - table->data = &tmp;
87294 - table->maxlen = sizeof(unsigned long);
87295 - ret = proc_doulongvec_minmax(table, write, buffer, length, ppos);
87296 + hugetlb_table = *table;
87297 + hugetlb_table.data = &tmp;
87298 + hugetlb_table.maxlen = sizeof(unsigned long);
87299 + ret = proc_doulongvec_minmax(&hugetlb_table, write, buffer, length, ppos);
87300 if (ret)
87301 goto out;
87302
87303 @@ -2147,15 +2149,17 @@ int hugetlb_overcommit_handler(struct ctl_table *table, int write,
87304 struct hstate *h = &default_hstate;
87305 unsigned long tmp;
87306 int ret;
87307 + ctl_table_no_const hugetlb_table;
87308
87309 tmp = h->nr_overcommit_huge_pages;
87310
87311 if (write && h->order >= MAX_ORDER)
87312 return -EINVAL;
87313
87314 - table->data = &tmp;
87315 - table->maxlen = sizeof(unsigned long);
87316 - ret = proc_doulongvec_minmax(table, write, buffer, length, ppos);
87317 + hugetlb_table = *table;
87318 + hugetlb_table.data = &tmp;
87319 + hugetlb_table.maxlen = sizeof(unsigned long);
87320 + ret = proc_doulongvec_minmax(&hugetlb_table, write, buffer, length, ppos);
87321 if (ret)
87322 goto out;
87323
87324 @@ -2605,6 +2609,27 @@ static int unmap_ref_private(struct mm_struct *mm, struct vm_area_struct *vma,
87325 return 1;
87326 }
87327
87328 +#ifdef CONFIG_PAX_SEGMEXEC
87329 +static void pax_mirror_huge_pte(struct vm_area_struct *vma, unsigned long address, struct page *page_m)
87330 +{
87331 + struct mm_struct *mm = vma->vm_mm;
87332 + struct vm_area_struct *vma_m;
87333 + unsigned long address_m;
87334 + pte_t *ptep_m;
87335 +
87336 + vma_m = pax_find_mirror_vma(vma);
87337 + if (!vma_m)
87338 + return;
87339 +
87340 + BUG_ON(address >= SEGMEXEC_TASK_SIZE);
87341 + address_m = address + SEGMEXEC_TASK_SIZE;
87342 + ptep_m = huge_pte_offset(mm, address_m & HPAGE_MASK);
87343 + get_page(page_m);
87344 + hugepage_add_anon_rmap(page_m, vma_m, address_m);
87345 + set_huge_pte_at(mm, address_m, ptep_m, make_huge_pte(vma_m, page_m, 0));
87346 +}
87347 +#endif
87348 +
87349 /*
87350 * Hugetlb_cow() should be called with page lock of the original hugepage held.
87351 * Called with hugetlb_instantiation_mutex held and pte_page locked so we
87352 @@ -2721,6 +2746,11 @@ retry_avoidcopy:
87353 make_huge_pte(vma, new_page, 1));
87354 page_remove_rmap(old_page);
87355 hugepage_add_new_anon_rmap(new_page, vma, address);
87356 +
87357 +#ifdef CONFIG_PAX_SEGMEXEC
87358 + pax_mirror_huge_pte(vma, address, new_page);
87359 +#endif
87360 +
87361 /* Make the old page be freed below */
87362 new_page = old_page;
87363 }
87364 @@ -2883,6 +2913,10 @@ retry:
87365 && (vma->vm_flags & VM_SHARED)));
87366 set_huge_pte_at(mm, address, ptep, new_pte);
87367
87368 +#ifdef CONFIG_PAX_SEGMEXEC
87369 + pax_mirror_huge_pte(vma, address, page);
87370 +#endif
87371 +
87372 if ((flags & FAULT_FLAG_WRITE) && !(vma->vm_flags & VM_SHARED)) {
87373 /* Optimization, do the COW without a second fault */
87374 ret = hugetlb_cow(mm, vma, address, ptep, new_pte, page);
87375 @@ -2912,6 +2946,10 @@ int hugetlb_fault(struct mm_struct *mm, struct vm_area_struct *vma,
87376 static DEFINE_MUTEX(hugetlb_instantiation_mutex);
87377 struct hstate *h = hstate_vma(vma);
87378
87379 +#ifdef CONFIG_PAX_SEGMEXEC
87380 + struct vm_area_struct *vma_m;
87381 +#endif
87382 +
87383 address &= huge_page_mask(h);
87384
87385 ptep = huge_pte_offset(mm, address);
87386 @@ -2925,6 +2963,26 @@ int hugetlb_fault(struct mm_struct *mm, struct vm_area_struct *vma,
87387 VM_FAULT_SET_HINDEX(hstate_index(h));
87388 }
87389
87390 +#ifdef CONFIG_PAX_SEGMEXEC
87391 + vma_m = pax_find_mirror_vma(vma);
87392 + if (vma_m) {
87393 + unsigned long address_m;
87394 +
87395 + if (vma->vm_start > vma_m->vm_start) {
87396 + address_m = address;
87397 + address -= SEGMEXEC_TASK_SIZE;
87398 + vma = vma_m;
87399 + h = hstate_vma(vma);
87400 + } else
87401 + address_m = address + SEGMEXEC_TASK_SIZE;
87402 +
87403 + if (!huge_pte_alloc(mm, address_m, huge_page_size(h)))
87404 + return VM_FAULT_OOM;
87405 + address_m &= HPAGE_MASK;
87406 + unmap_hugepage_range(vma, address_m, address_m + HPAGE_SIZE, NULL);
87407 + }
87408 +#endif
87409 +
87410 ptep = huge_pte_alloc(mm, address, huge_page_size(h));
87411 if (!ptep)
87412 return VM_FAULT_OOM;
87413 diff --git a/mm/internal.h b/mm/internal.h
87414 index 684f7aa..9eb9edc 100644
87415 --- a/mm/internal.h
87416 +++ b/mm/internal.h
87417 @@ -97,6 +97,7 @@ extern pmd_t *mm_find_pmd(struct mm_struct *mm, unsigned long address);
87418 * in mm/page_alloc.c
87419 */
87420 extern void __free_pages_bootmem(struct page *page, unsigned int order);
87421 +extern void free_compound_page(struct page *page);
87422 extern void prep_compound_page(struct page *page, unsigned long order);
87423 #ifdef CONFIG_MEMORY_FAILURE
87424 extern bool is_free_buddy_page(struct page *page);
87425 @@ -352,7 +353,7 @@ extern u32 hwpoison_filter_enable;
87426
87427 extern unsigned long vm_mmap_pgoff(struct file *, unsigned long,
87428 unsigned long, unsigned long,
87429 - unsigned long, unsigned long);
87430 + unsigned long, unsigned long) __intentional_overflow(-1);
87431
87432 extern void set_pageblock_order(void);
87433 unsigned long reclaim_clean_pages_from_list(struct zone *zone,
87434 diff --git a/mm/kmemleak.c b/mm/kmemleak.c
87435 index e126b0e..e986018 100644
87436 --- a/mm/kmemleak.c
87437 +++ b/mm/kmemleak.c
87438 @@ -363,7 +363,7 @@ static void print_unreferenced(struct seq_file *seq,
87439
87440 for (i = 0; i < object->trace_len; i++) {
87441 void *ptr = (void *)object->trace[i];
87442 - seq_printf(seq, " [<%p>] %pS\n", ptr, ptr);
87443 + seq_printf(seq, " [<%pP>] %pA\n", ptr, ptr);
87444 }
87445 }
87446
87447 @@ -1851,7 +1851,7 @@ static int __init kmemleak_late_init(void)
87448 return -ENOMEM;
87449 }
87450
87451 - dentry = debugfs_create_file("kmemleak", S_IRUGO, NULL, NULL,
87452 + dentry = debugfs_create_file("kmemleak", S_IRUSR, NULL, NULL,
87453 &kmemleak_fops);
87454 if (!dentry)
87455 pr_warning("Failed to create the debugfs kmemleak file\n");
87456 diff --git a/mm/maccess.c b/mm/maccess.c
87457 index d53adf9..03a24bf 100644
87458 --- a/mm/maccess.c
87459 +++ b/mm/maccess.c
87460 @@ -26,7 +26,7 @@ long __probe_kernel_read(void *dst, const void *src, size_t size)
87461 set_fs(KERNEL_DS);
87462 pagefault_disable();
87463 ret = __copy_from_user_inatomic(dst,
87464 - (__force const void __user *)src, size);
87465 + (const void __force_user *)src, size);
87466 pagefault_enable();
87467 set_fs(old_fs);
87468
87469 @@ -53,7 +53,7 @@ long __probe_kernel_write(void *dst, const void *src, size_t size)
87470
87471 set_fs(KERNEL_DS);
87472 pagefault_disable();
87473 - ret = __copy_to_user_inatomic((__force void __user *)dst, src, size);
87474 + ret = __copy_to_user_inatomic((void __force_user *)dst, src, size);
87475 pagefault_enable();
87476 set_fs(old_fs);
87477
87478 diff --git a/mm/madvise.c b/mm/madvise.c
87479 index 539eeb9..e24a987 100644
87480 --- a/mm/madvise.c
87481 +++ b/mm/madvise.c
87482 @@ -51,6 +51,10 @@ static long madvise_behavior(struct vm_area_struct *vma,
87483 pgoff_t pgoff;
87484 unsigned long new_flags = vma->vm_flags;
87485
87486 +#ifdef CONFIG_PAX_SEGMEXEC
87487 + struct vm_area_struct *vma_m;
87488 +#endif
87489 +
87490 switch (behavior) {
87491 case MADV_NORMAL:
87492 new_flags = new_flags & ~VM_RAND_READ & ~VM_SEQ_READ;
87493 @@ -126,6 +130,13 @@ success:
87494 /*
87495 * vm_flags is protected by the mmap_sem held in write mode.
87496 */
87497 +
87498 +#ifdef CONFIG_PAX_SEGMEXEC
87499 + vma_m = pax_find_mirror_vma(vma);
87500 + if (vma_m)
87501 + vma_m->vm_flags = new_flags & ~(VM_WRITE | VM_MAYWRITE | VM_ACCOUNT);
87502 +#endif
87503 +
87504 vma->vm_flags = new_flags;
87505
87506 out:
87507 @@ -274,6 +285,11 @@ static long madvise_dontneed(struct vm_area_struct *vma,
87508 struct vm_area_struct **prev,
87509 unsigned long start, unsigned long end)
87510 {
87511 +
87512 +#ifdef CONFIG_PAX_SEGMEXEC
87513 + struct vm_area_struct *vma_m;
87514 +#endif
87515 +
87516 *prev = vma;
87517 if (vma->vm_flags & (VM_LOCKED|VM_HUGETLB|VM_PFNMAP))
87518 return -EINVAL;
87519 @@ -286,6 +302,21 @@ static long madvise_dontneed(struct vm_area_struct *vma,
87520 zap_page_range(vma, start, end - start, &details);
87521 } else
87522 zap_page_range(vma, start, end - start, NULL);
87523 +
87524 +#ifdef CONFIG_PAX_SEGMEXEC
87525 + vma_m = pax_find_mirror_vma(vma);
87526 + if (vma_m) {
87527 + if (unlikely(vma->vm_flags & VM_NONLINEAR)) {
87528 + struct zap_details details = {
87529 + .nonlinear_vma = vma_m,
87530 + .last_index = ULONG_MAX,
87531 + };
87532 + zap_page_range(vma, start + SEGMEXEC_TASK_SIZE, end - start, &details);
87533 + } else
87534 + zap_page_range(vma, start + SEGMEXEC_TASK_SIZE, end - start, NULL);
87535 + }
87536 +#endif
87537 +
87538 return 0;
87539 }
87540
87541 @@ -491,6 +522,16 @@ SYSCALL_DEFINE3(madvise, unsigned long, start, size_t, len_in, int, behavior)
87542 if (end < start)
87543 return error;
87544
87545 +#ifdef CONFIG_PAX_SEGMEXEC
87546 + if (current->mm->pax_flags & MF_PAX_SEGMEXEC) {
87547 + if (end > SEGMEXEC_TASK_SIZE)
87548 + return error;
87549 + } else
87550 +#endif
87551 +
87552 + if (end > TASK_SIZE)
87553 + return error;
87554 +
87555 error = 0;
87556 if (end == start)
87557 return error;
87558 diff --git a/mm/memory-failure.c b/mm/memory-failure.c
87559 index bf3351b..aea800d 100644
87560 --- a/mm/memory-failure.c
87561 +++ b/mm/memory-failure.c
87562 @@ -61,7 +61,7 @@ int sysctl_memory_failure_early_kill __read_mostly = 0;
87563
87564 int sysctl_memory_failure_recovery __read_mostly = 1;
87565
87566 -atomic_long_t num_poisoned_pages __read_mostly = ATOMIC_LONG_INIT(0);
87567 +atomic_long_unchecked_t num_poisoned_pages __read_mostly = ATOMIC_LONG_INIT(0);
87568
87569 #if defined(CONFIG_HWPOISON_INJECT) || defined(CONFIG_HWPOISON_INJECT_MODULE)
87570
87571 @@ -202,7 +202,7 @@ static int kill_proc(struct task_struct *t, unsigned long addr, int trapno,
87572 pfn, t->comm, t->pid);
87573 si.si_signo = SIGBUS;
87574 si.si_errno = 0;
87575 - si.si_addr = (void *)addr;
87576 + si.si_addr = (void __user *)addr;
87577 #ifdef __ARCH_SI_TRAPNO
87578 si.si_trapno = trapno;
87579 #endif
87580 @@ -762,7 +762,7 @@ static struct page_state {
87581 unsigned long res;
87582 char *msg;
87583 int (*action)(struct page *p, unsigned long pfn);
87584 -} error_states[] = {
87585 +} __do_const error_states[] = {
87586 { reserved, reserved, "reserved kernel", me_kernel },
87587 /*
87588 * free pages are specially detected outside this table:
87589 @@ -1053,7 +1053,7 @@ int memory_failure(unsigned long pfn, int trapno, int flags)
87590 nr_pages = 1 << compound_order(hpage);
87591 else /* normal page or thp */
87592 nr_pages = 1;
87593 - atomic_long_add(nr_pages, &num_poisoned_pages);
87594 + atomic_long_add_unchecked(nr_pages, &num_poisoned_pages);
87595
87596 /*
87597 * We need/can do nothing about count=0 pages.
87598 @@ -1083,7 +1083,7 @@ int memory_failure(unsigned long pfn, int trapno, int flags)
87599 if (!PageHWPoison(hpage)
87600 || (hwpoison_filter(p) && TestClearPageHWPoison(p))
87601 || (p != hpage && TestSetPageHWPoison(hpage))) {
87602 - atomic_long_sub(nr_pages, &num_poisoned_pages);
87603 + atomic_long_sub_unchecked(nr_pages, &num_poisoned_pages);
87604 return 0;
87605 }
87606 set_page_hwpoison_huge_page(hpage);
87607 @@ -1152,7 +1152,7 @@ int memory_failure(unsigned long pfn, int trapno, int flags)
87608 }
87609 if (hwpoison_filter(p)) {
87610 if (TestClearPageHWPoison(p))
87611 - atomic_long_sub(nr_pages, &num_poisoned_pages);
87612 + atomic_long_sub_unchecked(nr_pages, &num_poisoned_pages);
87613 unlock_page(hpage);
87614 put_page(hpage);
87615 return 0;
87616 @@ -1370,7 +1370,7 @@ int unpoison_memory(unsigned long pfn)
87617 return 0;
87618 }
87619 if (TestClearPageHWPoison(p))
87620 - atomic_long_dec(&num_poisoned_pages);
87621 + atomic_long_dec_unchecked(&num_poisoned_pages);
87622 pr_info("MCE: Software-unpoisoned free page %#lx\n", pfn);
87623 return 0;
87624 }
87625 @@ -1384,7 +1384,7 @@ int unpoison_memory(unsigned long pfn)
87626 */
87627 if (TestClearPageHWPoison(page)) {
87628 pr_info("MCE: Software-unpoisoned page %#lx\n", pfn);
87629 - atomic_long_sub(nr_pages, &num_poisoned_pages);
87630 + atomic_long_sub_unchecked(nr_pages, &num_poisoned_pages);
87631 freeit = 1;
87632 if (PageHuge(page))
87633 clear_page_hwpoison_huge_page(page);
87634 @@ -1521,7 +1521,7 @@ static int soft_offline_huge_page(struct page *page, int flags)
87635 } else {
87636 set_page_hwpoison_huge_page(hpage);
87637 dequeue_hwpoisoned_huge_page(hpage);
87638 - atomic_long_add(1 << compound_order(hpage),
87639 + atomic_long_add_unchecked(1 << compound_order(hpage),
87640 &num_poisoned_pages);
87641 }
87642 return ret;
87643 @@ -1560,7 +1560,7 @@ static int __soft_offline_page(struct page *page, int flags)
87644 put_page(page);
87645 pr_info("soft_offline: %#lx: invalidated\n", pfn);
87646 SetPageHWPoison(page);
87647 - atomic_long_inc(&num_poisoned_pages);
87648 + atomic_long_inc_unchecked(&num_poisoned_pages);
87649 return 0;
87650 }
87651
87652 @@ -1605,7 +1605,7 @@ static int __soft_offline_page(struct page *page, int flags)
87653 if (!is_free_buddy_page(page))
87654 pr_info("soft offline: %#lx: page leaked\n",
87655 pfn);
87656 - atomic_long_inc(&num_poisoned_pages);
87657 + atomic_long_inc_unchecked(&num_poisoned_pages);
87658 }
87659 } else {
87660 pr_info("soft offline: %#lx: isolation failed: %d, page count %d, type %lx\n",
87661 @@ -1666,11 +1666,11 @@ int soft_offline_page(struct page *page, int flags)
87662 if (PageHuge(page)) {
87663 set_page_hwpoison_huge_page(hpage);
87664 dequeue_hwpoisoned_huge_page(hpage);
87665 - atomic_long_add(1 << compound_order(hpage),
87666 + atomic_long_add_unchecked(1 << compound_order(hpage),
87667 &num_poisoned_pages);
87668 } else {
87669 SetPageHWPoison(page);
87670 - atomic_long_inc(&num_poisoned_pages);
87671 + atomic_long_inc_unchecked(&num_poisoned_pages);
87672 }
87673 }
87674 unset:
87675 diff --git a/mm/memory.c b/mm/memory.c
87676 index d176154..cd1b387 100644
87677 --- a/mm/memory.c
87678 +++ b/mm/memory.c
87679 @@ -402,6 +402,7 @@ static inline void free_pmd_range(struct mmu_gather *tlb, pud_t *pud,
87680 free_pte_range(tlb, pmd, addr);
87681 } while (pmd++, addr = next, addr != end);
87682
87683 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_PER_CPU_PGD)
87684 start &= PUD_MASK;
87685 if (start < floor)
87686 return;
87687 @@ -416,6 +417,8 @@ static inline void free_pmd_range(struct mmu_gather *tlb, pud_t *pud,
87688 pmd = pmd_offset(pud, start);
87689 pud_clear(pud);
87690 pmd_free_tlb(tlb, pmd, start);
87691 +#endif
87692 +
87693 }
87694
87695 static inline void free_pud_range(struct mmu_gather *tlb, pgd_t *pgd,
87696 @@ -435,6 +438,7 @@ static inline void free_pud_range(struct mmu_gather *tlb, pgd_t *pgd,
87697 free_pmd_range(tlb, pud, addr, next, floor, ceiling);
87698 } while (pud++, addr = next, addr != end);
87699
87700 +#if !defined(CONFIG_X86_64) || !defined(CONFIG_PAX_PER_CPU_PGD)
87701 start &= PGDIR_MASK;
87702 if (start < floor)
87703 return;
87704 @@ -449,6 +453,8 @@ static inline void free_pud_range(struct mmu_gather *tlb, pgd_t *pgd,
87705 pud = pud_offset(pgd, start);
87706 pgd_clear(pgd);
87707 pud_free_tlb(tlb, pud, start);
87708 +#endif
87709 +
87710 }
87711
87712 /*
87713 @@ -1636,12 +1642,6 @@ no_page_table:
87714 return page;
87715 }
87716
87717 -static inline int stack_guard_page(struct vm_area_struct *vma, unsigned long addr)
87718 -{
87719 - return stack_guard_page_start(vma, addr) ||
87720 - stack_guard_page_end(vma, addr+PAGE_SIZE);
87721 -}
87722 -
87723 /**
87724 * __get_user_pages() - pin user pages in memory
87725 * @tsk: task_struct of target task
87726 @@ -1728,10 +1728,10 @@ long __get_user_pages(struct task_struct *tsk, struct mm_struct *mm,
87727
87728 i = 0;
87729
87730 - do {
87731 + while (nr_pages) {
87732 struct vm_area_struct *vma;
87733
87734 - vma = find_extend_vma(mm, start);
87735 + vma = find_vma(mm, start);
87736 if (!vma && in_gate_area(mm, start)) {
87737 unsigned long pg = start & PAGE_MASK;
87738 pgd_t *pgd;
87739 @@ -1780,7 +1780,7 @@ long __get_user_pages(struct task_struct *tsk, struct mm_struct *mm,
87740 goto next_page;
87741 }
87742
87743 - if (!vma ||
87744 + if (!vma || start < vma->vm_start ||
87745 (vma->vm_flags & (VM_IO | VM_PFNMAP)) ||
87746 !(vm_flags & vma->vm_flags))
87747 return i ? : -EFAULT;
87748 @@ -1809,11 +1809,6 @@ long __get_user_pages(struct task_struct *tsk, struct mm_struct *mm,
87749 int ret;
87750 unsigned int fault_flags = 0;
87751
87752 - /* For mlock, just skip the stack guard page. */
87753 - if (foll_flags & FOLL_MLOCK) {
87754 - if (stack_guard_page(vma, start))
87755 - goto next_page;
87756 - }
87757 if (foll_flags & FOLL_WRITE)
87758 fault_flags |= FAULT_FLAG_WRITE;
87759 if (nonblocking)
87760 @@ -1893,7 +1888,7 @@ next_page:
87761 start += page_increm * PAGE_SIZE;
87762 nr_pages -= page_increm;
87763 } while (nr_pages && start < vma->vm_end);
87764 - } while (nr_pages);
87765 + }
87766 return i;
87767 }
87768 EXPORT_SYMBOL(__get_user_pages);
87769 @@ -2100,6 +2095,10 @@ static int insert_page(struct vm_area_struct *vma, unsigned long addr,
87770 page_add_file_rmap(page);
87771 set_pte_at(mm, addr, pte, mk_pte(page, prot));
87772
87773 +#ifdef CONFIG_PAX_SEGMEXEC
87774 + pax_mirror_file_pte(vma, addr, page, ptl);
87775 +#endif
87776 +
87777 retval = 0;
87778 pte_unmap_unlock(pte, ptl);
87779 return retval;
87780 @@ -2144,9 +2143,21 @@ int vm_insert_page(struct vm_area_struct *vma, unsigned long addr,
87781 if (!page_count(page))
87782 return -EINVAL;
87783 if (!(vma->vm_flags & VM_MIXEDMAP)) {
87784 +
87785 +#ifdef CONFIG_PAX_SEGMEXEC
87786 + struct vm_area_struct *vma_m;
87787 +#endif
87788 +
87789 BUG_ON(down_read_trylock(&vma->vm_mm->mmap_sem));
87790 BUG_ON(vma->vm_flags & VM_PFNMAP);
87791 vma->vm_flags |= VM_MIXEDMAP;
87792 +
87793 +#ifdef CONFIG_PAX_SEGMEXEC
87794 + vma_m = pax_find_mirror_vma(vma);
87795 + if (vma_m)
87796 + vma_m->vm_flags |= VM_MIXEDMAP;
87797 +#endif
87798 +
87799 }
87800 return insert_page(vma, addr, page, vma->vm_page_prot);
87801 }
87802 @@ -2229,6 +2240,7 @@ int vm_insert_mixed(struct vm_area_struct *vma, unsigned long addr,
87803 unsigned long pfn)
87804 {
87805 BUG_ON(!(vma->vm_flags & VM_MIXEDMAP));
87806 + BUG_ON(vma->vm_mirror);
87807
87808 if (addr < vma->vm_start || addr >= vma->vm_end)
87809 return -EFAULT;
87810 @@ -2476,7 +2488,9 @@ static int apply_to_pmd_range(struct mm_struct *mm, pud_t *pud,
87811
87812 BUG_ON(pud_huge(*pud));
87813
87814 - pmd = pmd_alloc(mm, pud, addr);
87815 + pmd = (mm == &init_mm) ?
87816 + pmd_alloc_kernel(mm, pud, addr) :
87817 + pmd_alloc(mm, pud, addr);
87818 if (!pmd)
87819 return -ENOMEM;
87820 do {
87821 @@ -2496,7 +2510,9 @@ static int apply_to_pud_range(struct mm_struct *mm, pgd_t *pgd,
87822 unsigned long next;
87823 int err;
87824
87825 - pud = pud_alloc(mm, pgd, addr);
87826 + pud = (mm == &init_mm) ?
87827 + pud_alloc_kernel(mm, pgd, addr) :
87828 + pud_alloc(mm, pgd, addr);
87829 if (!pud)
87830 return -ENOMEM;
87831 do {
87832 @@ -2584,6 +2600,186 @@ static inline void cow_user_page(struct page *dst, struct page *src, unsigned lo
87833 copy_user_highpage(dst, src, va, vma);
87834 }
87835
87836 +#ifdef CONFIG_PAX_SEGMEXEC
87837 +static void pax_unmap_mirror_pte(struct vm_area_struct *vma, unsigned long address, pmd_t *pmd)
87838 +{
87839 + struct mm_struct *mm = vma->vm_mm;
87840 + spinlock_t *ptl;
87841 + pte_t *pte, entry;
87842 +
87843 + pte = pte_offset_map_lock(mm, pmd, address, &ptl);
87844 + entry = *pte;
87845 + if (!pte_present(entry)) {
87846 + if (!pte_none(entry)) {
87847 + BUG_ON(pte_file(entry));
87848 + free_swap_and_cache(pte_to_swp_entry(entry));
87849 + pte_clear_not_present_full(mm, address, pte, 0);
87850 + }
87851 + } else {
87852 + struct page *page;
87853 +
87854 + flush_cache_page(vma, address, pte_pfn(entry));
87855 + entry = ptep_clear_flush(vma, address, pte);
87856 + BUG_ON(pte_dirty(entry));
87857 + page = vm_normal_page(vma, address, entry);
87858 + if (page) {
87859 + update_hiwater_rss(mm);
87860 + if (PageAnon(page))
87861 + dec_mm_counter_fast(mm, MM_ANONPAGES);
87862 + else
87863 + dec_mm_counter_fast(mm, MM_FILEPAGES);
87864 + page_remove_rmap(page);
87865 + page_cache_release(page);
87866 + }
87867 + }
87868 + pte_unmap_unlock(pte, ptl);
87869 +}
87870 +
87871 +/* PaX: if vma is mirrored, synchronize the mirror's PTE
87872 + *
87873 + * the ptl of the lower mapped page is held on entry and is not released on exit
87874 + * or inside to ensure atomic changes to the PTE states (swapout, mremap, munmap, etc)
87875 + */
87876 +static void pax_mirror_anon_pte(struct vm_area_struct *vma, unsigned long address, struct page *page_m, spinlock_t *ptl)
87877 +{
87878 + struct mm_struct *mm = vma->vm_mm;
87879 + unsigned long address_m;
87880 + spinlock_t *ptl_m;
87881 + struct vm_area_struct *vma_m;
87882 + pmd_t *pmd_m;
87883 + pte_t *pte_m, entry_m;
87884 +
87885 + BUG_ON(!page_m || !PageAnon(page_m));
87886 +
87887 + vma_m = pax_find_mirror_vma(vma);
87888 + if (!vma_m)
87889 + return;
87890 +
87891 + BUG_ON(!PageLocked(page_m));
87892 + BUG_ON(address >= SEGMEXEC_TASK_SIZE);
87893 + address_m = address + SEGMEXEC_TASK_SIZE;
87894 + pmd_m = pmd_offset(pud_offset(pgd_offset(mm, address_m), address_m), address_m);
87895 + pte_m = pte_offset_map(pmd_m, address_m);
87896 + ptl_m = pte_lockptr(mm, pmd_m);
87897 + if (ptl != ptl_m) {
87898 + spin_lock_nested(ptl_m, SINGLE_DEPTH_NESTING);
87899 + if (!pte_none(*pte_m))
87900 + goto out;
87901 + }
87902 +
87903 + entry_m = pfn_pte(page_to_pfn(page_m), vma_m->vm_page_prot);
87904 + page_cache_get(page_m);
87905 + page_add_anon_rmap(page_m, vma_m, address_m);
87906 + inc_mm_counter_fast(mm, MM_ANONPAGES);
87907 + set_pte_at(mm, address_m, pte_m, entry_m);
87908 + update_mmu_cache(vma_m, address_m, pte_m);
87909 +out:
87910 + if (ptl != ptl_m)
87911 + spin_unlock(ptl_m);
87912 + pte_unmap(pte_m);
87913 + unlock_page(page_m);
87914 +}
87915 +
87916 +void pax_mirror_file_pte(struct vm_area_struct *vma, unsigned long address, struct page *page_m, spinlock_t *ptl)
87917 +{
87918 + struct mm_struct *mm = vma->vm_mm;
87919 + unsigned long address_m;
87920 + spinlock_t *ptl_m;
87921 + struct vm_area_struct *vma_m;
87922 + pmd_t *pmd_m;
87923 + pte_t *pte_m, entry_m;
87924 +
87925 + BUG_ON(!page_m || PageAnon(page_m));
87926 +
87927 + vma_m = pax_find_mirror_vma(vma);
87928 + if (!vma_m)
87929 + return;
87930 +
87931 + BUG_ON(address >= SEGMEXEC_TASK_SIZE);
87932 + address_m = address + SEGMEXEC_TASK_SIZE;
87933 + pmd_m = pmd_offset(pud_offset(pgd_offset(mm, address_m), address_m), address_m);
87934 + pte_m = pte_offset_map(pmd_m, address_m);
87935 + ptl_m = pte_lockptr(mm, pmd_m);
87936 + if (ptl != ptl_m) {
87937 + spin_lock_nested(ptl_m, SINGLE_DEPTH_NESTING);
87938 + if (!pte_none(*pte_m))
87939 + goto out;
87940 + }
87941 +
87942 + entry_m = pfn_pte(page_to_pfn(page_m), vma_m->vm_page_prot);
87943 + page_cache_get(page_m);
87944 + page_add_file_rmap(page_m);
87945 + inc_mm_counter_fast(mm, MM_FILEPAGES);
87946 + set_pte_at(mm, address_m, pte_m, entry_m);
87947 + update_mmu_cache(vma_m, address_m, pte_m);
87948 +out:
87949 + if (ptl != ptl_m)
87950 + spin_unlock(ptl_m);
87951 + pte_unmap(pte_m);
87952 +}
87953 +
87954 +static void pax_mirror_pfn_pte(struct vm_area_struct *vma, unsigned long address, unsigned long pfn_m, spinlock_t *ptl)
87955 +{
87956 + struct mm_struct *mm = vma->vm_mm;
87957 + unsigned long address_m;
87958 + spinlock_t *ptl_m;
87959 + struct vm_area_struct *vma_m;
87960 + pmd_t *pmd_m;
87961 + pte_t *pte_m, entry_m;
87962 +
87963 + vma_m = pax_find_mirror_vma(vma);
87964 + if (!vma_m)
87965 + return;
87966 +
87967 + BUG_ON(address >= SEGMEXEC_TASK_SIZE);
87968 + address_m = address + SEGMEXEC_TASK_SIZE;
87969 + pmd_m = pmd_offset(pud_offset(pgd_offset(mm, address_m), address_m), address_m);
87970 + pte_m = pte_offset_map(pmd_m, address_m);
87971 + ptl_m = pte_lockptr(mm, pmd_m);
87972 + if (ptl != ptl_m) {
87973 + spin_lock_nested(ptl_m, SINGLE_DEPTH_NESTING);
87974 + if (!pte_none(*pte_m))
87975 + goto out;
87976 + }
87977 +
87978 + entry_m = pfn_pte(pfn_m, vma_m->vm_page_prot);
87979 + set_pte_at(mm, address_m, pte_m, entry_m);
87980 +out:
87981 + if (ptl != ptl_m)
87982 + spin_unlock(ptl_m);
87983 + pte_unmap(pte_m);
87984 +}
87985 +
87986 +static void pax_mirror_pte(struct vm_area_struct *vma, unsigned long address, pte_t *pte, pmd_t *pmd, spinlock_t *ptl)
87987 +{
87988 + struct page *page_m;
87989 + pte_t entry;
87990 +
87991 + if (!(vma->vm_mm->pax_flags & MF_PAX_SEGMEXEC))
87992 + goto out;
87993 +
87994 + entry = *pte;
87995 + page_m = vm_normal_page(vma, address, entry);
87996 + if (!page_m)
87997 + pax_mirror_pfn_pte(vma, address, pte_pfn(entry), ptl);
87998 + else if (PageAnon(page_m)) {
87999 + if (pax_find_mirror_vma(vma)) {
88000 + pte_unmap_unlock(pte, ptl);
88001 + lock_page(page_m);
88002 + pte = pte_offset_map_lock(vma->vm_mm, pmd, address, &ptl);
88003 + if (pte_same(entry, *pte))
88004 + pax_mirror_anon_pte(vma, address, page_m, ptl);
88005 + else
88006 + unlock_page(page_m);
88007 + }
88008 + } else
88009 + pax_mirror_file_pte(vma, address, page_m, ptl);
88010 +
88011 +out:
88012 + pte_unmap_unlock(pte, ptl);
88013 +}
88014 +#endif
88015 +
88016 /*
88017 * This routine handles present pages, when users try to write
88018 * to a shared page. It is done by copying the page to a new address
88019 @@ -2800,6 +2996,12 @@ gotten:
88020 */
88021 page_table = pte_offset_map_lock(mm, pmd, address, &ptl);
88022 if (likely(pte_same(*page_table, orig_pte))) {
88023 +
88024 +#ifdef CONFIG_PAX_SEGMEXEC
88025 + if (pax_find_mirror_vma(vma))
88026 + BUG_ON(!trylock_page(new_page));
88027 +#endif
88028 +
88029 if (old_page) {
88030 if (!PageAnon(old_page)) {
88031 dec_mm_counter_fast(mm, MM_FILEPAGES);
88032 @@ -2851,6 +3053,10 @@ gotten:
88033 page_remove_rmap(old_page);
88034 }
88035
88036 +#ifdef CONFIG_PAX_SEGMEXEC
88037 + pax_mirror_anon_pte(vma, address, new_page, ptl);
88038 +#endif
88039 +
88040 /* Free the old page.. */
88041 new_page = old_page;
88042 ret |= VM_FAULT_WRITE;
88043 @@ -3128,6 +3334,11 @@ static int do_swap_page(struct mm_struct *mm, struct vm_area_struct *vma,
88044 swap_free(entry);
88045 if (vm_swap_full() || (vma->vm_flags & VM_LOCKED) || PageMlocked(page))
88046 try_to_free_swap(page);
88047 +
88048 +#ifdef CONFIG_PAX_SEGMEXEC
88049 + if ((flags & FAULT_FLAG_WRITE) || !pax_find_mirror_vma(vma))
88050 +#endif
88051 +
88052 unlock_page(page);
88053 if (page != swapcache) {
88054 /*
88055 @@ -3151,6 +3362,11 @@ static int do_swap_page(struct mm_struct *mm, struct vm_area_struct *vma,
88056
88057 /* No need to invalidate - it was non-present before */
88058 update_mmu_cache(vma, address, page_table);
88059 +
88060 +#ifdef CONFIG_PAX_SEGMEXEC
88061 + pax_mirror_anon_pte(vma, address, page, ptl);
88062 +#endif
88063 +
88064 unlock:
88065 pte_unmap_unlock(page_table, ptl);
88066 out:
88067 @@ -3170,40 +3386,6 @@ out_release:
88068 }
88069
88070 /*
88071 - * This is like a special single-page "expand_{down|up}wards()",
88072 - * except we must first make sure that 'address{-|+}PAGE_SIZE'
88073 - * doesn't hit another vma.
88074 - */
88075 -static inline int check_stack_guard_page(struct vm_area_struct *vma, unsigned long address)
88076 -{
88077 - address &= PAGE_MASK;
88078 - if ((vma->vm_flags & VM_GROWSDOWN) && address == vma->vm_start) {
88079 - struct vm_area_struct *prev = vma->vm_prev;
88080 -
88081 - /*
88082 - * Is there a mapping abutting this one below?
88083 - *
88084 - * That's only ok if it's the same stack mapping
88085 - * that has gotten split..
88086 - */
88087 - if (prev && prev->vm_end == address)
88088 - return prev->vm_flags & VM_GROWSDOWN ? 0 : -ENOMEM;
88089 -
88090 - expand_downwards(vma, address - PAGE_SIZE);
88091 - }
88092 - if ((vma->vm_flags & VM_GROWSUP) && address + PAGE_SIZE == vma->vm_end) {
88093 - struct vm_area_struct *next = vma->vm_next;
88094 -
88095 - /* As VM_GROWSDOWN but s/below/above/ */
88096 - if (next && next->vm_start == address + PAGE_SIZE)
88097 - return next->vm_flags & VM_GROWSUP ? 0 : -ENOMEM;
88098 -
88099 - expand_upwards(vma, address + PAGE_SIZE);
88100 - }
88101 - return 0;
88102 -}
88103 -
88104 -/*
88105 * We enter with non-exclusive mmap_sem (to exclude vma changes,
88106 * but allow concurrent faults), and pte mapped but not yet locked.
88107 * We return with mmap_sem still held, but pte unmapped and unlocked.
88108 @@ -3212,27 +3394,23 @@ static int do_anonymous_page(struct mm_struct *mm, struct vm_area_struct *vma,
88109 unsigned long address, pte_t *page_table, pmd_t *pmd,
88110 unsigned int flags)
88111 {
88112 - struct page *page;
88113 + struct page *page = NULL;
88114 spinlock_t *ptl;
88115 pte_t entry;
88116
88117 - pte_unmap(page_table);
88118 -
88119 - /* Check if we need to add a guard page to the stack */
88120 - if (check_stack_guard_page(vma, address) < 0)
88121 - return VM_FAULT_SIGBUS;
88122 -
88123 - /* Use the zero-page for reads */
88124 if (!(flags & FAULT_FLAG_WRITE)) {
88125 entry = pte_mkspecial(pfn_pte(my_zero_pfn(address),
88126 vma->vm_page_prot));
88127 - page_table = pte_offset_map_lock(mm, pmd, address, &ptl);
88128 + ptl = pte_lockptr(mm, pmd);
88129 + spin_lock(ptl);
88130 if (!pte_none(*page_table))
88131 goto unlock;
88132 goto setpte;
88133 }
88134
88135 /* Allocate our own private page. */
88136 + pte_unmap(page_table);
88137 +
88138 if (unlikely(anon_vma_prepare(vma)))
88139 goto oom;
88140 page = alloc_zeroed_user_highpage_movable(vma, address);
88141 @@ -3256,6 +3434,11 @@ static int do_anonymous_page(struct mm_struct *mm, struct vm_area_struct *vma,
88142 if (!pte_none(*page_table))
88143 goto release;
88144
88145 +#ifdef CONFIG_PAX_SEGMEXEC
88146 + if (pax_find_mirror_vma(vma))
88147 + BUG_ON(!trylock_page(page));
88148 +#endif
88149 +
88150 inc_mm_counter_fast(mm, MM_ANONPAGES);
88151 page_add_new_anon_rmap(page, vma, address);
88152 setpte:
88153 @@ -3263,6 +3446,12 @@ setpte:
88154
88155 /* No need to invalidate - it was non-present before */
88156 update_mmu_cache(vma, address, page_table);
88157 +
88158 +#ifdef CONFIG_PAX_SEGMEXEC
88159 + if (page)
88160 + pax_mirror_anon_pte(vma, address, page, ptl);
88161 +#endif
88162 +
88163 unlock:
88164 pte_unmap_unlock(page_table, ptl);
88165 return 0;
88166 @@ -3406,6 +3595,12 @@ static int __do_fault(struct mm_struct *mm, struct vm_area_struct *vma,
88167 */
88168 /* Only go through if we didn't race with anybody else... */
88169 if (likely(pte_same(*page_table, orig_pte))) {
88170 +
88171 +#ifdef CONFIG_PAX_SEGMEXEC
88172 + if (anon && pax_find_mirror_vma(vma))
88173 + BUG_ON(!trylock_page(page));
88174 +#endif
88175 +
88176 flush_icache_page(vma, page);
88177 entry = mk_pte(page, vma->vm_page_prot);
88178 if (flags & FAULT_FLAG_WRITE)
88179 @@ -3427,6 +3622,14 @@ static int __do_fault(struct mm_struct *mm, struct vm_area_struct *vma,
88180
88181 /* no need to invalidate: a not-present page won't be cached */
88182 update_mmu_cache(vma, address, page_table);
88183 +
88184 +#ifdef CONFIG_PAX_SEGMEXEC
88185 + if (anon)
88186 + pax_mirror_anon_pte(vma, address, page, ptl);
88187 + else
88188 + pax_mirror_file_pte(vma, address, page, ptl);
88189 +#endif
88190 +
88191 } else {
88192 if (cow_page)
88193 mem_cgroup_uncharge_page(cow_page);
88194 @@ -3737,6 +3940,12 @@ static int handle_pte_fault(struct mm_struct *mm,
88195 if (flags & FAULT_FLAG_WRITE)
88196 flush_tlb_fix_spurious_fault(vma, address);
88197 }
88198 +
88199 +#ifdef CONFIG_PAX_SEGMEXEC
88200 + pax_mirror_pte(vma, address, pte, pmd, ptl);
88201 + return 0;
88202 +#endif
88203 +
88204 unlock:
88205 pte_unmap_unlock(pte, ptl);
88206 return 0;
88207 @@ -3753,9 +3962,41 @@ static int __handle_mm_fault(struct mm_struct *mm, struct vm_area_struct *vma,
88208 pmd_t *pmd;
88209 pte_t *pte;
88210
88211 +#ifdef CONFIG_PAX_SEGMEXEC
88212 + struct vm_area_struct *vma_m;
88213 +#endif
88214 +
88215 if (unlikely(is_vm_hugetlb_page(vma)))
88216 return hugetlb_fault(mm, vma, address, flags);
88217
88218 +#ifdef CONFIG_PAX_SEGMEXEC
88219 + vma_m = pax_find_mirror_vma(vma);
88220 + if (vma_m) {
88221 + unsigned long address_m;
88222 + pgd_t *pgd_m;
88223 + pud_t *pud_m;
88224 + pmd_t *pmd_m;
88225 +
88226 + if (vma->vm_start > vma_m->vm_start) {
88227 + address_m = address;
88228 + address -= SEGMEXEC_TASK_SIZE;
88229 + vma = vma_m;
88230 + } else
88231 + address_m = address + SEGMEXEC_TASK_SIZE;
88232 +
88233 + pgd_m = pgd_offset(mm, address_m);
88234 + pud_m = pud_alloc(mm, pgd_m, address_m);
88235 + if (!pud_m)
88236 + return VM_FAULT_OOM;
88237 + pmd_m = pmd_alloc(mm, pud_m, address_m);
88238 + if (!pmd_m)
88239 + return VM_FAULT_OOM;
88240 + if (!pmd_present(*pmd_m) && __pte_alloc(mm, vma_m, pmd_m, address_m))
88241 + return VM_FAULT_OOM;
88242 + pax_unmap_mirror_pte(vma_m, address_m, pmd_m);
88243 + }
88244 +#endif
88245 +
88246 retry:
88247 pgd = pgd_offset(mm, address);
88248 pud = pud_alloc(mm, pgd, address);
88249 @@ -3894,6 +4135,23 @@ int __pud_alloc(struct mm_struct *mm, pgd_t *pgd, unsigned long address)
88250 spin_unlock(&mm->page_table_lock);
88251 return 0;
88252 }
88253 +
88254 +int __pud_alloc_kernel(struct mm_struct *mm, pgd_t *pgd, unsigned long address)
88255 +{
88256 + pud_t *new = pud_alloc_one(mm, address);
88257 + if (!new)
88258 + return -ENOMEM;
88259 +
88260 + smp_wmb(); /* See comment in __pte_alloc */
88261 +
88262 + spin_lock(&mm->page_table_lock);
88263 + if (pgd_present(*pgd)) /* Another has populated it */
88264 + pud_free(mm, new);
88265 + else
88266 + pgd_populate_kernel(mm, pgd, new);
88267 + spin_unlock(&mm->page_table_lock);
88268 + return 0;
88269 +}
88270 #endif /* __PAGETABLE_PUD_FOLDED */
88271
88272 #ifndef __PAGETABLE_PMD_FOLDED
88273 @@ -3924,6 +4182,30 @@ int __pmd_alloc(struct mm_struct *mm, pud_t *pud, unsigned long address)
88274 spin_unlock(&mm->page_table_lock);
88275 return 0;
88276 }
88277 +
88278 +int __pmd_alloc_kernel(struct mm_struct *mm, pud_t *pud, unsigned long address)
88279 +{
88280 + pmd_t *new = pmd_alloc_one(mm, address);
88281 + if (!new)
88282 + return -ENOMEM;
88283 +
88284 + smp_wmb(); /* See comment in __pte_alloc */
88285 +
88286 + spin_lock(&mm->page_table_lock);
88287 +#ifndef __ARCH_HAS_4LEVEL_HACK
88288 + if (pud_present(*pud)) /* Another has populated it */
88289 + pmd_free(mm, new);
88290 + else
88291 + pud_populate_kernel(mm, pud, new);
88292 +#else
88293 + if (pgd_present(*pud)) /* Another has populated it */
88294 + pmd_free(mm, new);
88295 + else
88296 + pgd_populate_kernel(mm, pud, new);
88297 +#endif /* __ARCH_HAS_4LEVEL_HACK */
88298 + spin_unlock(&mm->page_table_lock);
88299 + return 0;
88300 +}
88301 #endif /* __PAGETABLE_PMD_FOLDED */
88302
88303 #if !defined(__HAVE_ARCH_GATE_AREA)
88304 @@ -3937,7 +4219,7 @@ static int __init gate_vma_init(void)
88305 gate_vma.vm_start = FIXADDR_USER_START;
88306 gate_vma.vm_end = FIXADDR_USER_END;
88307 gate_vma.vm_flags = VM_READ | VM_MAYREAD | VM_EXEC | VM_MAYEXEC;
88308 - gate_vma.vm_page_prot = __P101;
88309 + gate_vma.vm_page_prot = vm_get_page_prot(gate_vma.vm_flags);
88310
88311 return 0;
88312 }
88313 @@ -4071,8 +4353,8 @@ out:
88314 return ret;
88315 }
88316
88317 -int generic_access_phys(struct vm_area_struct *vma, unsigned long addr,
88318 - void *buf, int len, int write)
88319 +ssize_t generic_access_phys(struct vm_area_struct *vma, unsigned long addr,
88320 + void *buf, size_t len, int write)
88321 {
88322 resource_size_t phys_addr;
88323 unsigned long prot = 0;
88324 @@ -4098,8 +4380,8 @@ EXPORT_SYMBOL_GPL(generic_access_phys);
88325 * Access another process' address space as given in mm. If non-NULL, use the
88326 * given task for page fault accounting.
88327 */
88328 -static int __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
88329 - unsigned long addr, void *buf, int len, int write)
88330 +static ssize_t __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
88331 + unsigned long addr, void *buf, size_t len, int write)
88332 {
88333 struct vm_area_struct *vma;
88334 void *old_buf = buf;
88335 @@ -4107,7 +4389,7 @@ static int __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
88336 down_read(&mm->mmap_sem);
88337 /* ignore errors, just check how much was successfully transferred */
88338 while (len) {
88339 - int bytes, ret, offset;
88340 + ssize_t bytes, ret, offset;
88341 void *maddr;
88342 struct page *page = NULL;
88343
88344 @@ -4166,8 +4448,8 @@ static int __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
88345 *
88346 * The caller must hold a reference on @mm.
88347 */
88348 -int access_remote_vm(struct mm_struct *mm, unsigned long addr,
88349 - void *buf, int len, int write)
88350 +ssize_t access_remote_vm(struct mm_struct *mm, unsigned long addr,
88351 + void *buf, size_t len, int write)
88352 {
88353 return __access_remote_vm(NULL, mm, addr, buf, len, write);
88354 }
88355 @@ -4177,11 +4459,11 @@ int access_remote_vm(struct mm_struct *mm, unsigned long addr,
88356 * Source/target buffer must be kernel space,
88357 * Do not walk the page table directly, use get_user_pages
88358 */
88359 -int access_process_vm(struct task_struct *tsk, unsigned long addr,
88360 - void *buf, int len, int write)
88361 +ssize_t access_process_vm(struct task_struct *tsk, unsigned long addr,
88362 + void *buf, size_t len, int write)
88363 {
88364 struct mm_struct *mm;
88365 - int ret;
88366 + ssize_t ret;
88367
88368 mm = get_task_mm(tsk);
88369 if (!mm)
88370 diff --git a/mm/mempolicy.c b/mm/mempolicy.c
88371 index 0472964..7d5a0ea 100644
88372 --- a/mm/mempolicy.c
88373 +++ b/mm/mempolicy.c
88374 @@ -746,6 +746,10 @@ static int mbind_range(struct mm_struct *mm, unsigned long start,
88375 unsigned long vmstart;
88376 unsigned long vmend;
88377
88378 +#ifdef CONFIG_PAX_SEGMEXEC
88379 + struct vm_area_struct *vma_m;
88380 +#endif
88381 +
88382 vma = find_vma(mm, start);
88383 if (!vma || vma->vm_start > start)
88384 return -EFAULT;
88385 @@ -789,6 +793,16 @@ static int mbind_range(struct mm_struct *mm, unsigned long start,
88386 err = vma_replace_policy(vma, new_pol);
88387 if (err)
88388 goto out;
88389 +
88390 +#ifdef CONFIG_PAX_SEGMEXEC
88391 + vma_m = pax_find_mirror_vma(vma);
88392 + if (vma_m) {
88393 + err = vma_replace_policy(vma_m, new_pol);
88394 + if (err)
88395 + goto out;
88396 + }
88397 +#endif
88398 +
88399 }
88400
88401 out:
88402 @@ -1252,6 +1266,17 @@ static long do_mbind(unsigned long start, unsigned long len,
88403
88404 if (end < start)
88405 return -EINVAL;
88406 +
88407 +#ifdef CONFIG_PAX_SEGMEXEC
88408 + if (mm->pax_flags & MF_PAX_SEGMEXEC) {
88409 + if (end > SEGMEXEC_TASK_SIZE)
88410 + return -EINVAL;
88411 + } else
88412 +#endif
88413 +
88414 + if (end > TASK_SIZE)
88415 + return -EINVAL;
88416 +
88417 if (end == start)
88418 return 0;
88419
88420 @@ -1480,8 +1505,7 @@ SYSCALL_DEFINE4(migrate_pages, pid_t, pid, unsigned long, maxnode,
88421 */
88422 tcred = __task_cred(task);
88423 if (!uid_eq(cred->euid, tcred->suid) && !uid_eq(cred->euid, tcred->uid) &&
88424 - !uid_eq(cred->uid, tcred->suid) && !uid_eq(cred->uid, tcred->uid) &&
88425 - !capable(CAP_SYS_NICE)) {
88426 + !uid_eq(cred->uid, tcred->suid) && !capable(CAP_SYS_NICE)) {
88427 rcu_read_unlock();
88428 err = -EPERM;
88429 goto out_put;
88430 @@ -1512,6 +1536,15 @@ SYSCALL_DEFINE4(migrate_pages, pid_t, pid, unsigned long, maxnode,
88431 goto out;
88432 }
88433
88434 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
88435 + if (mm != current->mm &&
88436 + (mm->pax_flags & MF_PAX_RANDMMAP || mm->pax_flags & MF_PAX_SEGMEXEC)) {
88437 + mmput(mm);
88438 + err = -EPERM;
88439 + goto out;
88440 + }
88441 +#endif
88442 +
88443 err = do_migrate_pages(mm, old, new,
88444 capable(CAP_SYS_NICE) ? MPOL_MF_MOVE_ALL : MPOL_MF_MOVE);
88445
88446 diff --git a/mm/migrate.c b/mm/migrate.c
88447 index c046927..6996b40 100644
88448 --- a/mm/migrate.c
88449 +++ b/mm/migrate.c
88450 @@ -1404,8 +1404,7 @@ SYSCALL_DEFINE6(move_pages, pid_t, pid, unsigned long, nr_pages,
88451 */
88452 tcred = __task_cred(task);
88453 if (!uid_eq(cred->euid, tcred->suid) && !uid_eq(cred->euid, tcred->uid) &&
88454 - !uid_eq(cred->uid, tcred->suid) && !uid_eq(cred->uid, tcred->uid) &&
88455 - !capable(CAP_SYS_NICE)) {
88456 + !uid_eq(cred->uid, tcred->suid) && !capable(CAP_SYS_NICE)) {
88457 rcu_read_unlock();
88458 err = -EPERM;
88459 goto out;
88460 diff --git a/mm/mlock.c b/mm/mlock.c
88461 index d480cd6..0f98458 100644
88462 --- a/mm/mlock.c
88463 +++ b/mm/mlock.c
88464 @@ -14,6 +14,7 @@
88465 #include <linux/pagevec.h>
88466 #include <linux/mempolicy.h>
88467 #include <linux/syscalls.h>
88468 +#include <linux/security.h>
88469 #include <linux/sched.h>
88470 #include <linux/export.h>
88471 #include <linux/rmap.h>
88472 @@ -568,7 +569,7 @@ static int do_mlock(unsigned long start, size_t len, int on)
88473 {
88474 unsigned long nstart, end, tmp;
88475 struct vm_area_struct * vma, * prev;
88476 - int error;
88477 + int error = 0;
88478
88479 VM_BUG_ON(start & ~PAGE_MASK);
88480 VM_BUG_ON(len != PAGE_ALIGN(len));
88481 @@ -577,6 +578,9 @@ static int do_mlock(unsigned long start, size_t len, int on)
88482 return -EINVAL;
88483 if (end == start)
88484 return 0;
88485 + if (end > TASK_SIZE)
88486 + return -EINVAL;
88487 +
88488 vma = find_vma(current->mm, start);
88489 if (!vma || vma->vm_start > start)
88490 return -ENOMEM;
88491 @@ -588,6 +592,11 @@ static int do_mlock(unsigned long start, size_t len, int on)
88492 for (nstart = start ; ; ) {
88493 vm_flags_t newflags;
88494
88495 +#ifdef CONFIG_PAX_SEGMEXEC
88496 + if ((current->mm->pax_flags & MF_PAX_SEGMEXEC) && (vma->vm_start >= SEGMEXEC_TASK_SIZE))
88497 + break;
88498 +#endif
88499 +
88500 /* Here we know that vma->vm_start <= nstart < vma->vm_end. */
88501
88502 newflags = vma->vm_flags & ~VM_LOCKED;
88503 @@ -700,6 +709,7 @@ SYSCALL_DEFINE2(mlock, unsigned long, start, size_t, len)
88504 lock_limit >>= PAGE_SHIFT;
88505
88506 /* check against resource limits */
88507 + gr_learn_resource(current, RLIMIT_MEMLOCK, (current->mm->locked_vm << PAGE_SHIFT) + len, 1);
88508 if ((locked <= lock_limit) || capable(CAP_IPC_LOCK))
88509 error = do_mlock(start, len, 1);
88510 up_write(&current->mm->mmap_sem);
88511 @@ -734,6 +744,11 @@ static int do_mlockall(int flags)
88512 for (vma = current->mm->mmap; vma ; vma = prev->vm_next) {
88513 vm_flags_t newflags;
88514
88515 +#ifdef CONFIG_PAX_SEGMEXEC
88516 + if ((current->mm->pax_flags & MF_PAX_SEGMEXEC) && (vma->vm_start >= SEGMEXEC_TASK_SIZE))
88517 + break;
88518 +#endif
88519 +
88520 newflags = vma->vm_flags & ~VM_LOCKED;
88521 if (flags & MCL_CURRENT)
88522 newflags |= VM_LOCKED;
88523 @@ -767,6 +782,7 @@ SYSCALL_DEFINE1(mlockall, int, flags)
88524 lock_limit >>= PAGE_SHIFT;
88525
88526 ret = -ENOMEM;
88527 + gr_learn_resource(current, RLIMIT_MEMLOCK, current->mm->total_vm << PAGE_SHIFT, 1);
88528 if (!(flags & MCL_CURRENT) || (current->mm->total_vm <= lock_limit) ||
88529 capable(CAP_IPC_LOCK))
88530 ret = do_mlockall(flags);
88531 diff --git a/mm/mmap.c b/mm/mmap.c
88532 index 362e5f1..8968e02 100644
88533 --- a/mm/mmap.c
88534 +++ b/mm/mmap.c
88535 @@ -36,6 +36,7 @@
88536 #include <linux/sched/sysctl.h>
88537 #include <linux/notifier.h>
88538 #include <linux/memory.h>
88539 +#include <linux/random.h>
88540
88541 #include <asm/uaccess.h>
88542 #include <asm/cacheflush.h>
88543 @@ -52,6 +53,16 @@
88544 #define arch_rebalance_pgtables(addr, len) (addr)
88545 #endif
88546
88547 +static inline void verify_mm_writelocked(struct mm_struct *mm)
88548 +{
88549 +#if defined(CONFIG_DEBUG_VM) || defined(CONFIG_PAX)
88550 + if (unlikely(down_read_trylock(&mm->mmap_sem))) {
88551 + up_read(&mm->mmap_sem);
88552 + BUG();
88553 + }
88554 +#endif
88555 +}
88556 +
88557 static void unmap_region(struct mm_struct *mm,
88558 struct vm_area_struct *vma, struct vm_area_struct *prev,
88559 unsigned long start, unsigned long end);
88560 @@ -71,16 +82,25 @@ static void unmap_region(struct mm_struct *mm,
88561 * x: (no) no x: (no) yes x: (no) yes x: (yes) yes
88562 *
88563 */
88564 -pgprot_t protection_map[16] = {
88565 +pgprot_t protection_map[16] __read_only = {
88566 __P000, __P001, __P010, __P011, __P100, __P101, __P110, __P111,
88567 __S000, __S001, __S010, __S011, __S100, __S101, __S110, __S111
88568 };
88569
88570 -pgprot_t vm_get_page_prot(unsigned long vm_flags)
88571 +pgprot_t vm_get_page_prot(vm_flags_t vm_flags)
88572 {
88573 - return __pgprot(pgprot_val(protection_map[vm_flags &
88574 + pgprot_t prot = __pgprot(pgprot_val(protection_map[vm_flags &
88575 (VM_READ|VM_WRITE|VM_EXEC|VM_SHARED)]) |
88576 pgprot_val(arch_vm_get_page_prot(vm_flags)));
88577 +
88578 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_X86_32)
88579 + if (!(__supported_pte_mask & _PAGE_NX) &&
88580 + (vm_flags & (VM_PAGEEXEC | VM_EXEC)) == VM_PAGEEXEC &&
88581 + (vm_flags & (VM_READ | VM_WRITE)))
88582 + prot = __pgprot(pte_val(pte_exprotect(__pte(pgprot_val(prot)))));
88583 +#endif
88584 +
88585 + return prot;
88586 }
88587 EXPORT_SYMBOL(vm_get_page_prot);
88588
88589 @@ -89,6 +109,7 @@ int sysctl_overcommit_ratio __read_mostly = 50; /* default is 50% */
88590 int sysctl_max_map_count __read_mostly = DEFAULT_MAX_MAP_COUNT;
88591 unsigned long sysctl_user_reserve_kbytes __read_mostly = 1UL << 17; /* 128MB */
88592 unsigned long sysctl_admin_reserve_kbytes __read_mostly = 1UL << 13; /* 8MB */
88593 +unsigned long sysctl_heap_stack_gap __read_mostly = 64*1024;
88594 /*
88595 * Make sure vm_committed_as in one cacheline and not cacheline shared with
88596 * other variables. It can be updated by several CPUs frequently.
88597 @@ -247,6 +268,7 @@ static struct vm_area_struct *remove_vma(struct vm_area_struct *vma)
88598 struct vm_area_struct *next = vma->vm_next;
88599
88600 might_sleep();
88601 + BUG_ON(vma->vm_mirror);
88602 if (vma->vm_ops && vma->vm_ops->close)
88603 vma->vm_ops->close(vma);
88604 if (vma->vm_file)
88605 @@ -291,6 +313,7 @@ SYSCALL_DEFINE1(brk, unsigned long, brk)
88606 * not page aligned -Ram Gupta
88607 */
88608 rlim = rlimit(RLIMIT_DATA);
88609 + gr_learn_resource(current, RLIMIT_DATA, (brk - mm->start_brk) + (mm->end_data - mm->start_data), 1);
88610 if (rlim < RLIM_INFINITY && (brk - mm->start_brk) +
88611 (mm->end_data - mm->start_data) > rlim)
88612 goto out;
88613 @@ -933,6 +956,12 @@ static int
88614 can_vma_merge_before(struct vm_area_struct *vma, unsigned long vm_flags,
88615 struct anon_vma *anon_vma, struct file *file, pgoff_t vm_pgoff)
88616 {
88617 +
88618 +#ifdef CONFIG_PAX_SEGMEXEC
88619 + if ((vma->vm_mm->pax_flags & MF_PAX_SEGMEXEC) && vma->vm_start == SEGMEXEC_TASK_SIZE)
88620 + return 0;
88621 +#endif
88622 +
88623 if (is_mergeable_vma(vma, file, vm_flags) &&
88624 is_mergeable_anon_vma(anon_vma, vma->anon_vma, vma)) {
88625 if (vma->vm_pgoff == vm_pgoff)
88626 @@ -952,6 +981,12 @@ static int
88627 can_vma_merge_after(struct vm_area_struct *vma, unsigned long vm_flags,
88628 struct anon_vma *anon_vma, struct file *file, pgoff_t vm_pgoff)
88629 {
88630 +
88631 +#ifdef CONFIG_PAX_SEGMEXEC
88632 + if ((vma->vm_mm->pax_flags & MF_PAX_SEGMEXEC) && vma->vm_end == SEGMEXEC_TASK_SIZE)
88633 + return 0;
88634 +#endif
88635 +
88636 if (is_mergeable_vma(vma, file, vm_flags) &&
88637 is_mergeable_anon_vma(anon_vma, vma->anon_vma, vma)) {
88638 pgoff_t vm_pglen;
88639 @@ -994,13 +1029,20 @@ can_vma_merge_after(struct vm_area_struct *vma, unsigned long vm_flags,
88640 struct vm_area_struct *vma_merge(struct mm_struct *mm,
88641 struct vm_area_struct *prev, unsigned long addr,
88642 unsigned long end, unsigned long vm_flags,
88643 - struct anon_vma *anon_vma, struct file *file,
88644 + struct anon_vma *anon_vma, struct file *file,
88645 pgoff_t pgoff, struct mempolicy *policy)
88646 {
88647 pgoff_t pglen = (end - addr) >> PAGE_SHIFT;
88648 struct vm_area_struct *area, *next;
88649 int err;
88650
88651 +#ifdef CONFIG_PAX_SEGMEXEC
88652 + unsigned long addr_m = addr + SEGMEXEC_TASK_SIZE, end_m = end + SEGMEXEC_TASK_SIZE;
88653 + struct vm_area_struct *area_m = NULL, *next_m = NULL, *prev_m = NULL;
88654 +
88655 + BUG_ON((mm->pax_flags & MF_PAX_SEGMEXEC) && SEGMEXEC_TASK_SIZE < end);
88656 +#endif
88657 +
88658 /*
88659 * We later require that vma->vm_flags == vm_flags,
88660 * so this tests vma->vm_flags & VM_SPECIAL, too.
88661 @@ -1016,6 +1058,15 @@ struct vm_area_struct *vma_merge(struct mm_struct *mm,
88662 if (next && next->vm_end == end) /* cases 6, 7, 8 */
88663 next = next->vm_next;
88664
88665 +#ifdef CONFIG_PAX_SEGMEXEC
88666 + if (prev)
88667 + prev_m = pax_find_mirror_vma(prev);
88668 + if (area)
88669 + area_m = pax_find_mirror_vma(area);
88670 + if (next)
88671 + next_m = pax_find_mirror_vma(next);
88672 +#endif
88673 +
88674 /*
88675 * Can it merge with the predecessor?
88676 */
88677 @@ -1035,9 +1086,24 @@ struct vm_area_struct *vma_merge(struct mm_struct *mm,
88678 /* cases 1, 6 */
88679 err = vma_adjust(prev, prev->vm_start,
88680 next->vm_end, prev->vm_pgoff, NULL);
88681 - } else /* cases 2, 5, 7 */
88682 +
88683 +#ifdef CONFIG_PAX_SEGMEXEC
88684 + if (!err && prev_m)
88685 + err = vma_adjust(prev_m, prev_m->vm_start,
88686 + next_m->vm_end, prev_m->vm_pgoff, NULL);
88687 +#endif
88688 +
88689 + } else { /* cases 2, 5, 7 */
88690 err = vma_adjust(prev, prev->vm_start,
88691 end, prev->vm_pgoff, NULL);
88692 +
88693 +#ifdef CONFIG_PAX_SEGMEXEC
88694 + if (!err && prev_m)
88695 + err = vma_adjust(prev_m, prev_m->vm_start,
88696 + end_m, prev_m->vm_pgoff, NULL);
88697 +#endif
88698 +
88699 + }
88700 if (err)
88701 return NULL;
88702 khugepaged_enter_vma_merge(prev);
88703 @@ -1051,12 +1117,27 @@ struct vm_area_struct *vma_merge(struct mm_struct *mm,
88704 mpol_equal(policy, vma_policy(next)) &&
88705 can_vma_merge_before(next, vm_flags,
88706 anon_vma, file, pgoff+pglen)) {
88707 - if (prev && addr < prev->vm_end) /* case 4 */
88708 + if (prev && addr < prev->vm_end) { /* case 4 */
88709 err = vma_adjust(prev, prev->vm_start,
88710 addr, prev->vm_pgoff, NULL);
88711 - else /* cases 3, 8 */
88712 +
88713 +#ifdef CONFIG_PAX_SEGMEXEC
88714 + if (!err && prev_m)
88715 + err = vma_adjust(prev_m, prev_m->vm_start,
88716 + addr_m, prev_m->vm_pgoff, NULL);
88717 +#endif
88718 +
88719 + } else { /* cases 3, 8 */
88720 err = vma_adjust(area, addr, next->vm_end,
88721 next->vm_pgoff - pglen, NULL);
88722 +
88723 +#ifdef CONFIG_PAX_SEGMEXEC
88724 + if (!err && area_m)
88725 + err = vma_adjust(area_m, addr_m, next_m->vm_end,
88726 + next_m->vm_pgoff - pglen, NULL);
88727 +#endif
88728 +
88729 + }
88730 if (err)
88731 return NULL;
88732 khugepaged_enter_vma_merge(area);
88733 @@ -1165,8 +1246,10 @@ none:
88734 void vm_stat_account(struct mm_struct *mm, unsigned long flags,
88735 struct file *file, long pages)
88736 {
88737 - const unsigned long stack_flags
88738 - = VM_STACK_FLAGS & (VM_GROWSUP|VM_GROWSDOWN);
88739 +
88740 +#ifdef CONFIG_PAX_RANDMMAP
88741 + if (!(mm->pax_flags & MF_PAX_RANDMMAP) || (flags & (VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)))
88742 +#endif
88743
88744 mm->total_vm += pages;
88745
88746 @@ -1174,7 +1257,7 @@ void vm_stat_account(struct mm_struct *mm, unsigned long flags,
88747 mm->shared_vm += pages;
88748 if ((flags & (VM_EXEC|VM_WRITE)) == VM_EXEC)
88749 mm->exec_vm += pages;
88750 - } else if (flags & stack_flags)
88751 + } else if (flags & (VM_GROWSUP|VM_GROWSDOWN))
88752 mm->stack_vm += pages;
88753 }
88754 #endif /* CONFIG_PROC_FS */
88755 @@ -1212,7 +1295,7 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
88756 * (the exception is when the underlying filesystem is noexec
88757 * mounted, in which case we dont add PROT_EXEC.)
88758 */
88759 - if ((prot & PROT_READ) && (current->personality & READ_IMPLIES_EXEC))
88760 + if ((prot & (PROT_READ | PROT_WRITE)) && (current->personality & READ_IMPLIES_EXEC))
88761 if (!(file && (file->f_path.mnt->mnt_flags & MNT_NOEXEC)))
88762 prot |= PROT_EXEC;
88763
88764 @@ -1238,7 +1321,7 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
88765 /* Obtain the address to map to. we verify (or select) it and ensure
88766 * that it represents a valid section of the address space.
88767 */
88768 - addr = get_unmapped_area(file, addr, len, pgoff, flags);
88769 + addr = get_unmapped_area(file, addr, len, pgoff, flags | ((prot & PROT_EXEC) ? MAP_EXECUTABLE : 0));
88770 if (addr & ~PAGE_MASK)
88771 return addr;
88772
88773 @@ -1249,6 +1332,43 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
88774 vm_flags = calc_vm_prot_bits(prot) | calc_vm_flag_bits(flags) |
88775 mm->def_flags | VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC;
88776
88777 +#ifdef CONFIG_PAX_MPROTECT
88778 + if (mm->pax_flags & MF_PAX_MPROTECT) {
88779 +
88780 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
88781 + if (file && !pgoff && (vm_flags & VM_EXEC) && mm->binfmt &&
88782 + mm->binfmt->handle_mmap)
88783 + mm->binfmt->handle_mmap(file);
88784 +#endif
88785 +
88786 +#ifndef CONFIG_PAX_MPROTECT_COMPAT
88787 + if ((vm_flags & (VM_WRITE | VM_EXEC)) == (VM_WRITE | VM_EXEC)) {
88788 + gr_log_rwxmmap(file);
88789 +
88790 +#ifdef CONFIG_PAX_EMUPLT
88791 + vm_flags &= ~VM_EXEC;
88792 +#else
88793 + return -EPERM;
88794 +#endif
88795 +
88796 + }
88797 +
88798 + if (!(vm_flags & VM_EXEC))
88799 + vm_flags &= ~VM_MAYEXEC;
88800 +#else
88801 + if ((vm_flags & (VM_WRITE | VM_EXEC)) != VM_EXEC)
88802 + vm_flags &= ~(VM_EXEC | VM_MAYEXEC);
88803 +#endif
88804 + else
88805 + vm_flags &= ~VM_MAYWRITE;
88806 + }
88807 +#endif
88808 +
88809 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_X86_32)
88810 + if ((mm->pax_flags & MF_PAX_PAGEEXEC) && file)
88811 + vm_flags &= ~VM_PAGEEXEC;
88812 +#endif
88813 +
88814 if (flags & MAP_LOCKED)
88815 if (!can_do_mlock())
88816 return -EPERM;
88817 @@ -1260,6 +1380,7 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
88818 locked += mm->locked_vm;
88819 lock_limit = rlimit(RLIMIT_MEMLOCK);
88820 lock_limit >>= PAGE_SHIFT;
88821 + gr_learn_resource(current, RLIMIT_MEMLOCK, locked << PAGE_SHIFT, 1);
88822 if (locked > lock_limit && !capable(CAP_IPC_LOCK))
88823 return -EAGAIN;
88824 }
88825 @@ -1344,6 +1465,9 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
88826 vm_flags |= VM_NORESERVE;
88827 }
88828
88829 + if (!gr_acl_handle_mmap(file, prot))
88830 + return -EACCES;
88831 +
88832 addr = mmap_region(file, addr, len, vm_flags, pgoff);
88833 if (!IS_ERR_VALUE(addr) &&
88834 ((vm_flags & VM_LOCKED) ||
88835 @@ -1437,7 +1561,7 @@ int vma_wants_writenotify(struct vm_area_struct *vma)
88836 vm_flags_t vm_flags = vma->vm_flags;
88837
88838 /* If it was private or non-writable, the write bit is already clear */
88839 - if ((vm_flags & (VM_WRITE|VM_SHARED)) != ((VM_WRITE|VM_SHARED)))
88840 + if ((vm_flags & (VM_WRITE|VM_SHARED)) != (VM_WRITE|VM_SHARED))
88841 return 0;
88842
88843 /* The backer wishes to know when pages are first written to? */
88844 @@ -1483,7 +1607,22 @@ unsigned long mmap_region(struct file *file, unsigned long addr,
88845 struct rb_node **rb_link, *rb_parent;
88846 unsigned long charged = 0;
88847
88848 +#ifdef CONFIG_PAX_SEGMEXEC
88849 + struct vm_area_struct *vma_m = NULL;
88850 +#endif
88851 +
88852 + /*
88853 + * mm->mmap_sem is required to protect against another thread
88854 + * changing the mappings in case we sleep.
88855 + */
88856 + verify_mm_writelocked(mm);
88857 +
88858 /* Check against address space limit. */
88859 +
88860 +#ifdef CONFIG_PAX_RANDMMAP
88861 + if (!(mm->pax_flags & MF_PAX_RANDMMAP) || (vm_flags & (VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)))
88862 +#endif
88863 +
88864 if (!may_expand_vm(mm, len >> PAGE_SHIFT)) {
88865 unsigned long nr_pages;
88866
88867 @@ -1502,11 +1641,10 @@ unsigned long mmap_region(struct file *file, unsigned long addr,
88868
88869 /* Clear old maps */
88870 error = -ENOMEM;
88871 -munmap_back:
88872 if (find_vma_links(mm, addr, addr + len, &prev, &rb_link, &rb_parent)) {
88873 if (do_munmap(mm, addr, len))
88874 return -ENOMEM;
88875 - goto munmap_back;
88876 + BUG_ON(find_vma_links(mm, addr, addr + len, &prev, &rb_link, &rb_parent));
88877 }
88878
88879 /*
88880 @@ -1537,6 +1675,16 @@ munmap_back:
88881 goto unacct_error;
88882 }
88883
88884 +#ifdef CONFIG_PAX_SEGMEXEC
88885 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && (vm_flags & VM_EXEC)) {
88886 + vma_m = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
88887 + if (!vma_m) {
88888 + error = -ENOMEM;
88889 + goto free_vma;
88890 + }
88891 + }
88892 +#endif
88893 +
88894 vma->vm_mm = mm;
88895 vma->vm_start = addr;
88896 vma->vm_end = addr + len;
88897 @@ -1556,6 +1704,13 @@ munmap_back:
88898 if (error)
88899 goto unmap_and_free_vma;
88900
88901 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_X86_32)
88902 + if ((mm->pax_flags & MF_PAX_PAGEEXEC) && !(vma->vm_flags & VM_SPECIAL)) {
88903 + vma->vm_flags |= VM_PAGEEXEC;
88904 + vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
88905 + }
88906 +#endif
88907 +
88908 /* Can addr have changed??
88909 *
88910 * Answer: Yes, several device drivers can do it in their
88911 @@ -1589,6 +1744,12 @@ munmap_back:
88912 }
88913
88914 vma_link(mm, vma, prev, rb_link, rb_parent);
88915 +
88916 +#ifdef CONFIG_PAX_SEGMEXEC
88917 + if (vma_m)
88918 + BUG_ON(pax_mirror_vma(vma_m, vma));
88919 +#endif
88920 +
88921 /* Once vma denies write, undo our temporary denial count */
88922 if (vm_flags & VM_DENYWRITE)
88923 allow_write_access(file);
88924 @@ -1597,6 +1758,7 @@ out:
88925 perf_event_mmap(vma);
88926
88927 vm_stat_account(mm, vm_flags, file, len >> PAGE_SHIFT);
88928 + track_exec_limit(mm, addr, addr + len, vm_flags);
88929 if (vm_flags & VM_LOCKED) {
88930 if (!((vm_flags & VM_SPECIAL) || is_vm_hugetlb_page(vma) ||
88931 vma == get_gate_vma(current->mm)))
88932 @@ -1629,6 +1791,12 @@ unmap_and_free_vma:
88933 unmap_region(mm, vma, prev, vma->vm_start, vma->vm_end);
88934 charged = 0;
88935 free_vma:
88936 +
88937 +#ifdef CONFIG_PAX_SEGMEXEC
88938 + if (vma_m)
88939 + kmem_cache_free(vm_area_cachep, vma_m);
88940 +#endif
88941 +
88942 kmem_cache_free(vm_area_cachep, vma);
88943 unacct_error:
88944 if (charged)
88945 @@ -1636,7 +1804,63 @@ unacct_error:
88946 return error;
88947 }
88948
88949 -unsigned long unmapped_area(struct vm_unmapped_area_info *info)
88950 +#ifdef CONFIG_GRKERNSEC_RAND_THREADSTACK
88951 +unsigned long gr_rand_threadstack_offset(const struct mm_struct *mm, const struct file *filp, unsigned long flags)
88952 +{
88953 + if ((mm->pax_flags & MF_PAX_RANDMMAP) && !filp && (flags & MAP_STACK))
88954 + return ((prandom_u32() & 0xFF) + 1) << PAGE_SHIFT;
88955 +
88956 + return 0;
88957 +}
88958 +#endif
88959 +
88960 +bool check_heap_stack_gap(const struct vm_area_struct *vma, unsigned long addr, unsigned long len, unsigned long offset)
88961 +{
88962 + if (!vma) {
88963 +#ifdef CONFIG_STACK_GROWSUP
88964 + if (addr > sysctl_heap_stack_gap)
88965 + vma = find_vma(current->mm, addr - sysctl_heap_stack_gap);
88966 + else
88967 + vma = find_vma(current->mm, 0);
88968 + if (vma && (vma->vm_flags & VM_GROWSUP))
88969 + return false;
88970 +#endif
88971 + return true;
88972 + }
88973 +
88974 + if (addr + len > vma->vm_start)
88975 + return false;
88976 +
88977 + if (vma->vm_flags & VM_GROWSDOWN)
88978 + return sysctl_heap_stack_gap <= vma->vm_start - addr - len;
88979 +#ifdef CONFIG_STACK_GROWSUP
88980 + else if (vma->vm_prev && (vma->vm_prev->vm_flags & VM_GROWSUP))
88981 + return addr - vma->vm_prev->vm_end >= sysctl_heap_stack_gap;
88982 +#endif
88983 + else if (offset)
88984 + return offset <= vma->vm_start - addr - len;
88985 +
88986 + return true;
88987 +}
88988 +
88989 +unsigned long skip_heap_stack_gap(const struct vm_area_struct *vma, unsigned long len, unsigned long offset)
88990 +{
88991 + if (vma->vm_start < len)
88992 + return -ENOMEM;
88993 +
88994 + if (!(vma->vm_flags & VM_GROWSDOWN)) {
88995 + if (offset <= vma->vm_start - len)
88996 + return vma->vm_start - len - offset;
88997 + else
88998 + return -ENOMEM;
88999 + }
89000 +
89001 + if (sysctl_heap_stack_gap <= vma->vm_start - len)
89002 + return vma->vm_start - len - sysctl_heap_stack_gap;
89003 + return -ENOMEM;
89004 +}
89005 +
89006 +unsigned long unmapped_area(const struct vm_unmapped_area_info *info)
89007 {
89008 /*
89009 * We implement the search by looking for an rbtree node that
89010 @@ -1684,11 +1908,29 @@ unsigned long unmapped_area(struct vm_unmapped_area_info *info)
89011 }
89012 }
89013
89014 - gap_start = vma->vm_prev ? vma->vm_prev->vm_end : 0;
89015 + gap_start = vma->vm_prev ? vma->vm_prev->vm_end: 0;
89016 check_current:
89017 /* Check if current node has a suitable gap */
89018 if (gap_start > high_limit)
89019 return -ENOMEM;
89020 +
89021 + if (gap_end - gap_start > info->threadstack_offset)
89022 + gap_start += info->threadstack_offset;
89023 + else
89024 + gap_start = gap_end;
89025 +
89026 + if (vma->vm_prev && (vma->vm_prev->vm_flags & VM_GROWSUP)) {
89027 + if (gap_end - gap_start > sysctl_heap_stack_gap)
89028 + gap_start += sysctl_heap_stack_gap;
89029 + else
89030 + gap_start = gap_end;
89031 + }
89032 + if (vma->vm_flags & VM_GROWSDOWN) {
89033 + if (gap_end - gap_start > sysctl_heap_stack_gap)
89034 + gap_end -= sysctl_heap_stack_gap;
89035 + else
89036 + gap_end = gap_start;
89037 + }
89038 if (gap_end >= low_limit && gap_end - gap_start >= length)
89039 goto found;
89040
89041 @@ -1738,7 +1980,7 @@ found:
89042 return gap_start;
89043 }
89044
89045 -unsigned long unmapped_area_topdown(struct vm_unmapped_area_info *info)
89046 +unsigned long unmapped_area_topdown(const struct vm_unmapped_area_info *info)
89047 {
89048 struct mm_struct *mm = current->mm;
89049 struct vm_area_struct *vma;
89050 @@ -1792,6 +2034,24 @@ check_current:
89051 gap_end = vma->vm_start;
89052 if (gap_end < low_limit)
89053 return -ENOMEM;
89054 +
89055 + if (gap_end - gap_start > info->threadstack_offset)
89056 + gap_end -= info->threadstack_offset;
89057 + else
89058 + gap_end = gap_start;
89059 +
89060 + if (vma->vm_prev && (vma->vm_prev->vm_flags & VM_GROWSUP)) {
89061 + if (gap_end - gap_start > sysctl_heap_stack_gap)
89062 + gap_start += sysctl_heap_stack_gap;
89063 + else
89064 + gap_start = gap_end;
89065 + }
89066 + if (vma->vm_flags & VM_GROWSDOWN) {
89067 + if (gap_end - gap_start > sysctl_heap_stack_gap)
89068 + gap_end -= sysctl_heap_stack_gap;
89069 + else
89070 + gap_end = gap_start;
89071 + }
89072 if (gap_start <= high_limit && gap_end - gap_start >= length)
89073 goto found;
89074
89075 @@ -1855,6 +2115,7 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
89076 struct mm_struct *mm = current->mm;
89077 struct vm_area_struct *vma;
89078 struct vm_unmapped_area_info info;
89079 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
89080
89081 if (len > TASK_SIZE - mmap_min_addr)
89082 return -ENOMEM;
89083 @@ -1862,19 +2123,30 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
89084 if (flags & MAP_FIXED)
89085 return addr;
89086
89087 +#ifdef CONFIG_PAX_RANDMMAP
89088 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
89089 +#endif
89090 +
89091 if (addr) {
89092 addr = PAGE_ALIGN(addr);
89093 vma = find_vma(mm, addr);
89094 if (TASK_SIZE - len >= addr && addr >= mmap_min_addr &&
89095 - (!vma || addr + len <= vma->vm_start))
89096 + check_heap_stack_gap(vma, addr, len, offset))
89097 return addr;
89098 }
89099
89100 info.flags = 0;
89101 info.length = len;
89102 info.low_limit = TASK_UNMAPPED_BASE;
89103 +
89104 +#ifdef CONFIG_PAX_RANDMMAP
89105 + if (mm->pax_flags & MF_PAX_RANDMMAP)
89106 + info.low_limit += mm->delta_mmap;
89107 +#endif
89108 +
89109 info.high_limit = TASK_SIZE;
89110 info.align_mask = 0;
89111 + info.threadstack_offset = offset;
89112 return vm_unmapped_area(&info);
89113 }
89114 #endif
89115 @@ -1893,6 +2165,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
89116 struct mm_struct *mm = current->mm;
89117 unsigned long addr = addr0;
89118 struct vm_unmapped_area_info info;
89119 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
89120
89121 /* requested length too big for entire address space */
89122 if (len > TASK_SIZE - mmap_min_addr)
89123 @@ -1901,12 +2174,16 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
89124 if (flags & MAP_FIXED)
89125 return addr;
89126
89127 +#ifdef CONFIG_PAX_RANDMMAP
89128 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
89129 +#endif
89130 +
89131 /* requesting a specific address */
89132 if (addr) {
89133 addr = PAGE_ALIGN(addr);
89134 vma = find_vma(mm, addr);
89135 if (TASK_SIZE - len >= addr && addr >= mmap_min_addr &&
89136 - (!vma || addr + len <= vma->vm_start))
89137 + check_heap_stack_gap(vma, addr, len, offset))
89138 return addr;
89139 }
89140
89141 @@ -1915,6 +2192,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
89142 info.low_limit = max(PAGE_SIZE, mmap_min_addr);
89143 info.high_limit = mm->mmap_base;
89144 info.align_mask = 0;
89145 + info.threadstack_offset = offset;
89146 addr = vm_unmapped_area(&info);
89147
89148 /*
89149 @@ -1927,6 +2205,12 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
89150 VM_BUG_ON(addr != -ENOMEM);
89151 info.flags = 0;
89152 info.low_limit = TASK_UNMAPPED_BASE;
89153 +
89154 +#ifdef CONFIG_PAX_RANDMMAP
89155 + if (mm->pax_flags & MF_PAX_RANDMMAP)
89156 + info.low_limit += mm->delta_mmap;
89157 +#endif
89158 +
89159 info.high_limit = TASK_SIZE;
89160 addr = vm_unmapped_area(&info);
89161 }
89162 @@ -2028,6 +2312,28 @@ find_vma_prev(struct mm_struct *mm, unsigned long addr,
89163 return vma;
89164 }
89165
89166 +#ifdef CONFIG_PAX_SEGMEXEC
89167 +struct vm_area_struct *pax_find_mirror_vma(struct vm_area_struct *vma)
89168 +{
89169 + struct vm_area_struct *vma_m;
89170 +
89171 + BUG_ON(!vma || vma->vm_start >= vma->vm_end);
89172 + if (!(vma->vm_mm->pax_flags & MF_PAX_SEGMEXEC) || !(vma->vm_flags & VM_EXEC)) {
89173 + BUG_ON(vma->vm_mirror);
89174 + return NULL;
89175 + }
89176 + BUG_ON(vma->vm_start < SEGMEXEC_TASK_SIZE && SEGMEXEC_TASK_SIZE < vma->vm_end);
89177 + vma_m = vma->vm_mirror;
89178 + BUG_ON(!vma_m || vma_m->vm_mirror != vma);
89179 + BUG_ON(vma->vm_file != vma_m->vm_file);
89180 + BUG_ON(vma->vm_end - vma->vm_start != vma_m->vm_end - vma_m->vm_start);
89181 + BUG_ON(vma->vm_pgoff != vma_m->vm_pgoff);
89182 + BUG_ON(vma->anon_vma != vma_m->anon_vma && vma->anon_vma->root != vma_m->anon_vma->root);
89183 + BUG_ON((vma->vm_flags ^ vma_m->vm_flags) & ~(VM_WRITE | VM_MAYWRITE | VM_ACCOUNT | VM_LOCKED));
89184 + return vma_m;
89185 +}
89186 +#endif
89187 +
89188 /*
89189 * Verify that the stack growth is acceptable and
89190 * update accounting. This is shared with both the
89191 @@ -2044,6 +2350,7 @@ static int acct_stack_growth(struct vm_area_struct *vma, unsigned long size, uns
89192 return -ENOMEM;
89193
89194 /* Stack limit test */
89195 + gr_learn_resource(current, RLIMIT_STACK, size, 1);
89196 if (size > ACCESS_ONCE(rlim[RLIMIT_STACK].rlim_cur))
89197 return -ENOMEM;
89198
89199 @@ -2054,6 +2361,7 @@ static int acct_stack_growth(struct vm_area_struct *vma, unsigned long size, uns
89200 locked = mm->locked_vm + grow;
89201 limit = ACCESS_ONCE(rlim[RLIMIT_MEMLOCK].rlim_cur);
89202 limit >>= PAGE_SHIFT;
89203 + gr_learn_resource(current, RLIMIT_MEMLOCK, locked << PAGE_SHIFT, 1);
89204 if (locked > limit && !capable(CAP_IPC_LOCK))
89205 return -ENOMEM;
89206 }
89207 @@ -2083,37 +2391,48 @@ static int acct_stack_growth(struct vm_area_struct *vma, unsigned long size, uns
89208 * PA-RISC uses this for its stack; IA64 for its Register Backing Store.
89209 * vma is the last one with address > vma->vm_end. Have to extend vma.
89210 */
89211 +#ifndef CONFIG_IA64
89212 +static
89213 +#endif
89214 int expand_upwards(struct vm_area_struct *vma, unsigned long address)
89215 {
89216 int error;
89217 + bool locknext;
89218
89219 if (!(vma->vm_flags & VM_GROWSUP))
89220 return -EFAULT;
89221
89222 + /* Also guard against wrapping around to address 0. */
89223 + if (address < PAGE_ALIGN(address+1))
89224 + address = PAGE_ALIGN(address+1);
89225 + else
89226 + return -ENOMEM;
89227 +
89228 /*
89229 * We must make sure the anon_vma is allocated
89230 * so that the anon_vma locking is not a noop.
89231 */
89232 if (unlikely(anon_vma_prepare(vma)))
89233 return -ENOMEM;
89234 + locknext = vma->vm_next && (vma->vm_next->vm_flags & VM_GROWSDOWN);
89235 + if (locknext && anon_vma_prepare(vma->vm_next))
89236 + return -ENOMEM;
89237 vma_lock_anon_vma(vma);
89238 + if (locknext)
89239 + vma_lock_anon_vma(vma->vm_next);
89240
89241 /*
89242 * vma->vm_start/vm_end cannot change under us because the caller
89243 * is required to hold the mmap_sem in read mode. We need the
89244 - * anon_vma lock to serialize against concurrent expand_stacks.
89245 - * Also guard against wrapping around to address 0.
89246 + * anon_vma locks to serialize against concurrent expand_stacks
89247 + * and expand_upwards.
89248 */
89249 - if (address < PAGE_ALIGN(address+4))
89250 - address = PAGE_ALIGN(address+4);
89251 - else {
89252 - vma_unlock_anon_vma(vma);
89253 - return -ENOMEM;
89254 - }
89255 error = 0;
89256
89257 /* Somebody else might have raced and expanded it already */
89258 - if (address > vma->vm_end) {
89259 + 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)
89260 + error = -ENOMEM;
89261 + else if (address > vma->vm_end && (!locknext || vma->vm_next->vm_start >= address)) {
89262 unsigned long size, grow;
89263
89264 size = address - vma->vm_start;
89265 @@ -2148,6 +2467,8 @@ int expand_upwards(struct vm_area_struct *vma, unsigned long address)
89266 }
89267 }
89268 }
89269 + if (locknext)
89270 + vma_unlock_anon_vma(vma->vm_next);
89271 vma_unlock_anon_vma(vma);
89272 khugepaged_enter_vma_merge(vma);
89273 validate_mm(vma->vm_mm);
89274 @@ -2162,6 +2483,8 @@ int expand_downwards(struct vm_area_struct *vma,
89275 unsigned long address)
89276 {
89277 int error;
89278 + bool lockprev = false;
89279 + struct vm_area_struct *prev;
89280
89281 /*
89282 * We must make sure the anon_vma is allocated
89283 @@ -2175,6 +2498,15 @@ int expand_downwards(struct vm_area_struct *vma,
89284 if (error)
89285 return error;
89286
89287 + prev = vma->vm_prev;
89288 +#if defined(CONFIG_STACK_GROWSUP) || defined(CONFIG_IA64)
89289 + lockprev = prev && (prev->vm_flags & VM_GROWSUP);
89290 +#endif
89291 + if (lockprev && anon_vma_prepare(prev))
89292 + return -ENOMEM;
89293 + if (lockprev)
89294 + vma_lock_anon_vma(prev);
89295 +
89296 vma_lock_anon_vma(vma);
89297
89298 /*
89299 @@ -2184,9 +2516,17 @@ int expand_downwards(struct vm_area_struct *vma,
89300 */
89301
89302 /* Somebody else might have raced and expanded it already */
89303 - if (address < vma->vm_start) {
89304 + if (prev && (prev->vm_flags & (VM_READ | VM_WRITE | VM_EXEC)) && address - prev->vm_end < sysctl_heap_stack_gap)
89305 + error = -ENOMEM;
89306 + else if (address < vma->vm_start && (!lockprev || prev->vm_end <= address)) {
89307 unsigned long size, grow;
89308
89309 +#ifdef CONFIG_PAX_SEGMEXEC
89310 + struct vm_area_struct *vma_m;
89311 +
89312 + vma_m = pax_find_mirror_vma(vma);
89313 +#endif
89314 +
89315 size = vma->vm_end - address;
89316 grow = (vma->vm_start - address) >> PAGE_SHIFT;
89317
89318 @@ -2211,13 +2551,27 @@ int expand_downwards(struct vm_area_struct *vma,
89319 vma->vm_pgoff -= grow;
89320 anon_vma_interval_tree_post_update_vma(vma);
89321 vma_gap_update(vma);
89322 +
89323 +#ifdef CONFIG_PAX_SEGMEXEC
89324 + if (vma_m) {
89325 + anon_vma_interval_tree_pre_update_vma(vma_m);
89326 + vma_m->vm_start -= grow << PAGE_SHIFT;
89327 + vma_m->vm_pgoff -= grow;
89328 + anon_vma_interval_tree_post_update_vma(vma_m);
89329 + vma_gap_update(vma_m);
89330 + }
89331 +#endif
89332 +
89333 spin_unlock(&vma->vm_mm->page_table_lock);
89334
89335 + track_exec_limit(vma->vm_mm, vma->vm_start, vma->vm_end, vma->vm_flags);
89336 perf_event_mmap(vma);
89337 }
89338 }
89339 }
89340 vma_unlock_anon_vma(vma);
89341 + if (lockprev)
89342 + vma_unlock_anon_vma(prev);
89343 khugepaged_enter_vma_merge(vma);
89344 validate_mm(vma->vm_mm);
89345 return error;
89346 @@ -2315,6 +2669,13 @@ static void remove_vma_list(struct mm_struct *mm, struct vm_area_struct *vma)
89347 do {
89348 long nrpages = vma_pages(vma);
89349
89350 +#ifdef CONFIG_PAX_SEGMEXEC
89351 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && (vma->vm_start >= SEGMEXEC_TASK_SIZE)) {
89352 + vma = remove_vma(vma);
89353 + continue;
89354 + }
89355 +#endif
89356 +
89357 if (vma->vm_flags & VM_ACCOUNT)
89358 nr_accounted += nrpages;
89359 vm_stat_account(mm, vma->vm_flags, vma->vm_file, -nrpages);
89360 @@ -2359,6 +2720,16 @@ detach_vmas_to_be_unmapped(struct mm_struct *mm, struct vm_area_struct *vma,
89361 insertion_point = (prev ? &prev->vm_next : &mm->mmap);
89362 vma->vm_prev = NULL;
89363 do {
89364 +
89365 +#ifdef CONFIG_PAX_SEGMEXEC
89366 + if (vma->vm_mirror) {
89367 + BUG_ON(!vma->vm_mirror->vm_mirror || vma->vm_mirror->vm_mirror != vma);
89368 + vma->vm_mirror->vm_mirror = NULL;
89369 + vma->vm_mirror->vm_flags &= ~VM_EXEC;
89370 + vma->vm_mirror = NULL;
89371 + }
89372 +#endif
89373 +
89374 vma_rb_erase(vma, &mm->mm_rb);
89375 mm->map_count--;
89376 tail_vma = vma;
89377 @@ -2384,14 +2755,33 @@ static int __split_vma(struct mm_struct * mm, struct vm_area_struct * vma,
89378 struct vm_area_struct *new;
89379 int err = -ENOMEM;
89380
89381 +#ifdef CONFIG_PAX_SEGMEXEC
89382 + struct vm_area_struct *vma_m, *new_m = NULL;
89383 + unsigned long addr_m = addr + SEGMEXEC_TASK_SIZE;
89384 +#endif
89385 +
89386 if (is_vm_hugetlb_page(vma) && (addr &
89387 ~(huge_page_mask(hstate_vma(vma)))))
89388 return -EINVAL;
89389
89390 +#ifdef CONFIG_PAX_SEGMEXEC
89391 + vma_m = pax_find_mirror_vma(vma);
89392 +#endif
89393 +
89394 new = kmem_cache_alloc(vm_area_cachep, GFP_KERNEL);
89395 if (!new)
89396 goto out_err;
89397
89398 +#ifdef CONFIG_PAX_SEGMEXEC
89399 + if (vma_m) {
89400 + new_m = kmem_cache_alloc(vm_area_cachep, GFP_KERNEL);
89401 + if (!new_m) {
89402 + kmem_cache_free(vm_area_cachep, new);
89403 + goto out_err;
89404 + }
89405 + }
89406 +#endif
89407 +
89408 /* most fields are the same, copy all, and then fixup */
89409 *new = *vma;
89410
89411 @@ -2404,6 +2794,22 @@ static int __split_vma(struct mm_struct * mm, struct vm_area_struct * vma,
89412 new->vm_pgoff += ((addr - vma->vm_start) >> PAGE_SHIFT);
89413 }
89414
89415 +#ifdef CONFIG_PAX_SEGMEXEC
89416 + if (vma_m) {
89417 + *new_m = *vma_m;
89418 + INIT_LIST_HEAD(&new_m->anon_vma_chain);
89419 + new_m->vm_mirror = new;
89420 + new->vm_mirror = new_m;
89421 +
89422 + if (new_below)
89423 + new_m->vm_end = addr_m;
89424 + else {
89425 + new_m->vm_start = addr_m;
89426 + new_m->vm_pgoff += ((addr_m - vma_m->vm_start) >> PAGE_SHIFT);
89427 + }
89428 + }
89429 +#endif
89430 +
89431 err = vma_dup_policy(vma, new);
89432 if (err)
89433 goto out_free_vma;
89434 @@ -2423,6 +2829,38 @@ static int __split_vma(struct mm_struct * mm, struct vm_area_struct * vma,
89435 else
89436 err = vma_adjust(vma, vma->vm_start, addr, vma->vm_pgoff, new);
89437
89438 +#ifdef CONFIG_PAX_SEGMEXEC
89439 + if (!err && vma_m) {
89440 + struct mempolicy *pol = vma_policy(new);
89441 +
89442 + if (anon_vma_clone(new_m, vma_m))
89443 + goto out_free_mpol;
89444 +
89445 + mpol_get(pol);
89446 + set_vma_policy(new_m, pol);
89447 +
89448 + if (new_m->vm_file)
89449 + get_file(new_m->vm_file);
89450 +
89451 + if (new_m->vm_ops && new_m->vm_ops->open)
89452 + new_m->vm_ops->open(new_m);
89453 +
89454 + if (new_below)
89455 + err = vma_adjust(vma_m, addr_m, vma_m->vm_end, vma_m->vm_pgoff +
89456 + ((addr_m - new_m->vm_start) >> PAGE_SHIFT), new_m);
89457 + else
89458 + err = vma_adjust(vma_m, vma_m->vm_start, addr_m, vma_m->vm_pgoff, new_m);
89459 +
89460 + if (err) {
89461 + if (new_m->vm_ops && new_m->vm_ops->close)
89462 + new_m->vm_ops->close(new_m);
89463 + if (new_m->vm_file)
89464 + fput(new_m->vm_file);
89465 + mpol_put(pol);
89466 + }
89467 + }
89468 +#endif
89469 +
89470 /* Success. */
89471 if (!err)
89472 return 0;
89473 @@ -2432,10 +2870,18 @@ static int __split_vma(struct mm_struct * mm, struct vm_area_struct * vma,
89474 new->vm_ops->close(new);
89475 if (new->vm_file)
89476 fput(new->vm_file);
89477 - unlink_anon_vmas(new);
89478 out_free_mpol:
89479 mpol_put(vma_policy(new));
89480 out_free_vma:
89481 +
89482 +#ifdef CONFIG_PAX_SEGMEXEC
89483 + if (new_m) {
89484 + unlink_anon_vmas(new_m);
89485 + kmem_cache_free(vm_area_cachep, new_m);
89486 + }
89487 +#endif
89488 +
89489 + unlink_anon_vmas(new);
89490 kmem_cache_free(vm_area_cachep, new);
89491 out_err:
89492 return err;
89493 @@ -2448,6 +2894,15 @@ static int __split_vma(struct mm_struct * mm, struct vm_area_struct * vma,
89494 int split_vma(struct mm_struct *mm, struct vm_area_struct *vma,
89495 unsigned long addr, int new_below)
89496 {
89497 +
89498 +#ifdef CONFIG_PAX_SEGMEXEC
89499 + if (mm->pax_flags & MF_PAX_SEGMEXEC) {
89500 + BUG_ON(vma->vm_end > SEGMEXEC_TASK_SIZE);
89501 + if (mm->map_count >= sysctl_max_map_count-1)
89502 + return -ENOMEM;
89503 + } else
89504 +#endif
89505 +
89506 if (mm->map_count >= sysctl_max_map_count)
89507 return -ENOMEM;
89508
89509 @@ -2459,11 +2914,30 @@ int split_vma(struct mm_struct *mm, struct vm_area_struct *vma,
89510 * work. This now handles partial unmappings.
89511 * Jeremy Fitzhardinge <jeremy@goop.org>
89512 */
89513 +#ifdef CONFIG_PAX_SEGMEXEC
89514 int do_munmap(struct mm_struct *mm, unsigned long start, size_t len)
89515 {
89516 + int ret = __do_munmap(mm, start, len);
89517 + if (ret || !(mm->pax_flags & MF_PAX_SEGMEXEC))
89518 + return ret;
89519 +
89520 + return __do_munmap(mm, start + SEGMEXEC_TASK_SIZE, len);
89521 +}
89522 +
89523 +int __do_munmap(struct mm_struct *mm, unsigned long start, size_t len)
89524 +#else
89525 +int do_munmap(struct mm_struct *mm, unsigned long start, size_t len)
89526 +#endif
89527 +{
89528 unsigned long end;
89529 struct vm_area_struct *vma, *prev, *last;
89530
89531 + /*
89532 + * mm->mmap_sem is required to protect against another thread
89533 + * changing the mappings in case we sleep.
89534 + */
89535 + verify_mm_writelocked(mm);
89536 +
89537 if ((start & ~PAGE_MASK) || start > TASK_SIZE || len > TASK_SIZE-start)
89538 return -EINVAL;
89539
89540 @@ -2538,6 +3012,8 @@ int do_munmap(struct mm_struct *mm, unsigned long start, size_t len)
89541 /* Fix up all other VM information */
89542 remove_vma_list(mm, vma);
89543
89544 + track_exec_limit(mm, start, end, 0UL);
89545 +
89546 return 0;
89547 }
89548
89549 @@ -2546,6 +3022,13 @@ int vm_munmap(unsigned long start, size_t len)
89550 int ret;
89551 struct mm_struct *mm = current->mm;
89552
89553 +
89554 +#ifdef CONFIG_PAX_SEGMEXEC
89555 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) &&
89556 + (len > SEGMEXEC_TASK_SIZE || start > SEGMEXEC_TASK_SIZE-len))
89557 + return -EINVAL;
89558 +#endif
89559 +
89560 down_write(&mm->mmap_sem);
89561 ret = do_munmap(mm, start, len);
89562 up_write(&mm->mmap_sem);
89563 @@ -2559,16 +3042,6 @@ SYSCALL_DEFINE2(munmap, unsigned long, addr, size_t, len)
89564 return vm_munmap(addr, len);
89565 }
89566
89567 -static inline void verify_mm_writelocked(struct mm_struct *mm)
89568 -{
89569 -#ifdef CONFIG_DEBUG_VM
89570 - if (unlikely(down_read_trylock(&mm->mmap_sem))) {
89571 - WARN_ON(1);
89572 - up_read(&mm->mmap_sem);
89573 - }
89574 -#endif
89575 -}
89576 -
89577 /*
89578 * this is really a simplified "do_mmap". it only handles
89579 * anonymous maps. eventually we may be able to do some
89580 @@ -2582,6 +3055,7 @@ static unsigned long do_brk(unsigned long addr, unsigned long len)
89581 struct rb_node ** rb_link, * rb_parent;
89582 pgoff_t pgoff = addr >> PAGE_SHIFT;
89583 int error;
89584 + unsigned long charged;
89585
89586 len = PAGE_ALIGN(len);
89587 if (!len)
89588 @@ -2589,16 +3063,30 @@ static unsigned long do_brk(unsigned long addr, unsigned long len)
89589
89590 flags = VM_DATA_DEFAULT_FLAGS | VM_ACCOUNT | mm->def_flags;
89591
89592 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
89593 + if (mm->pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) {
89594 + flags &= ~VM_EXEC;
89595 +
89596 +#ifdef CONFIG_PAX_MPROTECT
89597 + if (mm->pax_flags & MF_PAX_MPROTECT)
89598 + flags &= ~VM_MAYEXEC;
89599 +#endif
89600 +
89601 + }
89602 +#endif
89603 +
89604 error = get_unmapped_area(NULL, addr, len, 0, MAP_FIXED);
89605 if (error & ~PAGE_MASK)
89606 return error;
89607
89608 + charged = len >> PAGE_SHIFT;
89609 +
89610 /*
89611 * mlock MCL_FUTURE?
89612 */
89613 if (mm->def_flags & VM_LOCKED) {
89614 unsigned long locked, lock_limit;
89615 - locked = len >> PAGE_SHIFT;
89616 + locked = charged;
89617 locked += mm->locked_vm;
89618 lock_limit = rlimit(RLIMIT_MEMLOCK);
89619 lock_limit >>= PAGE_SHIFT;
89620 @@ -2615,21 +3103,20 @@ static unsigned long do_brk(unsigned long addr, unsigned long len)
89621 /*
89622 * Clear old maps. this also does some error checking for us
89623 */
89624 - munmap_back:
89625 if (find_vma_links(mm, addr, addr + len, &prev, &rb_link, &rb_parent)) {
89626 if (do_munmap(mm, addr, len))
89627 return -ENOMEM;
89628 - goto munmap_back;
89629 + BUG_ON(find_vma_links(mm, addr, addr + len, &prev, &rb_link, &rb_parent));
89630 }
89631
89632 /* Check against address space limits *after* clearing old maps... */
89633 - if (!may_expand_vm(mm, len >> PAGE_SHIFT))
89634 + if (!may_expand_vm(mm, charged))
89635 return -ENOMEM;
89636
89637 if (mm->map_count > sysctl_max_map_count)
89638 return -ENOMEM;
89639
89640 - if (security_vm_enough_memory_mm(mm, len >> PAGE_SHIFT))
89641 + if (security_vm_enough_memory_mm(mm, charged))
89642 return -ENOMEM;
89643
89644 /* Can we just expand an old private anonymous mapping? */
89645 @@ -2643,7 +3130,7 @@ static unsigned long do_brk(unsigned long addr, unsigned long len)
89646 */
89647 vma = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
89648 if (!vma) {
89649 - vm_unacct_memory(len >> PAGE_SHIFT);
89650 + vm_unacct_memory(charged);
89651 return -ENOMEM;
89652 }
89653
89654 @@ -2657,10 +3144,11 @@ static unsigned long do_brk(unsigned long addr, unsigned long len)
89655 vma_link(mm, vma, prev, rb_link, rb_parent);
89656 out:
89657 perf_event_mmap(vma);
89658 - mm->total_vm += len >> PAGE_SHIFT;
89659 + mm->total_vm += charged;
89660 if (flags & VM_LOCKED)
89661 - mm->locked_vm += (len >> PAGE_SHIFT);
89662 + mm->locked_vm += charged;
89663 vma->vm_flags |= VM_SOFTDIRTY;
89664 + track_exec_limit(mm, addr, addr + len, flags);
89665 return addr;
89666 }
89667
89668 @@ -2722,6 +3210,7 @@ void exit_mmap(struct mm_struct *mm)
89669 while (vma) {
89670 if (vma->vm_flags & VM_ACCOUNT)
89671 nr_accounted += vma_pages(vma);
89672 + vma->vm_mirror = NULL;
89673 vma = remove_vma(vma);
89674 }
89675 vm_unacct_memory(nr_accounted);
89676 @@ -2738,6 +3227,13 @@ int insert_vm_struct(struct mm_struct *mm, struct vm_area_struct *vma)
89677 struct vm_area_struct *prev;
89678 struct rb_node **rb_link, *rb_parent;
89679
89680 +#ifdef CONFIG_PAX_SEGMEXEC
89681 + struct vm_area_struct *vma_m = NULL;
89682 +#endif
89683 +
89684 + if (security_mmap_addr(vma->vm_start))
89685 + return -EPERM;
89686 +
89687 /*
89688 * The vm_pgoff of a purely anonymous vma should be irrelevant
89689 * until its first write fault, when page's anon_vma and index
89690 @@ -2761,7 +3257,21 @@ int insert_vm_struct(struct mm_struct *mm, struct vm_area_struct *vma)
89691 security_vm_enough_memory_mm(mm, vma_pages(vma)))
89692 return -ENOMEM;
89693
89694 +#ifdef CONFIG_PAX_SEGMEXEC
89695 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && (vma->vm_flags & VM_EXEC)) {
89696 + vma_m = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
89697 + if (!vma_m)
89698 + return -ENOMEM;
89699 + }
89700 +#endif
89701 +
89702 vma_link(mm, vma, prev, rb_link, rb_parent);
89703 +
89704 +#ifdef CONFIG_PAX_SEGMEXEC
89705 + if (vma_m)
89706 + BUG_ON(pax_mirror_vma(vma_m, vma));
89707 +#endif
89708 +
89709 return 0;
89710 }
89711
89712 @@ -2780,6 +3290,8 @@ struct vm_area_struct *copy_vma(struct vm_area_struct **vmap,
89713 struct rb_node **rb_link, *rb_parent;
89714 bool faulted_in_anon_vma = true;
89715
89716 + BUG_ON(vma->vm_mirror);
89717 +
89718 /*
89719 * If anonymous vma has not yet been faulted, update new pgoff
89720 * to match new location, to increase its chance of merging.
89721 @@ -2844,6 +3356,39 @@ struct vm_area_struct *copy_vma(struct vm_area_struct **vmap,
89722 return NULL;
89723 }
89724
89725 +#ifdef CONFIG_PAX_SEGMEXEC
89726 +long pax_mirror_vma(struct vm_area_struct *vma_m, struct vm_area_struct *vma)
89727 +{
89728 + struct vm_area_struct *prev_m;
89729 + struct rb_node **rb_link_m, *rb_parent_m;
89730 + struct mempolicy *pol_m;
89731 +
89732 + BUG_ON(!(vma->vm_mm->pax_flags & MF_PAX_SEGMEXEC) || !(vma->vm_flags & VM_EXEC));
89733 + BUG_ON(vma->vm_mirror || vma_m->vm_mirror);
89734 + BUG_ON(!mpol_equal(vma_policy(vma), vma_policy(vma_m)));
89735 + *vma_m = *vma;
89736 + INIT_LIST_HEAD(&vma_m->anon_vma_chain);
89737 + if (anon_vma_clone(vma_m, vma))
89738 + return -ENOMEM;
89739 + pol_m = vma_policy(vma_m);
89740 + mpol_get(pol_m);
89741 + set_vma_policy(vma_m, pol_m);
89742 + vma_m->vm_start += SEGMEXEC_TASK_SIZE;
89743 + vma_m->vm_end += SEGMEXEC_TASK_SIZE;
89744 + vma_m->vm_flags &= ~(VM_WRITE | VM_MAYWRITE | VM_ACCOUNT | VM_LOCKED);
89745 + vma_m->vm_page_prot = vm_get_page_prot(vma_m->vm_flags);
89746 + if (vma_m->vm_file)
89747 + get_file(vma_m->vm_file);
89748 + if (vma_m->vm_ops && vma_m->vm_ops->open)
89749 + vma_m->vm_ops->open(vma_m);
89750 + BUG_ON(find_vma_links(vma->vm_mm, vma_m->vm_start, vma_m->vm_end, &prev_m, &rb_link_m, &rb_parent_m));
89751 + vma_link(vma->vm_mm, vma_m, prev_m, rb_link_m, rb_parent_m);
89752 + vma_m->vm_mirror = vma;
89753 + vma->vm_mirror = vma_m;
89754 + return 0;
89755 +}
89756 +#endif
89757 +
89758 /*
89759 * Return true if the calling process may expand its vm space by the passed
89760 * number of pages
89761 @@ -2855,6 +3400,7 @@ int may_expand_vm(struct mm_struct *mm, unsigned long npages)
89762
89763 lim = rlimit(RLIMIT_AS) >> PAGE_SHIFT;
89764
89765 + gr_learn_resource(current, RLIMIT_AS, (cur + npages) << PAGE_SHIFT, 1);
89766 if (cur + npages > lim)
89767 return 0;
89768 return 1;
89769 @@ -2925,6 +3471,22 @@ int install_special_mapping(struct mm_struct *mm,
89770 vma->vm_start = addr;
89771 vma->vm_end = addr + len;
89772
89773 +#ifdef CONFIG_PAX_MPROTECT
89774 + if (mm->pax_flags & MF_PAX_MPROTECT) {
89775 +#ifndef CONFIG_PAX_MPROTECT_COMPAT
89776 + if ((vm_flags & (VM_WRITE | VM_EXEC)) == (VM_WRITE | VM_EXEC))
89777 + return -EPERM;
89778 + if (!(vm_flags & VM_EXEC))
89779 + vm_flags &= ~VM_MAYEXEC;
89780 +#else
89781 + if ((vm_flags & (VM_WRITE | VM_EXEC)) != VM_EXEC)
89782 + vm_flags &= ~(VM_EXEC | VM_MAYEXEC);
89783 +#endif
89784 + else
89785 + vm_flags &= ~VM_MAYWRITE;
89786 + }
89787 +#endif
89788 +
89789 vma->vm_flags = vm_flags | mm->def_flags | VM_DONTEXPAND | VM_SOFTDIRTY;
89790 vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
89791
89792 diff --git a/mm/mprotect.c b/mm/mprotect.c
89793 index 6c3f56f..b2340b0 100644
89794 --- a/mm/mprotect.c
89795 +++ b/mm/mprotect.c
89796 @@ -23,10 +23,18 @@
89797 #include <linux/mmu_notifier.h>
89798 #include <linux/migrate.h>
89799 #include <linux/perf_event.h>
89800 +#include <linux/sched/sysctl.h>
89801 +
89802 +#ifdef CONFIG_PAX_MPROTECT
89803 +#include <linux/elf.h>
89804 +#include <linux/binfmts.h>
89805 +#endif
89806 +
89807 #include <asm/uaccess.h>
89808 #include <asm/pgtable.h>
89809 #include <asm/cacheflush.h>
89810 #include <asm/tlbflush.h>
89811 +#include <asm/mmu_context.h>
89812
89813 #ifndef pgprot_modify
89814 static inline pgprot_t pgprot_modify(pgprot_t oldprot, pgprot_t newprot)
89815 @@ -241,6 +249,48 @@ unsigned long change_protection(struct vm_area_struct *vma, unsigned long start,
89816 return pages;
89817 }
89818
89819 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
89820 +/* called while holding the mmap semaphor for writing except stack expansion */
89821 +void track_exec_limit(struct mm_struct *mm, unsigned long start, unsigned long end, unsigned long prot)
89822 +{
89823 + unsigned long oldlimit, newlimit = 0UL;
89824 +
89825 + if (!(mm->pax_flags & MF_PAX_PAGEEXEC) || (__supported_pte_mask & _PAGE_NX))
89826 + return;
89827 +
89828 + spin_lock(&mm->page_table_lock);
89829 + oldlimit = mm->context.user_cs_limit;
89830 + if ((prot & VM_EXEC) && oldlimit < end)
89831 + /* USER_CS limit moved up */
89832 + newlimit = end;
89833 + else if (!(prot & VM_EXEC) && start < oldlimit && oldlimit <= end)
89834 + /* USER_CS limit moved down */
89835 + newlimit = start;
89836 +
89837 + if (newlimit) {
89838 + mm->context.user_cs_limit = newlimit;
89839 +
89840 +#ifdef CONFIG_SMP
89841 + wmb();
89842 + cpus_clear(mm->context.cpu_user_cs_mask);
89843 + cpu_set(smp_processor_id(), mm->context.cpu_user_cs_mask);
89844 +#endif
89845 +
89846 + set_user_cs(mm->context.user_cs_base, mm->context.user_cs_limit, smp_processor_id());
89847 + }
89848 + spin_unlock(&mm->page_table_lock);
89849 + if (newlimit == end) {
89850 + struct vm_area_struct *vma = find_vma(mm, oldlimit);
89851 +
89852 + for (; vma && vma->vm_start < end; vma = vma->vm_next)
89853 + if (is_vm_hugetlb_page(vma))
89854 + hugetlb_change_protection(vma, vma->vm_start, vma->vm_end, vma->vm_page_prot);
89855 + else
89856 + change_protection(vma, vma->vm_start, vma->vm_end, vma->vm_page_prot, vma_wants_writenotify(vma), 0);
89857 + }
89858 +}
89859 +#endif
89860 +
89861 int
89862 mprotect_fixup(struct vm_area_struct *vma, struct vm_area_struct **pprev,
89863 unsigned long start, unsigned long end, unsigned long newflags)
89864 @@ -253,11 +303,29 @@ mprotect_fixup(struct vm_area_struct *vma, struct vm_area_struct **pprev,
89865 int error;
89866 int dirty_accountable = 0;
89867
89868 +#ifdef CONFIG_PAX_SEGMEXEC
89869 + struct vm_area_struct *vma_m = NULL;
89870 + unsigned long start_m, end_m;
89871 +
89872 + start_m = start + SEGMEXEC_TASK_SIZE;
89873 + end_m = end + SEGMEXEC_TASK_SIZE;
89874 +#endif
89875 +
89876 if (newflags == oldflags) {
89877 *pprev = vma;
89878 return 0;
89879 }
89880
89881 + if (newflags & (VM_READ | VM_WRITE | VM_EXEC)) {
89882 + struct vm_area_struct *prev = vma->vm_prev, *next = vma->vm_next;
89883 +
89884 + if (next && (next->vm_flags & VM_GROWSDOWN) && sysctl_heap_stack_gap > next->vm_start - end)
89885 + return -ENOMEM;
89886 +
89887 + if (prev && (prev->vm_flags & VM_GROWSUP) && sysctl_heap_stack_gap > start - prev->vm_end)
89888 + return -ENOMEM;
89889 + }
89890 +
89891 /*
89892 * If we make a private mapping writable we increase our commit;
89893 * but (without finer accounting) cannot reduce our commit if we
89894 @@ -274,6 +342,42 @@ mprotect_fixup(struct vm_area_struct *vma, struct vm_area_struct **pprev,
89895 }
89896 }
89897
89898 +#ifdef CONFIG_PAX_SEGMEXEC
89899 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && ((oldflags ^ newflags) & VM_EXEC)) {
89900 + if (start != vma->vm_start) {
89901 + error = split_vma(mm, vma, start, 1);
89902 + if (error)
89903 + goto fail;
89904 + BUG_ON(!*pprev || (*pprev)->vm_next == vma);
89905 + *pprev = (*pprev)->vm_next;
89906 + }
89907 +
89908 + if (end != vma->vm_end) {
89909 + error = split_vma(mm, vma, end, 0);
89910 + if (error)
89911 + goto fail;
89912 + }
89913 +
89914 + if (pax_find_mirror_vma(vma)) {
89915 + error = __do_munmap(mm, start_m, end_m - start_m);
89916 + if (error)
89917 + goto fail;
89918 + } else {
89919 + vma_m = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
89920 + if (!vma_m) {
89921 + error = -ENOMEM;
89922 + goto fail;
89923 + }
89924 + vma->vm_flags = newflags;
89925 + error = pax_mirror_vma(vma_m, vma);
89926 + if (error) {
89927 + vma->vm_flags = oldflags;
89928 + goto fail;
89929 + }
89930 + }
89931 + }
89932 +#endif
89933 +
89934 /*
89935 * First try to merge with previous and/or next vma.
89936 */
89937 @@ -304,9 +408,21 @@ success:
89938 * vm_flags and vm_page_prot are protected by the mmap_sem
89939 * held in write mode.
89940 */
89941 +
89942 +#ifdef CONFIG_PAX_SEGMEXEC
89943 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && (newflags & VM_EXEC) && ((vma->vm_flags ^ newflags) & VM_READ))
89944 + pax_find_mirror_vma(vma)->vm_flags ^= VM_READ;
89945 +#endif
89946 +
89947 vma->vm_flags = newflags;
89948 +
89949 +#ifdef CONFIG_PAX_MPROTECT
89950 + if (mm->binfmt && mm->binfmt->handle_mprotect)
89951 + mm->binfmt->handle_mprotect(vma, newflags);
89952 +#endif
89953 +
89954 vma->vm_page_prot = pgprot_modify(vma->vm_page_prot,
89955 - vm_get_page_prot(newflags));
89956 + vm_get_page_prot(vma->vm_flags));
89957
89958 if (vma_wants_writenotify(vma)) {
89959 vma->vm_page_prot = vm_get_page_prot(newflags & ~VM_SHARED);
89960 @@ -345,6 +461,17 @@ SYSCALL_DEFINE3(mprotect, unsigned long, start, size_t, len,
89961 end = start + len;
89962 if (end <= start)
89963 return -ENOMEM;
89964 +
89965 +#ifdef CONFIG_PAX_SEGMEXEC
89966 + if (current->mm->pax_flags & MF_PAX_SEGMEXEC) {
89967 + if (end > SEGMEXEC_TASK_SIZE)
89968 + return -EINVAL;
89969 + } else
89970 +#endif
89971 +
89972 + if (end > TASK_SIZE)
89973 + return -EINVAL;
89974 +
89975 if (!arch_validate_prot(prot))
89976 return -EINVAL;
89977
89978 @@ -352,7 +479,7 @@ SYSCALL_DEFINE3(mprotect, unsigned long, start, size_t, len,
89979 /*
89980 * Does the application expect PROT_READ to imply PROT_EXEC:
89981 */
89982 - if ((prot & PROT_READ) && (current->personality & READ_IMPLIES_EXEC))
89983 + if ((prot & (PROT_READ | PROT_WRITE)) && (current->personality & READ_IMPLIES_EXEC))
89984 prot |= PROT_EXEC;
89985
89986 vm_flags = calc_vm_prot_bits(prot);
89987 @@ -384,6 +511,11 @@ SYSCALL_DEFINE3(mprotect, unsigned long, start, size_t, len,
89988 if (start > vma->vm_start)
89989 prev = vma;
89990
89991 +#ifdef CONFIG_PAX_MPROTECT
89992 + if (current->mm->binfmt && current->mm->binfmt->handle_mprotect)
89993 + current->mm->binfmt->handle_mprotect(vma, vm_flags);
89994 +#endif
89995 +
89996 for (nstart = start ; ; ) {
89997 unsigned long newflags;
89998
89999 @@ -394,6 +526,14 @@ SYSCALL_DEFINE3(mprotect, unsigned long, start, size_t, len,
90000
90001 /* newflags >> 4 shift VM_MAY% in place of VM_% */
90002 if ((newflags & ~(newflags >> 4)) & (VM_READ | VM_WRITE | VM_EXEC)) {
90003 + if (prot & (PROT_WRITE | PROT_EXEC))
90004 + gr_log_rwxmprotect(vma);
90005 +
90006 + error = -EACCES;
90007 + goto out;
90008 + }
90009 +
90010 + if (!gr_acl_handle_mprotect(vma->vm_file, prot)) {
90011 error = -EACCES;
90012 goto out;
90013 }
90014 @@ -408,6 +548,9 @@ SYSCALL_DEFINE3(mprotect, unsigned long, start, size_t, len,
90015 error = mprotect_fixup(vma, &prev, nstart, tmp, newflags);
90016 if (error)
90017 goto out;
90018 +
90019 + track_exec_limit(current->mm, nstart, tmp, vm_flags);
90020 +
90021 nstart = tmp;
90022
90023 if (nstart < prev->vm_end)
90024 diff --git a/mm/mremap.c b/mm/mremap.c
90025 index 0843feb..4f5b2e6 100644
90026 --- a/mm/mremap.c
90027 +++ b/mm/mremap.c
90028 @@ -144,6 +144,12 @@ static void move_ptes(struct vm_area_struct *vma, pmd_t *old_pmd,
90029 continue;
90030 pte = ptep_get_and_clear(mm, old_addr, old_pte);
90031 pte = move_pte(pte, new_vma->vm_page_prot, old_addr, new_addr);
90032 +
90033 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
90034 + if (!(__supported_pte_mask & _PAGE_NX) && pte_present(pte) && (new_vma->vm_flags & (VM_PAGEEXEC | VM_EXEC)) == VM_PAGEEXEC)
90035 + pte = pte_exprotect(pte);
90036 +#endif
90037 +
90038 pte = move_soft_dirty_pte(pte);
90039 set_pte_at(mm, new_addr, new_pte, pte);
90040 }
90041 @@ -337,6 +343,11 @@ static struct vm_area_struct *vma_to_resize(unsigned long addr,
90042 if (is_vm_hugetlb_page(vma))
90043 goto Einval;
90044
90045 +#ifdef CONFIG_PAX_SEGMEXEC
90046 + if (pax_find_mirror_vma(vma))
90047 + goto Einval;
90048 +#endif
90049 +
90050 /* We can't remap across vm area boundaries */
90051 if (old_len > vma->vm_end - addr)
90052 goto Efault;
90053 @@ -392,20 +403,25 @@ static unsigned long mremap_to(unsigned long addr, unsigned long old_len,
90054 unsigned long ret = -EINVAL;
90055 unsigned long charged = 0;
90056 unsigned long map_flags;
90057 + unsigned long pax_task_size = TASK_SIZE;
90058
90059 if (new_addr & ~PAGE_MASK)
90060 goto out;
90061
90062 - if (new_len > TASK_SIZE || new_addr > TASK_SIZE - new_len)
90063 +#ifdef CONFIG_PAX_SEGMEXEC
90064 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
90065 + pax_task_size = SEGMEXEC_TASK_SIZE;
90066 +#endif
90067 +
90068 + pax_task_size -= PAGE_SIZE;
90069 +
90070 + if (new_len > TASK_SIZE || new_addr > pax_task_size - new_len)
90071 goto out;
90072
90073 /* Check if the location we're moving into overlaps the
90074 * old location at all, and fail if it does.
90075 */
90076 - if ((new_addr <= addr) && (new_addr+new_len) > addr)
90077 - goto out;
90078 -
90079 - if ((addr <= new_addr) && (addr+old_len) > new_addr)
90080 + if (addr + old_len > new_addr && new_addr + new_len > addr)
90081 goto out;
90082
90083 ret = do_munmap(mm, new_addr, new_len);
90084 @@ -474,6 +490,7 @@ SYSCALL_DEFINE5(mremap, unsigned long, addr, unsigned long, old_len,
90085 unsigned long ret = -EINVAL;
90086 unsigned long charged = 0;
90087 bool locked = false;
90088 + unsigned long pax_task_size = TASK_SIZE;
90089
90090 if (flags & ~(MREMAP_FIXED | MREMAP_MAYMOVE))
90091 return ret;
90092 @@ -495,6 +512,17 @@ SYSCALL_DEFINE5(mremap, unsigned long, addr, unsigned long, old_len,
90093 if (!new_len)
90094 return ret;
90095
90096 +#ifdef CONFIG_PAX_SEGMEXEC
90097 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
90098 + pax_task_size = SEGMEXEC_TASK_SIZE;
90099 +#endif
90100 +
90101 + pax_task_size -= PAGE_SIZE;
90102 +
90103 + if (new_len > pax_task_size || addr > pax_task_size-new_len ||
90104 + old_len > pax_task_size || addr > pax_task_size-old_len)
90105 + return ret;
90106 +
90107 down_write(&current->mm->mmap_sem);
90108
90109 if (flags & MREMAP_FIXED) {
90110 @@ -545,6 +573,7 @@ SYSCALL_DEFINE5(mremap, unsigned long, addr, unsigned long, old_len,
90111 new_addr = addr;
90112 }
90113 ret = addr;
90114 + track_exec_limit(vma->vm_mm, vma->vm_start, addr + new_len, vma->vm_flags);
90115 goto out;
90116 }
90117 }
90118 @@ -568,7 +597,12 @@ SYSCALL_DEFINE5(mremap, unsigned long, addr, unsigned long, old_len,
90119 goto out;
90120 }
90121
90122 + map_flags = vma->vm_flags;
90123 ret = move_vma(vma, addr, old_len, new_len, new_addr, &locked);
90124 + if (!(ret & ~PAGE_MASK)) {
90125 + track_exec_limit(current->mm, addr, addr + old_len, 0UL);
90126 + track_exec_limit(current->mm, new_addr, new_addr + new_len, map_flags);
90127 + }
90128 }
90129 out:
90130 if (ret & ~PAGE_MASK)
90131 diff --git a/mm/nommu.c b/mm/nommu.c
90132 index ecd1f15..77039bd 100644
90133 --- a/mm/nommu.c
90134 +++ b/mm/nommu.c
90135 @@ -64,7 +64,6 @@ int sysctl_max_map_count = DEFAULT_MAX_MAP_COUNT;
90136 int sysctl_nr_trim_pages = CONFIG_NOMMU_INITIAL_TRIM_EXCESS;
90137 unsigned long sysctl_user_reserve_kbytes __read_mostly = 1UL << 17; /* 128MB */
90138 unsigned long sysctl_admin_reserve_kbytes __read_mostly = 1UL << 13; /* 8MB */
90139 -int heap_stack_gap = 0;
90140
90141 atomic_long_t mmap_pages_allocated;
90142
90143 @@ -844,15 +843,6 @@ struct vm_area_struct *find_vma(struct mm_struct *mm, unsigned long addr)
90144 EXPORT_SYMBOL(find_vma);
90145
90146 /*
90147 - * find a VMA
90148 - * - we don't extend stack VMAs under NOMMU conditions
90149 - */
90150 -struct vm_area_struct *find_extend_vma(struct mm_struct *mm, unsigned long addr)
90151 -{
90152 - return find_vma(mm, addr);
90153 -}
90154 -
90155 -/*
90156 * expand a stack to a given address
90157 * - not supported under NOMMU conditions
90158 */
90159 @@ -1563,6 +1553,7 @@ int split_vma(struct mm_struct *mm, struct vm_area_struct *vma,
90160
90161 /* most fields are the same, copy all, and then fixup */
90162 *new = *vma;
90163 + INIT_LIST_HEAD(&new->anon_vma_chain);
90164 *region = *vma->vm_region;
90165 new->vm_region = region;
90166
90167 @@ -1993,8 +1984,8 @@ int generic_file_remap_pages(struct vm_area_struct *vma, unsigned long addr,
90168 }
90169 EXPORT_SYMBOL(generic_file_remap_pages);
90170
90171 -static int __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
90172 - unsigned long addr, void *buf, int len, int write)
90173 +static ssize_t __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
90174 + unsigned long addr, void *buf, size_t len, int write)
90175 {
90176 struct vm_area_struct *vma;
90177
90178 @@ -2035,8 +2026,8 @@ static int __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
90179 *
90180 * The caller must hold a reference on @mm.
90181 */
90182 -int access_remote_vm(struct mm_struct *mm, unsigned long addr,
90183 - void *buf, int len, int write)
90184 +ssize_t access_remote_vm(struct mm_struct *mm, unsigned long addr,
90185 + void *buf, size_t len, int write)
90186 {
90187 return __access_remote_vm(NULL, mm, addr, buf, len, write);
90188 }
90189 @@ -2045,7 +2036,7 @@ int access_remote_vm(struct mm_struct *mm, unsigned long addr,
90190 * Access another process' address space.
90191 * - source/target buffer must be kernel space
90192 */
90193 -int access_process_vm(struct task_struct *tsk, unsigned long addr, void *buf, int len, int write)
90194 +ssize_t access_process_vm(struct task_struct *tsk, unsigned long addr, void *buf, size_t len, int write)
90195 {
90196 struct mm_struct *mm;
90197
90198 diff --git a/mm/page-writeback.c b/mm/page-writeback.c
90199 index 6380758..4064aec 100644
90200 --- a/mm/page-writeback.c
90201 +++ b/mm/page-writeback.c
90202 @@ -690,7 +690,7 @@ static inline long long pos_ratio_polynom(unsigned long setpoint,
90203 * card's bdi_dirty may rush to many times higher than bdi_setpoint.
90204 * - the bdi dirty thresh drops quickly due to change of JBOD workload
90205 */
90206 -static unsigned long bdi_position_ratio(struct backing_dev_info *bdi,
90207 +static unsigned long __intentional_overflow(-1) bdi_position_ratio(struct backing_dev_info *bdi,
90208 unsigned long thresh,
90209 unsigned long bg_thresh,
90210 unsigned long dirty,
90211 diff --git a/mm/page_alloc.c b/mm/page_alloc.c
90212 index dd886fa..7686339 100644
90213 --- a/mm/page_alloc.c
90214 +++ b/mm/page_alloc.c
90215 @@ -61,6 +61,7 @@
90216 #include <linux/page-debug-flags.h>
90217 #include <linux/hugetlb.h>
90218 #include <linux/sched/rt.h>
90219 +#include <linux/random.h>
90220
90221 #include <asm/sections.h>
90222 #include <asm/tlbflush.h>
90223 @@ -354,7 +355,7 @@ out:
90224 * This usage means that zero-order pages may not be compound.
90225 */
90226
90227 -static void free_compound_page(struct page *page)
90228 +void free_compound_page(struct page *page)
90229 {
90230 __free_pages_ok(page, compound_order(page));
90231 }
90232 @@ -712,6 +713,10 @@ static bool free_pages_prepare(struct page *page, unsigned int order)
90233 int i;
90234 int bad = 0;
90235
90236 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
90237 + unsigned long index = 1UL << order;
90238 +#endif
90239 +
90240 trace_mm_page_free(page, order);
90241 kmemcheck_free_shadow(page, order);
90242
90243 @@ -728,6 +733,12 @@ static bool free_pages_prepare(struct page *page, unsigned int order)
90244 debug_check_no_obj_freed(page_address(page),
90245 PAGE_SIZE << order);
90246 }
90247 +
90248 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
90249 + for (; index; --index)
90250 + sanitize_highpage(page + index - 1);
90251 +#endif
90252 +
90253 arch_free_page(page, order);
90254 kernel_map_pages(page, 1 << order, 0);
90255
90256 @@ -750,6 +761,20 @@ static void __free_pages_ok(struct page *page, unsigned int order)
90257 local_irq_restore(flags);
90258 }
90259
90260 +#ifdef CONFIG_PAX_LATENT_ENTROPY
90261 +bool __meminitdata extra_latent_entropy;
90262 +
90263 +static int __init setup_pax_extra_latent_entropy(char *str)
90264 +{
90265 + extra_latent_entropy = true;
90266 + return 0;
90267 +}
90268 +early_param("pax_extra_latent_entropy", setup_pax_extra_latent_entropy);
90269 +
90270 +volatile u64 latent_entropy __latent_entropy;
90271 +EXPORT_SYMBOL(latent_entropy);
90272 +#endif
90273 +
90274 void __init __free_pages_bootmem(struct page *page, unsigned int order)
90275 {
90276 unsigned int nr_pages = 1 << order;
90277 @@ -765,6 +790,19 @@ void __init __free_pages_bootmem(struct page *page, unsigned int order)
90278 __ClearPageReserved(p);
90279 set_page_count(p, 0);
90280
90281 +#ifdef CONFIG_PAX_LATENT_ENTROPY
90282 + if (extra_latent_entropy && !PageHighMem(page) && page_to_pfn(page) < 0x100000) {
90283 + u64 hash = 0;
90284 + size_t index, end = PAGE_SIZE * nr_pages / sizeof hash;
90285 + const u64 *data = lowmem_page_address(page);
90286 +
90287 + for (index = 0; index < end; index++)
90288 + hash ^= hash + data[index];
90289 + latent_entropy ^= hash;
90290 + add_device_randomness((const void *)&latent_entropy, sizeof(latent_entropy));
90291 + }
90292 +#endif
90293 +
90294 page_zone(page)->managed_pages += nr_pages;
90295 set_page_refcounted(page);
90296 __free_pages(page, order);
90297 @@ -870,8 +908,10 @@ static int prep_new_page(struct page *page, int order, gfp_t gfp_flags)
90298 arch_alloc_page(page, order);
90299 kernel_map_pages(page, 1 << order, 1);
90300
90301 +#ifndef CONFIG_PAX_MEMORY_SANITIZE
90302 if (gfp_flags & __GFP_ZERO)
90303 prep_zero_page(page, order, gfp_flags);
90304 +#endif
90305
90306 if (order && (gfp_flags & __GFP_COMP))
90307 prep_compound_page(page, order);
90308 diff --git a/mm/page_io.c b/mm/page_io.c
90309 index 8c79a47..a689e0d 100644
90310 --- a/mm/page_io.c
90311 +++ b/mm/page_io.c
90312 @@ -260,7 +260,7 @@ int __swap_writepage(struct page *page, struct writeback_control *wbc,
90313 struct file *swap_file = sis->swap_file;
90314 struct address_space *mapping = swap_file->f_mapping;
90315 struct iovec iov = {
90316 - .iov_base = kmap(page),
90317 + .iov_base = (void __force_user *)kmap(page),
90318 .iov_len = PAGE_SIZE,
90319 };
90320
90321 diff --git a/mm/percpu.c b/mm/percpu.c
90322 index 8c8e08f..73a5cda 100644
90323 --- a/mm/percpu.c
90324 +++ b/mm/percpu.c
90325 @@ -122,7 +122,7 @@ static unsigned int pcpu_low_unit_cpu __read_mostly;
90326 static unsigned int pcpu_high_unit_cpu __read_mostly;
90327
90328 /* the address of the first chunk which starts with the kernel static area */
90329 -void *pcpu_base_addr __read_mostly;
90330 +void *pcpu_base_addr __read_only;
90331 EXPORT_SYMBOL_GPL(pcpu_base_addr);
90332
90333 static const int *pcpu_unit_map __read_mostly; /* cpu -> unit */
90334 diff --git a/mm/process_vm_access.c b/mm/process_vm_access.c
90335 index fd26d04..0cea1b0 100644
90336 --- a/mm/process_vm_access.c
90337 +++ b/mm/process_vm_access.c
90338 @@ -13,6 +13,7 @@
90339 #include <linux/uio.h>
90340 #include <linux/sched.h>
90341 #include <linux/highmem.h>
90342 +#include <linux/security.h>
90343 #include <linux/ptrace.h>
90344 #include <linux/slab.h>
90345 #include <linux/syscalls.h>
90346 @@ -258,19 +259,19 @@ static ssize_t process_vm_rw_core(pid_t pid, const struct iovec *lvec,
90347 size_t iov_l_curr_offset = 0;
90348 ssize_t iov_len;
90349
90350 + return -ENOSYS; // PaX: until properly audited
90351 +
90352 /*
90353 * Work out how many pages of struct pages we're going to need
90354 * when eventually calling get_user_pages
90355 */
90356 for (i = 0; i < riovcnt; i++) {
90357 iov_len = rvec[i].iov_len;
90358 - if (iov_len > 0) {
90359 - nr_pages_iov = ((unsigned long)rvec[i].iov_base
90360 - + iov_len)
90361 - / PAGE_SIZE - (unsigned long)rvec[i].iov_base
90362 - / PAGE_SIZE + 1;
90363 - nr_pages = max(nr_pages, nr_pages_iov);
90364 - }
90365 + if (iov_len <= 0)
90366 + continue;
90367 + nr_pages_iov = ((unsigned long)rvec[i].iov_base + iov_len) / PAGE_SIZE -
90368 + (unsigned long)rvec[i].iov_base / PAGE_SIZE + 1;
90369 + nr_pages = max(nr_pages, nr_pages_iov);
90370 }
90371
90372 if (nr_pages == 0)
90373 @@ -298,6 +299,11 @@ static ssize_t process_vm_rw_core(pid_t pid, const struct iovec *lvec,
90374 goto free_proc_pages;
90375 }
90376
90377 + if (gr_handle_ptrace(task, vm_write ? PTRACE_POKETEXT : PTRACE_ATTACH)) {
90378 + rc = -EPERM;
90379 + goto put_task_struct;
90380 + }
90381 +
90382 mm = mm_access(task, PTRACE_MODE_ATTACH);
90383 if (!mm || IS_ERR(mm)) {
90384 rc = IS_ERR(mm) ? PTR_ERR(mm) : -ESRCH;
90385 diff --git a/mm/rmap.c b/mm/rmap.c
90386 index fd3ee7a..3613079 100644
90387 --- a/mm/rmap.c
90388 +++ b/mm/rmap.c
90389 @@ -163,6 +163,10 @@ int anon_vma_prepare(struct vm_area_struct *vma)
90390 struct anon_vma *anon_vma = vma->anon_vma;
90391 struct anon_vma_chain *avc;
90392
90393 +#ifdef CONFIG_PAX_SEGMEXEC
90394 + struct anon_vma_chain *avc_m = NULL;
90395 +#endif
90396 +
90397 might_sleep();
90398 if (unlikely(!anon_vma)) {
90399 struct mm_struct *mm = vma->vm_mm;
90400 @@ -172,6 +176,12 @@ int anon_vma_prepare(struct vm_area_struct *vma)
90401 if (!avc)
90402 goto out_enomem;
90403
90404 +#ifdef CONFIG_PAX_SEGMEXEC
90405 + avc_m = anon_vma_chain_alloc(GFP_KERNEL);
90406 + if (!avc_m)
90407 + goto out_enomem_free_avc;
90408 +#endif
90409 +
90410 anon_vma = find_mergeable_anon_vma(vma);
90411 allocated = NULL;
90412 if (!anon_vma) {
90413 @@ -185,6 +195,18 @@ int anon_vma_prepare(struct vm_area_struct *vma)
90414 /* page_table_lock to protect against threads */
90415 spin_lock(&mm->page_table_lock);
90416 if (likely(!vma->anon_vma)) {
90417 +
90418 +#ifdef CONFIG_PAX_SEGMEXEC
90419 + struct vm_area_struct *vma_m = pax_find_mirror_vma(vma);
90420 +
90421 + if (vma_m) {
90422 + BUG_ON(vma_m->anon_vma);
90423 + vma_m->anon_vma = anon_vma;
90424 + anon_vma_chain_link(vma_m, avc_m, anon_vma);
90425 + avc_m = NULL;
90426 + }
90427 +#endif
90428 +
90429 vma->anon_vma = anon_vma;
90430 anon_vma_chain_link(vma, avc, anon_vma);
90431 allocated = NULL;
90432 @@ -195,12 +217,24 @@ int anon_vma_prepare(struct vm_area_struct *vma)
90433
90434 if (unlikely(allocated))
90435 put_anon_vma(allocated);
90436 +
90437 +#ifdef CONFIG_PAX_SEGMEXEC
90438 + if (unlikely(avc_m))
90439 + anon_vma_chain_free(avc_m);
90440 +#endif
90441 +
90442 if (unlikely(avc))
90443 anon_vma_chain_free(avc);
90444 }
90445 return 0;
90446
90447 out_enomem_free_avc:
90448 +
90449 +#ifdef CONFIG_PAX_SEGMEXEC
90450 + if (avc_m)
90451 + anon_vma_chain_free(avc_m);
90452 +#endif
90453 +
90454 anon_vma_chain_free(avc);
90455 out_enomem:
90456 return -ENOMEM;
90457 @@ -236,7 +270,7 @@ static inline void unlock_anon_vma_root(struct anon_vma *root)
90458 * Attach the anon_vmas from src to dst.
90459 * Returns 0 on success, -ENOMEM on failure.
90460 */
90461 -int anon_vma_clone(struct vm_area_struct *dst, struct vm_area_struct *src)
90462 +int anon_vma_clone(struct vm_area_struct *dst, const struct vm_area_struct *src)
90463 {
90464 struct anon_vma_chain *avc, *pavc;
90465 struct anon_vma *root = NULL;
90466 @@ -269,7 +303,7 @@ int anon_vma_clone(struct vm_area_struct *dst, struct vm_area_struct *src)
90467 * the corresponding VMA in the parent process is attached to.
90468 * Returns 0 on success, non-zero on failure.
90469 */
90470 -int anon_vma_fork(struct vm_area_struct *vma, struct vm_area_struct *pvma)
90471 +int anon_vma_fork(struct vm_area_struct *vma, const struct vm_area_struct *pvma)
90472 {
90473 struct anon_vma_chain *avc;
90474 struct anon_vma *anon_vma;
90475 @@ -373,8 +407,10 @@ static void anon_vma_ctor(void *data)
90476 void __init anon_vma_init(void)
90477 {
90478 anon_vma_cachep = kmem_cache_create("anon_vma", sizeof(struct anon_vma),
90479 - 0, SLAB_DESTROY_BY_RCU|SLAB_PANIC, anon_vma_ctor);
90480 - anon_vma_chain_cachep = KMEM_CACHE(anon_vma_chain, SLAB_PANIC);
90481 + 0, SLAB_DESTROY_BY_RCU|SLAB_PANIC|SLAB_NO_SANITIZE,
90482 + anon_vma_ctor);
90483 + anon_vma_chain_cachep = KMEM_CACHE(anon_vma_chain,
90484 + SLAB_PANIC|SLAB_NO_SANITIZE);
90485 }
90486
90487 /*
90488 diff --git a/mm/shmem.c b/mm/shmem.c
90489 index 8297623..6b9dfe9 100644
90490 --- a/mm/shmem.c
90491 +++ b/mm/shmem.c
90492 @@ -33,7 +33,7 @@
90493 #include <linux/swap.h>
90494 #include <linux/aio.h>
90495
90496 -static struct vfsmount *shm_mnt;
90497 +struct vfsmount *shm_mnt;
90498
90499 #ifdef CONFIG_SHMEM
90500 /*
90501 @@ -77,7 +77,7 @@ static struct vfsmount *shm_mnt;
90502 #define BOGO_DIRENT_SIZE 20
90503
90504 /* Symlink up to this size is kmalloc'ed instead of using a swappable page */
90505 -#define SHORT_SYMLINK_LEN 128
90506 +#define SHORT_SYMLINK_LEN 64
90507
90508 /*
90509 * shmem_fallocate and shmem_writepage communicate via inode->i_private
90510 @@ -2232,6 +2232,11 @@ static const struct xattr_handler *shmem_xattr_handlers[] = {
90511 static int shmem_xattr_validate(const char *name)
90512 {
90513 struct { const char *prefix; size_t len; } arr[] = {
90514 +
90515 +#ifdef CONFIG_PAX_XATTR_PAX_FLAGS
90516 + { XATTR_USER_PREFIX, XATTR_USER_PREFIX_LEN},
90517 +#endif
90518 +
90519 { XATTR_SECURITY_PREFIX, XATTR_SECURITY_PREFIX_LEN },
90520 { XATTR_TRUSTED_PREFIX, XATTR_TRUSTED_PREFIX_LEN }
90521 };
90522 @@ -2287,6 +2292,15 @@ static int shmem_setxattr(struct dentry *dentry, const char *name,
90523 if (err)
90524 return err;
90525
90526 +#ifdef CONFIG_PAX_XATTR_PAX_FLAGS
90527 + if (!strncmp(name, XATTR_USER_PREFIX, XATTR_USER_PREFIX_LEN)) {
90528 + if (strcmp(name, XATTR_NAME_PAX_FLAGS))
90529 + return -EOPNOTSUPP;
90530 + if (size > 8)
90531 + return -EINVAL;
90532 + }
90533 +#endif
90534 +
90535 return simple_xattr_set(&info->xattrs, name, value, size, flags);
90536 }
90537
90538 @@ -2599,8 +2613,7 @@ int shmem_fill_super(struct super_block *sb, void *data, int silent)
90539 int err = -ENOMEM;
90540
90541 /* Round up to L1_CACHE_BYTES to resist false sharing */
90542 - sbinfo = kzalloc(max((int)sizeof(struct shmem_sb_info),
90543 - L1_CACHE_BYTES), GFP_KERNEL);
90544 + sbinfo = kzalloc(max(sizeof(struct shmem_sb_info), L1_CACHE_BYTES), GFP_KERNEL);
90545 if (!sbinfo)
90546 return -ENOMEM;
90547
90548 diff --git a/mm/slab.c b/mm/slab.c
90549 index 2580db0..0523956 100644
90550 --- a/mm/slab.c
90551 +++ b/mm/slab.c
90552 @@ -366,10 +366,12 @@ static void kmem_cache_node_init(struct kmem_cache_node *parent)
90553 if ((x)->max_freeable < i) \
90554 (x)->max_freeable = i; \
90555 } while (0)
90556 -#define STATS_INC_ALLOCHIT(x) atomic_inc(&(x)->allochit)
90557 -#define STATS_INC_ALLOCMISS(x) atomic_inc(&(x)->allocmiss)
90558 -#define STATS_INC_FREEHIT(x) atomic_inc(&(x)->freehit)
90559 -#define STATS_INC_FREEMISS(x) atomic_inc(&(x)->freemiss)
90560 +#define STATS_INC_ALLOCHIT(x) atomic_inc_unchecked(&(x)->allochit)
90561 +#define STATS_INC_ALLOCMISS(x) atomic_inc_unchecked(&(x)->allocmiss)
90562 +#define STATS_INC_FREEHIT(x) atomic_inc_unchecked(&(x)->freehit)
90563 +#define STATS_INC_FREEMISS(x) atomic_inc_unchecked(&(x)->freemiss)
90564 +#define STATS_INC_SANITIZED(x) atomic_inc_unchecked(&(x)->sanitized)
90565 +#define STATS_INC_NOT_SANITIZED(x) atomic_inc_unchecked(&(x)->not_sanitized)
90566 #else
90567 #define STATS_INC_ACTIVE(x) do { } while (0)
90568 #define STATS_DEC_ACTIVE(x) do { } while (0)
90569 @@ -386,6 +388,8 @@ static void kmem_cache_node_init(struct kmem_cache_node *parent)
90570 #define STATS_INC_ALLOCMISS(x) do { } while (0)
90571 #define STATS_INC_FREEHIT(x) do { } while (0)
90572 #define STATS_INC_FREEMISS(x) do { } while (0)
90573 +#define STATS_INC_SANITIZED(x) do { } while (0)
90574 +#define STATS_INC_NOT_SANITIZED(x) do { } while (0)
90575 #endif
90576
90577 #if DEBUG
90578 @@ -477,7 +481,7 @@ static inline void *index_to_obj(struct kmem_cache *cache, struct slab *slab,
90579 * reciprocal_divide(offset, cache->reciprocal_buffer_size)
90580 */
90581 static inline unsigned int obj_to_index(const struct kmem_cache *cache,
90582 - const struct slab *slab, void *obj)
90583 + const struct slab *slab, const void *obj)
90584 {
90585 u32 offset = (obj - slab->s_mem);
90586 return reciprocal_divide(offset, cache->reciprocal_buffer_size);
90587 @@ -1571,12 +1575,12 @@ void __init kmem_cache_init(void)
90588 */
90589
90590 kmalloc_caches[INDEX_AC] = create_kmalloc_cache("kmalloc-ac",
90591 - kmalloc_size(INDEX_AC), ARCH_KMALLOC_FLAGS);
90592 + kmalloc_size(INDEX_AC), SLAB_USERCOPY | ARCH_KMALLOC_FLAGS);
90593
90594 if (INDEX_AC != INDEX_NODE)
90595 kmalloc_caches[INDEX_NODE] =
90596 create_kmalloc_cache("kmalloc-node",
90597 - kmalloc_size(INDEX_NODE), ARCH_KMALLOC_FLAGS);
90598 + kmalloc_size(INDEX_NODE), SLAB_USERCOPY | ARCH_KMALLOC_FLAGS);
90599
90600 slab_early_init = 0;
90601
90602 @@ -3577,6 +3581,21 @@ static inline void __cache_free(struct kmem_cache *cachep, void *objp,
90603 struct array_cache *ac = cpu_cache_get(cachep);
90604
90605 check_irq_off();
90606 +
90607 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
90608 + if (pax_sanitize_slab) {
90609 + if (!(cachep->flags & (SLAB_POISON | SLAB_NO_SANITIZE))) {
90610 + memset(objp, PAX_MEMORY_SANITIZE_VALUE, cachep->object_size);
90611 +
90612 + if (cachep->ctor)
90613 + cachep->ctor(objp);
90614 +
90615 + STATS_INC_SANITIZED(cachep);
90616 + } else
90617 + STATS_INC_NOT_SANITIZED(cachep);
90618 + }
90619 +#endif
90620 +
90621 kmemleak_free_recursive(objp, cachep->flags);
90622 objp = cache_free_debugcheck(cachep, objp, caller);
90623
90624 @@ -3805,6 +3824,7 @@ void kfree(const void *objp)
90625
90626 if (unlikely(ZERO_OR_NULL_PTR(objp)))
90627 return;
90628 + VM_BUG_ON(!virt_addr_valid(objp));
90629 local_irq_save(flags);
90630 kfree_debugcheck(objp);
90631 c = virt_to_cache(objp);
90632 @@ -4246,14 +4266,22 @@ void slabinfo_show_stats(struct seq_file *m, struct kmem_cache *cachep)
90633 }
90634 /* cpu stats */
90635 {
90636 - unsigned long allochit = atomic_read(&cachep->allochit);
90637 - unsigned long allocmiss = atomic_read(&cachep->allocmiss);
90638 - unsigned long freehit = atomic_read(&cachep->freehit);
90639 - unsigned long freemiss = atomic_read(&cachep->freemiss);
90640 + unsigned long allochit = atomic_read_unchecked(&cachep->allochit);
90641 + unsigned long allocmiss = atomic_read_unchecked(&cachep->allocmiss);
90642 + unsigned long freehit = atomic_read_unchecked(&cachep->freehit);
90643 + unsigned long freemiss = atomic_read_unchecked(&cachep->freemiss);
90644
90645 seq_printf(m, " : cpustat %6lu %6lu %6lu %6lu",
90646 allochit, allocmiss, freehit, freemiss);
90647 }
90648 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
90649 + {
90650 + unsigned long sanitized = atomic_read_unchecked(&cachep->sanitized);
90651 + unsigned long not_sanitized = atomic_read_unchecked(&cachep->not_sanitized);
90652 +
90653 + seq_printf(m, " : pax %6lu %6lu", sanitized, not_sanitized);
90654 + }
90655 +#endif
90656 #endif
90657 }
90658
90659 @@ -4471,13 +4499,71 @@ static const struct file_operations proc_slabstats_operations = {
90660 static int __init slab_proc_init(void)
90661 {
90662 #ifdef CONFIG_DEBUG_SLAB_LEAK
90663 - proc_create("slab_allocators", 0, NULL, &proc_slabstats_operations);
90664 + proc_create("slab_allocators", S_IRUSR, NULL, &proc_slabstats_operations);
90665 #endif
90666 return 0;
90667 }
90668 module_init(slab_proc_init);
90669 #endif
90670
90671 +bool is_usercopy_object(const void *ptr)
90672 +{
90673 + struct page *page;
90674 + struct kmem_cache *cachep;
90675 +
90676 + if (ZERO_OR_NULL_PTR(ptr))
90677 + return false;
90678 +
90679 + if (!slab_is_available())
90680 + return false;
90681 +
90682 + if (!virt_addr_valid(ptr))
90683 + return false;
90684 +
90685 + page = virt_to_head_page(ptr);
90686 +
90687 + if (!PageSlab(page))
90688 + return false;
90689 +
90690 + cachep = page->slab_cache;
90691 + return cachep->flags & SLAB_USERCOPY;
90692 +}
90693 +
90694 +#ifdef CONFIG_PAX_USERCOPY
90695 +const char *check_heap_object(const void *ptr, unsigned long n)
90696 +{
90697 + struct page *page;
90698 + struct kmem_cache *cachep;
90699 + struct slab *slabp;
90700 + unsigned int objnr;
90701 + unsigned long offset;
90702 +
90703 + if (ZERO_OR_NULL_PTR(ptr))
90704 + return "<null>";
90705 +
90706 + if (!virt_addr_valid(ptr))
90707 + return NULL;
90708 +
90709 + page = virt_to_head_page(ptr);
90710 +
90711 + if (!PageSlab(page))
90712 + return NULL;
90713 +
90714 + cachep = page->slab_cache;
90715 + if (!(cachep->flags & SLAB_USERCOPY))
90716 + return cachep->name;
90717 +
90718 + slabp = page->slab_page;
90719 + objnr = obj_to_index(cachep, slabp, ptr);
90720 + BUG_ON(objnr >= cachep->num);
90721 + offset = ptr - index_to_obj(cachep, slabp, objnr) - obj_offset(cachep);
90722 + if (offset <= cachep->object_size && n <= cachep->object_size - offset)
90723 + return NULL;
90724 +
90725 + return cachep->name;
90726 +}
90727 +#endif
90728 +
90729 /**
90730 * ksize - get the actual amount of memory allocated for a given object
90731 * @objp: Pointer to the object
90732 diff --git a/mm/slab.h b/mm/slab.h
90733 index a535033..2f98fe5 100644
90734 --- a/mm/slab.h
90735 +++ b/mm/slab.h
90736 @@ -32,6 +32,15 @@ extern struct list_head slab_caches;
90737 /* The slab cache that manages slab cache information */
90738 extern struct kmem_cache *kmem_cache;
90739
90740 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
90741 +#ifdef CONFIG_X86_64
90742 +#define PAX_MEMORY_SANITIZE_VALUE '\xfe'
90743 +#else
90744 +#define PAX_MEMORY_SANITIZE_VALUE '\xff'
90745 +#endif
90746 +extern bool pax_sanitize_slab;
90747 +#endif
90748 +
90749 unsigned long calculate_alignment(unsigned long flags,
90750 unsigned long align, unsigned long size);
90751
90752 @@ -67,7 +76,8 @@ __kmem_cache_alias(struct mem_cgroup *memcg, const char *name, size_t size,
90753
90754 /* Legal flag mask for kmem_cache_create(), for various configurations */
90755 #define SLAB_CORE_FLAGS (SLAB_HWCACHE_ALIGN | SLAB_CACHE_DMA | SLAB_PANIC | \
90756 - SLAB_DESTROY_BY_RCU | SLAB_DEBUG_OBJECTS )
90757 + SLAB_DESTROY_BY_RCU | SLAB_DEBUG_OBJECTS | \
90758 + SLAB_USERCOPY | SLAB_NO_SANITIZE)
90759
90760 #if defined(CONFIG_DEBUG_SLAB)
90761 #define SLAB_DEBUG_FLAGS (SLAB_RED_ZONE | SLAB_POISON | SLAB_STORE_USER)
90762 @@ -231,6 +241,9 @@ static inline struct kmem_cache *cache_from_obj(struct kmem_cache *s, void *x)
90763 return s;
90764
90765 page = virt_to_head_page(x);
90766 +
90767 + BUG_ON(!PageSlab(page));
90768 +
90769 cachep = page->slab_cache;
90770 if (slab_equal_or_root(cachep, s))
90771 return cachep;
90772 diff --git a/mm/slab_common.c b/mm/slab_common.c
90773 index e2e98af..3b1a163 100644
90774 --- a/mm/slab_common.c
90775 +++ b/mm/slab_common.c
90776 @@ -23,11 +23,22 @@
90777
90778 #include "slab.h"
90779
90780 -enum slab_state slab_state;
90781 +enum slab_state slab_state __read_only;
90782 LIST_HEAD(slab_caches);
90783 DEFINE_MUTEX(slab_mutex);
90784 struct kmem_cache *kmem_cache;
90785
90786 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
90787 +bool pax_sanitize_slab __read_only = true;
90788 +static int __init pax_sanitize_slab_setup(char *str)
90789 +{
90790 + pax_sanitize_slab = !!simple_strtol(str, NULL, 0);
90791 + printk("%sabled PaX slab sanitization\n", pax_sanitize_slab ? "En" : "Dis");
90792 + return 1;
90793 +}
90794 +__setup("pax_sanitize_slab=", pax_sanitize_slab_setup);
90795 +#endif
90796 +
90797 #ifdef CONFIG_DEBUG_VM
90798 static int kmem_cache_sanity_check(struct mem_cgroup *memcg, const char *name,
90799 size_t size)
90800 @@ -212,7 +223,7 @@ kmem_cache_create_memcg(struct mem_cgroup *memcg, const char *name, size_t size,
90801
90802 err = __kmem_cache_create(s, flags);
90803 if (!err) {
90804 - s->refcount = 1;
90805 + atomic_set(&s->refcount, 1);
90806 list_add(&s->list, &slab_caches);
90807 memcg_cache_list_add(memcg, s);
90808 } else {
90809 @@ -258,8 +269,7 @@ void kmem_cache_destroy(struct kmem_cache *s)
90810
90811 get_online_cpus();
90812 mutex_lock(&slab_mutex);
90813 - s->refcount--;
90814 - if (!s->refcount) {
90815 + if (atomic_dec_and_test(&s->refcount)) {
90816 list_del(&s->list);
90817
90818 if (!__kmem_cache_shutdown(s)) {
90819 @@ -305,7 +315,7 @@ void __init create_boot_cache(struct kmem_cache *s, const char *name, size_t siz
90820 panic("Creation of kmalloc slab %s size=%zu failed. Reason %d\n",
90821 name, size, err);
90822
90823 - s->refcount = -1; /* Exempt from merging for now */
90824 + atomic_set(&s->refcount, -1); /* Exempt from merging for now */
90825 }
90826
90827 struct kmem_cache *__init create_kmalloc_cache(const char *name, size_t size,
90828 @@ -318,7 +328,7 @@ struct kmem_cache *__init create_kmalloc_cache(const char *name, size_t size,
90829
90830 create_boot_cache(s, name, size, flags);
90831 list_add(&s->list, &slab_caches);
90832 - s->refcount = 1;
90833 + atomic_set(&s->refcount, 1);
90834 return s;
90835 }
90836
90837 @@ -330,6 +340,11 @@ struct kmem_cache *kmalloc_dma_caches[KMALLOC_SHIFT_HIGH + 1];
90838 EXPORT_SYMBOL(kmalloc_dma_caches);
90839 #endif
90840
90841 +#ifdef CONFIG_PAX_USERCOPY_SLABS
90842 +struct kmem_cache *kmalloc_usercopy_caches[KMALLOC_SHIFT_HIGH + 1];
90843 +EXPORT_SYMBOL(kmalloc_usercopy_caches);
90844 +#endif
90845 +
90846 /*
90847 * Conversion table for small slabs sizes / 8 to the index in the
90848 * kmalloc array. This is necessary for slabs < 192 since we have non power
90849 @@ -394,6 +409,13 @@ struct kmem_cache *kmalloc_slab(size_t size, gfp_t flags)
90850 return kmalloc_dma_caches[index];
90851
90852 #endif
90853 +
90854 +#ifdef CONFIG_PAX_USERCOPY_SLABS
90855 + if (unlikely((flags & GFP_USERCOPY)))
90856 + return kmalloc_usercopy_caches[index];
90857 +
90858 +#endif
90859 +
90860 return kmalloc_caches[index];
90861 }
90862
90863 @@ -450,7 +472,7 @@ void __init create_kmalloc_caches(unsigned long flags)
90864 for (i = KMALLOC_SHIFT_LOW; i <= KMALLOC_SHIFT_HIGH; i++) {
90865 if (!kmalloc_caches[i]) {
90866 kmalloc_caches[i] = create_kmalloc_cache(NULL,
90867 - 1 << i, flags);
90868 + 1 << i, SLAB_USERCOPY | flags);
90869 }
90870
90871 /*
90872 @@ -459,10 +481,10 @@ void __init create_kmalloc_caches(unsigned long flags)
90873 * earlier power of two caches
90874 */
90875 if (KMALLOC_MIN_SIZE <= 32 && !kmalloc_caches[1] && i == 6)
90876 - kmalloc_caches[1] = create_kmalloc_cache(NULL, 96, flags);
90877 + kmalloc_caches[1] = create_kmalloc_cache(NULL, 96, SLAB_USERCOPY | flags);
90878
90879 if (KMALLOC_MIN_SIZE <= 64 && !kmalloc_caches[2] && i == 7)
90880 - kmalloc_caches[2] = create_kmalloc_cache(NULL, 192, flags);
90881 + kmalloc_caches[2] = create_kmalloc_cache(NULL, 192, SLAB_USERCOPY | flags);
90882 }
90883
90884 /* Kmalloc array is now usable */
90885 @@ -495,6 +517,23 @@ void __init create_kmalloc_caches(unsigned long flags)
90886 }
90887 }
90888 #endif
90889 +
90890 +#ifdef CONFIG_PAX_USERCOPY_SLABS
90891 + for (i = 0; i <= KMALLOC_SHIFT_HIGH; i++) {
90892 + struct kmem_cache *s = kmalloc_caches[i];
90893 +
90894 + if (s) {
90895 + int size = kmalloc_size(i);
90896 + char *n = kasprintf(GFP_NOWAIT,
90897 + "usercopy-kmalloc-%d", size);
90898 +
90899 + BUG_ON(!n);
90900 + kmalloc_usercopy_caches[i] = create_kmalloc_cache(n,
90901 + size, SLAB_USERCOPY | flags);
90902 + }
90903 + }
90904 +#endif
90905 +
90906 }
90907 #endif /* !CONFIG_SLOB */
90908
90909 @@ -535,6 +574,9 @@ void print_slabinfo_header(struct seq_file *m)
90910 seq_puts(m, " : globalstat <listallocs> <maxobjs> <grown> <reaped> "
90911 "<error> <maxfreeable> <nodeallocs> <remotefrees> <alienoverflow>");
90912 seq_puts(m, " : cpustat <allochit> <allocmiss> <freehit> <freemiss>");
90913 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
90914 + seq_puts(m, " : pax <sanitized> <not_sanitized>");
90915 +#endif
90916 #endif
90917 seq_putc(m, '\n');
90918 }
90919 diff --git a/mm/slob.c b/mm/slob.c
90920 index 4bf8809..98a6914 100644
90921 --- a/mm/slob.c
90922 +++ b/mm/slob.c
90923 @@ -157,7 +157,7 @@ static void set_slob(slob_t *s, slobidx_t size, slob_t *next)
90924 /*
90925 * Return the size of a slob block.
90926 */
90927 -static slobidx_t slob_units(slob_t *s)
90928 +static slobidx_t slob_units(const slob_t *s)
90929 {
90930 if (s->units > 0)
90931 return s->units;
90932 @@ -167,7 +167,7 @@ static slobidx_t slob_units(slob_t *s)
90933 /*
90934 * Return the next free slob block pointer after this one.
90935 */
90936 -static slob_t *slob_next(slob_t *s)
90937 +static slob_t *slob_next(const slob_t *s)
90938 {
90939 slob_t *base = (slob_t *)((unsigned long)s & PAGE_MASK);
90940 slobidx_t next;
90941 @@ -182,14 +182,14 @@ static slob_t *slob_next(slob_t *s)
90942 /*
90943 * Returns true if s is the last free block in its page.
90944 */
90945 -static int slob_last(slob_t *s)
90946 +static int slob_last(const slob_t *s)
90947 {
90948 return !((unsigned long)slob_next(s) & ~PAGE_MASK);
90949 }
90950
90951 -static void *slob_new_pages(gfp_t gfp, int order, int node)
90952 +static struct page *slob_new_pages(gfp_t gfp, unsigned int order, int node)
90953 {
90954 - void *page;
90955 + struct page *page;
90956
90957 #ifdef CONFIG_NUMA
90958 if (node != NUMA_NO_NODE)
90959 @@ -201,14 +201,18 @@ static void *slob_new_pages(gfp_t gfp, int order, int node)
90960 if (!page)
90961 return NULL;
90962
90963 - return page_address(page);
90964 + __SetPageSlab(page);
90965 + return page;
90966 }
90967
90968 -static void slob_free_pages(void *b, int order)
90969 +static void slob_free_pages(struct page *sp, int order)
90970 {
90971 if (current->reclaim_state)
90972 current->reclaim_state->reclaimed_slab += 1 << order;
90973 - free_pages((unsigned long)b, order);
90974 + __ClearPageSlab(sp);
90975 + page_mapcount_reset(sp);
90976 + sp->private = 0;
90977 + __free_pages(sp, order);
90978 }
90979
90980 /*
90981 @@ -313,15 +317,15 @@ static void *slob_alloc(size_t size, gfp_t gfp, int align, int node)
90982
90983 /* Not enough space: must allocate a new page */
90984 if (!b) {
90985 - b = slob_new_pages(gfp & ~__GFP_ZERO, 0, node);
90986 - if (!b)
90987 + sp = slob_new_pages(gfp & ~__GFP_ZERO, 0, node);
90988 + if (!sp)
90989 return NULL;
90990 - sp = virt_to_page(b);
90991 - __SetPageSlab(sp);
90992 + b = page_address(sp);
90993
90994 spin_lock_irqsave(&slob_lock, flags);
90995 sp->units = SLOB_UNITS(PAGE_SIZE);
90996 sp->freelist = b;
90997 + sp->private = 0;
90998 INIT_LIST_HEAD(&sp->list);
90999 set_slob(b, SLOB_UNITS(PAGE_SIZE), b + SLOB_UNITS(PAGE_SIZE));
91000 set_slob_page_free(sp, slob_list);
91001 @@ -359,12 +363,15 @@ static void slob_free(void *block, int size)
91002 if (slob_page_free(sp))
91003 clear_slob_page_free(sp);
91004 spin_unlock_irqrestore(&slob_lock, flags);
91005 - __ClearPageSlab(sp);
91006 - page_mapcount_reset(sp);
91007 - slob_free_pages(b, 0);
91008 + slob_free_pages(sp, 0);
91009 return;
91010 }
91011
91012 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
91013 + if (pax_sanitize_slab)
91014 + memset(block, PAX_MEMORY_SANITIZE_VALUE, size);
91015 +#endif
91016 +
91017 if (!slob_page_free(sp)) {
91018 /* This slob page is about to become partially free. Easy! */
91019 sp->units = units;
91020 @@ -424,11 +431,10 @@ out:
91021 */
91022
91023 static __always_inline void *
91024 -__do_kmalloc_node(size_t size, gfp_t gfp, int node, unsigned long caller)
91025 +__do_kmalloc_node_align(size_t size, gfp_t gfp, int node, unsigned long caller, int align)
91026 {
91027 - unsigned int *m;
91028 - int align = max_t(size_t, ARCH_KMALLOC_MINALIGN, ARCH_SLAB_MINALIGN);
91029 - void *ret;
91030 + slob_t *m;
91031 + void *ret = NULL;
91032
91033 gfp &= gfp_allowed_mask;
91034
91035 @@ -442,23 +448,41 @@ __do_kmalloc_node(size_t size, gfp_t gfp, int node, unsigned long caller)
91036
91037 if (!m)
91038 return NULL;
91039 - *m = size;
91040 + BUILD_BUG_ON(ARCH_KMALLOC_MINALIGN < 2 * SLOB_UNIT);
91041 + BUILD_BUG_ON(ARCH_SLAB_MINALIGN < 2 * SLOB_UNIT);
91042 + m[0].units = size;
91043 + m[1].units = align;
91044 ret = (void *)m + align;
91045
91046 trace_kmalloc_node(caller, ret,
91047 size, size + align, gfp, node);
91048 } else {
91049 unsigned int order = get_order(size);
91050 + struct page *page;
91051
91052 if (likely(order))
91053 gfp |= __GFP_COMP;
91054 - ret = slob_new_pages(gfp, order, node);
91055 + page = slob_new_pages(gfp, order, node);
91056 + if (page) {
91057 + ret = page_address(page);
91058 + page->private = size;
91059 + }
91060
91061 trace_kmalloc_node(caller, ret,
91062 size, PAGE_SIZE << order, gfp, node);
91063 }
91064
91065 - kmemleak_alloc(ret, size, 1, gfp);
91066 + return ret;
91067 +}
91068 +
91069 +static __always_inline void *
91070 +__do_kmalloc_node(size_t size, gfp_t gfp, int node, unsigned long caller)
91071 +{
91072 + int align = max(ARCH_KMALLOC_MINALIGN, ARCH_SLAB_MINALIGN);
91073 + void *ret = __do_kmalloc_node_align(size, gfp, node, caller, align);
91074 +
91075 + if (!ZERO_OR_NULL_PTR(ret))
91076 + kmemleak_alloc(ret, size, 1, gfp);
91077 return ret;
91078 }
91079
91080 @@ -493,34 +517,112 @@ void kfree(const void *block)
91081 return;
91082 kmemleak_free(block);
91083
91084 + VM_BUG_ON(!virt_addr_valid(block));
91085 sp = virt_to_page(block);
91086 - if (PageSlab(sp)) {
91087 + VM_BUG_ON(!PageSlab(sp));
91088 + if (!sp->private) {
91089 int align = max_t(size_t, ARCH_KMALLOC_MINALIGN, ARCH_SLAB_MINALIGN);
91090 - unsigned int *m = (unsigned int *)(block - align);
91091 - slob_free(m, *m + align);
91092 - } else
91093 + slob_t *m = (slob_t *)(block - align);
91094 + slob_free(m, m[0].units + align);
91095 + } else {
91096 + __ClearPageSlab(sp);
91097 + page_mapcount_reset(sp);
91098 + sp->private = 0;
91099 __free_pages(sp, compound_order(sp));
91100 + }
91101 }
91102 EXPORT_SYMBOL(kfree);
91103
91104 +bool is_usercopy_object(const void *ptr)
91105 +{
91106 + if (!slab_is_available())
91107 + return false;
91108 +
91109 + // PAX: TODO
91110 +
91111 + return false;
91112 +}
91113 +
91114 +#ifdef CONFIG_PAX_USERCOPY
91115 +const char *check_heap_object(const void *ptr, unsigned long n)
91116 +{
91117 + struct page *page;
91118 + const slob_t *free;
91119 + const void *base;
91120 + unsigned long flags;
91121 +
91122 + if (ZERO_OR_NULL_PTR(ptr))
91123 + return "<null>";
91124 +
91125 + if (!virt_addr_valid(ptr))
91126 + return NULL;
91127 +
91128 + page = virt_to_head_page(ptr);
91129 + if (!PageSlab(page))
91130 + return NULL;
91131 +
91132 + if (page->private) {
91133 + base = page;
91134 + if (base <= ptr && n <= page->private - (ptr - base))
91135 + return NULL;
91136 + return "<slob>";
91137 + }
91138 +
91139 + /* some tricky double walking to find the chunk */
91140 + spin_lock_irqsave(&slob_lock, flags);
91141 + base = (void *)((unsigned long)ptr & PAGE_MASK);
91142 + free = page->freelist;
91143 +
91144 + while (!slob_last(free) && (void *)free <= ptr) {
91145 + base = free + slob_units(free);
91146 + free = slob_next(free);
91147 + }
91148 +
91149 + while (base < (void *)free) {
91150 + slobidx_t m = ((slob_t *)base)[0].units, align = ((slob_t *)base)[1].units;
91151 + int size = SLOB_UNIT * SLOB_UNITS(m + align);
91152 + int offset;
91153 +
91154 + if (ptr < base + align)
91155 + break;
91156 +
91157 + offset = ptr - base - align;
91158 + if (offset >= m) {
91159 + base += size;
91160 + continue;
91161 + }
91162 +
91163 + if (n > m - offset)
91164 + break;
91165 +
91166 + spin_unlock_irqrestore(&slob_lock, flags);
91167 + return NULL;
91168 + }
91169 +
91170 + spin_unlock_irqrestore(&slob_lock, flags);
91171 + return "<slob>";
91172 +}
91173 +#endif
91174 +
91175 /* can't use ksize for kmem_cache_alloc memory, only kmalloc */
91176 size_t ksize(const void *block)
91177 {
91178 struct page *sp;
91179 int align;
91180 - unsigned int *m;
91181 + slob_t *m;
91182
91183 BUG_ON(!block);
91184 if (unlikely(block == ZERO_SIZE_PTR))
91185 return 0;
91186
91187 sp = virt_to_page(block);
91188 - if (unlikely(!PageSlab(sp)))
91189 - return PAGE_SIZE << compound_order(sp);
91190 + VM_BUG_ON(!PageSlab(sp));
91191 + if (sp->private)
91192 + return sp->private;
91193
91194 align = max_t(size_t, ARCH_KMALLOC_MINALIGN, ARCH_SLAB_MINALIGN);
91195 - m = (unsigned int *)(block - align);
91196 - return SLOB_UNITS(*m) * SLOB_UNIT;
91197 + m = (slob_t *)(block - align);
91198 + return SLOB_UNITS(m[0].units) * SLOB_UNIT;
91199 }
91200 EXPORT_SYMBOL(ksize);
91201
91202 @@ -536,23 +638,33 @@ int __kmem_cache_create(struct kmem_cache *c, unsigned long flags)
91203
91204 void *slob_alloc_node(struct kmem_cache *c, gfp_t flags, int node)
91205 {
91206 - void *b;
91207 + void *b = NULL;
91208
91209 flags &= gfp_allowed_mask;
91210
91211 lockdep_trace_alloc(flags);
91212
91213 +#ifdef CONFIG_PAX_USERCOPY_SLABS
91214 + b = __do_kmalloc_node_align(c->size, flags, node, _RET_IP_, c->align);
91215 +#else
91216 if (c->size < PAGE_SIZE) {
91217 b = slob_alloc(c->size, flags, c->align, node);
91218 trace_kmem_cache_alloc_node(_RET_IP_, b, c->object_size,
91219 SLOB_UNITS(c->size) * SLOB_UNIT,
91220 flags, node);
91221 } else {
91222 - b = slob_new_pages(flags, get_order(c->size), node);
91223 + struct page *sp;
91224 +
91225 + sp = slob_new_pages(flags, get_order(c->size), node);
91226 + if (sp) {
91227 + b = page_address(sp);
91228 + sp->private = c->size;
91229 + }
91230 trace_kmem_cache_alloc_node(_RET_IP_, b, c->object_size,
91231 PAGE_SIZE << get_order(c->size),
91232 flags, node);
91233 }
91234 +#endif
91235
91236 if (b && c->ctor)
91237 c->ctor(b);
91238 @@ -584,10 +696,14 @@ EXPORT_SYMBOL(kmem_cache_alloc_node);
91239
91240 static void __kmem_cache_free(void *b, int size)
91241 {
91242 - if (size < PAGE_SIZE)
91243 + struct page *sp;
91244 +
91245 + sp = virt_to_page(b);
91246 + BUG_ON(!PageSlab(sp));
91247 + if (!sp->private)
91248 slob_free(b, size);
91249 else
91250 - slob_free_pages(b, get_order(size));
91251 + slob_free_pages(sp, get_order(size));
91252 }
91253
91254 static void kmem_rcu_free(struct rcu_head *head)
91255 @@ -600,17 +716,31 @@ static void kmem_rcu_free(struct rcu_head *head)
91256
91257 void kmem_cache_free(struct kmem_cache *c, void *b)
91258 {
91259 + int size = c->size;
91260 +
91261 +#ifdef CONFIG_PAX_USERCOPY_SLABS
91262 + if (size + c->align < PAGE_SIZE) {
91263 + size += c->align;
91264 + b -= c->align;
91265 + }
91266 +#endif
91267 +
91268 kmemleak_free_recursive(b, c->flags);
91269 if (unlikely(c->flags & SLAB_DESTROY_BY_RCU)) {
91270 struct slob_rcu *slob_rcu;
91271 - slob_rcu = b + (c->size - sizeof(struct slob_rcu));
91272 - slob_rcu->size = c->size;
91273 + slob_rcu = b + (size - sizeof(struct slob_rcu));
91274 + slob_rcu->size = size;
91275 call_rcu(&slob_rcu->head, kmem_rcu_free);
91276 } else {
91277 - __kmem_cache_free(b, c->size);
91278 + __kmem_cache_free(b, size);
91279 }
91280
91281 +#ifdef CONFIG_PAX_USERCOPY_SLABS
91282 + trace_kfree(_RET_IP_, b);
91283 +#else
91284 trace_kmem_cache_free(_RET_IP_, b);
91285 +#endif
91286 +
91287 }
91288 EXPORT_SYMBOL(kmem_cache_free);
91289
91290 diff --git a/mm/slub.c b/mm/slub.c
91291 index 96f2169..9111a59 100644
91292 --- a/mm/slub.c
91293 +++ b/mm/slub.c
91294 @@ -207,7 +207,7 @@ struct track {
91295
91296 enum track_item { TRACK_ALLOC, TRACK_FREE };
91297
91298 -#ifdef CONFIG_SYSFS
91299 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
91300 static int sysfs_slab_add(struct kmem_cache *);
91301 static int sysfs_slab_alias(struct kmem_cache *, const char *);
91302 static void sysfs_slab_remove(struct kmem_cache *);
91303 @@ -530,7 +530,7 @@ static void print_track(const char *s, struct track *t)
91304 if (!t->addr)
91305 return;
91306
91307 - printk(KERN_ERR "INFO: %s in %pS age=%lu cpu=%u pid=%d\n",
91308 + printk(KERN_ERR "INFO: %s in %pA age=%lu cpu=%u pid=%d\n",
91309 s, (void *)t->addr, jiffies - t->when, t->cpu, t->pid);
91310 #ifdef CONFIG_STACKTRACE
91311 {
91312 @@ -2616,6 +2616,14 @@ static __always_inline void slab_free(struct kmem_cache *s,
91313
91314 slab_free_hook(s, x);
91315
91316 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
91317 + if (pax_sanitize_slab && !(s->flags & SLAB_NO_SANITIZE)) {
91318 + memset(x, PAX_MEMORY_SANITIZE_VALUE, s->object_size);
91319 + if (s->ctor)
91320 + s->ctor(x);
91321 + }
91322 +#endif
91323 +
91324 redo:
91325 /*
91326 * Determine the currently cpus per cpu slab.
91327 @@ -2683,7 +2691,7 @@ static int slub_min_objects;
91328 * Merge control. If this is set then no merging of slab caches will occur.
91329 * (Could be removed. This was introduced to pacify the merge skeptics.)
91330 */
91331 -static int slub_nomerge;
91332 +static int slub_nomerge = 1;
91333
91334 /*
91335 * Calculate the order of allocation given an slab object size.
91336 @@ -2960,6 +2968,9 @@ static int calculate_sizes(struct kmem_cache *s, int forced_order)
91337 s->inuse = size;
91338
91339 if (((flags & (SLAB_DESTROY_BY_RCU | SLAB_POISON)) ||
91340 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
91341 + (pax_sanitize_slab && !(flags & SLAB_NO_SANITIZE)) ||
91342 +#endif
91343 s->ctor)) {
91344 /*
91345 * Relocate free pointer after the object if it is not
91346 @@ -3305,6 +3316,59 @@ void *__kmalloc_node(size_t size, gfp_t flags, int node)
91347 EXPORT_SYMBOL(__kmalloc_node);
91348 #endif
91349
91350 +bool is_usercopy_object(const void *ptr)
91351 +{
91352 + struct page *page;
91353 + struct kmem_cache *s;
91354 +
91355 + if (ZERO_OR_NULL_PTR(ptr))
91356 + return false;
91357 +
91358 + if (!slab_is_available())
91359 + return false;
91360 +
91361 + if (!virt_addr_valid(ptr))
91362 + return false;
91363 +
91364 + page = virt_to_head_page(ptr);
91365 +
91366 + if (!PageSlab(page))
91367 + return false;
91368 +
91369 + s = page->slab_cache;
91370 + return s->flags & SLAB_USERCOPY;
91371 +}
91372 +
91373 +#ifdef CONFIG_PAX_USERCOPY
91374 +const char *check_heap_object(const void *ptr, unsigned long n)
91375 +{
91376 + struct page *page;
91377 + struct kmem_cache *s;
91378 + unsigned long offset;
91379 +
91380 + if (ZERO_OR_NULL_PTR(ptr))
91381 + return "<null>";
91382 +
91383 + if (!virt_addr_valid(ptr))
91384 + return NULL;
91385 +
91386 + page = virt_to_head_page(ptr);
91387 +
91388 + if (!PageSlab(page))
91389 + return NULL;
91390 +
91391 + s = page->slab_cache;
91392 + if (!(s->flags & SLAB_USERCOPY))
91393 + return s->name;
91394 +
91395 + offset = (ptr - page_address(page)) % s->size;
91396 + if (offset <= s->object_size && n <= s->object_size - offset)
91397 + return NULL;
91398 +
91399 + return s->name;
91400 +}
91401 +#endif
91402 +
91403 size_t ksize(const void *object)
91404 {
91405 struct page *page;
91406 @@ -3333,6 +3397,7 @@ void kfree(const void *x)
91407 if (unlikely(ZERO_OR_NULL_PTR(x)))
91408 return;
91409
91410 + VM_BUG_ON(!virt_addr_valid(x));
91411 page = virt_to_head_page(x);
91412 if (unlikely(!PageSlab(page))) {
91413 BUG_ON(!PageCompound(page));
91414 @@ -3638,7 +3703,7 @@ static int slab_unmergeable(struct kmem_cache *s)
91415 /*
91416 * We may have set a slab to be unmergeable during bootstrap.
91417 */
91418 - if (s->refcount < 0)
91419 + if (atomic_read(&s->refcount) < 0)
91420 return 1;
91421
91422 return 0;
91423 @@ -3696,7 +3761,7 @@ __kmem_cache_alias(struct mem_cgroup *memcg, const char *name, size_t size,
91424
91425 s = find_mergeable(memcg, size, align, flags, name, ctor);
91426 if (s) {
91427 - s->refcount++;
91428 + atomic_inc(&s->refcount);
91429 /*
91430 * Adjust the object sizes so that we clear
91431 * the complete object on kzalloc.
91432 @@ -3705,7 +3770,7 @@ __kmem_cache_alias(struct mem_cgroup *memcg, const char *name, size_t size,
91433 s->inuse = max_t(int, s->inuse, ALIGN(size, sizeof(void *)));
91434
91435 if (sysfs_slab_alias(s, name)) {
91436 - s->refcount--;
91437 + atomic_dec(&s->refcount);
91438 s = NULL;
91439 }
91440 }
91441 @@ -3825,7 +3890,7 @@ void *__kmalloc_node_track_caller(size_t size, gfp_t gfpflags,
91442 }
91443 #endif
91444
91445 -#ifdef CONFIG_SYSFS
91446 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
91447 static int count_inuse(struct page *page)
91448 {
91449 return page->inuse;
91450 @@ -4214,12 +4279,12 @@ static void resiliency_test(void)
91451 validate_slab_cache(kmalloc_caches[9]);
91452 }
91453 #else
91454 -#ifdef CONFIG_SYSFS
91455 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
91456 static void resiliency_test(void) {};
91457 #endif
91458 #endif
91459
91460 -#ifdef CONFIG_SYSFS
91461 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
91462 enum slab_stat_type {
91463 SL_ALL, /* All slabs */
91464 SL_PARTIAL, /* Only partially allocated slabs */
91465 @@ -4459,7 +4524,7 @@ SLAB_ATTR_RO(ctor);
91466
91467 static ssize_t aliases_show(struct kmem_cache *s, char *buf)
91468 {
91469 - return sprintf(buf, "%d\n", s->refcount - 1);
91470 + return sprintf(buf, "%d\n", atomic_read(&s->refcount) - 1);
91471 }
91472 SLAB_ATTR_RO(aliases);
91473
91474 @@ -4547,6 +4612,14 @@ static ssize_t cache_dma_show(struct kmem_cache *s, char *buf)
91475 SLAB_ATTR_RO(cache_dma);
91476 #endif
91477
91478 +#ifdef CONFIG_PAX_USERCOPY_SLABS
91479 +static ssize_t usercopy_show(struct kmem_cache *s, char *buf)
91480 +{
91481 + return sprintf(buf, "%d\n", !!(s->flags & SLAB_USERCOPY));
91482 +}
91483 +SLAB_ATTR_RO(usercopy);
91484 +#endif
91485 +
91486 static ssize_t destroy_by_rcu_show(struct kmem_cache *s, char *buf)
91487 {
91488 return sprintf(buf, "%d\n", !!(s->flags & SLAB_DESTROY_BY_RCU));
91489 @@ -4881,6 +4954,9 @@ static struct attribute *slab_attrs[] = {
91490 #ifdef CONFIG_ZONE_DMA
91491 &cache_dma_attr.attr,
91492 #endif
91493 +#ifdef CONFIG_PAX_USERCOPY_SLABS
91494 + &usercopy_attr.attr,
91495 +#endif
91496 #ifdef CONFIG_NUMA
91497 &remote_node_defrag_ratio_attr.attr,
91498 #endif
91499 @@ -5113,6 +5189,7 @@ static char *create_unique_id(struct kmem_cache *s)
91500 return name;
91501 }
91502
91503 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
91504 static int sysfs_slab_add(struct kmem_cache *s)
91505 {
91506 int err;
91507 @@ -5136,7 +5213,7 @@ static int sysfs_slab_add(struct kmem_cache *s)
91508 }
91509
91510 s->kobj.kset = slab_kset;
91511 - err = kobject_init_and_add(&s->kobj, &slab_ktype, NULL, name);
91512 + err = kobject_init_and_add(&s->kobj, &slab_ktype, NULL, "%s", name);
91513 if (err) {
91514 kobject_put(&s->kobj);
91515 return err;
91516 @@ -5170,6 +5247,7 @@ static void sysfs_slab_remove(struct kmem_cache *s)
91517 kobject_del(&s->kobj);
91518 kobject_put(&s->kobj);
91519 }
91520 +#endif
91521
91522 /*
91523 * Need to buffer aliases during bootup until sysfs becomes
91524 @@ -5183,6 +5261,7 @@ struct saved_alias {
91525
91526 static struct saved_alias *alias_list;
91527
91528 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
91529 static int sysfs_slab_alias(struct kmem_cache *s, const char *name)
91530 {
91531 struct saved_alias *al;
91532 @@ -5205,6 +5284,7 @@ static int sysfs_slab_alias(struct kmem_cache *s, const char *name)
91533 alias_list = al;
91534 return 0;
91535 }
91536 +#endif
91537
91538 static int __init slab_sysfs_init(void)
91539 {
91540 diff --git a/mm/sparse-vmemmap.c b/mm/sparse-vmemmap.c
91541 index 27eeab3..7c3f7f2 100644
91542 --- a/mm/sparse-vmemmap.c
91543 +++ b/mm/sparse-vmemmap.c
91544 @@ -130,7 +130,7 @@ pud_t * __meminit vmemmap_pud_populate(pgd_t *pgd, unsigned long addr, int node)
91545 void *p = vmemmap_alloc_block(PAGE_SIZE, node);
91546 if (!p)
91547 return NULL;
91548 - pud_populate(&init_mm, pud, p);
91549 + pud_populate_kernel(&init_mm, pud, p);
91550 }
91551 return pud;
91552 }
91553 @@ -142,7 +142,7 @@ pgd_t * __meminit vmemmap_pgd_populate(unsigned long addr, int node)
91554 void *p = vmemmap_alloc_block(PAGE_SIZE, node);
91555 if (!p)
91556 return NULL;
91557 - pgd_populate(&init_mm, pgd, p);
91558 + pgd_populate_kernel(&init_mm, pgd, p);
91559 }
91560 return pgd;
91561 }
91562 diff --git a/mm/sparse.c b/mm/sparse.c
91563 index 4ac1d7e..bbfcb1f 100644
91564 --- a/mm/sparse.c
91565 +++ b/mm/sparse.c
91566 @@ -745,7 +745,7 @@ static void clear_hwpoisoned_pages(struct page *memmap, int nr_pages)
91567
91568 for (i = 0; i < PAGES_PER_SECTION; i++) {
91569 if (PageHWPoison(&memmap[i])) {
91570 - atomic_long_sub(1, &num_poisoned_pages);
91571 + atomic_long_sub_unchecked(1, &num_poisoned_pages);
91572 ClearPageHWPoison(&memmap[i]);
91573 }
91574 }
91575 diff --git a/mm/swap.c b/mm/swap.c
91576 index 759c3ca..7c1a5b4 100644
91577 --- a/mm/swap.c
91578 +++ b/mm/swap.c
91579 @@ -77,6 +77,8 @@ static void __put_compound_page(struct page *page)
91580
91581 __page_cache_release(page);
91582 dtor = get_compound_page_dtor(page);
91583 + if (!PageHuge(page))
91584 + BUG_ON(dtor != free_compound_page);
91585 (*dtor)(page);
91586 }
91587
91588 diff --git a/mm/swapfile.c b/mm/swapfile.c
91589 index de7c904..c84bf11 100644
91590 --- a/mm/swapfile.c
91591 +++ b/mm/swapfile.c
91592 @@ -66,7 +66,7 @@ static DEFINE_MUTEX(swapon_mutex);
91593
91594 static DECLARE_WAIT_QUEUE_HEAD(proc_poll_wait);
91595 /* Activity counter to indicate that a swapon or swapoff has occurred */
91596 -static atomic_t proc_poll_event = ATOMIC_INIT(0);
91597 +static atomic_unchecked_t proc_poll_event = ATOMIC_INIT(0);
91598
91599 static inline unsigned char swap_count(unsigned char ent)
91600 {
91601 @@ -1949,7 +1949,7 @@ SYSCALL_DEFINE1(swapoff, const char __user *, specialfile)
91602 }
91603 filp_close(swap_file, NULL);
91604 err = 0;
91605 - atomic_inc(&proc_poll_event);
91606 + atomic_inc_unchecked(&proc_poll_event);
91607 wake_up_interruptible(&proc_poll_wait);
91608
91609 out_dput:
91610 @@ -1966,8 +1966,8 @@ static unsigned swaps_poll(struct file *file, poll_table *wait)
91611
91612 poll_wait(file, &proc_poll_wait, wait);
91613
91614 - if (seq->poll_event != atomic_read(&proc_poll_event)) {
91615 - seq->poll_event = atomic_read(&proc_poll_event);
91616 + if (seq->poll_event != atomic_read_unchecked(&proc_poll_event)) {
91617 + seq->poll_event = atomic_read_unchecked(&proc_poll_event);
91618 return POLLIN | POLLRDNORM | POLLERR | POLLPRI;
91619 }
91620
91621 @@ -2065,7 +2065,7 @@ static int swaps_open(struct inode *inode, struct file *file)
91622 return ret;
91623
91624 seq = file->private_data;
91625 - seq->poll_event = atomic_read(&proc_poll_event);
91626 + seq->poll_event = atomic_read_unchecked(&proc_poll_event);
91627 return 0;
91628 }
91629
91630 @@ -2524,7 +2524,7 @@ SYSCALL_DEFINE2(swapon, const char __user *, specialfile, int, swap_flags)
91631 (frontswap_map) ? "FS" : "");
91632
91633 mutex_unlock(&swapon_mutex);
91634 - atomic_inc(&proc_poll_event);
91635 + atomic_inc_unchecked(&proc_poll_event);
91636 wake_up_interruptible(&proc_poll_wait);
91637
91638 if (S_ISREG(inode->i_mode))
91639 diff --git a/mm/util.c b/mm/util.c
91640 index eaf63fc2..32b2629 100644
91641 --- a/mm/util.c
91642 +++ b/mm/util.c
91643 @@ -294,6 +294,12 @@ done:
91644 void arch_pick_mmap_layout(struct mm_struct *mm)
91645 {
91646 mm->mmap_base = TASK_UNMAPPED_BASE;
91647 +
91648 +#ifdef CONFIG_PAX_RANDMMAP
91649 + if (mm->pax_flags & MF_PAX_RANDMMAP)
91650 + mm->mmap_base += mm->delta_mmap;
91651 +#endif
91652 +
91653 mm->get_unmapped_area = arch_get_unmapped_area;
91654 }
91655 #endif
91656 diff --git a/mm/vmalloc.c b/mm/vmalloc.c
91657 index 1074543..136dbe0 100644
91658 --- a/mm/vmalloc.c
91659 +++ b/mm/vmalloc.c
91660 @@ -59,8 +59,19 @@ static void vunmap_pte_range(pmd_t *pmd, unsigned long addr, unsigned long end)
91661
91662 pte = pte_offset_kernel(pmd, addr);
91663 do {
91664 - pte_t ptent = ptep_get_and_clear(&init_mm, addr, pte);
91665 - WARN_ON(!pte_none(ptent) && !pte_present(ptent));
91666 +
91667 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
91668 + if ((unsigned long)MODULES_EXEC_VADDR <= addr && addr < (unsigned long)MODULES_EXEC_END) {
91669 + BUG_ON(!pte_exec(*pte));
91670 + set_pte_at(&init_mm, addr, pte, pfn_pte(__pa(addr) >> PAGE_SHIFT, PAGE_KERNEL_EXEC));
91671 + continue;
91672 + }
91673 +#endif
91674 +
91675 + {
91676 + pte_t ptent = ptep_get_and_clear(&init_mm, addr, pte);
91677 + WARN_ON(!pte_none(ptent) && !pte_present(ptent));
91678 + }
91679 } while (pte++, addr += PAGE_SIZE, addr != end);
91680 }
91681
91682 @@ -120,16 +131,29 @@ static int vmap_pte_range(pmd_t *pmd, unsigned long addr,
91683 pte = pte_alloc_kernel(pmd, addr);
91684 if (!pte)
91685 return -ENOMEM;
91686 +
91687 + pax_open_kernel();
91688 do {
91689 struct page *page = pages[*nr];
91690
91691 - if (WARN_ON(!pte_none(*pte)))
91692 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
91693 + if (pgprot_val(prot) & _PAGE_NX)
91694 +#endif
91695 +
91696 + if (!pte_none(*pte)) {
91697 + pax_close_kernel();
91698 + WARN_ON(1);
91699 return -EBUSY;
91700 - if (WARN_ON(!page))
91701 + }
91702 + if (!page) {
91703 + pax_close_kernel();
91704 + WARN_ON(1);
91705 return -ENOMEM;
91706 + }
91707 set_pte_at(&init_mm, addr, pte, mk_pte(page, prot));
91708 (*nr)++;
91709 } while (pte++, addr += PAGE_SIZE, addr != end);
91710 + pax_close_kernel();
91711 return 0;
91712 }
91713
91714 @@ -139,7 +163,7 @@ static int vmap_pmd_range(pud_t *pud, unsigned long addr,
91715 pmd_t *pmd;
91716 unsigned long next;
91717
91718 - pmd = pmd_alloc(&init_mm, pud, addr);
91719 + pmd = pmd_alloc_kernel(&init_mm, pud, addr);
91720 if (!pmd)
91721 return -ENOMEM;
91722 do {
91723 @@ -156,7 +180,7 @@ static int vmap_pud_range(pgd_t *pgd, unsigned long addr,
91724 pud_t *pud;
91725 unsigned long next;
91726
91727 - pud = pud_alloc(&init_mm, pgd, addr);
91728 + pud = pud_alloc_kernel(&init_mm, pgd, addr);
91729 if (!pud)
91730 return -ENOMEM;
91731 do {
91732 @@ -216,6 +240,12 @@ int is_vmalloc_or_module_addr(const void *x)
91733 if (addr >= MODULES_VADDR && addr < MODULES_END)
91734 return 1;
91735 #endif
91736 +
91737 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
91738 + if (x >= (const void *)MODULES_EXEC_VADDR && x < (const void *)MODULES_EXEC_END)
91739 + return 1;
91740 +#endif
91741 +
91742 return is_vmalloc_addr(x);
91743 }
91744
91745 @@ -236,8 +266,14 @@ struct page *vmalloc_to_page(const void *vmalloc_addr)
91746
91747 if (!pgd_none(*pgd)) {
91748 pud_t *pud = pud_offset(pgd, addr);
91749 +#ifdef CONFIG_X86
91750 + if (!pud_large(*pud))
91751 +#endif
91752 if (!pud_none(*pud)) {
91753 pmd_t *pmd = pmd_offset(pud, addr);
91754 +#ifdef CONFIG_X86
91755 + if (!pmd_large(*pmd))
91756 +#endif
91757 if (!pmd_none(*pmd)) {
91758 pte_t *ptep, pte;
91759
91760 @@ -1303,6 +1339,16 @@ static struct vm_struct *__get_vm_area_node(unsigned long size,
91761 struct vm_struct *area;
91762
91763 BUG_ON(in_interrupt());
91764 +
91765 +#if defined(CONFIG_X86) && defined(CONFIG_PAX_KERNEXEC)
91766 + if (flags & VM_KERNEXEC) {
91767 + if (start != VMALLOC_START || end != VMALLOC_END)
91768 + return NULL;
91769 + start = (unsigned long)MODULES_EXEC_VADDR;
91770 + end = (unsigned long)MODULES_EXEC_END;
91771 + }
91772 +#endif
91773 +
91774 if (flags & VM_IOREMAP)
91775 align = 1ul << clamp(fls(size), PAGE_SHIFT, IOREMAP_MAX_ORDER);
91776
91777 @@ -1528,6 +1574,11 @@ void *vmap(struct page **pages, unsigned int count,
91778 if (count > totalram_pages)
91779 return NULL;
91780
91781 +#if defined(CONFIG_X86) && defined(CONFIG_PAX_KERNEXEC)
91782 + if (!(pgprot_val(prot) & _PAGE_NX))
91783 + flags |= VM_KERNEXEC;
91784 +#endif
91785 +
91786 area = get_vm_area_caller((count << PAGE_SHIFT), flags,
91787 __builtin_return_address(0));
91788 if (!area)
91789 @@ -1629,6 +1680,13 @@ void *__vmalloc_node_range(unsigned long size, unsigned long align,
91790 if (!size || (size >> PAGE_SHIFT) > totalram_pages)
91791 goto fail;
91792
91793 +#if defined(CONFIG_X86) && defined(CONFIG_PAX_KERNEXEC)
91794 + if (!(pgprot_val(prot) & _PAGE_NX))
91795 + area = __get_vm_area_node(size, align, VM_ALLOC | VM_UNINITIALIZED | VM_KERNEXEC,
91796 + VMALLOC_START, VMALLOC_END, node, gfp_mask, caller);
91797 + else
91798 +#endif
91799 +
91800 area = __get_vm_area_node(size, align, VM_ALLOC | VM_UNINITIALIZED,
91801 start, end, node, gfp_mask, caller);
91802 if (!area)
91803 @@ -1805,10 +1863,9 @@ EXPORT_SYMBOL(vzalloc_node);
91804 * For tight control over page level allocator and protection flags
91805 * use __vmalloc() instead.
91806 */
91807 -
91808 void *vmalloc_exec(unsigned long size)
91809 {
91810 - return __vmalloc_node(size, 1, GFP_KERNEL | __GFP_HIGHMEM, PAGE_KERNEL_EXEC,
91811 + return __vmalloc_node(size, 1, GFP_KERNEL | __GFP_HIGHMEM | __GFP_ZERO, PAGE_KERNEL_EXEC,
91812 NUMA_NO_NODE, __builtin_return_address(0));
91813 }
91814
91815 @@ -2115,6 +2172,8 @@ int remap_vmalloc_range_partial(struct vm_area_struct *vma, unsigned long uaddr,
91816 {
91817 struct vm_struct *area;
91818
91819 + BUG_ON(vma->vm_mirror);
91820 +
91821 size = PAGE_ALIGN(size);
91822
91823 if (!PAGE_ALIGNED(uaddr) || !PAGE_ALIGNED(kaddr))
91824 @@ -2600,7 +2659,11 @@ static int s_show(struct seq_file *m, void *p)
91825 v->addr, v->addr + v->size, v->size);
91826
91827 if (v->caller)
91828 +#ifdef CONFIG_GRKERNSEC_HIDESYM
91829 + seq_printf(m, " %pK", v->caller);
91830 +#else
91831 seq_printf(m, " %pS", v->caller);
91832 +#endif
91833
91834 if (v->nr_pages)
91835 seq_printf(m, " pages=%d", v->nr_pages);
91836 diff --git a/mm/vmstat.c b/mm/vmstat.c
91837 index 5a442a7..5eb281e 100644
91838 --- a/mm/vmstat.c
91839 +++ b/mm/vmstat.c
91840 @@ -79,7 +79,7 @@ void vm_events_fold_cpu(int cpu)
91841 *
91842 * vm_stat contains the global counters
91843 */
91844 -atomic_long_t vm_stat[NR_VM_ZONE_STAT_ITEMS] __cacheline_aligned_in_smp;
91845 +atomic_long_unchecked_t vm_stat[NR_VM_ZONE_STAT_ITEMS] __cacheline_aligned_in_smp;
91846 EXPORT_SYMBOL(vm_stat);
91847
91848 #ifdef CONFIG_SMP
91849 @@ -423,7 +423,7 @@ static inline void fold_diff(int *diff)
91850
91851 for (i = 0; i < NR_VM_ZONE_STAT_ITEMS; i++)
91852 if (diff[i])
91853 - atomic_long_add(diff[i], &vm_stat[i]);
91854 + atomic_long_add_unchecked(diff[i], &vm_stat[i]);
91855 }
91856
91857 /*
91858 @@ -455,7 +455,7 @@ static void refresh_cpu_vm_stats(void)
91859 v = this_cpu_xchg(p->vm_stat_diff[i], 0);
91860 if (v) {
91861
91862 - atomic_long_add(v, &zone->vm_stat[i]);
91863 + atomic_long_add_unchecked(v, &zone->vm_stat[i]);
91864 global_diff[i] += v;
91865 #ifdef CONFIG_NUMA
91866 /* 3 seconds idle till flush */
91867 @@ -517,7 +517,7 @@ void cpu_vm_stats_fold(int cpu)
91868
91869 v = p->vm_stat_diff[i];
91870 p->vm_stat_diff[i] = 0;
91871 - atomic_long_add(v, &zone->vm_stat[i]);
91872 + atomic_long_add_unchecked(v, &zone->vm_stat[i]);
91873 global_diff[i] += v;
91874 }
91875 }
91876 @@ -537,8 +537,8 @@ void drain_zonestat(struct zone *zone, struct per_cpu_pageset *pset)
91877 if (pset->vm_stat_diff[i]) {
91878 int v = pset->vm_stat_diff[i];
91879 pset->vm_stat_diff[i] = 0;
91880 - atomic_long_add(v, &zone->vm_stat[i]);
91881 - atomic_long_add(v, &vm_stat[i]);
91882 + atomic_long_add_unchecked(v, &zone->vm_stat[i]);
91883 + atomic_long_add_unchecked(v, &vm_stat[i]);
91884 }
91885 }
91886 #endif
91887 @@ -1281,10 +1281,20 @@ static int __init setup_vmstat(void)
91888 start_cpu_timer(cpu);
91889 #endif
91890 #ifdef CONFIG_PROC_FS
91891 - proc_create("buddyinfo", S_IRUGO, NULL, &fragmentation_file_operations);
91892 - proc_create("pagetypeinfo", S_IRUGO, NULL, &pagetypeinfo_file_ops);
91893 - proc_create("vmstat", S_IRUGO, NULL, &proc_vmstat_file_operations);
91894 - proc_create("zoneinfo", S_IRUGO, NULL, &proc_zoneinfo_file_operations);
91895 + {
91896 + mode_t gr_mode = S_IRUGO;
91897 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
91898 + gr_mode = S_IRUSR;
91899 +#endif
91900 + proc_create("buddyinfo", gr_mode, NULL, &fragmentation_file_operations);
91901 + proc_create("pagetypeinfo", gr_mode, NULL, &pagetypeinfo_file_ops);
91902 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
91903 + proc_create("vmstat", gr_mode | S_IRGRP, NULL, &proc_vmstat_file_operations);
91904 +#else
91905 + proc_create("vmstat", gr_mode, NULL, &proc_vmstat_file_operations);
91906 +#endif
91907 + proc_create("zoneinfo", gr_mode, NULL, &proc_zoneinfo_file_operations);
91908 + }
91909 #endif
91910 return 0;
91911 }
91912 diff --git a/net/8021q/vlan.c b/net/8021q/vlan.c
91913 index 61fc573..b5e47d0 100644
91914 --- a/net/8021q/vlan.c
91915 +++ b/net/8021q/vlan.c
91916 @@ -472,7 +472,7 @@ out:
91917 return NOTIFY_DONE;
91918 }
91919
91920 -static struct notifier_block vlan_notifier_block __read_mostly = {
91921 +static struct notifier_block vlan_notifier_block = {
91922 .notifier_call = vlan_device_event,
91923 };
91924
91925 @@ -547,8 +547,7 @@ static int vlan_ioctl_handler(struct net *net, void __user *arg)
91926 err = -EPERM;
91927 if (!ns_capable(net->user_ns, CAP_NET_ADMIN))
91928 break;
91929 - if ((args.u.name_type >= 0) &&
91930 - (args.u.name_type < VLAN_NAME_TYPE_HIGHEST)) {
91931 + if (args.u.name_type < VLAN_NAME_TYPE_HIGHEST) {
91932 struct vlan_net *vn;
91933
91934 vn = net_generic(net, vlan_net_id);
91935 diff --git a/net/9p/mod.c b/net/9p/mod.c
91936 index 6ab36ae..6f1841b 100644
91937 --- a/net/9p/mod.c
91938 +++ b/net/9p/mod.c
91939 @@ -84,7 +84,7 @@ static LIST_HEAD(v9fs_trans_list);
91940 void v9fs_register_trans(struct p9_trans_module *m)
91941 {
91942 spin_lock(&v9fs_trans_lock);
91943 - list_add_tail(&m->list, &v9fs_trans_list);
91944 + pax_list_add_tail((struct list_head *)&m->list, &v9fs_trans_list);
91945 spin_unlock(&v9fs_trans_lock);
91946 }
91947 EXPORT_SYMBOL(v9fs_register_trans);
91948 @@ -97,7 +97,7 @@ EXPORT_SYMBOL(v9fs_register_trans);
91949 void v9fs_unregister_trans(struct p9_trans_module *m)
91950 {
91951 spin_lock(&v9fs_trans_lock);
91952 - list_del_init(&m->list);
91953 + pax_list_del_init((struct list_head *)&m->list);
91954 spin_unlock(&v9fs_trans_lock);
91955 }
91956 EXPORT_SYMBOL(v9fs_unregister_trans);
91957 diff --git a/net/9p/trans_fd.c b/net/9p/trans_fd.c
91958 index 3ffda1b..fceac96 100644
91959 --- a/net/9p/trans_fd.c
91960 +++ b/net/9p/trans_fd.c
91961 @@ -432,7 +432,7 @@ static int p9_fd_write(struct p9_client *client, void *v, int len)
91962 oldfs = get_fs();
91963 set_fs(get_ds());
91964 /* The cast to a user pointer is valid due to the set_fs() */
91965 - ret = vfs_write(ts->wr, (__force void __user *)v, len, &ts->wr->f_pos);
91966 + ret = vfs_write(ts->wr, (void __force_user *)v, len, &ts->wr->f_pos);
91967 set_fs(oldfs);
91968
91969 if (ret <= 0 && ret != -ERESTARTSYS && ret != -EAGAIN)
91970 diff --git a/net/atm/atm_misc.c b/net/atm/atm_misc.c
91971 index 876fbe8..8bbea9f 100644
91972 --- a/net/atm/atm_misc.c
91973 +++ b/net/atm/atm_misc.c
91974 @@ -17,7 +17,7 @@ int atm_charge(struct atm_vcc *vcc, int truesize)
91975 if (atomic_read(&sk_atm(vcc)->sk_rmem_alloc) <= sk_atm(vcc)->sk_rcvbuf)
91976 return 1;
91977 atm_return(vcc, truesize);
91978 - atomic_inc(&vcc->stats->rx_drop);
91979 + atomic_inc_unchecked(&vcc->stats->rx_drop);
91980 return 0;
91981 }
91982 EXPORT_SYMBOL(atm_charge);
91983 @@ -39,7 +39,7 @@ struct sk_buff *atm_alloc_charge(struct atm_vcc *vcc, int pdu_size,
91984 }
91985 }
91986 atm_return(vcc, guess);
91987 - atomic_inc(&vcc->stats->rx_drop);
91988 + atomic_inc_unchecked(&vcc->stats->rx_drop);
91989 return NULL;
91990 }
91991 EXPORT_SYMBOL(atm_alloc_charge);
91992 @@ -86,7 +86,7 @@ EXPORT_SYMBOL(atm_pcr_goal);
91993
91994 void sonet_copy_stats(struct k_sonet_stats *from, struct sonet_stats *to)
91995 {
91996 -#define __HANDLE_ITEM(i) to->i = atomic_read(&from->i)
91997 +#define __HANDLE_ITEM(i) to->i = atomic_read_unchecked(&from->i)
91998 __SONET_ITEMS
91999 #undef __HANDLE_ITEM
92000 }
92001 @@ -94,7 +94,7 @@ EXPORT_SYMBOL(sonet_copy_stats);
92002
92003 void sonet_subtract_stats(struct k_sonet_stats *from, struct sonet_stats *to)
92004 {
92005 -#define __HANDLE_ITEM(i) atomic_sub(to->i, &from->i)
92006 +#define __HANDLE_ITEM(i) atomic_sub_unchecked(to->i,&from->i)
92007 __SONET_ITEMS
92008 #undef __HANDLE_ITEM
92009 }
92010 diff --git a/net/atm/lec.h b/net/atm/lec.h
92011 index 4149db1..f2ab682 100644
92012 --- a/net/atm/lec.h
92013 +++ b/net/atm/lec.h
92014 @@ -48,7 +48,7 @@ struct lane2_ops {
92015 const u8 *tlvs, u32 sizeoftlvs);
92016 void (*associate_indicator) (struct net_device *dev, const u8 *mac_addr,
92017 const u8 *tlvs, u32 sizeoftlvs);
92018 -};
92019 +} __no_const;
92020
92021 /*
92022 * ATM LAN Emulation supports both LLC & Dix Ethernet EtherType
92023 diff --git a/net/atm/proc.c b/net/atm/proc.c
92024 index bbb6461..cf04016 100644
92025 --- a/net/atm/proc.c
92026 +++ b/net/atm/proc.c
92027 @@ -45,9 +45,9 @@ static void add_stats(struct seq_file *seq, const char *aal,
92028 const struct k_atm_aal_stats *stats)
92029 {
92030 seq_printf(seq, "%s ( %d %d %d %d %d )", aal,
92031 - atomic_read(&stats->tx), atomic_read(&stats->tx_err),
92032 - atomic_read(&stats->rx), atomic_read(&stats->rx_err),
92033 - atomic_read(&stats->rx_drop));
92034 + atomic_read_unchecked(&stats->tx),atomic_read_unchecked(&stats->tx_err),
92035 + atomic_read_unchecked(&stats->rx),atomic_read_unchecked(&stats->rx_err),
92036 + atomic_read_unchecked(&stats->rx_drop));
92037 }
92038
92039 static void atm_dev_info(struct seq_file *seq, const struct atm_dev *dev)
92040 diff --git a/net/atm/resources.c b/net/atm/resources.c
92041 index 0447d5d..3cf4728 100644
92042 --- a/net/atm/resources.c
92043 +++ b/net/atm/resources.c
92044 @@ -160,7 +160,7 @@ EXPORT_SYMBOL(atm_dev_deregister);
92045 static void copy_aal_stats(struct k_atm_aal_stats *from,
92046 struct atm_aal_stats *to)
92047 {
92048 -#define __HANDLE_ITEM(i) to->i = atomic_read(&from->i)
92049 +#define __HANDLE_ITEM(i) to->i = atomic_read_unchecked(&from->i)
92050 __AAL_STAT_ITEMS
92051 #undef __HANDLE_ITEM
92052 }
92053 @@ -168,7 +168,7 @@ static void copy_aal_stats(struct k_atm_aal_stats *from,
92054 static void subtract_aal_stats(struct k_atm_aal_stats *from,
92055 struct atm_aal_stats *to)
92056 {
92057 -#define __HANDLE_ITEM(i) atomic_sub(to->i, &from->i)
92058 +#define __HANDLE_ITEM(i) atomic_sub_unchecked(to->i, &from->i)
92059 __AAL_STAT_ITEMS
92060 #undef __HANDLE_ITEM
92061 }
92062 diff --git a/net/ax25/sysctl_net_ax25.c b/net/ax25/sysctl_net_ax25.c
92063 index 919a5ce..cc6b444 100644
92064 --- a/net/ax25/sysctl_net_ax25.c
92065 +++ b/net/ax25/sysctl_net_ax25.c
92066 @@ -152,7 +152,7 @@ int ax25_register_dev_sysctl(ax25_dev *ax25_dev)
92067 {
92068 char path[sizeof("net/ax25/") + IFNAMSIZ];
92069 int k;
92070 - struct ctl_table *table;
92071 + ctl_table_no_const *table;
92072
92073 table = kmemdup(ax25_param_table, sizeof(ax25_param_table), GFP_KERNEL);
92074 if (!table)
92075 diff --git a/net/batman-adv/bat_iv_ogm.c b/net/batman-adv/bat_iv_ogm.c
92076 index 0a8a80c..f7e89aa 100644
92077 --- a/net/batman-adv/bat_iv_ogm.c
92078 +++ b/net/batman-adv/bat_iv_ogm.c
92079 @@ -121,7 +121,7 @@ static int batadv_iv_ogm_iface_enable(struct batadv_hard_iface *hard_iface)
92080
92081 /* randomize initial seqno to avoid collision */
92082 get_random_bytes(&random_seqno, sizeof(random_seqno));
92083 - atomic_set(&hard_iface->bat_iv.ogm_seqno, random_seqno);
92084 + atomic_set_unchecked(&hard_iface->bat_iv.ogm_seqno, random_seqno);
92085
92086 hard_iface->bat_iv.ogm_buff_len = BATADV_OGM_HLEN;
92087 ogm_buff = kmalloc(hard_iface->bat_iv.ogm_buff_len, GFP_ATOMIC);
92088 @@ -703,9 +703,9 @@ static void batadv_iv_ogm_schedule(struct batadv_hard_iface *hard_iface)
92089 batadv_ogm_packet = (struct batadv_ogm_packet *)(*ogm_buff);
92090
92091 /* change sequence number to network order */
92092 - seqno = (uint32_t)atomic_read(&hard_iface->bat_iv.ogm_seqno);
92093 + seqno = (uint32_t)atomic_read_unchecked(&hard_iface->bat_iv.ogm_seqno);
92094 batadv_ogm_packet->seqno = htonl(seqno);
92095 - atomic_inc(&hard_iface->bat_iv.ogm_seqno);
92096 + atomic_inc_unchecked(&hard_iface->bat_iv.ogm_seqno);
92097
92098 batadv_ogm_packet->ttvn = atomic_read(&bat_priv->tt.vn);
92099 batadv_ogm_packet->tt_crc = htons(bat_priv->tt.local_crc);
92100 @@ -1111,7 +1111,7 @@ static void batadv_iv_ogm_process(const struct ethhdr *ethhdr,
92101 return;
92102
92103 /* could be changed by schedule_own_packet() */
92104 - if_incoming_seqno = atomic_read(&if_incoming->bat_iv.ogm_seqno);
92105 + if_incoming_seqno = atomic_read_unchecked(&if_incoming->bat_iv.ogm_seqno);
92106
92107 if (batadv_ogm_packet->flags & BATADV_DIRECTLINK)
92108 has_directlink_flag = 1;
92109 diff --git a/net/batman-adv/hard-interface.c b/net/batman-adv/hard-interface.c
92110 index c478e6b..469fd2f 100644
92111 --- a/net/batman-adv/hard-interface.c
92112 +++ b/net/batman-adv/hard-interface.c
92113 @@ -453,7 +453,7 @@ int batadv_hardif_enable_interface(struct batadv_hard_iface *hard_iface,
92114 hard_iface->batman_adv_ptype.dev = hard_iface->net_dev;
92115 dev_add_pack(&hard_iface->batman_adv_ptype);
92116
92117 - atomic_set(&hard_iface->frag_seqno, 1);
92118 + atomic_set_unchecked(&hard_iface->frag_seqno, 1);
92119 batadv_info(hard_iface->soft_iface, "Adding interface: %s\n",
92120 hard_iface->net_dev->name);
92121
92122 diff --git a/net/batman-adv/soft-interface.c b/net/batman-adv/soft-interface.c
92123 index 813db4e..847edac 100644
92124 --- a/net/batman-adv/soft-interface.c
92125 +++ b/net/batman-adv/soft-interface.c
92126 @@ -263,7 +263,7 @@ static int batadv_interface_tx(struct sk_buff *skb,
92127 primary_if->net_dev->dev_addr, ETH_ALEN);
92128
92129 /* set broadcast sequence number */
92130 - seqno = atomic_inc_return(&bat_priv->bcast_seqno);
92131 + seqno = atomic_inc_return_unchecked(&bat_priv->bcast_seqno);
92132 bcast_packet->seqno = htonl(seqno);
92133
92134 batadv_add_bcast_packet_to_list(bat_priv, skb, brd_delay);
92135 @@ -483,7 +483,7 @@ static int batadv_softif_init_late(struct net_device *dev)
92136 atomic_set(&bat_priv->batman_queue_left, BATADV_BATMAN_QUEUE_LEN);
92137
92138 atomic_set(&bat_priv->mesh_state, BATADV_MESH_INACTIVE);
92139 - atomic_set(&bat_priv->bcast_seqno, 1);
92140 + atomic_set_unchecked(&bat_priv->bcast_seqno, 1);
92141 atomic_set(&bat_priv->tt.vn, 0);
92142 atomic_set(&bat_priv->tt.local_changes, 0);
92143 atomic_set(&bat_priv->tt.ogm_append_cnt, 0);
92144 diff --git a/net/batman-adv/types.h b/net/batman-adv/types.h
92145 index b2c94e1..3d47e07 100644
92146 --- a/net/batman-adv/types.h
92147 +++ b/net/batman-adv/types.h
92148 @@ -51,7 +51,7 @@
92149 struct batadv_hard_iface_bat_iv {
92150 unsigned char *ogm_buff;
92151 int ogm_buff_len;
92152 - atomic_t ogm_seqno;
92153 + atomic_unchecked_t ogm_seqno;
92154 };
92155
92156 /**
92157 @@ -76,7 +76,7 @@ struct batadv_hard_iface {
92158 int16_t if_num;
92159 char if_status;
92160 struct net_device *net_dev;
92161 - atomic_t frag_seqno;
92162 + atomic_unchecked_t frag_seqno;
92163 uint8_t num_bcasts;
92164 struct kobject *hardif_obj;
92165 atomic_t refcount;
92166 @@ -560,7 +560,7 @@ struct batadv_priv {
92167 #ifdef CONFIG_BATMAN_ADV_DEBUG
92168 atomic_t log_level;
92169 #endif
92170 - atomic_t bcast_seqno;
92171 + atomic_unchecked_t bcast_seqno;
92172 atomic_t bcast_queue_left;
92173 atomic_t batman_queue_left;
92174 char num_ifaces;
92175 diff --git a/net/batman-adv/unicast.c b/net/batman-adv/unicast.c
92176 index 48b31d3..62a0bcb 100644
92177 --- a/net/batman-adv/unicast.c
92178 +++ b/net/batman-adv/unicast.c
92179 @@ -272,7 +272,7 @@ int batadv_frag_send_skb(struct sk_buff *skb, struct batadv_priv *bat_priv,
92180 frag1->flags = BATADV_UNI_FRAG_HEAD | large_tail;
92181 frag2->flags = large_tail;
92182
92183 - seqno = atomic_add_return(2, &hard_iface->frag_seqno);
92184 + seqno = atomic_add_return_unchecked(2, &hard_iface->frag_seqno);
92185 frag1->seqno = htons(seqno - 1);
92186 frag2->seqno = htons(seqno);
92187
92188 diff --git a/net/bluetooth/hci_sock.c b/net/bluetooth/hci_sock.c
92189 index fa4bf66..e92948f 100644
92190 --- a/net/bluetooth/hci_sock.c
92191 +++ b/net/bluetooth/hci_sock.c
92192 @@ -932,7 +932,7 @@ static int hci_sock_setsockopt(struct socket *sock, int level, int optname,
92193 uf.event_mask[1] = *((u32 *) f->event_mask + 1);
92194 }
92195
92196 - len = min_t(unsigned int, len, sizeof(uf));
92197 + len = min((size_t)len, sizeof(uf));
92198 if (copy_from_user(&uf, optval, len)) {
92199 err = -EFAULT;
92200 break;
92201 diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
92202 index 63fa111..b166ec6 100644
92203 --- a/net/bluetooth/l2cap_core.c
92204 +++ b/net/bluetooth/l2cap_core.c
92205 @@ -3511,8 +3511,10 @@ static int l2cap_parse_conf_rsp(struct l2cap_chan *chan, void *rsp, int len,
92206 break;
92207
92208 case L2CAP_CONF_RFC:
92209 - if (olen == sizeof(rfc))
92210 - memcpy(&rfc, (void *)val, olen);
92211 + if (olen != sizeof(rfc))
92212 + break;
92213 +
92214 + memcpy(&rfc, (void *)val, olen);
92215
92216 if (test_bit(CONF_STATE2_DEVICE, &chan->conf_state) &&
92217 rfc.mode != chan->mode)
92218 diff --git a/net/bluetooth/l2cap_sock.c b/net/bluetooth/l2cap_sock.c
92219 index 0098af8..fb5a31f 100644
92220 --- a/net/bluetooth/l2cap_sock.c
92221 +++ b/net/bluetooth/l2cap_sock.c
92222 @@ -485,7 +485,8 @@ static int l2cap_sock_setsockopt_old(struct socket *sock, int optname,
92223 struct sock *sk = sock->sk;
92224 struct l2cap_chan *chan = l2cap_pi(sk)->chan;
92225 struct l2cap_options opts;
92226 - int len, err = 0;
92227 + int err = 0;
92228 + size_t len = optlen;
92229 u32 opt;
92230
92231 BT_DBG("sk %p", sk);
92232 @@ -507,7 +508,7 @@ static int l2cap_sock_setsockopt_old(struct socket *sock, int optname,
92233 opts.max_tx = chan->max_tx;
92234 opts.txwin_size = chan->tx_win;
92235
92236 - len = min_t(unsigned int, sizeof(opts), optlen);
92237 + len = min(sizeof(opts), len);
92238 if (copy_from_user((char *) &opts, optval, len)) {
92239 err = -EFAULT;
92240 break;
92241 @@ -587,7 +588,8 @@ static int l2cap_sock_setsockopt(struct socket *sock, int level, int optname,
92242 struct bt_security sec;
92243 struct bt_power pwr;
92244 struct l2cap_conn *conn;
92245 - int len, err = 0;
92246 + int err = 0;
92247 + size_t len = optlen;
92248 u32 opt;
92249
92250 BT_DBG("sk %p", sk);
92251 @@ -610,7 +612,7 @@ static int l2cap_sock_setsockopt(struct socket *sock, int level, int optname,
92252
92253 sec.level = BT_SECURITY_LOW;
92254
92255 - len = min_t(unsigned int, sizeof(sec), optlen);
92256 + len = min(sizeof(sec), len);
92257 if (copy_from_user((char *) &sec, optval, len)) {
92258 err = -EFAULT;
92259 break;
92260 @@ -707,7 +709,7 @@ static int l2cap_sock_setsockopt(struct socket *sock, int level, int optname,
92261
92262 pwr.force_active = BT_POWER_FORCE_ACTIVE_ON;
92263
92264 - len = min_t(unsigned int, sizeof(pwr), optlen);
92265 + len = min(sizeof(pwr), len);
92266 if (copy_from_user((char *) &pwr, optval, len)) {
92267 err = -EFAULT;
92268 break;
92269 diff --git a/net/bluetooth/rfcomm/sock.c b/net/bluetooth/rfcomm/sock.c
92270 index c1c6028..17e8dcc 100644
92271 --- a/net/bluetooth/rfcomm/sock.c
92272 +++ b/net/bluetooth/rfcomm/sock.c
92273 @@ -665,7 +665,7 @@ static int rfcomm_sock_setsockopt(struct socket *sock, int level, int optname, c
92274 struct sock *sk = sock->sk;
92275 struct bt_security sec;
92276 int err = 0;
92277 - size_t len;
92278 + size_t len = optlen;
92279 u32 opt;
92280
92281 BT_DBG("sk %p", sk);
92282 @@ -687,7 +687,7 @@ static int rfcomm_sock_setsockopt(struct socket *sock, int level, int optname, c
92283
92284 sec.level = BT_SECURITY_LOW;
92285
92286 - len = min_t(unsigned int, sizeof(sec), optlen);
92287 + len = min(sizeof(sec), len);
92288 if (copy_from_user((char *) &sec, optval, len)) {
92289 err = -EFAULT;
92290 break;
92291 diff --git a/net/bluetooth/rfcomm/tty.c b/net/bluetooth/rfcomm/tty.c
92292 index 84fcf9f..e389b27 100644
92293 --- a/net/bluetooth/rfcomm/tty.c
92294 +++ b/net/bluetooth/rfcomm/tty.c
92295 @@ -684,7 +684,7 @@ static int rfcomm_tty_open(struct tty_struct *tty, struct file *filp)
92296 BT_DBG("tty %p id %d", tty, tty->index);
92297
92298 BT_DBG("dev %p dst %pMR channel %d opened %d", dev, &dev->dst,
92299 - dev->channel, dev->port.count);
92300 + dev->channel, atomic_read(&dev->port.count));
92301
92302 err = tty_port_open(&dev->port, tty, filp);
92303 if (err)
92304 @@ -707,7 +707,7 @@ static void rfcomm_tty_close(struct tty_struct *tty, struct file *filp)
92305 struct rfcomm_dev *dev = (struct rfcomm_dev *) tty->driver_data;
92306
92307 BT_DBG("tty %p dev %p dlc %p opened %d", tty, dev, dev->dlc,
92308 - dev->port.count);
92309 + atomic_read(&dev->port.count));
92310
92311 tty_port_close(&dev->port, tty, filp);
92312 }
92313 diff --git a/net/bridge/netfilter/ebt_ulog.c b/net/bridge/netfilter/ebt_ulog.c
92314 index 5180938..7c470c3 100644
92315 --- a/net/bridge/netfilter/ebt_ulog.c
92316 +++ b/net/bridge/netfilter/ebt_ulog.c
92317 @@ -181,6 +181,7 @@ static void ebt_ulog_packet(struct net *net, unsigned int hooknr,
92318 ub->qlen++;
92319
92320 pm = nlmsg_data(nlh);
92321 + memset(pm, 0, sizeof(*pm));
92322
92323 /* Fill in the ulog data */
92324 pm->version = EBT_ULOG_VERSION;
92325 @@ -193,8 +194,6 @@ static void ebt_ulog_packet(struct net *net, unsigned int hooknr,
92326 pm->hook = hooknr;
92327 if (uloginfo->prefix != NULL)
92328 strcpy(pm->prefix, uloginfo->prefix);
92329 - else
92330 - *(pm->prefix) = '\0';
92331
92332 if (in) {
92333 strcpy(pm->physindev, in->name);
92334 @@ -204,16 +203,14 @@ static void ebt_ulog_packet(struct net *net, unsigned int hooknr,
92335 strcpy(pm->indev, br_port_get_rcu(in)->br->dev->name);
92336 else
92337 strcpy(pm->indev, in->name);
92338 - } else
92339 - pm->indev[0] = pm->physindev[0] = '\0';
92340 + }
92341
92342 if (out) {
92343 /* If out exists, then out is a bridge port */
92344 strcpy(pm->physoutdev, out->name);
92345 /* rcu_read_lock()ed by nf_hook_slow */
92346 strcpy(pm->outdev, br_port_get_rcu(out)->br->dev->name);
92347 - } else
92348 - pm->outdev[0] = pm->physoutdev[0] = '\0';
92349 + }
92350
92351 if (skb_copy_bits(skb, -ETH_HLEN, pm->data, copy_len) < 0)
92352 BUG();
92353 diff --git a/net/bridge/netfilter/ebtables.c b/net/bridge/netfilter/ebtables.c
92354 index ac78024..161a80c 100644
92355 --- a/net/bridge/netfilter/ebtables.c
92356 +++ b/net/bridge/netfilter/ebtables.c
92357 @@ -1525,7 +1525,7 @@ static int do_ebt_get_ctl(struct sock *sk, int cmd, void __user *user, int *len)
92358 tmp.valid_hooks = t->table->valid_hooks;
92359 }
92360 mutex_unlock(&ebt_mutex);
92361 - if (copy_to_user(user, &tmp, *len) != 0){
92362 + if (*len > sizeof(tmp) || copy_to_user(user, &tmp, *len) != 0){
92363 BUGPRINT("c2u Didn't work\n");
92364 ret = -EFAULT;
92365 break;
92366 @@ -2331,7 +2331,7 @@ static int compat_do_ebt_get_ctl(struct sock *sk, int cmd,
92367 goto out;
92368 tmp.valid_hooks = t->valid_hooks;
92369
92370 - if (copy_to_user(user, &tmp, *len) != 0) {
92371 + if (*len > sizeof(tmp) || copy_to_user(user, &tmp, *len) != 0) {
92372 ret = -EFAULT;
92373 break;
92374 }
92375 @@ -2342,7 +2342,7 @@ static int compat_do_ebt_get_ctl(struct sock *sk, int cmd,
92376 tmp.entries_size = t->table->entries_size;
92377 tmp.valid_hooks = t->table->valid_hooks;
92378
92379 - if (copy_to_user(user, &tmp, *len) != 0) {
92380 + if (*len > sizeof(tmp) || copy_to_user(user, &tmp, *len) != 0) {
92381 ret = -EFAULT;
92382 break;
92383 }
92384 diff --git a/net/caif/cfctrl.c b/net/caif/cfctrl.c
92385 index 0f45522..dab651f 100644
92386 --- a/net/caif/cfctrl.c
92387 +++ b/net/caif/cfctrl.c
92388 @@ -10,6 +10,7 @@
92389 #include <linux/spinlock.h>
92390 #include <linux/slab.h>
92391 #include <linux/pkt_sched.h>
92392 +#include <linux/sched.h>
92393 #include <net/caif/caif_layer.h>
92394 #include <net/caif/cfpkt.h>
92395 #include <net/caif/cfctrl.h>
92396 @@ -43,8 +44,8 @@ struct cflayer *cfctrl_create(void)
92397 memset(&dev_info, 0, sizeof(dev_info));
92398 dev_info.id = 0xff;
92399 cfsrvl_init(&this->serv, 0, &dev_info, false);
92400 - atomic_set(&this->req_seq_no, 1);
92401 - atomic_set(&this->rsp_seq_no, 1);
92402 + atomic_set_unchecked(&this->req_seq_no, 1);
92403 + atomic_set_unchecked(&this->rsp_seq_no, 1);
92404 this->serv.layer.receive = cfctrl_recv;
92405 sprintf(this->serv.layer.name, "ctrl");
92406 this->serv.layer.ctrlcmd = cfctrl_ctrlcmd;
92407 @@ -130,8 +131,8 @@ static void cfctrl_insert_req(struct cfctrl *ctrl,
92408 struct cfctrl_request_info *req)
92409 {
92410 spin_lock_bh(&ctrl->info_list_lock);
92411 - atomic_inc(&ctrl->req_seq_no);
92412 - req->sequence_no = atomic_read(&ctrl->req_seq_no);
92413 + atomic_inc_unchecked(&ctrl->req_seq_no);
92414 + req->sequence_no = atomic_read_unchecked(&ctrl->req_seq_no);
92415 list_add_tail(&req->list, &ctrl->list);
92416 spin_unlock_bh(&ctrl->info_list_lock);
92417 }
92418 @@ -149,7 +150,7 @@ static struct cfctrl_request_info *cfctrl_remove_req(struct cfctrl *ctrl,
92419 if (p != first)
92420 pr_warn("Requests are not received in order\n");
92421
92422 - atomic_set(&ctrl->rsp_seq_no,
92423 + atomic_set_unchecked(&ctrl->rsp_seq_no,
92424 p->sequence_no);
92425 list_del(&p->list);
92426 goto out;
92427 diff --git a/net/can/af_can.c b/net/can/af_can.c
92428 index 3ab8dd2..b9aef13 100644
92429 --- a/net/can/af_can.c
92430 +++ b/net/can/af_can.c
92431 @@ -862,7 +862,7 @@ static const struct net_proto_family can_family_ops = {
92432 };
92433
92434 /* notifier block for netdevice event */
92435 -static struct notifier_block can_netdev_notifier __read_mostly = {
92436 +static struct notifier_block can_netdev_notifier = {
92437 .notifier_call = can_notifier,
92438 };
92439
92440 diff --git a/net/can/gw.c b/net/can/gw.c
92441 index 3f9b0f3..fc6d4fa 100644
92442 --- a/net/can/gw.c
92443 +++ b/net/can/gw.c
92444 @@ -80,7 +80,6 @@ MODULE_PARM_DESC(max_hops,
92445 "default: " __stringify(CGW_DEFAULT_HOPS) ")");
92446
92447 static HLIST_HEAD(cgw_list);
92448 -static struct notifier_block notifier;
92449
92450 static struct kmem_cache *cgw_cache __read_mostly;
92451
92452 @@ -954,6 +953,10 @@ static int cgw_remove_job(struct sk_buff *skb, struct nlmsghdr *nlh)
92453 return err;
92454 }
92455
92456 +static struct notifier_block notifier = {
92457 + .notifier_call = cgw_notifier
92458 +};
92459 +
92460 static __init int cgw_module_init(void)
92461 {
92462 /* sanitize given module parameter */
92463 @@ -969,7 +972,6 @@ static __init int cgw_module_init(void)
92464 return -ENOMEM;
92465
92466 /* set notifier */
92467 - notifier.notifier_call = cgw_notifier;
92468 register_netdevice_notifier(&notifier);
92469
92470 if (__rtnl_register(PF_CAN, RTM_GETROUTE, NULL, cgw_dump_jobs, NULL)) {
92471 diff --git a/net/ceph/messenger.c b/net/ceph/messenger.c
92472 index 4a5df7b..9ad1f1d 100644
92473 --- a/net/ceph/messenger.c
92474 +++ b/net/ceph/messenger.c
92475 @@ -186,7 +186,7 @@ static void con_fault(struct ceph_connection *con);
92476 #define MAX_ADDR_STR_LEN 64 /* 54 is enough */
92477
92478 static char addr_str[ADDR_STR_COUNT][MAX_ADDR_STR_LEN];
92479 -static atomic_t addr_str_seq = ATOMIC_INIT(0);
92480 +static atomic_unchecked_t addr_str_seq = ATOMIC_INIT(0);
92481
92482 static struct page *zero_page; /* used in certain error cases */
92483
92484 @@ -197,7 +197,7 @@ const char *ceph_pr_addr(const struct sockaddr_storage *ss)
92485 struct sockaddr_in *in4 = (struct sockaddr_in *) ss;
92486 struct sockaddr_in6 *in6 = (struct sockaddr_in6 *) ss;
92487
92488 - i = atomic_inc_return(&addr_str_seq) & ADDR_STR_COUNT_MASK;
92489 + i = atomic_inc_return_unchecked(&addr_str_seq) & ADDR_STR_COUNT_MASK;
92490 s = addr_str[i];
92491
92492 switch (ss->ss_family) {
92493 diff --git a/net/compat.c b/net/compat.c
92494 index dd32e34..6066f87 100644
92495 --- a/net/compat.c
92496 +++ b/net/compat.c
92497 @@ -73,9 +73,9 @@ int get_compat_msghdr(struct msghdr *kmsg, struct compat_msghdr __user *umsg)
92498 return -EFAULT;
92499 if (kmsg->msg_namelen > sizeof(struct sockaddr_storage))
92500 kmsg->msg_namelen = sizeof(struct sockaddr_storage);
92501 - kmsg->msg_name = compat_ptr(tmp1);
92502 - kmsg->msg_iov = compat_ptr(tmp2);
92503 - kmsg->msg_control = compat_ptr(tmp3);
92504 + kmsg->msg_name = (void __force_kernel *)compat_ptr(tmp1);
92505 + kmsg->msg_iov = (void __force_kernel *)compat_ptr(tmp2);
92506 + kmsg->msg_control = (void __force_kernel *)compat_ptr(tmp3);
92507 return 0;
92508 }
92509
92510 @@ -87,7 +87,7 @@ int verify_compat_iovec(struct msghdr *kern_msg, struct iovec *kern_iov,
92511
92512 if (kern_msg->msg_namelen) {
92513 if (mode == VERIFY_READ) {
92514 - int err = move_addr_to_kernel(kern_msg->msg_name,
92515 + int err = move_addr_to_kernel((void __force_user *)kern_msg->msg_name,
92516 kern_msg->msg_namelen,
92517 kern_address);
92518 if (err < 0)
92519 @@ -99,7 +99,7 @@ int verify_compat_iovec(struct msghdr *kern_msg, struct iovec *kern_iov,
92520 kern_msg->msg_name = NULL;
92521
92522 tot_len = iov_from_user_compat_to_kern(kern_iov,
92523 - (struct compat_iovec __user *)kern_msg->msg_iov,
92524 + (struct compat_iovec __force_user *)kern_msg->msg_iov,
92525 kern_msg->msg_iovlen);
92526 if (tot_len >= 0)
92527 kern_msg->msg_iov = kern_iov;
92528 @@ -119,20 +119,20 @@ int verify_compat_iovec(struct msghdr *kern_msg, struct iovec *kern_iov,
92529
92530 #define CMSG_COMPAT_FIRSTHDR(msg) \
92531 (((msg)->msg_controllen) >= sizeof(struct compat_cmsghdr) ? \
92532 - (struct compat_cmsghdr __user *)((msg)->msg_control) : \
92533 + (struct compat_cmsghdr __force_user *)((msg)->msg_control) : \
92534 (struct compat_cmsghdr __user *)NULL)
92535
92536 #define CMSG_COMPAT_OK(ucmlen, ucmsg, mhdr) \
92537 ((ucmlen) >= sizeof(struct compat_cmsghdr) && \
92538 (ucmlen) <= (unsigned long) \
92539 ((mhdr)->msg_controllen - \
92540 - ((char *)(ucmsg) - (char *)(mhdr)->msg_control)))
92541 + ((char __force_kernel *)(ucmsg) - (char *)(mhdr)->msg_control)))
92542
92543 static inline struct compat_cmsghdr __user *cmsg_compat_nxthdr(struct msghdr *msg,
92544 struct compat_cmsghdr __user *cmsg, int cmsg_len)
92545 {
92546 char __user *ptr = (char __user *)cmsg + CMSG_COMPAT_ALIGN(cmsg_len);
92547 - if ((unsigned long)(ptr + 1 - (char __user *)msg->msg_control) >
92548 + if ((unsigned long)(ptr + 1 - (char __force_user *)msg->msg_control) >
92549 msg->msg_controllen)
92550 return NULL;
92551 return (struct compat_cmsghdr __user *)ptr;
92552 @@ -222,7 +222,7 @@ Efault:
92553
92554 int put_cmsg_compat(struct msghdr *kmsg, int level, int type, int len, void *data)
92555 {
92556 - struct compat_cmsghdr __user *cm = (struct compat_cmsghdr __user *) kmsg->msg_control;
92557 + struct compat_cmsghdr __user *cm = (struct compat_cmsghdr __force_user *) kmsg->msg_control;
92558 struct compat_cmsghdr cmhdr;
92559 struct compat_timeval ctv;
92560 struct compat_timespec cts[3];
92561 @@ -278,7 +278,7 @@ int put_cmsg_compat(struct msghdr *kmsg, int level, int type, int len, void *dat
92562
92563 void scm_detach_fds_compat(struct msghdr *kmsg, struct scm_cookie *scm)
92564 {
92565 - struct compat_cmsghdr __user *cm = (struct compat_cmsghdr __user *) kmsg->msg_control;
92566 + struct compat_cmsghdr __user *cm = (struct compat_cmsghdr __force_user *) kmsg->msg_control;
92567 int fdmax = (kmsg->msg_controllen - sizeof(struct compat_cmsghdr)) / sizeof(int);
92568 int fdnum = scm->fp->count;
92569 struct file **fp = scm->fp->fp;
92570 @@ -366,7 +366,7 @@ static int do_set_sock_timeout(struct socket *sock, int level,
92571 return -EFAULT;
92572 old_fs = get_fs();
92573 set_fs(KERNEL_DS);
92574 - err = sock_setsockopt(sock, level, optname, (char *)&ktime, sizeof(ktime));
92575 + err = sock_setsockopt(sock, level, optname, (char __force_user *)&ktime, sizeof(ktime));
92576 set_fs(old_fs);
92577
92578 return err;
92579 @@ -427,7 +427,7 @@ static int do_get_sock_timeout(struct socket *sock, int level, int optname,
92580 len = sizeof(ktime);
92581 old_fs = get_fs();
92582 set_fs(KERNEL_DS);
92583 - err = sock_getsockopt(sock, level, optname, (char *) &ktime, &len);
92584 + err = sock_getsockopt(sock, level, optname, (char __force_user *) &ktime, (int __force_user *)&len);
92585 set_fs(old_fs);
92586
92587 if (!err) {
92588 @@ -570,7 +570,7 @@ int compat_mc_setsockopt(struct sock *sock, int level, int optname,
92589 case MCAST_JOIN_GROUP:
92590 case MCAST_LEAVE_GROUP:
92591 {
92592 - struct compat_group_req __user *gr32 = (void *)optval;
92593 + struct compat_group_req __user *gr32 = (void __user *)optval;
92594 struct group_req __user *kgr =
92595 compat_alloc_user_space(sizeof(struct group_req));
92596 u32 interface;
92597 @@ -591,7 +591,7 @@ int compat_mc_setsockopt(struct sock *sock, int level, int optname,
92598 case MCAST_BLOCK_SOURCE:
92599 case MCAST_UNBLOCK_SOURCE:
92600 {
92601 - struct compat_group_source_req __user *gsr32 = (void *)optval;
92602 + struct compat_group_source_req __user *gsr32 = (void __user *)optval;
92603 struct group_source_req __user *kgsr = compat_alloc_user_space(
92604 sizeof(struct group_source_req));
92605 u32 interface;
92606 @@ -612,7 +612,7 @@ int compat_mc_setsockopt(struct sock *sock, int level, int optname,
92607 }
92608 case MCAST_MSFILTER:
92609 {
92610 - struct compat_group_filter __user *gf32 = (void *)optval;
92611 + struct compat_group_filter __user *gf32 = (void __user *)optval;
92612 struct group_filter __user *kgf;
92613 u32 interface, fmode, numsrc;
92614
92615 @@ -650,7 +650,7 @@ int compat_mc_getsockopt(struct sock *sock, int level, int optname,
92616 char __user *optval, int __user *optlen,
92617 int (*getsockopt)(struct sock *, int, int, char __user *, int __user *))
92618 {
92619 - struct compat_group_filter __user *gf32 = (void *)optval;
92620 + struct compat_group_filter __user *gf32 = (void __user *)optval;
92621 struct group_filter __user *kgf;
92622 int __user *koptlen;
92623 u32 interface, fmode, numsrc;
92624 @@ -808,7 +808,7 @@ asmlinkage long compat_sys_socketcall(int call, u32 __user *args)
92625
92626 if (call < SYS_SOCKET || call > SYS_SENDMMSG)
92627 return -EINVAL;
92628 - if (copy_from_user(a, args, nas[call]))
92629 + if (nas[call] > sizeof a || copy_from_user(a, args, nas[call]))
92630 return -EFAULT;
92631 a0 = a[0];
92632 a1 = a[1];
92633 diff --git a/net/core/datagram.c b/net/core/datagram.c
92634 index af814e7..3d761de 100644
92635 --- a/net/core/datagram.c
92636 +++ b/net/core/datagram.c
92637 @@ -301,7 +301,7 @@ int skb_kill_datagram(struct sock *sk, struct sk_buff *skb, unsigned int flags)
92638 }
92639
92640 kfree_skb(skb);
92641 - atomic_inc(&sk->sk_drops);
92642 + atomic_inc_unchecked(&sk->sk_drops);
92643 sk_mem_reclaim_partial(sk);
92644
92645 return err;
92646 diff --git a/net/core/dev.c b/net/core/dev.c
92647 index 3d13874..6e78dc7 100644
92648 --- a/net/core/dev.c
92649 +++ b/net/core/dev.c
92650 @@ -1680,14 +1680,14 @@ int dev_forward_skb(struct net_device *dev, struct sk_buff *skb)
92651 {
92652 if (skb_shinfo(skb)->tx_flags & SKBTX_DEV_ZEROCOPY) {
92653 if (skb_copy_ubufs(skb, GFP_ATOMIC)) {
92654 - atomic_long_inc(&dev->rx_dropped);
92655 + atomic_long_inc_unchecked(&dev->rx_dropped);
92656 kfree_skb(skb);
92657 return NET_RX_DROP;
92658 }
92659 }
92660
92661 if (unlikely(!is_skb_forwardable(dev, skb))) {
92662 - atomic_long_inc(&dev->rx_dropped);
92663 + atomic_long_inc_unchecked(&dev->rx_dropped);
92664 kfree_skb(skb);
92665 return NET_RX_DROP;
92666 }
92667 @@ -2428,7 +2428,7 @@ static int illegal_highdma(struct net_device *dev, struct sk_buff *skb)
92668
92669 struct dev_gso_cb {
92670 void (*destructor)(struct sk_buff *skb);
92671 -};
92672 +} __no_const;
92673
92674 #define DEV_GSO_CB(skb) ((struct dev_gso_cb *)(skb)->cb)
92675
92676 @@ -3203,7 +3203,7 @@ enqueue:
92677
92678 local_irq_restore(flags);
92679
92680 - atomic_long_inc(&skb->dev->rx_dropped);
92681 + atomic_long_inc_unchecked(&skb->dev->rx_dropped);
92682 kfree_skb(skb);
92683 return NET_RX_DROP;
92684 }
92685 @@ -3275,7 +3275,7 @@ int netif_rx_ni(struct sk_buff *skb)
92686 }
92687 EXPORT_SYMBOL(netif_rx_ni);
92688
92689 -static void net_tx_action(struct softirq_action *h)
92690 +static __latent_entropy void net_tx_action(void)
92691 {
92692 struct softnet_data *sd = &__get_cpu_var(softnet_data);
92693
92694 @@ -3609,7 +3609,7 @@ ncls:
92695 ret = pt_prev->func(skb, skb->dev, pt_prev, orig_dev);
92696 } else {
92697 drop:
92698 - atomic_long_inc(&skb->dev->rx_dropped);
92699 + atomic_long_inc_unchecked(&skb->dev->rx_dropped);
92700 kfree_skb(skb);
92701 /* Jamal, now you will not able to escape explaining
92702 * me how you were going to use this. :-)
92703 @@ -4269,7 +4269,7 @@ void netif_napi_del(struct napi_struct *napi)
92704 }
92705 EXPORT_SYMBOL(netif_napi_del);
92706
92707 -static void net_rx_action(struct softirq_action *h)
92708 +static __latent_entropy void net_rx_action(void)
92709 {
92710 struct softnet_data *sd = &__get_cpu_var(softnet_data);
92711 unsigned long time_limit = jiffies + 2;
92712 @@ -5973,7 +5973,7 @@ struct rtnl_link_stats64 *dev_get_stats(struct net_device *dev,
92713 } else {
92714 netdev_stats_to_stats64(storage, &dev->stats);
92715 }
92716 - storage->rx_dropped += atomic_long_read(&dev->rx_dropped);
92717 + storage->rx_dropped += atomic_long_read_unchecked(&dev->rx_dropped);
92718 return storage;
92719 }
92720 EXPORT_SYMBOL(dev_get_stats);
92721 diff --git a/net/core/dev_ioctl.c b/net/core/dev_ioctl.c
92722 index 5b7d0e1..cb960fc 100644
92723 --- a/net/core/dev_ioctl.c
92724 +++ b/net/core/dev_ioctl.c
92725 @@ -365,9 +365,13 @@ void dev_load(struct net *net, const char *name)
92726 if (no_module && capable(CAP_NET_ADMIN))
92727 no_module = request_module("netdev-%s", name);
92728 if (no_module && capable(CAP_SYS_MODULE)) {
92729 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
92730 + ___request_module(true, "grsec_modharden_netdev", "%s", name);
92731 +#else
92732 if (!request_module("%s", name))
92733 pr_warn("Loading kernel module for a network device with CAP_SYS_MODULE (deprecated). Use CAP_NET_ADMIN and alias netdev-%s instead.\n",
92734 name);
92735 +#endif
92736 }
92737 }
92738 EXPORT_SYMBOL(dev_load);
92739 diff --git a/net/core/flow.c b/net/core/flow.c
92740 index dfa602c..3103d88 100644
92741 --- a/net/core/flow.c
92742 +++ b/net/core/flow.c
92743 @@ -61,7 +61,7 @@ struct flow_cache {
92744 struct timer_list rnd_timer;
92745 };
92746
92747 -atomic_t flow_cache_genid = ATOMIC_INIT(0);
92748 +atomic_unchecked_t flow_cache_genid = ATOMIC_INIT(0);
92749 EXPORT_SYMBOL(flow_cache_genid);
92750 static struct flow_cache flow_cache_global;
92751 static struct kmem_cache *flow_cachep __read_mostly;
92752 @@ -86,7 +86,7 @@ static void flow_cache_new_hashrnd(unsigned long arg)
92753
92754 static int flow_entry_valid(struct flow_cache_entry *fle)
92755 {
92756 - if (atomic_read(&flow_cache_genid) != fle->genid)
92757 + if (atomic_read_unchecked(&flow_cache_genid) != fle->genid)
92758 return 0;
92759 if (fle->object && !fle->object->ops->check(fle->object))
92760 return 0;
92761 @@ -258,7 +258,7 @@ flow_cache_lookup(struct net *net, const struct flowi *key, u16 family, u8 dir,
92762 hlist_add_head(&fle->u.hlist, &fcp->hash_table[hash]);
92763 fcp->hash_count++;
92764 }
92765 - } else if (likely(fle->genid == atomic_read(&flow_cache_genid))) {
92766 + } else if (likely(fle->genid == atomic_read_unchecked(&flow_cache_genid))) {
92767 flo = fle->object;
92768 if (!flo)
92769 goto ret_object;
92770 @@ -279,7 +279,7 @@ nocache:
92771 }
92772 flo = resolver(net, key, family, dir, flo, ctx);
92773 if (fle) {
92774 - fle->genid = atomic_read(&flow_cache_genid);
92775 + fle->genid = atomic_read_unchecked(&flow_cache_genid);
92776 if (!IS_ERR(flo))
92777 fle->object = flo;
92778 else
92779 diff --git a/net/core/iovec.c b/net/core/iovec.c
92780 index 7d84ea1..55385ae 100644
92781 --- a/net/core/iovec.c
92782 +++ b/net/core/iovec.c
92783 @@ -42,7 +42,7 @@ int verify_iovec(struct msghdr *m, struct iovec *iov, struct sockaddr_storage *a
92784 if (m->msg_namelen) {
92785 if (mode == VERIFY_READ) {
92786 void __user *namep;
92787 - namep = (void __user __force *) m->msg_name;
92788 + namep = (void __force_user *) m->msg_name;
92789 err = move_addr_to_kernel(namep, m->msg_namelen,
92790 address);
92791 if (err < 0)
92792 @@ -55,7 +55,7 @@ int verify_iovec(struct msghdr *m, struct iovec *iov, struct sockaddr_storage *a
92793 }
92794
92795 size = m->msg_iovlen * sizeof(struct iovec);
92796 - if (copy_from_user(iov, (void __user __force *) m->msg_iov, size))
92797 + if (copy_from_user(iov, (void __force_user *) m->msg_iov, size))
92798 return -EFAULT;
92799
92800 m->msg_iov = iov;
92801 diff --git a/net/core/neighbour.c b/net/core/neighbour.c
92802 index 6072610..7374c18 100644
92803 --- a/net/core/neighbour.c
92804 +++ b/net/core/neighbour.c
92805 @@ -2774,7 +2774,7 @@ static int proc_unres_qlen(struct ctl_table *ctl, int write,
92806 void __user *buffer, size_t *lenp, loff_t *ppos)
92807 {
92808 int size, ret;
92809 - struct ctl_table tmp = *ctl;
92810 + ctl_table_no_const tmp = *ctl;
92811
92812 tmp.extra1 = &zero;
92813 tmp.extra2 = &unres_qlen_max;
92814 diff --git a/net/core/net-procfs.c b/net/core/net-procfs.c
92815 index 2bf8329..7960607 100644
92816 --- a/net/core/net-procfs.c
92817 +++ b/net/core/net-procfs.c
92818 @@ -283,8 +283,13 @@ static int ptype_seq_show(struct seq_file *seq, void *v)
92819 else
92820 seq_printf(seq, "%04x", ntohs(pt->type));
92821
92822 +#ifdef CONFIG_GRKERNSEC_HIDESYM
92823 + seq_printf(seq, " %-8s %pf\n",
92824 + pt->dev ? pt->dev->name : "", NULL);
92825 +#else
92826 seq_printf(seq, " %-8s %pf\n",
92827 pt->dev ? pt->dev->name : "", pt->func);
92828 +#endif
92829 }
92830
92831 return 0;
92832 diff --git a/net/core/net-sysfs.c b/net/core/net-sysfs.c
92833 index d954b56..b0a0f7a 100644
92834 --- a/net/core/net-sysfs.c
92835 +++ b/net/core/net-sysfs.c
92836 @@ -1356,7 +1356,7 @@ void netdev_class_remove_file(struct class_attribute *class_attr)
92837 }
92838 EXPORT_SYMBOL(netdev_class_remove_file);
92839
92840 -int netdev_kobject_init(void)
92841 +int __init netdev_kobject_init(void)
92842 {
92843 kobj_ns_type_register(&net_ns_type_operations);
92844 return class_register(&net_class);
92845 diff --git a/net/core/net_namespace.c b/net/core/net_namespace.c
92846 index 81d3a9a..a0bd7a8 100644
92847 --- a/net/core/net_namespace.c
92848 +++ b/net/core/net_namespace.c
92849 @@ -443,7 +443,7 @@ static int __register_pernet_operations(struct list_head *list,
92850 int error;
92851 LIST_HEAD(net_exit_list);
92852
92853 - list_add_tail(&ops->list, list);
92854 + pax_list_add_tail((struct list_head *)&ops->list, list);
92855 if (ops->init || (ops->id && ops->size)) {
92856 for_each_net(net) {
92857 error = ops_init(ops, net);
92858 @@ -456,7 +456,7 @@ static int __register_pernet_operations(struct list_head *list,
92859
92860 out_undo:
92861 /* If I have an error cleanup all namespaces I initialized */
92862 - list_del(&ops->list);
92863 + pax_list_del((struct list_head *)&ops->list);
92864 ops_exit_list(ops, &net_exit_list);
92865 ops_free_list(ops, &net_exit_list);
92866 return error;
92867 @@ -467,7 +467,7 @@ static void __unregister_pernet_operations(struct pernet_operations *ops)
92868 struct net *net;
92869 LIST_HEAD(net_exit_list);
92870
92871 - list_del(&ops->list);
92872 + pax_list_del((struct list_head *)&ops->list);
92873 for_each_net(net)
92874 list_add_tail(&net->exit_list, &net_exit_list);
92875 ops_exit_list(ops, &net_exit_list);
92876 @@ -601,7 +601,7 @@ int register_pernet_device(struct pernet_operations *ops)
92877 mutex_lock(&net_mutex);
92878 error = register_pernet_operations(&pernet_list, ops);
92879 if (!error && (first_device == &pernet_list))
92880 - first_device = &ops->list;
92881 + first_device = (struct list_head *)&ops->list;
92882 mutex_unlock(&net_mutex);
92883 return error;
92884 }
92885 diff --git a/net/core/netpoll.c b/net/core/netpoll.c
92886 index fc75c9e..8c8e9be 100644
92887 --- a/net/core/netpoll.c
92888 +++ b/net/core/netpoll.c
92889 @@ -428,7 +428,7 @@ void netpoll_send_udp(struct netpoll *np, const char *msg, int len)
92890 struct udphdr *udph;
92891 struct iphdr *iph;
92892 struct ethhdr *eth;
92893 - static atomic_t ip_ident;
92894 + static atomic_unchecked_t ip_ident;
92895 struct ipv6hdr *ip6h;
92896
92897 udp_len = len + sizeof(*udph);
92898 @@ -499,7 +499,7 @@ void netpoll_send_udp(struct netpoll *np, const char *msg, int len)
92899 put_unaligned(0x45, (unsigned char *)iph);
92900 iph->tos = 0;
92901 put_unaligned(htons(ip_len), &(iph->tot_len));
92902 - iph->id = htons(atomic_inc_return(&ip_ident));
92903 + iph->id = htons(atomic_inc_return_unchecked(&ip_ident));
92904 iph->frag_off = 0;
92905 iph->ttl = 64;
92906 iph->protocol = IPPROTO_UDP;
92907 diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c
92908 index 2a0e21d..6ad7642 100644
92909 --- a/net/core/rtnetlink.c
92910 +++ b/net/core/rtnetlink.c
92911 @@ -58,7 +58,7 @@ struct rtnl_link {
92912 rtnl_doit_func doit;
92913 rtnl_dumpit_func dumpit;
92914 rtnl_calcit_func calcit;
92915 -};
92916 +} __no_const;
92917
92918 static DEFINE_MUTEX(rtnl_mutex);
92919
92920 @@ -299,10 +299,13 @@ int __rtnl_link_register(struct rtnl_link_ops *ops)
92921 if (rtnl_link_ops_get(ops->kind))
92922 return -EEXIST;
92923
92924 - if (!ops->dellink)
92925 - ops->dellink = unregister_netdevice_queue;
92926 + if (!ops->dellink) {
92927 + pax_open_kernel();
92928 + *(void **)&ops->dellink = unregister_netdevice_queue;
92929 + pax_close_kernel();
92930 + }
92931
92932 - list_add_tail(&ops->list, &link_ops);
92933 + pax_list_add_tail((struct list_head *)&ops->list, &link_ops);
92934 return 0;
92935 }
92936 EXPORT_SYMBOL_GPL(__rtnl_link_register);
92937 @@ -349,7 +352,7 @@ void __rtnl_link_unregister(struct rtnl_link_ops *ops)
92938 for_each_net(net) {
92939 __rtnl_kill_links(net, ops);
92940 }
92941 - list_del(&ops->list);
92942 + pax_list_del((struct list_head *)&ops->list);
92943 }
92944 EXPORT_SYMBOL_GPL(__rtnl_link_unregister);
92945
92946 diff --git a/net/core/scm.c b/net/core/scm.c
92947 index b442e7e..6f5b5a2 100644
92948 --- a/net/core/scm.c
92949 +++ b/net/core/scm.c
92950 @@ -210,7 +210,7 @@ EXPORT_SYMBOL(__scm_send);
92951 int put_cmsg(struct msghdr * msg, int level, int type, int len, void *data)
92952 {
92953 struct cmsghdr __user *cm
92954 - = (__force struct cmsghdr __user *)msg->msg_control;
92955 + = (struct cmsghdr __force_user *)msg->msg_control;
92956 struct cmsghdr cmhdr;
92957 int cmlen = CMSG_LEN(len);
92958 int err;
92959 @@ -233,7 +233,7 @@ int put_cmsg(struct msghdr * msg, int level, int type, int len, void *data)
92960 err = -EFAULT;
92961 if (copy_to_user(cm, &cmhdr, sizeof cmhdr))
92962 goto out;
92963 - if (copy_to_user(CMSG_DATA(cm), data, cmlen - sizeof(struct cmsghdr)))
92964 + if (copy_to_user((void __force_user *)CMSG_DATA((void __force_kernel *)cm), data, cmlen - sizeof(struct cmsghdr)))
92965 goto out;
92966 cmlen = CMSG_SPACE(len);
92967 if (msg->msg_controllen < cmlen)
92968 @@ -249,7 +249,7 @@ EXPORT_SYMBOL(put_cmsg);
92969 void scm_detach_fds(struct msghdr *msg, struct scm_cookie *scm)
92970 {
92971 struct cmsghdr __user *cm
92972 - = (__force struct cmsghdr __user*)msg->msg_control;
92973 + = (struct cmsghdr __force_user *)msg->msg_control;
92974
92975 int fdmax = 0;
92976 int fdnum = scm->fp->count;
92977 @@ -269,7 +269,7 @@ void scm_detach_fds(struct msghdr *msg, struct scm_cookie *scm)
92978 if (fdnum < fdmax)
92979 fdmax = fdnum;
92980
92981 - for (i=0, cmfptr=(__force int __user *)CMSG_DATA(cm); i<fdmax;
92982 + for (i=0, cmfptr=(int __force_user *)CMSG_DATA((void __force_kernel *)cm); i<fdmax;
92983 i++, cmfptr++)
92984 {
92985 struct socket *sock;
92986 diff --git a/net/core/skbuff.c b/net/core/skbuff.c
92987 index c28c7fe..a399a6d 100644
92988 --- a/net/core/skbuff.c
92989 +++ b/net/core/skbuff.c
92990 @@ -3104,13 +3104,15 @@ void __init skb_init(void)
92991 skbuff_head_cache = kmem_cache_create("skbuff_head_cache",
92992 sizeof(struct sk_buff),
92993 0,
92994 - SLAB_HWCACHE_ALIGN|SLAB_PANIC,
92995 + SLAB_HWCACHE_ALIGN|SLAB_PANIC|
92996 + SLAB_NO_SANITIZE,
92997 NULL);
92998 skbuff_fclone_cache = kmem_cache_create("skbuff_fclone_cache",
92999 (2*sizeof(struct sk_buff)) +
93000 sizeof(atomic_t),
93001 0,
93002 - SLAB_HWCACHE_ALIGN|SLAB_PANIC,
93003 + SLAB_HWCACHE_ALIGN|SLAB_PANIC|
93004 + SLAB_NO_SANITIZE,
93005 NULL);
93006 }
93007
93008 @@ -3541,6 +3543,7 @@ void skb_scrub_packet(struct sk_buff *skb, bool xnet)
93009 skb->tstamp.tv64 = 0;
93010 skb->pkt_type = PACKET_HOST;
93011 skb->skb_iif = 0;
93012 + skb->local_df = 0;
93013 skb_dst_drop(skb);
93014 skb->mark = 0;
93015 secpath_reset(skb);
93016 diff --git a/net/core/sock.c b/net/core/sock.c
93017 index 0b39e7a..5e9f91e 100644
93018 --- a/net/core/sock.c
93019 +++ b/net/core/sock.c
93020 @@ -393,7 +393,7 @@ int sock_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
93021 struct sk_buff_head *list = &sk->sk_receive_queue;
93022
93023 if (atomic_read(&sk->sk_rmem_alloc) >= sk->sk_rcvbuf) {
93024 - atomic_inc(&sk->sk_drops);
93025 + atomic_inc_unchecked(&sk->sk_drops);
93026 trace_sock_rcvqueue_full(sk, skb);
93027 return -ENOMEM;
93028 }
93029 @@ -403,7 +403,7 @@ int sock_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
93030 return err;
93031
93032 if (!sk_rmem_schedule(sk, skb, skb->truesize)) {
93033 - atomic_inc(&sk->sk_drops);
93034 + atomic_inc_unchecked(&sk->sk_drops);
93035 return -ENOBUFS;
93036 }
93037
93038 @@ -423,7 +423,7 @@ int sock_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
93039 skb_dst_force(skb);
93040
93041 spin_lock_irqsave(&list->lock, flags);
93042 - skb->dropcount = atomic_read(&sk->sk_drops);
93043 + skb->dropcount = atomic_read_unchecked(&sk->sk_drops);
93044 __skb_queue_tail(list, skb);
93045 spin_unlock_irqrestore(&list->lock, flags);
93046
93047 @@ -443,7 +443,7 @@ int sk_receive_skb(struct sock *sk, struct sk_buff *skb, const int nested)
93048 skb->dev = NULL;
93049
93050 if (sk_rcvqueues_full(sk, skb, sk->sk_rcvbuf)) {
93051 - atomic_inc(&sk->sk_drops);
93052 + atomic_inc_unchecked(&sk->sk_drops);
93053 goto discard_and_relse;
93054 }
93055 if (nested)
93056 @@ -461,7 +461,7 @@ int sk_receive_skb(struct sock *sk, struct sk_buff *skb, const int nested)
93057 mutex_release(&sk->sk_lock.dep_map, 1, _RET_IP_);
93058 } else if (sk_add_backlog(sk, skb, sk->sk_rcvbuf)) {
93059 bh_unlock_sock(sk);
93060 - atomic_inc(&sk->sk_drops);
93061 + atomic_inc_unchecked(&sk->sk_drops);
93062 goto discard_and_relse;
93063 }
93064
93065 @@ -949,12 +949,12 @@ int sock_getsockopt(struct socket *sock, int level, int optname,
93066 struct timeval tm;
93067 } v;
93068
93069 - int lv = sizeof(int);
93070 - int len;
93071 + unsigned int lv = sizeof(int);
93072 + unsigned int len;
93073
93074 if (get_user(len, optlen))
93075 return -EFAULT;
93076 - if (len < 0)
93077 + if (len > INT_MAX)
93078 return -EINVAL;
93079
93080 memset(&v, 0, sizeof(v));
93081 @@ -1106,11 +1106,11 @@ int sock_getsockopt(struct socket *sock, int level, int optname,
93082
93083 case SO_PEERNAME:
93084 {
93085 - char address[128];
93086 + char address[_K_SS_MAXSIZE];
93087
93088 if (sock->ops->getname(sock, (struct sockaddr *)address, &lv, 2))
93089 return -ENOTCONN;
93090 - if (lv < len)
93091 + if (lv < len || sizeof address < len)
93092 return -EINVAL;
93093 if (copy_to_user(optval, address, len))
93094 return -EFAULT;
93095 @@ -1183,7 +1183,7 @@ int sock_getsockopt(struct socket *sock, int level, int optname,
93096
93097 if (len > lv)
93098 len = lv;
93099 - if (copy_to_user(optval, &v, len))
93100 + if (len > sizeof(v) || copy_to_user(optval, &v, len))
93101 return -EFAULT;
93102 lenout:
93103 if (put_user(len, optlen))
93104 @@ -2326,7 +2326,7 @@ void sock_init_data(struct socket *sock, struct sock *sk)
93105 */
93106 smp_wmb();
93107 atomic_set(&sk->sk_refcnt, 1);
93108 - atomic_set(&sk->sk_drops, 0);
93109 + atomic_set_unchecked(&sk->sk_drops, 0);
93110 }
93111 EXPORT_SYMBOL(sock_init_data);
93112
93113 @@ -2451,6 +2451,7 @@ void sock_enable_timestamp(struct sock *sk, int flag)
93114 int sock_recv_errqueue(struct sock *sk, struct msghdr *msg, int len,
93115 int level, int type)
93116 {
93117 + struct sock_extended_err ee;
93118 struct sock_exterr_skb *serr;
93119 struct sk_buff *skb, *skb2;
93120 int copied, err;
93121 @@ -2472,7 +2473,8 @@ int sock_recv_errqueue(struct sock *sk, struct msghdr *msg, int len,
93122 sock_recv_timestamp(msg, sk, skb);
93123
93124 serr = SKB_EXT_ERR(skb);
93125 - put_cmsg(msg, level, type, sizeof(serr->ee), &serr->ee);
93126 + ee = serr->ee;
93127 + put_cmsg(msg, level, type, sizeof ee, &ee);
93128
93129 msg->msg_flags |= MSG_ERRQUEUE;
93130 err = copied;
93131 diff --git a/net/core/sock_diag.c b/net/core/sock_diag.c
93132 index a0e9cf6..ef7f9ed 100644
93133 --- a/net/core/sock_diag.c
93134 +++ b/net/core/sock_diag.c
93135 @@ -9,26 +9,33 @@
93136 #include <linux/inet_diag.h>
93137 #include <linux/sock_diag.h>
93138
93139 -static const struct sock_diag_handler *sock_diag_handlers[AF_MAX];
93140 +static const struct sock_diag_handler *sock_diag_handlers[AF_MAX] __read_only;
93141 static int (*inet_rcv_compat)(struct sk_buff *skb, struct nlmsghdr *nlh);
93142 static DEFINE_MUTEX(sock_diag_table_mutex);
93143
93144 int sock_diag_check_cookie(void *sk, __u32 *cookie)
93145 {
93146 +#ifndef CONFIG_GRKERNSEC_HIDESYM
93147 if ((cookie[0] != INET_DIAG_NOCOOKIE ||
93148 cookie[1] != INET_DIAG_NOCOOKIE) &&
93149 ((u32)(unsigned long)sk != cookie[0] ||
93150 (u32)((((unsigned long)sk) >> 31) >> 1) != cookie[1]))
93151 return -ESTALE;
93152 else
93153 +#endif
93154 return 0;
93155 }
93156 EXPORT_SYMBOL_GPL(sock_diag_check_cookie);
93157
93158 void sock_diag_save_cookie(void *sk, __u32 *cookie)
93159 {
93160 +#ifdef CONFIG_GRKERNSEC_HIDESYM
93161 + cookie[0] = 0;
93162 + cookie[1] = 0;
93163 +#else
93164 cookie[0] = (u32)(unsigned long)sk;
93165 cookie[1] = (u32)(((unsigned long)sk >> 31) >> 1);
93166 +#endif
93167 }
93168 EXPORT_SYMBOL_GPL(sock_diag_save_cookie);
93169
93170 @@ -113,8 +120,11 @@ int sock_diag_register(const struct sock_diag_handler *hndl)
93171 mutex_lock(&sock_diag_table_mutex);
93172 if (sock_diag_handlers[hndl->family])
93173 err = -EBUSY;
93174 - else
93175 + else {
93176 + pax_open_kernel();
93177 sock_diag_handlers[hndl->family] = hndl;
93178 + pax_close_kernel();
93179 + }
93180 mutex_unlock(&sock_diag_table_mutex);
93181
93182 return err;
93183 @@ -130,7 +140,9 @@ void sock_diag_unregister(const struct sock_diag_handler *hnld)
93184
93185 mutex_lock(&sock_diag_table_mutex);
93186 BUG_ON(sock_diag_handlers[family] != hnld);
93187 + pax_open_kernel();
93188 sock_diag_handlers[family] = NULL;
93189 + pax_close_kernel();
93190 mutex_unlock(&sock_diag_table_mutex);
93191 }
93192 EXPORT_SYMBOL_GPL(sock_diag_unregister);
93193 diff --git a/net/core/sysctl_net_core.c b/net/core/sysctl_net_core.c
93194 index cca4441..5e616de 100644
93195 --- a/net/core/sysctl_net_core.c
93196 +++ b/net/core/sysctl_net_core.c
93197 @@ -32,7 +32,7 @@ static int rps_sock_flow_sysctl(struct ctl_table *table, int write,
93198 {
93199 unsigned int orig_size, size;
93200 int ret, i;
93201 - struct ctl_table tmp = {
93202 + ctl_table_no_const tmp = {
93203 .data = &size,
93204 .maxlen = sizeof(size),
93205 .mode = table->mode
93206 @@ -199,7 +199,7 @@ static int set_default_qdisc(struct ctl_table *table, int write,
93207 void __user *buffer, size_t *lenp, loff_t *ppos)
93208 {
93209 char id[IFNAMSIZ];
93210 - struct ctl_table tbl = {
93211 + ctl_table_no_const tbl = {
93212 .data = id,
93213 .maxlen = IFNAMSIZ,
93214 };
93215 @@ -378,13 +378,12 @@ static struct ctl_table netns_core_table[] = {
93216
93217 static __net_init int sysctl_core_net_init(struct net *net)
93218 {
93219 - struct ctl_table *tbl;
93220 + ctl_table_no_const *tbl = NULL;
93221
93222 net->core.sysctl_somaxconn = SOMAXCONN;
93223
93224 - tbl = netns_core_table;
93225 if (!net_eq(net, &init_net)) {
93226 - tbl = kmemdup(tbl, sizeof(netns_core_table), GFP_KERNEL);
93227 + tbl = kmemdup(netns_core_table, sizeof(netns_core_table), GFP_KERNEL);
93228 if (tbl == NULL)
93229 goto err_dup;
93230
93231 @@ -394,17 +393,16 @@ static __net_init int sysctl_core_net_init(struct net *net)
93232 if (net->user_ns != &init_user_ns) {
93233 tbl[0].procname = NULL;
93234 }
93235 - }
93236 -
93237 - net->core.sysctl_hdr = register_net_sysctl(net, "net/core", tbl);
93238 + net->core.sysctl_hdr = register_net_sysctl(net, "net/core", tbl);
93239 + } else
93240 + net->core.sysctl_hdr = register_net_sysctl(net, "net/core", netns_core_table);
93241 if (net->core.sysctl_hdr == NULL)
93242 goto err_reg;
93243
93244 return 0;
93245
93246 err_reg:
93247 - if (tbl != netns_core_table)
93248 - kfree(tbl);
93249 + kfree(tbl);
93250 err_dup:
93251 return -ENOMEM;
93252 }
93253 @@ -419,7 +417,7 @@ static __net_exit void sysctl_core_net_exit(struct net *net)
93254 kfree(tbl);
93255 }
93256
93257 -static __net_initdata struct pernet_operations sysctl_core_ops = {
93258 +static __net_initconst struct pernet_operations sysctl_core_ops = {
93259 .init = sysctl_core_net_init,
93260 .exit = sysctl_core_net_exit,
93261 };
93262 diff --git a/net/decnet/af_decnet.c b/net/decnet/af_decnet.c
93263 index dd4d506..fb2fb87 100644
93264 --- a/net/decnet/af_decnet.c
93265 +++ b/net/decnet/af_decnet.c
93266 @@ -465,6 +465,7 @@ static struct proto dn_proto = {
93267 .sysctl_rmem = sysctl_decnet_rmem,
93268 .max_header = DN_MAX_NSP_DATA_HEADER + 64,
93269 .obj_size = sizeof(struct dn_sock),
93270 + .slab_flags = SLAB_USERCOPY,
93271 };
93272
93273 static struct sock *dn_alloc_sock(struct net *net, struct socket *sock, gfp_t gfp)
93274 diff --git a/net/decnet/sysctl_net_decnet.c b/net/decnet/sysctl_net_decnet.c
93275 index 5325b54..a0d4d69 100644
93276 --- a/net/decnet/sysctl_net_decnet.c
93277 +++ b/net/decnet/sysctl_net_decnet.c
93278 @@ -174,7 +174,7 @@ static int dn_node_address_handler(struct ctl_table *table, int write,
93279
93280 if (len > *lenp) len = *lenp;
93281
93282 - if (copy_to_user(buffer, addr, len))
93283 + if (len > sizeof addr || copy_to_user(buffer, addr, len))
93284 return -EFAULT;
93285
93286 *lenp = len;
93287 @@ -237,7 +237,7 @@ static int dn_def_dev_handler(struct ctl_table *table, int write,
93288
93289 if (len > *lenp) len = *lenp;
93290
93291 - if (copy_to_user(buffer, devname, len))
93292 + if (len > sizeof devname || copy_to_user(buffer, devname, len))
93293 return -EFAULT;
93294
93295 *lenp = len;
93296 diff --git a/net/ieee802154/6lowpan.c b/net/ieee802154/6lowpan.c
93297 index 008f337..b03b8c9 100644
93298 --- a/net/ieee802154/6lowpan.c
93299 +++ b/net/ieee802154/6lowpan.c
93300 @@ -548,7 +548,7 @@ static int lowpan_header_create(struct sk_buff *skb,
93301 hc06_ptr += 3;
93302 } else {
93303 /* compress nothing */
93304 - memcpy(hc06_ptr, &hdr, 4);
93305 + memcpy(hc06_ptr, hdr, 4);
93306 /* replace the top byte with new ECN | DSCP format */
93307 *hc06_ptr = tmp;
93308 hc06_ptr += 4;
93309 diff --git a/net/ipv4/af_inet.c b/net/ipv4/af_inet.c
93310 index cfeb85c..385989a 100644
93311 --- a/net/ipv4/af_inet.c
93312 +++ b/net/ipv4/af_inet.c
93313 @@ -1675,13 +1675,9 @@ static int __init inet_init(void)
93314
93315 BUILD_BUG_ON(sizeof(struct inet_skb_parm) > FIELD_SIZEOF(struct sk_buff, cb));
93316
93317 - sysctl_local_reserved_ports = kzalloc(65536 / 8, GFP_KERNEL);
93318 - if (!sysctl_local_reserved_ports)
93319 - goto out;
93320 -
93321 rc = proto_register(&tcp_prot, 1);
93322 if (rc)
93323 - goto out_free_reserved_ports;
93324 + goto out;
93325
93326 rc = proto_register(&udp_prot, 1);
93327 if (rc)
93328 @@ -1790,8 +1786,6 @@ out_unregister_udp_proto:
93329 proto_unregister(&udp_prot);
93330 out_unregister_tcp_proto:
93331 proto_unregister(&tcp_prot);
93332 -out_free_reserved_ports:
93333 - kfree(sysctl_local_reserved_ports);
93334 goto out;
93335 }
93336
93337 diff --git a/net/ipv4/devinet.c b/net/ipv4/devinet.c
93338 index a1b5bcb..62ec5c6 100644
93339 --- a/net/ipv4/devinet.c
93340 +++ b/net/ipv4/devinet.c
93341 @@ -1533,7 +1533,7 @@ static int inet_dump_ifaddr(struct sk_buff *skb, struct netlink_callback *cb)
93342 idx = 0;
93343 head = &net->dev_index_head[h];
93344 rcu_read_lock();
93345 - cb->seq = atomic_read(&net->ipv4.dev_addr_genid) ^
93346 + cb->seq = atomic_read_unchecked(&net->ipv4.dev_addr_genid) ^
93347 net->dev_base_seq;
93348 hlist_for_each_entry_rcu(dev, head, index_hlist) {
93349 if (idx < s_idx)
93350 @@ -1844,7 +1844,7 @@ static int inet_netconf_dump_devconf(struct sk_buff *skb,
93351 idx = 0;
93352 head = &net->dev_index_head[h];
93353 rcu_read_lock();
93354 - cb->seq = atomic_read(&net->ipv4.dev_addr_genid) ^
93355 + cb->seq = atomic_read_unchecked(&net->ipv4.dev_addr_genid) ^
93356 net->dev_base_seq;
93357 hlist_for_each_entry_rcu(dev, head, index_hlist) {
93358 if (idx < s_idx)
93359 @@ -2069,7 +2069,7 @@ static int ipv4_doint_and_flush(struct ctl_table *ctl, int write,
93360 #define DEVINET_SYSCTL_FLUSHING_ENTRY(attr, name) \
93361 DEVINET_SYSCTL_COMPLEX_ENTRY(attr, name, ipv4_doint_and_flush)
93362
93363 -static struct devinet_sysctl_table {
93364 +static const struct devinet_sysctl_table {
93365 struct ctl_table_header *sysctl_header;
93366 struct ctl_table devinet_vars[__IPV4_DEVCONF_MAX];
93367 } devinet_sysctl = {
93368 @@ -2191,7 +2191,7 @@ static __net_init int devinet_init_net(struct net *net)
93369 int err;
93370 struct ipv4_devconf *all, *dflt;
93371 #ifdef CONFIG_SYSCTL
93372 - struct ctl_table *tbl = ctl_forward_entry;
93373 + ctl_table_no_const *tbl = NULL;
93374 struct ctl_table_header *forw_hdr;
93375 #endif
93376
93377 @@ -2209,7 +2209,7 @@ static __net_init int devinet_init_net(struct net *net)
93378 goto err_alloc_dflt;
93379
93380 #ifdef CONFIG_SYSCTL
93381 - tbl = kmemdup(tbl, sizeof(ctl_forward_entry), GFP_KERNEL);
93382 + tbl = kmemdup(ctl_forward_entry, sizeof(ctl_forward_entry), GFP_KERNEL);
93383 if (tbl == NULL)
93384 goto err_alloc_ctl;
93385
93386 @@ -2229,7 +2229,10 @@ static __net_init int devinet_init_net(struct net *net)
93387 goto err_reg_dflt;
93388
93389 err = -ENOMEM;
93390 - forw_hdr = register_net_sysctl(net, "net/ipv4", tbl);
93391 + if (!net_eq(net, &init_net))
93392 + forw_hdr = register_net_sysctl(net, "net/ipv4", tbl);
93393 + else
93394 + forw_hdr = register_net_sysctl(net, "net/ipv4", ctl_forward_entry);
93395 if (forw_hdr == NULL)
93396 goto err_reg_ctl;
93397 net->ipv4.forw_hdr = forw_hdr;
93398 @@ -2245,8 +2248,7 @@ err_reg_ctl:
93399 err_reg_dflt:
93400 __devinet_sysctl_unregister(all);
93401 err_reg_all:
93402 - if (tbl != ctl_forward_entry)
93403 - kfree(tbl);
93404 + kfree(tbl);
93405 err_alloc_ctl:
93406 #endif
93407 if (dflt != &ipv4_devconf_dflt)
93408 diff --git a/net/ipv4/fib_frontend.c b/net/ipv4/fib_frontend.c
93409 index b3f627a..b0f3e99 100644
93410 --- a/net/ipv4/fib_frontend.c
93411 +++ b/net/ipv4/fib_frontend.c
93412 @@ -1017,12 +1017,12 @@ static int fib_inetaddr_event(struct notifier_block *this, unsigned long event,
93413 #ifdef CONFIG_IP_ROUTE_MULTIPATH
93414 fib_sync_up(dev);
93415 #endif
93416 - atomic_inc(&net->ipv4.dev_addr_genid);
93417 + atomic_inc_unchecked(&net->ipv4.dev_addr_genid);
93418 rt_cache_flush(dev_net(dev));
93419 break;
93420 case NETDEV_DOWN:
93421 fib_del_ifaddr(ifa, NULL);
93422 - atomic_inc(&net->ipv4.dev_addr_genid);
93423 + atomic_inc_unchecked(&net->ipv4.dev_addr_genid);
93424 if (ifa->ifa_dev->ifa_list == NULL) {
93425 /* Last address was deleted from this interface.
93426 * Disable IP.
93427 @@ -1058,7 +1058,7 @@ static int fib_netdev_event(struct notifier_block *this, unsigned long event, vo
93428 #ifdef CONFIG_IP_ROUTE_MULTIPATH
93429 fib_sync_up(dev);
93430 #endif
93431 - atomic_inc(&net->ipv4.dev_addr_genid);
93432 + atomic_inc_unchecked(&net->ipv4.dev_addr_genid);
93433 rt_cache_flush(net);
93434 break;
93435 case NETDEV_DOWN:
93436 diff --git a/net/ipv4/fib_semantics.c b/net/ipv4/fib_semantics.c
93437 index d5dbca5..6251d5f 100644
93438 --- a/net/ipv4/fib_semantics.c
93439 +++ b/net/ipv4/fib_semantics.c
93440 @@ -766,7 +766,7 @@ __be32 fib_info_update_nh_saddr(struct net *net, struct fib_nh *nh)
93441 nh->nh_saddr = inet_select_addr(nh->nh_dev,
93442 nh->nh_gw,
93443 nh->nh_parent->fib_scope);
93444 - nh->nh_saddr_genid = atomic_read(&net->ipv4.dev_addr_genid);
93445 + nh->nh_saddr_genid = atomic_read_unchecked(&net->ipv4.dev_addr_genid);
93446
93447 return nh->nh_saddr;
93448 }
93449 diff --git a/net/ipv4/inet_connection_sock.c b/net/ipv4/inet_connection_sock.c
93450 index 6acb541..9ea617d 100644
93451 --- a/net/ipv4/inet_connection_sock.c
93452 +++ b/net/ipv4/inet_connection_sock.c
93453 @@ -37,7 +37,7 @@ struct local_ports sysctl_local_ports __read_mostly = {
93454 .range = { 32768, 61000 },
93455 };
93456
93457 -unsigned long *sysctl_local_reserved_ports;
93458 +unsigned long sysctl_local_reserved_ports[65536 / 8 / sizeof(unsigned long)];
93459 EXPORT_SYMBOL(sysctl_local_reserved_ports);
93460
93461 void inet_get_local_port_range(int *low, int *high)
93462 diff --git a/net/ipv4/inet_hashtables.c b/net/ipv4/inet_hashtables.c
93463 index 96da9c7..b956690 100644
93464 --- a/net/ipv4/inet_hashtables.c
93465 +++ b/net/ipv4/inet_hashtables.c
93466 @@ -18,12 +18,15 @@
93467 #include <linux/sched.h>
93468 #include <linux/slab.h>
93469 #include <linux/wait.h>
93470 +#include <linux/security.h>
93471
93472 #include <net/inet_connection_sock.h>
93473 #include <net/inet_hashtables.h>
93474 #include <net/secure_seq.h>
93475 #include <net/ip.h>
93476
93477 +extern void gr_update_task_in_ip_table(struct task_struct *task, const struct inet_sock *inet);
93478 +
93479 /*
93480 * Allocate and initialize a new local port bind bucket.
93481 * The bindhash mutex for snum's hash chain must be held here.
93482 @@ -554,6 +557,8 @@ ok:
93483 twrefcnt += inet_twsk_bind_unhash(tw, hinfo);
93484 spin_unlock(&head->lock);
93485
93486 + gr_update_task_in_ip_table(current, inet_sk(sk));
93487 +
93488 if (tw) {
93489 inet_twsk_deschedule(tw, death_row);
93490 while (twrefcnt) {
93491 diff --git a/net/ipv4/inetpeer.c b/net/ipv4/inetpeer.c
93492 index 33d5537..da337a4 100644
93493 --- a/net/ipv4/inetpeer.c
93494 +++ b/net/ipv4/inetpeer.c
93495 @@ -503,8 +503,8 @@ relookup:
93496 if (p) {
93497 p->daddr = *daddr;
93498 atomic_set(&p->refcnt, 1);
93499 - atomic_set(&p->rid, 0);
93500 - atomic_set(&p->ip_id_count,
93501 + atomic_set_unchecked(&p->rid, 0);
93502 + atomic_set_unchecked(&p->ip_id_count,
93503 (daddr->family == AF_INET) ?
93504 secure_ip_id(daddr->addr.a4) :
93505 secure_ipv6_id(daddr->addr.a6));
93506 diff --git a/net/ipv4/ip_fragment.c b/net/ipv4/ip_fragment.c
93507 index b66910a..cfe416e 100644
93508 --- a/net/ipv4/ip_fragment.c
93509 +++ b/net/ipv4/ip_fragment.c
93510 @@ -282,7 +282,7 @@ static inline int ip_frag_too_far(struct ipq *qp)
93511 return 0;
93512
93513 start = qp->rid;
93514 - end = atomic_inc_return(&peer->rid);
93515 + end = atomic_inc_return_unchecked(&peer->rid);
93516 qp->rid = end;
93517
93518 rc = qp->q.fragments && (end - start) > max;
93519 @@ -759,12 +759,11 @@ static struct ctl_table ip4_frags_ctl_table[] = {
93520
93521 static int __net_init ip4_frags_ns_ctl_register(struct net *net)
93522 {
93523 - struct ctl_table *table;
93524 + ctl_table_no_const *table = NULL;
93525 struct ctl_table_header *hdr;
93526
93527 - table = ip4_frags_ns_ctl_table;
93528 if (!net_eq(net, &init_net)) {
93529 - table = kmemdup(table, sizeof(ip4_frags_ns_ctl_table), GFP_KERNEL);
93530 + table = kmemdup(ip4_frags_ns_ctl_table, sizeof(ip4_frags_ns_ctl_table), GFP_KERNEL);
93531 if (table == NULL)
93532 goto err_alloc;
93533
93534 @@ -775,9 +774,10 @@ static int __net_init ip4_frags_ns_ctl_register(struct net *net)
93535 /* Don't export sysctls to unprivileged users */
93536 if (net->user_ns != &init_user_ns)
93537 table[0].procname = NULL;
93538 - }
93539 + hdr = register_net_sysctl(net, "net/ipv4", table);
93540 + } else
93541 + hdr = register_net_sysctl(net, "net/ipv4", ip4_frags_ns_ctl_table);
93542
93543 - hdr = register_net_sysctl(net, "net/ipv4", table);
93544 if (hdr == NULL)
93545 goto err_reg;
93546
93547 @@ -785,8 +785,7 @@ static int __net_init ip4_frags_ns_ctl_register(struct net *net)
93548 return 0;
93549
93550 err_reg:
93551 - if (!net_eq(net, &init_net))
93552 - kfree(table);
93553 + kfree(table);
93554 err_alloc:
93555 return -ENOMEM;
93556 }
93557 diff --git a/net/ipv4/ip_gre.c b/net/ipv4/ip_gre.c
93558 index d7aea4c..a8ee872 100644
93559 --- a/net/ipv4/ip_gre.c
93560 +++ b/net/ipv4/ip_gre.c
93561 @@ -115,7 +115,7 @@ static bool log_ecn_error = true;
93562 module_param(log_ecn_error, bool, 0644);
93563 MODULE_PARM_DESC(log_ecn_error, "Log packets received with corrupted ECN");
93564
93565 -static struct rtnl_link_ops ipgre_link_ops __read_mostly;
93566 +static struct rtnl_link_ops ipgre_link_ops;
93567 static int ipgre_tunnel_init(struct net_device *dev);
93568
93569 static int ipgre_net_id __read_mostly;
93570 @@ -731,7 +731,7 @@ static const struct nla_policy ipgre_policy[IFLA_GRE_MAX + 1] = {
93571 [IFLA_GRE_PMTUDISC] = { .type = NLA_U8 },
93572 };
93573
93574 -static struct rtnl_link_ops ipgre_link_ops __read_mostly = {
93575 +static struct rtnl_link_ops ipgre_link_ops = {
93576 .kind = "gre",
93577 .maxtype = IFLA_GRE_MAX,
93578 .policy = ipgre_policy,
93579 @@ -745,7 +745,7 @@ static struct rtnl_link_ops ipgre_link_ops __read_mostly = {
93580 .fill_info = ipgre_fill_info,
93581 };
93582
93583 -static struct rtnl_link_ops ipgre_tap_ops __read_mostly = {
93584 +static struct rtnl_link_ops ipgre_tap_ops = {
93585 .kind = "gretap",
93586 .maxtype = IFLA_GRE_MAX,
93587 .policy = ipgre_policy,
93588 diff --git a/net/ipv4/ip_sockglue.c b/net/ipv4/ip_sockglue.c
93589 index 23e6ab0..be67a57 100644
93590 --- a/net/ipv4/ip_sockglue.c
93591 +++ b/net/ipv4/ip_sockglue.c
93592 @@ -1153,7 +1153,8 @@ static int do_ip_getsockopt(struct sock *sk, int level, int optname,
93593 len = min_t(unsigned int, len, opt->optlen);
93594 if (put_user(len, optlen))
93595 return -EFAULT;
93596 - if (copy_to_user(optval, opt->__data, len))
93597 + if ((len > (sizeof(optbuf) - sizeof(struct ip_options))) ||
93598 + copy_to_user(optval, opt->__data, len))
93599 return -EFAULT;
93600 return 0;
93601 }
93602 @@ -1284,7 +1285,7 @@ static int do_ip_getsockopt(struct sock *sk, int level, int optname,
93603 if (sk->sk_type != SOCK_STREAM)
93604 return -ENOPROTOOPT;
93605
93606 - msg.msg_control = optval;
93607 + msg.msg_control = (void __force_kernel *)optval;
93608 msg.msg_controllen = len;
93609 msg.msg_flags = flags;
93610
93611 diff --git a/net/ipv4/ip_vti.c b/net/ipv4/ip_vti.c
93612 index 26847e1..75d2d2f 100644
93613 --- a/net/ipv4/ip_vti.c
93614 +++ b/net/ipv4/ip_vti.c
93615 @@ -44,7 +44,7 @@
93616 #include <net/net_namespace.h>
93617 #include <net/netns/generic.h>
93618
93619 -static struct rtnl_link_ops vti_link_ops __read_mostly;
93620 +static struct rtnl_link_ops vti_link_ops;
93621
93622 static int vti_net_id __read_mostly;
93623 static int vti_tunnel_init(struct net_device *dev);
93624 @@ -425,7 +425,7 @@ static const struct nla_policy vti_policy[IFLA_VTI_MAX + 1] = {
93625 [IFLA_VTI_REMOTE] = { .len = FIELD_SIZEOF(struct iphdr, daddr) },
93626 };
93627
93628 -static struct rtnl_link_ops vti_link_ops __read_mostly = {
93629 +static struct rtnl_link_ops vti_link_ops = {
93630 .kind = "vti",
93631 .maxtype = IFLA_VTI_MAX,
93632 .policy = vti_policy,
93633 diff --git a/net/ipv4/ipconfig.c b/net/ipv4/ipconfig.c
93634 index efa1138..20dbba0 100644
93635 --- a/net/ipv4/ipconfig.c
93636 +++ b/net/ipv4/ipconfig.c
93637 @@ -334,7 +334,7 @@ static int __init ic_devinet_ioctl(unsigned int cmd, struct ifreq *arg)
93638
93639 mm_segment_t oldfs = get_fs();
93640 set_fs(get_ds());
93641 - res = devinet_ioctl(&init_net, cmd, (struct ifreq __user *) arg);
93642 + res = devinet_ioctl(&init_net, cmd, (struct ifreq __force_user *) arg);
93643 set_fs(oldfs);
93644 return res;
93645 }
93646 @@ -345,7 +345,7 @@ static int __init ic_dev_ioctl(unsigned int cmd, struct ifreq *arg)
93647
93648 mm_segment_t oldfs = get_fs();
93649 set_fs(get_ds());
93650 - res = dev_ioctl(&init_net, cmd, (struct ifreq __user *) arg);
93651 + res = dev_ioctl(&init_net, cmd, (struct ifreq __force_user *) arg);
93652 set_fs(oldfs);
93653 return res;
93654 }
93655 @@ -356,7 +356,7 @@ static int __init ic_route_ioctl(unsigned int cmd, struct rtentry *arg)
93656
93657 mm_segment_t oldfs = get_fs();
93658 set_fs(get_ds());
93659 - res = ip_rt_ioctl(&init_net, cmd, (void __user *) arg);
93660 + res = ip_rt_ioctl(&init_net, cmd, (void __force_user *) arg);
93661 set_fs(oldfs);
93662 return res;
93663 }
93664 diff --git a/net/ipv4/ipip.c b/net/ipv4/ipip.c
93665 index 7f80fb4..b0328f6 100644
93666 --- a/net/ipv4/ipip.c
93667 +++ b/net/ipv4/ipip.c
93668 @@ -124,7 +124,7 @@ MODULE_PARM_DESC(log_ecn_error, "Log packets received with corrupted ECN");
93669 static int ipip_net_id __read_mostly;
93670
93671 static int ipip_tunnel_init(struct net_device *dev);
93672 -static struct rtnl_link_ops ipip_link_ops __read_mostly;
93673 +static struct rtnl_link_ops ipip_link_ops;
93674
93675 static int ipip_err(struct sk_buff *skb, u32 info)
93676 {
93677 @@ -408,7 +408,7 @@ static const struct nla_policy ipip_policy[IFLA_IPTUN_MAX + 1] = {
93678 [IFLA_IPTUN_PMTUDISC] = { .type = NLA_U8 },
93679 };
93680
93681 -static struct rtnl_link_ops ipip_link_ops __read_mostly = {
93682 +static struct rtnl_link_ops ipip_link_ops = {
93683 .kind = "ipip",
93684 .maxtype = IFLA_IPTUN_MAX,
93685 .policy = ipip_policy,
93686 diff --git a/net/ipv4/netfilter/arp_tables.c b/net/ipv4/netfilter/arp_tables.c
93687 index 85a4f21..1beb1f5 100644
93688 --- a/net/ipv4/netfilter/arp_tables.c
93689 +++ b/net/ipv4/netfilter/arp_tables.c
93690 @@ -880,14 +880,14 @@ static int compat_table_info(const struct xt_table_info *info,
93691 #endif
93692
93693 static int get_info(struct net *net, void __user *user,
93694 - const int *len, int compat)
93695 + int len, int compat)
93696 {
93697 char name[XT_TABLE_MAXNAMELEN];
93698 struct xt_table *t;
93699 int ret;
93700
93701 - if (*len != sizeof(struct arpt_getinfo)) {
93702 - duprintf("length %u != %Zu\n", *len,
93703 + if (len != sizeof(struct arpt_getinfo)) {
93704 + duprintf("length %u != %Zu\n", len,
93705 sizeof(struct arpt_getinfo));
93706 return -EINVAL;
93707 }
93708 @@ -924,7 +924,7 @@ static int get_info(struct net *net, void __user *user,
93709 info.size = private->size;
93710 strcpy(info.name, name);
93711
93712 - if (copy_to_user(user, &info, *len) != 0)
93713 + if (copy_to_user(user, &info, len) != 0)
93714 ret = -EFAULT;
93715 else
93716 ret = 0;
93717 @@ -1683,7 +1683,7 @@ static int compat_do_arpt_get_ctl(struct sock *sk, int cmd, void __user *user,
93718
93719 switch (cmd) {
93720 case ARPT_SO_GET_INFO:
93721 - ret = get_info(sock_net(sk), user, len, 1);
93722 + ret = get_info(sock_net(sk), user, *len, 1);
93723 break;
93724 case ARPT_SO_GET_ENTRIES:
93725 ret = compat_get_entries(sock_net(sk), user, len);
93726 @@ -1728,7 +1728,7 @@ static int do_arpt_get_ctl(struct sock *sk, int cmd, void __user *user, int *len
93727
93728 switch (cmd) {
93729 case ARPT_SO_GET_INFO:
93730 - ret = get_info(sock_net(sk), user, len, 0);
93731 + ret = get_info(sock_net(sk), user, *len, 0);
93732 break;
93733
93734 case ARPT_SO_GET_ENTRIES:
93735 diff --git a/net/ipv4/netfilter/ip_tables.c b/net/ipv4/netfilter/ip_tables.c
93736 index d23118d..6ad7277 100644
93737 --- a/net/ipv4/netfilter/ip_tables.c
93738 +++ b/net/ipv4/netfilter/ip_tables.c
93739 @@ -1068,14 +1068,14 @@ static int compat_table_info(const struct xt_table_info *info,
93740 #endif
93741
93742 static int get_info(struct net *net, void __user *user,
93743 - const int *len, int compat)
93744 + int len, int compat)
93745 {
93746 char name[XT_TABLE_MAXNAMELEN];
93747 struct xt_table *t;
93748 int ret;
93749
93750 - if (*len != sizeof(struct ipt_getinfo)) {
93751 - duprintf("length %u != %zu\n", *len,
93752 + if (len != sizeof(struct ipt_getinfo)) {
93753 + duprintf("length %u != %zu\n", len,
93754 sizeof(struct ipt_getinfo));
93755 return -EINVAL;
93756 }
93757 @@ -1112,7 +1112,7 @@ static int get_info(struct net *net, void __user *user,
93758 info.size = private->size;
93759 strcpy(info.name, name);
93760
93761 - if (copy_to_user(user, &info, *len) != 0)
93762 + if (copy_to_user(user, &info, len) != 0)
93763 ret = -EFAULT;
93764 else
93765 ret = 0;
93766 @@ -1966,7 +1966,7 @@ compat_do_ipt_get_ctl(struct sock *sk, int cmd, void __user *user, int *len)
93767
93768 switch (cmd) {
93769 case IPT_SO_GET_INFO:
93770 - ret = get_info(sock_net(sk), user, len, 1);
93771 + ret = get_info(sock_net(sk), user, *len, 1);
93772 break;
93773 case IPT_SO_GET_ENTRIES:
93774 ret = compat_get_entries(sock_net(sk), user, len);
93775 @@ -2013,7 +2013,7 @@ do_ipt_get_ctl(struct sock *sk, int cmd, void __user *user, int *len)
93776
93777 switch (cmd) {
93778 case IPT_SO_GET_INFO:
93779 - ret = get_info(sock_net(sk), user, len, 0);
93780 + ret = get_info(sock_net(sk), user, *len, 0);
93781 break;
93782
93783 case IPT_SO_GET_ENTRIES:
93784 diff --git a/net/ipv4/netfilter/ipt_ULOG.c b/net/ipv4/netfilter/ipt_ULOG.c
93785 index cbc2215..9cb993c 100644
93786 --- a/net/ipv4/netfilter/ipt_ULOG.c
93787 +++ b/net/ipv4/netfilter/ipt_ULOG.c
93788 @@ -220,6 +220,7 @@ static void ipt_ulog_packet(struct net *net,
93789 ub->qlen++;
93790
93791 pm = nlmsg_data(nlh);
93792 + memset(pm, 0, sizeof(*pm));
93793
93794 /* We might not have a timestamp, get one */
93795 if (skb->tstamp.tv64 == 0)
93796 @@ -238,8 +239,6 @@ static void ipt_ulog_packet(struct net *net,
93797 }
93798 else if (loginfo->prefix[0] != '\0')
93799 strncpy(pm->prefix, loginfo->prefix, sizeof(pm->prefix));
93800 - else
93801 - *(pm->prefix) = '\0';
93802
93803 if (in && in->hard_header_len > 0 &&
93804 skb->mac_header != skb->network_header &&
93805 @@ -251,13 +250,9 @@ static void ipt_ulog_packet(struct net *net,
93806
93807 if (in)
93808 strncpy(pm->indev_name, in->name, sizeof(pm->indev_name));
93809 - else
93810 - pm->indev_name[0] = '\0';
93811
93812 if (out)
93813 strncpy(pm->outdev_name, out->name, sizeof(pm->outdev_name));
93814 - else
93815 - pm->outdev_name[0] = '\0';
93816
93817 /* copy_len <= skb->len, so can't fail. */
93818 if (skb_copy_bits(skb, 0, pm->payload, copy_len) < 0)
93819 diff --git a/net/ipv4/ping.c b/net/ipv4/ping.c
93820 index c482f7c..2784262 100644
93821 --- a/net/ipv4/ping.c
93822 +++ b/net/ipv4/ping.c
93823 @@ -55,7 +55,7 @@
93824
93825
93826 struct ping_table ping_table;
93827 -struct pingv6_ops pingv6_ops;
93828 +struct pingv6_ops *pingv6_ops;
93829 EXPORT_SYMBOL_GPL(pingv6_ops);
93830
93831 static u16 ping_port_rover;
93832 @@ -335,7 +335,7 @@ static int ping_check_bind_addr(struct sock *sk, struct inet_sock *isk,
93833 return -ENODEV;
93834 }
93835 }
93836 - has_addr = pingv6_ops.ipv6_chk_addr(net, &addr->sin6_addr, dev,
93837 + has_addr = pingv6_ops->ipv6_chk_addr(net, &addr->sin6_addr, dev,
93838 scoped);
93839 rcu_read_unlock();
93840
93841 @@ -541,7 +541,7 @@ void ping_err(struct sk_buff *skb, int offset, u32 info)
93842 }
93843 #if IS_ENABLED(CONFIG_IPV6)
93844 } else if (skb->protocol == htons(ETH_P_IPV6)) {
93845 - harderr = pingv6_ops.icmpv6_err_convert(type, code, &err);
93846 + harderr = pingv6_ops->icmpv6_err_convert(type, code, &err);
93847 #endif
93848 }
93849
93850 @@ -559,7 +559,7 @@ void ping_err(struct sk_buff *skb, int offset, u32 info)
93851 info, (u8 *)icmph);
93852 #if IS_ENABLED(CONFIG_IPV6)
93853 } else if (family == AF_INET6) {
93854 - pingv6_ops.ipv6_icmp_error(sk, skb, err, 0,
93855 + pingv6_ops->ipv6_icmp_error(sk, skb, err, 0,
93856 info, (u8 *)icmph);
93857 #endif
93858 }
93859 @@ -841,7 +841,7 @@ int ping_recvmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
93860 return ip_recv_error(sk, msg, len, addr_len);
93861 #if IS_ENABLED(CONFIG_IPV6)
93862 } else if (family == AF_INET6) {
93863 - return pingv6_ops.ipv6_recv_error(sk, msg, len,
93864 + return pingv6_ops->ipv6_recv_error(sk, msg, len,
93865 addr_len);
93866 #endif
93867 }
93868 @@ -900,7 +900,7 @@ int ping_recvmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
93869 }
93870
93871 if (inet6_sk(sk)->rxopt.all)
93872 - pingv6_ops.ip6_datagram_recv_ctl(sk, msg, skb);
93873 + pingv6_ops->ip6_datagram_recv_ctl(sk, msg, skb);
93874 #endif
93875 } else {
93876 BUG();
93877 @@ -1090,7 +1090,7 @@ static void ping_v4_format_sock(struct sock *sp, struct seq_file *f,
93878 from_kuid_munged(seq_user_ns(f), sock_i_uid(sp)),
93879 0, sock_i_ino(sp),
93880 atomic_read(&sp->sk_refcnt), sp,
93881 - atomic_read(&sp->sk_drops), len);
93882 + atomic_read_unchecked(&sp->sk_drops), len);
93883 }
93884
93885 static int ping_v4_seq_show(struct seq_file *seq, void *v)
93886 diff --git a/net/ipv4/raw.c b/net/ipv4/raw.c
93887 index 7d3db78..9fd511d 100644
93888 --- a/net/ipv4/raw.c
93889 +++ b/net/ipv4/raw.c
93890 @@ -311,7 +311,7 @@ static int raw_rcv_skb(struct sock *sk, struct sk_buff *skb)
93891 int raw_rcv(struct sock *sk, struct sk_buff *skb)
93892 {
93893 if (!xfrm4_policy_check(sk, XFRM_POLICY_IN, skb)) {
93894 - atomic_inc(&sk->sk_drops);
93895 + atomic_inc_unchecked(&sk->sk_drops);
93896 kfree_skb(skb);
93897 return NET_RX_DROP;
93898 }
93899 @@ -746,16 +746,20 @@ static int raw_init(struct sock *sk)
93900
93901 static int raw_seticmpfilter(struct sock *sk, char __user *optval, int optlen)
93902 {
93903 + struct icmp_filter filter;
93904 +
93905 if (optlen > sizeof(struct icmp_filter))
93906 optlen = sizeof(struct icmp_filter);
93907 - if (copy_from_user(&raw_sk(sk)->filter, optval, optlen))
93908 + if (copy_from_user(&filter, optval, optlen))
93909 return -EFAULT;
93910 + raw_sk(sk)->filter = filter;
93911 return 0;
93912 }
93913
93914 static int raw_geticmpfilter(struct sock *sk, char __user *optval, int __user *optlen)
93915 {
93916 int len, ret = -EFAULT;
93917 + struct icmp_filter filter;
93918
93919 if (get_user(len, optlen))
93920 goto out;
93921 @@ -765,8 +769,8 @@ static int raw_geticmpfilter(struct sock *sk, char __user *optval, int __user *o
93922 if (len > sizeof(struct icmp_filter))
93923 len = sizeof(struct icmp_filter);
93924 ret = -EFAULT;
93925 - if (put_user(len, optlen) ||
93926 - copy_to_user(optval, &raw_sk(sk)->filter, len))
93927 + filter = raw_sk(sk)->filter;
93928 + if (put_user(len, optlen) || len > sizeof filter || copy_to_user(optval, &filter, len))
93929 goto out;
93930 ret = 0;
93931 out: return ret;
93932 @@ -995,7 +999,7 @@ static void raw_sock_seq_show(struct seq_file *seq, struct sock *sp, int i)
93933 0, 0L, 0,
93934 from_kuid_munged(seq_user_ns(seq), sock_i_uid(sp)),
93935 0, sock_i_ino(sp),
93936 - atomic_read(&sp->sk_refcnt), sp, atomic_read(&sp->sk_drops));
93937 + atomic_read(&sp->sk_refcnt), sp, atomic_read_unchecked(&sp->sk_drops));
93938 }
93939
93940 static int raw_seq_show(struct seq_file *seq, void *v)
93941 diff --git a/net/ipv4/route.c b/net/ipv4/route.c
93942 index 62290b5..f0d944f 100644
93943 --- a/net/ipv4/route.c
93944 +++ b/net/ipv4/route.c
93945 @@ -2617,34 +2617,34 @@ static struct ctl_table ipv4_route_flush_table[] = {
93946 .maxlen = sizeof(int),
93947 .mode = 0200,
93948 .proc_handler = ipv4_sysctl_rtcache_flush,
93949 + .extra1 = &init_net,
93950 },
93951 { },
93952 };
93953
93954 static __net_init int sysctl_route_net_init(struct net *net)
93955 {
93956 - struct ctl_table *tbl;
93957 + ctl_table_no_const *tbl = NULL;
93958
93959 - tbl = ipv4_route_flush_table;
93960 if (!net_eq(net, &init_net)) {
93961 - tbl = kmemdup(tbl, sizeof(ipv4_route_flush_table), GFP_KERNEL);
93962 + tbl = kmemdup(ipv4_route_flush_table, sizeof(ipv4_route_flush_table), GFP_KERNEL);
93963 if (tbl == NULL)
93964 goto err_dup;
93965
93966 /* Don't export sysctls to unprivileged users */
93967 if (net->user_ns != &init_user_ns)
93968 tbl[0].procname = NULL;
93969 - }
93970 - tbl[0].extra1 = net;
93971 + tbl[0].extra1 = net;
93972 + net->ipv4.route_hdr = register_net_sysctl(net, "net/ipv4/route", tbl);
93973 + } else
93974 + net->ipv4.route_hdr = register_net_sysctl(net, "net/ipv4/route", ipv4_route_flush_table);
93975
93976 - net->ipv4.route_hdr = register_net_sysctl(net, "net/ipv4/route", tbl);
93977 if (net->ipv4.route_hdr == NULL)
93978 goto err_reg;
93979 return 0;
93980
93981 err_reg:
93982 - if (tbl != ipv4_route_flush_table)
93983 - kfree(tbl);
93984 + kfree(tbl);
93985 err_dup:
93986 return -ENOMEM;
93987 }
93988 @@ -2667,8 +2667,8 @@ static __net_initdata struct pernet_operations sysctl_route_ops = {
93989
93990 static __net_init int rt_genid_init(struct net *net)
93991 {
93992 - atomic_set(&net->ipv4.rt_genid, 0);
93993 - atomic_set(&net->fnhe_genid, 0);
93994 + atomic_set_unchecked(&net->ipv4.rt_genid, 0);
93995 + atomic_set_unchecked(&net->fnhe_genid, 0);
93996 get_random_bytes(&net->ipv4.dev_addr_genid,
93997 sizeof(net->ipv4.dev_addr_genid));
93998 return 0;
93999 diff --git a/net/ipv4/sysctl_net_ipv4.c b/net/ipv4/sysctl_net_ipv4.c
94000 index 540279f..9855b16 100644
94001 --- a/net/ipv4/sysctl_net_ipv4.c
94002 +++ b/net/ipv4/sysctl_net_ipv4.c
94003 @@ -58,7 +58,7 @@ static int ipv4_local_port_range(struct ctl_table *table, int write,
94004 {
94005 int ret;
94006 int range[2];
94007 - struct ctl_table tmp = {
94008 + ctl_table_no_const tmp = {
94009 .data = &range,
94010 .maxlen = sizeof(range),
94011 .mode = table->mode,
94012 @@ -111,7 +111,7 @@ static int ipv4_ping_group_range(struct ctl_table *table, int write,
94013 int ret;
94014 gid_t urange[2];
94015 kgid_t low, high;
94016 - struct ctl_table tmp = {
94017 + ctl_table_no_const tmp = {
94018 .data = &urange,
94019 .maxlen = sizeof(urange),
94020 .mode = table->mode,
94021 @@ -142,7 +142,7 @@ static int proc_tcp_congestion_control(struct ctl_table *ctl, int write,
94022 void __user *buffer, size_t *lenp, loff_t *ppos)
94023 {
94024 char val[TCP_CA_NAME_MAX];
94025 - struct ctl_table tbl = {
94026 + ctl_table_no_const tbl = {
94027 .data = val,
94028 .maxlen = TCP_CA_NAME_MAX,
94029 };
94030 @@ -161,7 +161,7 @@ static int proc_tcp_available_congestion_control(struct ctl_table *ctl,
94031 void __user *buffer, size_t *lenp,
94032 loff_t *ppos)
94033 {
94034 - struct ctl_table tbl = { .maxlen = TCP_CA_BUF_MAX, };
94035 + ctl_table_no_const tbl = { .maxlen = TCP_CA_BUF_MAX, };
94036 int ret;
94037
94038 tbl.data = kmalloc(tbl.maxlen, GFP_USER);
94039 @@ -178,7 +178,7 @@ static int proc_allowed_congestion_control(struct ctl_table *ctl,
94040 void __user *buffer, size_t *lenp,
94041 loff_t *ppos)
94042 {
94043 - struct ctl_table tbl = { .maxlen = TCP_CA_BUF_MAX };
94044 + ctl_table_no_const tbl = { .maxlen = TCP_CA_BUF_MAX };
94045 int ret;
94046
94047 tbl.data = kmalloc(tbl.maxlen, GFP_USER);
94048 @@ -204,15 +204,17 @@ static int ipv4_tcp_mem(struct ctl_table *ctl, int write,
94049 struct mem_cgroup *memcg;
94050 #endif
94051
94052 - struct ctl_table tmp = {
94053 + ctl_table_no_const tmp = {
94054 .data = &vec,
94055 .maxlen = sizeof(vec),
94056 .mode = ctl->mode,
94057 };
94058
94059 if (!write) {
94060 - ctl->data = &net->ipv4.sysctl_tcp_mem;
94061 - return proc_doulongvec_minmax(ctl, write, buffer, lenp, ppos);
94062 + ctl_table_no_const tcp_mem = *ctl;
94063 +
94064 + tcp_mem.data = &net->ipv4.sysctl_tcp_mem;
94065 + return proc_doulongvec_minmax(&tcp_mem, write, buffer, lenp, ppos);
94066 }
94067
94068 ret = proc_doulongvec_minmax(&tmp, write, buffer, lenp, ppos);
94069 @@ -240,7 +242,7 @@ static int proc_tcp_fastopen_key(struct ctl_table *ctl, int write,
94070 void __user *buffer, size_t *lenp,
94071 loff_t *ppos)
94072 {
94073 - struct ctl_table tbl = { .maxlen = (TCP_FASTOPEN_KEY_LENGTH * 2 + 10) };
94074 + ctl_table_no_const tbl = { .maxlen = (TCP_FASTOPEN_KEY_LENGTH * 2 + 10) };
94075 struct tcp_fastopen_context *ctxt;
94076 int ret;
94077 u32 user_key[4]; /* 16 bytes, matching TCP_FASTOPEN_KEY_LENGTH */
94078 @@ -483,7 +485,7 @@ static struct ctl_table ipv4_table[] = {
94079 },
94080 {
94081 .procname = "ip_local_reserved_ports",
94082 - .data = NULL, /* initialized in sysctl_ipv4_init */
94083 + .data = sysctl_local_reserved_ports,
94084 .maxlen = 65536,
94085 .mode = 0644,
94086 .proc_handler = proc_do_large_bitmap,
94087 @@ -864,11 +866,10 @@ static struct ctl_table ipv4_net_table[] = {
94088
94089 static __net_init int ipv4_sysctl_init_net(struct net *net)
94090 {
94091 - struct ctl_table *table;
94092 + ctl_table_no_const *table = NULL;
94093
94094 - table = ipv4_net_table;
94095 if (!net_eq(net, &init_net)) {
94096 - table = kmemdup(table, sizeof(ipv4_net_table), GFP_KERNEL);
94097 + table = kmemdup(ipv4_net_table, sizeof(ipv4_net_table), GFP_KERNEL);
94098 if (table == NULL)
94099 goto err_alloc;
94100
94101 @@ -903,15 +904,17 @@ static __net_init int ipv4_sysctl_init_net(struct net *net)
94102
94103 tcp_init_mem(net);
94104
94105 - net->ipv4.ipv4_hdr = register_net_sysctl(net, "net/ipv4", table);
94106 + if (!net_eq(net, &init_net))
94107 + net->ipv4.ipv4_hdr = register_net_sysctl(net, "net/ipv4", table);
94108 + else
94109 + net->ipv4.ipv4_hdr = register_net_sysctl(net, "net/ipv4", ipv4_net_table);
94110 if (net->ipv4.ipv4_hdr == NULL)
94111 goto err_reg;
94112
94113 return 0;
94114
94115 err_reg:
94116 - if (!net_eq(net, &init_net))
94117 - kfree(table);
94118 + kfree(table);
94119 err_alloc:
94120 return -ENOMEM;
94121 }
94122 @@ -933,16 +936,6 @@ static __net_initdata struct pernet_operations ipv4_sysctl_ops = {
94123 static __init int sysctl_ipv4_init(void)
94124 {
94125 struct ctl_table_header *hdr;
94126 - struct ctl_table *i;
94127 -
94128 - for (i = ipv4_table; i->procname; i++) {
94129 - if (strcmp(i->procname, "ip_local_reserved_ports") == 0) {
94130 - i->data = sysctl_local_reserved_ports;
94131 - break;
94132 - }
94133 - }
94134 - if (!i->procname)
94135 - return -EINVAL;
94136
94137 hdr = register_net_sysctl(&init_net, "net/ipv4", ipv4_table);
94138 if (hdr == NULL)
94139 diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c
94140 index 068c8fb..a755c52 100644
94141 --- a/net/ipv4/tcp_input.c
94142 +++ b/net/ipv4/tcp_input.c
94143 @@ -4435,7 +4435,7 @@ static struct sk_buff *tcp_collapse_one(struct sock *sk, struct sk_buff *skb,
94144 * simplifies code)
94145 */
94146 static void
94147 -tcp_collapse(struct sock *sk, struct sk_buff_head *list,
94148 +__intentional_overflow(5,6) tcp_collapse(struct sock *sk, struct sk_buff_head *list,
94149 struct sk_buff *head, struct sk_buff *tail,
94150 u32 start, u32 end)
94151 {
94152 @@ -5520,6 +5520,7 @@ discard:
94153 tcp_paws_reject(&tp->rx_opt, 0))
94154 goto discard_and_undo;
94155
94156 +#ifndef CONFIG_GRKERNSEC_NO_SIMULT_CONNECT
94157 if (th->syn) {
94158 /* We see SYN without ACK. It is attempt of
94159 * simultaneous connect with crossed SYNs.
94160 @@ -5570,6 +5571,7 @@ discard:
94161 goto discard;
94162 #endif
94163 }
94164 +#endif
94165 /* "fifth, if neither of the SYN or RST bits is set then
94166 * drop the segment and return."
94167 */
94168 @@ -5616,7 +5618,7 @@ int tcp_rcv_state_process(struct sock *sk, struct sk_buff *skb,
94169 goto discard;
94170
94171 if (th->syn) {
94172 - if (th->fin)
94173 + if (th->fin || th->urg || th->psh)
94174 goto discard;
94175 if (icsk->icsk_af_ops->conn_request(sk, skb) < 0)
94176 return 1;
94177 diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c
94178 index 5031f68..91569e2 100644
94179 --- a/net/ipv4/tcp_ipv4.c
94180 +++ b/net/ipv4/tcp_ipv4.c
94181 @@ -91,6 +91,10 @@ int sysctl_tcp_low_latency __read_mostly;
94182 EXPORT_SYMBOL(sysctl_tcp_low_latency);
94183
94184
94185 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
94186 +extern int grsec_enable_blackhole;
94187 +#endif
94188 +
94189 #ifdef CONFIG_TCP_MD5SIG
94190 static int tcp_v4_md5_hash_hdr(char *md5_hash, const struct tcp_md5sig_key *key,
94191 __be32 daddr, __be32 saddr, const struct tcphdr *th);
94192 @@ -1829,6 +1833,9 @@ int tcp_v4_do_rcv(struct sock *sk, struct sk_buff *skb)
94193 return 0;
94194
94195 reset:
94196 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
94197 + if (!grsec_enable_blackhole)
94198 +#endif
94199 tcp_v4_send_reset(rsk, skb);
94200 discard:
94201 kfree_skb(skb);
94202 @@ -1974,12 +1981,19 @@ int tcp_v4_rcv(struct sk_buff *skb)
94203 TCP_SKB_CB(skb)->sacked = 0;
94204
94205 sk = __inet_lookup_skb(&tcp_hashinfo, skb, th->source, th->dest);
94206 - if (!sk)
94207 + if (!sk) {
94208 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
94209 + ret = 1;
94210 +#endif
94211 goto no_tcp_socket;
94212 -
94213 + }
94214 process:
94215 - if (sk->sk_state == TCP_TIME_WAIT)
94216 + if (sk->sk_state == TCP_TIME_WAIT) {
94217 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
94218 + ret = 2;
94219 +#endif
94220 goto do_time_wait;
94221 + }
94222
94223 if (unlikely(iph->ttl < inet_sk(sk)->min_ttl)) {
94224 NET_INC_STATS_BH(net, LINUX_MIB_TCPMINTTLDROP);
94225 @@ -2033,6 +2047,10 @@ csum_error:
94226 bad_packet:
94227 TCP_INC_STATS_BH(net, TCP_MIB_INERRS);
94228 } else {
94229 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
94230 + if (!grsec_enable_blackhole || (ret == 1 &&
94231 + (skb->dev->flags & IFF_LOOPBACK)))
94232 +#endif
94233 tcp_v4_send_reset(NULL, skb);
94234 }
94235
94236 diff --git a/net/ipv4/tcp_minisocks.c b/net/ipv4/tcp_minisocks.c
94237 index 58a3e69..7f0626e 100644
94238 --- a/net/ipv4/tcp_minisocks.c
94239 +++ b/net/ipv4/tcp_minisocks.c
94240 @@ -27,6 +27,10 @@
94241 #include <net/inet_common.h>
94242 #include <net/xfrm.h>
94243
94244 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
94245 +extern int grsec_enable_blackhole;
94246 +#endif
94247 +
94248 int sysctl_tcp_syncookies __read_mostly = 1;
94249 EXPORT_SYMBOL(sysctl_tcp_syncookies);
94250
94251 @@ -711,7 +715,10 @@ embryonic_reset:
94252 * avoid becoming vulnerable to outside attack aiming at
94253 * resetting legit local connections.
94254 */
94255 - req->rsk_ops->send_reset(sk, skb);
94256 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
94257 + if (!grsec_enable_blackhole)
94258 +#endif
94259 + req->rsk_ops->send_reset(sk, skb);
94260 } else if (fastopen) { /* received a valid RST pkt */
94261 reqsk_fastopen_remove(sk, req, true);
94262 tcp_reset(sk);
94263 diff --git a/net/ipv4/tcp_probe.c b/net/ipv4/tcp_probe.c
94264 index 611beab..c4b6e1d 100644
94265 --- a/net/ipv4/tcp_probe.c
94266 +++ b/net/ipv4/tcp_probe.c
94267 @@ -245,7 +245,7 @@ static ssize_t tcpprobe_read(struct file *file, char __user *buf,
94268 if (cnt + width >= len)
94269 break;
94270
94271 - if (copy_to_user(buf + cnt, tbuf, width))
94272 + if (width > sizeof tbuf || copy_to_user(buf + cnt, tbuf, width))
94273 return -EFAULT;
94274 cnt += width;
94275 }
94276 diff --git a/net/ipv4/tcp_timer.c b/net/ipv4/tcp_timer.c
94277 index 4b85e6f..22f9ac9 100644
94278 --- a/net/ipv4/tcp_timer.c
94279 +++ b/net/ipv4/tcp_timer.c
94280 @@ -22,6 +22,10 @@
94281 #include <linux/gfp.h>
94282 #include <net/tcp.h>
94283
94284 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
94285 +extern int grsec_lastack_retries;
94286 +#endif
94287 +
94288 int sysctl_tcp_syn_retries __read_mostly = TCP_SYN_RETRIES;
94289 int sysctl_tcp_synack_retries __read_mostly = TCP_SYNACK_RETRIES;
94290 int sysctl_tcp_keepalive_time __read_mostly = TCP_KEEPALIVE_TIME;
94291 @@ -185,6 +189,13 @@ static int tcp_write_timeout(struct sock *sk)
94292 }
94293 }
94294
94295 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
94296 + if ((sk->sk_state == TCP_LAST_ACK) &&
94297 + (grsec_lastack_retries > 0) &&
94298 + (grsec_lastack_retries < retry_until))
94299 + retry_until = grsec_lastack_retries;
94300 +#endif
94301 +
94302 if (retransmits_timed_out(sk, retry_until,
94303 syn_set ? 0 : icsk->icsk_user_timeout, syn_set)) {
94304 /* Has it gone just too far? */
94305 diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c
94306 index 5e2c2f1..6473c22 100644
94307 --- a/net/ipv4/udp.c
94308 +++ b/net/ipv4/udp.c
94309 @@ -87,6 +87,7 @@
94310 #include <linux/types.h>
94311 #include <linux/fcntl.h>
94312 #include <linux/module.h>
94313 +#include <linux/security.h>
94314 #include <linux/socket.h>
94315 #include <linux/sockios.h>
94316 #include <linux/igmp.h>
94317 @@ -112,6 +113,10 @@
94318 #include <net/busy_poll.h>
94319 #include "udp_impl.h"
94320
94321 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
94322 +extern int grsec_enable_blackhole;
94323 +#endif
94324 +
94325 struct udp_table udp_table __read_mostly;
94326 EXPORT_SYMBOL(udp_table);
94327
94328 @@ -595,6 +600,9 @@ found:
94329 return s;
94330 }
94331
94332 +extern int gr_search_udp_recvmsg(struct sock *sk, const struct sk_buff *skb);
94333 +extern int gr_search_udp_sendmsg(struct sock *sk, struct sockaddr_in *addr);
94334 +
94335 /*
94336 * This routine is called by the ICMP module when it gets some
94337 * sort of error condition. If err < 0 then the socket should
94338 @@ -892,9 +900,18 @@ int udp_sendmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
94339 dport = usin->sin_port;
94340 if (dport == 0)
94341 return -EINVAL;
94342 +
94343 + err = gr_search_udp_sendmsg(sk, usin);
94344 + if (err)
94345 + return err;
94346 } else {
94347 if (sk->sk_state != TCP_ESTABLISHED)
94348 return -EDESTADDRREQ;
94349 +
94350 + err = gr_search_udp_sendmsg(sk, NULL);
94351 + if (err)
94352 + return err;
94353 +
94354 daddr = inet->inet_daddr;
94355 dport = inet->inet_dport;
94356 /* Open fast path for connected socket.
94357 @@ -1141,7 +1158,7 @@ static unsigned int first_packet_length(struct sock *sk)
94358 IS_UDPLITE(sk));
94359 UDP_INC_STATS_BH(sock_net(sk), UDP_MIB_INERRORS,
94360 IS_UDPLITE(sk));
94361 - atomic_inc(&sk->sk_drops);
94362 + atomic_inc_unchecked(&sk->sk_drops);
94363 __skb_unlink(skb, rcvq);
94364 __skb_queue_tail(&list_kill, skb);
94365 }
94366 @@ -1221,6 +1238,10 @@ try_again:
94367 if (!skb)
94368 goto out;
94369
94370 + err = gr_search_udp_recvmsg(sk, skb);
94371 + if (err)
94372 + goto out_free;
94373 +
94374 ulen = skb->len - sizeof(struct udphdr);
94375 copied = len;
94376 if (copied > ulen)
94377 @@ -1254,7 +1275,7 @@ try_again:
94378 if (unlikely(err)) {
94379 trace_kfree_skb(skb, udp_recvmsg);
94380 if (!peeked) {
94381 - atomic_inc(&sk->sk_drops);
94382 + atomic_inc_unchecked(&sk->sk_drops);
94383 UDP_INC_STATS_USER(sock_net(sk),
94384 UDP_MIB_INERRORS, is_udplite);
94385 }
94386 @@ -1542,7 +1563,7 @@ csum_error:
94387 UDP_INC_STATS_BH(sock_net(sk), UDP_MIB_CSUMERRORS, is_udplite);
94388 drop:
94389 UDP_INC_STATS_BH(sock_net(sk), UDP_MIB_INERRORS, is_udplite);
94390 - atomic_inc(&sk->sk_drops);
94391 + atomic_inc_unchecked(&sk->sk_drops);
94392 kfree_skb(skb);
94393 return -1;
94394 }
94395 @@ -1561,7 +1582,7 @@ static void flush_stack(struct sock **stack, unsigned int count,
94396 skb1 = (i == final) ? skb : skb_clone(skb, GFP_ATOMIC);
94397
94398 if (!skb1) {
94399 - atomic_inc(&sk->sk_drops);
94400 + atomic_inc_unchecked(&sk->sk_drops);
94401 UDP_INC_STATS_BH(sock_net(sk), UDP_MIB_RCVBUFERRORS,
94402 IS_UDPLITE(sk));
94403 UDP_INC_STATS_BH(sock_net(sk), UDP_MIB_INERRORS,
94404 @@ -1733,6 +1754,9 @@ int __udp4_lib_rcv(struct sk_buff *skb, struct udp_table *udptable,
94405 goto csum_error;
94406
94407 UDP_INC_STATS_BH(net, UDP_MIB_NOPORTS, proto == IPPROTO_UDPLITE);
94408 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
94409 + if (!grsec_enable_blackhole || (skb->dev->flags & IFF_LOOPBACK))
94410 +#endif
94411 icmp_send(skb, ICMP_DEST_UNREACH, ICMP_PORT_UNREACH, 0);
94412
94413 /*
94414 @@ -2165,7 +2189,7 @@ static void udp4_format_sock(struct sock *sp, struct seq_file *f,
94415 from_kuid_munged(seq_user_ns(f), sock_i_uid(sp)),
94416 0, sock_i_ino(sp),
94417 atomic_read(&sp->sk_refcnt), sp,
94418 - atomic_read(&sp->sk_drops), len);
94419 + atomic_read_unchecked(&sp->sk_drops), len);
94420 }
94421
94422 int udp4_seq_show(struct seq_file *seq, void *v)
94423 diff --git a/net/ipv4/xfrm4_policy.c b/net/ipv4/xfrm4_policy.c
94424 index adf9983..8e45d0a 100644
94425 --- a/net/ipv4/xfrm4_policy.c
94426 +++ b/net/ipv4/xfrm4_policy.c
94427 @@ -186,11 +186,11 @@ _decode_session4(struct sk_buff *skb, struct flowi *fl, int reverse)
94428 fl4->flowi4_tos = iph->tos;
94429 }
94430
94431 -static inline int xfrm4_garbage_collect(struct dst_ops *ops)
94432 +static int xfrm4_garbage_collect(struct dst_ops *ops)
94433 {
94434 struct net *net = container_of(ops, struct net, xfrm.xfrm4_dst_ops);
94435
94436 - xfrm4_policy_afinfo.garbage_collect(net);
94437 + xfrm_garbage_collect_deferred(net);
94438 return (dst_entries_get_slow(ops) > ops->gc_thresh * 2);
94439 }
94440
94441 @@ -269,19 +269,18 @@ static struct ctl_table xfrm4_policy_table[] = {
94442
94443 static int __net_init xfrm4_net_init(struct net *net)
94444 {
94445 - struct ctl_table *table;
94446 + ctl_table_no_const *table = NULL;
94447 struct ctl_table_header *hdr;
94448
94449 - table = xfrm4_policy_table;
94450 if (!net_eq(net, &init_net)) {
94451 - table = kmemdup(table, sizeof(xfrm4_policy_table), GFP_KERNEL);
94452 + table = kmemdup(xfrm4_policy_table, sizeof(xfrm4_policy_table), GFP_KERNEL);
94453 if (!table)
94454 goto err_alloc;
94455
94456 table[0].data = &net->xfrm.xfrm4_dst_ops.gc_thresh;
94457 - }
94458 -
94459 - hdr = register_net_sysctl(net, "net/ipv4", table);
94460 + hdr = register_net_sysctl(net, "net/ipv4", table);
94461 + } else
94462 + hdr = register_net_sysctl(net, "net/ipv4", xfrm4_policy_table);
94463 if (!hdr)
94464 goto err_reg;
94465
94466 @@ -289,8 +288,7 @@ static int __net_init xfrm4_net_init(struct net *net)
94467 return 0;
94468
94469 err_reg:
94470 - if (!net_eq(net, &init_net))
94471 - kfree(table);
94472 + kfree(table);
94473 err_alloc:
94474 return -ENOMEM;
94475 }
94476 diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c
94477 index cd3fb30..b7dfef7 100644
94478 --- a/net/ipv6/addrconf.c
94479 +++ b/net/ipv6/addrconf.c
94480 @@ -586,7 +586,7 @@ static int inet6_netconf_dump_devconf(struct sk_buff *skb,
94481 idx = 0;
94482 head = &net->dev_index_head[h];
94483 rcu_read_lock();
94484 - cb->seq = atomic_read(&net->ipv6.dev_addr_genid) ^
94485 + cb->seq = atomic_read_unchecked(&net->ipv6.dev_addr_genid) ^
94486 net->dev_base_seq;
94487 hlist_for_each_entry_rcu(dev, head, index_hlist) {
94488 if (idx < s_idx)
94489 @@ -2364,7 +2364,7 @@ int addrconf_set_dstaddr(struct net *net, void __user *arg)
94490 p.iph.ihl = 5;
94491 p.iph.protocol = IPPROTO_IPV6;
94492 p.iph.ttl = 64;
94493 - ifr.ifr_ifru.ifru_data = (__force void __user *)&p;
94494 + ifr.ifr_ifru.ifru_data = (void __force_user *)&p;
94495
94496 if (ops->ndo_do_ioctl) {
94497 mm_segment_t oldfs = get_fs();
94498 @@ -3977,7 +3977,7 @@ static int inet6_dump_addr(struct sk_buff *skb, struct netlink_callback *cb,
94499 s_ip_idx = ip_idx = cb->args[2];
94500
94501 rcu_read_lock();
94502 - cb->seq = atomic_read(&net->ipv6.dev_addr_genid) ^ net->dev_base_seq;
94503 + cb->seq = atomic_read_unchecked(&net->ipv6.dev_addr_genid) ^ net->dev_base_seq;
94504 for (h = s_h; h < NETDEV_HASHENTRIES; h++, s_idx = 0) {
94505 idx = 0;
94506 head = &net->dev_index_head[h];
94507 @@ -4603,7 +4603,7 @@ static void __ipv6_ifa_notify(int event, struct inet6_ifaddr *ifp)
94508 dst_free(&ifp->rt->dst);
94509 break;
94510 }
94511 - atomic_inc(&net->ipv6.dev_addr_genid);
94512 + atomic_inc_unchecked(&net->ipv6.dev_addr_genid);
94513 rt_genid_bump_ipv6(net);
94514 }
94515
94516 @@ -4624,7 +4624,7 @@ int addrconf_sysctl_forward(struct ctl_table *ctl, int write,
94517 int *valp = ctl->data;
94518 int val = *valp;
94519 loff_t pos = *ppos;
94520 - struct ctl_table lctl;
94521 + ctl_table_no_const lctl;
94522 int ret;
94523
94524 /*
94525 @@ -4709,7 +4709,7 @@ int addrconf_sysctl_disable(struct ctl_table *ctl, int write,
94526 int *valp = ctl->data;
94527 int val = *valp;
94528 loff_t pos = *ppos;
94529 - struct ctl_table lctl;
94530 + ctl_table_no_const lctl;
94531 int ret;
94532
94533 /*
94534 diff --git a/net/ipv6/af_inet6.c b/net/ipv6/af_inet6.c
94535 index 8132b44..b8eca70 100644
94536 --- a/net/ipv6/af_inet6.c
94537 +++ b/net/ipv6/af_inet6.c
94538 @@ -767,7 +767,7 @@ static int __net_init inet6_net_init(struct net *net)
94539
94540 net->ipv6.sysctl.bindv6only = 0;
94541 net->ipv6.sysctl.icmpv6_time = 1*HZ;
94542 - atomic_set(&net->ipv6.rt_genid, 0);
94543 + atomic_set_unchecked(&net->ipv6.rt_genid, 0);
94544
94545 err = ipv6_init_mibs(net);
94546 if (err)
94547 diff --git a/net/ipv6/datagram.c b/net/ipv6/datagram.c
94548 index c66c6df..f375d3c 100644
94549 --- a/net/ipv6/datagram.c
94550 +++ b/net/ipv6/datagram.c
94551 @@ -908,5 +908,5 @@ void ip6_dgram_sock_seq_show(struct seq_file *seq, struct sock *sp,
94552 0,
94553 sock_i_ino(sp),
94554 atomic_read(&sp->sk_refcnt), sp,
94555 - atomic_read(&sp->sk_drops));
94556 + atomic_read_unchecked(&sp->sk_drops));
94557 }
94558 diff --git a/net/ipv6/icmp.c b/net/ipv6/icmp.c
94559 index eef8d94..cfa1852 100644
94560 --- a/net/ipv6/icmp.c
94561 +++ b/net/ipv6/icmp.c
94562 @@ -997,7 +997,7 @@ struct ctl_table ipv6_icmp_table_template[] = {
94563
94564 struct ctl_table * __net_init ipv6_icmp_sysctl_init(struct net *net)
94565 {
94566 - struct ctl_table *table;
94567 + ctl_table_no_const *table;
94568
94569 table = kmemdup(ipv6_icmp_table_template,
94570 sizeof(ipv6_icmp_table_template),
94571 diff --git a/net/ipv6/ip6_gre.c b/net/ipv6/ip6_gre.c
94572 index bf4a9a0..e5f6ac5 100644
94573 --- a/net/ipv6/ip6_gre.c
94574 +++ b/net/ipv6/ip6_gre.c
94575 @@ -74,7 +74,7 @@ struct ip6gre_net {
94576 struct net_device *fb_tunnel_dev;
94577 };
94578
94579 -static struct rtnl_link_ops ip6gre_link_ops __read_mostly;
94580 +static struct rtnl_link_ops ip6gre_link_ops;
94581 static int ip6gre_tunnel_init(struct net_device *dev);
94582 static void ip6gre_tunnel_setup(struct net_device *dev);
94583 static void ip6gre_tunnel_link(struct ip6gre_net *ign, struct ip6_tnl *t);
94584 @@ -1286,7 +1286,7 @@ static void ip6gre_fb_tunnel_init(struct net_device *dev)
94585 }
94586
94587
94588 -static struct inet6_protocol ip6gre_protocol __read_mostly = {
94589 +static struct inet6_protocol ip6gre_protocol = {
94590 .handler = ip6gre_rcv,
94591 .err_handler = ip6gre_err,
94592 .flags = INET6_PROTO_NOPOLICY|INET6_PROTO_FINAL,
94593 @@ -1622,7 +1622,7 @@ static const struct nla_policy ip6gre_policy[IFLA_GRE_MAX + 1] = {
94594 [IFLA_GRE_FLAGS] = { .type = NLA_U32 },
94595 };
94596
94597 -static struct rtnl_link_ops ip6gre_link_ops __read_mostly = {
94598 +static struct rtnl_link_ops ip6gre_link_ops = {
94599 .kind = "ip6gre",
94600 .maxtype = IFLA_GRE_MAX,
94601 .policy = ip6gre_policy,
94602 @@ -1635,7 +1635,7 @@ static struct rtnl_link_ops ip6gre_link_ops __read_mostly = {
94603 .fill_info = ip6gre_fill_info,
94604 };
94605
94606 -static struct rtnl_link_ops ip6gre_tap_ops __read_mostly = {
94607 +static struct rtnl_link_ops ip6gre_tap_ops = {
94608 .kind = "ip6gretap",
94609 .maxtype = IFLA_GRE_MAX,
94610 .policy = ip6gre_policy,
94611 diff --git a/net/ipv6/ip6_tunnel.c b/net/ipv6/ip6_tunnel.c
94612 index c1e11b5..568e633 100644
94613 --- a/net/ipv6/ip6_tunnel.c
94614 +++ b/net/ipv6/ip6_tunnel.c
94615 @@ -89,7 +89,7 @@ static u32 HASH(const struct in6_addr *addr1, const struct in6_addr *addr2)
94616
94617 static int ip6_tnl_dev_init(struct net_device *dev);
94618 static void ip6_tnl_dev_setup(struct net_device *dev);
94619 -static struct rtnl_link_ops ip6_link_ops __read_mostly;
94620 +static struct rtnl_link_ops ip6_link_ops;
94621
94622 static int ip6_tnl_net_id __read_mostly;
94623 struct ip6_tnl_net {
94624 @@ -1699,7 +1699,7 @@ static const struct nla_policy ip6_tnl_policy[IFLA_IPTUN_MAX + 1] = {
94625 [IFLA_IPTUN_PROTO] = { .type = NLA_U8 },
94626 };
94627
94628 -static struct rtnl_link_ops ip6_link_ops __read_mostly = {
94629 +static struct rtnl_link_ops ip6_link_ops = {
94630 .kind = "ip6tnl",
94631 .maxtype = IFLA_IPTUN_MAX,
94632 .policy = ip6_tnl_policy,
94633 diff --git a/net/ipv6/ipv6_sockglue.c b/net/ipv6/ipv6_sockglue.c
94634 index d1e2e8e..51c19ae 100644
94635 --- a/net/ipv6/ipv6_sockglue.c
94636 +++ b/net/ipv6/ipv6_sockglue.c
94637 @@ -991,7 +991,7 @@ static int do_ipv6_getsockopt(struct sock *sk, int level, int optname,
94638 if (sk->sk_type != SOCK_STREAM)
94639 return -ENOPROTOOPT;
94640
94641 - msg.msg_control = optval;
94642 + msg.msg_control = (void __force_kernel *)optval;
94643 msg.msg_controllen = len;
94644 msg.msg_flags = flags;
94645
94646 diff --git a/net/ipv6/netfilter/ip6_tables.c b/net/ipv6/netfilter/ip6_tables.c
94647 index 44400c2..8e11f52 100644
94648 --- a/net/ipv6/netfilter/ip6_tables.c
94649 +++ b/net/ipv6/netfilter/ip6_tables.c
94650 @@ -1078,14 +1078,14 @@ static int compat_table_info(const struct xt_table_info *info,
94651 #endif
94652
94653 static int get_info(struct net *net, void __user *user,
94654 - const int *len, int compat)
94655 + int len, int compat)
94656 {
94657 char name[XT_TABLE_MAXNAMELEN];
94658 struct xt_table *t;
94659 int ret;
94660
94661 - if (*len != sizeof(struct ip6t_getinfo)) {
94662 - duprintf("length %u != %zu\n", *len,
94663 + if (len != sizeof(struct ip6t_getinfo)) {
94664 + duprintf("length %u != %zu\n", len,
94665 sizeof(struct ip6t_getinfo));
94666 return -EINVAL;
94667 }
94668 @@ -1122,7 +1122,7 @@ static int get_info(struct net *net, void __user *user,
94669 info.size = private->size;
94670 strcpy(info.name, name);
94671
94672 - if (copy_to_user(user, &info, *len) != 0)
94673 + if (copy_to_user(user, &info, len) != 0)
94674 ret = -EFAULT;
94675 else
94676 ret = 0;
94677 @@ -1976,7 +1976,7 @@ compat_do_ip6t_get_ctl(struct sock *sk, int cmd, void __user *user, int *len)
94678
94679 switch (cmd) {
94680 case IP6T_SO_GET_INFO:
94681 - ret = get_info(sock_net(sk), user, len, 1);
94682 + ret = get_info(sock_net(sk), user, *len, 1);
94683 break;
94684 case IP6T_SO_GET_ENTRIES:
94685 ret = compat_get_entries(sock_net(sk), user, len);
94686 @@ -2023,7 +2023,7 @@ do_ip6t_get_ctl(struct sock *sk, int cmd, void __user *user, int *len)
94687
94688 switch (cmd) {
94689 case IP6T_SO_GET_INFO:
94690 - ret = get_info(sock_net(sk), user, len, 0);
94691 + ret = get_info(sock_net(sk), user, *len, 0);
94692 break;
94693
94694 case IP6T_SO_GET_ENTRIES:
94695 diff --git a/net/ipv6/netfilter/nf_conntrack_reasm.c b/net/ipv6/netfilter/nf_conntrack_reasm.c
94696 index 253566a..9fa50c7 100644
94697 --- a/net/ipv6/netfilter/nf_conntrack_reasm.c
94698 +++ b/net/ipv6/netfilter/nf_conntrack_reasm.c
94699 @@ -90,12 +90,11 @@ static struct ctl_table nf_ct_frag6_sysctl_table[] = {
94700
94701 static int nf_ct_frag6_sysctl_register(struct net *net)
94702 {
94703 - struct ctl_table *table;
94704 + ctl_table_no_const *table = NULL;
94705 struct ctl_table_header *hdr;
94706
94707 - table = nf_ct_frag6_sysctl_table;
94708 if (!net_eq(net, &init_net)) {
94709 - table = kmemdup(table, sizeof(nf_ct_frag6_sysctl_table),
94710 + table = kmemdup(nf_ct_frag6_sysctl_table, sizeof(nf_ct_frag6_sysctl_table),
94711 GFP_KERNEL);
94712 if (table == NULL)
94713 goto err_alloc;
94714 @@ -103,9 +102,9 @@ static int nf_ct_frag6_sysctl_register(struct net *net)
94715 table[0].data = &net->nf_frag.frags.timeout;
94716 table[1].data = &net->nf_frag.frags.low_thresh;
94717 table[2].data = &net->nf_frag.frags.high_thresh;
94718 - }
94719 -
94720 - hdr = register_net_sysctl(net, "net/netfilter", table);
94721 + hdr = register_net_sysctl(net, "net/netfilter", table);
94722 + } else
94723 + hdr = register_net_sysctl(net, "net/netfilter", nf_ct_frag6_sysctl_table);
94724 if (hdr == NULL)
94725 goto err_reg;
94726
94727 @@ -113,8 +112,7 @@ static int nf_ct_frag6_sysctl_register(struct net *net)
94728 return 0;
94729
94730 err_reg:
94731 - if (!net_eq(net, &init_net))
94732 - kfree(table);
94733 + kfree(table);
94734 err_alloc:
94735 return -ENOMEM;
94736 }
94737 diff --git a/net/ipv6/output_core.c b/net/ipv6/output_core.c
94738 index 827f795..7e28e82 100644
94739 --- a/net/ipv6/output_core.c
94740 +++ b/net/ipv6/output_core.c
94741 @@ -9,8 +9,8 @@
94742
94743 void ipv6_select_ident(struct frag_hdr *fhdr, struct rt6_info *rt)
94744 {
94745 - static atomic_t ipv6_fragmentation_id;
94746 - int old, new;
94747 + static atomic_unchecked_t ipv6_fragmentation_id;
94748 + int id;
94749
94750 #if IS_ENABLED(CONFIG_IPV6)
94751 if (rt && !(rt->dst.flags & DST_NOPEER)) {
94752 @@ -26,13 +26,10 @@ void ipv6_select_ident(struct frag_hdr *fhdr, struct rt6_info *rt)
94753 }
94754 }
94755 #endif
94756 - do {
94757 - old = atomic_read(&ipv6_fragmentation_id);
94758 - new = old + 1;
94759 - if (!new)
94760 - new = 1;
94761 - } while (atomic_cmpxchg(&ipv6_fragmentation_id, old, new) != old);
94762 - fhdr->identification = htonl(new);
94763 + id = atomic_inc_return_unchecked(&ipv6_fragmentation_id);
94764 + if (!id)
94765 + id = atomic_inc_return_unchecked(&ipv6_fragmentation_id);
94766 + fhdr->identification = htonl(id);
94767 }
94768 EXPORT_SYMBOL(ipv6_select_ident);
94769
94770 diff --git a/net/ipv6/ping.c b/net/ipv6/ping.c
94771 index 7856e96..75ebc7f 100644
94772 --- a/net/ipv6/ping.c
94773 +++ b/net/ipv6/ping.c
94774 @@ -246,6 +246,22 @@ static struct pernet_operations ping_v6_net_ops = {
94775 };
94776 #endif
94777
94778 +static struct pingv6_ops real_pingv6_ops = {
94779 + .ipv6_recv_error = ipv6_recv_error,
94780 + .ip6_datagram_recv_ctl = ip6_datagram_recv_ctl,
94781 + .icmpv6_err_convert = icmpv6_err_convert,
94782 + .ipv6_icmp_error = ipv6_icmp_error,
94783 + .ipv6_chk_addr = ipv6_chk_addr,
94784 +};
94785 +
94786 +static struct pingv6_ops dummy_pingv6_ops = {
94787 + .ipv6_recv_error = dummy_ipv6_recv_error,
94788 + .ip6_datagram_recv_ctl = dummy_ip6_datagram_recv_ctl,
94789 + .icmpv6_err_convert = dummy_icmpv6_err_convert,
94790 + .ipv6_icmp_error = dummy_ipv6_icmp_error,
94791 + .ipv6_chk_addr = dummy_ipv6_chk_addr,
94792 +};
94793 +
94794 int __init pingv6_init(void)
94795 {
94796 #ifdef CONFIG_PROC_FS
94797 @@ -253,11 +269,7 @@ int __init pingv6_init(void)
94798 if (ret)
94799 return ret;
94800 #endif
94801 - pingv6_ops.ipv6_recv_error = ipv6_recv_error;
94802 - pingv6_ops.ip6_datagram_recv_ctl = ip6_datagram_recv_ctl;
94803 - pingv6_ops.icmpv6_err_convert = icmpv6_err_convert;
94804 - pingv6_ops.ipv6_icmp_error = ipv6_icmp_error;
94805 - pingv6_ops.ipv6_chk_addr = ipv6_chk_addr;
94806 + pingv6_ops = &real_pingv6_ops;
94807 return inet6_register_protosw(&pingv6_protosw);
94808 }
94809
94810 @@ -266,11 +278,7 @@ int __init pingv6_init(void)
94811 */
94812 void pingv6_exit(void)
94813 {
94814 - pingv6_ops.ipv6_recv_error = dummy_ipv6_recv_error;
94815 - pingv6_ops.ip6_datagram_recv_ctl = dummy_ip6_datagram_recv_ctl;
94816 - pingv6_ops.icmpv6_err_convert = dummy_icmpv6_err_convert;
94817 - pingv6_ops.ipv6_icmp_error = dummy_ipv6_icmp_error;
94818 - pingv6_ops.ipv6_chk_addr = dummy_ipv6_chk_addr;
94819 + pingv6_ops = &dummy_pingv6_ops;
94820 #ifdef CONFIG_PROC_FS
94821 unregister_pernet_subsys(&ping_v6_net_ops);
94822 #endif
94823 diff --git a/net/ipv6/raw.c b/net/ipv6/raw.c
94824 index 430067c..4adf088 100644
94825 --- a/net/ipv6/raw.c
94826 +++ b/net/ipv6/raw.c
94827 @@ -385,7 +385,7 @@ static inline int rawv6_rcv_skb(struct sock *sk, struct sk_buff *skb)
94828 {
94829 if ((raw6_sk(sk)->checksum || rcu_access_pointer(sk->sk_filter)) &&
94830 skb_checksum_complete(skb)) {
94831 - atomic_inc(&sk->sk_drops);
94832 + atomic_inc_unchecked(&sk->sk_drops);
94833 kfree_skb(skb);
94834 return NET_RX_DROP;
94835 }
94836 @@ -413,7 +413,7 @@ int rawv6_rcv(struct sock *sk, struct sk_buff *skb)
94837 struct raw6_sock *rp = raw6_sk(sk);
94838
94839 if (!xfrm6_policy_check(sk, XFRM_POLICY_IN, skb)) {
94840 - atomic_inc(&sk->sk_drops);
94841 + atomic_inc_unchecked(&sk->sk_drops);
94842 kfree_skb(skb);
94843 return NET_RX_DROP;
94844 }
94845 @@ -437,7 +437,7 @@ int rawv6_rcv(struct sock *sk, struct sk_buff *skb)
94846
94847 if (inet->hdrincl) {
94848 if (skb_checksum_complete(skb)) {
94849 - atomic_inc(&sk->sk_drops);
94850 + atomic_inc_unchecked(&sk->sk_drops);
94851 kfree_skb(skb);
94852 return NET_RX_DROP;
94853 }
94854 @@ -607,7 +607,7 @@ out:
94855 return err;
94856 }
94857
94858 -static int rawv6_send_hdrinc(struct sock *sk, void *from, int length,
94859 +static int rawv6_send_hdrinc(struct sock *sk, void *from, unsigned int length,
94860 struct flowi6 *fl6, struct dst_entry **dstp,
94861 unsigned int flags)
94862 {
94863 @@ -920,12 +920,15 @@ do_confirm:
94864 static int rawv6_seticmpfilter(struct sock *sk, int level, int optname,
94865 char __user *optval, int optlen)
94866 {
94867 + struct icmp6_filter filter;
94868 +
94869 switch (optname) {
94870 case ICMPV6_FILTER:
94871 if (optlen > sizeof(struct icmp6_filter))
94872 optlen = sizeof(struct icmp6_filter);
94873 - if (copy_from_user(&raw6_sk(sk)->filter, optval, optlen))
94874 + if (copy_from_user(&filter, optval, optlen))
94875 return -EFAULT;
94876 + raw6_sk(sk)->filter = filter;
94877 return 0;
94878 default:
94879 return -ENOPROTOOPT;
94880 @@ -938,6 +941,7 @@ static int rawv6_geticmpfilter(struct sock *sk, int level, int optname,
94881 char __user *optval, int __user *optlen)
94882 {
94883 int len;
94884 + struct icmp6_filter filter;
94885
94886 switch (optname) {
94887 case ICMPV6_FILTER:
94888 @@ -949,7 +953,8 @@ static int rawv6_geticmpfilter(struct sock *sk, int level, int optname,
94889 len = sizeof(struct icmp6_filter);
94890 if (put_user(len, optlen))
94891 return -EFAULT;
94892 - if (copy_to_user(optval, &raw6_sk(sk)->filter, len))
94893 + filter = raw6_sk(sk)->filter;
94894 + if (len > sizeof filter || copy_to_user(optval, &filter, len))
94895 return -EFAULT;
94896 return 0;
94897 default:
94898 diff --git a/net/ipv6/reassembly.c b/net/ipv6/reassembly.c
94899 index 1aeb473..bea761c 100644
94900 --- a/net/ipv6/reassembly.c
94901 +++ b/net/ipv6/reassembly.c
94902 @@ -626,12 +626,11 @@ static struct ctl_table ip6_frags_ctl_table[] = {
94903
94904 static int __net_init ip6_frags_ns_sysctl_register(struct net *net)
94905 {
94906 - struct ctl_table *table;
94907 + ctl_table_no_const *table = NULL;
94908 struct ctl_table_header *hdr;
94909
94910 - table = ip6_frags_ns_ctl_table;
94911 if (!net_eq(net, &init_net)) {
94912 - table = kmemdup(table, sizeof(ip6_frags_ns_ctl_table), GFP_KERNEL);
94913 + table = kmemdup(ip6_frags_ns_ctl_table, sizeof(ip6_frags_ns_ctl_table), GFP_KERNEL);
94914 if (table == NULL)
94915 goto err_alloc;
94916
94917 @@ -642,9 +641,10 @@ static int __net_init ip6_frags_ns_sysctl_register(struct net *net)
94918 /* Don't export sysctls to unprivileged users */
94919 if (net->user_ns != &init_user_ns)
94920 table[0].procname = NULL;
94921 - }
94922 + hdr = register_net_sysctl(net, "net/ipv6", table);
94923 + } else
94924 + hdr = register_net_sysctl(net, "net/ipv6", ip6_frags_ns_ctl_table);
94925
94926 - hdr = register_net_sysctl(net, "net/ipv6", table);
94927 if (hdr == NULL)
94928 goto err_reg;
94929
94930 @@ -652,8 +652,7 @@ static int __net_init ip6_frags_ns_sysctl_register(struct net *net)
94931 return 0;
94932
94933 err_reg:
94934 - if (!net_eq(net, &init_net))
94935 - kfree(table);
94936 + kfree(table);
94937 err_alloc:
94938 return -ENOMEM;
94939 }
94940 diff --git a/net/ipv6/route.c b/net/ipv6/route.c
94941 index 77308af..36ed509 100644
94942 --- a/net/ipv6/route.c
94943 +++ b/net/ipv6/route.c
94944 @@ -3009,7 +3009,7 @@ struct ctl_table ipv6_route_table_template[] = {
94945
94946 struct ctl_table * __net_init ipv6_route_sysctl_init(struct net *net)
94947 {
94948 - struct ctl_table *table;
94949 + ctl_table_no_const *table;
94950
94951 table = kmemdup(ipv6_route_table_template,
94952 sizeof(ipv6_route_table_template),
94953 diff --git a/net/ipv6/sit.c b/net/ipv6/sit.c
94954 index b433884..3875266 100644
94955 --- a/net/ipv6/sit.c
94956 +++ b/net/ipv6/sit.c
94957 @@ -74,7 +74,7 @@ static void ipip6_tunnel_setup(struct net_device *dev);
94958 static void ipip6_dev_free(struct net_device *dev);
94959 static bool check_6rd(struct ip_tunnel *tunnel, const struct in6_addr *v6dst,
94960 __be32 *v4dst);
94961 -static struct rtnl_link_ops sit_link_ops __read_mostly;
94962 +static struct rtnl_link_ops sit_link_ops;
94963
94964 static int sit_net_id __read_mostly;
94965 struct sit_net {
94966 @@ -1603,7 +1603,7 @@ static void ipip6_dellink(struct net_device *dev, struct list_head *head)
94967 unregister_netdevice_queue(dev, head);
94968 }
94969
94970 -static struct rtnl_link_ops sit_link_ops __read_mostly = {
94971 +static struct rtnl_link_ops sit_link_ops = {
94972 .kind = "sit",
94973 .maxtype = IFLA_IPTUN_MAX,
94974 .policy = ipip6_policy,
94975 diff --git a/net/ipv6/sysctl_net_ipv6.c b/net/ipv6/sysctl_net_ipv6.c
94976 index 107b2f1..72741a9 100644
94977 --- a/net/ipv6/sysctl_net_ipv6.c
94978 +++ b/net/ipv6/sysctl_net_ipv6.c
94979 @@ -40,7 +40,7 @@ static struct ctl_table ipv6_rotable[] = {
94980
94981 static int __net_init ipv6_sysctl_net_init(struct net *net)
94982 {
94983 - struct ctl_table *ipv6_table;
94984 + ctl_table_no_const *ipv6_table;
94985 struct ctl_table *ipv6_route_table;
94986 struct ctl_table *ipv6_icmp_table;
94987 int err;
94988 diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c
94989 index 5c71501..7e8d5d3 100644
94990 --- a/net/ipv6/tcp_ipv6.c
94991 +++ b/net/ipv6/tcp_ipv6.c
94992 @@ -104,6 +104,10 @@ static void inet6_sk_rx_dst_set(struct sock *sk, const struct sk_buff *skb)
94993 inet6_sk(sk)->rx_dst_cookie = rt->rt6i_node->fn_sernum;
94994 }
94995
94996 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
94997 +extern int grsec_enable_blackhole;
94998 +#endif
94999 +
95000 static void tcp_v6_hash(struct sock *sk)
95001 {
95002 if (sk->sk_state != TCP_CLOSE) {
95003 @@ -1397,6 +1401,9 @@ static int tcp_v6_do_rcv(struct sock *sk, struct sk_buff *skb)
95004 return 0;
95005
95006 reset:
95007 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
95008 + if (!grsec_enable_blackhole)
95009 +#endif
95010 tcp_v6_send_reset(sk, skb);
95011 discard:
95012 if (opt_skb)
95013 @@ -1479,12 +1486,20 @@ static int tcp_v6_rcv(struct sk_buff *skb)
95014 TCP_SKB_CB(skb)->sacked = 0;
95015
95016 sk = __inet6_lookup_skb(&tcp_hashinfo, skb, th->source, th->dest);
95017 - if (!sk)
95018 + if (!sk) {
95019 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
95020 + ret = 1;
95021 +#endif
95022 goto no_tcp_socket;
95023 + }
95024
95025 process:
95026 - if (sk->sk_state == TCP_TIME_WAIT)
95027 + if (sk->sk_state == TCP_TIME_WAIT) {
95028 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
95029 + ret = 2;
95030 +#endif
95031 goto do_time_wait;
95032 + }
95033
95034 if (hdr->hop_limit < inet6_sk(sk)->min_hopcount) {
95035 NET_INC_STATS_BH(net, LINUX_MIB_TCPMINTTLDROP);
95036 @@ -1536,6 +1551,10 @@ csum_error:
95037 bad_packet:
95038 TCP_INC_STATS_BH(net, TCP_MIB_INERRS);
95039 } else {
95040 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
95041 + if (!grsec_enable_blackhole || (ret == 1 &&
95042 + (skb->dev->flags & IFF_LOOPBACK)))
95043 +#endif
95044 tcp_v6_send_reset(NULL, skb);
95045 }
95046
95047 diff --git a/net/ipv6/udp.c b/net/ipv6/udp.c
95048 index 3d2758d..626c422 100644
95049 --- a/net/ipv6/udp.c
95050 +++ b/net/ipv6/udp.c
95051 @@ -53,6 +53,10 @@
95052 #include <trace/events/skb.h>
95053 #include "udp_impl.h"
95054
95055 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
95056 +extern int grsec_enable_blackhole;
95057 +#endif
95058 +
95059 int ipv6_rcv_saddr_equal(const struct sock *sk, const struct sock *sk2)
95060 {
95061 const struct in6_addr *sk_rcv_saddr6 = &inet6_sk(sk)->rcv_saddr;
95062 @@ -417,7 +421,7 @@ try_again:
95063 if (unlikely(err)) {
95064 trace_kfree_skb(skb, udpv6_recvmsg);
95065 if (!peeked) {
95066 - atomic_inc(&sk->sk_drops);
95067 + atomic_inc_unchecked(&sk->sk_drops);
95068 if (is_udp4)
95069 UDP_INC_STATS_USER(sock_net(sk),
95070 UDP_MIB_INERRORS,
95071 @@ -665,7 +669,7 @@ csum_error:
95072 UDP6_INC_STATS_BH(sock_net(sk), UDP_MIB_CSUMERRORS, is_udplite);
95073 drop:
95074 UDP6_INC_STATS_BH(sock_net(sk), UDP_MIB_INERRORS, is_udplite);
95075 - atomic_inc(&sk->sk_drops);
95076 + atomic_inc_unchecked(&sk->sk_drops);
95077 kfree_skb(skb);
95078 return -1;
95079 }
95080 @@ -723,7 +727,7 @@ static void flush_stack(struct sock **stack, unsigned int count,
95081 if (likely(skb1 == NULL))
95082 skb1 = (i == final) ? skb : skb_clone(skb, GFP_ATOMIC);
95083 if (!skb1) {
95084 - atomic_inc(&sk->sk_drops);
95085 + atomic_inc_unchecked(&sk->sk_drops);
95086 UDP6_INC_STATS_BH(sock_net(sk), UDP_MIB_RCVBUFERRORS,
95087 IS_UDPLITE(sk));
95088 UDP6_INC_STATS_BH(sock_net(sk), UDP_MIB_INERRORS,
95089 @@ -863,6 +867,9 @@ int __udp6_lib_rcv(struct sk_buff *skb, struct udp_table *udptable,
95090 goto csum_error;
95091
95092 UDP6_INC_STATS_BH(net, UDP_MIB_NOPORTS, proto == IPPROTO_UDPLITE);
95093 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
95094 + if (!grsec_enable_blackhole || (skb->dev->flags & IFF_LOOPBACK))
95095 +#endif
95096 icmpv6_send(skb, ICMPV6_DEST_UNREACH, ICMPV6_PORT_UNREACH, 0);
95097
95098 kfree_skb(skb);
95099 diff --git a/net/ipv6/xfrm6_policy.c b/net/ipv6/xfrm6_policy.c
95100 index 550b195..6acea83 100644
95101 --- a/net/ipv6/xfrm6_policy.c
95102 +++ b/net/ipv6/xfrm6_policy.c
95103 @@ -212,11 +212,11 @@ _decode_session6(struct sk_buff *skb, struct flowi *fl, int reverse)
95104 }
95105 }
95106
95107 -static inline int xfrm6_garbage_collect(struct dst_ops *ops)
95108 +static int xfrm6_garbage_collect(struct dst_ops *ops)
95109 {
95110 struct net *net = container_of(ops, struct net, xfrm.xfrm6_dst_ops);
95111
95112 - xfrm6_policy_afinfo.garbage_collect(net);
95113 + xfrm_garbage_collect_deferred(net);
95114 return dst_entries_get_fast(ops) > ops->gc_thresh * 2;
95115 }
95116
95117 @@ -329,19 +329,19 @@ static struct ctl_table xfrm6_policy_table[] = {
95118
95119 static int __net_init xfrm6_net_init(struct net *net)
95120 {
95121 - struct ctl_table *table;
95122 + ctl_table_no_const *table = NULL;
95123 struct ctl_table_header *hdr;
95124
95125 - table = xfrm6_policy_table;
95126 if (!net_eq(net, &init_net)) {
95127 - table = kmemdup(table, sizeof(xfrm6_policy_table), GFP_KERNEL);
95128 + table = kmemdup(xfrm6_policy_table, sizeof(xfrm6_policy_table), GFP_KERNEL);
95129 if (!table)
95130 goto err_alloc;
95131
95132 table[0].data = &net->xfrm.xfrm6_dst_ops.gc_thresh;
95133 - }
95134 + hdr = register_net_sysctl(net, "net/ipv6", table);
95135 + } else
95136 + hdr = register_net_sysctl(net, "net/ipv6", xfrm6_policy_table);
95137
95138 - hdr = register_net_sysctl(net, "net/ipv6", table);
95139 if (!hdr)
95140 goto err_reg;
95141
95142 @@ -349,8 +349,7 @@ static int __net_init xfrm6_net_init(struct net *net)
95143 return 0;
95144
95145 err_reg:
95146 - if (!net_eq(net, &init_net))
95147 - kfree(table);
95148 + kfree(table);
95149 err_alloc:
95150 return -ENOMEM;
95151 }
95152 diff --git a/net/irda/ircomm/ircomm_tty.c b/net/irda/ircomm/ircomm_tty.c
95153 index 41ac7938..75e3bb1 100644
95154 --- a/net/irda/ircomm/ircomm_tty.c
95155 +++ b/net/irda/ircomm/ircomm_tty.c
95156 @@ -319,11 +319,11 @@ static int ircomm_tty_block_til_ready(struct ircomm_tty_cb *self,
95157 add_wait_queue(&port->open_wait, &wait);
95158
95159 IRDA_DEBUG(2, "%s(%d):block_til_ready before block on %s open_count=%d\n",
95160 - __FILE__, __LINE__, tty->driver->name, port->count);
95161 + __FILE__, __LINE__, tty->driver->name, atomic_read(&port->count));
95162
95163 spin_lock_irqsave(&port->lock, flags);
95164 if (!tty_hung_up_p(filp))
95165 - port->count--;
95166 + atomic_dec(&port->count);
95167 port->blocked_open++;
95168 spin_unlock_irqrestore(&port->lock, flags);
95169
95170 @@ -358,7 +358,7 @@ static int ircomm_tty_block_til_ready(struct ircomm_tty_cb *self,
95171 }
95172
95173 IRDA_DEBUG(1, "%s(%d):block_til_ready blocking on %s open_count=%d\n",
95174 - __FILE__, __LINE__, tty->driver->name, port->count);
95175 + __FILE__, __LINE__, tty->driver->name, atomic_read(&port->count));
95176
95177 schedule();
95178 }
95179 @@ -368,12 +368,12 @@ static int ircomm_tty_block_til_ready(struct ircomm_tty_cb *self,
95180
95181 spin_lock_irqsave(&port->lock, flags);
95182 if (!tty_hung_up_p(filp))
95183 - port->count++;
95184 + atomic_inc(&port->count);
95185 port->blocked_open--;
95186 spin_unlock_irqrestore(&port->lock, flags);
95187
95188 IRDA_DEBUG(1, "%s(%d):block_til_ready after blocking on %s open_count=%d\n",
95189 - __FILE__, __LINE__, tty->driver->name, port->count);
95190 + __FILE__, __LINE__, tty->driver->name, atomic_read(&port->count));
95191
95192 if (!retval)
95193 port->flags |= ASYNC_NORMAL_ACTIVE;
95194 @@ -447,12 +447,12 @@ static int ircomm_tty_open(struct tty_struct *tty, struct file *filp)
95195
95196 /* ++ is not atomic, so this should be protected - Jean II */
95197 spin_lock_irqsave(&self->port.lock, flags);
95198 - self->port.count++;
95199 + atomic_inc(&self->port.count);
95200 spin_unlock_irqrestore(&self->port.lock, flags);
95201 tty_port_tty_set(&self->port, tty);
95202
95203 IRDA_DEBUG(1, "%s(), %s%d, count = %d\n", __func__ , tty->driver->name,
95204 - self->line, self->port.count);
95205 + self->line, atomic_read(&self->port.count));
95206
95207 /* Not really used by us, but lets do it anyway */
95208 self->port.low_latency = (self->port.flags & ASYNC_LOW_LATENCY) ? 1 : 0;
95209 @@ -989,7 +989,7 @@ static void ircomm_tty_hangup(struct tty_struct *tty)
95210 tty_kref_put(port->tty);
95211 }
95212 port->tty = NULL;
95213 - port->count = 0;
95214 + atomic_set(&port->count, 0);
95215 spin_unlock_irqrestore(&port->lock, flags);
95216
95217 wake_up_interruptible(&port->open_wait);
95218 @@ -1346,7 +1346,7 @@ static void ircomm_tty_line_info(struct ircomm_tty_cb *self, struct seq_file *m)
95219 seq_putc(m, '\n');
95220
95221 seq_printf(m, "Role: %s\n", self->client ? "client" : "server");
95222 - seq_printf(m, "Open count: %d\n", self->port.count);
95223 + seq_printf(m, "Open count: %d\n", atomic_read(&self->port.count));
95224 seq_printf(m, "Max data size: %d\n", self->max_data_size);
95225 seq_printf(m, "Max header size: %d\n", self->max_header_size);
95226
95227 diff --git a/net/iucv/af_iucv.c b/net/iucv/af_iucv.c
95228 index c4b7218..3e83259 100644
95229 --- a/net/iucv/af_iucv.c
95230 +++ b/net/iucv/af_iucv.c
95231 @@ -773,10 +773,10 @@ static int iucv_sock_autobind(struct sock *sk)
95232
95233 write_lock_bh(&iucv_sk_list.lock);
95234
95235 - sprintf(name, "%08x", atomic_inc_return(&iucv_sk_list.autobind_name));
95236 + sprintf(name, "%08x", atomic_inc_return_unchecked(&iucv_sk_list.autobind_name));
95237 while (__iucv_get_sock_by_name(name)) {
95238 sprintf(name, "%08x",
95239 - atomic_inc_return(&iucv_sk_list.autobind_name));
95240 + atomic_inc_return_unchecked(&iucv_sk_list.autobind_name));
95241 }
95242
95243 write_unlock_bh(&iucv_sk_list.lock);
95244 diff --git a/net/iucv/iucv.c b/net/iucv/iucv.c
95245 index cd5b8ec..f205e6b 100644
95246 --- a/net/iucv/iucv.c
95247 +++ b/net/iucv/iucv.c
95248 @@ -690,7 +690,7 @@ static int iucv_cpu_notify(struct notifier_block *self,
95249 return NOTIFY_OK;
95250 }
95251
95252 -static struct notifier_block __refdata iucv_cpu_notifier = {
95253 +static struct notifier_block iucv_cpu_notifier = {
95254 .notifier_call = iucv_cpu_notify,
95255 };
95256
95257 diff --git a/net/key/af_key.c b/net/key/af_key.c
95258 index 545f047..9757a9d 100644
95259 --- a/net/key/af_key.c
95260 +++ b/net/key/af_key.c
95261 @@ -3041,10 +3041,10 @@ static int pfkey_send_policy_notify(struct xfrm_policy *xp, int dir, const struc
95262 static u32 get_acqseq(void)
95263 {
95264 u32 res;
95265 - static atomic_t acqseq;
95266 + static atomic_unchecked_t acqseq;
95267
95268 do {
95269 - res = atomic_inc_return(&acqseq);
95270 + res = atomic_inc_return_unchecked(&acqseq);
95271 } while (!res);
95272 return res;
95273 }
95274 diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c
95275 index 629dee7..4bdd2c8 100644
95276 --- a/net/mac80211/cfg.c
95277 +++ b/net/mac80211/cfg.c
95278 @@ -826,7 +826,7 @@ static int ieee80211_set_monitor_channel(struct wiphy *wiphy,
95279 ret = ieee80211_vif_use_channel(sdata, chandef,
95280 IEEE80211_CHANCTX_EXCLUSIVE);
95281 }
95282 - } else if (local->open_count == local->monitors) {
95283 + } else if (local_read(&local->open_count) == local->monitors) {
95284 local->_oper_chandef = *chandef;
95285 ieee80211_hw_config(local, 0);
95286 }
95287 @@ -3125,7 +3125,7 @@ static void ieee80211_mgmt_frame_register(struct wiphy *wiphy,
95288 else
95289 local->probe_req_reg--;
95290
95291 - if (!local->open_count)
95292 + if (!local_read(&local->open_count))
95293 break;
95294
95295 ieee80211_queue_work(&local->hw, &local->reconfig_filter);
95296 @@ -3588,8 +3588,8 @@ static int ieee80211_cfg_get_channel(struct wiphy *wiphy,
95297 if (chanctx_conf) {
95298 *chandef = chanctx_conf->def;
95299 ret = 0;
95300 - } else if (local->open_count > 0 &&
95301 - local->open_count == local->monitors &&
95302 + } else if (local_read(&local->open_count) > 0 &&
95303 + local_read(&local->open_count) == local->monitors &&
95304 sdata->vif.type == NL80211_IFTYPE_MONITOR) {
95305 if (local->use_chanctx)
95306 *chandef = local->monitor_chandef;
95307 diff --git a/net/mac80211/ieee80211_i.h b/net/mac80211/ieee80211_i.h
95308 index 611abfc..8c2c7e4 100644
95309 --- a/net/mac80211/ieee80211_i.h
95310 +++ b/net/mac80211/ieee80211_i.h
95311 @@ -28,6 +28,7 @@
95312 #include <net/ieee80211_radiotap.h>
95313 #include <net/cfg80211.h>
95314 #include <net/mac80211.h>
95315 +#include <asm/local.h>
95316 #include "key.h"
95317 #include "sta_info.h"
95318 #include "debug.h"
95319 @@ -945,7 +946,7 @@ struct ieee80211_local {
95320 /* also used to protect ampdu_ac_queue and amdpu_ac_stop_refcnt */
95321 spinlock_t queue_stop_reason_lock;
95322
95323 - int open_count;
95324 + local_t open_count;
95325 int monitors, cooked_mntrs;
95326 /* number of interfaces with corresponding FIF_ flags */
95327 int fif_fcsfail, fif_plcpfail, fif_control, fif_other_bss, fif_pspoll,
95328 diff --git a/net/mac80211/iface.c b/net/mac80211/iface.c
95329 index fcecd63..a404454 100644
95330 --- a/net/mac80211/iface.c
95331 +++ b/net/mac80211/iface.c
95332 @@ -519,7 +519,7 @@ int ieee80211_do_open(struct wireless_dev *wdev, bool coming_up)
95333 break;
95334 }
95335
95336 - if (local->open_count == 0) {
95337 + if (local_read(&local->open_count) == 0) {
95338 res = drv_start(local);
95339 if (res)
95340 goto err_del_bss;
95341 @@ -566,7 +566,7 @@ int ieee80211_do_open(struct wireless_dev *wdev, bool coming_up)
95342 res = drv_add_interface(local, sdata);
95343 if (res)
95344 goto err_stop;
95345 - } else if (local->monitors == 0 && local->open_count == 0) {
95346 + } else if (local->monitors == 0 && local_read(&local->open_count) == 0) {
95347 res = ieee80211_add_virtual_monitor(local);
95348 if (res)
95349 goto err_stop;
95350 @@ -675,7 +675,7 @@ int ieee80211_do_open(struct wireless_dev *wdev, bool coming_up)
95351 atomic_inc(&local->iff_promiscs);
95352
95353 if (coming_up)
95354 - local->open_count++;
95355 + local_inc(&local->open_count);
95356
95357 if (hw_reconf_flags)
95358 ieee80211_hw_config(local, hw_reconf_flags);
95359 @@ -713,7 +713,7 @@ int ieee80211_do_open(struct wireless_dev *wdev, bool coming_up)
95360 err_del_interface:
95361 drv_remove_interface(local, sdata);
95362 err_stop:
95363 - if (!local->open_count)
95364 + if (!local_read(&local->open_count))
95365 drv_stop(local);
95366 err_del_bss:
95367 sdata->bss = NULL;
95368 @@ -852,7 +852,7 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata,
95369 }
95370
95371 if (going_down)
95372 - local->open_count--;
95373 + local_dec(&local->open_count);
95374
95375 switch (sdata->vif.type) {
95376 case NL80211_IFTYPE_AP_VLAN:
95377 @@ -919,7 +919,7 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata,
95378 }
95379 spin_unlock_irqrestore(&local->queue_stop_reason_lock, flags);
95380
95381 - if (local->open_count == 0)
95382 + if (local_read(&local->open_count) == 0)
95383 ieee80211_clear_tx_pending(local);
95384
95385 /*
95386 @@ -959,7 +959,7 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata,
95387
95388 ieee80211_recalc_ps(local, -1);
95389
95390 - if (local->open_count == 0) {
95391 + if (local_read(&local->open_count) == 0) {
95392 ieee80211_stop_device(local);
95393
95394 /* no reconfiguring after stop! */
95395 @@ -970,7 +970,7 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata,
95396 ieee80211_configure_filter(local);
95397 ieee80211_hw_config(local, hw_reconf_flags);
95398
95399 - if (local->monitors == local->open_count)
95400 + if (local->monitors == local_read(&local->open_count))
95401 ieee80211_add_virtual_monitor(local);
95402 }
95403
95404 diff --git a/net/mac80211/main.c b/net/mac80211/main.c
95405 index 21d5d44..4fee18a 100644
95406 --- a/net/mac80211/main.c
95407 +++ b/net/mac80211/main.c
95408 @@ -172,7 +172,7 @@ int ieee80211_hw_config(struct ieee80211_local *local, u32 changed)
95409 changed &= ~(IEEE80211_CONF_CHANGE_CHANNEL |
95410 IEEE80211_CONF_CHANGE_POWER);
95411
95412 - if (changed && local->open_count) {
95413 + if (changed && local_read(&local->open_count)) {
95414 ret = drv_config(local, changed);
95415 /*
95416 * Goal:
95417 diff --git a/net/mac80211/pm.c b/net/mac80211/pm.c
95418 index 3401262..d5cd68d 100644
95419 --- a/net/mac80211/pm.c
95420 +++ b/net/mac80211/pm.c
95421 @@ -12,7 +12,7 @@ int __ieee80211_suspend(struct ieee80211_hw *hw, struct cfg80211_wowlan *wowlan)
95422 struct ieee80211_sub_if_data *sdata;
95423 struct sta_info *sta;
95424
95425 - if (!local->open_count)
95426 + if (!local_read(&local->open_count))
95427 goto suspend;
95428
95429 ieee80211_scan_cancel(local);
95430 @@ -59,7 +59,7 @@ int __ieee80211_suspend(struct ieee80211_hw *hw, struct cfg80211_wowlan *wowlan)
95431 cancel_work_sync(&local->dynamic_ps_enable_work);
95432 del_timer_sync(&local->dynamic_ps_timer);
95433
95434 - local->wowlan = wowlan && local->open_count;
95435 + local->wowlan = wowlan && local_read(&local->open_count);
95436 if (local->wowlan) {
95437 int err = drv_suspend(local, wowlan);
95438 if (err < 0) {
95439 @@ -116,7 +116,7 @@ int __ieee80211_suspend(struct ieee80211_hw *hw, struct cfg80211_wowlan *wowlan)
95440 WARN_ON(!list_empty(&local->chanctx_list));
95441
95442 /* stop hardware - this must stop RX */
95443 - if (local->open_count)
95444 + if (local_read(&local->open_count))
95445 ieee80211_stop_device(local);
95446
95447 suspend:
95448 diff --git a/net/mac80211/rate.c b/net/mac80211/rate.c
95449 index e126605..73d2c39 100644
95450 --- a/net/mac80211/rate.c
95451 +++ b/net/mac80211/rate.c
95452 @@ -725,7 +725,7 @@ int ieee80211_init_rate_ctrl_alg(struct ieee80211_local *local,
95453
95454 ASSERT_RTNL();
95455
95456 - if (local->open_count)
95457 + if (local_read(&local->open_count))
95458 return -EBUSY;
95459
95460 if (local->hw.flags & IEEE80211_HW_HAS_RATE_CONTROL) {
95461 diff --git a/net/mac80211/rc80211_pid_debugfs.c b/net/mac80211/rc80211_pid_debugfs.c
95462 index c97a065..ff61928 100644
95463 --- a/net/mac80211/rc80211_pid_debugfs.c
95464 +++ b/net/mac80211/rc80211_pid_debugfs.c
95465 @@ -193,7 +193,7 @@ static ssize_t rate_control_pid_events_read(struct file *file, char __user *buf,
95466
95467 spin_unlock_irqrestore(&events->lock, status);
95468
95469 - if (copy_to_user(buf, pb, p))
95470 + if (p > sizeof(pb) || copy_to_user(buf, pb, p))
95471 return -EFAULT;
95472
95473 return p;
95474 diff --git a/net/mac80211/util.c b/net/mac80211/util.c
95475 index 69e4ef5..e8e4b92 100644
95476 --- a/net/mac80211/util.c
95477 +++ b/net/mac80211/util.c
95478 @@ -1470,7 +1470,7 @@ int ieee80211_reconfig(struct ieee80211_local *local)
95479 }
95480 #endif
95481 /* everything else happens only if HW was up & running */
95482 - if (!local->open_count)
95483 + if (!local_read(&local->open_count))
95484 goto wake_up;
95485
95486 /*
95487 @@ -1695,7 +1695,7 @@ int ieee80211_reconfig(struct ieee80211_local *local)
95488 local->in_reconfig = false;
95489 barrier();
95490
95491 - if (local->monitors == local->open_count && local->monitors > 0)
95492 + if (local->monitors == local_read(&local->open_count) && local->monitors > 0)
95493 ieee80211_add_virtual_monitor(local);
95494
95495 /*
95496 diff --git a/net/netfilter/Kconfig b/net/netfilter/Kconfig
95497 index 6e839b6..002a233 100644
95498 --- a/net/netfilter/Kconfig
95499 +++ b/net/netfilter/Kconfig
95500 @@ -950,6 +950,16 @@ config NETFILTER_XT_MATCH_ESP
95501
95502 To compile it as a module, choose M here. If unsure, say N.
95503
95504 +config NETFILTER_XT_MATCH_GRADM
95505 + tristate '"gradm" match support'
95506 + depends on NETFILTER_XTABLES && NETFILTER_ADVANCED
95507 + depends on GRKERNSEC && !GRKERNSEC_NO_RBAC
95508 + ---help---
95509 + The gradm match allows to match on grsecurity RBAC being enabled.
95510 + It is useful when iptables rules are applied early on bootup to
95511 + prevent connections to the machine (except from a trusted host)
95512 + while the RBAC system is disabled.
95513 +
95514 config NETFILTER_XT_MATCH_HASHLIMIT
95515 tristate '"hashlimit" match support'
95516 depends on (IP6_NF_IPTABLES || IP6_NF_IPTABLES=n)
95517 diff --git a/net/netfilter/Makefile b/net/netfilter/Makefile
95518 index c3a0a12..90b587f 100644
95519 --- a/net/netfilter/Makefile
95520 +++ b/net/netfilter/Makefile
95521 @@ -112,6 +112,7 @@ obj-$(CONFIG_NETFILTER_XT_MATCH_DEVGROUP) += xt_devgroup.o
95522 obj-$(CONFIG_NETFILTER_XT_MATCH_DSCP) += xt_dscp.o
95523 obj-$(CONFIG_NETFILTER_XT_MATCH_ECN) += xt_ecn.o
95524 obj-$(CONFIG_NETFILTER_XT_MATCH_ESP) += xt_esp.o
95525 +obj-$(CONFIG_NETFILTER_XT_MATCH_GRADM) += xt_gradm.o
95526 obj-$(CONFIG_NETFILTER_XT_MATCH_HASHLIMIT) += xt_hashlimit.o
95527 obj-$(CONFIG_NETFILTER_XT_MATCH_HELPER) += xt_helper.o
95528 obj-$(CONFIG_NETFILTER_XT_MATCH_HL) += xt_hl.o
95529 diff --git a/net/netfilter/ipset/ip_set_core.c b/net/netfilter/ipset/ip_set_core.c
95530 index f2e30fb..f131862 100644
95531 --- a/net/netfilter/ipset/ip_set_core.c
95532 +++ b/net/netfilter/ipset/ip_set_core.c
95533 @@ -1819,7 +1819,7 @@ done:
95534 return ret;
95535 }
95536
95537 -static struct nf_sockopt_ops so_set __read_mostly = {
95538 +static struct nf_sockopt_ops so_set = {
95539 .pf = PF_INET,
95540 .get_optmin = SO_IP_SET,
95541 .get_optmax = SO_IP_SET + 1,
95542 diff --git a/net/netfilter/ipvs/ip_vs_conn.c b/net/netfilter/ipvs/ip_vs_conn.c
95543 index 4c8e5c0..5a79b4d 100644
95544 --- a/net/netfilter/ipvs/ip_vs_conn.c
95545 +++ b/net/netfilter/ipvs/ip_vs_conn.c
95546 @@ -556,7 +556,7 @@ ip_vs_bind_dest(struct ip_vs_conn *cp, struct ip_vs_dest *dest)
95547 /* Increase the refcnt counter of the dest */
95548 ip_vs_dest_hold(dest);
95549
95550 - conn_flags = atomic_read(&dest->conn_flags);
95551 + conn_flags = atomic_read_unchecked(&dest->conn_flags);
95552 if (cp->protocol != IPPROTO_UDP)
95553 conn_flags &= ~IP_VS_CONN_F_ONE_PACKET;
95554 flags = cp->flags;
95555 @@ -900,7 +900,7 @@ ip_vs_conn_new(const struct ip_vs_conn_param *p,
95556
95557 cp->control = NULL;
95558 atomic_set(&cp->n_control, 0);
95559 - atomic_set(&cp->in_pkts, 0);
95560 + atomic_set_unchecked(&cp->in_pkts, 0);
95561
95562 cp->packet_xmit = NULL;
95563 cp->app = NULL;
95564 @@ -1188,7 +1188,7 @@ static inline int todrop_entry(struct ip_vs_conn *cp)
95565
95566 /* Don't drop the entry if its number of incoming packets is not
95567 located in [0, 8] */
95568 - i = atomic_read(&cp->in_pkts);
95569 + i = atomic_read_unchecked(&cp->in_pkts);
95570 if (i > 8 || i < 0) return 0;
95571
95572 if (!todrop_rate[i]) return 0;
95573 diff --git a/net/netfilter/ipvs/ip_vs_core.c b/net/netfilter/ipvs/ip_vs_core.c
95574 index 3581736..c0453e9 100644
95575 --- a/net/netfilter/ipvs/ip_vs_core.c
95576 +++ b/net/netfilter/ipvs/ip_vs_core.c
95577 @@ -567,7 +567,7 @@ int ip_vs_leave(struct ip_vs_service *svc, struct sk_buff *skb,
95578 ret = cp->packet_xmit(skb, cp, pd->pp, iph);
95579 /* do not touch skb anymore */
95580
95581 - atomic_inc(&cp->in_pkts);
95582 + atomic_inc_unchecked(&cp->in_pkts);
95583 ip_vs_conn_put(cp);
95584 return ret;
95585 }
95586 @@ -1706,7 +1706,7 @@ ip_vs_in(unsigned int hooknum, struct sk_buff *skb, int af)
95587 if (cp->flags & IP_VS_CONN_F_ONE_PACKET)
95588 pkts = sysctl_sync_threshold(ipvs);
95589 else
95590 - pkts = atomic_add_return(1, &cp->in_pkts);
95591 + pkts = atomic_add_return_unchecked(1, &cp->in_pkts);
95592
95593 if (ipvs->sync_state & IP_VS_STATE_MASTER)
95594 ip_vs_sync_conn(net, cp, pkts);
95595 diff --git a/net/netfilter/ipvs/ip_vs_ctl.c b/net/netfilter/ipvs/ip_vs_ctl.c
95596 index a3df9bd..895ae09 100644
95597 --- a/net/netfilter/ipvs/ip_vs_ctl.c
95598 +++ b/net/netfilter/ipvs/ip_vs_ctl.c
95599 @@ -794,7 +794,7 @@ __ip_vs_update_dest(struct ip_vs_service *svc, struct ip_vs_dest *dest,
95600 */
95601 ip_vs_rs_hash(ipvs, dest);
95602 }
95603 - atomic_set(&dest->conn_flags, conn_flags);
95604 + atomic_set_unchecked(&dest->conn_flags, conn_flags);
95605
95606 /* bind the service */
95607 old_svc = rcu_dereference_protected(dest->svc, 1);
95608 @@ -1641,7 +1641,7 @@ proc_do_sync_ports(struct ctl_table *table, int write,
95609 * align with netns init in ip_vs_control_net_init()
95610 */
95611
95612 -static struct ctl_table vs_vars[] = {
95613 +static ctl_table_no_const vs_vars[] __read_only = {
95614 {
95615 .procname = "amemthresh",
95616 .maxlen = sizeof(int),
95617 @@ -2062,7 +2062,7 @@ static int ip_vs_info_seq_show(struct seq_file *seq, void *v)
95618 " %-7s %-6d %-10d %-10d\n",
95619 &dest->addr.in6,
95620 ntohs(dest->port),
95621 - ip_vs_fwd_name(atomic_read(&dest->conn_flags)),
95622 + ip_vs_fwd_name(atomic_read_unchecked(&dest->conn_flags)),
95623 atomic_read(&dest->weight),
95624 atomic_read(&dest->activeconns),
95625 atomic_read(&dest->inactconns));
95626 @@ -2073,7 +2073,7 @@ static int ip_vs_info_seq_show(struct seq_file *seq, void *v)
95627 "%-7s %-6d %-10d %-10d\n",
95628 ntohl(dest->addr.ip),
95629 ntohs(dest->port),
95630 - ip_vs_fwd_name(atomic_read(&dest->conn_flags)),
95631 + ip_vs_fwd_name(atomic_read_unchecked(&dest->conn_flags)),
95632 atomic_read(&dest->weight),
95633 atomic_read(&dest->activeconns),
95634 atomic_read(&dest->inactconns));
95635 @@ -2551,7 +2551,7 @@ __ip_vs_get_dest_entries(struct net *net, const struct ip_vs_get_dests *get,
95636
95637 entry.addr = dest->addr.ip;
95638 entry.port = dest->port;
95639 - entry.conn_flags = atomic_read(&dest->conn_flags);
95640 + entry.conn_flags = atomic_read_unchecked(&dest->conn_flags);
95641 entry.weight = atomic_read(&dest->weight);
95642 entry.u_threshold = dest->u_threshold;
95643 entry.l_threshold = dest->l_threshold;
95644 @@ -3094,7 +3094,7 @@ static int ip_vs_genl_fill_dest(struct sk_buff *skb, struct ip_vs_dest *dest)
95645 if (nla_put(skb, IPVS_DEST_ATTR_ADDR, sizeof(dest->addr), &dest->addr) ||
95646 nla_put_be16(skb, IPVS_DEST_ATTR_PORT, dest->port) ||
95647 nla_put_u32(skb, IPVS_DEST_ATTR_FWD_METHOD,
95648 - (atomic_read(&dest->conn_flags) &
95649 + (atomic_read_unchecked(&dest->conn_flags) &
95650 IP_VS_CONN_F_FWD_MASK)) ||
95651 nla_put_u32(skb, IPVS_DEST_ATTR_WEIGHT,
95652 atomic_read(&dest->weight)) ||
95653 @@ -3684,7 +3684,7 @@ static int __net_init ip_vs_control_net_init_sysctl(struct net *net)
95654 {
95655 int idx;
95656 struct netns_ipvs *ipvs = net_ipvs(net);
95657 - struct ctl_table *tbl;
95658 + ctl_table_no_const *tbl;
95659
95660 atomic_set(&ipvs->dropentry, 0);
95661 spin_lock_init(&ipvs->dropentry_lock);
95662 diff --git a/net/netfilter/ipvs/ip_vs_lblc.c b/net/netfilter/ipvs/ip_vs_lblc.c
95663 index eff13c9..c1aab3e 100644
95664 --- a/net/netfilter/ipvs/ip_vs_lblc.c
95665 +++ b/net/netfilter/ipvs/ip_vs_lblc.c
95666 @@ -118,7 +118,7 @@ struct ip_vs_lblc_table {
95667 * IPVS LBLC sysctl table
95668 */
95669 #ifdef CONFIG_SYSCTL
95670 -static struct ctl_table vs_vars_table[] = {
95671 +static ctl_table_no_const vs_vars_table[] __read_only = {
95672 {
95673 .procname = "lblc_expiration",
95674 .data = NULL,
95675 diff --git a/net/netfilter/ipvs/ip_vs_lblcr.c b/net/netfilter/ipvs/ip_vs_lblcr.c
95676 index 0b85500..8513fa5 100644
95677 --- a/net/netfilter/ipvs/ip_vs_lblcr.c
95678 +++ b/net/netfilter/ipvs/ip_vs_lblcr.c
95679 @@ -289,7 +289,7 @@ struct ip_vs_lblcr_table {
95680 * IPVS LBLCR sysctl table
95681 */
95682
95683 -static struct ctl_table vs_vars_table[] = {
95684 +static ctl_table_no_const vs_vars_table[] __read_only = {
95685 {
95686 .procname = "lblcr_expiration",
95687 .data = NULL,
95688 diff --git a/net/netfilter/ipvs/ip_vs_sync.c b/net/netfilter/ipvs/ip_vs_sync.c
95689 index f448471..995f131 100644
95690 --- a/net/netfilter/ipvs/ip_vs_sync.c
95691 +++ b/net/netfilter/ipvs/ip_vs_sync.c
95692 @@ -609,7 +609,7 @@ static void ip_vs_sync_conn_v0(struct net *net, struct ip_vs_conn *cp,
95693 cp = cp->control;
95694 if (cp) {
95695 if (cp->flags & IP_VS_CONN_F_TEMPLATE)
95696 - pkts = atomic_add_return(1, &cp->in_pkts);
95697 + pkts = atomic_add_return_unchecked(1, &cp->in_pkts);
95698 else
95699 pkts = sysctl_sync_threshold(ipvs);
95700 ip_vs_sync_conn(net, cp->control, pkts);
95701 @@ -771,7 +771,7 @@ control:
95702 if (!cp)
95703 return;
95704 if (cp->flags & IP_VS_CONN_F_TEMPLATE)
95705 - pkts = atomic_add_return(1, &cp->in_pkts);
95706 + pkts = atomic_add_return_unchecked(1, &cp->in_pkts);
95707 else
95708 pkts = sysctl_sync_threshold(ipvs);
95709 goto sloop;
95710 @@ -895,7 +895,7 @@ static void ip_vs_proc_conn(struct net *net, struct ip_vs_conn_param *param,
95711
95712 if (opt)
95713 memcpy(&cp->in_seq, opt, sizeof(*opt));
95714 - atomic_set(&cp->in_pkts, sysctl_sync_threshold(ipvs));
95715 + atomic_set_unchecked(&cp->in_pkts, sysctl_sync_threshold(ipvs));
95716 cp->state = state;
95717 cp->old_state = cp->state;
95718 /*
95719 diff --git a/net/netfilter/ipvs/ip_vs_xmit.c b/net/netfilter/ipvs/ip_vs_xmit.c
95720 index c47444e..b0961c6 100644
95721 --- a/net/netfilter/ipvs/ip_vs_xmit.c
95722 +++ b/net/netfilter/ipvs/ip_vs_xmit.c
95723 @@ -1102,7 +1102,7 @@ ip_vs_icmp_xmit(struct sk_buff *skb, struct ip_vs_conn *cp,
95724 else
95725 rc = NF_ACCEPT;
95726 /* do not touch skb anymore */
95727 - atomic_inc(&cp->in_pkts);
95728 + atomic_inc_unchecked(&cp->in_pkts);
95729 goto out;
95730 }
95731
95732 @@ -1194,7 +1194,7 @@ ip_vs_icmp_xmit_v6(struct sk_buff *skb, struct ip_vs_conn *cp,
95733 else
95734 rc = NF_ACCEPT;
95735 /* do not touch skb anymore */
95736 - atomic_inc(&cp->in_pkts);
95737 + atomic_inc_unchecked(&cp->in_pkts);
95738 goto out;
95739 }
95740
95741 diff --git a/net/netfilter/nf_conntrack_acct.c b/net/netfilter/nf_conntrack_acct.c
95742 index 2d3030a..7ba1c0a 100644
95743 --- a/net/netfilter/nf_conntrack_acct.c
95744 +++ b/net/netfilter/nf_conntrack_acct.c
95745 @@ -60,7 +60,7 @@ static struct nf_ct_ext_type acct_extend __read_mostly = {
95746 #ifdef CONFIG_SYSCTL
95747 static int nf_conntrack_acct_init_sysctl(struct net *net)
95748 {
95749 - struct ctl_table *table;
95750 + ctl_table_no_const *table;
95751
95752 table = kmemdup(acct_sysctl_table, sizeof(acct_sysctl_table),
95753 GFP_KERNEL);
95754 diff --git a/net/netfilter/nf_conntrack_core.c b/net/netfilter/nf_conntrack_core.c
95755 index 5d892fe..d2fc9d8 100644
95756 --- a/net/netfilter/nf_conntrack_core.c
95757 +++ b/net/netfilter/nf_conntrack_core.c
95758 @@ -1600,6 +1600,10 @@ void nf_conntrack_init_end(void)
95759 #define DYING_NULLS_VAL ((1<<30)+1)
95760 #define TEMPLATE_NULLS_VAL ((1<<30)+2)
95761
95762 +#ifdef CONFIG_GRKERNSEC_HIDESYM
95763 +static atomic_unchecked_t conntrack_cache_id = ATOMIC_INIT(0);
95764 +#endif
95765 +
95766 int nf_conntrack_init_net(struct net *net)
95767 {
95768 int ret;
95769 @@ -1614,7 +1618,11 @@ int nf_conntrack_init_net(struct net *net)
95770 goto err_stat;
95771 }
95772
95773 +#ifdef CONFIG_GRKERNSEC_HIDESYM
95774 + net->ct.slabname = kasprintf(GFP_KERNEL, "nf_conntrack_%08lx", atomic_inc_return_unchecked(&conntrack_cache_id));
95775 +#else
95776 net->ct.slabname = kasprintf(GFP_KERNEL, "nf_conntrack_%p", net);
95777 +#endif
95778 if (!net->ct.slabname) {
95779 ret = -ENOMEM;
95780 goto err_slabname;
95781 diff --git a/net/netfilter/nf_conntrack_ecache.c b/net/netfilter/nf_conntrack_ecache.c
95782 index 1df1761..ce8b88a 100644
95783 --- a/net/netfilter/nf_conntrack_ecache.c
95784 +++ b/net/netfilter/nf_conntrack_ecache.c
95785 @@ -188,7 +188,7 @@ static struct nf_ct_ext_type event_extend __read_mostly = {
95786 #ifdef CONFIG_SYSCTL
95787 static int nf_conntrack_event_init_sysctl(struct net *net)
95788 {
95789 - struct ctl_table *table;
95790 + ctl_table_no_const *table;
95791
95792 table = kmemdup(event_sysctl_table, sizeof(event_sysctl_table),
95793 GFP_KERNEL);
95794 diff --git a/net/netfilter/nf_conntrack_helper.c b/net/netfilter/nf_conntrack_helper.c
95795 index 974a2a4..52cc6ff 100644
95796 --- a/net/netfilter/nf_conntrack_helper.c
95797 +++ b/net/netfilter/nf_conntrack_helper.c
95798 @@ -57,7 +57,7 @@ static struct ctl_table helper_sysctl_table[] = {
95799
95800 static int nf_conntrack_helper_init_sysctl(struct net *net)
95801 {
95802 - struct ctl_table *table;
95803 + ctl_table_no_const *table;
95804
95805 table = kmemdup(helper_sysctl_table, sizeof(helper_sysctl_table),
95806 GFP_KERNEL);
95807 diff --git a/net/netfilter/nf_conntrack_proto.c b/net/netfilter/nf_conntrack_proto.c
95808 index ce30041..3861b5d 100644
95809 --- a/net/netfilter/nf_conntrack_proto.c
95810 +++ b/net/netfilter/nf_conntrack_proto.c
95811 @@ -52,7 +52,7 @@ nf_ct_register_sysctl(struct net *net,
95812
95813 static void
95814 nf_ct_unregister_sysctl(struct ctl_table_header **header,
95815 - struct ctl_table **table,
95816 + ctl_table_no_const **table,
95817 unsigned int users)
95818 {
95819 if (users > 0)
95820 diff --git a/net/netfilter/nf_conntrack_proto_dccp.c b/net/netfilter/nf_conntrack_proto_dccp.c
95821 index a99b6c3..cb372f9 100644
95822 --- a/net/netfilter/nf_conntrack_proto_dccp.c
95823 +++ b/net/netfilter/nf_conntrack_proto_dccp.c
95824 @@ -428,7 +428,7 @@ static bool dccp_new(struct nf_conn *ct, const struct sk_buff *skb,
95825 const char *msg;
95826 u_int8_t state;
95827
95828 - dh = skb_header_pointer(skb, dataoff, sizeof(_dh), &dh);
95829 + dh = skb_header_pointer(skb, dataoff, sizeof(_dh), &_dh);
95830 BUG_ON(dh == NULL);
95831
95832 state = dccp_state_table[CT_DCCP_ROLE_CLIENT][dh->dccph_type][CT_DCCP_NONE];
95833 @@ -457,7 +457,7 @@ static bool dccp_new(struct nf_conn *ct, const struct sk_buff *skb,
95834 out_invalid:
95835 if (LOG_INVALID(net, IPPROTO_DCCP))
95836 nf_log_packet(net, nf_ct_l3num(ct), 0, skb, NULL, NULL,
95837 - NULL, msg);
95838 + NULL, "%s", msg);
95839 return false;
95840 }
95841
95842 @@ -486,7 +486,7 @@ static int dccp_packet(struct nf_conn *ct, const struct sk_buff *skb,
95843 u_int8_t type, old_state, new_state;
95844 enum ct_dccp_roles role;
95845
95846 - dh = skb_header_pointer(skb, dataoff, sizeof(_dh), &dh);
95847 + dh = skb_header_pointer(skb, dataoff, sizeof(_dh), &_dh);
95848 BUG_ON(dh == NULL);
95849 type = dh->dccph_type;
95850
95851 @@ -577,7 +577,7 @@ static int dccp_error(struct net *net, struct nf_conn *tmpl,
95852 unsigned int cscov;
95853 const char *msg;
95854
95855 - dh = skb_header_pointer(skb, dataoff, sizeof(_dh), &dh);
95856 + dh = skb_header_pointer(skb, dataoff, sizeof(_dh), &_dh);
95857 if (dh == NULL) {
95858 msg = "nf_ct_dccp: short packet ";
95859 goto out_invalid;
95860 @@ -614,7 +614,7 @@ static int dccp_error(struct net *net, struct nf_conn *tmpl,
95861
95862 out_invalid:
95863 if (LOG_INVALID(net, IPPROTO_DCCP))
95864 - nf_log_packet(net, pf, 0, skb, NULL, NULL, NULL, msg);
95865 + nf_log_packet(net, pf, 0, skb, NULL, NULL, NULL, "%s", msg);
95866 return -NF_ACCEPT;
95867 }
95868
95869 diff --git a/net/netfilter/nf_conntrack_standalone.c b/net/netfilter/nf_conntrack_standalone.c
95870 index f641751..d3c5b51 100644
95871 --- a/net/netfilter/nf_conntrack_standalone.c
95872 +++ b/net/netfilter/nf_conntrack_standalone.c
95873 @@ -471,7 +471,7 @@ static struct ctl_table nf_ct_netfilter_table[] = {
95874
95875 static int nf_conntrack_standalone_init_sysctl(struct net *net)
95876 {
95877 - struct ctl_table *table;
95878 + ctl_table_no_const *table;
95879
95880 table = kmemdup(nf_ct_sysctl_table, sizeof(nf_ct_sysctl_table),
95881 GFP_KERNEL);
95882 diff --git a/net/netfilter/nf_conntrack_timestamp.c b/net/netfilter/nf_conntrack_timestamp.c
95883 index 902fb0a..87f7fdb 100644
95884 --- a/net/netfilter/nf_conntrack_timestamp.c
95885 +++ b/net/netfilter/nf_conntrack_timestamp.c
95886 @@ -42,7 +42,7 @@ static struct nf_ct_ext_type tstamp_extend __read_mostly = {
95887 #ifdef CONFIG_SYSCTL
95888 static int nf_conntrack_tstamp_init_sysctl(struct net *net)
95889 {
95890 - struct ctl_table *table;
95891 + ctl_table_no_const *table;
95892
95893 table = kmemdup(tstamp_sysctl_table, sizeof(tstamp_sysctl_table),
95894 GFP_KERNEL);
95895 diff --git a/net/netfilter/nf_log.c b/net/netfilter/nf_log.c
95896 index 85296d4..8becdec 100644
95897 --- a/net/netfilter/nf_log.c
95898 +++ b/net/netfilter/nf_log.c
95899 @@ -243,7 +243,7 @@ static const struct file_operations nflog_file_ops = {
95900
95901 #ifdef CONFIG_SYSCTL
95902 static char nf_log_sysctl_fnames[NFPROTO_NUMPROTO-NFPROTO_UNSPEC][3];
95903 -static struct ctl_table nf_log_sysctl_table[NFPROTO_NUMPROTO+1];
95904 +static ctl_table_no_const nf_log_sysctl_table[NFPROTO_NUMPROTO+1] __read_only;
95905
95906 static int nf_log_proc_dostring(struct ctl_table *table, int write,
95907 void __user *buffer, size_t *lenp, loff_t *ppos)
95908 @@ -274,14 +274,16 @@ static int nf_log_proc_dostring(struct ctl_table *table, int write,
95909 rcu_assign_pointer(net->nf.nf_loggers[tindex], logger);
95910 mutex_unlock(&nf_log_mutex);
95911 } else {
95912 + ctl_table_no_const nf_log_table = *table;
95913 +
95914 mutex_lock(&nf_log_mutex);
95915 logger = rcu_dereference_protected(net->nf.nf_loggers[tindex],
95916 lockdep_is_held(&nf_log_mutex));
95917 if (!logger)
95918 - table->data = "NONE";
95919 + nf_log_table.data = "NONE";
95920 else
95921 - table->data = logger->name;
95922 - r = proc_dostring(table, write, buffer, lenp, ppos);
95923 + nf_log_table.data = logger->name;
95924 + r = proc_dostring(&nf_log_table, write, buffer, lenp, ppos);
95925 mutex_unlock(&nf_log_mutex);
95926 }
95927
95928 diff --git a/net/netfilter/nf_sockopt.c b/net/netfilter/nf_sockopt.c
95929 index f042ae5..30ea486 100644
95930 --- a/net/netfilter/nf_sockopt.c
95931 +++ b/net/netfilter/nf_sockopt.c
95932 @@ -45,7 +45,7 @@ int nf_register_sockopt(struct nf_sockopt_ops *reg)
95933 }
95934 }
95935
95936 - list_add(&reg->list, &nf_sockopts);
95937 + pax_list_add((struct list_head *)&reg->list, &nf_sockopts);
95938 out:
95939 mutex_unlock(&nf_sockopt_mutex);
95940 return ret;
95941 @@ -55,7 +55,7 @@ EXPORT_SYMBOL(nf_register_sockopt);
95942 void nf_unregister_sockopt(struct nf_sockopt_ops *reg)
95943 {
95944 mutex_lock(&nf_sockopt_mutex);
95945 - list_del(&reg->list);
95946 + pax_list_del((struct list_head *)&reg->list);
95947 mutex_unlock(&nf_sockopt_mutex);
95948 }
95949 EXPORT_SYMBOL(nf_unregister_sockopt);
95950 diff --git a/net/netfilter/nfnetlink_log.c b/net/netfilter/nfnetlink_log.c
95951 index d92cc31..e46f350 100644
95952 --- a/net/netfilter/nfnetlink_log.c
95953 +++ b/net/netfilter/nfnetlink_log.c
95954 @@ -82,7 +82,7 @@ static int nfnl_log_net_id __read_mostly;
95955 struct nfnl_log_net {
95956 spinlock_t instances_lock;
95957 struct hlist_head instance_table[INSTANCE_BUCKETS];
95958 - atomic_t global_seq;
95959 + atomic_unchecked_t global_seq;
95960 };
95961
95962 static struct nfnl_log_net *nfnl_log_pernet(struct net *net)
95963 @@ -563,7 +563,7 @@ __build_packet_message(struct nfnl_log_net *log,
95964 /* global sequence number */
95965 if ((inst->flags & NFULNL_CFG_F_SEQ_GLOBAL) &&
95966 nla_put_be32(inst->skb, NFULA_SEQ_GLOBAL,
95967 - htonl(atomic_inc_return(&log->global_seq))))
95968 + htonl(atomic_inc_return_unchecked(&log->global_seq))))
95969 goto nla_put_failure;
95970
95971 if (data_len) {
95972 diff --git a/net/netfilter/xt_gradm.c b/net/netfilter/xt_gradm.c
95973 new file mode 100644
95974 index 0000000..c566332
95975 --- /dev/null
95976 +++ b/net/netfilter/xt_gradm.c
95977 @@ -0,0 +1,51 @@
95978 +/*
95979 + * gradm match for netfilter
95980 + * Copyright © Zbigniew Krzystolik, 2010
95981 + *
95982 + * This program is free software; you can redistribute it and/or modify
95983 + * it under the terms of the GNU General Public License; either version
95984 + * 2 or 3 as published by the Free Software Foundation.
95985 + */
95986 +#include <linux/module.h>
95987 +#include <linux/moduleparam.h>
95988 +#include <linux/skbuff.h>
95989 +#include <linux/netfilter/x_tables.h>
95990 +#include <linux/grsecurity.h>
95991 +#include <linux/netfilter/xt_gradm.h>
95992 +
95993 +static bool
95994 +gradm_mt(const struct sk_buff *skb, struct xt_action_param *par)
95995 +{
95996 + const struct xt_gradm_mtinfo *info = par->matchinfo;
95997 + bool retval = false;
95998 + if (gr_acl_is_enabled())
95999 + retval = true;
96000 + return retval ^ info->invflags;
96001 +}
96002 +
96003 +static struct xt_match gradm_mt_reg __read_mostly = {
96004 + .name = "gradm",
96005 + .revision = 0,
96006 + .family = NFPROTO_UNSPEC,
96007 + .match = gradm_mt,
96008 + .matchsize = XT_ALIGN(sizeof(struct xt_gradm_mtinfo)),
96009 + .me = THIS_MODULE,
96010 +};
96011 +
96012 +static int __init gradm_mt_init(void)
96013 +{
96014 + return xt_register_match(&gradm_mt_reg);
96015 +}
96016 +
96017 +static void __exit gradm_mt_exit(void)
96018 +{
96019 + xt_unregister_match(&gradm_mt_reg);
96020 +}
96021 +
96022 +module_init(gradm_mt_init);
96023 +module_exit(gradm_mt_exit);
96024 +MODULE_AUTHOR("Zbigniew Krzystolik <zbyniu@destrukcja.pl>");
96025 +MODULE_DESCRIPTION("Xtables: Grsecurity RBAC match");
96026 +MODULE_LICENSE("GPL");
96027 +MODULE_ALIAS("ipt_gradm");
96028 +MODULE_ALIAS("ip6t_gradm");
96029 diff --git a/net/netfilter/xt_statistic.c b/net/netfilter/xt_statistic.c
96030 index 4fe4fb4..87a89e5 100644
96031 --- a/net/netfilter/xt_statistic.c
96032 +++ b/net/netfilter/xt_statistic.c
96033 @@ -19,7 +19,7 @@
96034 #include <linux/module.h>
96035
96036 struct xt_statistic_priv {
96037 - atomic_t count;
96038 + atomic_unchecked_t count;
96039 } ____cacheline_aligned_in_smp;
96040
96041 MODULE_LICENSE("GPL");
96042 @@ -42,9 +42,9 @@ statistic_mt(const struct sk_buff *skb, struct xt_action_param *par)
96043 break;
96044 case XT_STATISTIC_MODE_NTH:
96045 do {
96046 - oval = atomic_read(&info->master->count);
96047 + oval = atomic_read_unchecked(&info->master->count);
96048 nval = (oval == info->u.nth.every) ? 0 : oval + 1;
96049 - } while (atomic_cmpxchg(&info->master->count, oval, nval) != oval);
96050 + } while (atomic_cmpxchg_unchecked(&info->master->count, oval, nval) != oval);
96051 if (nval == 0)
96052 ret = !ret;
96053 break;
96054 @@ -64,7 +64,7 @@ static int statistic_mt_check(const struct xt_mtchk_param *par)
96055 info->master = kzalloc(sizeof(*info->master), GFP_KERNEL);
96056 if (info->master == NULL)
96057 return -ENOMEM;
96058 - atomic_set(&info->master->count, info->u.nth.count);
96059 + atomic_set_unchecked(&info->master->count, info->u.nth.count);
96060
96061 return 0;
96062 }
96063 diff --git a/net/netlink/af_netlink.c b/net/netlink/af_netlink.c
96064 index 6135635..5bdc54a 100644
96065 --- a/net/netlink/af_netlink.c
96066 +++ b/net/netlink/af_netlink.c
96067 @@ -249,7 +249,7 @@ static void netlink_overrun(struct sock *sk)
96068 sk->sk_error_report(sk);
96069 }
96070 }
96071 - atomic_inc(&sk->sk_drops);
96072 + atomic_inc_unchecked(&sk->sk_drops);
96073 }
96074
96075 static void netlink_rcv_wake(struct sock *sk)
96076 @@ -2940,7 +2940,7 @@ static int netlink_seq_show(struct seq_file *seq, void *v)
96077 sk_wmem_alloc_get(s),
96078 nlk->cb_running,
96079 atomic_read(&s->sk_refcnt),
96080 - atomic_read(&s->sk_drops),
96081 + atomic_read_unchecked(&s->sk_drops),
96082 sock_i_ino(s)
96083 );
96084
96085 diff --git a/net/netlink/genetlink.c b/net/netlink/genetlink.c
96086 index 0c741ce..f8c8ca7 100644
96087 --- a/net/netlink/genetlink.c
96088 +++ b/net/netlink/genetlink.c
96089 @@ -310,18 +310,20 @@ int genl_register_ops(struct genl_family *family, struct genl_ops *ops)
96090 goto errout;
96091 }
96092
96093 + pax_open_kernel();
96094 if (ops->dumpit)
96095 - ops->flags |= GENL_CMD_CAP_DUMP;
96096 + *(unsigned int *)&ops->flags |= GENL_CMD_CAP_DUMP;
96097 if (ops->doit)
96098 - ops->flags |= GENL_CMD_CAP_DO;
96099 + *(unsigned int *)&ops->flags |= GENL_CMD_CAP_DO;
96100 if (ops->policy)
96101 - ops->flags |= GENL_CMD_CAP_HASPOL;
96102 + *(unsigned int *)&ops->flags |= GENL_CMD_CAP_HASPOL;
96103 + pax_close_kernel();
96104
96105 genl_lock_all();
96106 - list_add_tail(&ops->ops_list, &family->ops_list);
96107 + pax_list_add_tail((struct list_head *)&ops->ops_list, &family->ops_list);
96108 genl_unlock_all();
96109
96110 - genl_ctrl_event(CTRL_CMD_NEWOPS, ops);
96111 + genl_ctrl_event(CTRL_CMD_NEWOPS, (void *)ops);
96112 err = 0;
96113 errout:
96114 return err;
96115 @@ -351,9 +353,9 @@ int genl_unregister_ops(struct genl_family *family, struct genl_ops *ops)
96116 genl_lock_all();
96117 list_for_each_entry(rc, &family->ops_list, ops_list) {
96118 if (rc == ops) {
96119 - list_del(&ops->ops_list);
96120 + pax_list_del((struct list_head *)&ops->ops_list);
96121 genl_unlock_all();
96122 - genl_ctrl_event(CTRL_CMD_DELOPS, ops);
96123 + genl_ctrl_event(CTRL_CMD_DELOPS, (void *)ops);
96124 return 0;
96125 }
96126 }
96127 diff --git a/net/netrom/af_netrom.c b/net/netrom/af_netrom.c
96128 index 53c19a3..b0ac04a 100644
96129 --- a/net/netrom/af_netrom.c
96130 +++ b/net/netrom/af_netrom.c
96131 @@ -850,7 +850,6 @@ static int nr_getname(struct socket *sock, struct sockaddr *uaddr,
96132 *uaddr_len = sizeof(struct full_sockaddr_ax25);
96133 } else {
96134 sax->fsa_ax25.sax25_family = AF_NETROM;
96135 - sax->fsa_ax25.sax25_ndigis = 0;
96136 sax->fsa_ax25.sax25_call = nr->source_addr;
96137 *uaddr_len = sizeof(struct sockaddr_ax25);
96138 }
96139 diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c
96140 index ba2548b..1a4e98e 100644
96141 --- a/net/packet/af_packet.c
96142 +++ b/net/packet/af_packet.c
96143 @@ -1699,7 +1699,7 @@ static int packet_rcv(struct sk_buff *skb, struct net_device *dev,
96144
96145 spin_lock(&sk->sk_receive_queue.lock);
96146 po->stats.stats1.tp_packets++;
96147 - skb->dropcount = atomic_read(&sk->sk_drops);
96148 + skb->dropcount = atomic_read_unchecked(&sk->sk_drops);
96149 __skb_queue_tail(&sk->sk_receive_queue, skb);
96150 spin_unlock(&sk->sk_receive_queue.lock);
96151 sk->sk_data_ready(sk, skb->len);
96152 @@ -1708,7 +1708,7 @@ static int packet_rcv(struct sk_buff *skb, struct net_device *dev,
96153 drop_n_acct:
96154 spin_lock(&sk->sk_receive_queue.lock);
96155 po->stats.stats1.tp_drops++;
96156 - atomic_inc(&sk->sk_drops);
96157 + atomic_inc_unchecked(&sk->sk_drops);
96158 spin_unlock(&sk->sk_receive_queue.lock);
96159
96160 drop_n_restore:
96161 @@ -3261,7 +3261,7 @@ static int packet_getsockopt(struct socket *sock, int level, int optname,
96162 case PACKET_HDRLEN:
96163 if (len > sizeof(int))
96164 len = sizeof(int);
96165 - if (copy_from_user(&val, optval, len))
96166 + if (len > sizeof(val) || copy_from_user(&val, optval, len))
96167 return -EFAULT;
96168 switch (val) {
96169 case TPACKET_V1:
96170 @@ -3304,7 +3304,7 @@ static int packet_getsockopt(struct socket *sock, int level, int optname,
96171 len = lv;
96172 if (put_user(len, optlen))
96173 return -EFAULT;
96174 - if (copy_to_user(optval, data, len))
96175 + if (len > sizeof(st) || copy_to_user(optval, data, len))
96176 return -EFAULT;
96177 return 0;
96178 }
96179 diff --git a/net/phonet/pep.c b/net/phonet/pep.c
96180 index e774117..900b8b7 100644
96181 --- a/net/phonet/pep.c
96182 +++ b/net/phonet/pep.c
96183 @@ -388,7 +388,7 @@ static int pipe_do_rcv(struct sock *sk, struct sk_buff *skb)
96184
96185 case PNS_PEP_CTRL_REQ:
96186 if (skb_queue_len(&pn->ctrlreq_queue) >= PNPIPE_CTRLREQ_MAX) {
96187 - atomic_inc(&sk->sk_drops);
96188 + atomic_inc_unchecked(&sk->sk_drops);
96189 break;
96190 }
96191 __skb_pull(skb, 4);
96192 @@ -409,7 +409,7 @@ static int pipe_do_rcv(struct sock *sk, struct sk_buff *skb)
96193 }
96194
96195 if (pn->rx_credits == 0) {
96196 - atomic_inc(&sk->sk_drops);
96197 + atomic_inc_unchecked(&sk->sk_drops);
96198 err = -ENOBUFS;
96199 break;
96200 }
96201 @@ -580,7 +580,7 @@ static int pipe_handler_do_rcv(struct sock *sk, struct sk_buff *skb)
96202 }
96203
96204 if (pn->rx_credits == 0) {
96205 - atomic_inc(&sk->sk_drops);
96206 + atomic_inc_unchecked(&sk->sk_drops);
96207 err = NET_RX_DROP;
96208 break;
96209 }
96210 diff --git a/net/phonet/socket.c b/net/phonet/socket.c
96211 index 77e38f7..f4ef5c3 100644
96212 --- a/net/phonet/socket.c
96213 +++ b/net/phonet/socket.c
96214 @@ -612,7 +612,7 @@ static int pn_sock_seq_show(struct seq_file *seq, void *v)
96215 from_kuid_munged(seq_user_ns(seq), sock_i_uid(sk)),
96216 sock_i_ino(sk),
96217 atomic_read(&sk->sk_refcnt), sk,
96218 - atomic_read(&sk->sk_drops), &len);
96219 + atomic_read_unchecked(&sk->sk_drops), &len);
96220 }
96221 seq_printf(seq, "%*s\n", 127 - len, "");
96222 return 0;
96223 diff --git a/net/phonet/sysctl.c b/net/phonet/sysctl.c
96224 index c02a8c4..3c5b600 100644
96225 --- a/net/phonet/sysctl.c
96226 +++ b/net/phonet/sysctl.c
96227 @@ -67,7 +67,7 @@ static int proc_local_port_range(struct ctl_table *table, int write,
96228 {
96229 int ret;
96230 int range[2] = {local_port_range[0], local_port_range[1]};
96231 - struct ctl_table tmp = {
96232 + ctl_table_no_const tmp = {
96233 .data = &range,
96234 .maxlen = sizeof(range),
96235 .mode = table->mode,
96236 diff --git a/net/rds/cong.c b/net/rds/cong.c
96237 index e5b65ac..f3b6fb7 100644
96238 --- a/net/rds/cong.c
96239 +++ b/net/rds/cong.c
96240 @@ -78,7 +78,7 @@
96241 * finds that the saved generation number is smaller than the global generation
96242 * number, it wakes up the process.
96243 */
96244 -static atomic_t rds_cong_generation = ATOMIC_INIT(0);
96245 +static atomic_unchecked_t rds_cong_generation = ATOMIC_INIT(0);
96246
96247 /*
96248 * Congestion monitoring
96249 @@ -233,7 +233,7 @@ void rds_cong_map_updated(struct rds_cong_map *map, uint64_t portmask)
96250 rdsdebug("waking map %p for %pI4\n",
96251 map, &map->m_addr);
96252 rds_stats_inc(s_cong_update_received);
96253 - atomic_inc(&rds_cong_generation);
96254 + atomic_inc_unchecked(&rds_cong_generation);
96255 if (waitqueue_active(&map->m_waitq))
96256 wake_up(&map->m_waitq);
96257 if (waitqueue_active(&rds_poll_waitq))
96258 @@ -259,7 +259,7 @@ EXPORT_SYMBOL_GPL(rds_cong_map_updated);
96259
96260 int rds_cong_updated_since(unsigned long *recent)
96261 {
96262 - unsigned long gen = atomic_read(&rds_cong_generation);
96263 + unsigned long gen = atomic_read_unchecked(&rds_cong_generation);
96264
96265 if (likely(*recent == gen))
96266 return 0;
96267 diff --git a/net/rds/ib.h b/net/rds/ib.h
96268 index 7280ab8..e04f4ea 100644
96269 --- a/net/rds/ib.h
96270 +++ b/net/rds/ib.h
96271 @@ -128,7 +128,7 @@ struct rds_ib_connection {
96272 /* sending acks */
96273 unsigned long i_ack_flags;
96274 #ifdef KERNEL_HAS_ATOMIC64
96275 - atomic64_t i_ack_next; /* next ACK to send */
96276 + atomic64_unchecked_t i_ack_next; /* next ACK to send */
96277 #else
96278 spinlock_t i_ack_lock; /* protect i_ack_next */
96279 u64 i_ack_next; /* next ACK to send */
96280 diff --git a/net/rds/ib_cm.c b/net/rds/ib_cm.c
96281 index 31b74f5..dc1fbfa 100644
96282 --- a/net/rds/ib_cm.c
96283 +++ b/net/rds/ib_cm.c
96284 @@ -717,7 +717,7 @@ void rds_ib_conn_shutdown(struct rds_connection *conn)
96285 /* Clear the ACK state */
96286 clear_bit(IB_ACK_IN_FLIGHT, &ic->i_ack_flags);
96287 #ifdef KERNEL_HAS_ATOMIC64
96288 - atomic64_set(&ic->i_ack_next, 0);
96289 + atomic64_set_unchecked(&ic->i_ack_next, 0);
96290 #else
96291 ic->i_ack_next = 0;
96292 #endif
96293 diff --git a/net/rds/ib_recv.c b/net/rds/ib_recv.c
96294 index 8eb9501..0c386ff 100644
96295 --- a/net/rds/ib_recv.c
96296 +++ b/net/rds/ib_recv.c
96297 @@ -597,7 +597,7 @@ static u64 rds_ib_get_ack(struct rds_ib_connection *ic)
96298 static void rds_ib_set_ack(struct rds_ib_connection *ic, u64 seq,
96299 int ack_required)
96300 {
96301 - atomic64_set(&ic->i_ack_next, seq);
96302 + atomic64_set_unchecked(&ic->i_ack_next, seq);
96303 if (ack_required) {
96304 smp_mb__before_clear_bit();
96305 set_bit(IB_ACK_REQUESTED, &ic->i_ack_flags);
96306 @@ -609,7 +609,7 @@ static u64 rds_ib_get_ack(struct rds_ib_connection *ic)
96307 clear_bit(IB_ACK_REQUESTED, &ic->i_ack_flags);
96308 smp_mb__after_clear_bit();
96309
96310 - return atomic64_read(&ic->i_ack_next);
96311 + return atomic64_read_unchecked(&ic->i_ack_next);
96312 }
96313 #endif
96314
96315 diff --git a/net/rds/iw.h b/net/rds/iw.h
96316 index 04ce3b1..48119a6 100644
96317 --- a/net/rds/iw.h
96318 +++ b/net/rds/iw.h
96319 @@ -134,7 +134,7 @@ struct rds_iw_connection {
96320 /* sending acks */
96321 unsigned long i_ack_flags;
96322 #ifdef KERNEL_HAS_ATOMIC64
96323 - atomic64_t i_ack_next; /* next ACK to send */
96324 + atomic64_unchecked_t i_ack_next; /* next ACK to send */
96325 #else
96326 spinlock_t i_ack_lock; /* protect i_ack_next */
96327 u64 i_ack_next; /* next ACK to send */
96328 diff --git a/net/rds/iw_cm.c b/net/rds/iw_cm.c
96329 index a91e1db..cf3053f 100644
96330 --- a/net/rds/iw_cm.c
96331 +++ b/net/rds/iw_cm.c
96332 @@ -663,7 +663,7 @@ void rds_iw_conn_shutdown(struct rds_connection *conn)
96333 /* Clear the ACK state */
96334 clear_bit(IB_ACK_IN_FLIGHT, &ic->i_ack_flags);
96335 #ifdef KERNEL_HAS_ATOMIC64
96336 - atomic64_set(&ic->i_ack_next, 0);
96337 + atomic64_set_unchecked(&ic->i_ack_next, 0);
96338 #else
96339 ic->i_ack_next = 0;
96340 #endif
96341 diff --git a/net/rds/iw_recv.c b/net/rds/iw_recv.c
96342 index 4503335..db566b4 100644
96343 --- a/net/rds/iw_recv.c
96344 +++ b/net/rds/iw_recv.c
96345 @@ -427,7 +427,7 @@ static u64 rds_iw_get_ack(struct rds_iw_connection *ic)
96346 static void rds_iw_set_ack(struct rds_iw_connection *ic, u64 seq,
96347 int ack_required)
96348 {
96349 - atomic64_set(&ic->i_ack_next, seq);
96350 + atomic64_set_unchecked(&ic->i_ack_next, seq);
96351 if (ack_required) {
96352 smp_mb__before_clear_bit();
96353 set_bit(IB_ACK_REQUESTED, &ic->i_ack_flags);
96354 @@ -439,7 +439,7 @@ static u64 rds_iw_get_ack(struct rds_iw_connection *ic)
96355 clear_bit(IB_ACK_REQUESTED, &ic->i_ack_flags);
96356 smp_mb__after_clear_bit();
96357
96358 - return atomic64_read(&ic->i_ack_next);
96359 + return atomic64_read_unchecked(&ic->i_ack_next);
96360 }
96361 #endif
96362
96363 diff --git a/net/rds/rds.h b/net/rds/rds.h
96364 index ec1d731..90a3a8d 100644
96365 --- a/net/rds/rds.h
96366 +++ b/net/rds/rds.h
96367 @@ -449,7 +449,7 @@ struct rds_transport {
96368 void (*sync_mr)(void *trans_private, int direction);
96369 void (*free_mr)(void *trans_private, int invalidate);
96370 void (*flush_mrs)(void);
96371 -};
96372 +} __do_const;
96373
96374 struct rds_sock {
96375 struct sock rs_sk;
96376 diff --git a/net/rds/tcp.c b/net/rds/tcp.c
96377 index edac9ef..16bcb98 100644
96378 --- a/net/rds/tcp.c
96379 +++ b/net/rds/tcp.c
96380 @@ -59,7 +59,7 @@ void rds_tcp_nonagle(struct socket *sock)
96381 int val = 1;
96382
96383 set_fs(KERNEL_DS);
96384 - sock->ops->setsockopt(sock, SOL_TCP, TCP_NODELAY, (char __user *)&val,
96385 + sock->ops->setsockopt(sock, SOL_TCP, TCP_NODELAY, (char __force_user *)&val,
96386 sizeof(val));
96387 set_fs(oldfs);
96388 }
96389 diff --git a/net/rds/tcp_send.c b/net/rds/tcp_send.c
96390 index 81cf5a4..b5826ff 100644
96391 --- a/net/rds/tcp_send.c
96392 +++ b/net/rds/tcp_send.c
96393 @@ -43,7 +43,7 @@ static void rds_tcp_cork(struct socket *sock, int val)
96394
96395 oldfs = get_fs();
96396 set_fs(KERNEL_DS);
96397 - sock->ops->setsockopt(sock, SOL_TCP, TCP_CORK, (char __user *)&val,
96398 + sock->ops->setsockopt(sock, SOL_TCP, TCP_CORK, (char __force_user *)&val,
96399 sizeof(val));
96400 set_fs(oldfs);
96401 }
96402 diff --git a/net/rxrpc/af_rxrpc.c b/net/rxrpc/af_rxrpc.c
96403 index e61aa60..f07cc89 100644
96404 --- a/net/rxrpc/af_rxrpc.c
96405 +++ b/net/rxrpc/af_rxrpc.c
96406 @@ -40,7 +40,7 @@ static const struct proto_ops rxrpc_rpc_ops;
96407 __be32 rxrpc_epoch;
96408
96409 /* current debugging ID */
96410 -atomic_t rxrpc_debug_id;
96411 +atomic_unchecked_t rxrpc_debug_id;
96412
96413 /* count of skbs currently in use */
96414 atomic_t rxrpc_n_skbs;
96415 diff --git a/net/rxrpc/ar-ack.c b/net/rxrpc/ar-ack.c
96416 index e4d9cbc..b229649 100644
96417 --- a/net/rxrpc/ar-ack.c
96418 +++ b/net/rxrpc/ar-ack.c
96419 @@ -175,7 +175,7 @@ static void rxrpc_resend(struct rxrpc_call *call)
96420
96421 _enter("{%d,%d,%d,%d},",
96422 call->acks_hard, call->acks_unacked,
96423 - atomic_read(&call->sequence),
96424 + atomic_read_unchecked(&call->sequence),
96425 CIRC_CNT(call->acks_head, call->acks_tail, call->acks_winsz));
96426
96427 stop = 0;
96428 @@ -199,7 +199,7 @@ static void rxrpc_resend(struct rxrpc_call *call)
96429
96430 /* each Tx packet has a new serial number */
96431 sp->hdr.serial =
96432 - htonl(atomic_inc_return(&call->conn->serial));
96433 + htonl(atomic_inc_return_unchecked(&call->conn->serial));
96434
96435 hdr = (struct rxrpc_header *) txb->head;
96436 hdr->serial = sp->hdr.serial;
96437 @@ -403,7 +403,7 @@ static void rxrpc_rotate_tx_window(struct rxrpc_call *call, u32 hard)
96438 */
96439 static void rxrpc_clear_tx_window(struct rxrpc_call *call)
96440 {
96441 - rxrpc_rotate_tx_window(call, atomic_read(&call->sequence));
96442 + rxrpc_rotate_tx_window(call, atomic_read_unchecked(&call->sequence));
96443 }
96444
96445 /*
96446 @@ -629,7 +629,7 @@ process_further:
96447
96448 latest = ntohl(sp->hdr.serial);
96449 hard = ntohl(ack.firstPacket);
96450 - tx = atomic_read(&call->sequence);
96451 + tx = atomic_read_unchecked(&call->sequence);
96452
96453 _proto("Rx ACK %%%u { m=%hu f=#%u p=#%u s=%%%u r=%s n=%u }",
96454 latest,
96455 @@ -1161,7 +1161,7 @@ void rxrpc_process_call(struct work_struct *work)
96456 goto maybe_reschedule;
96457
96458 send_ACK_with_skew:
96459 - ack.maxSkew = htons(atomic_read(&call->conn->hi_serial) -
96460 + ack.maxSkew = htons(atomic_read_unchecked(&call->conn->hi_serial) -
96461 ntohl(ack.serial));
96462 send_ACK:
96463 mtu = call->conn->trans->peer->if_mtu;
96464 @@ -1173,7 +1173,7 @@ send_ACK:
96465 ackinfo.rxMTU = htonl(5692);
96466 ackinfo.jumbo_max = htonl(4);
96467
96468 - hdr.serial = htonl(atomic_inc_return(&call->conn->serial));
96469 + hdr.serial = htonl(atomic_inc_return_unchecked(&call->conn->serial));
96470 _proto("Tx ACK %%%u { m=%hu f=#%u p=#%u s=%%%u r=%s n=%u }",
96471 ntohl(hdr.serial),
96472 ntohs(ack.maxSkew),
96473 @@ -1191,7 +1191,7 @@ send_ACK:
96474 send_message:
96475 _debug("send message");
96476
96477 - hdr.serial = htonl(atomic_inc_return(&call->conn->serial));
96478 + hdr.serial = htonl(atomic_inc_return_unchecked(&call->conn->serial));
96479 _proto("Tx %s %%%u", rxrpc_pkts[hdr.type], ntohl(hdr.serial));
96480 send_message_2:
96481
96482 diff --git a/net/rxrpc/ar-call.c b/net/rxrpc/ar-call.c
96483 index a3bbb36..3341fb9 100644
96484 --- a/net/rxrpc/ar-call.c
96485 +++ b/net/rxrpc/ar-call.c
96486 @@ -83,7 +83,7 @@ static struct rxrpc_call *rxrpc_alloc_call(gfp_t gfp)
96487 spin_lock_init(&call->lock);
96488 rwlock_init(&call->state_lock);
96489 atomic_set(&call->usage, 1);
96490 - call->debug_id = atomic_inc_return(&rxrpc_debug_id);
96491 + call->debug_id = atomic_inc_return_unchecked(&rxrpc_debug_id);
96492 call->state = RXRPC_CALL_CLIENT_SEND_REQUEST;
96493
96494 memset(&call->sock_node, 0xed, sizeof(call->sock_node));
96495 diff --git a/net/rxrpc/ar-connection.c b/net/rxrpc/ar-connection.c
96496 index 4106ca9..a338d7a 100644
96497 --- a/net/rxrpc/ar-connection.c
96498 +++ b/net/rxrpc/ar-connection.c
96499 @@ -206,7 +206,7 @@ static struct rxrpc_connection *rxrpc_alloc_connection(gfp_t gfp)
96500 rwlock_init(&conn->lock);
96501 spin_lock_init(&conn->state_lock);
96502 atomic_set(&conn->usage, 1);
96503 - conn->debug_id = atomic_inc_return(&rxrpc_debug_id);
96504 + conn->debug_id = atomic_inc_return_unchecked(&rxrpc_debug_id);
96505 conn->avail_calls = RXRPC_MAXCALLS;
96506 conn->size_align = 4;
96507 conn->header_size = sizeof(struct rxrpc_header);
96508 diff --git a/net/rxrpc/ar-connevent.c b/net/rxrpc/ar-connevent.c
96509 index e7ed43a..6afa140 100644
96510 --- a/net/rxrpc/ar-connevent.c
96511 +++ b/net/rxrpc/ar-connevent.c
96512 @@ -109,7 +109,7 @@ static int rxrpc_abort_connection(struct rxrpc_connection *conn,
96513
96514 len = iov[0].iov_len + iov[1].iov_len;
96515
96516 - hdr.serial = htonl(atomic_inc_return(&conn->serial));
96517 + hdr.serial = htonl(atomic_inc_return_unchecked(&conn->serial));
96518 _proto("Tx CONN ABORT %%%u { %d }", ntohl(hdr.serial), abort_code);
96519
96520 ret = kernel_sendmsg(conn->trans->local->socket, &msg, iov, 2, len);
96521 diff --git a/net/rxrpc/ar-input.c b/net/rxrpc/ar-input.c
96522 index 529572f..c758ca7 100644
96523 --- a/net/rxrpc/ar-input.c
96524 +++ b/net/rxrpc/ar-input.c
96525 @@ -340,9 +340,9 @@ void rxrpc_fast_process_packet(struct rxrpc_call *call, struct sk_buff *skb)
96526 /* track the latest serial number on this connection for ACK packet
96527 * information */
96528 serial = ntohl(sp->hdr.serial);
96529 - hi_serial = atomic_read(&call->conn->hi_serial);
96530 + hi_serial = atomic_read_unchecked(&call->conn->hi_serial);
96531 while (serial > hi_serial)
96532 - hi_serial = atomic_cmpxchg(&call->conn->hi_serial, hi_serial,
96533 + hi_serial = atomic_cmpxchg_unchecked(&call->conn->hi_serial, hi_serial,
96534 serial);
96535
96536 /* request ACK generation for any ACK or DATA packet that requests
96537 diff --git a/net/rxrpc/ar-internal.h b/net/rxrpc/ar-internal.h
96538 index a693aca..81e7293 100644
96539 --- a/net/rxrpc/ar-internal.h
96540 +++ b/net/rxrpc/ar-internal.h
96541 @@ -272,8 +272,8 @@ struct rxrpc_connection {
96542 int error; /* error code for local abort */
96543 int debug_id; /* debug ID for printks */
96544 unsigned int call_counter; /* call ID counter */
96545 - atomic_t serial; /* packet serial number counter */
96546 - atomic_t hi_serial; /* highest serial number received */
96547 + atomic_unchecked_t serial; /* packet serial number counter */
96548 + atomic_unchecked_t hi_serial; /* highest serial number received */
96549 u8 avail_calls; /* number of calls available */
96550 u8 size_align; /* data size alignment (for security) */
96551 u8 header_size; /* rxrpc + security header size */
96552 @@ -346,7 +346,7 @@ struct rxrpc_call {
96553 spinlock_t lock;
96554 rwlock_t state_lock; /* lock for state transition */
96555 atomic_t usage;
96556 - atomic_t sequence; /* Tx data packet sequence counter */
96557 + atomic_unchecked_t sequence; /* Tx data packet sequence counter */
96558 u32 abort_code; /* local/remote abort code */
96559 enum { /* current state of call */
96560 RXRPC_CALL_CLIENT_SEND_REQUEST, /* - client sending request phase */
96561 @@ -420,7 +420,7 @@ static inline void rxrpc_abort_call(struct rxrpc_call *call, u32 abort_code)
96562 */
96563 extern atomic_t rxrpc_n_skbs;
96564 extern __be32 rxrpc_epoch;
96565 -extern atomic_t rxrpc_debug_id;
96566 +extern atomic_unchecked_t rxrpc_debug_id;
96567 extern struct workqueue_struct *rxrpc_workqueue;
96568
96569 /*
96570 diff --git a/net/rxrpc/ar-local.c b/net/rxrpc/ar-local.c
96571 index 87f7135..74d3703 100644
96572 --- a/net/rxrpc/ar-local.c
96573 +++ b/net/rxrpc/ar-local.c
96574 @@ -45,7 +45,7 @@ struct rxrpc_local *rxrpc_alloc_local(struct sockaddr_rxrpc *srx)
96575 spin_lock_init(&local->lock);
96576 rwlock_init(&local->services_lock);
96577 atomic_set(&local->usage, 1);
96578 - local->debug_id = atomic_inc_return(&rxrpc_debug_id);
96579 + local->debug_id = atomic_inc_return_unchecked(&rxrpc_debug_id);
96580 memcpy(&local->srx, srx, sizeof(*srx));
96581 }
96582
96583 diff --git a/net/rxrpc/ar-output.c b/net/rxrpc/ar-output.c
96584 index e1ac183..b43e10e 100644
96585 --- a/net/rxrpc/ar-output.c
96586 +++ b/net/rxrpc/ar-output.c
96587 @@ -682,9 +682,9 @@ static int rxrpc_send_data(struct kiocb *iocb,
96588 sp->hdr.cid = call->cid;
96589 sp->hdr.callNumber = call->call_id;
96590 sp->hdr.seq =
96591 - htonl(atomic_inc_return(&call->sequence));
96592 + htonl(atomic_inc_return_unchecked(&call->sequence));
96593 sp->hdr.serial =
96594 - htonl(atomic_inc_return(&conn->serial));
96595 + htonl(atomic_inc_return_unchecked(&conn->serial));
96596 sp->hdr.type = RXRPC_PACKET_TYPE_DATA;
96597 sp->hdr.userStatus = 0;
96598 sp->hdr.securityIndex = conn->security_ix;
96599 diff --git a/net/rxrpc/ar-peer.c b/net/rxrpc/ar-peer.c
96600 index bebaa43..2644591 100644
96601 --- a/net/rxrpc/ar-peer.c
96602 +++ b/net/rxrpc/ar-peer.c
96603 @@ -72,7 +72,7 @@ static struct rxrpc_peer *rxrpc_alloc_peer(struct sockaddr_rxrpc *srx,
96604 INIT_LIST_HEAD(&peer->error_targets);
96605 spin_lock_init(&peer->lock);
96606 atomic_set(&peer->usage, 1);
96607 - peer->debug_id = atomic_inc_return(&rxrpc_debug_id);
96608 + peer->debug_id = atomic_inc_return_unchecked(&rxrpc_debug_id);
96609 memcpy(&peer->srx, srx, sizeof(*srx));
96610
96611 rxrpc_assess_MTU_size(peer);
96612 diff --git a/net/rxrpc/ar-proc.c b/net/rxrpc/ar-proc.c
96613 index 38047f7..9f48511 100644
96614 --- a/net/rxrpc/ar-proc.c
96615 +++ b/net/rxrpc/ar-proc.c
96616 @@ -164,8 +164,8 @@ static int rxrpc_connection_seq_show(struct seq_file *seq, void *v)
96617 atomic_read(&conn->usage),
96618 rxrpc_conn_states[conn->state],
96619 key_serial(conn->key),
96620 - atomic_read(&conn->serial),
96621 - atomic_read(&conn->hi_serial));
96622 + atomic_read_unchecked(&conn->serial),
96623 + atomic_read_unchecked(&conn->hi_serial));
96624
96625 return 0;
96626 }
96627 diff --git a/net/rxrpc/ar-transport.c b/net/rxrpc/ar-transport.c
96628 index 92df566..87ec1bf 100644
96629 --- a/net/rxrpc/ar-transport.c
96630 +++ b/net/rxrpc/ar-transport.c
96631 @@ -47,7 +47,7 @@ static struct rxrpc_transport *rxrpc_alloc_transport(struct rxrpc_local *local,
96632 spin_lock_init(&trans->client_lock);
96633 rwlock_init(&trans->conn_lock);
96634 atomic_set(&trans->usage, 1);
96635 - trans->debug_id = atomic_inc_return(&rxrpc_debug_id);
96636 + trans->debug_id = atomic_inc_return_unchecked(&rxrpc_debug_id);
96637
96638 if (peer->srx.transport.family == AF_INET) {
96639 switch (peer->srx.transport_type) {
96640 diff --git a/net/rxrpc/rxkad.c b/net/rxrpc/rxkad.c
96641 index f226709..0e735a8 100644
96642 --- a/net/rxrpc/rxkad.c
96643 +++ b/net/rxrpc/rxkad.c
96644 @@ -610,7 +610,7 @@ static int rxkad_issue_challenge(struct rxrpc_connection *conn)
96645
96646 len = iov[0].iov_len + iov[1].iov_len;
96647
96648 - hdr.serial = htonl(atomic_inc_return(&conn->serial));
96649 + hdr.serial = htonl(atomic_inc_return_unchecked(&conn->serial));
96650 _proto("Tx CHALLENGE %%%u", ntohl(hdr.serial));
96651
96652 ret = kernel_sendmsg(conn->trans->local->socket, &msg, iov, 2, len);
96653 @@ -660,7 +660,7 @@ static int rxkad_send_response(struct rxrpc_connection *conn,
96654
96655 len = iov[0].iov_len + iov[1].iov_len + iov[2].iov_len;
96656
96657 - hdr->serial = htonl(atomic_inc_return(&conn->serial));
96658 + hdr->serial = htonl(atomic_inc_return_unchecked(&conn->serial));
96659 _proto("Tx RESPONSE %%%u", ntohl(hdr->serial));
96660
96661 ret = kernel_sendmsg(conn->trans->local->socket, &msg, iov, 3, len);
96662 diff --git a/net/sctp/ipv6.c b/net/sctp/ipv6.c
96663 index e7b2d4f..bb1efd0 100644
96664 --- a/net/sctp/ipv6.c
96665 +++ b/net/sctp/ipv6.c
96666 @@ -962,7 +962,7 @@ static const struct inet6_protocol sctpv6_protocol = {
96667 .flags = INET6_PROTO_NOPOLICY | INET6_PROTO_FINAL,
96668 };
96669
96670 -static struct sctp_af sctp_af_inet6 = {
96671 +static struct sctp_af sctp_af_inet6 __read_only = {
96672 .sa_family = AF_INET6,
96673 .sctp_xmit = sctp_v6_xmit,
96674 .setsockopt = ipv6_setsockopt,
96675 @@ -994,7 +994,7 @@ static struct sctp_af sctp_af_inet6 = {
96676 #endif
96677 };
96678
96679 -static struct sctp_pf sctp_pf_inet6 = {
96680 +static struct sctp_pf sctp_pf_inet6 __read_only = {
96681 .event_msgname = sctp_inet6_event_msgname,
96682 .skb_msgname = sctp_inet6_skb_msgname,
96683 .af_supported = sctp_inet6_af_supported,
96684 @@ -1019,7 +1019,7 @@ void sctp_v6_pf_init(void)
96685
96686 void sctp_v6_pf_exit(void)
96687 {
96688 - list_del(&sctp_af_inet6.list);
96689 + pax_list_del(&sctp_af_inet6.list);
96690 }
96691
96692 /* Initialize IPv6 support and register with socket layer. */
96693 diff --git a/net/sctp/protocol.c b/net/sctp/protocol.c
96694 index 5e17092..19be1d4 100644
96695 --- a/net/sctp/protocol.c
96696 +++ b/net/sctp/protocol.c
96697 @@ -832,8 +832,10 @@ int sctp_register_af(struct sctp_af *af)
96698 return 0;
96699 }
96700
96701 + pax_open_kernel();
96702 INIT_LIST_HEAD(&af->list);
96703 - list_add_tail(&af->list, &sctp_address_families);
96704 + pax_close_kernel();
96705 + pax_list_add_tail(&af->list, &sctp_address_families);
96706 return 1;
96707 }
96708
96709 @@ -963,7 +965,7 @@ static inline int sctp_v4_xmit(struct sk_buff *skb,
96710
96711 static struct sctp_af sctp_af_inet;
96712
96713 -static struct sctp_pf sctp_pf_inet = {
96714 +static struct sctp_pf sctp_pf_inet __read_only = {
96715 .event_msgname = sctp_inet_event_msgname,
96716 .skb_msgname = sctp_inet_skb_msgname,
96717 .af_supported = sctp_inet_af_supported,
96718 @@ -1034,7 +1036,7 @@ static const struct net_protocol sctp_protocol = {
96719 };
96720
96721 /* IPv4 address related functions. */
96722 -static struct sctp_af sctp_af_inet = {
96723 +static struct sctp_af sctp_af_inet __read_only = {
96724 .sa_family = AF_INET,
96725 .sctp_xmit = sctp_v4_xmit,
96726 .setsockopt = ip_setsockopt,
96727 @@ -1119,7 +1121,7 @@ static void sctp_v4_pf_init(void)
96728
96729 static void sctp_v4_pf_exit(void)
96730 {
96731 - list_del(&sctp_af_inet.list);
96732 + pax_list_del(&sctp_af_inet.list);
96733 }
96734
96735 static int sctp_v4_protosw_init(void)
96736 diff --git a/net/sctp/sm_sideeffect.c b/net/sctp/sm_sideeffect.c
96737 index 1a6eef3..17e898f 100644
96738 --- a/net/sctp/sm_sideeffect.c
96739 +++ b/net/sctp/sm_sideeffect.c
96740 @@ -440,7 +440,7 @@ static void sctp_generate_sack_event(unsigned long data)
96741 sctp_generate_timeout_event(asoc, SCTP_EVENT_TIMEOUT_SACK);
96742 }
96743
96744 -sctp_timer_event_t *sctp_timer_events[SCTP_NUM_TIMEOUT_TYPES] = {
96745 +sctp_timer_event_t * const sctp_timer_events[SCTP_NUM_TIMEOUT_TYPES] = {
96746 NULL,
96747 sctp_generate_t1_cookie_event,
96748 sctp_generate_t1_init_event,
96749 diff --git a/net/sctp/socket.c b/net/sctp/socket.c
96750 index 911b71b..90ade0a 100644
96751 --- a/net/sctp/socket.c
96752 +++ b/net/sctp/socket.c
96753 @@ -2153,11 +2153,13 @@ static int sctp_setsockopt_events(struct sock *sk, char __user *optval,
96754 {
96755 struct sctp_association *asoc;
96756 struct sctp_ulpevent *event;
96757 + struct sctp_event_subscribe subscribe;
96758
96759 if (optlen > sizeof(struct sctp_event_subscribe))
96760 return -EINVAL;
96761 - if (copy_from_user(&sctp_sk(sk)->subscribe, optval, optlen))
96762 + if (copy_from_user(&subscribe, optval, optlen))
96763 return -EFAULT;
96764 + sctp_sk(sk)->subscribe = subscribe;
96765
96766 /*
96767 * At the time when a user app subscribes to SCTP_SENDER_DRY_EVENT,
96768 @@ -4213,13 +4215,16 @@ static int sctp_getsockopt_disable_fragments(struct sock *sk, int len,
96769 static int sctp_getsockopt_events(struct sock *sk, int len, char __user *optval,
96770 int __user *optlen)
96771 {
96772 + struct sctp_event_subscribe subscribe;
96773 +
96774 if (len <= 0)
96775 return -EINVAL;
96776 if (len > sizeof(struct sctp_event_subscribe))
96777 len = sizeof(struct sctp_event_subscribe);
96778 if (put_user(len, optlen))
96779 return -EFAULT;
96780 - if (copy_to_user(optval, &sctp_sk(sk)->subscribe, len))
96781 + subscribe = sctp_sk(sk)->subscribe;
96782 + if (copy_to_user(optval, &subscribe, len))
96783 return -EFAULT;
96784 return 0;
96785 }
96786 @@ -4237,6 +4242,8 @@ static int sctp_getsockopt_events(struct sock *sk, int len, char __user *optval,
96787 */
96788 static int sctp_getsockopt_autoclose(struct sock *sk, int len, char __user *optval, int __user *optlen)
96789 {
96790 + __u32 autoclose;
96791 +
96792 /* Applicable to UDP-style socket only */
96793 if (sctp_style(sk, TCP))
96794 return -EOPNOTSUPP;
96795 @@ -4245,7 +4252,8 @@ static int sctp_getsockopt_autoclose(struct sock *sk, int len, char __user *optv
96796 len = sizeof(int);
96797 if (put_user(len, optlen))
96798 return -EFAULT;
96799 - if (copy_to_user(optval, &sctp_sk(sk)->autoclose, sizeof(int)))
96800 + autoclose = sctp_sk(sk)->autoclose;
96801 + if (copy_to_user(optval, &autoclose, sizeof(int)))
96802 return -EFAULT;
96803 return 0;
96804 }
96805 @@ -4617,12 +4625,15 @@ static int sctp_getsockopt_delayed_ack(struct sock *sk, int len,
96806 */
96807 static int sctp_getsockopt_initmsg(struct sock *sk, int len, char __user *optval, int __user *optlen)
96808 {
96809 + struct sctp_initmsg initmsg;
96810 +
96811 if (len < sizeof(struct sctp_initmsg))
96812 return -EINVAL;
96813 len = sizeof(struct sctp_initmsg);
96814 if (put_user(len, optlen))
96815 return -EFAULT;
96816 - if (copy_to_user(optval, &sctp_sk(sk)->initmsg, len))
96817 + initmsg = sctp_sk(sk)->initmsg;
96818 + if (copy_to_user(optval, &initmsg, len))
96819 return -EFAULT;
96820 return 0;
96821 }
96822 @@ -4663,6 +4674,8 @@ static int sctp_getsockopt_peer_addrs(struct sock *sk, int len,
96823 addrlen = sctp_get_af_specific(temp.sa.sa_family)->sockaddr_len;
96824 if (space_left < addrlen)
96825 return -ENOMEM;
96826 + if (addrlen > sizeof(temp) || addrlen < 0)
96827 + return -EFAULT;
96828 if (copy_to_user(to, &temp, addrlen))
96829 return -EFAULT;
96830 to += addrlen;
96831 diff --git a/net/sctp/sysctl.c b/net/sctp/sysctl.c
96832 index 6b36561..4f21064 100644
96833 --- a/net/sctp/sysctl.c
96834 +++ b/net/sctp/sysctl.c
96835 @@ -301,7 +301,7 @@ static int proc_sctp_do_hmac_alg(struct ctl_table *ctl,
96836 {
96837 struct net *net = current->nsproxy->net_ns;
96838 char tmp[8];
96839 - struct ctl_table tbl;
96840 + ctl_table_no_const tbl;
96841 int ret;
96842 int changed = 0;
96843 char *none = "none";
96844 @@ -344,7 +344,7 @@ static int proc_sctp_do_hmac_alg(struct ctl_table *ctl,
96845
96846 int sctp_sysctl_net_register(struct net *net)
96847 {
96848 - struct ctl_table *table;
96849 + ctl_table_no_const *table;
96850 int i;
96851
96852 table = kmemdup(sctp_net_table, sizeof(sctp_net_table), GFP_KERNEL);
96853 diff --git a/net/socket.c b/net/socket.c
96854 index e83c416..17afbfa 100644
96855 --- a/net/socket.c
96856 +++ b/net/socket.c
96857 @@ -88,6 +88,7 @@
96858 #include <linux/magic.h>
96859 #include <linux/slab.h>
96860 #include <linux/xattr.h>
96861 +#include <linux/in.h>
96862
96863 #include <asm/uaccess.h>
96864 #include <asm/unistd.h>
96865 @@ -111,6 +112,8 @@ unsigned int sysctl_net_busy_read __read_mostly;
96866 unsigned int sysctl_net_busy_poll __read_mostly;
96867 #endif
96868
96869 +#include <linux/grsock.h>
96870 +
96871 static int sock_no_open(struct inode *irrelevant, struct file *dontcare);
96872 static ssize_t sock_aio_read(struct kiocb *iocb, const struct iovec *iov,
96873 unsigned long nr_segs, loff_t pos);
96874 @@ -162,7 +165,7 @@ static const struct file_operations socket_file_ops = {
96875 */
96876
96877 static DEFINE_SPINLOCK(net_family_lock);
96878 -static const struct net_proto_family __rcu *net_families[NPROTO] __read_mostly;
96879 +const struct net_proto_family __rcu *net_families[NPROTO] __read_mostly;
96880
96881 /*
96882 * Statistics counters of the socket lists
96883 @@ -328,7 +331,7 @@ static struct dentry *sockfs_mount(struct file_system_type *fs_type,
96884 &sockfs_dentry_operations, SOCKFS_MAGIC);
96885 }
96886
96887 -static struct vfsmount *sock_mnt __read_mostly;
96888 +struct vfsmount *sock_mnt __read_mostly;
96889
96890 static struct file_system_type sock_fs_type = {
96891 .name = "sockfs",
96892 @@ -1255,6 +1258,8 @@ int __sock_create(struct net *net, int family, int type, int protocol,
96893 return -EAFNOSUPPORT;
96894 if (type < 0 || type >= SOCK_MAX)
96895 return -EINVAL;
96896 + if (protocol < 0)
96897 + return -EINVAL;
96898
96899 /* Compatibility.
96900
96901 @@ -1275,6 +1280,20 @@ int __sock_create(struct net *net, int family, int type, int protocol,
96902 if (err)
96903 return err;
96904
96905 + if(!kern && !gr_search_socket(family, type, protocol)) {
96906 + if (rcu_access_pointer(net_families[family]) == NULL)
96907 + return -EAFNOSUPPORT;
96908 + else
96909 + return -EACCES;
96910 + }
96911 +
96912 + if (!kern && gr_handle_sock_all(family, type, protocol)) {
96913 + if (rcu_access_pointer(net_families[family]) == NULL)
96914 + return -EAFNOSUPPORT;
96915 + else
96916 + return -EACCES;
96917 + }
96918 +
96919 /*
96920 * Allocate the socket and allow the family to set things up. if
96921 * the protocol is 0, the family is instructed to select an appropriate
96922 @@ -1513,6 +1532,14 @@ SYSCALL_DEFINE3(bind, int, fd, struct sockaddr __user *, umyaddr, int, addrlen)
96923 if (sock) {
96924 err = move_addr_to_kernel(umyaddr, addrlen, &address);
96925 if (err >= 0) {
96926 + if (gr_handle_sock_server((struct sockaddr *)&address)) {
96927 + err = -EACCES;
96928 + goto error;
96929 + }
96930 + err = gr_search_bind(sock, (struct sockaddr_in *)&address);
96931 + if (err)
96932 + goto error;
96933 +
96934 err = security_socket_bind(sock,
96935 (struct sockaddr *)&address,
96936 addrlen);
96937 @@ -1521,6 +1548,7 @@ SYSCALL_DEFINE3(bind, int, fd, struct sockaddr __user *, umyaddr, int, addrlen)
96938 (struct sockaddr *)
96939 &address, addrlen);
96940 }
96941 +error:
96942 fput_light(sock->file, fput_needed);
96943 }
96944 return err;
96945 @@ -1544,10 +1572,20 @@ SYSCALL_DEFINE2(listen, int, fd, int, backlog)
96946 if ((unsigned int)backlog > somaxconn)
96947 backlog = somaxconn;
96948
96949 + if (gr_handle_sock_server_other(sock->sk)) {
96950 + err = -EPERM;
96951 + goto error;
96952 + }
96953 +
96954 + err = gr_search_listen(sock);
96955 + if (err)
96956 + goto error;
96957 +
96958 err = security_socket_listen(sock, backlog);
96959 if (!err)
96960 err = sock->ops->listen(sock, backlog);
96961
96962 +error:
96963 fput_light(sock->file, fput_needed);
96964 }
96965 return err;
96966 @@ -1591,6 +1629,18 @@ SYSCALL_DEFINE4(accept4, int, fd, struct sockaddr __user *, upeer_sockaddr,
96967 newsock->type = sock->type;
96968 newsock->ops = sock->ops;
96969
96970 + if (gr_handle_sock_server_other(sock->sk)) {
96971 + err = -EPERM;
96972 + sock_release(newsock);
96973 + goto out_put;
96974 + }
96975 +
96976 + err = gr_search_accept(sock);
96977 + if (err) {
96978 + sock_release(newsock);
96979 + goto out_put;
96980 + }
96981 +
96982 /*
96983 * We don't need try_module_get here, as the listening socket (sock)
96984 * has the protocol module (sock->ops->owner) held.
96985 @@ -1636,6 +1686,8 @@ SYSCALL_DEFINE4(accept4, int, fd, struct sockaddr __user *, upeer_sockaddr,
96986 fd_install(newfd, newfile);
96987 err = newfd;
96988
96989 + gr_attach_curr_ip(newsock->sk);
96990 +
96991 out_put:
96992 fput_light(sock->file, fput_needed);
96993 out:
96994 @@ -1668,6 +1720,7 @@ SYSCALL_DEFINE3(connect, int, fd, struct sockaddr __user *, uservaddr,
96995 int, addrlen)
96996 {
96997 struct socket *sock;
96998 + struct sockaddr *sck;
96999 struct sockaddr_storage address;
97000 int err, fput_needed;
97001
97002 @@ -1678,6 +1731,17 @@ SYSCALL_DEFINE3(connect, int, fd, struct sockaddr __user *, uservaddr,
97003 if (err < 0)
97004 goto out_put;
97005
97006 + sck = (struct sockaddr *)&address;
97007 +
97008 + if (gr_handle_sock_client(sck)) {
97009 + err = -EACCES;
97010 + goto out_put;
97011 + }
97012 +
97013 + err = gr_search_connect(sock, (struct sockaddr_in *)sck);
97014 + if (err)
97015 + goto out_put;
97016 +
97017 err =
97018 security_socket_connect(sock, (struct sockaddr *)&address, addrlen);
97019 if (err)
97020 @@ -1759,6 +1823,8 @@ SYSCALL_DEFINE3(getpeername, int, fd, struct sockaddr __user *, usockaddr,
97021 * the protocol.
97022 */
97023
97024 +asmlinkage long sys_sendto(int, void *, size_t, unsigned, struct sockaddr *, int);
97025 +
97026 SYSCALL_DEFINE6(sendto, int, fd, void __user *, buff, size_t, len,
97027 unsigned int, flags, struct sockaddr __user *, addr,
97028 int, addr_len)
97029 @@ -1825,7 +1891,7 @@ SYSCALL_DEFINE6(recvfrom, int, fd, void __user *, ubuf, size_t, size,
97030 struct socket *sock;
97031 struct iovec iov;
97032 struct msghdr msg;
97033 - struct sockaddr_storage address;
97034 + struct sockaddr_storage address = { };
97035 int err, err2;
97036 int fput_needed;
97037
97038 @@ -2047,7 +2113,7 @@ static int ___sys_sendmsg(struct socket *sock, struct msghdr __user *msg,
97039 * checking falls down on this.
97040 */
97041 if (copy_from_user(ctl_buf,
97042 - (void __user __force *)msg_sys->msg_control,
97043 + (void __force_user *)msg_sys->msg_control,
97044 ctl_len))
97045 goto out_freectl;
97046 msg_sys->msg_control = ctl_buf;
97047 @@ -2198,7 +2264,7 @@ static int ___sys_recvmsg(struct socket *sock, struct msghdr __user *msg,
97048 int err, total_len, len;
97049
97050 /* kernel mode address */
97051 - struct sockaddr_storage addr;
97052 + struct sockaddr_storage addr = { };
97053
97054 /* user mode address pointers */
97055 struct sockaddr __user *uaddr;
97056 @@ -2985,7 +3051,7 @@ static int bond_ioctl(struct net *net, unsigned int cmd,
97057 old_fs = get_fs();
97058 set_fs(KERNEL_DS);
97059 err = dev_ioctl(net, cmd,
97060 - (struct ifreq __user __force *) &kifr);
97061 + (struct ifreq __force_user *) &kifr);
97062 set_fs(old_fs);
97063
97064 return err;
97065 @@ -3094,7 +3160,7 @@ static int compat_sioc_ifmap(struct net *net, unsigned int cmd,
97066
97067 old_fs = get_fs();
97068 set_fs(KERNEL_DS);
97069 - err = dev_ioctl(net, cmd, (void __user __force *)&ifr);
97070 + err = dev_ioctl(net, cmd, (void __force_user *)&ifr);
97071 set_fs(old_fs);
97072
97073 if (cmd == SIOCGIFMAP && !err) {
97074 @@ -3199,7 +3265,7 @@ static int routing_ioctl(struct net *net, struct socket *sock,
97075 ret |= get_user(rtdev, &(ur4->rt_dev));
97076 if (rtdev) {
97077 ret |= copy_from_user(devname, compat_ptr(rtdev), 15);
97078 - r4.rt_dev = (char __user __force *)devname;
97079 + r4.rt_dev = (char __force_user *)devname;
97080 devname[15] = 0;
97081 } else
97082 r4.rt_dev = NULL;
97083 @@ -3425,8 +3491,8 @@ int kernel_getsockopt(struct socket *sock, int level, int optname,
97084 int __user *uoptlen;
97085 int err;
97086
97087 - uoptval = (char __user __force *) optval;
97088 - uoptlen = (int __user __force *) optlen;
97089 + uoptval = (char __force_user *) optval;
97090 + uoptlen = (int __force_user *) optlen;
97091
97092 set_fs(KERNEL_DS);
97093 if (level == SOL_SOCKET)
97094 @@ -3446,7 +3512,7 @@ int kernel_setsockopt(struct socket *sock, int level, int optname,
97095 char __user *uoptval;
97096 int err;
97097
97098 - uoptval = (char __user __force *) optval;
97099 + uoptval = (char __force_user *) optval;
97100
97101 set_fs(KERNEL_DS);
97102 if (level == SOL_SOCKET)
97103 diff --git a/net/sunrpc/auth_gss/svcauth_gss.c b/net/sunrpc/auth_gss/svcauth_gss.c
97104 index 09fb638..2e6a5c5 100644
97105 --- a/net/sunrpc/auth_gss/svcauth_gss.c
97106 +++ b/net/sunrpc/auth_gss/svcauth_gss.c
97107 @@ -1140,7 +1140,7 @@ static int gss_proxy_save_rsc(struct cache_detail *cd,
97108 uint64_t *handle)
97109 {
97110 struct rsc rsci, *rscp = NULL;
97111 - static atomic64_t ctxhctr;
97112 + static atomic64_unchecked_t ctxhctr = ATOMIC64_INIT(0);
97113 long long ctxh;
97114 struct gss_api_mech *gm = NULL;
97115 time_t expiry;
97116 @@ -1151,7 +1151,7 @@ static int gss_proxy_save_rsc(struct cache_detail *cd,
97117 status = -ENOMEM;
97118 /* the handle needs to be just a unique id,
97119 * use a static counter */
97120 - ctxh = atomic64_inc_return(&ctxhctr);
97121 + ctxh = atomic64_inc_return_unchecked(&ctxhctr);
97122
97123 /* make a copy for the caller */
97124 *handle = ctxh;
97125 diff --git a/net/sunrpc/clnt.c b/net/sunrpc/clnt.c
97126 index 941d19f..c85ff07 100644
97127 --- a/net/sunrpc/clnt.c
97128 +++ b/net/sunrpc/clnt.c
97129 @@ -1319,7 +1319,9 @@ call_start(struct rpc_task *task)
97130 (RPC_IS_ASYNC(task) ? "async" : "sync"));
97131
97132 /* Increment call count */
97133 - task->tk_msg.rpc_proc->p_count++;
97134 + pax_open_kernel();
97135 + (*(unsigned int *)&task->tk_msg.rpc_proc->p_count)++;
97136 + pax_close_kernel();
97137 clnt->cl_stats->rpccnt++;
97138 task->tk_action = call_reserve;
97139 }
97140 diff --git a/net/sunrpc/sched.c b/net/sunrpc/sched.c
97141 index ff3cc4b..7612a9e 100644
97142 --- a/net/sunrpc/sched.c
97143 +++ b/net/sunrpc/sched.c
97144 @@ -261,9 +261,9 @@ static int rpc_wait_bit_killable(void *word)
97145 #if defined(RPC_DEBUG) || defined(RPC_TRACEPOINTS)
97146 static void rpc_task_set_debuginfo(struct rpc_task *task)
97147 {
97148 - static atomic_t rpc_pid;
97149 + static atomic_unchecked_t rpc_pid;
97150
97151 - task->tk_pid = atomic_inc_return(&rpc_pid);
97152 + task->tk_pid = atomic_inc_return_unchecked(&rpc_pid);
97153 }
97154 #else
97155 static inline void rpc_task_set_debuginfo(struct rpc_task *task)
97156 diff --git a/net/sunrpc/svc.c b/net/sunrpc/svc.c
97157 index b974571..678ed90 100644
97158 --- a/net/sunrpc/svc.c
97159 +++ b/net/sunrpc/svc.c
97160 @@ -1160,7 +1160,9 @@ svc_process_common(struct svc_rqst *rqstp, struct kvec *argv, struct kvec *resv)
97161 svc_putnl(resv, RPC_SUCCESS);
97162
97163 /* Bump per-procedure stats counter */
97164 - procp->pc_count++;
97165 + pax_open_kernel();
97166 + (*(unsigned int *)&procp->pc_count)++;
97167 + pax_close_kernel();
97168
97169 /* Initialize storage for argp and resp */
97170 memset(rqstp->rq_argp, 0, procp->pc_argsize);
97171 diff --git a/net/sunrpc/svcauth_unix.c b/net/sunrpc/svcauth_unix.c
97172 index 621ca7b..59421dd 100644
97173 --- a/net/sunrpc/svcauth_unix.c
97174 +++ b/net/sunrpc/svcauth_unix.c
97175 @@ -414,7 +414,7 @@ struct unix_gid {
97176 struct group_info *gi;
97177 };
97178
97179 -static int unix_gid_hash(kuid_t uid)
97180 +static int __intentional_overflow(-1) unix_gid_hash(kuid_t uid)
97181 {
97182 return hash_long(from_kuid(&init_user_ns, uid), GID_HASHBITS);
97183 }
97184 @@ -470,7 +470,7 @@ static void unix_gid_request(struct cache_detail *cd,
97185 (*bpp)[-1] = '\n';
97186 }
97187
97188 -static struct unix_gid *unix_gid_lookup(struct cache_detail *cd, kuid_t uid);
97189 +static struct unix_gid * __intentional_overflow(-1) unix_gid_lookup(struct cache_detail *cd, kuid_t uid);
97190
97191 static int unix_gid_parse(struct cache_detail *cd,
97192 char *mesg, int mlen)
97193 diff --git a/net/sunrpc/xprtrdma/svc_rdma.c b/net/sunrpc/xprtrdma/svc_rdma.c
97194 index c1b6270..05089c1 100644
97195 --- a/net/sunrpc/xprtrdma/svc_rdma.c
97196 +++ b/net/sunrpc/xprtrdma/svc_rdma.c
97197 @@ -62,15 +62,15 @@ unsigned int svcrdma_max_req_size = RPCRDMA_MAX_REQ_SIZE;
97198 static unsigned int min_max_inline = 4096;
97199 static unsigned int max_max_inline = 65536;
97200
97201 -atomic_t rdma_stat_recv;
97202 -atomic_t rdma_stat_read;
97203 -atomic_t rdma_stat_write;
97204 -atomic_t rdma_stat_sq_starve;
97205 -atomic_t rdma_stat_rq_starve;
97206 -atomic_t rdma_stat_rq_poll;
97207 -atomic_t rdma_stat_rq_prod;
97208 -atomic_t rdma_stat_sq_poll;
97209 -atomic_t rdma_stat_sq_prod;
97210 +atomic_unchecked_t rdma_stat_recv;
97211 +atomic_unchecked_t rdma_stat_read;
97212 +atomic_unchecked_t rdma_stat_write;
97213 +atomic_unchecked_t rdma_stat_sq_starve;
97214 +atomic_unchecked_t rdma_stat_rq_starve;
97215 +atomic_unchecked_t rdma_stat_rq_poll;
97216 +atomic_unchecked_t rdma_stat_rq_prod;
97217 +atomic_unchecked_t rdma_stat_sq_poll;
97218 +atomic_unchecked_t rdma_stat_sq_prod;
97219
97220 /* Temporary NFS request map and context caches */
97221 struct kmem_cache *svc_rdma_map_cachep;
97222 @@ -110,7 +110,7 @@ static int read_reset_stat(struct ctl_table *table, int write,
97223 len -= *ppos;
97224 if (len > *lenp)
97225 len = *lenp;
97226 - if (len && copy_to_user(buffer, str_buf, len))
97227 + if (len > sizeof str_buf || (len && copy_to_user(buffer, str_buf, len)))
97228 return -EFAULT;
97229 *lenp = len;
97230 *ppos += len;
97231 @@ -151,63 +151,63 @@ static struct ctl_table svcrdma_parm_table[] = {
97232 {
97233 .procname = "rdma_stat_read",
97234 .data = &rdma_stat_read,
97235 - .maxlen = sizeof(atomic_t),
97236 + .maxlen = sizeof(atomic_unchecked_t),
97237 .mode = 0644,
97238 .proc_handler = read_reset_stat,
97239 },
97240 {
97241 .procname = "rdma_stat_recv",
97242 .data = &rdma_stat_recv,
97243 - .maxlen = sizeof(atomic_t),
97244 + .maxlen = sizeof(atomic_unchecked_t),
97245 .mode = 0644,
97246 .proc_handler = read_reset_stat,
97247 },
97248 {
97249 .procname = "rdma_stat_write",
97250 .data = &rdma_stat_write,
97251 - .maxlen = sizeof(atomic_t),
97252 + .maxlen = sizeof(atomic_unchecked_t),
97253 .mode = 0644,
97254 .proc_handler = read_reset_stat,
97255 },
97256 {
97257 .procname = "rdma_stat_sq_starve",
97258 .data = &rdma_stat_sq_starve,
97259 - .maxlen = sizeof(atomic_t),
97260 + .maxlen = sizeof(atomic_unchecked_t),
97261 .mode = 0644,
97262 .proc_handler = read_reset_stat,
97263 },
97264 {
97265 .procname = "rdma_stat_rq_starve",
97266 .data = &rdma_stat_rq_starve,
97267 - .maxlen = sizeof(atomic_t),
97268 + .maxlen = sizeof(atomic_unchecked_t),
97269 .mode = 0644,
97270 .proc_handler = read_reset_stat,
97271 },
97272 {
97273 .procname = "rdma_stat_rq_poll",
97274 .data = &rdma_stat_rq_poll,
97275 - .maxlen = sizeof(atomic_t),
97276 + .maxlen = sizeof(atomic_unchecked_t),
97277 .mode = 0644,
97278 .proc_handler = read_reset_stat,
97279 },
97280 {
97281 .procname = "rdma_stat_rq_prod",
97282 .data = &rdma_stat_rq_prod,
97283 - .maxlen = sizeof(atomic_t),
97284 + .maxlen = sizeof(atomic_unchecked_t),
97285 .mode = 0644,
97286 .proc_handler = read_reset_stat,
97287 },
97288 {
97289 .procname = "rdma_stat_sq_poll",
97290 .data = &rdma_stat_sq_poll,
97291 - .maxlen = sizeof(atomic_t),
97292 + .maxlen = sizeof(atomic_unchecked_t),
97293 .mode = 0644,
97294 .proc_handler = read_reset_stat,
97295 },
97296 {
97297 .procname = "rdma_stat_sq_prod",
97298 .data = &rdma_stat_sq_prod,
97299 - .maxlen = sizeof(atomic_t),
97300 + .maxlen = sizeof(atomic_unchecked_t),
97301 .mode = 0644,
97302 .proc_handler = read_reset_stat,
97303 },
97304 diff --git a/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c b/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c
97305 index 0ce7552..d074459 100644
97306 --- a/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c
97307 +++ b/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c
97308 @@ -501,7 +501,7 @@ next_sge:
97309 svc_rdma_put_context(ctxt, 0);
97310 goto out;
97311 }
97312 - atomic_inc(&rdma_stat_read);
97313 + atomic_inc_unchecked(&rdma_stat_read);
97314
97315 if (read_wr.num_sge < chl_map->ch[ch_no].count) {
97316 chl_map->ch[ch_no].count -= read_wr.num_sge;
97317 @@ -611,7 +611,7 @@ int svc_rdma_recvfrom(struct svc_rqst *rqstp)
97318 dto_q);
97319 list_del_init(&ctxt->dto_q);
97320 } else {
97321 - atomic_inc(&rdma_stat_rq_starve);
97322 + atomic_inc_unchecked(&rdma_stat_rq_starve);
97323 clear_bit(XPT_DATA, &xprt->xpt_flags);
97324 ctxt = NULL;
97325 }
97326 @@ -631,7 +631,7 @@ int svc_rdma_recvfrom(struct svc_rqst *rqstp)
97327 dprintk("svcrdma: processing ctxt=%p on xprt=%p, rqstp=%p, status=%d\n",
97328 ctxt, rdma_xprt, rqstp, ctxt->wc_status);
97329 BUG_ON(ctxt->wc_status != IB_WC_SUCCESS);
97330 - atomic_inc(&rdma_stat_recv);
97331 + atomic_inc_unchecked(&rdma_stat_recv);
97332
97333 /* Build up the XDR from the receive buffers. */
97334 rdma_build_arg_xdr(rqstp, ctxt, ctxt->byte_len);
97335 diff --git a/net/sunrpc/xprtrdma/svc_rdma_sendto.c b/net/sunrpc/xprtrdma/svc_rdma_sendto.c
97336 index c1d124d..acfc59e 100644
97337 --- a/net/sunrpc/xprtrdma/svc_rdma_sendto.c
97338 +++ b/net/sunrpc/xprtrdma/svc_rdma_sendto.c
97339 @@ -362,7 +362,7 @@ static int send_write(struct svcxprt_rdma *xprt, struct svc_rqst *rqstp,
97340 write_wr.wr.rdma.remote_addr = to;
97341
97342 /* Post It */
97343 - atomic_inc(&rdma_stat_write);
97344 + atomic_inc_unchecked(&rdma_stat_write);
97345 if (svc_rdma_send(xprt, &write_wr))
97346 goto err;
97347 return 0;
97348 diff --git a/net/sunrpc/xprtrdma/svc_rdma_transport.c b/net/sunrpc/xprtrdma/svc_rdma_transport.c
97349 index 62e4f9b..dd3f2d7 100644
97350 --- a/net/sunrpc/xprtrdma/svc_rdma_transport.c
97351 +++ b/net/sunrpc/xprtrdma/svc_rdma_transport.c
97352 @@ -292,7 +292,7 @@ static void rq_cq_reap(struct svcxprt_rdma *xprt)
97353 return;
97354
97355 ib_req_notify_cq(xprt->sc_rq_cq, IB_CQ_NEXT_COMP);
97356 - atomic_inc(&rdma_stat_rq_poll);
97357 + atomic_inc_unchecked(&rdma_stat_rq_poll);
97358
97359 while ((ret = ib_poll_cq(xprt->sc_rq_cq, 1, &wc)) > 0) {
97360 ctxt = (struct svc_rdma_op_ctxt *)(unsigned long)wc.wr_id;
97361 @@ -314,7 +314,7 @@ static void rq_cq_reap(struct svcxprt_rdma *xprt)
97362 }
97363
97364 if (ctxt)
97365 - atomic_inc(&rdma_stat_rq_prod);
97366 + atomic_inc_unchecked(&rdma_stat_rq_prod);
97367
97368 set_bit(XPT_DATA, &xprt->sc_xprt.xpt_flags);
97369 /*
97370 @@ -386,7 +386,7 @@ static void sq_cq_reap(struct svcxprt_rdma *xprt)
97371 return;
97372
97373 ib_req_notify_cq(xprt->sc_sq_cq, IB_CQ_NEXT_COMP);
97374 - atomic_inc(&rdma_stat_sq_poll);
97375 + atomic_inc_unchecked(&rdma_stat_sq_poll);
97376 while ((ret = ib_poll_cq(cq, 1, &wc)) > 0) {
97377 if (wc.status != IB_WC_SUCCESS)
97378 /* Close the transport */
97379 @@ -404,7 +404,7 @@ static void sq_cq_reap(struct svcxprt_rdma *xprt)
97380 }
97381
97382 if (ctxt)
97383 - atomic_inc(&rdma_stat_sq_prod);
97384 + atomic_inc_unchecked(&rdma_stat_sq_prod);
97385 }
97386
97387 static void sq_comp_handler(struct ib_cq *cq, void *cq_context)
97388 @@ -1262,7 +1262,7 @@ int svc_rdma_send(struct svcxprt_rdma *xprt, struct ib_send_wr *wr)
97389 spin_lock_bh(&xprt->sc_lock);
97390 if (xprt->sc_sq_depth < atomic_read(&xprt->sc_sq_count) + wr_count) {
97391 spin_unlock_bh(&xprt->sc_lock);
97392 - atomic_inc(&rdma_stat_sq_starve);
97393 + atomic_inc_unchecked(&rdma_stat_sq_starve);
97394
97395 /* See if we can opportunistically reap SQ WR to make room */
97396 sq_cq_reap(xprt);
97397 diff --git a/net/sysctl_net.c b/net/sysctl_net.c
97398 index e7000be..e3b0ba7 100644
97399 --- a/net/sysctl_net.c
97400 +++ b/net/sysctl_net.c
97401 @@ -46,7 +46,7 @@ static int net_ctl_permissions(struct ctl_table_header *head,
97402 kgid_t root_gid = make_kgid(net->user_ns, 0);
97403
97404 /* Allow network administrator to have same access as root. */
97405 - if (ns_capable(net->user_ns, CAP_NET_ADMIN) ||
97406 + if (ns_capable_nolog(net->user_ns, CAP_NET_ADMIN) ||
97407 uid_eq(root_uid, current_euid())) {
97408 int mode = (table->mode >> 6) & 7;
97409 return (mode << 6) | (mode << 3) | mode;
97410 diff --git a/net/tipc/link.c b/net/tipc/link.c
97411 index 0cc3d90..cc42021 100644
97412 --- a/net/tipc/link.c
97413 +++ b/net/tipc/link.c
97414 @@ -1165,7 +1165,7 @@ static int link_send_sections_long(struct tipc_port *sender,
97415 struct tipc_msg fragm_hdr;
97416 struct sk_buff *buf, *buf_chain, *prev;
97417 u32 fragm_crs, fragm_rest, hsz, sect_rest;
97418 - const unchar *sect_crs;
97419 + const unchar __user *sect_crs;
97420 int curr_sect;
97421 u32 fragm_no;
97422 int res = 0;
97423 @@ -1207,7 +1207,7 @@ again:
97424
97425 if (!sect_rest) {
97426 sect_rest = msg_sect[++curr_sect].iov_len;
97427 - sect_crs = (const unchar *)msg_sect[curr_sect].iov_base;
97428 + sect_crs = (const unchar __user *)msg_sect[curr_sect].iov_base;
97429 }
97430
97431 if (sect_rest < fragm_rest)
97432 diff --git a/net/tipc/msg.c b/net/tipc/msg.c
97433 index ced60e2..54eab6c 100644
97434 --- a/net/tipc/msg.c
97435 +++ b/net/tipc/msg.c
97436 @@ -93,7 +93,7 @@ int tipc_msg_build(struct tipc_msg *hdr, struct iovec const *msg_sect,
97437 skb_copy_to_linear_data(*buf, hdr, hsz);
97438 for (res = 1, cnt = 0; res && (cnt < num_sect); cnt++) {
97439 skb_copy_to_linear_data_offset(*buf, pos,
97440 - msg_sect[cnt].iov_base,
97441 + (const void __force_kernel *)msg_sect[cnt].iov_base,
97442 msg_sect[cnt].iov_len);
97443 pos += msg_sect[cnt].iov_len;
97444 }
97445 diff --git a/net/tipc/subscr.c b/net/tipc/subscr.c
97446 index d38bb45..4fd6ac6 100644
97447 --- a/net/tipc/subscr.c
97448 +++ b/net/tipc/subscr.c
97449 @@ -98,7 +98,7 @@ static void subscr_send_event(struct tipc_subscription *sub, u32 found_lower,
97450 struct kvec msg_sect;
97451 int ret;
97452
97453 - msg_sect.iov_base = (void *)&sub->evt;
97454 + msg_sect.iov_base = (void __force_user *)&sub->evt;
97455 msg_sect.iov_len = sizeof(struct tipc_event);
97456
97457 sub->evt.event = htohl(event, sub->swap);
97458 diff --git a/net/unix/af_unix.c b/net/unix/af_unix.c
97459 index 01625cc..d486b64 100644
97460 --- a/net/unix/af_unix.c
97461 +++ b/net/unix/af_unix.c
97462 @@ -784,6 +784,12 @@ static struct sock *unix_find_other(struct net *net,
97463 err = -ECONNREFUSED;
97464 if (!S_ISSOCK(inode->i_mode))
97465 goto put_fail;
97466 +
97467 + if (!gr_acl_handle_unix(path.dentry, path.mnt)) {
97468 + err = -EACCES;
97469 + goto put_fail;
97470 + }
97471 +
97472 u = unix_find_socket_byinode(inode);
97473 if (!u)
97474 goto put_fail;
97475 @@ -804,6 +810,13 @@ static struct sock *unix_find_other(struct net *net,
97476 if (u) {
97477 struct dentry *dentry;
97478 dentry = unix_sk(u)->path.dentry;
97479 +
97480 + if (!gr_handle_chroot_unix(pid_vnr(u->sk_peer_pid))) {
97481 + err = -EPERM;
97482 + sock_put(u);
97483 + goto fail;
97484 + }
97485 +
97486 if (dentry)
97487 touch_atime(&unix_sk(u)->path);
97488 } else
97489 @@ -837,12 +850,18 @@ static int unix_mknod(const char *sun_path, umode_t mode, struct path *res)
97490 */
97491 err = security_path_mknod(&path, dentry, mode, 0);
97492 if (!err) {
97493 + if (!gr_acl_handle_mknod(dentry, path.dentry, path.mnt, mode)) {
97494 + err = -EACCES;
97495 + goto out;
97496 + }
97497 err = vfs_mknod(path.dentry->d_inode, dentry, mode, 0);
97498 if (!err) {
97499 res->mnt = mntget(path.mnt);
97500 res->dentry = dget(dentry);
97501 + gr_handle_create(dentry, path.mnt);
97502 }
97503 }
97504 +out:
97505 done_path_create(&path, dentry);
97506 return err;
97507 }
97508 @@ -2328,9 +2347,13 @@ static int unix_seq_show(struct seq_file *seq, void *v)
97509 seq_puts(seq, "Num RefCount Protocol Flags Type St "
97510 "Inode Path\n");
97511 else {
97512 - struct sock *s = v;
97513 + struct sock *s = v, *peer;
97514 struct unix_sock *u = unix_sk(s);
97515 unix_state_lock(s);
97516 + peer = unix_peer(s);
97517 + unix_state_unlock(s);
97518 +
97519 + unix_state_double_lock(s, peer);
97520
97521 seq_printf(seq, "%pK: %08X %08X %08X %04X %02X %5lu",
97522 s,
97523 @@ -2357,8 +2380,10 @@ static int unix_seq_show(struct seq_file *seq, void *v)
97524 }
97525 for ( ; i < len; i++)
97526 seq_putc(seq, u->addr->name->sun_path[i]);
97527 - }
97528 - unix_state_unlock(s);
97529 + } else if (peer)
97530 + seq_printf(seq, " P%lu", sock_i_ino(peer));
97531 +
97532 + unix_state_double_unlock(s, peer);
97533 seq_putc(seq, '\n');
97534 }
97535
97536 diff --git a/net/unix/sysctl_net_unix.c b/net/unix/sysctl_net_unix.c
97537 index b3d5150..ff3a837 100644
97538 --- a/net/unix/sysctl_net_unix.c
97539 +++ b/net/unix/sysctl_net_unix.c
97540 @@ -28,7 +28,7 @@ static struct ctl_table unix_table[] = {
97541
97542 int __net_init unix_sysctl_register(struct net *net)
97543 {
97544 - struct ctl_table *table;
97545 + ctl_table_no_const *table;
97546
97547 table = kmemdup(unix_table, sizeof(unix_table), GFP_KERNEL);
97548 if (table == NULL)
97549 diff --git a/net/wireless/wext-core.c b/net/wireless/wext-core.c
97550 index c8717c1..08539f5 100644
97551 --- a/net/wireless/wext-core.c
97552 +++ b/net/wireless/wext-core.c
97553 @@ -748,8 +748,7 @@ static int ioctl_standard_iw_point(struct iw_point *iwp, unsigned int cmd,
97554 */
97555
97556 /* Support for very large requests */
97557 - if ((descr->flags & IW_DESCR_FLAG_NOMAX) &&
97558 - (user_length > descr->max_tokens)) {
97559 + if (user_length > descr->max_tokens) {
97560 /* Allow userspace to GET more than max so
97561 * we can support any size GET requests.
97562 * There is still a limit : -ENOMEM.
97563 @@ -788,22 +787,6 @@ static int ioctl_standard_iw_point(struct iw_point *iwp, unsigned int cmd,
97564 }
97565 }
97566
97567 - if (IW_IS_GET(cmd) && !(descr->flags & IW_DESCR_FLAG_NOMAX)) {
97568 - /*
97569 - * If this is a GET, but not NOMAX, it means that the extra
97570 - * data is not bounded by userspace, but by max_tokens. Thus
97571 - * set the length to max_tokens. This matches the extra data
97572 - * allocation.
97573 - * The driver should fill it with the number of tokens it
97574 - * provided, and it may check iwp->length rather than having
97575 - * knowledge of max_tokens. If the driver doesn't change the
97576 - * iwp->length, this ioctl just copies back max_token tokens
97577 - * filled with zeroes. Hopefully the driver isn't claiming
97578 - * them to be valid data.
97579 - */
97580 - iwp->length = descr->max_tokens;
97581 - }
97582 -
97583 err = handler(dev, info, (union iwreq_data *) iwp, extra);
97584
97585 iwp->length += essid_compat;
97586 diff --git a/net/xfrm/xfrm_policy.c b/net/xfrm/xfrm_policy.c
97587 index 76e1873..4a12664 100644
97588 --- a/net/xfrm/xfrm_policy.c
97589 +++ b/net/xfrm/xfrm_policy.c
97590 @@ -332,7 +332,7 @@ static void xfrm_policy_kill(struct xfrm_policy *policy)
97591 {
97592 policy->walk.dead = 1;
97593
97594 - atomic_inc(&policy->genid);
97595 + atomic_inc_unchecked(&policy->genid);
97596
97597 if (del_timer(&policy->polq.hold_timer))
97598 xfrm_pol_put(policy);
97599 @@ -660,7 +660,7 @@ int xfrm_policy_insert(int dir, struct xfrm_policy *policy, int excl)
97600 hlist_add_head(&policy->bydst, chain);
97601 xfrm_pol_hold(policy);
97602 net->xfrm.policy_count[dir]++;
97603 - atomic_inc(&flow_cache_genid);
97604 + atomic_inc_unchecked(&flow_cache_genid);
97605
97606 /* After previous checking, family can either be AF_INET or AF_INET6 */
97607 if (policy->family == AF_INET)
97608 @@ -1636,7 +1636,7 @@ free_dst:
97609 goto out;
97610 }
97611
97612 -static int inline
97613 +static inline int
97614 xfrm_dst_alloc_copy(void **target, const void *src, int size)
97615 {
97616 if (!*target) {
97617 @@ -1648,7 +1648,7 @@ xfrm_dst_alloc_copy(void **target, const void *src, int size)
97618 return 0;
97619 }
97620
97621 -static int inline
97622 +static inline int
97623 xfrm_dst_update_parent(struct dst_entry *dst, const struct xfrm_selector *sel)
97624 {
97625 #ifdef CONFIG_XFRM_SUB_POLICY
97626 @@ -1660,7 +1660,7 @@ xfrm_dst_update_parent(struct dst_entry *dst, const struct xfrm_selector *sel)
97627 #endif
97628 }
97629
97630 -static int inline
97631 +static inline int
97632 xfrm_dst_update_origin(struct dst_entry *dst, const struct flowi *fl)
97633 {
97634 #ifdef CONFIG_XFRM_SUB_POLICY
97635 @@ -1754,7 +1754,7 @@ xfrm_resolve_and_create_bundle(struct xfrm_policy **pols, int num_pols,
97636
97637 xdst->num_pols = num_pols;
97638 memcpy(xdst->pols, pols, sizeof(struct xfrm_policy*) * num_pols);
97639 - xdst->policy_genid = atomic_read(&pols[0]->genid);
97640 + xdst->policy_genid = atomic_read_unchecked(&pols[0]->genid);
97641
97642 return xdst;
97643 }
97644 @@ -2575,11 +2575,12 @@ void xfrm_garbage_collect(struct net *net)
97645 }
97646 EXPORT_SYMBOL(xfrm_garbage_collect);
97647
97648 -static void xfrm_garbage_collect_deferred(struct net *net)
97649 +void xfrm_garbage_collect_deferred(struct net *net)
97650 {
97651 flow_cache_flush_deferred();
97652 __xfrm_garbage_collect(net);
97653 }
97654 +EXPORT_SYMBOL(xfrm_garbage_collect_deferred);
97655
97656 static void xfrm_init_pmtu(struct dst_entry *dst)
97657 {
97658 @@ -2629,7 +2630,7 @@ static int xfrm_bundle_ok(struct xfrm_dst *first)
97659 if (xdst->xfrm_genid != dst->xfrm->genid)
97660 return 0;
97661 if (xdst->num_pols > 0 &&
97662 - xdst->policy_genid != atomic_read(&xdst->pols[0]->genid))
97663 + xdst->policy_genid != atomic_read_unchecked(&xdst->pols[0]->genid))
97664 return 0;
97665
97666 mtu = dst_mtu(dst->child);
97667 @@ -2717,8 +2718,6 @@ int xfrm_policy_register_afinfo(struct xfrm_policy_afinfo *afinfo)
97668 dst_ops->link_failure = xfrm_link_failure;
97669 if (likely(dst_ops->neigh_lookup == NULL))
97670 dst_ops->neigh_lookup = xfrm_neigh_lookup;
97671 - if (likely(afinfo->garbage_collect == NULL))
97672 - afinfo->garbage_collect = xfrm_garbage_collect_deferred;
97673 rcu_assign_pointer(xfrm_policy_afinfo[afinfo->family], afinfo);
97674 }
97675 spin_unlock(&xfrm_policy_afinfo_lock);
97676 @@ -2772,7 +2771,6 @@ int xfrm_policy_unregister_afinfo(struct xfrm_policy_afinfo *afinfo)
97677 dst_ops->check = NULL;
97678 dst_ops->negative_advice = NULL;
97679 dst_ops->link_failure = NULL;
97680 - afinfo->garbage_collect = NULL;
97681 }
97682 return err;
97683 }
97684 @@ -3155,7 +3153,7 @@ static int xfrm_policy_migrate(struct xfrm_policy *pol,
97685 sizeof(pol->xfrm_vec[i].saddr));
97686 pol->xfrm_vec[i].encap_family = mp->new_family;
97687 /* flush bundles */
97688 - atomic_inc(&pol->genid);
97689 + atomic_inc_unchecked(&pol->genid);
97690 }
97691 }
97692
97693 diff --git a/net/xfrm/xfrm_state.c b/net/xfrm/xfrm_state.c
97694 index b9c3f9e..4767526 100644
97695 --- a/net/xfrm/xfrm_state.c
97696 +++ b/net/xfrm/xfrm_state.c
97697 @@ -174,12 +174,14 @@ int xfrm_register_type(const struct xfrm_type *type, unsigned short family)
97698
97699 if (unlikely(afinfo == NULL))
97700 return -EAFNOSUPPORT;
97701 - typemap = afinfo->type_map;
97702 + typemap = (const struct xfrm_type **)afinfo->type_map;
97703 spin_lock_bh(&xfrm_type_lock);
97704
97705 - if (likely(typemap[type->proto] == NULL))
97706 + if (likely(typemap[type->proto] == NULL)) {
97707 + pax_open_kernel();
97708 typemap[type->proto] = type;
97709 - else
97710 + pax_close_kernel();
97711 + } else
97712 err = -EEXIST;
97713 spin_unlock_bh(&xfrm_type_lock);
97714 xfrm_state_put_afinfo(afinfo);
97715 @@ -195,13 +197,16 @@ int xfrm_unregister_type(const struct xfrm_type *type, unsigned short family)
97716
97717 if (unlikely(afinfo == NULL))
97718 return -EAFNOSUPPORT;
97719 - typemap = afinfo->type_map;
97720 + typemap = (const struct xfrm_type **)afinfo->type_map;
97721 spin_lock_bh(&xfrm_type_lock);
97722
97723 if (unlikely(typemap[type->proto] != type))
97724 err = -ENOENT;
97725 - else
97726 + else {
97727 + pax_open_kernel();
97728 typemap[type->proto] = NULL;
97729 + pax_close_kernel();
97730 + }
97731 spin_unlock_bh(&xfrm_type_lock);
97732 xfrm_state_put_afinfo(afinfo);
97733 return err;
97734 @@ -211,7 +216,6 @@ EXPORT_SYMBOL(xfrm_unregister_type);
97735 static const struct xfrm_type *xfrm_get_type(u8 proto, unsigned short family)
97736 {
97737 struct xfrm_state_afinfo *afinfo;
97738 - const struct xfrm_type **typemap;
97739 const struct xfrm_type *type;
97740 int modload_attempted = 0;
97741
97742 @@ -219,9 +223,8 @@ retry:
97743 afinfo = xfrm_state_get_afinfo(family);
97744 if (unlikely(afinfo == NULL))
97745 return NULL;
97746 - typemap = afinfo->type_map;
97747
97748 - type = typemap[proto];
97749 + type = afinfo->type_map[proto];
97750 if (unlikely(type && !try_module_get(type->owner)))
97751 type = NULL;
97752 if (!type && !modload_attempted) {
97753 @@ -255,7 +258,7 @@ int xfrm_register_mode(struct xfrm_mode *mode, int family)
97754 return -EAFNOSUPPORT;
97755
97756 err = -EEXIST;
97757 - modemap = afinfo->mode_map;
97758 + modemap = (struct xfrm_mode **)afinfo->mode_map;
97759 spin_lock_bh(&xfrm_mode_lock);
97760 if (modemap[mode->encap])
97761 goto out;
97762 @@ -264,8 +267,10 @@ int xfrm_register_mode(struct xfrm_mode *mode, int family)
97763 if (!try_module_get(afinfo->owner))
97764 goto out;
97765
97766 - mode->afinfo = afinfo;
97767 + pax_open_kernel();
97768 + *(const void **)&mode->afinfo = afinfo;
97769 modemap[mode->encap] = mode;
97770 + pax_close_kernel();
97771 err = 0;
97772
97773 out:
97774 @@ -289,10 +294,12 @@ int xfrm_unregister_mode(struct xfrm_mode *mode, int family)
97775 return -EAFNOSUPPORT;
97776
97777 err = -ENOENT;
97778 - modemap = afinfo->mode_map;
97779 + modemap = (struct xfrm_mode **)afinfo->mode_map;
97780 spin_lock_bh(&xfrm_mode_lock);
97781 if (likely(modemap[mode->encap] == mode)) {
97782 + pax_open_kernel();
97783 modemap[mode->encap] = NULL;
97784 + pax_close_kernel();
97785 module_put(mode->afinfo->owner);
97786 err = 0;
97787 }
97788 @@ -1486,10 +1493,10 @@ EXPORT_SYMBOL(xfrm_find_acq_byseq);
97789 u32 xfrm_get_acqseq(void)
97790 {
97791 u32 res;
97792 - static atomic_t acqseq;
97793 + static atomic_unchecked_t acqseq;
97794
97795 do {
97796 - res = atomic_inc_return(&acqseq);
97797 + res = atomic_inc_return_unchecked(&acqseq);
97798 } while (!res);
97799
97800 return res;
97801 diff --git a/net/xfrm/xfrm_sysctl.c b/net/xfrm/xfrm_sysctl.c
97802 index 05a6e3d..6716ec9 100644
97803 --- a/net/xfrm/xfrm_sysctl.c
97804 +++ b/net/xfrm/xfrm_sysctl.c
97805 @@ -42,7 +42,7 @@ static struct ctl_table xfrm_table[] = {
97806
97807 int __net_init xfrm_sysctl_init(struct net *net)
97808 {
97809 - struct ctl_table *table;
97810 + ctl_table_no_const *table;
97811
97812 __xfrm_sysctl_init(net);
97813
97814 diff --git a/scripts/Makefile.build b/scripts/Makefile.build
97815 index d5d859c..781cbcb 100644
97816 --- a/scripts/Makefile.build
97817 +++ b/scripts/Makefile.build
97818 @@ -111,7 +111,7 @@ endif
97819 endif
97820
97821 # Do not include host rules unless needed
97822 -ifneq ($(hostprogs-y)$(hostprogs-m),)
97823 +ifneq ($(hostprogs-y)$(hostprogs-m)$(hostlibs-y)$(hostlibs-m)$(hostcxxlibs-y)$(hostcxxlibs-m),)
97824 include scripts/Makefile.host
97825 endif
97826
97827 diff --git a/scripts/Makefile.clean b/scripts/Makefile.clean
97828 index 686cb0d..9d653bf 100644
97829 --- a/scripts/Makefile.clean
97830 +++ b/scripts/Makefile.clean
97831 @@ -43,7 +43,8 @@ subdir-ymn := $(addprefix $(obj)/,$(subdir-ymn))
97832 __clean-files := $(extra-y) $(always) \
97833 $(targets) $(clean-files) \
97834 $(host-progs) \
97835 - $(hostprogs-y) $(hostprogs-m) $(hostprogs-)
97836 + $(hostprogs-y) $(hostprogs-m) $(hostprogs-) \
97837 + $(hostlibs-y) $(hostlibs-m) $(hostlibs-)
97838
97839 __clean-files := $(filter-out $(no-clean-files), $(__clean-files))
97840
97841 diff --git a/scripts/Makefile.host b/scripts/Makefile.host
97842 index 1ac414f..38575f7 100644
97843 --- a/scripts/Makefile.host
97844 +++ b/scripts/Makefile.host
97845 @@ -31,6 +31,8 @@
97846 # Note: Shared libraries consisting of C++ files are not supported
97847
97848 __hostprogs := $(sort $(hostprogs-y) $(hostprogs-m))
97849 +__hostlibs := $(sort $(hostlibs-y) $(hostlibs-m))
97850 +__hostcxxlibs := $(sort $(hostcxxlibs-y) $(hostcxxlibs-m))
97851
97852 # C code
97853 # Executables compiled from a single .c file
97854 @@ -54,11 +56,15 @@ host-cxxobjs := $(sort $(foreach m,$(host-cxxmulti),$($(m)-cxxobjs)))
97855 # Shared libaries (only .c supported)
97856 # Shared libraries (.so) - all .so files referenced in "xxx-objs"
97857 host-cshlib := $(sort $(filter %.so, $(host-cobjs)))
97858 +host-cshlib += $(sort $(filter %.so, $(__hostlibs)))
97859 +host-cxxshlib := $(sort $(filter %.so, $(__hostcxxlibs)))
97860 # Remove .so files from "xxx-objs"
97861 host-cobjs := $(filter-out %.so,$(host-cobjs))
97862 +host-cxxobjs := $(filter-out %.so,$(host-cxxobjs))
97863
97864 -#Object (.o) files used by the shared libaries
97865 +# Object (.o) files used by the shared libaries
97866 host-cshobjs := $(sort $(foreach m,$(host-cshlib),$($(m:.so=-objs))))
97867 +host-cxxshobjs := $(sort $(foreach m,$(host-cxxshlib),$($(m:.so=-objs))))
97868
97869 # output directory for programs/.o files
97870 # hostprogs-y := tools/build may have been specified. Retrieve directory
97871 @@ -82,7 +88,9 @@ host-cobjs := $(addprefix $(obj)/,$(host-cobjs))
97872 host-cxxmulti := $(addprefix $(obj)/,$(host-cxxmulti))
97873 host-cxxobjs := $(addprefix $(obj)/,$(host-cxxobjs))
97874 host-cshlib := $(addprefix $(obj)/,$(host-cshlib))
97875 +host-cxxshlib := $(addprefix $(obj)/,$(host-cxxshlib))
97876 host-cshobjs := $(addprefix $(obj)/,$(host-cshobjs))
97877 +host-cxxshobjs := $(addprefix $(obj)/,$(host-cxxshobjs))
97878 host-objdirs := $(addprefix $(obj)/,$(host-objdirs))
97879
97880 obj-dirs += $(host-objdirs)
97881 @@ -156,6 +164,13 @@ quiet_cmd_host-cshobjs = HOSTCC -fPIC $@
97882 $(host-cshobjs): $(obj)/%.o: $(src)/%.c FORCE
97883 $(call if_changed_dep,host-cshobjs)
97884
97885 +# Compile .c file, create position independent .o file
97886 +# host-cxxshobjs -> .o
97887 +quiet_cmd_host-cxxshobjs = HOSTCXX -fPIC $@
97888 + cmd_host-cxxshobjs = $(HOSTCXX) $(hostcxx_flags) -fPIC -c -o $@ $<
97889 +$(host-cxxshobjs): $(obj)/%.o: $(src)/%.c FORCE
97890 + $(call if_changed_dep,host-cxxshobjs)
97891 +
97892 # Link a shared library, based on position independent .o files
97893 # *.o -> .so shared library (host-cshlib)
97894 quiet_cmd_host-cshlib = HOSTLLD -shared $@
97895 @@ -165,6 +180,15 @@ quiet_cmd_host-cshlib = HOSTLLD -shared $@
97896 $(host-cshlib): $(obj)/%: $(host-cshobjs) FORCE
97897 $(call if_changed,host-cshlib)
97898
97899 +# Link a shared library, based on position independent .o files
97900 +# *.o -> .so shared library (host-cxxshlib)
97901 +quiet_cmd_host-cxxshlib = HOSTLLD -shared $@
97902 + cmd_host-cxxshlib = $(HOSTCXX) $(HOSTLDFLAGS) -shared -o $@ \
97903 + $(addprefix $(obj)/,$($(@F:.so=-objs))) \
97904 + $(HOST_LOADLIBES) $(HOSTLOADLIBES_$(@F))
97905 +$(host-cxxshlib): $(obj)/%: $(host-cxxshobjs) FORCE
97906 + $(call if_changed,host-cxxshlib)
97907 +
97908 targets += $(host-csingle) $(host-cmulti) $(host-cobjs)\
97909 - $(host-cxxmulti) $(host-cxxobjs) $(host-cshlib) $(host-cshobjs)
97910 + $(host-cxxmulti) $(host-cxxobjs) $(host-cshlib) $(host-cshobjs) $(host-cxxshlib) $(host-cxxshobjs)
97911
97912 diff --git a/scripts/basic/fixdep.c b/scripts/basic/fixdep.c
97913 index 078fe1d..fbdb363 100644
97914 --- a/scripts/basic/fixdep.c
97915 +++ b/scripts/basic/fixdep.c
97916 @@ -161,7 +161,7 @@ static unsigned int strhash(const char *str, unsigned int sz)
97917 /*
97918 * Lookup a value in the configuration string.
97919 */
97920 -static int is_defined_config(const char *name, int len, unsigned int hash)
97921 +static int is_defined_config(const char *name, unsigned int len, unsigned int hash)
97922 {
97923 struct item *aux;
97924
97925 @@ -211,10 +211,10 @@ static void clear_config(void)
97926 /*
97927 * Record the use of a CONFIG_* word.
97928 */
97929 -static void use_config(const char *m, int slen)
97930 +static void use_config(const char *m, unsigned int slen)
97931 {
97932 unsigned int hash = strhash(m, slen);
97933 - int c, i;
97934 + unsigned int c, i;
97935
97936 if (is_defined_config(m, slen, hash))
97937 return;
97938 @@ -235,9 +235,9 @@ static void use_config(const char *m, int slen)
97939
97940 static void parse_config_file(const char *map, size_t len)
97941 {
97942 - const int *end = (const int *) (map + len);
97943 + const unsigned int *end = (const unsigned int *) (map + len);
97944 /* start at +1, so that p can never be < map */
97945 - const int *m = (const int *) map + 1;
97946 + const unsigned int *m = (const unsigned int *) map + 1;
97947 const char *p, *q;
97948
97949 for (; m < end; m++) {
97950 @@ -435,7 +435,7 @@ static void print_deps(void)
97951 static void traps(void)
97952 {
97953 static char test[] __attribute__((aligned(sizeof(int)))) = "CONF";
97954 - int *p = (int *)test;
97955 + unsigned int *p = (unsigned int *)test;
97956
97957 if (*p != INT_CONF) {
97958 fprintf(stderr, "fixdep: sizeof(int) != 4 or wrong endianness? %#x\n",
97959 diff --git a/scripts/gcc-plugin.sh b/scripts/gcc-plugin.sh
97960 new file mode 100644
97961 index 0000000..5e0222d
97962 --- /dev/null
97963 +++ b/scripts/gcc-plugin.sh
97964 @@ -0,0 +1,17 @@
97965 +#!/bin/bash
97966 +plugincc=`$1 -E -shared - -o /dev/null -I\`$3 -print-file-name=plugin\`/include 2>&1 <<EOF
97967 +#include "gcc-plugin.h"
97968 +#include "tree.h"
97969 +#include "tm.h"
97970 +#include "rtl.h"
97971 +#ifdef ENABLE_BUILD_WITH_CXX
97972 +#warning $2
97973 +#else
97974 +#warning $1
97975 +#endif
97976 +EOF`
97977 +if [ $? -eq 0 ]
97978 +then
97979 + [[ "$plugincc" =~ "$1" ]] && echo "$1"
97980 + [[ "$plugincc" =~ "$2" ]] && echo "$2"
97981 +fi
97982 diff --git a/scripts/headers_install.sh b/scripts/headers_install.sh
97983 index 5de5660..d3deb89 100644
97984 --- a/scripts/headers_install.sh
97985 +++ b/scripts/headers_install.sh
97986 @@ -32,6 +32,7 @@ do
97987 FILE="$(basename "$i")"
97988 sed -r \
97989 -e 's/([ \t(])(__user|__force|__iomem)[ \t]/\1/g' \
97990 + -e 's/__intentional_overflow\([- \t,0-9]*\)//g' \
97991 -e 's/__attribute_const__([ \t]|$)/\1/g' \
97992 -e 's@^#include <linux/compiler.h>@@' \
97993 -e 's/(^|[^a-zA-Z0-9])__packed([^a-zA-Z0-9_]|$)/\1__attribute__((packed))\2/g' \
97994 diff --git a/scripts/link-vmlinux.sh b/scripts/link-vmlinux.sh
97995 index 32b10f5..64eeb30 100644
97996 --- a/scripts/link-vmlinux.sh
97997 +++ b/scripts/link-vmlinux.sh
97998 @@ -82,7 +82,9 @@ kallsyms()
97999 kallsymopt="${kallsymopt} --all-symbols"
98000 fi
98001
98002 - kallsymopt="${kallsymopt} --page-offset=$CONFIG_PAGE_OFFSET"
98003 + if [ -z "${CONFIG_X86_32}" ] || [ -z "${CONFIG_PAX_KERNEXEC}" ]; then
98004 + kallsymopt="${kallsymopt} --page-offset=$CONFIG_PAGE_OFFSET"
98005 + fi
98006
98007 local aflags="${KBUILD_AFLAGS} ${KBUILD_AFLAGS_KERNEL} \
98008 ${NOSTDINC_FLAGS} ${LINUXINCLUDE} ${KBUILD_CPPFLAGS}"
98009 @@ -160,7 +162,7 @@ else
98010 fi;
98011
98012 # final build of init/
98013 -${MAKE} -f "${srctree}/scripts/Makefile.build" obj=init
98014 +${MAKE} -f "${srctree}/scripts/Makefile.build" obj=init GCC_PLUGINS_CFLAGS="${GCC_PLUGINS_CFLAGS}" GCC_PLUGINS_AFLAGS="${GCC_PLUGINS_AFLAGS}"
98015
98016 kallsymso=""
98017 kallsyms_vmlinux=""
98018 diff --git a/scripts/mod/file2alias.c b/scripts/mod/file2alias.c
98019 index 2370863..212fbca 100644
98020 --- a/scripts/mod/file2alias.c
98021 +++ b/scripts/mod/file2alias.c
98022 @@ -142,7 +142,7 @@ static void device_id_check(const char *modname, const char *device_id,
98023 unsigned long size, unsigned long id_size,
98024 void *symval)
98025 {
98026 - int i;
98027 + unsigned int i;
98028
98029 if (size % id_size || size < id_size) {
98030 fatal("%s: sizeof(struct %s_device_id)=%lu is not a modulo "
98031 @@ -170,7 +170,7 @@ static void device_id_check(const char *modname, const char *device_id,
98032 /* USB is special because the bcdDevice can be matched against a numeric range */
98033 /* Looks like "usb:vNpNdNdcNdscNdpNicNiscNipNinN" */
98034 static void do_usb_entry(void *symval,
98035 - unsigned int bcdDevice_initial, int bcdDevice_initial_digits,
98036 + unsigned int bcdDevice_initial, unsigned int bcdDevice_initial_digits,
98037 unsigned char range_lo, unsigned char range_hi,
98038 unsigned char max, struct module *mod)
98039 {
98040 @@ -280,7 +280,7 @@ static void do_usb_entry_multi(void *symval, struct module *mod)
98041 {
98042 unsigned int devlo, devhi;
98043 unsigned char chi, clo, max;
98044 - int ndigits;
98045 + unsigned int ndigits;
98046
98047 DEF_FIELD(symval, usb_device_id, match_flags);
98048 DEF_FIELD(symval, usb_device_id, idVendor);
98049 @@ -533,7 +533,7 @@ static void do_pnp_device_entry(void *symval, unsigned long size,
98050 for (i = 0; i < count; i++) {
98051 DEF_FIELD_ADDR(symval + i*id_size, pnp_device_id, id);
98052 char acpi_id[sizeof(*id)];
98053 - int j;
98054 + unsigned int j;
98055
98056 buf_printf(&mod->dev_table_buf,
98057 "MODULE_ALIAS(\"pnp:d%s*\");\n", *id);
98058 @@ -562,7 +562,7 @@ static void do_pnp_card_entries(void *symval, unsigned long size,
98059
98060 for (j = 0; j < PNP_MAX_DEVICES; j++) {
98061 const char *id = (char *)(*devs)[j].id;
98062 - int i2, j2;
98063 + unsigned int i2, j2;
98064 int dup = 0;
98065
98066 if (!id[0])
98067 @@ -588,7 +588,7 @@ static void do_pnp_card_entries(void *symval, unsigned long size,
98068 /* add an individual alias for every device entry */
98069 if (!dup) {
98070 char acpi_id[PNP_ID_LEN];
98071 - int k;
98072 + unsigned int k;
98073
98074 buf_printf(&mod->dev_table_buf,
98075 "MODULE_ALIAS(\"pnp:d%s*\");\n", id);
98076 @@ -940,7 +940,7 @@ static void dmi_ascii_filter(char *d, const char *s)
98077 static int do_dmi_entry(const char *filename, void *symval,
98078 char *alias)
98079 {
98080 - int i, j;
98081 + unsigned int i, j;
98082 DEF_FIELD_ADDR(symval, dmi_system_id, matches);
98083 sprintf(alias, "dmi*");
98084
98085 diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c
98086 index 8247979..815ec76 100644
98087 --- a/scripts/mod/modpost.c
98088 +++ b/scripts/mod/modpost.c
98089 @@ -931,6 +931,7 @@ enum mismatch {
98090 ANY_INIT_TO_ANY_EXIT,
98091 ANY_EXIT_TO_ANY_INIT,
98092 EXPORT_TO_INIT_EXIT,
98093 + DATA_TO_TEXT
98094 };
98095
98096 struct sectioncheck {
98097 @@ -1017,6 +1018,12 @@ const struct sectioncheck sectioncheck[] = {
98098 .tosec = { INIT_SECTIONS, EXIT_SECTIONS, NULL },
98099 .mismatch = EXPORT_TO_INIT_EXIT,
98100 .symbol_white_list = { DEFAULT_SYMBOL_WHITE_LIST, NULL },
98101 +},
98102 +/* Do not reference code from writable data */
98103 +{
98104 + .fromsec = { DATA_SECTIONS, NULL },
98105 + .tosec = { TEXT_SECTIONS, NULL },
98106 + .mismatch = DATA_TO_TEXT
98107 }
98108 };
98109
98110 @@ -1137,10 +1144,10 @@ static Elf_Sym *find_elf_symbol(struct elf_info *elf, Elf64_Sword addr,
98111 continue;
98112 if (ELF_ST_TYPE(sym->st_info) == STT_SECTION)
98113 continue;
98114 - if (sym->st_value == addr)
98115 - return sym;
98116 /* Find a symbol nearby - addr are maybe negative */
98117 d = sym->st_value - addr;
98118 + if (d == 0)
98119 + return sym;
98120 if (d < 0)
98121 d = addr - sym->st_value;
98122 if (d < distance) {
98123 @@ -1418,6 +1425,14 @@ static void report_sec_mismatch(const char *modname,
98124 tosym, prl_to, prl_to, tosym);
98125 free(prl_to);
98126 break;
98127 + case DATA_TO_TEXT:
98128 +#if 0
98129 + fprintf(stderr,
98130 + "The %s %s:%s references\n"
98131 + "the %s %s:%s%s\n",
98132 + from, fromsec, fromsym, to, tosec, tosym, to_p);
98133 +#endif
98134 + break;
98135 }
98136 fprintf(stderr, "\n");
98137 }
98138 @@ -1652,7 +1667,7 @@ static void section_rel(const char *modname, struct elf_info *elf,
98139 static void check_sec_ref(struct module *mod, const char *modname,
98140 struct elf_info *elf)
98141 {
98142 - int i;
98143 + unsigned int i;
98144 Elf_Shdr *sechdrs = elf->sechdrs;
98145
98146 /* Walk through all sections */
98147 @@ -1771,7 +1786,7 @@ void __attribute__((format(printf, 2, 3))) buf_printf(struct buffer *buf,
98148 va_end(ap);
98149 }
98150
98151 -void buf_write(struct buffer *buf, const char *s, int len)
98152 +void buf_write(struct buffer *buf, const char *s, unsigned int len)
98153 {
98154 if (buf->size - buf->pos < len) {
98155 buf->size += len + SZ;
98156 @@ -1990,7 +2005,7 @@ static void write_if_changed(struct buffer *b, const char *fname)
98157 if (fstat(fileno(file), &st) < 0)
98158 goto close_write;
98159
98160 - if (st.st_size != b->pos)
98161 + if (st.st_size != (off_t)b->pos)
98162 goto close_write;
98163
98164 tmp = NOFAIL(malloc(b->pos));
98165 diff --git a/scripts/mod/modpost.h b/scripts/mod/modpost.h
98166 index 51207e4..f7d603d 100644
98167 --- a/scripts/mod/modpost.h
98168 +++ b/scripts/mod/modpost.h
98169 @@ -92,15 +92,15 @@ void *do_nofail(void *ptr, const char *expr);
98170
98171 struct buffer {
98172 char *p;
98173 - int pos;
98174 - int size;
98175 + unsigned int pos;
98176 + unsigned int size;
98177 };
98178
98179 void __attribute__((format(printf, 2, 3)))
98180 buf_printf(struct buffer *buf, const char *fmt, ...);
98181
98182 void
98183 -buf_write(struct buffer *buf, const char *s, int len);
98184 +buf_write(struct buffer *buf, const char *s, unsigned int len);
98185
98186 struct module {
98187 struct module *next;
98188 diff --git a/scripts/mod/sumversion.c b/scripts/mod/sumversion.c
98189 index 9dfcd6d..099068e 100644
98190 --- a/scripts/mod/sumversion.c
98191 +++ b/scripts/mod/sumversion.c
98192 @@ -470,7 +470,7 @@ static void write_version(const char *filename, const char *sum,
98193 goto out;
98194 }
98195
98196 - if (write(fd, sum, strlen(sum)+1) != strlen(sum)+1) {
98197 + if (write(fd, sum, strlen(sum)+1) != (ssize_t)strlen(sum)+1) {
98198 warn("writing sum in %s failed: %s\n",
98199 filename, strerror(errno));
98200 goto out;
98201 diff --git a/scripts/module-common.lds b/scripts/module-common.lds
98202 index 0865b3e..7235dd4 100644
98203 --- a/scripts/module-common.lds
98204 +++ b/scripts/module-common.lds
98205 @@ -6,6 +6,10 @@
98206 SECTIONS {
98207 /DISCARD/ : { *(.discard) }
98208
98209 + .rodata : {
98210 + *(.rodata) *(.rodata.*)
98211 + *(.data..read_only)
98212 + }
98213 __ksymtab : { *(SORT(___ksymtab+*)) }
98214 __ksymtab_gpl : { *(SORT(___ksymtab_gpl+*)) }
98215 __ksymtab_unused : { *(SORT(___ksymtab_unused+*)) }
98216 diff --git a/scripts/package/builddeb b/scripts/package/builddeb
98217 index 90e521f..e9eaf8f 100644
98218 --- a/scripts/package/builddeb
98219 +++ b/scripts/package/builddeb
98220 @@ -281,6 +281,7 @@ fi
98221 (cd $srctree; find . -name Makefile\* -o -name Kconfig\* -o -name \*.pl > "$objtree/debian/hdrsrcfiles")
98222 (cd $srctree; find arch/$SRCARCH/include include scripts -type f >> "$objtree/debian/hdrsrcfiles")
98223 (cd $objtree; find arch/$SRCARCH/include Module.symvers include scripts -type f >> "$objtree/debian/hdrobjfiles")
98224 +(cd $objtree; find tools/gcc -name \*.so >> "$objtree/debian/hdrobjfiles")
98225 destdir=$kernel_headers_dir/usr/src/linux-headers-$version
98226 mkdir -p "$destdir"
98227 (cd $srctree; tar -c -f - -T "$objtree/debian/hdrsrcfiles") | (cd $destdir; tar -xf -)
98228 diff --git a/scripts/pnmtologo.c b/scripts/pnmtologo.c
98229 index 68bb4ef..2f419e1 100644
98230 --- a/scripts/pnmtologo.c
98231 +++ b/scripts/pnmtologo.c
98232 @@ -244,14 +244,14 @@ static void write_header(void)
98233 fprintf(out, " * Linux logo %s\n", logoname);
98234 fputs(" */\n\n", out);
98235 fputs("#include <linux/linux_logo.h>\n\n", out);
98236 - fprintf(out, "static unsigned char %s_data[] __initdata = {\n",
98237 + fprintf(out, "static unsigned char %s_data[] = {\n",
98238 logoname);
98239 }
98240
98241 static void write_footer(void)
98242 {
98243 fputs("\n};\n\n", out);
98244 - fprintf(out, "const struct linux_logo %s __initconst = {\n", logoname);
98245 + fprintf(out, "const struct linux_logo %s = {\n", logoname);
98246 fprintf(out, "\t.type\t\t= %s,\n", logo_types[logo_type]);
98247 fprintf(out, "\t.width\t\t= %d,\n", logo_width);
98248 fprintf(out, "\t.height\t\t= %d,\n", logo_height);
98249 @@ -381,7 +381,7 @@ static void write_logo_clut224(void)
98250 fputs("\n};\n\n", out);
98251
98252 /* write logo clut */
98253 - fprintf(out, "static unsigned char %s_clut[] __initdata = {\n",
98254 + fprintf(out, "static unsigned char %s_clut[] = {\n",
98255 logoname);
98256 write_hex_cnt = 0;
98257 for (i = 0; i < logo_clutsize; i++) {
98258 diff --git a/scripts/sortextable.h b/scripts/sortextable.h
98259 index f5eb43d..1814de8 100644
98260 --- a/scripts/sortextable.h
98261 +++ b/scripts/sortextable.h
98262 @@ -106,9 +106,9 @@ do_func(Elf_Ehdr *ehdr, char const *const fname, table_sort_t custom_sort)
98263 const char *secstrtab;
98264 const char *strtab;
98265 char *extab_image;
98266 - int extab_index = 0;
98267 - int i;
98268 - int idx;
98269 + unsigned int extab_index = 0;
98270 + unsigned int i;
98271 + unsigned int idx;
98272
98273 shdr = (Elf_Shdr *)((char *)ehdr + _r(&ehdr->e_shoff));
98274 shstrtab_sec = shdr + r2(&ehdr->e_shstrndx);
98275 diff --git a/security/Kconfig b/security/Kconfig
98276 index e9c6ac7..031a726 100644
98277 --- a/security/Kconfig
98278 +++ b/security/Kconfig
98279 @@ -4,6 +4,960 @@
98280
98281 menu "Security options"
98282
98283 +menu "Grsecurity"
98284 +
98285 + config ARCH_TRACK_EXEC_LIMIT
98286 + bool
98287 +
98288 + config PAX_KERNEXEC_PLUGIN
98289 + bool
98290 +
98291 + config PAX_PER_CPU_PGD
98292 + bool
98293 +
98294 + config TASK_SIZE_MAX_SHIFT
98295 + int
98296 + depends on X86_64
98297 + default 47 if !PAX_PER_CPU_PGD
98298 + default 42 if PAX_PER_CPU_PGD
98299 +
98300 + config PAX_ENABLE_PAE
98301 + bool
98302 + default y if (X86_32 && (MPENTIUM4 || MK8 || MPSC || MCORE2 || MATOM))
98303 +
98304 + config PAX_USERCOPY_SLABS
98305 + bool
98306 +
98307 +config GRKERNSEC
98308 + bool "Grsecurity"
98309 + select CRYPTO
98310 + select CRYPTO_SHA256
98311 + select PROC_FS
98312 + select STOP_MACHINE
98313 + select TTY
98314 + select DEBUG_LIST
98315 + help
98316 + If you say Y here, you will be able to configure many features
98317 + that will enhance the security of your system. It is highly
98318 + recommended that you say Y here and read through the help
98319 + for each option so that you fully understand the features and
98320 + can evaluate their usefulness for your machine.
98321 +
98322 +choice
98323 + prompt "Configuration Method"
98324 + depends on GRKERNSEC
98325 + default GRKERNSEC_CONFIG_CUSTOM
98326 + help
98327 +
98328 +config GRKERNSEC_CONFIG_AUTO
98329 + bool "Automatic"
98330 + help
98331 + If you choose this configuration method, you'll be able to answer a small
98332 + number of simple questions about how you plan to use this kernel.
98333 + The settings of grsecurity and PaX will be automatically configured for
98334 + the highest commonly-used settings within the provided constraints.
98335 +
98336 + If you require additional configuration, custom changes can still be made
98337 + from the "custom configuration" menu.
98338 +
98339 +config GRKERNSEC_CONFIG_CUSTOM
98340 + bool "Custom"
98341 + help
98342 + If you choose this configuration method, you'll be able to configure all
98343 + grsecurity and PaX settings manually. Via this method, no options are
98344 + automatically enabled.
98345 +
98346 +endchoice
98347 +
98348 +choice
98349 + prompt "Usage Type"
98350 + depends on (GRKERNSEC && GRKERNSEC_CONFIG_AUTO)
98351 + default GRKERNSEC_CONFIG_SERVER
98352 + help
98353 +
98354 +config GRKERNSEC_CONFIG_SERVER
98355 + bool "Server"
98356 + help
98357 + Choose this option if you plan to use this kernel on a server.
98358 +
98359 +config GRKERNSEC_CONFIG_DESKTOP
98360 + bool "Desktop"
98361 + help
98362 + Choose this option if you plan to use this kernel on a desktop.
98363 +
98364 +endchoice
98365 +
98366 +choice
98367 + prompt "Virtualization Type"
98368 + depends on (GRKERNSEC && X86 && GRKERNSEC_CONFIG_AUTO)
98369 + default GRKERNSEC_CONFIG_VIRT_NONE
98370 + help
98371 +
98372 +config GRKERNSEC_CONFIG_VIRT_NONE
98373 + bool "None"
98374 + help
98375 + Choose this option if this kernel will be run on bare metal.
98376 +
98377 +config GRKERNSEC_CONFIG_VIRT_GUEST
98378 + bool "Guest"
98379 + help
98380 + Choose this option if this kernel will be run as a VM guest.
98381 +
98382 +config GRKERNSEC_CONFIG_VIRT_HOST
98383 + bool "Host"
98384 + help
98385 + Choose this option if this kernel will be run as a VM host.
98386 +
98387 +endchoice
98388 +
98389 +choice
98390 + prompt "Virtualization Hardware"
98391 + depends on (GRKERNSEC && X86 && GRKERNSEC_CONFIG_AUTO && (GRKERNSEC_CONFIG_VIRT_GUEST || GRKERNSEC_CONFIG_VIRT_HOST))
98392 + help
98393 +
98394 +config GRKERNSEC_CONFIG_VIRT_EPT
98395 + bool "EPT/RVI Processor Support"
98396 + depends on X86
98397 + help
98398 + Choose this option if your CPU supports the EPT or RVI features of 2nd-gen
98399 + hardware virtualization. This allows for additional kernel hardening protections
98400 + to operate without additional performance impact.
98401 +
98402 + To see if your Intel processor supports EPT, see:
98403 + http://ark.intel.com/Products/VirtualizationTechnology
98404 + (Most Core i3/5/7 support EPT)
98405 +
98406 + To see if your AMD processor supports RVI, see:
98407 + http://support.amd.com/us/kbarticles/Pages/GPU120AMDRVICPUsHyperVWin8.aspx
98408 +
98409 +config GRKERNSEC_CONFIG_VIRT_SOFT
98410 + bool "First-gen/No Hardware Virtualization"
98411 + help
98412 + Choose this option if you use an Atom/Pentium/Core 2 processor that either doesn't
98413 + support hardware virtualization or doesn't support the EPT/RVI extensions.
98414 +
98415 +endchoice
98416 +
98417 +choice
98418 + prompt "Virtualization Software"
98419 + depends on (GRKERNSEC && GRKERNSEC_CONFIG_AUTO && (GRKERNSEC_CONFIG_VIRT_GUEST || GRKERNSEC_CONFIG_VIRT_HOST))
98420 + help
98421 +
98422 +config GRKERNSEC_CONFIG_VIRT_XEN
98423 + bool "Xen"
98424 + help
98425 + Choose this option if this kernel is running as a Xen guest or host.
98426 +
98427 +config GRKERNSEC_CONFIG_VIRT_VMWARE
98428 + bool "VMWare"
98429 + help
98430 + Choose this option if this kernel is running as a VMWare guest or host.
98431 +
98432 +config GRKERNSEC_CONFIG_VIRT_KVM
98433 + bool "KVM"
98434 + help
98435 + Choose this option if this kernel is running as a KVM guest or host.
98436 +
98437 +config GRKERNSEC_CONFIG_VIRT_VIRTUALBOX
98438 + bool "VirtualBox"
98439 + help
98440 + Choose this option if this kernel is running as a VirtualBox guest or host.
98441 +
98442 +endchoice
98443 +
98444 +choice
98445 + prompt "Required Priorities"
98446 + depends on (GRKERNSEC && GRKERNSEC_CONFIG_AUTO)
98447 + default GRKERNSEC_CONFIG_PRIORITY_PERF
98448 + help
98449 +
98450 +config GRKERNSEC_CONFIG_PRIORITY_PERF
98451 + bool "Performance"
98452 + help
98453 + Choose this option if performance is of highest priority for this deployment
98454 + of grsecurity. Features like UDEREF on a 64bit kernel, kernel stack clearing,
98455 + clearing of structures intended for userland, and freed memory sanitizing will
98456 + be disabled.
98457 +
98458 +config GRKERNSEC_CONFIG_PRIORITY_SECURITY
98459 + bool "Security"
98460 + help
98461 + Choose this option if security is of highest priority for this deployment of
98462 + grsecurity. UDEREF, kernel stack clearing, clearing of structures intended
98463 + for userland, and freed memory sanitizing will be enabled for this kernel.
98464 + In a worst-case scenario, these features can introduce a 20% performance hit
98465 + (UDEREF on x64 contributing half of this hit).
98466 +
98467 +endchoice
98468 +
98469 +menu "Default Special Groups"
98470 +depends on (GRKERNSEC && GRKERNSEC_CONFIG_AUTO)
98471 +
98472 +config GRKERNSEC_PROC_GID
98473 + int "GID exempted from /proc restrictions"
98474 + default 1001
98475 + help
98476 + Setting this GID determines which group will be exempted from
98477 + grsecurity's /proc restrictions, allowing users of the specified
98478 + group to view network statistics and the existence of other users'
98479 + processes on the system. This GID may also be chosen at boot time
98480 + via "grsec_proc_gid=" on the kernel commandline.
98481 +
98482 +config GRKERNSEC_TPE_UNTRUSTED_GID
98483 + int "GID for TPE-untrusted users"
98484 + depends on GRKERNSEC_CONFIG_SERVER && GRKERNSEC_TPE && !GRKERNSEC_TPE_INVERT
98485 + default 1005
98486 + help
98487 + Setting this GID determines which group untrusted users should
98488 + be added to. These users will be placed under grsecurity's Trusted Path
98489 + Execution mechanism, preventing them from executing their own binaries.
98490 + The users will only be able to execute binaries in directories owned and
98491 + writable only by the root user. If the sysctl option is enabled, a sysctl
98492 + option with name "tpe_gid" is created.
98493 +
98494 +config GRKERNSEC_TPE_TRUSTED_GID
98495 + int "GID for TPE-trusted users"
98496 + depends on GRKERNSEC_CONFIG_SERVER && GRKERNSEC_TPE && GRKERNSEC_TPE_INVERT
98497 + default 1005
98498 + help
98499 + Setting this GID determines what group TPE restrictions will be
98500 + *disabled* for. If the sysctl option is enabled, a sysctl option
98501 + with name "tpe_gid" is created.
98502 +
98503 +config GRKERNSEC_SYMLINKOWN_GID
98504 + int "GID for users with kernel-enforced SymlinksIfOwnerMatch"
98505 + depends on GRKERNSEC_CONFIG_SERVER
98506 + default 1006
98507 + help
98508 + Setting this GID determines what group kernel-enforced
98509 + SymlinksIfOwnerMatch will be enabled for. If the sysctl option
98510 + is enabled, a sysctl option with name "symlinkown_gid" is created.
98511 +
98512 +
98513 +endmenu
98514 +
98515 +menu "Customize Configuration"
98516 +depends on GRKERNSEC
98517 +
98518 +menu "PaX"
98519 +
98520 +config PAX
98521 + bool "Enable various PaX features"
98522 + default y if GRKERNSEC_CONFIG_AUTO
98523 + depends on GRKERNSEC && (ALPHA || ARM || AVR32 || IA64 || MIPS || PARISC || PPC || SPARC || X86)
98524 + help
98525 + This allows you to enable various PaX features. PaX adds
98526 + intrusion prevention mechanisms to the kernel that reduce
98527 + the risks posed by exploitable memory corruption bugs.
98528 +
98529 +menu "PaX Control"
98530 + depends on PAX
98531 +
98532 +config PAX_SOFTMODE
98533 + bool 'Support soft mode'
98534 + help
98535 + Enabling this option will allow you to run PaX in soft mode, that
98536 + is, PaX features will not be enforced by default, only on executables
98537 + marked explicitly. You must also enable PT_PAX_FLAGS or XATTR_PAX_FLAGS
98538 + support as they are the only way to mark executables for soft mode use.
98539 +
98540 + Soft mode can be activated by using the "pax_softmode=1" kernel command
98541 + line option on boot. Furthermore you can control various PaX features
98542 + at runtime via the entries in /proc/sys/kernel/pax.
98543 +
98544 +config PAX_EI_PAX
98545 + bool 'Use legacy ELF header marking'
98546 + default y if GRKERNSEC_CONFIG_AUTO
98547 + help
98548 + Enabling this option will allow you to control PaX features on
98549 + a per executable basis via the 'chpax' utility available at
98550 + http://pax.grsecurity.net/. The control flags will be read from
98551 + an otherwise reserved part of the ELF header. This marking has
98552 + numerous drawbacks (no support for soft-mode, toolchain does not
98553 + know about the non-standard use of the ELF header) therefore it
98554 + has been deprecated in favour of PT_PAX_FLAGS and XATTR_PAX_FLAGS
98555 + support.
98556 +
98557 + Note that if you enable PT_PAX_FLAGS or XATTR_PAX_FLAGS marking
98558 + support as well, they will override the legacy EI_PAX marks.
98559 +
98560 + If you enable none of the marking options then all applications
98561 + will run with PaX enabled on them by default.
98562 +
98563 +config PAX_PT_PAX_FLAGS
98564 + bool 'Use ELF program header marking'
98565 + default y if GRKERNSEC_CONFIG_AUTO
98566 + help
98567 + Enabling this option will allow you to control PaX features on
98568 + a per executable basis via the 'paxctl' utility available at
98569 + http://pax.grsecurity.net/. The control flags will be read from
98570 + a PaX specific ELF program header (PT_PAX_FLAGS). This marking
98571 + has the benefits of supporting both soft mode and being fully
98572 + integrated into the toolchain (the binutils patch is available
98573 + from http://pax.grsecurity.net).
98574 +
98575 + Note that if you enable the legacy EI_PAX marking support as well,
98576 + the EI_PAX marks will be overridden by the PT_PAX_FLAGS marks.
98577 +
98578 + If you enable both PT_PAX_FLAGS and XATTR_PAX_FLAGS support then you
98579 + must make sure that the marks are the same if a binary has both marks.
98580 +
98581 + If you enable none of the marking options then all applications
98582 + will run with PaX enabled on them by default.
98583 +
98584 +config PAX_XATTR_PAX_FLAGS
98585 + bool 'Use filesystem extended attributes marking'
98586 + default y if GRKERNSEC_CONFIG_AUTO
98587 + select CIFS_XATTR if CIFS
98588 + select EXT2_FS_XATTR if EXT2_FS
98589 + select EXT3_FS_XATTR if EXT3_FS
98590 + select EXT4_FS_XATTR if EXT4_FS
98591 + select JFFS2_FS_XATTR if JFFS2_FS
98592 + select REISERFS_FS_XATTR if REISERFS_FS
98593 + select SQUASHFS_XATTR if SQUASHFS
98594 + select TMPFS_XATTR if TMPFS
98595 + select UBIFS_FS_XATTR if UBIFS_FS
98596 + help
98597 + Enabling this option will allow you to control PaX features on
98598 + a per executable basis via the 'setfattr' utility. The control
98599 + flags will be read from the user.pax.flags extended attribute of
98600 + the file. This marking has the benefit of supporting binary-only
98601 + applications that self-check themselves (e.g., skype) and would
98602 + not tolerate chpax/paxctl changes. The main drawback is that
98603 + extended attributes are not supported by some filesystems (e.g.,
98604 + isofs, udf, vfat) so copying files through such filesystems will
98605 + lose the extended attributes and these PaX markings.
98606 +
98607 + Note that if you enable the legacy EI_PAX marking support as well,
98608 + the EI_PAX marks will be overridden by the XATTR_PAX_FLAGS marks.
98609 +
98610 + If you enable both PT_PAX_FLAGS and XATTR_PAX_FLAGS support then you
98611 + must make sure that the marks are the same if a binary has both marks.
98612 +
98613 + If you enable none of the marking options then all applications
98614 + will run with PaX enabled on them by default.
98615 +
98616 +choice
98617 + prompt 'MAC system integration'
98618 + default PAX_HAVE_ACL_FLAGS
98619 + help
98620 + Mandatory Access Control systems have the option of controlling
98621 + PaX flags on a per executable basis, choose the method supported
98622 + by your particular system.
98623 +
98624 + - "none": if your MAC system does not interact with PaX,
98625 + - "direct": if your MAC system defines pax_set_initial_flags() itself,
98626 + - "hook": if your MAC system uses the pax_set_initial_flags_func callback.
98627 +
98628 + NOTE: this option is for developers/integrators only.
98629 +
98630 + config PAX_NO_ACL_FLAGS
98631 + bool 'none'
98632 +
98633 + config PAX_HAVE_ACL_FLAGS
98634 + bool 'direct'
98635 +
98636 + config PAX_HOOK_ACL_FLAGS
98637 + bool 'hook'
98638 +endchoice
98639 +
98640 +endmenu
98641 +
98642 +menu "Non-executable pages"
98643 + depends on PAX
98644 +
98645 +config PAX_NOEXEC
98646 + bool "Enforce non-executable pages"
98647 + default y if GRKERNSEC_CONFIG_AUTO
98648 + depends on ALPHA || (ARM && (CPU_V6 || CPU_V6K || CPU_V7)) || IA64 || MIPS || PARISC || PPC || S390 || SPARC || X86
98649 + help
98650 + By design some architectures do not allow for protecting memory
98651 + pages against execution or even if they do, Linux does not make
98652 + use of this feature. In practice this means that if a page is
98653 + readable (such as the stack or heap) it is also executable.
98654 +
98655 + There is a well known exploit technique that makes use of this
98656 + fact and a common programming mistake where an attacker can
98657 + introduce code of his choice somewhere in the attacked program's
98658 + memory (typically the stack or the heap) and then execute it.
98659 +
98660 + If the attacked program was running with different (typically
98661 + higher) privileges than that of the attacker, then he can elevate
98662 + his own privilege level (e.g. get a root shell, write to files for
98663 + which he does not have write access to, etc).
98664 +
98665 + Enabling this option will let you choose from various features
98666 + that prevent the injection and execution of 'foreign' code in
98667 + a program.
98668 +
98669 + This will also break programs that rely on the old behaviour and
98670 + expect that dynamically allocated memory via the malloc() family
98671 + of functions is executable (which it is not). Notable examples
98672 + are the XFree86 4.x server, the java runtime and wine.
98673 +
98674 +config PAX_PAGEEXEC
98675 + bool "Paging based non-executable pages"
98676 + default y if GRKERNSEC_CONFIG_AUTO
98677 + 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)
98678 + select ARCH_TRACK_EXEC_LIMIT if X86_32
98679 + help
98680 + This implementation is based on the paging feature of the CPU.
98681 + On i386 without hardware non-executable bit support there is a
98682 + variable but usually low performance impact, however on Intel's
98683 + P4 core based CPUs it is very high so you should not enable this
98684 + for kernels meant to be used on such CPUs.
98685 +
98686 + On alpha, avr32, ia64, parisc, sparc, sparc64, x86_64 and i386
98687 + with hardware non-executable bit support there is no performance
98688 + impact, on ppc the impact is negligible.
98689 +
98690 + Note that several architectures require various emulations due to
98691 + badly designed userland ABIs, this will cause a performance impact
98692 + but will disappear as soon as userland is fixed. For example, ppc
98693 + userland MUST have been built with secure-plt by a recent toolchain.
98694 +
98695 +config PAX_SEGMEXEC
98696 + bool "Segmentation based non-executable pages"
98697 + default y if GRKERNSEC_CONFIG_AUTO
98698 + depends on PAX_NOEXEC && X86_32
98699 + help
98700 + This implementation is based on the segmentation feature of the
98701 + CPU and has a very small performance impact, however applications
98702 + will be limited to a 1.5 GB address space instead of the normal
98703 + 3 GB.
98704 +
98705 +config PAX_EMUTRAMP
98706 + bool "Emulate trampolines" if (PAX_PAGEEXEC || PAX_SEGMEXEC) && (PARISC || X86)
98707 + default y if PARISC
98708 + help
98709 + There are some programs and libraries that for one reason or
98710 + another attempt to execute special small code snippets from
98711 + non-executable memory pages. Most notable examples are the
98712 + signal handler return code generated by the kernel itself and
98713 + the GCC trampolines.
98714 +
98715 + If you enabled CONFIG_PAX_PAGEEXEC or CONFIG_PAX_SEGMEXEC then
98716 + such programs will no longer work under your kernel.
98717 +
98718 + As a remedy you can say Y here and use the 'chpax' or 'paxctl'
98719 + utilities to enable trampoline emulation for the affected programs
98720 + yet still have the protection provided by the non-executable pages.
98721 +
98722 + On parisc you MUST enable this option and EMUSIGRT as well, otherwise
98723 + your system will not even boot.
98724 +
98725 + Alternatively you can say N here and use the 'chpax' or 'paxctl'
98726 + utilities to disable CONFIG_PAX_PAGEEXEC and CONFIG_PAX_SEGMEXEC
98727 + for the affected files.
98728 +
98729 + NOTE: enabling this feature *may* open up a loophole in the
98730 + protection provided by non-executable pages that an attacker
98731 + could abuse. Therefore the best solution is to not have any
98732 + files on your system that would require this option. This can
98733 + be achieved by not using libc5 (which relies on the kernel
98734 + signal handler return code) and not using or rewriting programs
98735 + that make use of the nested function implementation of GCC.
98736 + Skilled users can just fix GCC itself so that it implements
98737 + nested function calls in a way that does not interfere with PaX.
98738 +
98739 +config PAX_EMUSIGRT
98740 + bool "Automatically emulate sigreturn trampolines"
98741 + depends on PAX_EMUTRAMP && PARISC
98742 + default y
98743 + help
98744 + Enabling this option will have the kernel automatically detect
98745 + and emulate signal return trampolines executing on the stack
98746 + that would otherwise lead to task termination.
98747 +
98748 + This solution is intended as a temporary one for users with
98749 + legacy versions of libc (libc5, glibc 2.0, uClibc before 0.9.17,
98750 + Modula-3 runtime, etc) or executables linked to such, basically
98751 + everything that does not specify its own SA_RESTORER function in
98752 + normal executable memory like glibc 2.1+ does.
98753 +
98754 + On parisc you MUST enable this option, otherwise your system will
98755 + not even boot.
98756 +
98757 + NOTE: this feature cannot be disabled on a per executable basis
98758 + and since it *does* open up a loophole in the protection provided
98759 + by non-executable pages, the best solution is to not have any
98760 + files on your system that would require this option.
98761 +
98762 +config PAX_MPROTECT
98763 + bool "Restrict mprotect()"
98764 + default y if GRKERNSEC_CONFIG_AUTO
98765 + depends on (PAX_PAGEEXEC || PAX_SEGMEXEC)
98766 + help
98767 + Enabling this option will prevent programs from
98768 + - changing the executable status of memory pages that were
98769 + not originally created as executable,
98770 + - making read-only executable pages writable again,
98771 + - creating executable pages from anonymous memory,
98772 + - making read-only-after-relocations (RELRO) data pages writable again.
98773 +
98774 + You should say Y here to complete the protection provided by
98775 + the enforcement of non-executable pages.
98776 +
98777 + NOTE: you can use the 'chpax' or 'paxctl' utilities to control
98778 + this feature on a per file basis.
98779 +
98780 +config PAX_MPROTECT_COMPAT
98781 + bool "Use legacy/compat protection demoting (read help)"
98782 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_DESKTOP)
98783 + depends on PAX_MPROTECT
98784 + help
98785 + The current implementation of PAX_MPROTECT denies RWX allocations/mprotects
98786 + by sending the proper error code to the application. For some broken
98787 + userland, this can cause problems with Python or other applications. The
98788 + current implementation however allows for applications like clamav to
98789 + detect if JIT compilation/execution is allowed and to fall back gracefully
98790 + to an interpreter-based mode if it does not. While we encourage everyone
98791 + to use the current implementation as-is and push upstream to fix broken
98792 + userland (note that the RWX logging option can assist with this), in some
98793 + environments this may not be possible. Having to disable MPROTECT
98794 + completely on certain binaries reduces the security benefit of PaX,
98795 + so this option is provided for those environments to revert to the old
98796 + behavior.
98797 +
98798 +config PAX_ELFRELOCS
98799 + bool "Allow ELF text relocations (read help)"
98800 + depends on PAX_MPROTECT
98801 + default n
98802 + help
98803 + Non-executable pages and mprotect() restrictions are effective
98804 + in preventing the introduction of new executable code into an
98805 + attacked task's address space. There remain only two venues
98806 + for this kind of attack: if the attacker can execute already
98807 + existing code in the attacked task then he can either have it
98808 + create and mmap() a file containing his code or have it mmap()
98809 + an already existing ELF library that does not have position
98810 + independent code in it and use mprotect() on it to make it
98811 + writable and copy his code there. While protecting against
98812 + the former approach is beyond PaX, the latter can be prevented
98813 + by having only PIC ELF libraries on one's system (which do not
98814 + need to relocate their code). If you are sure this is your case,
98815 + as is the case with all modern Linux distributions, then leave
98816 + this option disabled. You should say 'n' here.
98817 +
98818 +config PAX_ETEXECRELOCS
98819 + bool "Allow ELF ET_EXEC text relocations"
98820 + depends on PAX_MPROTECT && (ALPHA || IA64 || PARISC)
98821 + select PAX_ELFRELOCS
98822 + default y
98823 + help
98824 + On some architectures there are incorrectly created applications
98825 + that require text relocations and would not work without enabling
98826 + this option. If you are an alpha, ia64 or parisc user, you should
98827 + enable this option and disable it once you have made sure that
98828 + none of your applications need it.
98829 +
98830 +config PAX_EMUPLT
98831 + bool "Automatically emulate ELF PLT"
98832 + depends on PAX_MPROTECT && (ALPHA || PARISC || SPARC)
98833 + default y
98834 + help
98835 + Enabling this option will have the kernel automatically detect
98836 + and emulate the Procedure Linkage Table entries in ELF files.
98837 + On some architectures such entries are in writable memory, and
98838 + become non-executable leading to task termination. Therefore
98839 + it is mandatory that you enable this option on alpha, parisc,
98840 + sparc and sparc64, otherwise your system would not even boot.
98841 +
98842 + NOTE: this feature *does* open up a loophole in the protection
98843 + provided by the non-executable pages, therefore the proper
98844 + solution is to modify the toolchain to produce a PLT that does
98845 + not need to be writable.
98846 +
98847 +config PAX_DLRESOLVE
98848 + bool 'Emulate old glibc resolver stub'
98849 + depends on PAX_EMUPLT && SPARC
98850 + default n
98851 + help
98852 + This option is needed if userland has an old glibc (before 2.4)
98853 + that puts a 'save' instruction into the runtime generated resolver
98854 + stub that needs special emulation.
98855 +
98856 +config PAX_KERNEXEC
98857 + bool "Enforce non-executable kernel pages"
98858 + 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))
98859 + depends on (X86 || (ARM && (CPU_V6 || CPU_V6K || CPU_V7) && !(ARM_LPAE && MODULES))) && !XEN
98860 + select PAX_PER_CPU_PGD if X86_64 || (X86_32 && X86_PAE)
98861 + select PAX_KERNEXEC_PLUGIN if X86_64
98862 + help
98863 + This is the kernel land equivalent of PAGEEXEC and MPROTECT,
98864 + that is, enabling this option will make it harder to inject
98865 + and execute 'foreign' code in kernel memory itself.
98866 +
98867 +choice
98868 + prompt "Return Address Instrumentation Method"
98869 + default PAX_KERNEXEC_PLUGIN_METHOD_BTS
98870 + depends on PAX_KERNEXEC_PLUGIN
98871 + help
98872 + Select the method used to instrument function pointer dereferences.
98873 + Note that binary modules cannot be instrumented by this approach.
98874 +
98875 + Note that the implementation requires a gcc with plugin support,
98876 + i.e., gcc 4.5 or newer. You may need to install the supporting
98877 + headers explicitly in addition to the normal gcc package.
98878 +
98879 + config PAX_KERNEXEC_PLUGIN_METHOD_BTS
98880 + bool "bts"
98881 + help
98882 + This method is compatible with binary only modules but has
98883 + a higher runtime overhead.
98884 +
98885 + config PAX_KERNEXEC_PLUGIN_METHOD_OR
98886 + bool "or"
98887 + depends on !PARAVIRT
98888 + help
98889 + This method is incompatible with binary only modules but has
98890 + a lower runtime overhead.
98891 +endchoice
98892 +
98893 +config PAX_KERNEXEC_PLUGIN_METHOD
98894 + string
98895 + default "bts" if PAX_KERNEXEC_PLUGIN_METHOD_BTS
98896 + default "or" if PAX_KERNEXEC_PLUGIN_METHOD_OR
98897 + default ""
98898 +
98899 +config PAX_KERNEXEC_MODULE_TEXT
98900 + int "Minimum amount of memory reserved for module code"
98901 + default "4" if (!GRKERNSEC_CONFIG_AUTO || GRKERNSEC_CONFIG_SERVER)
98902 + default "12" if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_DESKTOP)
98903 + depends on PAX_KERNEXEC && X86_32
98904 + help
98905 + Due to implementation details the kernel must reserve a fixed
98906 + amount of memory for runtime allocated code (such as modules)
98907 + at compile time that cannot be changed at runtime. Here you
98908 + can specify the minimum amount in MB that will be reserved.
98909 + Due to the same implementation details this size will always
98910 + be rounded up to the next 2/4 MB boundary (depends on PAE) so
98911 + the actually available memory for runtime allocated code will
98912 + usually be more than this minimum.
98913 +
98914 + The default 4 MB should be enough for most users but if you have
98915 + an excessive number of modules (e.g., most distribution configs
98916 + compile many drivers as modules) or use huge modules such as
98917 + nvidia's kernel driver, you will need to adjust this amount.
98918 + A good rule of thumb is to look at your currently loaded kernel
98919 + modules and add up their sizes.
98920 +
98921 +endmenu
98922 +
98923 +menu "Address Space Layout Randomization"
98924 + depends on PAX
98925 +
98926 +config PAX_ASLR
98927 + bool "Address Space Layout Randomization"
98928 + default y if GRKERNSEC_CONFIG_AUTO
98929 + help
98930 + Many if not most exploit techniques rely on the knowledge of
98931 + certain addresses in the attacked program. The following options
98932 + will allow the kernel to apply a certain amount of randomization
98933 + to specific parts of the program thereby forcing an attacker to
98934 + guess them in most cases. Any failed guess will most likely crash
98935 + the attacked program which allows the kernel to detect such attempts
98936 + and react on them. PaX itself provides no reaction mechanisms,
98937 + instead it is strongly encouraged that you make use of Nergal's
98938 + segvguard (ftp://ftp.pl.openwall.com/misc/segvguard/) or grsecurity's
98939 + (http://www.grsecurity.net/) built-in crash detection features or
98940 + develop one yourself.
98941 +
98942 + By saying Y here you can choose to randomize the following areas:
98943 + - top of the task's kernel stack
98944 + - top of the task's userland stack
98945 + - base address for mmap() requests that do not specify one
98946 + (this includes all libraries)
98947 + - base address of the main executable
98948 +
98949 + It is strongly recommended to say Y here as address space layout
98950 + randomization has negligible impact on performance yet it provides
98951 + a very effective protection.
98952 +
98953 + NOTE: you can use the 'chpax' or 'paxctl' utilities to control
98954 + this feature on a per file basis.
98955 +
98956 +config PAX_RANDKSTACK
98957 + bool "Randomize kernel stack base"
98958 + default y if GRKERNSEC_CONFIG_AUTO && !(GRKERNSEC_CONFIG_VIRT_HOST && GRKERNSEC_CONFIG_VIRT_VIRTUALBOX)
98959 + depends on X86_TSC && X86
98960 + help
98961 + By saying Y here the kernel will randomize every task's kernel
98962 + stack on every system call. This will not only force an attacker
98963 + to guess it but also prevent him from making use of possible
98964 + leaked information about it.
98965 +
98966 + Since the kernel stack is a rather scarce resource, randomization
98967 + may cause unexpected stack overflows, therefore you should very
98968 + carefully test your system. Note that once enabled in the kernel
98969 + configuration, this feature cannot be disabled on a per file basis.
98970 +
98971 +config PAX_RANDUSTACK
98972 + bool "Randomize user stack base"
98973 + default y if GRKERNSEC_CONFIG_AUTO
98974 + depends on PAX_ASLR
98975 + help
98976 + By saying Y here the kernel will randomize every task's userland
98977 + stack. The randomization is done in two steps where the second
98978 + one may apply a big amount of shift to the top of the stack and
98979 + cause problems for programs that want to use lots of memory (more
98980 + than 2.5 GB if SEGMEXEC is not active, or 1.25 GB when it is).
98981 + For this reason the second step can be controlled by 'chpax' or
98982 + 'paxctl' on a per file basis.
98983 +
98984 +config PAX_RANDMMAP
98985 + bool "Randomize mmap() base"
98986 + default y if GRKERNSEC_CONFIG_AUTO
98987 + depends on PAX_ASLR
98988 + help
98989 + By saying Y here the kernel will use a randomized base address for
98990 + mmap() requests that do not specify one themselves. As a result
98991 + all dynamically loaded libraries will appear at random addresses
98992 + and therefore be harder to exploit by a technique where an attacker
98993 + attempts to execute library code for his purposes (e.g. spawn a
98994 + shell from an exploited program that is running at an elevated
98995 + privilege level).
98996 +
98997 + Furthermore, if a program is relinked as a dynamic ELF file, its
98998 + base address will be randomized as well, completing the full
98999 + randomization of the address space layout. Attacking such programs
99000 + becomes a guess game. You can find an example of doing this at
99001 + http://pax.grsecurity.net/et_dyn.tar.gz and practical samples at
99002 + http://www.grsecurity.net/grsec-gcc-specs.tar.gz .
99003 +
99004 + NOTE: you can use the 'chpax' or 'paxctl' utilities to control this
99005 + feature on a per file basis.
99006 +
99007 +endmenu
99008 +
99009 +menu "Miscellaneous hardening features"
99010 +
99011 +config PAX_MEMORY_SANITIZE
99012 + bool "Sanitize all freed memory"
99013 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_PRIORITY_SECURITY)
99014 + depends on !HIBERNATION
99015 + help
99016 + By saying Y here the kernel will erase memory pages and slab objects
99017 + as soon as they are freed. This in turn reduces the lifetime of data
99018 + stored in them, making it less likely that sensitive information such
99019 + as passwords, cryptographic secrets, etc stay in memory for too long.
99020 +
99021 + This is especially useful for programs whose runtime is short, long
99022 + lived processes and the kernel itself benefit from this as long as
99023 + they ensure timely freeing of memory that may hold sensitive
99024 + information.
99025 +
99026 + A nice side effect of the sanitization of slab objects is the
99027 + reduction of possible info leaks caused by padding bytes within the
99028 + leaky structures. Use-after-free bugs for structures containing
99029 + pointers can also be detected as dereferencing the sanitized pointer
99030 + will generate an access violation.
99031 +
99032 + The tradeoff is performance impact, on a single CPU system kernel
99033 + compilation sees a 3% slowdown, other systems and workloads may vary
99034 + and you are advised to test this feature on your expected workload
99035 + before deploying it.
99036 +
99037 + To reduce the performance penalty by sanitizing pages only, albeit
99038 + limiting the effectiveness of this feature at the same time, slab
99039 + sanitization can be disabled with the kernel commandline parameter
99040 + "pax_sanitize_slab=0".
99041 +
99042 + Note that this feature does not protect data stored in live pages,
99043 + e.g., process memory swapped to disk may stay there for a long time.
99044 +
99045 +config PAX_MEMORY_STACKLEAK
99046 + bool "Sanitize kernel stack"
99047 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_PRIORITY_SECURITY)
99048 + depends on X86
99049 + help
99050 + By saying Y here the kernel will erase the kernel stack before it
99051 + returns from a system call. This in turn reduces the information
99052 + that a kernel stack leak bug can reveal.
99053 +
99054 + Note that such a bug can still leak information that was put on
99055 + the stack by the current system call (the one eventually triggering
99056 + the bug) but traces of earlier system calls on the kernel stack
99057 + cannot leak anymore.
99058 +
99059 + The tradeoff is performance impact: on a single CPU system kernel
99060 + compilation sees a 1% slowdown, other systems and workloads may vary
99061 + and you are advised to test this feature on your expected workload
99062 + before deploying it.
99063 +
99064 + Note that the full feature requires a gcc with plugin support,
99065 + i.e., gcc 4.5 or newer. You may need to install the supporting
99066 + headers explicitly in addition to the normal gcc package. Using
99067 + older gcc versions means that functions with large enough stack
99068 + frames may leave uninitialized memory behind that may be exposed
99069 + to a later syscall leaking the stack.
99070 +
99071 +config PAX_MEMORY_STRUCTLEAK
99072 + bool "Forcibly initialize local variables copied to userland"
99073 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_PRIORITY_SECURITY)
99074 + help
99075 + By saying Y here the kernel will zero initialize some local
99076 + variables that are going to be copied to userland. This in
99077 + turn prevents unintended information leakage from the kernel
99078 + stack should later code forget to explicitly set all parts of
99079 + the copied variable.
99080 +
99081 + The tradeoff is less performance impact than PAX_MEMORY_STACKLEAK
99082 + at a much smaller coverage.
99083 +
99084 + Note that the implementation requires a gcc with plugin support,
99085 + i.e., gcc 4.5 or newer. You may need to install the supporting
99086 + headers explicitly in addition to the normal gcc package.
99087 +
99088 +config PAX_MEMORY_UDEREF
99089 + bool "Prevent invalid userland pointer dereference"
99090 + default y if GRKERNSEC_CONFIG_AUTO && !(X86_64 && GRKERNSEC_CONFIG_PRIORITY_PERF) && (GRKERNSEC_CONFIG_VIRT_NONE || GRKERNSEC_CONFIG_VIRT_EPT)
99091 + depends on (X86 || (ARM && (CPU_V6 || CPU_V6K || CPU_V7) && !ARM_LPAE)) && !UML_X86 && !XEN
99092 + select PAX_PER_CPU_PGD if X86_64
99093 + help
99094 + By saying Y here the kernel will be prevented from dereferencing
99095 + userland pointers in contexts where the kernel expects only kernel
99096 + pointers. This is both a useful runtime debugging feature and a
99097 + security measure that prevents exploiting a class of kernel bugs.
99098 +
99099 + The tradeoff is that some virtualization solutions may experience
99100 + a huge slowdown and therefore you should not enable this feature
99101 + for kernels meant to run in such environments. Whether a given VM
99102 + solution is affected or not is best determined by simply trying it
99103 + out, the performance impact will be obvious right on boot as this
99104 + mechanism engages from very early on. A good rule of thumb is that
99105 + VMs running on CPUs without hardware virtualization support (i.e.,
99106 + the majority of IA-32 CPUs) will likely experience the slowdown.
99107 +
99108 + On X86_64 the kernel will make use of PCID support when available
99109 + (Intel's Westmere, Sandy Bridge, etc) for better security (default)
99110 + or performance impact. Pass pax_weakuderef on the kernel command
99111 + line to choose the latter.
99112 +
99113 +config PAX_REFCOUNT
99114 + bool "Prevent various kernel object reference counter overflows"
99115 + default y if GRKERNSEC_CONFIG_AUTO
99116 + depends on GRKERNSEC && ((ARM && (CPU_V6 || CPU_V6K || CPU_V7)) || MIPS || SPARC64 || X86)
99117 + help
99118 + By saying Y here the kernel will detect and prevent overflowing
99119 + various (but not all) kinds of object reference counters. Such
99120 + overflows can normally occur due to bugs only and are often, if
99121 + not always, exploitable.
99122 +
99123 + The tradeoff is that data structures protected by an overflowed
99124 + refcount will never be freed and therefore will leak memory. Note
99125 + that this leak also happens even without this protection but in
99126 + that case the overflow can eventually trigger the freeing of the
99127 + data structure while it is still being used elsewhere, resulting
99128 + in the exploitable situation that this feature prevents.
99129 +
99130 + Since this has a negligible performance impact, you should enable
99131 + this feature.
99132 +
99133 +config PAX_CONSTIFY_PLUGIN
99134 + bool "Automatically constify eligible structures"
99135 + default y
99136 + depends on !UML && PAX_KERNEXEC
99137 + help
99138 + By saying Y here the compiler will automatically constify a class
99139 + of types that contain only function pointers. This reduces the
99140 + kernel's attack surface and also produces a better memory layout.
99141 +
99142 + Note that the implementation requires a gcc with plugin support,
99143 + i.e., gcc 4.5 or newer. You may need to install the supporting
99144 + headers explicitly in addition to the normal gcc package.
99145 +
99146 + Note that if some code really has to modify constified variables
99147 + then the source code will have to be patched to allow it. Examples
99148 + can be found in PaX itself (the no_const attribute) and for some
99149 + out-of-tree modules at http://www.grsecurity.net/~paxguy1/ .
99150 +
99151 +config PAX_USERCOPY
99152 + bool "Harden heap object copies between kernel and userland"
99153 + default y if GRKERNSEC_CONFIG_AUTO
99154 + depends on ARM || IA64 || PPC || SPARC || X86
99155 + depends on GRKERNSEC && (SLAB || SLUB || SLOB)
99156 + select PAX_USERCOPY_SLABS
99157 + help
99158 + By saying Y here the kernel will enforce the size of heap objects
99159 + when they are copied in either direction between the kernel and
99160 + userland, even if only a part of the heap object is copied.
99161 +
99162 + Specifically, this checking prevents information leaking from the
99163 + kernel heap during kernel to userland copies (if the kernel heap
99164 + object is otherwise fully initialized) and prevents kernel heap
99165 + overflows during userland to kernel copies.
99166 +
99167 + Note that the current implementation provides the strictest bounds
99168 + checks for the SLUB allocator.
99169 +
99170 + Enabling this option also enables per-slab cache protection against
99171 + data in a given cache being copied into/out of via userland
99172 + accessors. Though the whitelist of regions will be reduced over
99173 + time, it notably protects important data structures like task structs.
99174 +
99175 + If frame pointers are enabled on x86, this option will also restrict
99176 + copies into and out of the kernel stack to local variables within a
99177 + single frame.
99178 +
99179 + Since this has a negligible performance impact, you should enable
99180 + this feature.
99181 +
99182 +config PAX_USERCOPY_DEBUG
99183 + bool
99184 + depends on X86 && PAX_USERCOPY
99185 + default n
99186 +
99187 +config PAX_SIZE_OVERFLOW
99188 + bool "Prevent various integer overflows in function size parameters"
99189 + default y if GRKERNSEC_CONFIG_AUTO
99190 + depends on X86
99191 + help
99192 + By saying Y here the kernel recomputes expressions of function
99193 + arguments marked by a size_overflow attribute with double integer
99194 + precision (DImode/TImode for 32/64 bit integer types).
99195 +
99196 + The recomputed argument is checked against TYPE_MAX and an event
99197 + is logged on overflow and the triggering process is killed.
99198 +
99199 + Homepage: http://www.grsecurity.net/~ephox/overflow_plugin/
99200 +
99201 + Note that the implementation requires a gcc with plugin support,
99202 + i.e., gcc 4.5 or newer. You may need to install the supporting
99203 + headers explicitly in addition to the normal gcc package.
99204 +
99205 +config PAX_LATENT_ENTROPY
99206 + bool "Generate some entropy during boot and runtime"
99207 + default y if GRKERNSEC_CONFIG_AUTO
99208 + help
99209 + By saying Y here the kernel will instrument some kernel code to
99210 + extract some entropy from both original and artificially created
99211 + program state. This will help especially embedded systems where
99212 + there is little 'natural' source of entropy normally. The cost
99213 + is some slowdown of the boot process and fork and irq processing.
99214 +
99215 + When pax_extra_latent_entropy is passed on the kernel command line,
99216 + entropy will be extracted from up to the first 4GB of RAM while the
99217 + runtime memory allocator is being initialized. This costs even more
99218 + slowdown of the boot process.
99219 +
99220 + Note that the implementation requires a gcc with plugin support,
99221 + i.e., gcc 4.5 or newer. You may need to install the supporting
99222 + headers explicitly in addition to the normal gcc package.
99223 +
99224 + Note that entropy extracted this way is not cryptographically
99225 + secure!
99226 +
99227 +endmenu
99228 +
99229 +endmenu
99230 +
99231 +source grsecurity/Kconfig
99232 +
99233 +endmenu
99234 +
99235 +endmenu
99236 +
99237 source security/keys/Kconfig
99238
99239 config SECURITY_DMESG_RESTRICT
99240 @@ -103,7 +1057,7 @@ config INTEL_TXT
99241 config LSM_MMAP_MIN_ADDR
99242 int "Low address space for LSM to protect from user allocation"
99243 depends on SECURITY && SECURITY_SELINUX
99244 - default 32768 if ARM
99245 + default 32768 if ALPHA || ARM || PARISC || SPARC32
99246 default 65536
99247 help
99248 This is the portion of low virtual memory which should be protected
99249 diff --git a/security/apparmor/lsm.c b/security/apparmor/lsm.c
99250 index fb99e18..b3e0bbb 100644
99251 --- a/security/apparmor/lsm.c
99252 +++ b/security/apparmor/lsm.c
99253 @@ -615,7 +615,7 @@ static int apparmor_task_setrlimit(struct task_struct *task,
99254 return error;
99255 }
99256
99257 -static struct security_operations apparmor_ops = {
99258 +static struct security_operations apparmor_ops __read_only = {
99259 .name = "apparmor",
99260
99261 .ptrace_access_check = apparmor_ptrace_access_check,
99262 diff --git a/security/commoncap.c b/security/commoncap.c
99263 index b9d613e..f68305c 100644
99264 --- a/security/commoncap.c
99265 +++ b/security/commoncap.c
99266 @@ -424,6 +424,32 @@ int get_vfs_caps_from_disk(const struct dentry *dentry, struct cpu_vfs_cap_data
99267 return 0;
99268 }
99269
99270 +/* returns:
99271 + 1 for suid privilege
99272 + 2 for sgid privilege
99273 + 3 for fscap privilege
99274 +*/
99275 +int is_privileged_binary(const struct dentry *dentry)
99276 +{
99277 + struct cpu_vfs_cap_data capdata;
99278 + struct inode *inode = dentry->d_inode;
99279 +
99280 + if (!inode || S_ISDIR(inode->i_mode))
99281 + return 0;
99282 +
99283 + if (inode->i_mode & S_ISUID)
99284 + return 1;
99285 + if ((inode->i_mode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP))
99286 + return 2;
99287 +
99288 + if (!get_vfs_caps_from_disk(dentry, &capdata)) {
99289 + if (!cap_isclear(capdata.inheritable) || !cap_isclear(capdata.permitted))
99290 + return 3;
99291 + }
99292 +
99293 + return 0;
99294 +}
99295 +
99296 /*
99297 * Attempt to get the on-exec apply capability sets for an executable file from
99298 * its xattrs and, if present, apply them to the proposed credentials being
99299 @@ -592,6 +618,9 @@ int cap_bprm_secureexec(struct linux_binprm *bprm)
99300 const struct cred *cred = current_cred();
99301 kuid_t root_uid = make_kuid(cred->user_ns, 0);
99302
99303 + if (gr_acl_enable_at_secure())
99304 + return 1;
99305 +
99306 if (!uid_eq(cred->uid, root_uid)) {
99307 if (bprm->cap_effective)
99308 return 1;
99309 diff --git a/security/integrity/ima/ima.h b/security/integrity/ima/ima.h
99310 index b3dd616..4bb17f3 100644
99311 --- a/security/integrity/ima/ima.h
99312 +++ b/security/integrity/ima/ima.h
99313 @@ -83,8 +83,8 @@ int ima_init_crypto(void);
99314 extern spinlock_t ima_queue_lock;
99315
99316 struct ima_h_table {
99317 - atomic_long_t len; /* number of stored measurements in the list */
99318 - atomic_long_t violations;
99319 + atomic_long_unchecked_t len; /* number of stored measurements in the list */
99320 + atomic_long_unchecked_t violations;
99321 struct hlist_head queue[IMA_MEASURE_HTABLE_SIZE];
99322 };
99323 extern struct ima_h_table ima_htable;
99324 diff --git a/security/integrity/ima/ima_api.c b/security/integrity/ima/ima_api.c
99325 index 1c03e8f1..398a941 100644
99326 --- a/security/integrity/ima/ima_api.c
99327 +++ b/security/integrity/ima/ima_api.c
99328 @@ -79,7 +79,7 @@ void ima_add_violation(struct inode *inode, const unsigned char *filename,
99329 int result;
99330
99331 /* can overflow, only indicator */
99332 - atomic_long_inc(&ima_htable.violations);
99333 + atomic_long_inc_unchecked(&ima_htable.violations);
99334
99335 entry = kmalloc(sizeof(*entry), GFP_KERNEL);
99336 if (!entry) {
99337 diff --git a/security/integrity/ima/ima_fs.c b/security/integrity/ima/ima_fs.c
99338 index 38477c9..87a60c7 100644
99339 --- a/security/integrity/ima/ima_fs.c
99340 +++ b/security/integrity/ima/ima_fs.c
99341 @@ -28,12 +28,12 @@
99342 static int valid_policy = 1;
99343 #define TMPBUFLEN 12
99344 static ssize_t ima_show_htable_value(char __user *buf, size_t count,
99345 - loff_t *ppos, atomic_long_t *val)
99346 + loff_t *ppos, atomic_long_unchecked_t *val)
99347 {
99348 char tmpbuf[TMPBUFLEN];
99349 ssize_t len;
99350
99351 - len = scnprintf(tmpbuf, TMPBUFLEN, "%li\n", atomic_long_read(val));
99352 + len = scnprintf(tmpbuf, TMPBUFLEN, "%li\n", atomic_long_read_unchecked(val));
99353 return simple_read_from_buffer(buf, count, ppos, tmpbuf, len);
99354 }
99355
99356 diff --git a/security/integrity/ima/ima_queue.c b/security/integrity/ima/ima_queue.c
99357 index ff63fe0..809cd96 100644
99358 --- a/security/integrity/ima/ima_queue.c
99359 +++ b/security/integrity/ima/ima_queue.c
99360 @@ -80,7 +80,7 @@ static int ima_add_digest_entry(struct ima_template_entry *entry)
99361 INIT_LIST_HEAD(&qe->later);
99362 list_add_tail_rcu(&qe->later, &ima_measurements);
99363
99364 - atomic_long_inc(&ima_htable.len);
99365 + atomic_long_inc_unchecked(&ima_htable.len);
99366 key = ima_hash_key(entry->digest);
99367 hlist_add_head_rcu(&qe->hnext, &ima_htable.queue[key]);
99368 return 0;
99369 diff --git a/security/keys/compat.c b/security/keys/compat.c
99370 index d65fa7f..cbfe366 100644
99371 --- a/security/keys/compat.c
99372 +++ b/security/keys/compat.c
99373 @@ -44,7 +44,7 @@ static long compat_keyctl_instantiate_key_iov(
99374 if (ret == 0)
99375 goto no_payload_free;
99376
99377 - ret = keyctl_instantiate_key_common(id, iov, ioc, ret, ringid);
99378 + ret = keyctl_instantiate_key_common(id, (const struct iovec __force_user *)iov, ioc, ret, ringid);
99379 err:
99380 if (iov != iovstack)
99381 kfree(iov);
99382 diff --git a/security/keys/internal.h b/security/keys/internal.h
99383 index d4f1468..cc52f92 100644
99384 --- a/security/keys/internal.h
99385 +++ b/security/keys/internal.h
99386 @@ -242,7 +242,7 @@ extern long keyctl_instantiate_key_iov(key_serial_t,
99387 extern long keyctl_invalidate_key(key_serial_t);
99388
99389 extern long keyctl_instantiate_key_common(key_serial_t,
99390 - const struct iovec *,
99391 + const struct iovec __user *,
99392 unsigned, size_t, key_serial_t);
99393
99394 /*
99395 diff --git a/security/keys/key.c b/security/keys/key.c
99396 index 8fb7c7b..ba3610d 100644
99397 --- a/security/keys/key.c
99398 +++ b/security/keys/key.c
99399 @@ -284,7 +284,7 @@ struct key *key_alloc(struct key_type *type, const char *desc,
99400
99401 atomic_set(&key->usage, 1);
99402 init_rwsem(&key->sem);
99403 - lockdep_set_class(&key->sem, &type->lock_class);
99404 + lockdep_set_class(&key->sem, (struct lock_class_key *)&type->lock_class);
99405 key->type = type;
99406 key->user = user;
99407 key->quotalen = quotalen;
99408 @@ -1032,7 +1032,9 @@ int register_key_type(struct key_type *ktype)
99409 struct key_type *p;
99410 int ret;
99411
99412 - memset(&ktype->lock_class, 0, sizeof(ktype->lock_class));
99413 + pax_open_kernel();
99414 + memset((void *)&ktype->lock_class, 0, sizeof(ktype->lock_class));
99415 + pax_close_kernel();
99416
99417 ret = -EEXIST;
99418 down_write(&key_types_sem);
99419 @@ -1044,7 +1046,7 @@ int register_key_type(struct key_type *ktype)
99420 }
99421
99422 /* store the type */
99423 - list_add(&ktype->link, &key_types_list);
99424 + pax_list_add((struct list_head *)&ktype->link, &key_types_list);
99425
99426 pr_notice("Key type %s registered\n", ktype->name);
99427 ret = 0;
99428 @@ -1066,7 +1068,7 @@ EXPORT_SYMBOL(register_key_type);
99429 void unregister_key_type(struct key_type *ktype)
99430 {
99431 down_write(&key_types_sem);
99432 - list_del_init(&ktype->link);
99433 + pax_list_del_init((struct list_head *)&ktype->link);
99434 downgrade_write(&key_types_sem);
99435 key_gc_keytype(ktype);
99436 pr_notice("Key type %s unregistered\n", ktype->name);
99437 @@ -1084,10 +1086,10 @@ void __init key_init(void)
99438 0, SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL);
99439
99440 /* add the special key types */
99441 - list_add_tail(&key_type_keyring.link, &key_types_list);
99442 - list_add_tail(&key_type_dead.link, &key_types_list);
99443 - list_add_tail(&key_type_user.link, &key_types_list);
99444 - list_add_tail(&key_type_logon.link, &key_types_list);
99445 + pax_list_add_tail((struct list_head *)&key_type_keyring.link, &key_types_list);
99446 + pax_list_add_tail((struct list_head *)&key_type_dead.link, &key_types_list);
99447 + pax_list_add_tail((struct list_head *)&key_type_user.link, &key_types_list);
99448 + pax_list_add_tail((struct list_head *)&key_type_logon.link, &key_types_list);
99449
99450 /* record the root user tracking */
99451 rb_link_node(&root_key_user.node,
99452 diff --git a/security/keys/keyctl.c b/security/keys/keyctl.c
99453 index 33cfd27..842fc5a 100644
99454 --- a/security/keys/keyctl.c
99455 +++ b/security/keys/keyctl.c
99456 @@ -987,7 +987,7 @@ static int keyctl_change_reqkey_auth(struct key *key)
99457 /*
99458 * Copy the iovec data from userspace
99459 */
99460 -static long copy_from_user_iovec(void *buffer, const struct iovec *iov,
99461 +static long copy_from_user_iovec(void *buffer, const struct iovec __user *iov,
99462 unsigned ioc)
99463 {
99464 for (; ioc > 0; ioc--) {
99465 @@ -1009,7 +1009,7 @@ static long copy_from_user_iovec(void *buffer, const struct iovec *iov,
99466 * If successful, 0 will be returned.
99467 */
99468 long keyctl_instantiate_key_common(key_serial_t id,
99469 - const struct iovec *payload_iov,
99470 + const struct iovec __user *payload_iov,
99471 unsigned ioc,
99472 size_t plen,
99473 key_serial_t ringid)
99474 @@ -1104,7 +1104,7 @@ long keyctl_instantiate_key(key_serial_t id,
99475 [0].iov_len = plen
99476 };
99477
99478 - return keyctl_instantiate_key_common(id, iov, 1, plen, ringid);
99479 + return keyctl_instantiate_key_common(id, (const struct iovec __force_user *)iov, 1, plen, ringid);
99480 }
99481
99482 return keyctl_instantiate_key_common(id, NULL, 0, 0, ringid);
99483 @@ -1137,7 +1137,7 @@ long keyctl_instantiate_key_iov(key_serial_t id,
99484 if (ret == 0)
99485 goto no_payload_free;
99486
99487 - ret = keyctl_instantiate_key_common(id, iov, ioc, ret, ringid);
99488 + ret = keyctl_instantiate_key_common(id, (const struct iovec __force_user *)iov, ioc, ret, ringid);
99489 err:
99490 if (iov != iovstack)
99491 kfree(iov);
99492 diff --git a/security/keys/keyring.c b/security/keys/keyring.c
99493 index 6ece7f2..ecdb55c 100644
99494 --- a/security/keys/keyring.c
99495 +++ b/security/keys/keyring.c
99496 @@ -227,16 +227,16 @@ static long keyring_read(const struct key *keyring,
99497 ret = -EFAULT;
99498
99499 for (loop = 0; loop < klist->nkeys; loop++) {
99500 + key_serial_t serial;
99501 key = rcu_deref_link_locked(klist, loop,
99502 keyring);
99503 + serial = key->serial;
99504
99505 tmp = sizeof(key_serial_t);
99506 if (tmp > buflen)
99507 tmp = buflen;
99508
99509 - if (copy_to_user(buffer,
99510 - &key->serial,
99511 - tmp) != 0)
99512 + if (copy_to_user(buffer, &serial, tmp))
99513 goto error;
99514
99515 buflen -= tmp;
99516 diff --git a/security/min_addr.c b/security/min_addr.c
99517 index f728728..6457a0c 100644
99518 --- a/security/min_addr.c
99519 +++ b/security/min_addr.c
99520 @@ -14,6 +14,7 @@ unsigned long dac_mmap_min_addr = CONFIG_DEFAULT_MMAP_MIN_ADDR;
99521 */
99522 static void update_mmap_min_addr(void)
99523 {
99524 +#ifndef SPARC
99525 #ifdef CONFIG_LSM_MMAP_MIN_ADDR
99526 if (dac_mmap_min_addr > CONFIG_LSM_MMAP_MIN_ADDR)
99527 mmap_min_addr = dac_mmap_min_addr;
99528 @@ -22,6 +23,7 @@ static void update_mmap_min_addr(void)
99529 #else
99530 mmap_min_addr = dac_mmap_min_addr;
99531 #endif
99532 +#endif
99533 }
99534
99535 /*
99536 diff --git a/security/security.c b/security/security.c
99537 index 4dc31f4..eabcf41 100644
99538 --- a/security/security.c
99539 +++ b/security/security.c
99540 @@ -33,8 +33,8 @@
99541 static __initdata char chosen_lsm[SECURITY_NAME_MAX + 1] =
99542 CONFIG_DEFAULT_SECURITY;
99543
99544 -static struct security_operations *security_ops;
99545 -static struct security_operations default_security_ops = {
99546 +struct security_operations *security_ops __read_only;
99547 +struct security_operations default_security_ops __read_only = {
99548 .name = "default",
99549 };
99550
99551 @@ -73,11 +73,6 @@ int __init security_init(void)
99552 return 0;
99553 }
99554
99555 -void reset_security_ops(void)
99556 -{
99557 - security_ops = &default_security_ops;
99558 -}
99559 -
99560 /* Save user chosen LSM */
99561 static int __init choose_lsm(char *str)
99562 {
99563 diff --git a/security/selinux/avc.c b/security/selinux/avc.c
99564 index fc3e662..7844c60 100644
99565 --- a/security/selinux/avc.c
99566 +++ b/security/selinux/avc.c
99567 @@ -59,7 +59,7 @@ struct avc_node {
99568 struct avc_cache {
99569 struct hlist_head slots[AVC_CACHE_SLOTS]; /* head for avc_node->list */
99570 spinlock_t slots_lock[AVC_CACHE_SLOTS]; /* lock for writes */
99571 - atomic_t lru_hint; /* LRU hint for reclaim scan */
99572 + atomic_unchecked_t lru_hint; /* LRU hint for reclaim scan */
99573 atomic_t active_nodes;
99574 u32 latest_notif; /* latest revocation notification */
99575 };
99576 @@ -167,7 +167,7 @@ void __init avc_init(void)
99577 spin_lock_init(&avc_cache.slots_lock[i]);
99578 }
99579 atomic_set(&avc_cache.active_nodes, 0);
99580 - atomic_set(&avc_cache.lru_hint, 0);
99581 + atomic_set_unchecked(&avc_cache.lru_hint, 0);
99582
99583 avc_node_cachep = kmem_cache_create("avc_node", sizeof(struct avc_node),
99584 0, SLAB_PANIC, NULL);
99585 @@ -242,7 +242,7 @@ static inline int avc_reclaim_node(void)
99586 spinlock_t *lock;
99587
99588 for (try = 0, ecx = 0; try < AVC_CACHE_SLOTS; try++) {
99589 - hvalue = atomic_inc_return(&avc_cache.lru_hint) & (AVC_CACHE_SLOTS - 1);
99590 + hvalue = atomic_inc_return_unchecked(&avc_cache.lru_hint) & (AVC_CACHE_SLOTS - 1);
99591 head = &avc_cache.slots[hvalue];
99592 lock = &avc_cache.slots_lock[hvalue];
99593
99594 diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c
99595 index 5b52310..da3bf8e 100644
99596 --- a/security/selinux/hooks.c
99597 +++ b/security/selinux/hooks.c
99598 @@ -5603,7 +5603,7 @@ static int selinux_key_getsecurity(struct key *key, char **_buffer)
99599
99600 #endif
99601
99602 -static struct security_operations selinux_ops = {
99603 +static struct security_operations selinux_ops __read_only = {
99604 .name = "selinux",
99605
99606 .ptrace_access_check = selinux_ptrace_access_check,
99607 @@ -5955,6 +5955,9 @@ static void selinux_nf_ip_exit(void)
99608 #ifdef CONFIG_SECURITY_SELINUX_DISABLE
99609 static int selinux_disabled;
99610
99611 +extern struct security_operations *security_ops;
99612 +extern struct security_operations default_security_ops;
99613 +
99614 int selinux_disable(void)
99615 {
99616 if (ss_initialized) {
99617 @@ -5972,7 +5975,9 @@ int selinux_disable(void)
99618 selinux_disabled = 1;
99619 selinux_enabled = 0;
99620
99621 - reset_security_ops();
99622 + pax_open_kernel();
99623 + security_ops = &default_security_ops;
99624 + pax_close_kernel();
99625
99626 /* Try to destroy the avc node cache */
99627 avc_disable();
99628 diff --git a/security/selinux/include/xfrm.h b/security/selinux/include/xfrm.h
99629 index 6713f04..c57ecef 100644
99630 --- a/security/selinux/include/xfrm.h
99631 +++ b/security/selinux/include/xfrm.h
99632 @@ -52,7 +52,7 @@ static inline void selinux_xfrm_notify_policyload(void)
99633 {
99634 struct net *net;
99635
99636 - atomic_inc(&flow_cache_genid);
99637 + atomic_inc_unchecked(&flow_cache_genid);
99638 rtnl_lock();
99639 for_each_net(net)
99640 rt_genid_bump_all(net);
99641 diff --git a/security/smack/smack_lsm.c b/security/smack/smack_lsm.c
99642 index 8825375..97a623b 100644
99643 --- a/security/smack/smack_lsm.c
99644 +++ b/security/smack/smack_lsm.c
99645 @@ -3726,7 +3726,7 @@ static int smack_inode_getsecctx(struct inode *inode, void **ctx, u32 *ctxlen)
99646 return 0;
99647 }
99648
99649 -struct security_operations smack_ops = {
99650 +struct security_operations smack_ops __read_only = {
99651 .name = "smack",
99652
99653 .ptrace_access_check = smack_ptrace_access_check,
99654 diff --git a/security/tomoyo/mount.c b/security/tomoyo/mount.c
99655 index 390c646..f2f8db3 100644
99656 --- a/security/tomoyo/mount.c
99657 +++ b/security/tomoyo/mount.c
99658 @@ -118,6 +118,10 @@ static int tomoyo_mount_acl(struct tomoyo_request_info *r,
99659 type == tomoyo_mounts[TOMOYO_MOUNT_MOVE]) {
99660 need_dev = -1; /* dev_name is a directory */
99661 } else {
99662 + if (!capable(CAP_SYS_ADMIN)) {
99663 + error = -EPERM;
99664 + goto out;
99665 + }
99666 fstype = get_fs_type(type);
99667 if (!fstype) {
99668 error = -ENODEV;
99669 diff --git a/security/tomoyo/tomoyo.c b/security/tomoyo/tomoyo.c
99670 index f0b756e..b129202 100644
99671 --- a/security/tomoyo/tomoyo.c
99672 +++ b/security/tomoyo/tomoyo.c
99673 @@ -503,7 +503,7 @@ static int tomoyo_socket_sendmsg(struct socket *sock, struct msghdr *msg,
99674 * tomoyo_security_ops is a "struct security_operations" which is used for
99675 * registering TOMOYO.
99676 */
99677 -static struct security_operations tomoyo_security_ops = {
99678 +static struct security_operations tomoyo_security_ops __read_only = {
99679 .name = "tomoyo",
99680 .cred_alloc_blank = tomoyo_cred_alloc_blank,
99681 .cred_prepare = tomoyo_cred_prepare,
99682 diff --git a/security/yama/Kconfig b/security/yama/Kconfig
99683 index 20ef514..4182bed 100644
99684 --- a/security/yama/Kconfig
99685 +++ b/security/yama/Kconfig
99686 @@ -1,6 +1,6 @@
99687 config SECURITY_YAMA
99688 bool "Yama support"
99689 - depends on SECURITY
99690 + depends on SECURITY && !GRKERNSEC
99691 select SECURITYFS
99692 select SECURITY_PATH
99693 default n
99694 diff --git a/security/yama/yama_lsm.c b/security/yama/yama_lsm.c
99695 index 13c88fbc..f8c115e 100644
99696 --- a/security/yama/yama_lsm.c
99697 +++ b/security/yama/yama_lsm.c
99698 @@ -365,7 +365,7 @@ int yama_ptrace_traceme(struct task_struct *parent)
99699 }
99700
99701 #ifndef CONFIG_SECURITY_YAMA_STACKED
99702 -static struct security_operations yama_ops = {
99703 +static struct security_operations yama_ops __read_only = {
99704 .name = "yama",
99705
99706 .ptrace_access_check = yama_ptrace_access_check,
99707 @@ -376,28 +376,24 @@ static struct security_operations yama_ops = {
99708 #endif
99709
99710 #ifdef CONFIG_SYSCTL
99711 +static int zero __read_only;
99712 +static int max_scope __read_only = YAMA_SCOPE_NO_ATTACH;
99713 +
99714 static int yama_dointvec_minmax(struct ctl_table *table, int write,
99715 void __user *buffer, size_t *lenp, loff_t *ppos)
99716 {
99717 - int rc;
99718 + ctl_table_no_const yama_table;
99719
99720 if (write && !capable(CAP_SYS_PTRACE))
99721 return -EPERM;
99722
99723 - rc = proc_dointvec_minmax(table, write, buffer, lenp, ppos);
99724 - if (rc)
99725 - return rc;
99726 -
99727 + yama_table = *table;
99728 /* Lock the max value if it ever gets set. */
99729 - if (write && *(int *)table->data == *(int *)table->extra2)
99730 - table->extra1 = table->extra2;
99731 -
99732 - return rc;
99733 + if (ptrace_scope == max_scope)
99734 + yama_table.extra1 = &max_scope;
99735 + return proc_dointvec_minmax(&yama_table, write, buffer, lenp, ppos);
99736 }
99737
99738 -static int zero;
99739 -static int max_scope = YAMA_SCOPE_NO_ATTACH;
99740 -
99741 struct ctl_path yama_sysctl_path[] = {
99742 { .procname = "kernel", },
99743 { .procname = "yama", },
99744 diff --git a/sound/aoa/codecs/onyx.c b/sound/aoa/codecs/onyx.c
99745 index 4cedc69..e59d8a3 100644
99746 --- a/sound/aoa/codecs/onyx.c
99747 +++ b/sound/aoa/codecs/onyx.c
99748 @@ -54,7 +54,7 @@ struct onyx {
99749 spdif_locked:1,
99750 analog_locked:1,
99751 original_mute:2;
99752 - int open_count;
99753 + local_t open_count;
99754 struct codec_info *codec_info;
99755
99756 /* mutex serializes concurrent access to the device
99757 @@ -753,7 +753,7 @@ static int onyx_open(struct codec_info_item *cii,
99758 struct onyx *onyx = cii->codec_data;
99759
99760 mutex_lock(&onyx->mutex);
99761 - onyx->open_count++;
99762 + local_inc(&onyx->open_count);
99763 mutex_unlock(&onyx->mutex);
99764
99765 return 0;
99766 @@ -765,8 +765,7 @@ static int onyx_close(struct codec_info_item *cii,
99767 struct onyx *onyx = cii->codec_data;
99768
99769 mutex_lock(&onyx->mutex);
99770 - onyx->open_count--;
99771 - if (!onyx->open_count)
99772 + if (local_dec_and_test(&onyx->open_count))
99773 onyx->spdif_locked = onyx->analog_locked = 0;
99774 mutex_unlock(&onyx->mutex);
99775
99776 diff --git a/sound/aoa/codecs/onyx.h b/sound/aoa/codecs/onyx.h
99777 index ffd2025..df062c9 100644
99778 --- a/sound/aoa/codecs/onyx.h
99779 +++ b/sound/aoa/codecs/onyx.h
99780 @@ -11,6 +11,7 @@
99781 #include <linux/i2c.h>
99782 #include <asm/pmac_low_i2c.h>
99783 #include <asm/prom.h>
99784 +#include <asm/local.h>
99785
99786 /* PCM3052 register definitions */
99787
99788 diff --git a/sound/core/oss/pcm_oss.c b/sound/core/oss/pcm_oss.c
99789 index 4c1cc51..16040040 100644
99790 --- a/sound/core/oss/pcm_oss.c
99791 +++ b/sound/core/oss/pcm_oss.c
99792 @@ -1189,10 +1189,10 @@ snd_pcm_sframes_t snd_pcm_oss_write3(struct snd_pcm_substream *substream, const
99793 if (in_kernel) {
99794 mm_segment_t fs;
99795 fs = snd_enter_user();
99796 - ret = snd_pcm_lib_write(substream, (void __force __user *)ptr, frames);
99797 + ret = snd_pcm_lib_write(substream, (void __force_user *)ptr, frames);
99798 snd_leave_user(fs);
99799 } else {
99800 - ret = snd_pcm_lib_write(substream, (void __force __user *)ptr, frames);
99801 + ret = snd_pcm_lib_write(substream, (void __force_user *)ptr, frames);
99802 }
99803 if (ret != -EPIPE && ret != -ESTRPIPE)
99804 break;
99805 @@ -1234,10 +1234,10 @@ snd_pcm_sframes_t snd_pcm_oss_read3(struct snd_pcm_substream *substream, char *p
99806 if (in_kernel) {
99807 mm_segment_t fs;
99808 fs = snd_enter_user();
99809 - ret = snd_pcm_lib_read(substream, (void __force __user *)ptr, frames);
99810 + ret = snd_pcm_lib_read(substream, (void __force_user *)ptr, frames);
99811 snd_leave_user(fs);
99812 } else {
99813 - ret = snd_pcm_lib_read(substream, (void __force __user *)ptr, frames);
99814 + ret = snd_pcm_lib_read(substream, (void __force_user *)ptr, frames);
99815 }
99816 if (ret == -EPIPE) {
99817 if (runtime->status->state == SNDRV_PCM_STATE_DRAINING) {
99818 @@ -1337,7 +1337,7 @@ static ssize_t snd_pcm_oss_write2(struct snd_pcm_substream *substream, const cha
99819 struct snd_pcm_plugin_channel *channels;
99820 size_t oss_frame_bytes = (runtime->oss.plugin_first->src_width * runtime->oss.plugin_first->src_format.channels) / 8;
99821 if (!in_kernel) {
99822 - if (copy_from_user(runtime->oss.buffer, (const char __force __user *)buf, bytes))
99823 + if (copy_from_user(runtime->oss.buffer, (const char __force_user *)buf, bytes))
99824 return -EFAULT;
99825 buf = runtime->oss.buffer;
99826 }
99827 @@ -1407,7 +1407,7 @@ static ssize_t snd_pcm_oss_write1(struct snd_pcm_substream *substream, const cha
99828 }
99829 } else {
99830 tmp = snd_pcm_oss_write2(substream,
99831 - (const char __force *)buf,
99832 + (const char __force_kernel *)buf,
99833 runtime->oss.period_bytes, 0);
99834 if (tmp <= 0)
99835 goto err;
99836 @@ -1433,7 +1433,7 @@ static ssize_t snd_pcm_oss_read2(struct snd_pcm_substream *substream, char *buf,
99837 struct snd_pcm_runtime *runtime = substream->runtime;
99838 snd_pcm_sframes_t frames, frames1;
99839 #ifdef CONFIG_SND_PCM_OSS_PLUGINS
99840 - char __user *final_dst = (char __force __user *)buf;
99841 + char __user *final_dst = (char __force_user *)buf;
99842 if (runtime->oss.plugin_first) {
99843 struct snd_pcm_plugin_channel *channels;
99844 size_t oss_frame_bytes = (runtime->oss.plugin_last->dst_width * runtime->oss.plugin_last->dst_format.channels) / 8;
99845 @@ -1495,7 +1495,7 @@ static ssize_t snd_pcm_oss_read1(struct snd_pcm_substream *substream, char __use
99846 xfer += tmp;
99847 runtime->oss.buffer_used -= tmp;
99848 } else {
99849 - tmp = snd_pcm_oss_read2(substream, (char __force *)buf,
99850 + tmp = snd_pcm_oss_read2(substream, (char __force_kernel *)buf,
99851 runtime->oss.period_bytes, 0);
99852 if (tmp <= 0)
99853 goto err;
99854 @@ -1663,7 +1663,7 @@ static int snd_pcm_oss_sync(struct snd_pcm_oss_file *pcm_oss_file)
99855 size1);
99856 size1 /= runtime->channels; /* frames */
99857 fs = snd_enter_user();
99858 - snd_pcm_lib_write(substream, (void __force __user *)runtime->oss.buffer, size1);
99859 + snd_pcm_lib_write(substream, (void __force_user *)runtime->oss.buffer, size1);
99860 snd_leave_user(fs);
99861 }
99862 } else if (runtime->access == SNDRV_PCM_ACCESS_RW_NONINTERLEAVED) {
99863 diff --git a/sound/core/pcm_compat.c b/sound/core/pcm_compat.c
99864 index af49721..e85058e 100644
99865 --- a/sound/core/pcm_compat.c
99866 +++ b/sound/core/pcm_compat.c
99867 @@ -31,7 +31,7 @@ static int snd_pcm_ioctl_delay_compat(struct snd_pcm_substream *substream,
99868 int err;
99869
99870 fs = snd_enter_user();
99871 - err = snd_pcm_delay(substream, &delay);
99872 + err = snd_pcm_delay(substream, (snd_pcm_sframes_t __force_user *)&delay);
99873 snd_leave_user(fs);
99874 if (err < 0)
99875 return err;
99876 diff --git a/sound/core/pcm_native.c b/sound/core/pcm_native.c
99877 index a68d4c6..72af3cf 100644
99878 --- a/sound/core/pcm_native.c
99879 +++ b/sound/core/pcm_native.c
99880 @@ -2809,11 +2809,11 @@ int snd_pcm_kernel_ioctl(struct snd_pcm_substream *substream,
99881 switch (substream->stream) {
99882 case SNDRV_PCM_STREAM_PLAYBACK:
99883 result = snd_pcm_playback_ioctl1(NULL, substream, cmd,
99884 - (void __user *)arg);
99885 + (void __force_user *)arg);
99886 break;
99887 case SNDRV_PCM_STREAM_CAPTURE:
99888 result = snd_pcm_capture_ioctl1(NULL, substream, cmd,
99889 - (void __user *)arg);
99890 + (void __force_user *)arg);
99891 break;
99892 default:
99893 result = -EINVAL;
99894 diff --git a/sound/core/seq/seq_device.c b/sound/core/seq/seq_device.c
99895 index 040c60e..989a19a 100644
99896 --- a/sound/core/seq/seq_device.c
99897 +++ b/sound/core/seq/seq_device.c
99898 @@ -64,7 +64,7 @@ struct ops_list {
99899 int argsize; /* argument size */
99900
99901 /* operators */
99902 - struct snd_seq_dev_ops ops;
99903 + struct snd_seq_dev_ops *ops;
99904
99905 /* registered devices */
99906 struct list_head dev_list; /* list of devices */
99907 @@ -333,7 +333,7 @@ int snd_seq_device_register_driver(char *id, struct snd_seq_dev_ops *entry,
99908
99909 mutex_lock(&ops->reg_mutex);
99910 /* copy driver operators */
99911 - ops->ops = *entry;
99912 + ops->ops = entry;
99913 ops->driver |= DRIVER_LOADED;
99914 ops->argsize = argsize;
99915
99916 @@ -463,7 +463,7 @@ static int init_device(struct snd_seq_device *dev, struct ops_list *ops)
99917 dev->name, ops->id, ops->argsize, dev->argsize);
99918 return -EINVAL;
99919 }
99920 - if (ops->ops.init_device(dev) >= 0) {
99921 + if (ops->ops->init_device(dev) >= 0) {
99922 dev->status = SNDRV_SEQ_DEVICE_REGISTERED;
99923 ops->num_init_devices++;
99924 } else {
99925 @@ -490,7 +490,7 @@ static int free_device(struct snd_seq_device *dev, struct ops_list *ops)
99926 dev->name, ops->id, ops->argsize, dev->argsize);
99927 return -EINVAL;
99928 }
99929 - if ((result = ops->ops.free_device(dev)) >= 0 || result == -ENXIO) {
99930 + if ((result = ops->ops->free_device(dev)) >= 0 || result == -ENXIO) {
99931 dev->status = SNDRV_SEQ_DEVICE_FREE;
99932 dev->driver_data = NULL;
99933 ops->num_init_devices--;
99934 diff --git a/sound/core/sound.c b/sound/core/sound.c
99935 index f002bd9..c462985 100644
99936 --- a/sound/core/sound.c
99937 +++ b/sound/core/sound.c
99938 @@ -86,7 +86,7 @@ static void snd_request_other(int minor)
99939 case SNDRV_MINOR_TIMER: str = "snd-timer"; break;
99940 default: return;
99941 }
99942 - request_module(str);
99943 + request_module("%s", str);
99944 }
99945
99946 #endif /* modular kernel */
99947 diff --git a/sound/drivers/mts64.c b/sound/drivers/mts64.c
99948 index 4e0dd22..7a1f32c 100644
99949 --- a/sound/drivers/mts64.c
99950 +++ b/sound/drivers/mts64.c
99951 @@ -29,6 +29,7 @@
99952 #include <sound/initval.h>
99953 #include <sound/rawmidi.h>
99954 #include <sound/control.h>
99955 +#include <asm/local.h>
99956
99957 #define CARD_NAME "Miditerminal 4140"
99958 #define DRIVER_NAME "MTS64"
99959 @@ -67,7 +68,7 @@ struct mts64 {
99960 struct pardevice *pardev;
99961 int pardev_claimed;
99962
99963 - int open_count;
99964 + local_t open_count;
99965 int current_midi_output_port;
99966 int current_midi_input_port;
99967 u8 mode[MTS64_NUM_INPUT_PORTS];
99968 @@ -697,7 +698,7 @@ static int snd_mts64_rawmidi_open(struct snd_rawmidi_substream *substream)
99969 {
99970 struct mts64 *mts = substream->rmidi->private_data;
99971
99972 - if (mts->open_count == 0) {
99973 + if (local_read(&mts->open_count) == 0) {
99974 /* We don't need a spinlock here, because this is just called
99975 if the device has not been opened before.
99976 So there aren't any IRQs from the device */
99977 @@ -705,7 +706,7 @@ static int snd_mts64_rawmidi_open(struct snd_rawmidi_substream *substream)
99978
99979 msleep(50);
99980 }
99981 - ++(mts->open_count);
99982 + local_inc(&mts->open_count);
99983
99984 return 0;
99985 }
99986 @@ -715,8 +716,7 @@ static int snd_mts64_rawmidi_close(struct snd_rawmidi_substream *substream)
99987 struct mts64 *mts = substream->rmidi->private_data;
99988 unsigned long flags;
99989
99990 - --(mts->open_count);
99991 - if (mts->open_count == 0) {
99992 + if (local_dec_return(&mts->open_count) == 0) {
99993 /* We need the spinlock_irqsave here because we can still
99994 have IRQs at this point */
99995 spin_lock_irqsave(&mts->lock, flags);
99996 @@ -725,8 +725,8 @@ static int snd_mts64_rawmidi_close(struct snd_rawmidi_substream *substream)
99997
99998 msleep(500);
99999
100000 - } else if (mts->open_count < 0)
100001 - mts->open_count = 0;
100002 + } else if (local_read(&mts->open_count) < 0)
100003 + local_set(&mts->open_count, 0);
100004
100005 return 0;
100006 }
100007 diff --git a/sound/drivers/opl4/opl4_lib.c b/sound/drivers/opl4/opl4_lib.c
100008 index b953fb4..1999c01 100644
100009 --- a/sound/drivers/opl4/opl4_lib.c
100010 +++ b/sound/drivers/opl4/opl4_lib.c
100011 @@ -29,7 +29,7 @@ MODULE_AUTHOR("Clemens Ladisch <clemens@ladisch.de>");
100012 MODULE_DESCRIPTION("OPL4 driver");
100013 MODULE_LICENSE("GPL");
100014
100015 -static void inline snd_opl4_wait(struct snd_opl4 *opl4)
100016 +static inline void snd_opl4_wait(struct snd_opl4 *opl4)
100017 {
100018 int timeout = 10;
100019 while ((inb(opl4->fm_port) & OPL4_STATUS_BUSY) && --timeout > 0)
100020 diff --git a/sound/drivers/portman2x4.c b/sound/drivers/portman2x4.c
100021 index 991018d..8984740 100644
100022 --- a/sound/drivers/portman2x4.c
100023 +++ b/sound/drivers/portman2x4.c
100024 @@ -48,6 +48,7 @@
100025 #include <sound/initval.h>
100026 #include <sound/rawmidi.h>
100027 #include <sound/control.h>
100028 +#include <asm/local.h>
100029
100030 #define CARD_NAME "Portman 2x4"
100031 #define DRIVER_NAME "portman"
100032 @@ -85,7 +86,7 @@ struct portman {
100033 struct pardevice *pardev;
100034 int pardev_claimed;
100035
100036 - int open_count;
100037 + local_t open_count;
100038 int mode[PORTMAN_NUM_INPUT_PORTS];
100039 struct snd_rawmidi_substream *midi_input[PORTMAN_NUM_INPUT_PORTS];
100040 };
100041 diff --git a/sound/firewire/amdtp.c b/sound/firewire/amdtp.c
100042 index ea995af..f1bfa37 100644
100043 --- a/sound/firewire/amdtp.c
100044 +++ b/sound/firewire/amdtp.c
100045 @@ -389,7 +389,7 @@ static void queue_out_packet(struct amdtp_out_stream *s, unsigned int cycle)
100046 ptr = s->pcm_buffer_pointer + data_blocks;
100047 if (ptr >= pcm->runtime->buffer_size)
100048 ptr -= pcm->runtime->buffer_size;
100049 - ACCESS_ONCE(s->pcm_buffer_pointer) = ptr;
100050 + ACCESS_ONCE_RW(s->pcm_buffer_pointer) = ptr;
100051
100052 s->pcm_period_pointer += data_blocks;
100053 if (s->pcm_period_pointer >= pcm->runtime->period_size) {
100054 @@ -557,7 +557,7 @@ EXPORT_SYMBOL(amdtp_out_stream_pcm_pointer);
100055 */
100056 void amdtp_out_stream_update(struct amdtp_out_stream *s)
100057 {
100058 - ACCESS_ONCE(s->source_node_id_field) =
100059 + ACCESS_ONCE_RW(s->source_node_id_field) =
100060 (fw_parent_device(s->unit)->card->node_id & 0x3f) << 24;
100061 }
100062 EXPORT_SYMBOL(amdtp_out_stream_update);
100063 diff --git a/sound/firewire/amdtp.h b/sound/firewire/amdtp.h
100064 index f6103d6..4843fbf 100644
100065 --- a/sound/firewire/amdtp.h
100066 +++ b/sound/firewire/amdtp.h
100067 @@ -138,7 +138,7 @@ static inline bool amdtp_out_streaming_error(struct amdtp_out_stream *s)
100068 static inline void amdtp_out_stream_pcm_trigger(struct amdtp_out_stream *s,
100069 struct snd_pcm_substream *pcm)
100070 {
100071 - ACCESS_ONCE(s->pcm) = pcm;
100072 + ACCESS_ONCE_RW(s->pcm) = pcm;
100073 }
100074
100075 static inline bool cip_sfc_is_base_44100(enum cip_sfc sfc)
100076 diff --git a/sound/firewire/isight.c b/sound/firewire/isight.c
100077 index 58a5afe..af5bd64 100644
100078 --- a/sound/firewire/isight.c
100079 +++ b/sound/firewire/isight.c
100080 @@ -96,7 +96,7 @@ static void isight_update_pointers(struct isight *isight, unsigned int count)
100081 ptr += count;
100082 if (ptr >= runtime->buffer_size)
100083 ptr -= runtime->buffer_size;
100084 - ACCESS_ONCE(isight->buffer_pointer) = ptr;
100085 + ACCESS_ONCE_RW(isight->buffer_pointer) = ptr;
100086
100087 isight->period_counter += count;
100088 if (isight->period_counter >= runtime->period_size) {
100089 @@ -307,7 +307,7 @@ static int isight_hw_params(struct snd_pcm_substream *substream,
100090 if (err < 0)
100091 return err;
100092
100093 - ACCESS_ONCE(isight->pcm_active) = true;
100094 + ACCESS_ONCE_RW(isight->pcm_active) = true;
100095
100096 return 0;
100097 }
100098 @@ -340,7 +340,7 @@ static int isight_hw_free(struct snd_pcm_substream *substream)
100099 {
100100 struct isight *isight = substream->private_data;
100101
100102 - ACCESS_ONCE(isight->pcm_active) = false;
100103 + ACCESS_ONCE_RW(isight->pcm_active) = false;
100104
100105 mutex_lock(&isight->mutex);
100106 isight_stop_streaming(isight);
100107 @@ -433,10 +433,10 @@ static int isight_trigger(struct snd_pcm_substream *substream, int cmd)
100108
100109 switch (cmd) {
100110 case SNDRV_PCM_TRIGGER_START:
100111 - ACCESS_ONCE(isight->pcm_running) = true;
100112 + ACCESS_ONCE_RW(isight->pcm_running) = true;
100113 break;
100114 case SNDRV_PCM_TRIGGER_STOP:
100115 - ACCESS_ONCE(isight->pcm_running) = false;
100116 + ACCESS_ONCE_RW(isight->pcm_running) = false;
100117 break;
100118 default:
100119 return -EINVAL;
100120 diff --git a/sound/firewire/scs1x.c b/sound/firewire/scs1x.c
100121 index 505fc81..62e569e 100644
100122 --- a/sound/firewire/scs1x.c
100123 +++ b/sound/firewire/scs1x.c
100124 @@ -74,7 +74,7 @@ static void scs_output_trigger(struct snd_rawmidi_substream *stream, int up)
100125 {
100126 struct scs *scs = stream->rmidi->private_data;
100127
100128 - ACCESS_ONCE(scs->output) = up ? stream : NULL;
100129 + ACCESS_ONCE_RW(scs->output) = up ? stream : NULL;
100130 if (up) {
100131 scs->output_idle = false;
100132 tasklet_schedule(&scs->tasklet);
100133 @@ -257,7 +257,7 @@ static void scs_input_trigger(struct snd_rawmidi_substream *stream, int up)
100134 {
100135 struct scs *scs = stream->rmidi->private_data;
100136
100137 - ACCESS_ONCE(scs->input) = up ? stream : NULL;
100138 + ACCESS_ONCE_RW(scs->input) = up ? stream : NULL;
100139 }
100140
100141 static void scs_input_escaped_byte(struct snd_rawmidi_substream *stream,
100142 @@ -469,8 +469,8 @@ static void scs_remove(struct fw_unit *unit)
100143
100144 snd_card_disconnect(scs->card);
100145
100146 - ACCESS_ONCE(scs->output) = NULL;
100147 - ACCESS_ONCE(scs->input) = NULL;
100148 + ACCESS_ONCE_RW(scs->output) = NULL;
100149 + ACCESS_ONCE_RW(scs->input) = NULL;
100150
100151 wait_event(scs->idle_wait, scs->output_idle);
100152
100153 diff --git a/sound/oss/sb_audio.c b/sound/oss/sb_audio.c
100154 index 048439a..3be9f6f 100644
100155 --- a/sound/oss/sb_audio.c
100156 +++ b/sound/oss/sb_audio.c
100157 @@ -904,7 +904,7 @@ sb16_copy_from_user(int dev,
100158 buf16 = (signed short *)(localbuf + localoffs);
100159 while (c)
100160 {
100161 - locallen = (c >= LBUFCOPYSIZE ? LBUFCOPYSIZE : c);
100162 + locallen = ((unsigned)c >= LBUFCOPYSIZE ? LBUFCOPYSIZE : c);
100163 if (copy_from_user(lbuf8,
100164 userbuf+useroffs + p,
100165 locallen))
100166 diff --git a/sound/oss/swarm_cs4297a.c b/sound/oss/swarm_cs4297a.c
100167 index 7d8803a..559f8d0 100644
100168 --- a/sound/oss/swarm_cs4297a.c
100169 +++ b/sound/oss/swarm_cs4297a.c
100170 @@ -2621,7 +2621,6 @@ static int __init cs4297a_init(void)
100171 {
100172 struct cs4297a_state *s;
100173 u32 pwr, id;
100174 - mm_segment_t fs;
100175 int rval;
100176 #ifndef CONFIG_BCM_CS4297A_CSWARM
100177 u64 cfg;
100178 @@ -2711,22 +2710,23 @@ static int __init cs4297a_init(void)
100179 if (!rval) {
100180 char *sb1250_duart_present;
100181
100182 +#if 0
100183 + mm_segment_t fs;
100184 fs = get_fs();
100185 set_fs(KERNEL_DS);
100186 -#if 0
100187 val = SOUND_MASK_LINE;
100188 mixer_ioctl(s, SOUND_MIXER_WRITE_RECSRC, (unsigned long) &val);
100189 for (i = 0; i < ARRAY_SIZE(initvol); i++) {
100190 val = initvol[i].vol;
100191 mixer_ioctl(s, initvol[i].mixch, (unsigned long) &val);
100192 }
100193 + set_fs(fs);
100194 // cs4297a_write_ac97(s, 0x18, 0x0808);
100195 #else
100196 // cs4297a_write_ac97(s, 0x5e, 0x180);
100197 cs4297a_write_ac97(s, 0x02, 0x0808);
100198 cs4297a_write_ac97(s, 0x18, 0x0808);
100199 #endif
100200 - set_fs(fs);
100201
100202 list_add(&s->list, &cs4297a_devs);
100203
100204 diff --git a/sound/pci/hda/hda_codec.c b/sound/pci/hda/hda_codec.c
100205 index e938a68..2a728ad 100644
100206 --- a/sound/pci/hda/hda_codec.c
100207 +++ b/sound/pci/hda/hda_codec.c
100208 @@ -976,14 +976,10 @@ find_codec_preset(struct hda_codec *codec)
100209 mutex_unlock(&preset_mutex);
100210
100211 if (mod_requested < HDA_MODREQ_MAX_COUNT) {
100212 - char name[32];
100213 if (!mod_requested)
100214 - snprintf(name, sizeof(name), "snd-hda-codec-id:%08x",
100215 - codec->vendor_id);
100216 + request_module("snd-hda-codec-id:%08x", codec->vendor_id);
100217 else
100218 - snprintf(name, sizeof(name), "snd-hda-codec-id:%04x*",
100219 - (codec->vendor_id >> 16) & 0xffff);
100220 - request_module(name);
100221 + request_module("snd-hda-codec-id:%04x*", (codec->vendor_id >> 16) & 0xffff);
100222 mod_requested++;
100223 goto again;
100224 }
100225 diff --git a/sound/pci/ymfpci/ymfpci.h b/sound/pci/ymfpci/ymfpci.h
100226 index 4631a23..001ae57 100644
100227 --- a/sound/pci/ymfpci/ymfpci.h
100228 +++ b/sound/pci/ymfpci/ymfpci.h
100229 @@ -358,7 +358,7 @@ struct snd_ymfpci {
100230 spinlock_t reg_lock;
100231 spinlock_t voice_lock;
100232 wait_queue_head_t interrupt_sleep;
100233 - atomic_t interrupt_sleep_count;
100234 + atomic_unchecked_t interrupt_sleep_count;
100235 struct snd_info_entry *proc_entry;
100236 const struct firmware *dsp_microcode;
100237 const struct firmware *controller_microcode;
100238 diff --git a/sound/pci/ymfpci/ymfpci_main.c b/sound/pci/ymfpci/ymfpci_main.c
100239 index d591c15..8cb8f94 100644
100240 --- a/sound/pci/ymfpci/ymfpci_main.c
100241 +++ b/sound/pci/ymfpci/ymfpci_main.c
100242 @@ -202,8 +202,8 @@ static void snd_ymfpci_hw_stop(struct snd_ymfpci *chip)
100243 if ((snd_ymfpci_readl(chip, YDSXGR_STATUS) & 2) == 0)
100244 break;
100245 }
100246 - if (atomic_read(&chip->interrupt_sleep_count)) {
100247 - atomic_set(&chip->interrupt_sleep_count, 0);
100248 + if (atomic_read_unchecked(&chip->interrupt_sleep_count)) {
100249 + atomic_set_unchecked(&chip->interrupt_sleep_count, 0);
100250 wake_up(&chip->interrupt_sleep);
100251 }
100252 __end:
100253 @@ -787,7 +787,7 @@ static void snd_ymfpci_irq_wait(struct snd_ymfpci *chip)
100254 continue;
100255 init_waitqueue_entry(&wait, current);
100256 add_wait_queue(&chip->interrupt_sleep, &wait);
100257 - atomic_inc(&chip->interrupt_sleep_count);
100258 + atomic_inc_unchecked(&chip->interrupt_sleep_count);
100259 schedule_timeout_uninterruptible(msecs_to_jiffies(50));
100260 remove_wait_queue(&chip->interrupt_sleep, &wait);
100261 }
100262 @@ -825,8 +825,8 @@ static irqreturn_t snd_ymfpci_interrupt(int irq, void *dev_id)
100263 snd_ymfpci_writel(chip, YDSXGR_MODE, mode);
100264 spin_unlock(&chip->reg_lock);
100265
100266 - if (atomic_read(&chip->interrupt_sleep_count)) {
100267 - atomic_set(&chip->interrupt_sleep_count, 0);
100268 + if (atomic_read_unchecked(&chip->interrupt_sleep_count)) {
100269 + atomic_set_unchecked(&chip->interrupt_sleep_count, 0);
100270 wake_up(&chip->interrupt_sleep);
100271 }
100272 }
100273 @@ -2421,7 +2421,7 @@ int snd_ymfpci_create(struct snd_card *card,
100274 spin_lock_init(&chip->reg_lock);
100275 spin_lock_init(&chip->voice_lock);
100276 init_waitqueue_head(&chip->interrupt_sleep);
100277 - atomic_set(&chip->interrupt_sleep_count, 0);
100278 + atomic_set_unchecked(&chip->interrupt_sleep_count, 0);
100279 chip->card = card;
100280 chip->pci = pci;
100281 chip->irq = -1;
100282 diff --git a/sound/soc/fsl/fsl_ssi.c b/sound/soc/fsl/fsl_ssi.c
100283 index 6b81d0c..031c056 100644
100284 --- a/sound/soc/fsl/fsl_ssi.c
100285 +++ b/sound/soc/fsl/fsl_ssi.c
100286 @@ -864,7 +864,7 @@ static int fsl_ssi_probe(struct platform_device *pdev)
100287 {
100288 struct fsl_ssi_private *ssi_private;
100289 int ret = 0;
100290 - struct device_attribute *dev_attr = NULL;
100291 + device_attribute_no_const *dev_attr = NULL;
100292 struct device_node *np = pdev->dev.of_node;
100293 const char *p, *sprop;
100294 const uint32_t *iprop;
100295 diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
100296 index 1a38be0..66809d1 100644
100297 --- a/sound/soc/soc-core.c
100298 +++ b/sound/soc/soc-core.c
100299 @@ -2248,8 +2248,10 @@ int snd_soc_set_ac97_ops_of_reset(struct snd_ac97_bus_ops *ops,
100300 if (ret)
100301 return ret;
100302
100303 - ops->warm_reset = snd_soc_ac97_warm_reset;
100304 - ops->reset = snd_soc_ac97_reset;
100305 + pax_open_kernel();
100306 + *(void **)&ops->warm_reset = snd_soc_ac97_warm_reset;
100307 + *(void **)&ops->reset = snd_soc_ac97_reset;
100308 + pax_close_kernel();
100309
100310 snd_ac97_rst_cfg = cfg;
100311 return 0;
100312 diff --git a/tools/gcc/.gitignore b/tools/gcc/.gitignore
100313 new file mode 100644
100314 index 0000000..50f2f2f
100315 --- /dev/null
100316 +++ b/tools/gcc/.gitignore
100317 @@ -0,0 +1 @@
100318 +size_overflow_hash.h
100319 diff --git a/tools/gcc/Makefile b/tools/gcc/Makefile
100320 new file mode 100644
100321 index 0000000..144dbee
100322 --- /dev/null
100323 +++ b/tools/gcc/Makefile
100324 @@ -0,0 +1,45 @@
100325 +#CC := gcc
100326 +#PLUGIN_SOURCE_FILES := pax_plugin.c
100327 +#PLUGIN_OBJECT_FILES := $(patsubst %.c,%.o,$(PLUGIN_SOURCE_FILES))
100328 +GCCPLUGINS_DIR := $(shell $(CC) -print-file-name=plugin)
100329 +#CFLAGS += -I$(GCCPLUGINS_DIR)/include -fPIC -O2 -Wall -W -std=gnu99
100330 +
100331 +ifeq ($(PLUGINCC),$(HOSTCC))
100332 +HOSTLIBS := hostlibs
100333 +HOST_EXTRACFLAGS += -I$(GCCPLUGINS_DIR)/include -std=gnu99 -ggdb
100334 +else
100335 +HOSTLIBS := hostcxxlibs
100336 +HOST_EXTRACXXFLAGS += -I$(GCCPLUGINS_DIR)/include -std=gnu++98 -ggdb -Wno-unused-parameter
100337 +endif
100338 +
100339 +$(HOSTLIBS)-$(CONFIG_PAX_CONSTIFY_PLUGIN) := constify_plugin.so
100340 +$(HOSTLIBS)-$(CONFIG_PAX_MEMORY_STACKLEAK) += stackleak_plugin.so
100341 +$(HOSTLIBS)-$(CONFIG_KALLOCSTAT_PLUGIN) += kallocstat_plugin.so
100342 +$(HOSTLIBS)-$(CONFIG_PAX_KERNEXEC_PLUGIN) += kernexec_plugin.so
100343 +$(HOSTLIBS)-$(CONFIG_CHECKER_PLUGIN) += checker_plugin.so
100344 +$(HOSTLIBS)-y += colorize_plugin.so
100345 +$(HOSTLIBS)-$(CONFIG_PAX_SIZE_OVERFLOW) += size_overflow_plugin.so
100346 +$(HOSTLIBS)-$(CONFIG_PAX_LATENT_ENTROPY) += latent_entropy_plugin.so
100347 +$(HOSTLIBS)-$(CONFIG_PAX_MEMORY_STRUCTLEAK) += structleak_plugin.so
100348 +
100349 +always := $($(HOSTLIBS)-y)
100350 +
100351 +constify_plugin-objs := constify_plugin.o
100352 +stackleak_plugin-objs := stackleak_plugin.o
100353 +kallocstat_plugin-objs := kallocstat_plugin.o
100354 +kernexec_plugin-objs := kernexec_plugin.o
100355 +checker_plugin-objs := checker_plugin.o
100356 +colorize_plugin-objs := colorize_plugin.o
100357 +size_overflow_plugin-objs := size_overflow_plugin.o
100358 +latent_entropy_plugin-objs := latent_entropy_plugin.o
100359 +structleak_plugin-objs := structleak_plugin.o
100360 +
100361 +$(obj)/size_overflow_plugin.o: $(objtree)/$(obj)/size_overflow_hash.h
100362 +
100363 +quiet_cmd_build_size_overflow_hash = GENHASH $@
100364 + cmd_build_size_overflow_hash = \
100365 + $(CONFIG_SHELL) $(srctree)/$(src)/generate_size_overflow_hash.sh -d $< -o $@
100366 +$(objtree)/$(obj)/size_overflow_hash.h: $(src)/size_overflow_hash.data FORCE
100367 + $(call if_changed,build_size_overflow_hash)
100368 +
100369 +targets += size_overflow_hash.h
100370 diff --git a/tools/gcc/checker_plugin.c b/tools/gcc/checker_plugin.c
100371 new file mode 100644
100372 index 0000000..22f03c0
100373 --- /dev/null
100374 +++ b/tools/gcc/checker_plugin.c
100375 @@ -0,0 +1,172 @@
100376 +/*
100377 + * Copyright 2011 by the PaX Team <pageexec@freemail.hu>
100378 + * Licensed under the GPL v2
100379 + *
100380 + * Note: the choice of the license means that the compilation process is
100381 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
100382 + * but for the kernel it doesn't matter since it doesn't link against
100383 + * any of the gcc libraries
100384 + *
100385 + * gcc plugin to implement various sparse (source code checker) features
100386 + *
100387 + * TODO:
100388 + * - define separate __iomem, __percpu and __rcu address spaces (lots of code to patch)
100389 + *
100390 + * BUGS:
100391 + * - none known
100392 + */
100393 +#include "gcc-plugin.h"
100394 +#include "config.h"
100395 +#include "system.h"
100396 +#include "coretypes.h"
100397 +#include "tree.h"
100398 +#include "tree-pass.h"
100399 +#include "flags.h"
100400 +#include "intl.h"
100401 +#include "toplev.h"
100402 +#include "plugin.h"
100403 +//#include "expr.h" where are you...
100404 +#include "diagnostic.h"
100405 +#include "plugin-version.h"
100406 +#include "tm.h"
100407 +#include "function.h"
100408 +#include "basic-block.h"
100409 +#include "gimple.h"
100410 +#include "rtl.h"
100411 +#include "emit-rtl.h"
100412 +#include "tree-flow.h"
100413 +#include "target.h"
100414 +
100415 +extern void c_register_addr_space (const char *str, addr_space_t as);
100416 +extern enum machine_mode default_addr_space_pointer_mode (addr_space_t);
100417 +extern enum machine_mode default_addr_space_address_mode (addr_space_t);
100418 +extern bool default_addr_space_valid_pointer_mode(enum machine_mode mode, addr_space_t as);
100419 +extern bool default_addr_space_legitimate_address_p(enum machine_mode mode, rtx mem, bool strict, addr_space_t as);
100420 +extern rtx default_addr_space_legitimize_address(rtx x, rtx oldx, enum machine_mode mode, addr_space_t as);
100421 +
100422 +extern void print_gimple_stmt(FILE *, gimple, int, int);
100423 +extern rtx emit_move_insn(rtx x, rtx y);
100424 +
100425 +int plugin_is_GPL_compatible;
100426 +
100427 +static struct plugin_info checker_plugin_info = {
100428 + .version = "201111150100",
100429 + .help = NULL,
100430 +};
100431 +
100432 +#define ADDR_SPACE_KERNEL 0
100433 +#define ADDR_SPACE_FORCE_KERNEL 1
100434 +#define ADDR_SPACE_USER 2
100435 +#define ADDR_SPACE_FORCE_USER 3
100436 +#define ADDR_SPACE_IOMEM 0
100437 +#define ADDR_SPACE_FORCE_IOMEM 0
100438 +#define ADDR_SPACE_PERCPU 0
100439 +#define ADDR_SPACE_FORCE_PERCPU 0
100440 +#define ADDR_SPACE_RCU 0
100441 +#define ADDR_SPACE_FORCE_RCU 0
100442 +
100443 +static enum machine_mode checker_addr_space_pointer_mode(addr_space_t addrspace)
100444 +{
100445 + return default_addr_space_pointer_mode(ADDR_SPACE_GENERIC);
100446 +}
100447 +
100448 +static enum machine_mode checker_addr_space_address_mode(addr_space_t addrspace)
100449 +{
100450 + return default_addr_space_address_mode(ADDR_SPACE_GENERIC);
100451 +}
100452 +
100453 +static bool checker_addr_space_valid_pointer_mode(enum machine_mode mode, addr_space_t as)
100454 +{
100455 + return default_addr_space_valid_pointer_mode(mode, as);
100456 +}
100457 +
100458 +static bool checker_addr_space_legitimate_address_p(enum machine_mode mode, rtx mem, bool strict, addr_space_t as)
100459 +{
100460 + return default_addr_space_legitimate_address_p(mode, mem, strict, ADDR_SPACE_GENERIC);
100461 +}
100462 +
100463 +static rtx checker_addr_space_legitimize_address(rtx x, rtx oldx, enum machine_mode mode, addr_space_t as)
100464 +{
100465 + return default_addr_space_legitimize_address(x, oldx, mode, as);
100466 +}
100467 +
100468 +static bool checker_addr_space_subset_p(addr_space_t subset, addr_space_t superset)
100469 +{
100470 + if (subset == ADDR_SPACE_FORCE_KERNEL && superset == ADDR_SPACE_KERNEL)
100471 + return true;
100472 +
100473 + if (subset == ADDR_SPACE_FORCE_USER && superset == ADDR_SPACE_USER)
100474 + return true;
100475 +
100476 + if (subset == ADDR_SPACE_FORCE_IOMEM && superset == ADDR_SPACE_IOMEM)
100477 + return true;
100478 +
100479 + if (subset == ADDR_SPACE_KERNEL && superset == ADDR_SPACE_FORCE_USER)
100480 + return true;
100481 +
100482 + if (subset == ADDR_SPACE_KERNEL && superset == ADDR_SPACE_FORCE_IOMEM)
100483 + return true;
100484 +
100485 + if (subset == ADDR_SPACE_USER && superset == ADDR_SPACE_FORCE_KERNEL)
100486 + return true;
100487 +
100488 + if (subset == ADDR_SPACE_IOMEM && superset == ADDR_SPACE_FORCE_KERNEL)
100489 + return true;
100490 +
100491 + return subset == superset;
100492 +}
100493 +
100494 +static rtx checker_addr_space_convert(rtx op, tree from_type, tree to_type)
100495 +{
100496 +// addr_space_t from_as = TYPE_ADDR_SPACE(TREE_TYPE(from_type));
100497 +// addr_space_t to_as = TYPE_ADDR_SPACE(TREE_TYPE(to_type));
100498 +
100499 + return op;
100500 +}
100501 +
100502 +static void register_checker_address_spaces(void *event_data, void *data)
100503 +{
100504 + c_register_addr_space("__kernel", ADDR_SPACE_KERNEL);
100505 + c_register_addr_space("__force_kernel", ADDR_SPACE_FORCE_KERNEL);
100506 + c_register_addr_space("__user", ADDR_SPACE_USER);
100507 + c_register_addr_space("__force_user", ADDR_SPACE_FORCE_USER);
100508 +// c_register_addr_space("__iomem", ADDR_SPACE_IOMEM);
100509 +// c_register_addr_space("__force_iomem", ADDR_SPACE_FORCE_IOMEM);
100510 +// c_register_addr_space("__percpu", ADDR_SPACE_PERCPU);
100511 +// c_register_addr_space("__force_percpu", ADDR_SPACE_FORCE_PERCPU);
100512 +// c_register_addr_space("__rcu", ADDR_SPACE_RCU);
100513 +// c_register_addr_space("__force_rcu", ADDR_SPACE_FORCE_RCU);
100514 +
100515 + targetm.addr_space.pointer_mode = checker_addr_space_pointer_mode;
100516 + targetm.addr_space.address_mode = checker_addr_space_address_mode;
100517 + targetm.addr_space.valid_pointer_mode = checker_addr_space_valid_pointer_mode;
100518 + targetm.addr_space.legitimate_address_p = checker_addr_space_legitimate_address_p;
100519 +// targetm.addr_space.legitimize_address = checker_addr_space_legitimize_address;
100520 + targetm.addr_space.subset_p = checker_addr_space_subset_p;
100521 + targetm.addr_space.convert = checker_addr_space_convert;
100522 +}
100523 +
100524 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
100525 +{
100526 + const char * const plugin_name = plugin_info->base_name;
100527 + const int argc = plugin_info->argc;
100528 + const struct plugin_argument * const argv = plugin_info->argv;
100529 + int i;
100530 +
100531 + if (!plugin_default_version_check(version, &gcc_version)) {
100532 + error(G_("incompatible gcc/plugin versions"));
100533 + return 1;
100534 + }
100535 +
100536 + register_callback(plugin_name, PLUGIN_INFO, NULL, &checker_plugin_info);
100537 +
100538 + for (i = 0; i < argc; ++i)
100539 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
100540 +
100541 + if (TARGET_64BIT == 0)
100542 + return 0;
100543 +
100544 + register_callback(plugin_name, PLUGIN_PRAGMAS, register_checker_address_spaces, NULL);
100545 +
100546 + return 0;
100547 +}
100548 diff --git a/tools/gcc/colorize_plugin.c b/tools/gcc/colorize_plugin.c
100549 new file mode 100644
100550 index 0000000..414fe5e
100551 --- /dev/null
100552 +++ b/tools/gcc/colorize_plugin.c
100553 @@ -0,0 +1,151 @@
100554 +/*
100555 + * Copyright 2012-2013 by PaX Team <pageexec@freemail.hu>
100556 + * Licensed under the GPL v2
100557 + *
100558 + * Note: the choice of the license means that the compilation process is
100559 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
100560 + * but for the kernel it doesn't matter since it doesn't link against
100561 + * any of the gcc libraries
100562 + *
100563 + * gcc plugin to colorize diagnostic output
100564 + *
100565 + */
100566 +
100567 +#include "gcc-plugin.h"
100568 +#include "config.h"
100569 +#include "system.h"
100570 +#include "coretypes.h"
100571 +#include "tree.h"
100572 +#include "tree-pass.h"
100573 +#include "flags.h"
100574 +#include "intl.h"
100575 +#include "toplev.h"
100576 +#include "plugin.h"
100577 +#include "diagnostic.h"
100578 +#include "plugin-version.h"
100579 +#include "tm.h"
100580 +
100581 +int plugin_is_GPL_compatible;
100582 +
100583 +static struct plugin_info colorize_plugin_info = {
100584 + .version = "201302112000",
100585 + .help = NULL,
100586 +};
100587 +
100588 +#define GREEN "\033[32m\033[2m"
100589 +#define LIGHTGREEN "\033[32m\033[1m"
100590 +#define YELLOW "\033[33m\033[2m"
100591 +#define LIGHTYELLOW "\033[33m\033[1m"
100592 +#define RED "\033[31m\033[2m"
100593 +#define LIGHTRED "\033[31m\033[1m"
100594 +#define BLUE "\033[34m\033[2m"
100595 +#define LIGHTBLUE "\033[34m\033[1m"
100596 +#define BRIGHT "\033[m\033[1m"
100597 +#define NORMAL "\033[m"
100598 +
100599 +static diagnostic_starter_fn old_starter;
100600 +static diagnostic_finalizer_fn old_finalizer;
100601 +
100602 +static void start_colorize(diagnostic_context *context, diagnostic_info *diagnostic)
100603 +{
100604 + const char *color;
100605 + char *newprefix;
100606 +
100607 + switch (diagnostic->kind) {
100608 + case DK_NOTE:
100609 + color = LIGHTBLUE;
100610 + break;
100611 +
100612 + case DK_PEDWARN:
100613 + case DK_WARNING:
100614 + color = LIGHTYELLOW;
100615 + break;
100616 +
100617 + case DK_ERROR:
100618 + case DK_FATAL:
100619 + case DK_ICE:
100620 + case DK_PERMERROR:
100621 + case DK_SORRY:
100622 + color = LIGHTRED;
100623 + break;
100624 +
100625 + default:
100626 + color = NORMAL;
100627 + }
100628 +
100629 + old_starter(context, diagnostic);
100630 + if (-1 == asprintf(&newprefix, "%s%s" NORMAL, color, context->printer->prefix))
100631 + return;
100632 + pp_destroy_prefix(context->printer);
100633 + pp_set_prefix(context->printer, newprefix);
100634 +}
100635 +
100636 +static void finalize_colorize(diagnostic_context *context, diagnostic_info *diagnostic)
100637 +{
100638 + old_finalizer(context, diagnostic);
100639 +}
100640 +
100641 +static void colorize_arm(void)
100642 +{
100643 + old_starter = diagnostic_starter(global_dc);
100644 + old_finalizer = diagnostic_finalizer(global_dc);
100645 +
100646 + diagnostic_starter(global_dc) = start_colorize;
100647 + diagnostic_finalizer(global_dc) = finalize_colorize;
100648 +}
100649 +
100650 +static unsigned int execute_colorize_rearm(void)
100651 +{
100652 + if (diagnostic_starter(global_dc) == start_colorize)
100653 + return 0;
100654 +
100655 + colorize_arm();
100656 + return 0;
100657 +}
100658 +
100659 +struct simple_ipa_opt_pass pass_ipa_colorize_rearm = {
100660 + .pass = {
100661 + .type = SIMPLE_IPA_PASS,
100662 + .name = "colorize_rearm",
100663 +#if BUILDING_GCC_VERSION >= 4008
100664 + .optinfo_flags = OPTGROUP_NONE,
100665 +#endif
100666 + .gate = NULL,
100667 + .execute = execute_colorize_rearm,
100668 + .sub = NULL,
100669 + .next = NULL,
100670 + .static_pass_number = 0,
100671 + .tv_id = TV_NONE,
100672 + .properties_required = 0,
100673 + .properties_provided = 0,
100674 + .properties_destroyed = 0,
100675 + .todo_flags_start = 0,
100676 + .todo_flags_finish = 0
100677 + }
100678 +};
100679 +
100680 +static void colorize_start_unit(void *gcc_data, void *user_data)
100681 +{
100682 + colorize_arm();
100683 +}
100684 +
100685 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
100686 +{
100687 + const char * const plugin_name = plugin_info->base_name;
100688 + struct register_pass_info colorize_rearm_pass_info = {
100689 + .pass = &pass_ipa_colorize_rearm.pass,
100690 + .reference_pass_name = "*free_lang_data",
100691 + .ref_pass_instance_number = 1,
100692 + .pos_op = PASS_POS_INSERT_AFTER
100693 + };
100694 +
100695 + if (!plugin_default_version_check(version, &gcc_version)) {
100696 + error(G_("incompatible gcc/plugin versions"));
100697 + return 1;
100698 + }
100699 +
100700 + register_callback(plugin_name, PLUGIN_INFO, NULL, &colorize_plugin_info);
100701 + register_callback(plugin_name, PLUGIN_START_UNIT, &colorize_start_unit, NULL);
100702 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &colorize_rearm_pass_info);
100703 + return 0;
100704 +}
100705 diff --git a/tools/gcc/constify_plugin.c b/tools/gcc/constify_plugin.c
100706 new file mode 100644
100707 index 0000000..ba59e50
100708 --- /dev/null
100709 +++ b/tools/gcc/constify_plugin.c
100710 @@ -0,0 +1,558 @@
100711 +/*
100712 + * Copyright 2011 by Emese Revfy <re.emese@gmail.com>
100713 + * Copyright 2011-2013 by PaX Team <pageexec@freemail.hu>
100714 + * Licensed under the GPL v2, or (at your option) v3
100715 + *
100716 + * This gcc plugin constifies all structures which contain only function pointers or are explicitly marked for constification.
100717 + *
100718 + * Homepage:
100719 + * http://www.grsecurity.net/~ephox/const_plugin/
100720 + *
100721 + * Usage:
100722 + * $ gcc -I`gcc -print-file-name=plugin`/include -fPIC -shared -O2 -o constify_plugin.so constify_plugin.c
100723 + * $ gcc -fplugin=constify_plugin.so test.c -O2
100724 + */
100725 +
100726 +#include "gcc-plugin.h"
100727 +#include "config.h"
100728 +#include "system.h"
100729 +#include "coretypes.h"
100730 +#include "tree.h"
100731 +#include "tree-pass.h"
100732 +#include "flags.h"
100733 +#include "intl.h"
100734 +#include "toplev.h"
100735 +#include "plugin.h"
100736 +#include "diagnostic.h"
100737 +#include "plugin-version.h"
100738 +#include "tm.h"
100739 +#include "function.h"
100740 +#include "basic-block.h"
100741 +#include "gimple.h"
100742 +#include "rtl.h"
100743 +#include "emit-rtl.h"
100744 +#include "tree-flow.h"
100745 +#include "target.h"
100746 +#include "langhooks.h"
100747 +
100748 +// should come from c-tree.h if only it were installed for gcc 4.5...
100749 +#define C_TYPE_FIELDS_READONLY(TYPE) TREE_LANG_FLAG_1(TYPE)
100750 +
100751 +// unused type flag in all versions 4.5-4.8
100752 +#define TYPE_CONSTIFY_VISITED(TYPE) TYPE_LANG_FLAG_4(TYPE)
100753 +
100754 +int plugin_is_GPL_compatible;
100755 +
100756 +static struct plugin_info const_plugin_info = {
100757 + .version = "201312032345",
100758 + .help = "no-constify\tturn off constification\n",
100759 +};
100760 +
100761 +typedef struct {
100762 + bool has_fptr_field;
100763 + bool has_writable_field;
100764 + bool has_do_const_field;
100765 + bool has_no_const_field;
100766 +} constify_info;
100767 +
100768 +static const_tree get_field_type(const_tree field)
100769 +{
100770 + return strip_array_types(TREE_TYPE(field));
100771 +}
100772 +
100773 +static bool is_fptr(const_tree field)
100774 +{
100775 + const_tree ptr = get_field_type(field);
100776 +
100777 + if (TREE_CODE(ptr) != POINTER_TYPE)
100778 + return false;
100779 +
100780 + return TREE_CODE(TREE_TYPE(ptr)) == FUNCTION_TYPE;
100781 +}
100782 +
100783 +/*
100784 + * determine whether the given structure type meets the requirements for automatic constification,
100785 + * including the constification attributes on nested structure types
100786 + */
100787 +static void constifiable(const_tree node, constify_info *cinfo)
100788 +{
100789 + const_tree field;
100790 +
100791 + gcc_assert(TREE_CODE(node) == RECORD_TYPE || TREE_CODE(node) == UNION_TYPE);
100792 +
100793 + // e.g., pointer to structure fields while still constructing the structure type
100794 + if (TYPE_FIELDS(node) == NULL_TREE)
100795 + return;
100796 +
100797 + for (field = TYPE_FIELDS(node); field; field = TREE_CHAIN(field)) {
100798 + const_tree type = get_field_type(field);
100799 + enum tree_code code = TREE_CODE(type);
100800 +
100801 + if (node == type)
100802 + continue;
100803 +
100804 + if (is_fptr(field))
100805 + cinfo->has_fptr_field = true;
100806 + else if (!TREE_READONLY(field))
100807 + cinfo->has_writable_field = true;
100808 +
100809 + if (code == RECORD_TYPE || code == UNION_TYPE) {
100810 + if (lookup_attribute("do_const", TYPE_ATTRIBUTES(type)))
100811 + cinfo->has_do_const_field = true;
100812 + else if (lookup_attribute("no_const", TYPE_ATTRIBUTES(type)))
100813 + cinfo->has_no_const_field = true;
100814 + else
100815 + constifiable(type, cinfo);
100816 + }
100817 + }
100818 +}
100819 +
100820 +static bool constified(const_tree node)
100821 +{
100822 + constify_info cinfo = {
100823 + .has_fptr_field = false,
100824 + .has_writable_field = false,
100825 + .has_do_const_field = false,
100826 + .has_no_const_field = false
100827 + };
100828 +
100829 + gcc_assert(TREE_CODE(node) == RECORD_TYPE || TREE_CODE(node) == UNION_TYPE);
100830 +
100831 + if (lookup_attribute("no_const", TYPE_ATTRIBUTES(node))) {
100832 + gcc_assert(!TYPE_READONLY(node));
100833 + return false;
100834 + }
100835 +
100836 + if (lookup_attribute("do_const", TYPE_ATTRIBUTES(node))) {
100837 + gcc_assert(TYPE_READONLY(node));
100838 + return true;
100839 + }
100840 +
100841 + constifiable(node, &cinfo);
100842 + if ((!cinfo.has_fptr_field || cinfo.has_writable_field) && !cinfo.has_do_const_field)
100843 + return false;
100844 +
100845 + return TYPE_READONLY(node);
100846 +}
100847 +
100848 +static void deconstify_tree(tree node);
100849 +
100850 +static void deconstify_type(tree type)
100851 +{
100852 + tree field;
100853 +
100854 + gcc_assert(TREE_CODE(type) == RECORD_TYPE || TREE_CODE(type) == UNION_TYPE);
100855 +
100856 + for (field = TYPE_FIELDS(type); field; field = TREE_CHAIN(field)) {
100857 + const_tree fieldtype = get_field_type(field);
100858 +
100859 + // special case handling of simple ptr-to-same-array-type members
100860 + if (TREE_CODE(TREE_TYPE(field)) == POINTER_TYPE) {
100861 + const_tree ptrtype = TREE_TYPE(TREE_TYPE(field));
100862 +
100863 + if (TREE_CODE(ptrtype) != RECORD_TYPE && TREE_CODE(ptrtype) != UNION_TYPE)
100864 + continue;
100865 + if (TREE_TYPE(TREE_TYPE(field)) == type)
100866 + continue;
100867 + if (TYPE_MAIN_VARIANT(ptrtype) == TYPE_MAIN_VARIANT(type)) {
100868 + TREE_TYPE(field) = copy_node(TREE_TYPE(field));
100869 + TREE_TYPE(TREE_TYPE(field)) = type;
100870 + }
100871 + continue;
100872 + }
100873 + if (TREE_CODE(fieldtype) != RECORD_TYPE && TREE_CODE(fieldtype) != UNION_TYPE)
100874 + continue;
100875 + if (!constified(fieldtype))
100876 + continue;
100877 +
100878 + deconstify_tree(field);
100879 + TREE_READONLY(field) = 0;
100880 + }
100881 + TYPE_READONLY(type) = 0;
100882 + C_TYPE_FIELDS_READONLY(type) = 0;
100883 + if (lookup_attribute("do_const", TYPE_ATTRIBUTES(type)))
100884 + TYPE_ATTRIBUTES(type) = remove_attribute("do_const", TYPE_ATTRIBUTES(type));
100885 +}
100886 +
100887 +static void deconstify_tree(tree node)
100888 +{
100889 + tree old_type, new_type, field;
100890 +
100891 + old_type = TREE_TYPE(node);
100892 + while (TREE_CODE(old_type) == ARRAY_TYPE && TREE_CODE(TREE_TYPE(old_type)) != ARRAY_TYPE) {
100893 + node = TREE_TYPE(node) = copy_node(old_type);
100894 + old_type = TREE_TYPE(old_type);
100895 + }
100896 +
100897 + gcc_assert(TREE_CODE(old_type) == RECORD_TYPE || TREE_CODE(old_type) == UNION_TYPE);
100898 + gcc_assert(TYPE_READONLY(old_type) && (TYPE_QUALS(old_type) & TYPE_QUAL_CONST));
100899 +
100900 + new_type = build_qualified_type(old_type, TYPE_QUALS(old_type) & ~TYPE_QUAL_CONST);
100901 + TYPE_FIELDS(new_type) = copy_list(TYPE_FIELDS(new_type));
100902 + for (field = TYPE_FIELDS(new_type); field; field = TREE_CHAIN(field))
100903 + DECL_FIELD_CONTEXT(field) = new_type;
100904 +
100905 + deconstify_type(new_type);
100906 +
100907 + TREE_TYPE(node) = new_type;
100908 +}
100909 +
100910 +static tree handle_no_const_attribute(tree *node, tree name, tree args, int flags, bool *no_add_attrs)
100911 +{
100912 + tree type;
100913 + constify_info cinfo = {
100914 + .has_fptr_field = false,
100915 + .has_writable_field = false,
100916 + .has_do_const_field = false,
100917 + .has_no_const_field = false
100918 + };
100919 +
100920 + *no_add_attrs = true;
100921 + if (TREE_CODE(*node) == FUNCTION_DECL) {
100922 + error("%qE attribute does not apply to functions (%qF)", name, *node);
100923 + return NULL_TREE;
100924 + }
100925 +
100926 + if (TREE_CODE(*node) == PARM_DECL) {
100927 + error("%qE attribute does not apply to function parameters (%qD)", name, *node);
100928 + return NULL_TREE;
100929 + }
100930 +
100931 + if (TREE_CODE(*node) == VAR_DECL) {
100932 + error("%qE attribute does not apply to variables (%qD)", name, *node);
100933 + return NULL_TREE;
100934 + }
100935 +
100936 + if (TYPE_P(*node)) {
100937 + *no_add_attrs = false;
100938 + type = *node;
100939 + } else {
100940 + gcc_assert(TREE_CODE(*node) == TYPE_DECL);
100941 + type = TREE_TYPE(*node);
100942 + }
100943 +
100944 + if (TREE_CODE(type) != RECORD_TYPE && TREE_CODE(type) != UNION_TYPE) {
100945 + error("%qE attribute used on %qT applies to struct and union types only", name, type);
100946 + return NULL_TREE;
100947 + }
100948 +
100949 + if (lookup_attribute(IDENTIFIER_POINTER(name), TYPE_ATTRIBUTES(type))) {
100950 + error("%qE attribute is already applied to the type %qT", name, type);
100951 + return NULL_TREE;
100952 + }
100953 +
100954 + if (TYPE_P(*node)) {
100955 + if (lookup_attribute("do_const", TYPE_ATTRIBUTES(type)))
100956 + error("%qE attribute used on type %qT is incompatible with 'do_const'", name, type);
100957 + return NULL_TREE;
100958 + }
100959 +
100960 + constifiable(type, &cinfo);
100961 + if ((cinfo.has_fptr_field && !cinfo.has_writable_field) || lookup_attribute("do_const", TYPE_ATTRIBUTES(type))) {
100962 + deconstify_tree(*node);
100963 + TYPE_CONSTIFY_VISITED(TREE_TYPE(*node)) = 1;
100964 + return NULL_TREE;
100965 + }
100966 +
100967 + error("%qE attribute used on type %qT that is not constified", name, type);
100968 + return NULL_TREE;
100969 +}
100970 +
100971 +static void constify_type(tree type)
100972 +{
100973 + TYPE_READONLY(type) = 1;
100974 + C_TYPE_FIELDS_READONLY(type) = 1;
100975 + TYPE_CONSTIFY_VISITED(type) = 1;
100976 +// TYPE_ATTRIBUTES(type) = tree_cons(get_identifier("do_const"), NULL_TREE, TYPE_ATTRIBUTES(type));
100977 +}
100978 +
100979 +static tree handle_do_const_attribute(tree *node, tree name, tree args, int flags, bool *no_add_attrs)
100980 +{
100981 + *no_add_attrs = true;
100982 + if (!TYPE_P(*node)) {
100983 + error("%qE attribute applies to types only (%qD)", name, *node);
100984 + return NULL_TREE;
100985 + }
100986 +
100987 + if (TREE_CODE(*node) != RECORD_TYPE && TREE_CODE(*node) != UNION_TYPE) {
100988 + error("%qE attribute used on %qT applies to struct and union types only", name, *node);
100989 + return NULL_TREE;
100990 + }
100991 +
100992 + if (lookup_attribute(IDENTIFIER_POINTER(name), TYPE_ATTRIBUTES(*node))) {
100993 + error("%qE attribute used on %qT is already applied to the type", name, *node);
100994 + return NULL_TREE;
100995 + }
100996 +
100997 + if (lookup_attribute("no_const", TYPE_ATTRIBUTES(*node))) {
100998 + error("%qE attribute used on %qT is incompatible with 'no_const'", name, *node);
100999 + return NULL_TREE;
101000 + }
101001 +
101002 + *no_add_attrs = false;
101003 + return NULL_TREE;
101004 +}
101005 +
101006 +static struct attribute_spec no_const_attr = {
101007 + .name = "no_const",
101008 + .min_length = 0,
101009 + .max_length = 0,
101010 + .decl_required = false,
101011 + .type_required = false,
101012 + .function_type_required = false,
101013 + .handler = handle_no_const_attribute,
101014 +#if BUILDING_GCC_VERSION >= 4007
101015 + .affects_type_identity = true
101016 +#endif
101017 +};
101018 +
101019 +static struct attribute_spec do_const_attr = {
101020 + .name = "do_const",
101021 + .min_length = 0,
101022 + .max_length = 0,
101023 + .decl_required = false,
101024 + .type_required = false,
101025 + .function_type_required = false,
101026 + .handler = handle_do_const_attribute,
101027 +#if BUILDING_GCC_VERSION >= 4007
101028 + .affects_type_identity = true
101029 +#endif
101030 +};
101031 +
101032 +static void register_attributes(void *event_data, void *data)
101033 +{
101034 + register_attribute(&no_const_attr);
101035 + register_attribute(&do_const_attr);
101036 +}
101037 +
101038 +static void finish_type(void *event_data, void *data)
101039 +{
101040 + tree type = (tree)event_data;
101041 + constify_info cinfo = {
101042 + .has_fptr_field = false,
101043 + .has_writable_field = false,
101044 + .has_do_const_field = false,
101045 + .has_no_const_field = false
101046 + };
101047 +
101048 + if (type == NULL_TREE || type == error_mark_node)
101049 + return;
101050 +
101051 + if (TYPE_FIELDS(type) == NULL_TREE || TYPE_CONSTIFY_VISITED(type))
101052 + return;
101053 +
101054 + constifiable(type, &cinfo);
101055 +
101056 + if (lookup_attribute("no_const", TYPE_ATTRIBUTES(type))) {
101057 + if ((cinfo.has_fptr_field && !cinfo.has_writable_field) || cinfo.has_do_const_field) {
101058 + deconstify_type(type);
101059 + TYPE_CONSTIFY_VISITED(type) = 1;
101060 + } else
101061 + error("'no_const' attribute used on type %qT that is not constified", type);
101062 + return;
101063 + }
101064 +
101065 + if (lookup_attribute("do_const", TYPE_ATTRIBUTES(type))) {
101066 + if (!cinfo.has_writable_field) {
101067 + error("'do_const' attribute used on type %qT that is%sconstified", type, cinfo.has_fptr_field ? " " : " not ");
101068 + return;
101069 + }
101070 + constify_type(type);
101071 + return;
101072 + }
101073 +
101074 + if (cinfo.has_fptr_field && !cinfo.has_writable_field) {
101075 + if (lookup_attribute("do_const", TYPE_ATTRIBUTES(type))) {
101076 + error("'do_const' attribute used on type %qT that is constified", type);
101077 + return;
101078 + }
101079 + constify_type(type);
101080 + return;
101081 + }
101082 +
101083 + deconstify_type(type);
101084 + TYPE_CONSTIFY_VISITED(type) = 1;
101085 +}
101086 +
101087 +static void check_global_variables(void)
101088 +{
101089 + struct varpool_node *node;
101090 +
101091 +#if BUILDING_GCC_VERSION <= 4007
101092 + for (node = varpool_nodes; node; node = node->next) {
101093 + tree var = node->decl;
101094 +#else
101095 + FOR_EACH_VARIABLE(node) {
101096 + tree var = node->symbol.decl;
101097 +#endif
101098 + tree type = TREE_TYPE(var);
101099 +
101100 + if (TREE_CODE(type) != RECORD_TYPE && TREE_CODE(type) != UNION_TYPE)
101101 + continue;
101102 +
101103 + if (!TYPE_READONLY(type) || !C_TYPE_FIELDS_READONLY(type))
101104 + continue;
101105 +
101106 + if (!TYPE_CONSTIFY_VISITED(type))
101107 + continue;
101108 +
101109 + if (DECL_EXTERNAL(var))
101110 + continue;
101111 +
101112 + if (DECL_INITIAL(var))
101113 + continue;
101114 +
101115 + // this works around a gcc bug/feature where uninitialized globals
101116 + // are moved into the .bss section regardless of any constification
101117 + DECL_INITIAL(var) = build_constructor(type, NULL);
101118 +// inform(DECL_SOURCE_LOCATION(var), "constified variable %qE moved into .rodata", var);
101119 + }
101120 +}
101121 +
101122 +static unsigned int check_local_variables(void)
101123 +{
101124 + unsigned int ret = 0;
101125 + tree var;
101126 +
101127 +#if BUILDING_GCC_VERSION == 4005
101128 + tree vars;
101129 +#else
101130 + unsigned int i;
101131 +#endif
101132 +
101133 +#if BUILDING_GCC_VERSION == 4005
101134 + for (vars = cfun->local_decls; vars; vars = TREE_CHAIN(vars)) {
101135 + var = TREE_VALUE(vars);
101136 +#else
101137 + FOR_EACH_LOCAL_DECL(cfun, i, var) {
101138 +#endif
101139 + tree type = TREE_TYPE(var);
101140 +
101141 + gcc_assert(DECL_P(var));
101142 + if (is_global_var(var))
101143 + continue;
101144 +
101145 + if (TREE_CODE(type) != RECORD_TYPE && TREE_CODE(type) != UNION_TYPE)
101146 + continue;
101147 +
101148 + if (!TYPE_READONLY(type) || !C_TYPE_FIELDS_READONLY(type))
101149 + continue;
101150 +
101151 + if (!TYPE_CONSTIFY_VISITED(type))
101152 + continue;
101153 +
101154 + error_at(DECL_SOURCE_LOCATION(var), "constified variable %qE cannot be local", var);
101155 + ret = 1;
101156 + }
101157 + return ret;
101158 +}
101159 +
101160 +static unsigned int check_variables(void)
101161 +{
101162 + check_global_variables();
101163 + return check_local_variables();
101164 +}
101165 +
101166 +static struct gimple_opt_pass pass_local_variable = {
101167 + {
101168 + .type = GIMPLE_PASS,
101169 + .name = "check_variables",
101170 +#if BUILDING_GCC_VERSION >= 4008
101171 + .optinfo_flags = OPTGROUP_NONE,
101172 +#endif
101173 + .gate = NULL,
101174 + .execute = check_variables,
101175 + .sub = NULL,
101176 + .next = NULL,
101177 + .static_pass_number = 0,
101178 + .tv_id = TV_NONE,
101179 + .properties_required = 0,
101180 + .properties_provided = 0,
101181 + .properties_destroyed = 0,
101182 + .todo_flags_start = 0,
101183 + .todo_flags_finish = 0
101184 + }
101185 +};
101186 +
101187 +static struct {
101188 + const char *name;
101189 + const char *asm_op;
101190 +} sections[] = {
101191 + {".init.rodata", "\t.section\t.init.rodata,\"a\""},
101192 + {".ref.rodata", "\t.section\t.ref.rodata,\"a\""},
101193 + {".devinit.rodata", "\t.section\t.devinit.rodata,\"a\""},
101194 + {".devexit.rodata", "\t.section\t.devexit.rodata,\"a\""},
101195 + {".cpuinit.rodata", "\t.section\t.cpuinit.rodata,\"a\""},
101196 + {".cpuexit.rodata", "\t.section\t.cpuexit.rodata,\"a\""},
101197 + {".meminit.rodata", "\t.section\t.meminit.rodata,\"a\""},
101198 + {".memexit.rodata", "\t.section\t.memexit.rodata,\"a\""},
101199 + {".data..read_only", "\t.section\t.data..read_only,\"a\""},
101200 +};
101201 +
101202 +static unsigned int (*old_section_type_flags)(tree decl, const char *name, int reloc);
101203 +
101204 +static unsigned int constify_section_type_flags(tree decl, const char *name, int reloc)
101205 +{
101206 + size_t i;
101207 +
101208 + for (i = 0; i < ARRAY_SIZE(sections); i++)
101209 + if (!strcmp(sections[i].name, name))
101210 + return 0;
101211 + return old_section_type_flags(decl, name, reloc);
101212 +}
101213 +
101214 +static void constify_start_unit(void *gcc_data, void *user_data)
101215 +{
101216 +// size_t i;
101217 +
101218 +// for (i = 0; i < ARRAY_SIZE(sections); i++)
101219 +// sections[i].section = get_unnamed_section(0, output_section_asm_op, sections[i].asm_op);
101220 +// sections[i].section = get_section(sections[i].name, 0, NULL);
101221 +
101222 + old_section_type_flags = targetm.section_type_flags;
101223 + targetm.section_type_flags = constify_section_type_flags;
101224 +}
101225 +
101226 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
101227 +{
101228 + const char * const plugin_name = plugin_info->base_name;
101229 + const int argc = plugin_info->argc;
101230 + const struct plugin_argument * const argv = plugin_info->argv;
101231 + int i;
101232 + bool constify = true;
101233 +
101234 + struct register_pass_info local_variable_pass_info = {
101235 + .pass = &pass_local_variable.pass,
101236 + .reference_pass_name = "ssa",
101237 + .ref_pass_instance_number = 1,
101238 + .pos_op = PASS_POS_INSERT_BEFORE
101239 + };
101240 +
101241 + if (!plugin_default_version_check(version, &gcc_version)) {
101242 + error(G_("incompatible gcc/plugin versions"));
101243 + return 1;
101244 + }
101245 +
101246 + for (i = 0; i < argc; ++i) {
101247 + if (!(strcmp(argv[i].key, "no-constify"))) {
101248 + constify = false;
101249 + continue;
101250 + }
101251 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
101252 + }
101253 +
101254 + if (strcmp(lang_hooks.name, "GNU C")) {
101255 + inform(UNKNOWN_LOCATION, G_("%s supports C only"), plugin_name);
101256 + constify = false;
101257 + }
101258 +
101259 + register_callback(plugin_name, PLUGIN_INFO, NULL, &const_plugin_info);
101260 + if (constify) {
101261 + register_callback(plugin_name, PLUGIN_FINISH_TYPE, finish_type, NULL);
101262 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &local_variable_pass_info);
101263 + register_callback(plugin_name, PLUGIN_START_UNIT, constify_start_unit, NULL);
101264 + }
101265 + register_callback(plugin_name, PLUGIN_ATTRIBUTES, register_attributes, NULL);
101266 +
101267 + return 0;
101268 +}
101269 diff --git a/tools/gcc/generate_size_overflow_hash.sh b/tools/gcc/generate_size_overflow_hash.sh
101270 new file mode 100644
101271 index 0000000..e518932
101272 --- /dev/null
101273 +++ b/tools/gcc/generate_size_overflow_hash.sh
101274 @@ -0,0 +1,94 @@
101275 +#!/bin/bash
101276 +
101277 +# This script generates the hash table (size_overflow_hash.h) for the size_overflow gcc plugin (size_overflow_plugin.c).
101278 +
101279 +header1="size_overflow_hash.h"
101280 +database="size_overflow_hash.data"
101281 +n=65536
101282 +
101283 +usage() {
101284 +cat <<EOF
101285 +usage: $0 options
101286 +OPTIONS:
101287 + -h|--help help
101288 + -o header file
101289 + -d database file
101290 + -n hash array size
101291 +EOF
101292 + return 0
101293 +}
101294 +
101295 +while true
101296 +do
101297 + case "$1" in
101298 + -h|--help) usage && exit 0;;
101299 + -n) n=$2; shift 2;;
101300 + -o) header1="$2"; shift 2;;
101301 + -d) database="$2"; shift 2;;
101302 + --) shift 1; break ;;
101303 + *) break ;;
101304 + esac
101305 +done
101306 +
101307 +create_defines() {
101308 + for i in `seq 0 31`
101309 + do
101310 + echo -e "#define PARAM"$i" (1U << "$i")" >> "$header1"
101311 + done
101312 + echo >> "$header1"
101313 +}
101314 +
101315 +create_structs() {
101316 + rm -f "$header1"
101317 +
101318 + create_defines
101319 +
101320 + cat "$database" | while read data
101321 + do
101322 + data_array=($data)
101323 + struct_hash_name="${data_array[0]}"
101324 + funcn="${data_array[1]}"
101325 + params="${data_array[2]}"
101326 + next="${data_array[4]}"
101327 +
101328 + echo "const struct size_overflow_hash $struct_hash_name = {" >> "$header1"
101329 +
101330 + echo -e "\t.next\t= $next,\n\t.name\t= \"$funcn\"," >> "$header1"
101331 + echo -en "\t.param\t= " >> "$header1"
101332 + line=
101333 + for param_num in ${params//-/ };
101334 + do
101335 + line="${line}PARAM"$param_num"|"
101336 + done
101337 +
101338 + echo -e "${line%?},\n};\n" >> "$header1"
101339 + done
101340 +}
101341 +
101342 +create_headers() {
101343 + echo "const struct size_overflow_hash * const size_overflow_hash[$n] = {" >> "$header1"
101344 +}
101345 +
101346 +create_array_elements() {
101347 + index=0
101348 + grep -v "nohasharray" $database | sort -n -k 4 | while read data
101349 + do
101350 + data_array=($data)
101351 + i="${data_array[3]}"
101352 + hash="${data_array[0]}"
101353 + while [[ $index -lt $i ]]
101354 + do
101355 + echo -e "\t["$index"]\t= NULL," >> "$header1"
101356 + index=$(($index + 1))
101357 + done
101358 + index=$(($index + 1))
101359 + echo -e "\t["$i"]\t= &"$hash"," >> "$header1"
101360 + done
101361 + echo '};' >> $header1
101362 +}
101363 +
101364 +create_structs
101365 +create_headers
101366 +create_array_elements
101367 +
101368 +exit 0
101369 diff --git a/tools/gcc/kallocstat_plugin.c b/tools/gcc/kallocstat_plugin.c
101370 new file mode 100644
101371 index 0000000..568b360
101372 --- /dev/null
101373 +++ b/tools/gcc/kallocstat_plugin.c
101374 @@ -0,0 +1,170 @@
101375 +/*
101376 + * Copyright 2011-2013 by the PaX Team <pageexec@freemail.hu>
101377 + * Licensed under the GPL v2
101378 + *
101379 + * Note: the choice of the license means that the compilation process is
101380 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
101381 + * but for the kernel it doesn't matter since it doesn't link against
101382 + * any of the gcc libraries
101383 + *
101384 + * gcc plugin to find the distribution of k*alloc sizes
101385 + *
101386 + * TODO:
101387 + *
101388 + * BUGS:
101389 + * - none known
101390 + */
101391 +#include "gcc-plugin.h"
101392 +#include "config.h"
101393 +#include "system.h"
101394 +#include "coretypes.h"
101395 +#include "tree.h"
101396 +#include "tree-pass.h"
101397 +#include "flags.h"
101398 +#include "intl.h"
101399 +#include "toplev.h"
101400 +#include "plugin.h"
101401 +//#include "expr.h" where are you...
101402 +#include "diagnostic.h"
101403 +#include "plugin-version.h"
101404 +#include "tm.h"
101405 +#include "function.h"
101406 +#include "basic-block.h"
101407 +#include "gimple.h"
101408 +#include "rtl.h"
101409 +#include "emit-rtl.h"
101410 +
101411 +extern void print_gimple_stmt(FILE *, gimple, int, int);
101412 +
101413 +int plugin_is_GPL_compatible;
101414 +
101415 +static const char * const kalloc_functions[] = {
101416 + "__kmalloc",
101417 + "kmalloc",
101418 + "kmalloc_large",
101419 + "kmalloc_node",
101420 + "kmalloc_order",
101421 + "kmalloc_order_trace",
101422 + "kmalloc_slab",
101423 + "kzalloc",
101424 + "kzalloc_node",
101425 +};
101426 +
101427 +static struct plugin_info kallocstat_plugin_info = {
101428 + .version = "201302112000",
101429 +};
101430 +
101431 +static unsigned int execute_kallocstat(void);
101432 +
101433 +static struct gimple_opt_pass kallocstat_pass = {
101434 + .pass = {
101435 + .type = GIMPLE_PASS,
101436 + .name = "kallocstat",
101437 +#if BUILDING_GCC_VERSION >= 4008
101438 + .optinfo_flags = OPTGROUP_NONE,
101439 +#endif
101440 + .gate = NULL,
101441 + .execute = execute_kallocstat,
101442 + .sub = NULL,
101443 + .next = NULL,
101444 + .static_pass_number = 0,
101445 + .tv_id = TV_NONE,
101446 + .properties_required = 0,
101447 + .properties_provided = 0,
101448 + .properties_destroyed = 0,
101449 + .todo_flags_start = 0,
101450 + .todo_flags_finish = 0
101451 + }
101452 +};
101453 +
101454 +static bool is_kalloc(const char *fnname)
101455 +{
101456 + size_t i;
101457 +
101458 + for (i = 0; i < ARRAY_SIZE(kalloc_functions); i++)
101459 + if (!strcmp(fnname, kalloc_functions[i]))
101460 + return true;
101461 + return false;
101462 +}
101463 +
101464 +static unsigned int execute_kallocstat(void)
101465 +{
101466 + basic_block bb;
101467 +
101468 + // 1. loop through BBs and GIMPLE statements
101469 + FOR_EACH_BB(bb) {
101470 + gimple_stmt_iterator gsi;
101471 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
101472 + // gimple match:
101473 + tree fndecl, size;
101474 + gimple call_stmt;
101475 + const char *fnname;
101476 +
101477 + // is it a call
101478 + call_stmt = gsi_stmt(gsi);
101479 + if (!is_gimple_call(call_stmt))
101480 + continue;
101481 + fndecl = gimple_call_fndecl(call_stmt);
101482 + if (fndecl == NULL_TREE)
101483 + continue;
101484 + if (TREE_CODE(fndecl) != FUNCTION_DECL)
101485 + continue;
101486 +
101487 + // is it a call to k*alloc
101488 + fnname = IDENTIFIER_POINTER(DECL_NAME(fndecl));
101489 + if (!is_kalloc(fnname))
101490 + continue;
101491 +
101492 + // is the size arg the result of a simple const assignment
101493 + size = gimple_call_arg(call_stmt, 0);
101494 + while (true) {
101495 + gimple def_stmt;
101496 + expanded_location xloc;
101497 + size_t size_val;
101498 +
101499 + if (TREE_CODE(size) != SSA_NAME)
101500 + break;
101501 + def_stmt = SSA_NAME_DEF_STMT(size);
101502 + if (!def_stmt || !is_gimple_assign(def_stmt))
101503 + break;
101504 + if (gimple_num_ops(def_stmt) != 2)
101505 + break;
101506 + size = gimple_assign_rhs1(def_stmt);
101507 + if (!TREE_CONSTANT(size))
101508 + continue;
101509 + xloc = expand_location(gimple_location(def_stmt));
101510 + if (!xloc.file)
101511 + xloc = expand_location(DECL_SOURCE_LOCATION(current_function_decl));
101512 + size_val = TREE_INT_CST_LOW(size);
101513 + fprintf(stderr, "kallocsize: %8zu %8zx %s %s:%u\n", size_val, size_val, fnname, xloc.file, xloc.line);
101514 + break;
101515 + }
101516 +//print_gimple_stmt(stderr, call_stmt, 0, TDF_LINENO);
101517 +//debug_tree(gimple_call_fn(call_stmt));
101518 +//print_node(stderr, "pax", fndecl, 4);
101519 + }
101520 + }
101521 +
101522 + return 0;
101523 +}
101524 +
101525 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
101526 +{
101527 + const char * const plugin_name = plugin_info->base_name;
101528 + struct register_pass_info kallocstat_pass_info = {
101529 + .pass = &kallocstat_pass.pass,
101530 + .reference_pass_name = "ssa",
101531 + .ref_pass_instance_number = 1,
101532 + .pos_op = PASS_POS_INSERT_AFTER
101533 + };
101534 +
101535 + if (!plugin_default_version_check(version, &gcc_version)) {
101536 + error(G_("incompatible gcc/plugin versions"));
101537 + return 1;
101538 + }
101539 +
101540 + register_callback(plugin_name, PLUGIN_INFO, NULL, &kallocstat_plugin_info);
101541 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &kallocstat_pass_info);
101542 +
101543 + return 0;
101544 +}
101545 diff --git a/tools/gcc/kernexec_plugin.c b/tools/gcc/kernexec_plugin.c
101546 new file mode 100644
101547 index 0000000..698da67
101548 --- /dev/null
101549 +++ b/tools/gcc/kernexec_plugin.c
101550 @@ -0,0 +1,471 @@
101551 +/*
101552 + * Copyright 2011-2013 by the PaX Team <pageexec@freemail.hu>
101553 + * Licensed under the GPL v2
101554 + *
101555 + * Note: the choice of the license means that the compilation process is
101556 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
101557 + * but for the kernel it doesn't matter since it doesn't link against
101558 + * any of the gcc libraries
101559 + *
101560 + * gcc plugin to make KERNEXEC/amd64 almost as good as it is on i386
101561 + *
101562 + * TODO:
101563 + *
101564 + * BUGS:
101565 + * - none known
101566 + */
101567 +#include "gcc-plugin.h"
101568 +#include "config.h"
101569 +#include "system.h"
101570 +#include "coretypes.h"
101571 +#include "tree.h"
101572 +#include "tree-pass.h"
101573 +#include "flags.h"
101574 +#include "intl.h"
101575 +#include "toplev.h"
101576 +#include "plugin.h"
101577 +//#include "expr.h" where are you...
101578 +#include "diagnostic.h"
101579 +#include "plugin-version.h"
101580 +#include "tm.h"
101581 +#include "function.h"
101582 +#include "basic-block.h"
101583 +#include "gimple.h"
101584 +#include "rtl.h"
101585 +#include "emit-rtl.h"
101586 +#include "tree-flow.h"
101587 +
101588 +extern void print_gimple_stmt(FILE *, gimple, int, int);
101589 +extern rtx emit_move_insn(rtx x, rtx y);
101590 +
101591 +#if BUILDING_GCC_VERSION <= 4006
101592 +#define ANY_RETURN_P(rtx) (GET_CODE(rtx) == RETURN)
101593 +#endif
101594 +
101595 +#if BUILDING_GCC_VERSION >= 4008
101596 +#define TODO_dump_func 0
101597 +#endif
101598 +
101599 +int plugin_is_GPL_compatible;
101600 +
101601 +static struct plugin_info kernexec_plugin_info = {
101602 + .version = "201308230150",
101603 + .help = "method=[bts|or]\tinstrumentation method\n"
101604 +};
101605 +
101606 +static unsigned int execute_kernexec_reload(void);
101607 +static unsigned int execute_kernexec_fptr(void);
101608 +static unsigned int execute_kernexec_retaddr(void);
101609 +static bool kernexec_cmodel_check(void);
101610 +
101611 +static void (*kernexec_instrument_fptr)(gimple_stmt_iterator *);
101612 +static void (*kernexec_instrument_retaddr)(rtx);
101613 +
101614 +static struct gimple_opt_pass kernexec_reload_pass = {
101615 + .pass = {
101616 + .type = GIMPLE_PASS,
101617 + .name = "kernexec_reload",
101618 +#if BUILDING_GCC_VERSION >= 4008
101619 + .optinfo_flags = OPTGROUP_NONE,
101620 +#endif
101621 + .gate = kernexec_cmodel_check,
101622 + .execute = execute_kernexec_reload,
101623 + .sub = NULL,
101624 + .next = NULL,
101625 + .static_pass_number = 0,
101626 + .tv_id = TV_NONE,
101627 + .properties_required = 0,
101628 + .properties_provided = 0,
101629 + .properties_destroyed = 0,
101630 + .todo_flags_start = 0,
101631 + .todo_flags_finish = TODO_verify_ssa | TODO_verify_stmts | TODO_dump_func | TODO_remove_unused_locals | TODO_update_ssa_no_phi
101632 + }
101633 +};
101634 +
101635 +static struct gimple_opt_pass kernexec_fptr_pass = {
101636 + .pass = {
101637 + .type = GIMPLE_PASS,
101638 + .name = "kernexec_fptr",
101639 +#if BUILDING_GCC_VERSION >= 4008
101640 + .optinfo_flags = OPTGROUP_NONE,
101641 +#endif
101642 + .gate = kernexec_cmodel_check,
101643 + .execute = execute_kernexec_fptr,
101644 + .sub = NULL,
101645 + .next = NULL,
101646 + .static_pass_number = 0,
101647 + .tv_id = TV_NONE,
101648 + .properties_required = 0,
101649 + .properties_provided = 0,
101650 + .properties_destroyed = 0,
101651 + .todo_flags_start = 0,
101652 + .todo_flags_finish = TODO_verify_ssa | TODO_verify_stmts | TODO_dump_func | TODO_remove_unused_locals | TODO_update_ssa_no_phi
101653 + }
101654 +};
101655 +
101656 +static struct rtl_opt_pass kernexec_retaddr_pass = {
101657 + .pass = {
101658 + .type = RTL_PASS,
101659 + .name = "kernexec_retaddr",
101660 +#if BUILDING_GCC_VERSION >= 4008
101661 + .optinfo_flags = OPTGROUP_NONE,
101662 +#endif
101663 + .gate = kernexec_cmodel_check,
101664 + .execute = execute_kernexec_retaddr,
101665 + .sub = NULL,
101666 + .next = NULL,
101667 + .static_pass_number = 0,
101668 + .tv_id = TV_NONE,
101669 + .properties_required = 0,
101670 + .properties_provided = 0,
101671 + .properties_destroyed = 0,
101672 + .todo_flags_start = 0,
101673 + .todo_flags_finish = TODO_dump_func | TODO_ggc_collect
101674 + }
101675 +};
101676 +
101677 +static bool kernexec_cmodel_check(void)
101678 +{
101679 + tree section;
101680 +
101681 + if (ix86_cmodel != CM_KERNEL)
101682 + return false;
101683 +
101684 + section = lookup_attribute("section", DECL_ATTRIBUTES(current_function_decl));
101685 + if (!section || !TREE_VALUE(section))
101686 + return true;
101687 +
101688 + section = TREE_VALUE(TREE_VALUE(section));
101689 + if (strncmp(TREE_STRING_POINTER(section), ".vsyscall_", 10))
101690 + return true;
101691 +
101692 + return false;
101693 +}
101694 +
101695 +/*
101696 + * add special KERNEXEC instrumentation: reload %r10 after it has been clobbered
101697 + */
101698 +static void kernexec_reload_fptr_mask(gimple_stmt_iterator *gsi)
101699 +{
101700 + gimple asm_movabs_stmt;
101701 +
101702 + // build asm volatile("movabs $0x8000000000000000, %%r10\n\t" : : : );
101703 + asm_movabs_stmt = gimple_build_asm_vec("movabs $0x8000000000000000, %%r10\n\t", NULL, NULL, NULL, NULL);
101704 + gimple_asm_set_volatile(asm_movabs_stmt, true);
101705 + gsi_insert_after(gsi, asm_movabs_stmt, GSI_CONTINUE_LINKING);
101706 + update_stmt(asm_movabs_stmt);
101707 +}
101708 +
101709 +/*
101710 + * find all asm() stmts that clobber r10 and add a reload of r10
101711 + */
101712 +static unsigned int execute_kernexec_reload(void)
101713 +{
101714 + basic_block bb;
101715 +
101716 + // 1. loop through BBs and GIMPLE statements
101717 + FOR_EACH_BB(bb) {
101718 + gimple_stmt_iterator gsi;
101719 +
101720 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
101721 + // gimple match: __asm__ ("" : : : "r10");
101722 + gimple asm_stmt;
101723 + size_t nclobbers;
101724 +
101725 + // is it an asm ...
101726 + asm_stmt = gsi_stmt(gsi);
101727 + if (gimple_code(asm_stmt) != GIMPLE_ASM)
101728 + continue;
101729 +
101730 + // ... clobbering r10
101731 + nclobbers = gimple_asm_nclobbers(asm_stmt);
101732 + while (nclobbers--) {
101733 + tree op = gimple_asm_clobber_op(asm_stmt, nclobbers);
101734 + if (strcmp(TREE_STRING_POINTER(TREE_VALUE(op)), "r10"))
101735 + continue;
101736 + kernexec_reload_fptr_mask(&gsi);
101737 +//print_gimple_stmt(stderr, asm_stmt, 0, TDF_LINENO);
101738 + break;
101739 + }
101740 + }
101741 + }
101742 +
101743 + return 0;
101744 +}
101745 +
101746 +/*
101747 + * add special KERNEXEC instrumentation: force MSB of fptr to 1, which will produce
101748 + * a non-canonical address from a userland ptr and will just trigger a GPF on dereference
101749 + */
101750 +static void kernexec_instrument_fptr_bts(gimple_stmt_iterator *gsi)
101751 +{
101752 + gimple assign_intptr, assign_new_fptr, call_stmt;
101753 + tree intptr, orptr, old_fptr, new_fptr, kernexec_mask;
101754 +
101755 + call_stmt = gsi_stmt(*gsi);
101756 + old_fptr = gimple_call_fn(call_stmt);
101757 +
101758 + // create temporary unsigned long variable used for bitops and cast fptr to it
101759 + intptr = create_tmp_var(long_unsigned_type_node, "kernexec_bts");
101760 +#if BUILDING_GCC_VERSION <= 4007
101761 + add_referenced_var(intptr);
101762 +#endif
101763 + intptr = make_ssa_name(intptr, NULL);
101764 + assign_intptr = gimple_build_assign(intptr, fold_convert(long_unsigned_type_node, old_fptr));
101765 + SSA_NAME_DEF_STMT(intptr) = assign_intptr;
101766 + gsi_insert_before(gsi, assign_intptr, GSI_SAME_STMT);
101767 + update_stmt(assign_intptr);
101768 +
101769 + // apply logical or to temporary unsigned long and bitmask
101770 + kernexec_mask = build_int_cstu(long_long_unsigned_type_node, 0x8000000000000000LL);
101771 +// kernexec_mask = build_int_cstu(long_long_unsigned_type_node, 0xffffffff80000000LL);
101772 + orptr = fold_build2(BIT_IOR_EXPR, long_long_unsigned_type_node, intptr, kernexec_mask);
101773 + intptr = make_ssa_name(SSA_NAME_VAR(intptr), NULL);
101774 + assign_intptr = gimple_build_assign(intptr, orptr);
101775 + SSA_NAME_DEF_STMT(intptr) = assign_intptr;
101776 + gsi_insert_before(gsi, assign_intptr, GSI_SAME_STMT);
101777 + update_stmt(assign_intptr);
101778 +
101779 + // cast temporary unsigned long back to a temporary fptr variable
101780 + new_fptr = create_tmp_var(TREE_TYPE(old_fptr), "kernexec_fptr");
101781 +#if BUILDING_GCC_VERSION <= 4007
101782 + add_referenced_var(new_fptr);
101783 +#endif
101784 + new_fptr = make_ssa_name(new_fptr, NULL);
101785 + assign_new_fptr = gimple_build_assign(new_fptr, fold_convert(TREE_TYPE(old_fptr), intptr));
101786 + SSA_NAME_DEF_STMT(new_fptr) = assign_new_fptr;
101787 + gsi_insert_before(gsi, assign_new_fptr, GSI_SAME_STMT);
101788 + update_stmt(assign_new_fptr);
101789 +
101790 + // replace call stmt fn with the new fptr
101791 + gimple_call_set_fn(call_stmt, new_fptr);
101792 + update_stmt(call_stmt);
101793 +}
101794 +
101795 +static void kernexec_instrument_fptr_or(gimple_stmt_iterator *gsi)
101796 +{
101797 + gimple asm_or_stmt, call_stmt;
101798 + tree old_fptr, new_fptr, input, output;
101799 +#if BUILDING_GCC_VERSION <= 4007
101800 + VEC(tree, gc) *inputs = NULL;
101801 + VEC(tree, gc) *outputs = NULL;
101802 +#else
101803 + vec<tree, va_gc> *inputs = NULL;
101804 + vec<tree, va_gc> *outputs = NULL;
101805 +#endif
101806 +
101807 + call_stmt = gsi_stmt(*gsi);
101808 + old_fptr = gimple_call_fn(call_stmt);
101809 +
101810 + // create temporary fptr variable
101811 + new_fptr = create_tmp_var(TREE_TYPE(old_fptr), "kernexec_or");
101812 +#if BUILDING_GCC_VERSION <= 4007
101813 + add_referenced_var(new_fptr);
101814 +#endif
101815 + new_fptr = make_ssa_name(new_fptr, NULL);
101816 +
101817 + // build asm volatile("orq %%r10, %0\n\t" : "=r"(new_fptr) : "0"(old_fptr));
101818 + input = build_tree_list(NULL_TREE, build_string(1, "0"));
101819 + input = chainon(NULL_TREE, build_tree_list(input, old_fptr));
101820 + output = build_tree_list(NULL_TREE, build_string(2, "=r"));
101821 + output = chainon(NULL_TREE, build_tree_list(output, new_fptr));
101822 +#if BUILDING_GCC_VERSION <= 4007
101823 + VEC_safe_push(tree, gc, inputs, input);
101824 + VEC_safe_push(tree, gc, outputs, output);
101825 +#else
101826 + vec_safe_push(inputs, input);
101827 + vec_safe_push(outputs, output);
101828 +#endif
101829 + asm_or_stmt = gimple_build_asm_vec("orq %%r10, %0\n\t", inputs, outputs, NULL, NULL);
101830 + SSA_NAME_DEF_STMT(new_fptr) = asm_or_stmt;
101831 + gimple_asm_set_volatile(asm_or_stmt, true);
101832 + gsi_insert_before(gsi, asm_or_stmt, GSI_SAME_STMT);
101833 + update_stmt(asm_or_stmt);
101834 +
101835 + // replace call stmt fn with the new fptr
101836 + gimple_call_set_fn(call_stmt, new_fptr);
101837 + update_stmt(call_stmt);
101838 +}
101839 +
101840 +/*
101841 + * find all C level function pointer dereferences and forcibly set the highest bit of the pointer
101842 + */
101843 +static unsigned int execute_kernexec_fptr(void)
101844 +{
101845 + basic_block bb;
101846 +
101847 + // 1. loop through BBs and GIMPLE statements
101848 + FOR_EACH_BB(bb) {
101849 + gimple_stmt_iterator gsi;
101850 +
101851 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
101852 + // gimple match: h_1 = get_fptr (); D.2709_3 = h_1 (x_2(D));
101853 + tree fn;
101854 + gimple call_stmt;
101855 +
101856 + // is it a call ...
101857 + call_stmt = gsi_stmt(gsi);
101858 + if (!is_gimple_call(call_stmt))
101859 + continue;
101860 + fn = gimple_call_fn(call_stmt);
101861 + if (TREE_CODE(fn) == ADDR_EXPR)
101862 + continue;
101863 + if (TREE_CODE(fn) != SSA_NAME)
101864 + gcc_unreachable();
101865 +
101866 + // ... through a function pointer
101867 + if (SSA_NAME_VAR(fn) != NULL_TREE) {
101868 + fn = SSA_NAME_VAR(fn);
101869 + if (TREE_CODE(fn) != VAR_DECL && TREE_CODE(fn) != PARM_DECL) {
101870 + debug_tree(fn);
101871 + gcc_unreachable();
101872 + }
101873 + }
101874 + fn = TREE_TYPE(fn);
101875 + if (TREE_CODE(fn) != POINTER_TYPE)
101876 + continue;
101877 + fn = TREE_TYPE(fn);
101878 + if (TREE_CODE(fn) != FUNCTION_TYPE)
101879 + continue;
101880 +
101881 + kernexec_instrument_fptr(&gsi);
101882 +
101883 +//debug_tree(gimple_call_fn(call_stmt));
101884 +//print_gimple_stmt(stderr, call_stmt, 0, TDF_LINENO);
101885 + }
101886 + }
101887 +
101888 + return 0;
101889 +}
101890 +
101891 +// add special KERNEXEC instrumentation: btsq $63,(%rsp) just before retn
101892 +static void kernexec_instrument_retaddr_bts(rtx insn)
101893 +{
101894 + rtx btsq;
101895 + rtvec argvec, constraintvec, labelvec;
101896 + int line;
101897 +
101898 + // create asm volatile("btsq $63,(%%rsp)":::)
101899 + argvec = rtvec_alloc(0);
101900 + constraintvec = rtvec_alloc(0);
101901 + labelvec = rtvec_alloc(0);
101902 + line = expand_location(RTL_LOCATION(insn)).line;
101903 + btsq = gen_rtx_ASM_OPERANDS(VOIDmode, "btsq $63,(%%rsp)", empty_string, 0, argvec, constraintvec, labelvec, line);
101904 + MEM_VOLATILE_P(btsq) = 1;
101905 +// RTX_FRAME_RELATED_P(btsq) = 1; // not for ASM_OPERANDS
101906 + emit_insn_before(btsq, insn);
101907 +}
101908 +
101909 +// add special KERNEXEC instrumentation: orq %r10,(%rsp) just before retn
101910 +static void kernexec_instrument_retaddr_or(rtx insn)
101911 +{
101912 + rtx orq;
101913 + rtvec argvec, constraintvec, labelvec;
101914 + int line;
101915 +
101916 + // create asm volatile("orq %%r10,(%%rsp)":::)
101917 + argvec = rtvec_alloc(0);
101918 + constraintvec = rtvec_alloc(0);
101919 + labelvec = rtvec_alloc(0);
101920 + line = expand_location(RTL_LOCATION(insn)).line;
101921 + orq = gen_rtx_ASM_OPERANDS(VOIDmode, "orq %%r10,(%%rsp)", empty_string, 0, argvec, constraintvec, labelvec, line);
101922 + MEM_VOLATILE_P(orq) = 1;
101923 +// RTX_FRAME_RELATED_P(orq) = 1; // not for ASM_OPERANDS
101924 + emit_insn_before(orq, insn);
101925 +}
101926 +
101927 +/*
101928 + * find all asm level function returns and forcibly set the highest bit of the return address
101929 + */
101930 +static unsigned int execute_kernexec_retaddr(void)
101931 +{
101932 + rtx insn;
101933 +
101934 + // 1. find function returns
101935 + for (insn = get_insns(); insn; insn = NEXT_INSN(insn)) {
101936 + // rtl match: (jump_insn 41 40 42 2 (return) fptr.c:42 634 {return_internal} (nil))
101937 + // (jump_insn 12 9 11 2 (parallel [ (return) (unspec [ (0) ] UNSPEC_REP) ]) fptr.c:46 635 {return_internal_long} (nil))
101938 + // (jump_insn 97 96 98 6 (simple_return) fptr.c:50 -1 (nil) -> simple_return)
101939 + rtx body;
101940 +
101941 + // is it a retn
101942 + if (!JUMP_P(insn))
101943 + continue;
101944 + body = PATTERN(insn);
101945 + if (GET_CODE(body) == PARALLEL)
101946 + body = XVECEXP(body, 0, 0);
101947 + if (!ANY_RETURN_P(body))
101948 + continue;
101949 + kernexec_instrument_retaddr(insn);
101950 + }
101951 +
101952 +// print_simple_rtl(stderr, get_insns());
101953 +// print_rtl(stderr, get_insns());
101954 +
101955 + return 0;
101956 +}
101957 +
101958 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
101959 +{
101960 + const char * const plugin_name = plugin_info->base_name;
101961 + const int argc = plugin_info->argc;
101962 + const struct plugin_argument * const argv = plugin_info->argv;
101963 + int i;
101964 + struct register_pass_info kernexec_reload_pass_info = {
101965 + .pass = &kernexec_reload_pass.pass,
101966 + .reference_pass_name = "ssa",
101967 + .ref_pass_instance_number = 1,
101968 + .pos_op = PASS_POS_INSERT_AFTER
101969 + };
101970 + struct register_pass_info kernexec_fptr_pass_info = {
101971 + .pass = &kernexec_fptr_pass.pass,
101972 + .reference_pass_name = "ssa",
101973 + .ref_pass_instance_number = 1,
101974 + .pos_op = PASS_POS_INSERT_AFTER
101975 + };
101976 + struct register_pass_info kernexec_retaddr_pass_info = {
101977 + .pass = &kernexec_retaddr_pass.pass,
101978 + .reference_pass_name = "pro_and_epilogue",
101979 + .ref_pass_instance_number = 1,
101980 + .pos_op = PASS_POS_INSERT_AFTER
101981 + };
101982 +
101983 + if (!plugin_default_version_check(version, &gcc_version)) {
101984 + error(G_("incompatible gcc/plugin versions"));
101985 + return 1;
101986 + }
101987 +
101988 + register_callback(plugin_name, PLUGIN_INFO, NULL, &kernexec_plugin_info);
101989 +
101990 + if (TARGET_64BIT == 0)
101991 + return 0;
101992 +
101993 + for (i = 0; i < argc; ++i) {
101994 + if (!strcmp(argv[i].key, "method")) {
101995 + if (!argv[i].value) {
101996 + error(G_("no value supplied for option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
101997 + continue;
101998 + }
101999 + if (!strcmp(argv[i].value, "bts")) {
102000 + kernexec_instrument_fptr = kernexec_instrument_fptr_bts;
102001 + kernexec_instrument_retaddr = kernexec_instrument_retaddr_bts;
102002 + } else if (!strcmp(argv[i].value, "or")) {
102003 + kernexec_instrument_fptr = kernexec_instrument_fptr_or;
102004 + kernexec_instrument_retaddr = kernexec_instrument_retaddr_or;
102005 + fix_register("r10", 1, 1);
102006 + } else
102007 + error(G_("invalid option argument '-fplugin-arg-%s-%s=%s'"), plugin_name, argv[i].key, argv[i].value);
102008 + continue;
102009 + }
102010 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
102011 + }
102012 + if (!kernexec_instrument_fptr || !kernexec_instrument_retaddr)
102013 + error(G_("no instrumentation method was selected via '-fplugin-arg-%s-method'"), plugin_name);
102014 +
102015 + if (kernexec_instrument_fptr == kernexec_instrument_fptr_or)
102016 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &kernexec_reload_pass_info);
102017 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &kernexec_fptr_pass_info);
102018 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &kernexec_retaddr_pass_info);
102019 +
102020 + return 0;
102021 +}
102022 diff --git a/tools/gcc/latent_entropy_plugin.c b/tools/gcc/latent_entropy_plugin.c
102023 new file mode 100644
102024 index 0000000..679b9ef
102025 --- /dev/null
102026 +++ b/tools/gcc/latent_entropy_plugin.c
102027 @@ -0,0 +1,335 @@
102028 +/*
102029 + * Copyright 2012-2013 by the PaX Team <pageexec@freemail.hu>
102030 + * Licensed under the GPL v2
102031 + *
102032 + * Note: the choice of the license means that the compilation process is
102033 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
102034 + * but for the kernel it doesn't matter since it doesn't link against
102035 + * any of the gcc libraries
102036 + *
102037 + * gcc plugin to help generate a little bit of entropy from program state,
102038 + * used during boot in the kernel
102039 + *
102040 + * TODO:
102041 + * - add ipa pass to identify not explicitly marked candidate functions
102042 + * - mix in more program state (function arguments/return values, loop variables, etc)
102043 + * - more instrumentation control via attribute parameters
102044 + *
102045 + * BUGS:
102046 + * - LTO needs -flto-partition=none for now
102047 + */
102048 +#include "gcc-plugin.h"
102049 +#include "config.h"
102050 +#include "system.h"
102051 +#include "coretypes.h"
102052 +#include "tree.h"
102053 +#include "tree-pass.h"
102054 +#include "flags.h"
102055 +#include "intl.h"
102056 +#include "toplev.h"
102057 +#include "plugin.h"
102058 +//#include "expr.h" where are you...
102059 +#include "diagnostic.h"
102060 +#include "plugin-version.h"
102061 +#include "tm.h"
102062 +#include "function.h"
102063 +#include "basic-block.h"
102064 +#include "gimple.h"
102065 +#include "rtl.h"
102066 +#include "emit-rtl.h"
102067 +#include "tree-flow.h"
102068 +#include "langhooks.h"
102069 +
102070 +#if BUILDING_GCC_VERSION >= 4008
102071 +#define TODO_dump_func 0
102072 +#endif
102073 +
102074 +int plugin_is_GPL_compatible;
102075 +
102076 +static tree latent_entropy_decl;
102077 +
102078 +static struct plugin_info latent_entropy_plugin_info = {
102079 + .version = "201308230230",
102080 + .help = NULL
102081 +};
102082 +
102083 +static unsigned int execute_latent_entropy(void);
102084 +static bool gate_latent_entropy(void);
102085 +
102086 +static struct gimple_opt_pass latent_entropy_pass = {
102087 + .pass = {
102088 + .type = GIMPLE_PASS,
102089 + .name = "latent_entropy",
102090 +#if BUILDING_GCC_VERSION >= 4008
102091 + .optinfo_flags = OPTGROUP_NONE,
102092 +#endif
102093 + .gate = gate_latent_entropy,
102094 + .execute = execute_latent_entropy,
102095 + .sub = NULL,
102096 + .next = NULL,
102097 + .static_pass_number = 0,
102098 + .tv_id = TV_NONE,
102099 + .properties_required = PROP_gimple_leh | PROP_cfg,
102100 + .properties_provided = 0,
102101 + .properties_destroyed = 0,
102102 + .todo_flags_start = 0, //TODO_verify_ssa | TODO_verify_flow | TODO_verify_stmts,
102103 + .todo_flags_finish = TODO_verify_ssa | TODO_verify_stmts | TODO_dump_func | TODO_update_ssa
102104 + }
102105 +};
102106 +
102107 +static unsigned HOST_WIDE_INT seed;
102108 +static unsigned HOST_WIDE_INT get_random_const(void)
102109 +{
102110 + seed = (seed >> 1U) ^ (-(seed & 1ULL) & 0xD800000000000000ULL);
102111 + return seed;
102112 +}
102113 +
102114 +static tree handle_latent_entropy_attribute(tree *node, tree name, tree args, int flags, bool *no_add_attrs)
102115 +{
102116 + switch (TREE_CODE(*node)) {
102117 + default:
102118 + *no_add_attrs = true;
102119 + error("%qE attribute only applies to functions and variables", name);
102120 + break;
102121 +
102122 + case VAR_DECL:
102123 + if (DECL_INITIAL(*node)) {
102124 + *no_add_attrs = true;
102125 + error("variable %qD with %qE attribute must not be initialized", *node, name);
102126 + break;
102127 + }
102128 + DECL_INITIAL(*node) = build_int_cstu(long_long_unsigned_type_node, get_random_const());
102129 + break;
102130 +
102131 + case FUNCTION_DECL:
102132 + break;
102133 + }
102134 +
102135 + return NULL_TREE;
102136 +}
102137 +
102138 +static struct attribute_spec latent_entropy_attr = {
102139 + .name = "latent_entropy",
102140 + .min_length = 0,
102141 + .max_length = 0,
102142 + .decl_required = true,
102143 + .type_required = false,
102144 + .function_type_required = false,
102145 + .handler = handle_latent_entropy_attribute,
102146 +#if BUILDING_GCC_VERSION >= 4007
102147 + .affects_type_identity = false
102148 +#endif
102149 +};
102150 +
102151 +static void register_attributes(void *event_data, void *data)
102152 +{
102153 + register_attribute(&latent_entropy_attr);
102154 +}
102155 +
102156 +static bool gate_latent_entropy(void)
102157 +{
102158 + tree latent_entropy_attr;
102159 +
102160 + latent_entropy_attr = lookup_attribute("latent_entropy", DECL_ATTRIBUTES(current_function_decl));
102161 + return latent_entropy_attr != NULL_TREE;
102162 +}
102163 +
102164 +static enum tree_code get_op(tree *rhs)
102165 +{
102166 + static enum tree_code op;
102167 + unsigned HOST_WIDE_INT random_const;
102168 +
102169 + random_const = get_random_const();
102170 +
102171 + switch (op) {
102172 + case BIT_XOR_EXPR:
102173 + op = PLUS_EXPR;
102174 + break;
102175 +
102176 + case PLUS_EXPR:
102177 + if (rhs) {
102178 + op = LROTATE_EXPR;
102179 + random_const &= HOST_BITS_PER_WIDE_INT - 1;
102180 + break;
102181 + }
102182 +
102183 + case LROTATE_EXPR:
102184 + default:
102185 + op = BIT_XOR_EXPR;
102186 + break;
102187 + }
102188 + if (rhs)
102189 + *rhs = build_int_cstu(unsigned_intDI_type_node, random_const);
102190 + return op;
102191 +}
102192 +
102193 +static void perturb_local_entropy(basic_block bb, tree local_entropy)
102194 +{
102195 + gimple_stmt_iterator gsi;
102196 + gimple assign;
102197 + tree addxorrol, rhs;
102198 + enum tree_code op;
102199 +
102200 + op = get_op(&rhs);
102201 + addxorrol = fold_build2_loc(UNKNOWN_LOCATION, op, unsigned_intDI_type_node, local_entropy, rhs);
102202 + assign = gimple_build_assign(local_entropy, addxorrol);
102203 + gsi = gsi_after_labels(bb);
102204 + gsi_insert_before(&gsi, assign, GSI_NEW_STMT);
102205 + update_stmt(assign);
102206 +//debug_bb(bb);
102207 +}
102208 +
102209 +static void perturb_latent_entropy(basic_block bb, tree rhs)
102210 +{
102211 + gimple_stmt_iterator gsi;
102212 + gimple assign;
102213 + tree addxorrol, temp;
102214 +
102215 + // 1. create temporary copy of latent_entropy
102216 + temp = create_tmp_var(unsigned_intDI_type_node, "temp_latent_entropy");
102217 +#if BUILDING_GCC_VERSION <= 4007
102218 + add_referenced_var(temp);
102219 +#endif
102220 +
102221 + // 2. read...
102222 + temp = make_ssa_name(temp, NULL);
102223 + assign = gimple_build_assign(temp, latent_entropy_decl);
102224 + SSA_NAME_DEF_STMT(temp) = assign;
102225 +#if BUILDING_GCC_VERSION <= 4007
102226 + add_referenced_var(latent_entropy_decl);
102227 +#endif
102228 + gsi = gsi_after_labels(bb);
102229 + gsi_insert_after(&gsi, assign, GSI_NEW_STMT);
102230 + update_stmt(assign);
102231 +
102232 + // 3. ...modify...
102233 + addxorrol = fold_build2_loc(UNKNOWN_LOCATION, get_op(NULL), unsigned_intDI_type_node, temp, rhs);
102234 + temp = make_ssa_name(SSA_NAME_VAR(temp), NULL);
102235 + assign = gimple_build_assign(temp, addxorrol);
102236 + SSA_NAME_DEF_STMT(temp) = assign;
102237 + gsi_insert_after(&gsi, assign, GSI_NEW_STMT);
102238 + update_stmt(assign);
102239 +
102240 + // 4. ...write latent_entropy
102241 + assign = gimple_build_assign(latent_entropy_decl, temp);
102242 + gsi_insert_after(&gsi, assign, GSI_NEW_STMT);
102243 + update_stmt(assign);
102244 +}
102245 +
102246 +static unsigned int execute_latent_entropy(void)
102247 +{
102248 + basic_block bb;
102249 + gimple assign;
102250 + gimple_stmt_iterator gsi;
102251 + tree local_entropy;
102252 +
102253 + if (!latent_entropy_decl) {
102254 + struct varpool_node *node;
102255 +
102256 +#if BUILDING_GCC_VERSION <= 4007
102257 + for (node = varpool_nodes; node; node = node->next) {
102258 + tree var = node->decl;
102259 +#else
102260 + FOR_EACH_VARIABLE(node) {
102261 + tree var = node->symbol.decl;
102262 +#endif
102263 + if (strcmp(IDENTIFIER_POINTER(DECL_NAME(var)), "latent_entropy"))
102264 + continue;
102265 + latent_entropy_decl = var;
102266 +// debug_tree(var);
102267 + break;
102268 + }
102269 + if (!latent_entropy_decl) {
102270 +// debug_tree(current_function_decl);
102271 + return 0;
102272 + }
102273 + }
102274 +
102275 +//fprintf(stderr, "latent_entropy: %s\n", IDENTIFIER_POINTER(DECL_NAME(current_function_decl)));
102276 +
102277 + // 1. create local entropy variable
102278 + local_entropy = create_tmp_var(unsigned_intDI_type_node, "local_entropy");
102279 +#if BUILDING_GCC_VERSION <= 4007
102280 + add_referenced_var(local_entropy);
102281 + mark_sym_for_renaming(local_entropy);
102282 +#endif
102283 +
102284 + // 2. initialize local entropy variable
102285 + bb = split_block_after_labels(ENTRY_BLOCK_PTR)->dest;
102286 + if (dom_info_available_p(CDI_DOMINATORS))
102287 + set_immediate_dominator(CDI_DOMINATORS, bb, ENTRY_BLOCK_PTR);
102288 + gsi = gsi_start_bb(bb);
102289 +
102290 + assign = gimple_build_assign(local_entropy, build_int_cstu(unsigned_intDI_type_node, get_random_const()));
102291 +// gimple_set_location(assign, loc);
102292 + gsi_insert_after(&gsi, assign, GSI_NEW_STMT);
102293 + update_stmt(assign);
102294 +//debug_bb(bb);
102295 + bb = bb->next_bb;
102296 +
102297 + // 3. instrument each BB with an operation on the local entropy variable
102298 + while (bb != EXIT_BLOCK_PTR) {
102299 + perturb_local_entropy(bb, local_entropy);
102300 +//debug_bb(bb);
102301 + bb = bb->next_bb;
102302 + };
102303 +
102304 + // 4. mix local entropy into the global entropy variable
102305 + perturb_latent_entropy(EXIT_BLOCK_PTR->prev_bb, local_entropy);
102306 +//debug_bb(EXIT_BLOCK_PTR->prev_bb);
102307 + return 0;
102308 +}
102309 +
102310 +static void start_unit_callback(void *gcc_data, void *user_data)
102311 +{
102312 + tree latent_entropy_type;
102313 +
102314 +#if BUILDING_GCC_VERSION >= 4007
102315 + seed = get_random_seed(false);
102316 +#else
102317 + sscanf(get_random_seed(false), "%" HOST_WIDE_INT_PRINT "x", &seed);
102318 + seed *= seed;
102319 +#endif
102320 +
102321 + if (in_lto_p)
102322 + return;
102323 +
102324 + // extern volatile u64 latent_entropy
102325 + gcc_assert(TYPE_PRECISION(long_long_unsigned_type_node) == 64);
102326 + latent_entropy_type = build_qualified_type(long_long_unsigned_type_node, TYPE_QUALS(long_long_unsigned_type_node) | TYPE_QUAL_VOLATILE);
102327 + latent_entropy_decl = build_decl(UNKNOWN_LOCATION, VAR_DECL, get_identifier("latent_entropy"), latent_entropy_type);
102328 +
102329 + TREE_STATIC(latent_entropy_decl) = 1;
102330 + TREE_PUBLIC(latent_entropy_decl) = 1;
102331 + TREE_USED(latent_entropy_decl) = 1;
102332 + TREE_THIS_VOLATILE(latent_entropy_decl) = 1;
102333 + DECL_EXTERNAL(latent_entropy_decl) = 1;
102334 + DECL_ARTIFICIAL(latent_entropy_decl) = 1;
102335 + lang_hooks.decls.pushdecl(latent_entropy_decl);
102336 +// DECL_ASSEMBLER_NAME(latent_entropy_decl);
102337 +// varpool_finalize_decl(latent_entropy_decl);
102338 +// varpool_mark_needed_node(latent_entropy_decl);
102339 +}
102340 +
102341 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
102342 +{
102343 + const char * const plugin_name = plugin_info->base_name;
102344 + struct register_pass_info latent_entropy_pass_info = {
102345 + .pass = &latent_entropy_pass.pass,
102346 + .reference_pass_name = "optimized",
102347 + .ref_pass_instance_number = 1,
102348 + .pos_op = PASS_POS_INSERT_BEFORE
102349 + };
102350 +
102351 + if (!plugin_default_version_check(version, &gcc_version)) {
102352 + error(G_("incompatible gcc/plugin versions"));
102353 + return 1;
102354 + }
102355 +
102356 + register_callback(plugin_name, PLUGIN_INFO, NULL, &latent_entropy_plugin_info);
102357 + register_callback ("start_unit", PLUGIN_START_UNIT, &start_unit_callback, NULL);
102358 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &latent_entropy_pass_info);
102359 + register_callback(plugin_name, PLUGIN_ATTRIBUTES, register_attributes, NULL);
102360 +
102361 + return 0;
102362 +}
102363 diff --git a/tools/gcc/size_overflow_hash.data b/tools/gcc/size_overflow_hash.data
102364 new file mode 100644
102365 index 0000000..3a5b4b5
102366 --- /dev/null
102367 +++ b/tools/gcc/size_overflow_hash.data
102368 @@ -0,0 +1,7687 @@
102369 +intel_fake_agp_alloc_by_type_1 intel_fake_agp_alloc_by_type 1 1 NULL
102370 +ocfs2_get_refcount_tree_3 ocfs2_get_refcount_tree 0 3 NULL
102371 +batadv_orig_node_del_if_4 batadv_orig_node_del_if 2 4 NULL
102372 +storvsc_connect_to_vsp_22 storvsc_connect_to_vsp 2 22 NULL
102373 +compat_sock_setsockopt_23 compat_sock_setsockopt 5 23 NULL
102374 +carl9170_alloc_27 carl9170_alloc 1 27 NULL
102375 +sel_read_policyvers_55 sel_read_policyvers 3 55 NULL nohasharray
102376 +padzero_55 padzero 1 55 &sel_read_policyvers_55
102377 +cfg80211_disconnected_57 cfg80211_disconnected 4 57 NULL
102378 +__skb_to_sgvec_72 __skb_to_sgvec 0 72 NULL
102379 +crypto_authenc_setkey_80 crypto_authenc_setkey 3 80 NULL
102380 +snd_korg1212_copy_to_92 snd_korg1212_copy_to 6 92 NULL
102381 +load_msg_95 load_msg 2 95 NULL
102382 +device_flush_iotlb_115 device_flush_iotlb 2-3 115 NULL
102383 +ipath_verbs_send_117 ipath_verbs_send 5-3 117 NULL nohasharray
102384 +write_all_supers_117 write_all_supers 0 117 &ipath_verbs_send_117
102385 +init_q_132 init_q 4 132 NULL
102386 +ocfs2_local_alloc_slide_window_134 ocfs2_local_alloc_slide_window 0 134 NULL
102387 +memstick_alloc_host_142 memstick_alloc_host 1 142 NULL
102388 +hva_to_gfn_memslot_149 hva_to_gfn_memslot 0-1 149 NULL
102389 +ping_v6_sendmsg_152 ping_v6_sendmsg 4 152 NULL
102390 +ext4_ext_get_actual_len_153 ext4_ext_get_actual_len 0 153 NULL nohasharray
102391 +tracing_trace_options_write_153 tracing_trace_options_write 3 153 &ext4_ext_get_actual_len_153
102392 +nvme_create_queue_170 nvme_create_queue 3 170 NULL
102393 +xfs_buf_item_get_format_189 xfs_buf_item_get_format 2 189 NULL
102394 +iscsi_session_setup_196 iscsi_session_setup 4-5 196 NULL
102395 +device_add_bin_attributes_205 device_add_bin_attributes 0 205 NULL
102396 +br_port_info_size_268 br_port_info_size 0 268 NULL
102397 +generic_file_direct_write_291 generic_file_direct_write 0 291 NULL
102398 +read_file_war_stats_292 read_file_war_stats 3 292 NULL
102399 +SYSC_connect_304 SYSC_connect 3 304 NULL
102400 +syslog_print_307 syslog_print 2 307 NULL
102401 +dn_setsockopt_314 dn_setsockopt 5 314 NULL
102402 +next_node_allowed_318 next_node_allowed 1-0 318 NULL
102403 +mlx5_core_access_reg_361 mlx5_core_access_reg 5-3 361 NULL
102404 +xfs_get_blocks_364 xfs_get_blocks 2 364 NULL
102405 +get_more_blocks_367 get_more_blocks 0 367 NULL
102406 +sysfs_create_dir_398 sysfs_create_dir 0 398 NULL
102407 +hw_device_state_409 hw_device_state 0 409 NULL
102408 +aio_read_events_ring_410 aio_read_events_ring 3 410 NULL
102409 +lbs_rdmac_read_418 lbs_rdmac_read 3 418 NULL
102410 +snd_ca0106_ptr_read_467 snd_ca0106_ptr_read 0 467 NULL
102411 +sparse_index_init_482 sparse_index_init 2 482 NULL
102412 +cfs_trace_set_debug_mb_usrstr_486 cfs_trace_set_debug_mb_usrstr 2 486 NULL
102413 +nvme_trans_modesel_data_488 nvme_trans_modesel_data 4 488 NULL
102414 +iwl_dbgfs_protection_mode_write_502 iwl_dbgfs_protection_mode_write 3 502 NULL
102415 +rx_rx_defrag_end_read_505 rx_rx_defrag_end_read 3 505 NULL
102416 +_snd_pcm_hw_param_first_516 _snd_pcm_hw_param_first 0 516 NULL
102417 +ocfs2_validate_meta_ecc_bhs_527 ocfs2_validate_meta_ecc_bhs 0 527 NULL
102418 +zlib_deflate_workspacesize_537 zlib_deflate_workspacesize 0-1-2 537 NULL
102419 +iwl_dbgfs_wowlan_sram_read_540 iwl_dbgfs_wowlan_sram_read 3 540 NULL
102420 +sco_sock_setsockopt_552 sco_sock_setsockopt 5 552 NULL
102421 +lpfc_nlp_state_name_556 lpfc_nlp_state_name 2 556 NULL
102422 +snd_aw2_saa7146_get_hw_ptr_playback_558 snd_aw2_saa7146_get_hw_ptr_playback 0 558 NULL
102423 +dev_hard_header_565 dev_hard_header 0 565 NULL nohasharray
102424 +start_isoc_chain_565 start_isoc_chain 2 565 &dev_hard_header_565
102425 +ocfs2_refcounted_xattr_delete_need_584 ocfs2_refcounted_xattr_delete_need 0 584 NULL
102426 +smk_write_load_self2_591 smk_write_load_self2 3 591 NULL
102427 +cl_page_own0_599 cl_page_own0 0 599 NULL
102428 +btrfs_stack_file_extent_offset_607 btrfs_stack_file_extent_offset 0 607 NULL
102429 +ni_gpct_device_construct_610 ni_gpct_device_construct 5 610 NULL
102430 +fuse_request_alloc_nofs_617 fuse_request_alloc_nofs 1 617 NULL
102431 +ptlrpc_lprocfs_nrs_seq_write_621 ptlrpc_lprocfs_nrs_seq_write 3 621 NULL
102432 +viafb_dfpl_proc_write_627 viafb_dfpl_proc_write 3 627 NULL
102433 +ocfs2_num_free_extents_632 ocfs2_num_free_extents 0 632 NULL
102434 +clone_split_bio_633 clone_split_bio 6 633 NULL
102435 +ceph_osdc_new_request_635 ceph_osdc_new_request 6 635 NULL
102436 +remap_to_cache_640 remap_to_cache 3 640 NULL
102437 +cfs_hash_bkt_size_643 cfs_hash_bkt_size 0 643 NULL nohasharray
102438 +drbd_bm_find_next_643 drbd_bm_find_next 2 643 &cfs_hash_bkt_size_643
102439 +unlink_queued_645 unlink_queued 4 645 NULL
102440 +dtim_interval_read_654 dtim_interval_read 3 654 NULL
102441 +div_u64_rem_672 div_u64_rem 0 672 NULL
102442 +mem_rx_free_mem_blks_read_675 mem_rx_free_mem_blks_read 3 675 NULL
102443 +persistent_ram_vmap_709 persistent_ram_vmap 1-2 709 NULL
102444 +ipath_resize_cq_712 ipath_resize_cq 2 712 NULL
102445 +disk_max_parts_719 disk_max_parts 0 719 NULL
102446 +sctp_setsockopt_peer_addr_params_734 sctp_setsockopt_peer_addr_params 3 734 NULL
102447 +dvb_video_write_754 dvb_video_write 3 754 NULL
102448 +cfs_trace_allocate_string_buffer_781 cfs_trace_allocate_string_buffer 2 781 NULL
102449 +jbd2_journal_dirty_metadata_784 jbd2_journal_dirty_metadata 0 784 NULL
102450 +ath6kl_disconnect_timeout_write_794 ath6kl_disconnect_timeout_write 3 794 NULL
102451 +__vmalloc_node_range_811 __vmalloc_node_range 7 811 NULL nohasharray
102452 +snd_pcm_drain_811 snd_pcm_drain 0 811 &__vmalloc_node_range_811
102453 +if_writecmd_815 if_writecmd 2 815 NULL
102454 +aac_change_queue_depth_825 aac_change_queue_depth 2 825 NULL
102455 +SyS_write_846 SyS_write 3 846 NULL
102456 +um_idi_read_850 um_idi_read 3 850 NULL
102457 +error_state_read_859 error_state_read 6 859 NULL
102458 +o2net_send_message_vec_879 o2net_send_message_vec 4 879 NULL nohasharray
102459 +iwl_dbgfs_fh_reg_read_879 iwl_dbgfs_fh_reg_read 3 879 &o2net_send_message_vec_879
102460 +intel_alloc_iova_883 intel_alloc_iova 3 883 NULL
102461 +snd_pcm_action_single_905 snd_pcm_action_single 0 905 NULL
102462 +readw_931 readw 0 931 NULL
102463 +carl9170_cmd_buf_950 carl9170_cmd_buf 3 950 NULL
102464 +__nodes_weight_956 __nodes_weight 2-0 956 NULL
102465 +bnx2x_fill_fw_str_968 bnx2x_fill_fw_str 3 968 NULL
102466 +memcmp_990 memcmp 0 990 NULL
102467 +pte_prefetch_gfn_to_pfn_997 pte_prefetch_gfn_to_pfn 2 997 NULL
102468 +free_ind_block_999 free_ind_block 0 999 NULL
102469 +dm_cache_set_dirty_1016 dm_cache_set_dirty 2 1016 NULL
102470 +readreg_1017 readreg 0-1 1017 NULL
102471 +_do_truncate_1019 _do_truncate 2 1019 NULL
102472 +smk_write_cipso2_1021 smk_write_cipso2 3 1021 NULL
102473 +gigaset_initdriver_1060 gigaset_initdriver 2 1060 NULL
102474 +mce_request_packet_1073 mce_request_packet 3 1073 NULL
102475 +agp_create_memory_1075 agp_create_memory 1 1075 NULL
102476 +ext4_orphan_add_1080 ext4_orphan_add 0 1080 NULL
102477 +_scsih_adjust_queue_depth_1083 _scsih_adjust_queue_depth 2 1083 NULL
102478 +llcp_sock_sendmsg_1092 llcp_sock_sendmsg 4 1092 NULL
102479 +inode_ref_info_1094 inode_ref_info 0 1094 NULL nohasharray
102480 +llc_mac_hdr_init_1094 llc_mac_hdr_init 0 1094 &inode_ref_info_1094
102481 +nfs4_init_nonuniform_client_string_1097 nfs4_init_nonuniform_client_string 3 1097 NULL
102482 +utf8s_to_utf16s_1115 utf8s_to_utf16s 0 1115 NULL
102483 +__btrfs_cow_block_1125 __btrfs_cow_block 7-0 1125 NULL nohasharray
102484 +__ext4_journal_stop_1125 __ext4_journal_stop 0 1125 &__btrfs_cow_block_1125
102485 +cfg80211_report_obss_beacon_1133 cfg80211_report_obss_beacon 3 1133 NULL
102486 +vmalloc_32_1135 vmalloc_32 1 1135 NULL
102487 +i2400m_rx_ctl_1157 i2400m_rx_ctl 4 1157 NULL
102488 +find_free_extent_1173 find_free_extent 4-0 1173 NULL
102489 +ipc_alloc_1192 ipc_alloc 1 1192 NULL
102490 +ib_create_send_mad_1196 ib_create_send_mad 5 1196 NULL
102491 +pstore_ftrace_knob_write_1198 pstore_ftrace_knob_write 3 1198 NULL
102492 +i2400m_rx_ctl_ack_1199 i2400m_rx_ctl_ack 3 1199 NULL
102493 +dgrp_dpa_read_1204 dgrp_dpa_read 3 1204 NULL
102494 +i2cdev_read_1206 i2cdev_read 3 1206 NULL
102495 +lov_ost_pool_init_1215 lov_ost_pool_init 2 1215 NULL
102496 +acpi_battery_write_alarm_1240 acpi_battery_write_alarm 3 1240 NULL
102497 +nested_get_page_1252 nested_get_page 2 1252 NULL
102498 +ocfs2_extend_file_1266 ocfs2_extend_file 3 1266 NULL
102499 +qla4xxx_change_queue_depth_1268 qla4xxx_change_queue_depth 2 1268 NULL
102500 +ioctl_private_iw_point_1273 ioctl_private_iw_point 7 1273 NULL
102501 +batadv_tt_prepare_packet_buff_1280 batadv_tt_prepare_packet_buff 4 1280 NULL
102502 +SyS_flistxattr_1287 SyS_flistxattr 3 1287 NULL
102503 +tx_frag_in_process_called_read_1290 tx_frag_in_process_called_read 3 1290 NULL
102504 +ocfs2_append_rec_to_path_1321 ocfs2_append_rec_to_path 0 1321 NULL
102505 +ffs_1322 ffs 0 1322 NULL
102506 +qlcnic_pci_sriov_configure_1327 qlcnic_pci_sriov_configure 2 1327 NULL nohasharray
102507 +push_node_left_1327 push_node_left 0 1327 &qlcnic_pci_sriov_configure_1327
102508 +btrfs_submit_compressed_write_1347 btrfs_submit_compressed_write 5 1347 NULL
102509 +gen_pool_best_fit_1348 gen_pool_best_fit 2-3-4 1348 NULL
102510 +btrfs_alloc_logged_file_extent_1354 btrfs_alloc_logged_file_extent 0 1354 NULL
102511 +snd_pcm_lib_write1_1358 snd_pcm_lib_write1 0-3 1358 NULL
102512 +ipx_sendmsg_1362 ipx_sendmsg 4 1362 NULL
102513 +iov_num_pages_1364 iov_num_pages 0 1364 NULL
102514 +fw_stats_raw_read_1369 fw_stats_raw_read 3 1369 NULL
102515 +ocfs2_prepare_inode_for_write_1372 ocfs2_prepare_inode_for_write 3 1372 NULL
102516 +sctp_setsockopt_initmsg_1383 sctp_setsockopt_initmsg 3 1383 NULL
102517 +do_msgsnd_1387 do_msgsnd 4 1387 NULL
102518 +SYSC_io_getevents_1392 SYSC_io_getevents 3 1392 NULL
102519 +zone_page_state_1393 zone_page_state 0 1393 NULL
102520 +file_read_actor_1401 file_read_actor 4 1401 NULL
102521 +vb2_vmalloc_alloc_1402 vb2_vmalloc_alloc 2 1402 NULL
102522 +cfs_trace_copyout_string_1416 cfs_trace_copyout_string 2 1416 NULL
102523 +init_rs_internal_1436 init_rs_internal 1 1436 NULL
102524 +vb2_dc_get_user_pages_1442 vb2_dc_get_user_pages 1-3 1442 NULL
102525 +stack_max_size_read_1445 stack_max_size_read 3 1445 NULL
102526 +tx_queue_len_read_1463 tx_queue_len_read 3 1463 NULL
102527 +xprt_alloc_1475 xprt_alloc 2 1475 NULL
102528 +SYSC_syslog_1477 SYSC_syslog 3 1477 NULL
102529 +sta_num_ps_buf_frames_read_1488 sta_num_ps_buf_frames_read 3 1488 NULL
102530 +posix_acl_permission_1495 posix_acl_permission 0 1495 NULL
102531 +fpregs_set_1497 fpregs_set 4 1497 NULL
102532 +ocfs2_alloc_dinode_update_counts_1507 ocfs2_alloc_dinode_update_counts 0 1507 NULL
102533 +tomoyo_round2_1518 tomoyo_round2 0 1518 NULL
102534 +alloc_perm_bits_1532 alloc_perm_bits 2 1532 NULL
102535 +ath6kl_init_get_fwcaps_1557 ath6kl_init_get_fwcaps 3 1557 NULL
102536 +extent_from_logical_1585 extent_from_logical 0 1585 NULL
102537 +ieee80211_if_read_dot11MeshHWMPnetDiameterTraversalTime_1589 ieee80211_if_read_dot11MeshHWMPnetDiameterTraversalTime 3 1589 NULL
102538 +ipath_ht_handle_hwerrors_1592 ipath_ht_handle_hwerrors 3 1592 NULL
102539 +packet_buffer_init_1607 packet_buffer_init 2 1607 NULL
102540 +btmrvl_hscmd_read_1614 btmrvl_hscmd_read 3 1614 NULL
102541 +v9fs_fid_xattr_get_1618 v9fs_fid_xattr_get 0 1618 NULL
102542 +run_delayed_extent_op_1637 run_delayed_extent_op 0 1637 NULL
102543 +ikconfig_read_current_1658 ikconfig_read_current 3 1658 NULL
102544 +qgroup_rescan_init_1664 qgroup_rescan_init 0 1664 NULL
102545 +mei_cl_recv_1665 mei_cl_recv 3 1665 NULL
102546 +rmap_add_1677 rmap_add 3 1677 NULL
102547 +configfs_read_file_1683 configfs_read_file 3 1683 NULL
102548 +pdu_write_u_1710 pdu_write_u 3 1710 NULL
102549 +coda_psdev_write_1711 coda_psdev_write 3 1711 NULL nohasharray
102550 +gfn_to_hva_prot_1711 gfn_to_hva_prot 2 1711 &coda_psdev_write_1711
102551 +btrfs_dir_data_len_1714 btrfs_dir_data_len 0 1714 NULL
102552 +dma_memcpy_pg_to_iovec_1725 dma_memcpy_pg_to_iovec 6 1725 NULL
102553 +internal_create_group_1733 internal_create_group 0 1733 NULL
102554 +dev_irnet_read_1741 dev_irnet_read 3 1741 NULL
102555 +tx_frag_called_read_1748 tx_frag_called_read 3 1748 NULL
102556 +ebt_size_mwt_1768 ebt_size_mwt 0 1768 NULL
102557 +cosa_write_1774 cosa_write 3 1774 NULL
102558 +fcoe_ctlr_device_add_1793 fcoe_ctlr_device_add 3 1793 NULL
102559 +__nodelist_scnprintf_1815 __nodelist_scnprintf 4-2-0 1815 NULL
102560 +sb_issue_zeroout_1884 sb_issue_zeroout 3-0 1884 NULL
102561 +rx_defrag_called_read_1897 rx_defrag_called_read 3 1897 NULL
102562 +nfs_parse_server_name_1899 nfs_parse_server_name 2 1899 NULL
102563 +SyS_add_key_1900 SyS_add_key 4 1900 NULL
102564 +uhid_char_read_1920 uhid_char_read 3 1920 NULL
102565 +tx_tx_retry_data_read_1926 tx_tx_retry_data_read 3 1926 NULL
102566 +bdev_erase_1933 bdev_erase 3 1933 NULL
102567 +ext3_fiemap_1936 ext3_fiemap 4 1936 NULL
102568 +cyttsp_probe_1940 cyttsp_probe 4 1940 NULL
102569 +ieee80211_if_fmt_dot11MeshConfirmTimeout_1945 ieee80211_if_fmt_dot11MeshConfirmTimeout 3 1945 NULL
102570 +read_swap_header_1957 read_swap_header 0 1957 NULL
102571 +ivtv_v4l2_read_1964 ivtv_v4l2_read 3 1964 NULL
102572 +sel_read_avc_hash_stats_1984 sel_read_avc_hash_stats 3 1984 NULL
102573 +gpio_power_write_1991 gpio_power_write 3 1991 NULL
102574 +__alloc_bootmem_node_1992 __alloc_bootmem_node 2 1992 NULL
102575 +atomic_read_unchecked_1995 atomic_read_unchecked 0 1995 NULL
102576 +sb_min_blocksize_2004 sb_min_blocksize 0-2 2004 NULL
102577 +batadv_tt_commit_changes_2008 batadv_tt_commit_changes 4 2008 NULL
102578 +sep_prepare_input_dma_table_2009 sep_prepare_input_dma_table 2-3 2009 NULL
102579 +rx_rx_defrag_read_2010 rx_rx_defrag_read 3 2010 NULL
102580 +ksm_madvise_2012 ksm_madvise 0 2012 NULL
102581 +ocfs2_global_qinit_alloc_2018 ocfs2_global_qinit_alloc 0 2018 NULL
102582 +write_flush_pipefs_2021 write_flush_pipefs 3 2021 NULL
102583 +BcmCopySection_2035 BcmCopySection 5-0 2035 NULL
102584 +ath6kl_fwlog_mask_read_2050 ath6kl_fwlog_mask_read 3 2050 NULL
102585 +ocfs2_expand_inline_dir_2063 ocfs2_expand_inline_dir 3 2063 NULL
102586 +__generic_copy_from_user_intel_2073 __generic_copy_from_user_intel 0-3 2073 NULL
102587 +diva_set_driver_dbg_mask_2077 diva_set_driver_dbg_mask 0 2077 NULL nohasharray
102588 +alloc_retstack_tasklist_2077 alloc_retstack_tasklist 0 2077 &diva_set_driver_dbg_mask_2077
102589 +iwl_dbgfs_current_sleep_command_read_2081 iwl_dbgfs_current_sleep_command_read 3 2081 NULL
102590 +get_unaligned_le32_2092 get_unaligned_le32 0 2092 NULL
102591 +idetape_chrdev_read_2097 idetape_chrdev_read 3 2097 NULL
102592 +audit_expand_2098 audit_expand 0 2098 NULL
102593 +num_pages_spanned_2105 num_pages_spanned 0 2105 NULL
102594 +shrd128_2106 shrd128 0-1-3-2 2106 NULL
102595 +iwl_dbgfs_log_event_read_2107 iwl_dbgfs_log_event_read 3 2107 NULL
102596 +ecryptfs_encrypt_and_encode_filename_2109 ecryptfs_encrypt_and_encode_filename 6 2109 NULL
102597 +enable_read_2117 enable_read 3 2117 NULL
102598 +pcf50633_write_block_2124 pcf50633_write_block 2-3 2124 NULL
102599 +snd_interval_refine_last_2127 snd_interval_refine_last 0 2127 NULL
102600 +check_load_and_stores_2143 check_load_and_stores 2 2143 NULL
102601 +lp_gpio_irq_map_2149 lp_gpio_irq_map 2 2149 NULL
102602 +iov_iter_count_2152 iov_iter_count 0 2152 NULL
102603 +__copy_to_user_ll_2157 __copy_to_user_ll 0-3 2157 NULL
102604 +ocfs2_et_sanity_check_2164 ocfs2_et_sanity_check 0 2164 NULL
102605 +_ore_get_io_state_2166 _ore_get_io_state 5-3-4 2166 NULL
102606 +bio_integrity_alloc_2194 bio_integrity_alloc 3 2194 NULL
102607 +picolcd_debug_reset_write_2195 picolcd_debug_reset_write 3 2195 NULL
102608 +mei_dbgfs_read_meclients_2219 mei_dbgfs_read_meclients 3 2219 NULL nohasharray
102609 +u32_array_read_2219 u32_array_read 3 2219 &mei_dbgfs_read_meclients_2219
102610 +vhci_write_2224 vhci_write 3 2224 NULL
102611 +__ocfs2_journal_access_2241 __ocfs2_journal_access 0 2241 NULL
102612 +ieee80211_if_read_dot11MeshHWMPRannInterval_2249 ieee80211_if_read_dot11MeshHWMPRannInterval 3 2249 NULL
102613 +netlbl_secattr_catmap_walk_2255 netlbl_secattr_catmap_walk 0-2 2255 NULL
102614 +sel_write_avc_cache_threshold_2256 sel_write_avc_cache_threshold 3 2256 NULL
102615 +do_update_counters_2259 do_update_counters 4 2259 NULL
102616 +ath6kl_wmi_bssinfo_event_rx_2275 ath6kl_wmi_bssinfo_event_rx 3 2275 NULL
102617 +debug_debug5_read_2291 debug_debug5_read 3 2291 NULL
102618 +ocfs2_shift_tree_depth_2292 ocfs2_shift_tree_depth 0 2292 NULL
102619 +kvm_clear_guest_page_2308 kvm_clear_guest_page 2-4 2308 NULL
102620 +intel_sdvo_set_value_2311 intel_sdvo_set_value 4 2311 NULL
102621 +picolcd_fb_write_2318 picolcd_fb_write 3 2318 NULL nohasharray
102622 +hfsplus_find_init_2318 hfsplus_find_init 0 2318 &picolcd_fb_write_2318
102623 +gart_map_page_2325 gart_map_page 4-3 2325 NULL
102624 +__erst_read_to_erange_2341 __erst_read_to_erange 0 2341 NULL
102625 +zr364xx_read_2354 zr364xx_read 3 2354 NULL
102626 +viafb_iga2_odev_proc_write_2363 viafb_iga2_odev_proc_write 3 2363 NULL
102627 +SyS_mremap_2367 SyS_mremap 2-3-1-5 2367 NULL
102628 +xfs_buf_map_from_irec_2368 xfs_buf_map_from_irec 5 2368 NULL nohasharray
102629 +rose_recvmsg_2368 rose_recvmsg 4 2368 &xfs_buf_map_from_irec_2368
102630 +il_dbgfs_sensitivity_read_2370 il_dbgfs_sensitivity_read 3 2370 NULL
102631 +rxpipe_rx_prep_beacon_drop_read_2403 rxpipe_rx_prep_beacon_drop_read 3 2403 NULL
102632 +SYSC_mlock_2415 SYSC_mlock 1-2 2415 NULL
102633 +isdn_v110_open_2418 isdn_v110_open 3 2418 NULL
102634 +raid1_size_2419 raid1_size 0-2 2419 NULL
102635 +timespec_to_jiffies_timeout_2428 timespec_to_jiffies_timeout 0 2428 NULL
102636 +tty_buffer_find_2443 tty_buffer_find 2 2443 NULL
102637 +b43legacy_debugfs_read_2473 b43legacy_debugfs_read 3 2473 NULL
102638 +wiphy_new_2482 wiphy_new 2 2482 NULL
102639 +bio_alloc_bioset_2484 bio_alloc_bioset 2 2484 NULL
102640 +hfsplus_user_setxattr_2485 hfsplus_user_setxattr 4 2485 NULL
102641 +lookup_cache_entry_2494 lookup_cache_entry 2 2494 NULL
102642 +squashfs_read_fragment_index_table_2506 squashfs_read_fragment_index_table 4 2506 NULL
102643 +v9fs_cached_file_read_2514 v9fs_cached_file_read 3 2514 NULL
102644 +ext4_get_inode_loc_2516 ext4_get_inode_loc 0 2516 NULL
102645 +gspca_dev_probe_2570 gspca_dev_probe 4 2570 NULL
102646 +pcm_sanity_check_2574 pcm_sanity_check 0 2574 NULL
102647 +mdc_max_rpcs_in_flight_seq_write_2594 mdc_max_rpcs_in_flight_seq_write 3 2594 NULL
102648 +slot_bytes_2609 slot_bytes 0 2609 NULL
102649 +smk_write_logging_2618 smk_write_logging 3 2618 NULL
102650 +switch_status_2629 switch_status 5 2629 NULL
102651 +tlv_put_string_2631 tlv_put_string 0 2631 NULL
102652 +kvm_gfn_to_hva_cache_init_2636 kvm_gfn_to_hva_cache_init 3 2636 NULL
102653 +tcp_xmit_size_goal_2661 tcp_xmit_size_goal 2 2661 NULL
102654 +osc_build_ppga_2670 osc_build_ppga 2 2670 NULL
102655 +ffs_ep0_read_2672 ffs_ep0_read 3 2672 NULL
102656 +ocfs2_rotate_subtree_right_2674 ocfs2_rotate_subtree_right 0 2674 NULL
102657 +oti6858_write_2692 oti6858_write 4 2692 NULL
102658 +nfc_llcp_send_ui_frame_2702 nfc_llcp_send_ui_frame 5 2702 NULL
102659 +memcpy_fromiovecend_2707 memcpy_fromiovecend 4-3 2707 NULL
102660 +SyS_pwrite64_2708 SyS_pwrite64 3 2708 NULL nohasharray
102661 +lprocfs_stats_counter_size_2708 lprocfs_stats_counter_size 0 2708 &SyS_pwrite64_2708
102662 +__xip_file_write_2733 __xip_file_write 3-4 2733 NULL
102663 +can_nocow_extent_2744 can_nocow_extent 3 2744 NULL
102664 +xfs_readdir_2767 xfs_readdir 3 2767 NULL
102665 +mon_bin_ioctl_2771 mon_bin_ioctl 3 2771 NULL nohasharray
102666 +bictcp_update_2771 bictcp_update 2 2771 &mon_bin_ioctl_2771
102667 +__next_cpu_2782 __next_cpu 1-0 2782 NULL
102668 +set_msr_hyperv_pw_2785 set_msr_hyperv_pw 3 2785 NULL
102669 +device_add_attrs_2789 device_add_attrs 0 2789 NULL
102670 +iwl_dbgfs_clear_ucode_statistics_write_2804 iwl_dbgfs_clear_ucode_statistics_write 3 2804 NULL
102671 +sel_read_enforce_2828 sel_read_enforce 3 2828 NULL
102672 +vb2_dc_get_userptr_2829 vb2_dc_get_userptr 2-3 2829 NULL nohasharray
102673 +snd_pcm_reset_2829 snd_pcm_reset 0 2829 &vb2_dc_get_userptr_2829
102674 +sock_create_2838 sock_create 0 2838 NULL
102675 +wait_for_avail_2847 wait_for_avail 0 2847 NULL
102676 +ufs_free_fragments_2857 ufs_free_fragments 2 2857 NULL
102677 +sfq_alloc_2861 sfq_alloc 1 2861 NULL
102678 +irnet_ctrl_read_2863 irnet_ctrl_read 4 2863 NULL
102679 +move_addr_to_user_2868 move_addr_to_user 2 2868 NULL
102680 +mq_map_2871 mq_map 2 2871 NULL
102681 +__swab64p_2875 __swab64p 0 2875 NULL
102682 +nla_padlen_2883 nla_padlen 1 2883 NULL
102683 +cmm_write_2896 cmm_write 3 2896 NULL
102684 +alloc_page_cgroup_2919 alloc_page_cgroup 1 2919 NULL
102685 +osc_import_seq_write_2923 osc_import_seq_write 3 2923 NULL
102686 +xfs_trans_get_buf_map_2927 xfs_trans_get_buf_map 4 2927 NULL
102687 +nes_read_indexed_2946 nes_read_indexed 0 2946 NULL
102688 +tm6000_i2c_recv_regs16_2949 tm6000_i2c_recv_regs16 5 2949 NULL
102689 +i40e_dbg_prep_dump_buf_2951 i40e_dbg_prep_dump_buf 2 2951 NULL
102690 +set_fast_connectable_2952 set_fast_connectable 4 2952 NULL
102691 +free_area_init_core_2962 free_area_init_core 2-3 2962 NULL
102692 +do_strnlen_user_2976 do_strnlen_user 0-2 2976 NULL
102693 +ocfs2_find_branch_target_2989 ocfs2_find_branch_target 0 2989 NULL
102694 +p9_nr_pages_2992 p9_nr_pages 0-2 2992 NULL
102695 +lov_stripetype_seq_write_3013 lov_stripetype_seq_write 3 3013 NULL
102696 +btrfs_add_block_group_cache_3016 btrfs_add_block_group_cache 0 3016 NULL
102697 +do_dmabuf_dirty_sou_3017 do_dmabuf_dirty_sou 7 3017 NULL
102698 +depth_write_3021 depth_write 3 3021 NULL
102699 +snd_azf3328_codec_inl_3022 snd_azf3328_codec_inl 0 3022 NULL
102700 +kvm_unmap_hva_3028 kvm_unmap_hva 2 3028 NULL
102701 +xfrm_dst_alloc_copy_3034 xfrm_dst_alloc_copy 3 3034 NULL
102702 +lpfc_idiag_mbxacc_write_3038 lpfc_idiag_mbxacc_write 3 3038 NULL nohasharray
102703 +iwl_dbgfs_sleep_level_override_read_3038 iwl_dbgfs_sleep_level_override_read 3 3038 &lpfc_idiag_mbxacc_write_3038
102704 +nr_free_buffer_pages_3044 nr_free_buffer_pages 0 3044 NULL
102705 +il3945_ucode_rx_stats_read_3048 il3945_ucode_rx_stats_read 3 3048 NULL
102706 +qp_alloc_ppn_set_3068 qp_alloc_ppn_set 2-4 3068 NULL
102707 +__blk_end_bidi_request_3070 __blk_end_bidi_request 4-3 3070 NULL
102708 +dac960_user_command_proc_write_3071 dac960_user_command_proc_write 3 3071 NULL
102709 +read_file_antenna_diversity_3077 read_file_antenna_diversity 3 3077 NULL
102710 +free_coherent_3082 free_coherent 4-2 3082 NULL
102711 +ocfs2_get_right_path_3097 ocfs2_get_right_path 0 3097 NULL
102712 +clone_bio_3100 clone_bio 6 3100 NULL nohasharray
102713 +ttusb2_msg_3100 ttusb2_msg 4 3100 &clone_bio_3100
102714 +rb_alloc_3102 rb_alloc 1 3102 NULL
102715 +simple_write_to_buffer_3122 simple_write_to_buffer 2-5 3122 NULL
102716 +print_time_3132 print_time 0 3132 NULL
102717 +fill_write_buffer_3142 fill_write_buffer 3 3142 NULL
102718 +find_free_extent_3153 find_free_extent 5 3153 NULL
102719 +CIFSSMBSetPosixACL_3154 CIFSSMBSetPosixACL 5 3154 NULL
102720 +compat_sys_migrate_pages_3157 compat_sys_migrate_pages 2 3157 NULL
102721 +i915_gem_obj_ggtt_offset_3162 i915_gem_obj_ggtt_offset 0 3162 NULL
102722 +uv_num_possible_blades_3177 uv_num_possible_blades 0 3177 NULL
102723 +uvc_video_stats_dump_3181 uvc_video_stats_dump 3 3181 NULL
102724 +compat_do_ip6t_set_ctl_3184 compat_do_ip6t_set_ctl 4 3184 NULL
102725 +wait_table_bits_3187 wait_table_bits 1 3187 NULL
102726 +mempool_create_node_3191 mempool_create_node 1-6 3191 NULL
102727 +alloc_context_3194 alloc_context 1 3194 NULL
102728 +shmem_pread_slow_3198 shmem_pread_slow 3-2 3198 NULL
102729 +codec_reg_write_file_3204 codec_reg_write_file 3 3204 NULL
102730 +SyS_sendto_3219 SyS_sendto 6 3219 NULL
102731 +btrfs_prealloc_file_range_3227 btrfs_prealloc_file_range 3 3227 NULL
102732 +btrfs_next_leaf_3232 btrfs_next_leaf 0 3232 NULL
102733 +kimage_crash_alloc_3233 kimage_crash_alloc 3 3233 NULL
102734 +write_adapter_mem_3234 write_adapter_mem 3 3234 NULL
102735 +do_read_log_to_user_3236 do_read_log_to_user 4 3236 NULL
102736 +ext3_xattr_find_entry_3237 ext3_xattr_find_entry 0 3237 NULL
102737 +key_key_read_3241 key_key_read 3 3241 NULL
102738 +mmap_piobufs_3244 mmap_piobufs 4 3244 NULL
102739 +did_overwrite_first_ref_3259 did_overwrite_first_ref 0 3259 NULL
102740 +__ilog2_u64_3284 __ilog2_u64 0 3284 NULL
102741 +__iovec_copy_from_user_inatomic_3314 __iovec_copy_from_user_inatomic 0-4-3 3314 NULL
102742 +dbDiscardAG_3322 dbDiscardAG 3 3322 NULL
102743 +compat_sys_setsockopt_3326 compat_sys_setsockopt 5 3326 NULL
102744 +read_from_oldmem_3337 read_from_oldmem 2 3337 NULL
102745 +sysfs_create_group_3339 sysfs_create_group 0 3339 NULL
102746 +tty_port_register_device_attr_3341 tty_port_register_device_attr 3 3341 NULL
102747 +il_dbgfs_interrupt_read_3351 il_dbgfs_interrupt_read 3 3351 NULL
102748 +gsm_control_rls_3353 gsm_control_rls 3 3353 NULL
102749 +scnprintf_3360 scnprintf 0-2 3360 NULL
102750 +ReadByteAmd7930_3365 ReadByteAmd7930 0 3365 NULL
102751 +sr_read_3366 sr_read 3 3366 NULL
102752 +count_inode_refs_3375 count_inode_refs 0 3375 NULL
102753 +x86_emulate_instruction_3389 x86_emulate_instruction 2 3389 NULL
102754 +mtdchar_writeoob_3393 mtdchar_writeoob 4 3393 NULL
102755 +send_stream_3397 send_stream 4 3397 NULL
102756 +isdn_readbchan_3401 isdn_readbchan 0-5 3401 NULL
102757 +mei_io_cb_alloc_resp_buf_3414 mei_io_cb_alloc_resp_buf 2 3414 NULL
102758 +zone_to_nid_3415 zone_to_nid 0 3415 NULL
102759 +pci_add_cap_save_buffer_3426 pci_add_cap_save_buffer 3 3426 NULL
102760 +crystalhd_create_dio_pool_3427 crystalhd_create_dio_pool 2 3427 NULL
102761 +SyS_msgsnd_3436 SyS_msgsnd 3 3436 NULL
102762 +send_unlink_3438 send_unlink 0 3438 NULL
102763 +pipe_iov_copy_to_user_3447 pipe_iov_copy_to_user 3 3447 NULL
102764 +map_single_3449 map_single 0 3449 NULL
102765 +softsynth_write_3455 softsynth_write 3 3455 NULL
102766 +jffs2_acl_setxattr_3464 jffs2_acl_setxattr 4 3464 NULL nohasharray
102767 +snd_pcm_lib_readv_transfer_3464 snd_pcm_lib_readv_transfer 5-4-2 3464 &jffs2_acl_setxattr_3464
102768 +security_context_to_sid_default_3492 security_context_to_sid_default 2 3492 NULL
102769 +xfrm_migrate_msgsize_3496 xfrm_migrate_msgsize 1 3496 NULL
102770 +run_one_delayed_ref_3503 run_one_delayed_ref 0 3503 NULL nohasharray
102771 +kvm_handle_bad_page_3503 kvm_handle_bad_page 2 3503 &run_one_delayed_ref_3503
102772 +mem_tx_free_mem_blks_read_3521 mem_tx_free_mem_blks_read 3 3521 NULL
102773 +SyS_semtimedop_3532 SyS_semtimedop 3 3532 NULL
102774 +SyS_readv_3539 SyS_readv 3 3539 NULL
102775 +btrfs_dir_name_len_3549 btrfs_dir_name_len 0 3549 NULL
102776 +iommu_map_3554 iommu_map 3-2 3554 NULL
102777 +btrfs_delayed_update_inode_3557 btrfs_delayed_update_inode 0 3557 NULL
102778 +i915_gem_execbuffer_reserve_3558 i915_gem_execbuffer_reserve 0 3558 NULL
102779 +alloc_smp_resp_3566 alloc_smp_resp 1 3566 NULL
102780 +evtchn_read_3569 evtchn_read 3 3569 NULL
102781 +ll_track_ppid_seq_write_3582 ll_track_ppid_seq_write 3 3582 NULL
102782 +vc_resize_3585 vc_resize 3-2 3585 NULL
102783 +kvm_mmu_notifier_change_pte_3596 kvm_mmu_notifier_change_pte 3 3596 NULL
102784 +sctp_getsockopt_events_3607 sctp_getsockopt_events 2 3607 NULL
102785 +edac_mc_alloc_3611 edac_mc_alloc 4 3611 NULL
102786 +tx_tx_starts_read_3617 tx_tx_starts_read 3 3617 NULL
102787 +aligned_kmalloc_3628 aligned_kmalloc 1 3628 NULL
102788 +x86_swiotlb_alloc_coherent_3649 x86_swiotlb_alloc_coherent 2 3649 NULL
102789 +ath6kl_disconnect_timeout_read_3650 ath6kl_disconnect_timeout_read 3 3650 NULL
102790 +i915_compat_ioctl_3656 i915_compat_ioctl 2 3656 NULL
102791 +replace_pin_at_irq_node_3687 replace_pin_at_irq_node 2 3687 NULL
102792 +ntfs_attr_make_non_resident_3694 ntfs_attr_make_non_resident 0 3694 NULL
102793 +snd_m3_assp_read_3703 snd_m3_assp_read 0 3703 NULL nohasharray
102794 +create_irq_3703 create_irq 0 3703 &snd_m3_assp_read_3703
102795 +videobuf_pages_to_sg_3708 videobuf_pages_to_sg 2 3708 NULL
102796 +ci_ll_write_3740 ci_ll_write 4 3740 NULL nohasharray
102797 +ath6kl_mgmt_tx_3740 ath6kl_mgmt_tx 7 3740 &ci_ll_write_3740
102798 +uar_index2pfn_3741 uar_index2pfn 0-2 3741 NULL
102799 +sctp_setsockopt_auth_key_3793 sctp_setsockopt_auth_key 3 3793 NULL
102800 +btrfs_alloc_chunk_3808 btrfs_alloc_chunk 0 3808 NULL
102801 +ncp_file_write_3813 ncp_file_write 3 3813 NULL
102802 +llc_ui_recvmsg_3826 llc_ui_recvmsg 4 3826 NULL
102803 +btrfs_uuid_iter_rem_3831 btrfs_uuid_iter_rem 0 3831 NULL
102804 +hfsplus_direct_IO_3835 hfsplus_direct_IO 4 3835 NULL
102805 +stringify_nodemap_3842 stringify_nodemap 2 3842 NULL
102806 +ubi_eba_read_leb_3847 ubi_eba_read_leb 0 3847 NULL
102807 +create_one_cdev_3852 create_one_cdev 2 3852 NULL
102808 +smk_read_onlycap_3855 smk_read_onlycap 3 3855 NULL
102809 +get_fd_set_3866 get_fd_set 1 3866 NULL
102810 +apei_res_sub_3873 apei_res_sub 0 3873 NULL
102811 +garp_attr_create_3883 garp_attr_create 3 3883 NULL
102812 +efivarfs_file_read_3893 efivarfs_file_read 3 3893 NULL
102813 +nvram_write_3894 nvram_write 3 3894 NULL
102814 +pipeline_pre_proc_swi_read_3898 pipeline_pre_proc_swi_read 3 3898 NULL
102815 +comedi_buf_read_n_available_3899 comedi_buf_read_n_available 0 3899 NULL
102816 +vcs_write_3910 vcs_write 3 3910 NULL
102817 +SyS_move_pages_3920 SyS_move_pages 2 3920 NULL
102818 +hdlc_irq_one_3944 hdlc_irq_one 2 3944 NULL
102819 +brcmf_debugfs_fws_stats_read_3947 brcmf_debugfs_fws_stats_read 3 3947 NULL
102820 +mite_bytes_written_to_memory_lb_3987 mite_bytes_written_to_memory_lb 0 3987 NULL
102821 +do_add_counters_3992 do_add_counters 3 3992 NULL
102822 +obd_alloc_memmd_4002 obd_alloc_memmd 0 4002 NULL
102823 +userspace_status_4004 userspace_status 4 4004 NULL
102824 +mei_write_4005 mei_write 3 4005 NULL nohasharray
102825 +xfs_check_block_4005 xfs_check_block 4 4005 &mei_write_4005
102826 +snd_hdsp_capture_copy_4011 snd_hdsp_capture_copy 5 4011 NULL
102827 +mm_populate_4016 mm_populate 1-2 4016 NULL nohasharray
102828 +i915_gem_object_unbind_4016 i915_gem_object_unbind 0 4016 &mm_populate_4016
102829 +blk_end_request_4024 blk_end_request 3 4024 NULL
102830 +ext4_xattr_find_entry_4025 ext4_xattr_find_entry 0 4025 NULL
102831 +mtip_hw_read_registers_4037 mtip_hw_read_registers 3 4037 NULL
102832 +i915_gpu_idle_4062 i915_gpu_idle 0 4062 NULL
102833 +read_file_queues_4078 read_file_queues 3 4078 NULL
102834 +fbcon_do_set_font_4079 fbcon_do_set_font 2-3 4079 NULL
102835 +btrfs_inc_ref_4084 btrfs_inc_ref 0 4084 NULL
102836 +da9052_free_irq_4090 da9052_free_irq 2 4090 NULL
102837 +tm6000_read_4151 tm6000_read 3 4151 NULL
102838 +mpt_raid_phys_disk_get_num_paths_4155 mpt_raid_phys_disk_get_num_paths 0 4155 NULL
102839 +msg_bits_4158 msg_bits 0-3-4 4158 NULL
102840 +get_alua_req_4166 get_alua_req 3 4166 NULL
102841 +blk_dropped_read_4168 blk_dropped_read 3 4168 NULL
102842 +read_file_bool_4180 read_file_bool 3 4180 NULL
102843 +ocfs2_find_cpos_for_right_leaf_4194 ocfs2_find_cpos_for_right_leaf 0 4194 NULL
102844 +f1x_determine_channel_4202 f1x_determine_channel 2 4202 NULL
102845 +_osd_req_list_objects_4204 _osd_req_list_objects 6 4204 NULL
102846 +__snd_gf1_read_addr_4210 __snd_gf1_read_addr 0 4210 NULL
102847 +ath6kl_force_roam_write_4282 ath6kl_force_roam_write 3 4282 NULL
102848 +goldfish_audio_write_4284 goldfish_audio_write 3 4284 NULL
102849 +msb_do_write_request_4286 msb_do_write_request 2 4286 NULL
102850 +paging32_page_fault_4288 paging32_page_fault 2 4288 NULL
102851 +xt_compat_add_offset_4289 xt_compat_add_offset 0 4289 NULL
102852 +__usbnet_read_cmd_4299 __usbnet_read_cmd 7 4299 NULL
102853 +dvb_ringbuffer_pkt_read_user_4303 dvb_ringbuffer_pkt_read_user 3-2-5 4303 NULL
102854 +__pool_find_4308 __pool_find 3 4308 NULL
102855 +count_strings_4315 count_strings 0 4315 NULL
102856 +nouveau_fifo_create__4327 nouveau_fifo_create_ 5-6 4327 NULL
102857 +snd_rawmidi_kernel_read_4328 snd_rawmidi_kernel_read 3 4328 NULL
102858 +kvm_apic_get_reg_4354 kvm_apic_get_reg 0 4354 NULL
102859 +__copy_from_user_inatomic_4365 __copy_from_user_inatomic 0-3 4365 NULL nohasharray
102860 +lookup_string_4365 lookup_string 0 4365 &__copy_from_user_inatomic_4365
102861 +btrfs_set_disk_extent_flags_4374 btrfs_set_disk_extent_flags 0 4374 NULL
102862 +irda_sendmsg_4388 irda_sendmsg 4 4388 NULL
102863 +access_process_vm_4412 access_process_vm 0-4-2 4412 NULL nohasharray
102864 +cxacru_cm_get_array_4412 cxacru_cm_get_array 4 4412 &access_process_vm_4412
102865 +libfc_vport_create_4415 libfc_vport_create 2 4415 NULL
102866 +rtw_android_get_rssi_4421 rtw_android_get_rssi 0 4421 NULL
102867 +do_pages_stat_4437 do_pages_stat 2 4437 NULL
102868 +memparse_4444 memparse 0 4444 NULL
102869 +tcp_dma_try_early_copy_4457 tcp_dma_try_early_copy 3 4457 NULL
102870 +at76_set_card_command_4471 at76_set_card_command 4 4471 NULL
102871 +snd_seq_expand_var_event_4481 snd_seq_expand_var_event 5-0 4481 NULL
102872 +ocfs2_grow_tree_4492 ocfs2_grow_tree 0 4492 NULL
102873 +vmbus_establish_gpadl_4495 vmbus_establish_gpadl 3 4495 NULL
102874 +set_link_security_4502 set_link_security 4 4502 NULL
102875 +dm_cache_remove_mapping_4513 dm_cache_remove_mapping 2 4513 NULL
102876 +__gfn_to_pfn_memslot_4530 __gfn_to_pfn_memslot 2-0 4530 NULL
102877 +ll_max_readahead_per_file_mb_seq_write_4531 ll_max_readahead_per_file_mb_seq_write 3 4531 NULL
102878 +da9052_group_write_4534 da9052_group_write 2-3 4534 NULL
102879 +tty_register_device_4544 tty_register_device 2 4544 NULL
102880 +videobuf_vmalloc_to_sg_4548 videobuf_vmalloc_to_sg 2 4548 NULL
102881 +btrfs_file_extent_inline_item_len_4575 btrfs_file_extent_inline_item_len 0 4575 NULL
102882 +xfs_buf_get_maps_4581 xfs_buf_get_maps 2 4581 NULL
102883 +iommu_map_page_4588 iommu_map_page 5 4588 NULL
102884 +bch_alloc_4593 bch_alloc 1 4593 NULL
102885 +ocfs2_refcount_lock_4595 ocfs2_refcount_lock 0 4595 NULL
102886 +__wb_force_remove_mapping_4622 __wb_force_remove_mapping 2 4622 NULL
102887 +ll_rw_extents_stats_seq_write_4633 ll_rw_extents_stats_seq_write 3 4633 NULL
102888 +iwl_dbgfs_tx_queue_read_4635 iwl_dbgfs_tx_queue_read 3 4635 NULL
102889 +ext3_orphan_add_4665 ext3_orphan_add 0 4665 NULL
102890 +skb_add_data_nocache_4682 skb_add_data_nocache 4 4682 NULL
102891 +cx18_read_pos_4683 cx18_read_pos 3 4683 NULL
102892 +short_retry_limit_read_4687 short_retry_limit_read 3 4687 NULL
102893 +kone_receive_4690 kone_receive 4 4690 NULL
102894 +link_to_fixup_dir_4699 link_to_fixup_dir 0 4699 NULL
102895 +cxgbi_alloc_big_mem_4707 cxgbi_alloc_big_mem 1 4707 NULL
102896 +konepure_sysfs_read_4709 konepure_sysfs_read 6 4709 NULL
102897 +ati_create_gatt_pages_4722 ati_create_gatt_pages 1 4722 NULL nohasharray
102898 +show_header_4722 show_header 3 4722 &ati_create_gatt_pages_4722
102899 +gfs2_bit_search_4728 gfs2_bit_search 0-2 4728 NULL
102900 +ll_rw_offset_stats_seq_write_4736 ll_rw_offset_stats_seq_write 3 4736 NULL nohasharray
102901 +bitmap_startwrite_4736 bitmap_startwrite 2 4736 &ll_rw_offset_stats_seq_write_4736
102902 +__find_free_cblock_4741 __find_free_cblock 2 4741 NULL
102903 +lu_buf_alloc_4753 lu_buf_alloc 2 4753 NULL
102904 +find_next_best_node_4774 find_next_best_node 1-0 4774 NULL nohasharray
102905 +pwr_rcvd_bcns_cnt_read_4774 pwr_rcvd_bcns_cnt_read 3 4774 &find_next_best_node_4774
102906 +btrfs_del_items_4791 btrfs_del_items 0 4791 NULL nohasharray
102907 +create_subvol_4791 create_subvol 4 4791 &btrfs_del_items_4791
102908 +ncp__vol2io_4804 ncp__vol2io 5 4804 NULL
102909 +repair_io_failure_4815 repair_io_failure 4-3 4815 NULL
102910 +comedi_buf_write_free_4847 comedi_buf_write_free 2 4847 NULL
102911 +gigaset_if_receive_4861 gigaset_if_receive 3 4861 NULL
102912 +key_tx_spec_read_4862 key_tx_spec_read 3 4862 NULL
102913 +get_new_location_4866 get_new_location 0 4866 NULL
102914 +ocfs2_defrag_extent_4873 ocfs2_defrag_extent 3-2 4873 NULL
102915 +hid_register_field_4874 hid_register_field 2-3 4874 NULL
102916 +vga_arb_read_4886 vga_arb_read 3 4886 NULL
102917 +ntfs_rl_insert_4931 ntfs_rl_insert 4-2 4931 NULL
102918 +ieee80211_if_fmt_ave_beacon_4941 ieee80211_if_fmt_ave_beacon 3 4941 NULL
102919 +ocfs2_should_refresh_lock_res_4958 ocfs2_should_refresh_lock_res 0 4958 NULL
102920 +compat_rawv6_setsockopt_4967 compat_rawv6_setsockopt 5 4967 NULL
102921 +skb_network_header_len_4971 skb_network_header_len 0 4971 NULL
102922 +ieee80211_if_fmt_dot11MeshHWMPconfirmationInterval_4976 ieee80211_if_fmt_dot11MeshHWMPconfirmationInterval 3 4976 NULL
102923 +do_sync_read_4977 do_sync_read 0 4977 NULL
102924 +vmw_surface_define_size_4993 vmw_surface_define_size 0 4993 NULL
102925 +compat_SyS_ipc_5000 compat_SyS_ipc 3 5000 NULL
102926 +do_mincore_5018 do_mincore 0-2-1 5018 NULL
102927 +btrfs_punch_hole_5041 btrfs_punch_hole 2 5041 NULL
102928 +cfg80211_rx_mgmt_5056 cfg80211_rx_mgmt 5 5056 NULL
102929 +ocfs2_check_range_for_holes_5066 ocfs2_check_range_for_holes 3-2 5066 NULL
102930 +snd_mixart_BA1_read_5082 snd_mixart_BA1_read 5 5082 NULL
102931 +snd_emu10k1_ptr20_read_5087 snd_emu10k1_ptr20_read 0 5087 NULL
102932 +get_random_bytes_5091 get_random_bytes 2 5091 NULL nohasharray
102933 +kfifo_copy_from_user_5091 kfifo_copy_from_user 4-3-0 5091 &get_random_bytes_5091 nohasharray
102934 +blk_rq_sectors_5091 blk_rq_sectors 0 5091 &kfifo_copy_from_user_5091
102935 +sound_write_5102 sound_write 3 5102 NULL
102936 +clear_dirty_5105 clear_dirty 3 5105 NULL
102937 +i40e_dbg_netdev_ops_write_5117 i40e_dbg_netdev_ops_write 3 5117 NULL
102938 +qib_7220_handle_hwerrors_5142 qib_7220_handle_hwerrors 3 5142 NULL
102939 +ufs_add_fragments_5144 ufs_add_fragments 2 5144 NULL
102940 +ocfs2_inode_lock_full_nested_5148 ocfs2_inode_lock_full_nested 0 5148 NULL
102941 +__uwb_addr_print_5161 __uwb_addr_print 2 5161 NULL
102942 +iwl_dbgfs_status_read_5171 iwl_dbgfs_status_read 3 5171 NULL
102943 +acpi_pcc_get_sqty_5176 acpi_pcc_get_sqty 0 5176 NULL
102944 +ppp_cp_parse_cr_5214 ppp_cp_parse_cr 4 5214 NULL nohasharray
102945 +r600_mip_minify_5214 r600_mip_minify 2-1-0 5214 &ppp_cp_parse_cr_5214
102946 +dwc2_hcd_urb_alloc_5217 dwc2_hcd_urb_alloc 2 5217 NULL
102947 +ath6kl_debug_roam_tbl_event_5224 ath6kl_debug_roam_tbl_event 3 5224 NULL
102948 +nouveau_fb_create__5244 nouveau_fb_create_ 5 5244 NULL
102949 +gfn_to_hva_memslot_5265 gfn_to_hva_memslot 2 5265 NULL
102950 +btrfs_alloc_reserved_file_extent_5274 btrfs_alloc_reserved_file_extent 0 5274 NULL
102951 +iommu_domain_identity_map_5284 iommu_domain_identity_map 2-3 5284 NULL
102952 +alloc_cache_blocks_with_hash_5285 alloc_cache_blocks_with_hash 2 5285 NULL
102953 +usb_descriptor_fillbuf_5302 usb_descriptor_fillbuf 0 5302 NULL
102954 +__gfn_to_hva_memslot_5304 __gfn_to_hva_memslot 0-2 5304 NULL
102955 +r592_write_fifo_pio_5315 r592_write_fifo_pio 3 5315 NULL
102956 +sbc_get_write_same_sectors_5317 sbc_get_write_same_sectors 0 5317 NULL
102957 +pwr_elp_enter_read_5324 pwr_elp_enter_read 3 5324 NULL
102958 +allocate_cnodes_5329 allocate_cnodes 1 5329 NULL
102959 +vm_insert_pfn_5341 vm_insert_pfn 3-0 5341 NULL
102960 +cq_free_res_5355 cq_free_res 5 5355 NULL
102961 +ps_pspoll_utilization_read_5361 ps_pspoll_utilization_read 3 5361 NULL
102962 +cciss_allocate_sg_chain_blocks_5368 cciss_allocate_sg_chain_blocks 2-3 5368 NULL
102963 +kvm_pin_pages_5369 kvm_pin_pages 2-0 5369 NULL
102964 +bitmap_fold_5396 bitmap_fold 4 5396 NULL
102965 +security_inode_init_security_5408 security_inode_init_security 0 5408 NULL
102966 +__resolve_indirect_refs_5409 __resolve_indirect_refs 0 5409 NULL
102967 +nilfs_palloc_entries_per_group_5418 nilfs_palloc_entries_per_group 0 5418 NULL
102968 +check_item_in_log_5440 check_item_in_log 0 5440 NULL
102969 +__split_bvec_across_targets_5454 __split_bvec_across_targets 3 5454 NULL
102970 +xfs_efd_init_5463 xfs_efd_init 3 5463 NULL
102971 +xfs_efi_init_5476 xfs_efi_init 2 5476 NULL
102972 +ubi_leb_write_5478 ubi_leb_write 4-5 5478 NULL
102973 +cifs_security_flags_proc_write_5484 cifs_security_flags_proc_write 3 5484 NULL
102974 +tty_write_5494 tty_write 3 5494 NULL
102975 +tomoyo_update_domain_5498 tomoyo_update_domain 2 5498 NULL nohasharray
102976 +ieee80211_if_fmt_last_beacon_5498 ieee80211_if_fmt_last_beacon 3 5498 &tomoyo_update_domain_5498
102977 +__max_nr_grant_frames_5505 __max_nr_grant_frames 0 5505 NULL
102978 +ieee80211_if_fmt_auto_open_plinks_5534 ieee80211_if_fmt_auto_open_plinks 3 5534 NULL
102979 +iommu_prepare_identity_map_5540 iommu_prepare_identity_map 2-3 5540 NULL
102980 +get_entry_msg_len_5552 get_entry_msg_len 0 5552 NULL
102981 +le_readq_5557 le_readq 0 5557 NULL
102982 +inw_5558 inw 0 5558 NULL
102983 +bioset_create_5580 bioset_create 1 5580 NULL
102984 +domain_sg_mapping_5586 domain_sg_mapping 4 5586 NULL
102985 +oz_ep_alloc_5587 oz_ep_alloc 1 5587 NULL
102986 +ldm_frag_add_5611 ldm_frag_add 2 5611 NULL
102987 +compat_copy_entries_5617 compat_copy_entries 0 5617 NULL
102988 +SYSC_init_module_5626 SYSC_init_module 2 5626 NULL
102989 +iterate_extent_inodes_5631 iterate_extent_inodes 0 5631 NULL
102990 +SYSC_fsetxattr_5639 SYSC_fsetxattr 4 5639 NULL
102991 +ext4_xattr_get_5661 ext4_xattr_get 0 5661 NULL
102992 +posix_clock_register_5662 posix_clock_register 2 5662 NULL
102993 +kgdb_arch_pc_5673 kgdb_arch_pc 0 5673 NULL
102994 +wb_clear_dirty_5684 wb_clear_dirty 2 5684 NULL
102995 +get_arg_5694 get_arg 3 5694 NULL
102996 +subbuf_read_actor_5708 subbuf_read_actor 3 5708 NULL
102997 +ntfs_attr_record_resize_5720 ntfs_attr_record_resize 0 5720 NULL
102998 +vmw_kms_readback_5727 vmw_kms_readback 6 5727 NULL
102999 +rts51x_transfer_data_partial_5735 rts51x_transfer_data_partial 6 5735 NULL
103000 +ubi_calc_fm_size_5749 ubi_calc_fm_size 0 5749 NULL
103001 +sctp_setsockopt_autoclose_5775 sctp_setsockopt_autoclose 3 5775 NULL
103002 +__vxge_hw_blockpool_malloc_5786 __vxge_hw_blockpool_malloc 2 5786 NULL
103003 +nvme_trans_bdev_char_page_5797 nvme_trans_bdev_char_page 3 5797 NULL
103004 +skb_copy_datagram_iovec_5806 skb_copy_datagram_iovec 2-4 5806 NULL
103005 +nv50_disp_pioc_create__5812 nv50_disp_pioc_create_ 5 5812 NULL
103006 +ceph_x_encrypt_buflen_5829 ceph_x_encrypt_buflen 0-1 5829 NULL
103007 +ceph_msg_new_5846 ceph_msg_new 2 5846 NULL
103008 +setup_req_5848 setup_req 3 5848 NULL
103009 +ria_page_count_5849 ria_page_count 0 5849 NULL
103010 +rx_filter_max_arp_queue_dep_read_5851 rx_filter_max_arp_queue_dep_read 3 5851 NULL
103011 +config_buf_5862 config_buf 0 5862 NULL
103012 +ext4_ext_correct_indexes_5865 ext4_ext_correct_indexes 0 5865 NULL
103013 +paging64_walk_addr_5887 paging64_walk_addr 3 5887 NULL
103014 +scan_bitmap_5888 scan_bitmap 3 5888 NULL
103015 +lprocfs_fid_width_seq_write_5889 lprocfs_fid_width_seq_write 3 5889 NULL
103016 +port_show_regs_5904 port_show_regs 3 5904 NULL
103017 +rbd_segment_length_5907 rbd_segment_length 0-3-2 5907 NULL
103018 +uhci_debug_read_5911 uhci_debug_read 3 5911 NULL
103019 +lbs_highsnr_read_5931 lbs_highsnr_read 3 5931 NULL
103020 +ps_poll_ps_poll_timeouts_read_5934 ps_poll_ps_poll_timeouts_read 3 5934 NULL
103021 +edac_device_alloc_ctl_info_5941 edac_device_alloc_ctl_info 1 5941 NULL
103022 +find_parent_nodes_5948 find_parent_nodes 0 5948 NULL
103023 +ll_statahead_one_5962 ll_statahead_one 3 5962 NULL
103024 +__apu_get_register_5967 __apu_get_register 0 5967 NULL
103025 +ieee80211_if_fmt_rc_rateidx_mask_5ghz_5971 ieee80211_if_fmt_rc_rateidx_mask_5ghz 3 5971 NULL
103026 +native_pte_val_5978 native_pte_val 0 5978 NULL
103027 +jbd2_journal_stop_5979 jbd2_journal_stop 0 5979 NULL
103028 +ntfs_rl_append_6037 ntfs_rl_append 4-2 6037 NULL
103029 +da9052_request_irq_6058 da9052_request_irq 2 6058 NULL nohasharray
103030 +device_add_attributes_6058 device_add_attributes 0 6058 &da9052_request_irq_6058
103031 +alloc_msg_6072 alloc_msg 1 6072 NULL
103032 +sctp_setsockopt_connectx_6073 sctp_setsockopt_connectx 3 6073 NULL
103033 +rts51x_ms_rw_multi_sector_6076 rts51x_ms_rw_multi_sector 3-4 6076 NULL
103034 +md_trim_bio_6078 md_trim_bio 2 6078 NULL
103035 +finish_inode_if_needed_6098 finish_inode_if_needed 0 6098 NULL
103036 +ipmi_addr_length_6110 ipmi_addr_length 0 6110 NULL
103037 +dfs_global_file_write_6112 dfs_global_file_write 3 6112 NULL
103038 +nouveau_parent_create__6131 nouveau_parent_create_ 7 6131 NULL
103039 +__btrfs_commit_inode_delayed_items_6150 __btrfs_commit_inode_delayed_items 0 6150 NULL
103040 +ieee80211_if_fmt_beacon_timeout_6153 ieee80211_if_fmt_beacon_timeout 3 6153 NULL
103041 +ivtv_copy_buf_to_user_6159 ivtv_copy_buf_to_user 4 6159 NULL
103042 +vdma_mem_alloc_6171 vdma_mem_alloc 1 6171 NULL
103043 +wl1251_cmd_template_set_6172 wl1251_cmd_template_set 4 6172 NULL
103044 +paging64_walk_addr_generic_6180 paging64_walk_addr_generic 4 6180 NULL
103045 +SyS_setgroups_6182 SyS_setgroups 1 6182 NULL
103046 +__add_pin_to_irq_node_6188 __add_pin_to_irq_node 2 6188 NULL
103047 +qp_host_get_user_memory_6189 qp_host_get_user_memory 1-2 6189 NULL
103048 +cl_sync_io_wait_6196 cl_sync_io_wait 0 6196 NULL
103049 +i915_gem_execbuffer_move_to_gpu_6197 i915_gem_execbuffer_move_to_gpu 0 6197 NULL
103050 +mxt_show_instance_6207 mxt_show_instance 2-0 6207 NULL
103051 +v4l2_ctrl_new_std_menu_6221 v4l2_ctrl_new_std_menu 4 6221 NULL
103052 +mqueue_read_file_6228 mqueue_read_file 3 6228 NULL
103053 +f_hidg_read_6238 f_hidg_read 3 6238 NULL
103054 +changed_ref_6242 changed_ref 0 6242 NULL
103055 +fbcon_prepare_logo_6246 fbcon_prepare_logo 5 6246 NULL
103056 +ext4_ext_split_6249 ext4_ext_split 0 6249 NULL
103057 +pcpu_next_pop_6277 pcpu_next_pop 4 6277 NULL
103058 +tx_tx_start_null_frame_read_6281 tx_tx_start_null_frame_read 3 6281 NULL
103059 +snd_hda_override_conn_list_6282 snd_hda_override_conn_list 3-0 6282 NULL nohasharray
103060 +xenbus_file_write_6282 xenbus_file_write 3 6282 &snd_hda_override_conn_list_6282
103061 +posix_acl_fix_xattr_to_user_6283 posix_acl_fix_xattr_to_user 2 6283 NULL
103062 +paging64_gva_to_gpa_nested_6287 paging64_gva_to_gpa_nested 2 6287 NULL
103063 +qlcnic_sriov_alloc_bc_msg_6309 qlcnic_sriov_alloc_bc_msg 2 6309 NULL
103064 +exclude_super_stripes_6326 exclude_super_stripes 0 6326 NULL
103065 +SyS_mincore_6329 SyS_mincore 2-1 6329 NULL nohasharray
103066 +hfa384x_inw_6329 hfa384x_inw 0 6329 &SyS_mincore_6329
103067 +fuse_get_req_for_background_6337 fuse_get_req_for_background 2 6337 NULL
103068 +ucs2_strnlen_6342 ucs2_strnlen 0 6342 NULL
103069 +regcache_sync_block_raw_6350 regcache_sync_block_raw 5-4 6350 NULL
103070 +mei_dbgfs_read_devstate_6352 mei_dbgfs_read_devstate 3 6352 NULL
103071 +_proc_do_string_6376 _proc_do_string 2 6376 NULL
103072 +osd_req_read_sg_kern_6378 osd_req_read_sg_kern 5 6378 NULL
103073 +msb_write_block_6379 msb_write_block 3 6379 NULL
103074 +BcmFlash2xBulkRead_6395 BcmFlash2xBulkRead 0 6395 NULL
103075 +posix_acl_fix_xattr_userns_6420 posix_acl_fix_xattr_userns 4 6420 NULL
103076 +add_transaction_credits_6422 add_transaction_credits 2-3 6422 NULL
103077 +ipr_change_queue_depth_6431 ipr_change_queue_depth 2 6431 NULL
103078 +__alloc_bootmem_node_nopanic_6432 __alloc_bootmem_node_nopanic 2 6432 NULL
103079 +add_to_list_6433 add_to_list 0 6433 NULL
103080 +paging32_gva_to_gpa_nested_6442 paging32_gva_to_gpa_nested 2 6442 NULL
103081 +i915_gem_object_wait_rendering_6446 i915_gem_object_wait_rendering 0 6446 NULL
103082 +mlx4_ib_reg_user_mr_6471 mlx4_ib_reg_user_mr 2-3 6471 NULL
103083 +ieee80211_if_fmt_dot11MeshMaxRetries_6476 ieee80211_if_fmt_dot11MeshMaxRetries 3 6476 NULL
103084 +qp_memcpy_from_queue_6479 qp_memcpy_from_queue 5-4 6479 NULL
103085 +cipso_v4_map_lvl_hton_6490 cipso_v4_map_lvl_hton 0 6490 NULL
103086 +dbg_intr_buf_6501 dbg_intr_buf 2 6501 NULL
103087 +mei_read_6507 mei_read 3 6507 NULL
103088 +__start_delalloc_inodes_6528 __start_delalloc_inodes 0 6528 NULL
103089 +rndis_set_oid_6547 rndis_set_oid 4 6547 NULL
103090 +wdm_read_6549 wdm_read 3 6549 NULL
103091 +dm_stats_create_6551 dm_stats_create 4-2-3 6551 NULL
103092 +fb_alloc_cmap_6554 fb_alloc_cmap 2 6554 NULL
103093 +SyS_semtimedop_6563 SyS_semtimedop 3 6563 NULL
103094 +SyS_fcntl64_6582 SyS_fcntl64 3 6582 NULL
103095 +snd_pcm_hw_refine_old_user_6586 snd_pcm_hw_refine_old_user 0 6586 NULL
103096 +btrfs_start_all_delalloc_inodes_6596 btrfs_start_all_delalloc_inodes 0 6596 NULL
103097 +snmp_mib_init_6604 snmp_mib_init 2-3 6604 NULL
103098 +ecryptfs_filldir_6622 ecryptfs_filldir 3 6622 NULL
103099 +xfs_do_div_6649 xfs_do_div 0-2 6649 NULL
103100 +journal_dirty_metadata_6658 journal_dirty_metadata 0 6658 NULL
103101 +process_rcvd_data_6679 process_rcvd_data 3 6679 NULL
103102 +btrfs_lookup_csums_range_6696 btrfs_lookup_csums_range 2-3-0 6696 NULL
103103 +ps_pspoll_max_apturn_read_6699 ps_pspoll_max_apturn_read 3 6699 NULL
103104 +bnad_debugfs_write_regrd_6706 bnad_debugfs_write_regrd 3 6706 NULL
103105 +mpeg_read_6708 mpeg_read 3 6708 NULL
103106 +ibmpex_query_sensor_count_6709 ibmpex_query_sensor_count 0 6709 NULL
103107 +set_orig_insn_6712 set_orig_insn 3 6712 NULL
103108 +video_proc_write_6724 video_proc_write 3 6724 NULL
103109 +posix_acl_xattr_count_6725 posix_acl_xattr_count 0-1 6725 NULL
103110 +ocfs2_insert_extent_6737 ocfs2_insert_extent 0 6737 NULL
103111 +btrfs_inode_delayed_dir_index_count_6759 btrfs_inode_delayed_dir_index_count 0 6759 NULL
103112 +kobject_add_varg_6781 kobject_add_varg 0 6781 NULL
103113 +iwl_dbgfs_channels_read_6784 iwl_dbgfs_channels_read 3 6784 NULL
103114 +ieee80211_if_read_6785 ieee80211_if_read 3 6785 NULL
103115 +zone_spanned_pages_in_node_6787 zone_spanned_pages_in_node 0-3-4 6787 NULL
103116 +hdlcdrv_register_6792 hdlcdrv_register 2 6792 NULL
103117 +tx_tx_done_data_read_6799 tx_tx_done_data_read 3 6799 NULL
103118 +ocfs2_calc_refcount_meta_credits_6802 ocfs2_calc_refcount_meta_credits 0 6802 NULL
103119 +lbs_rdrf_write_6826 lbs_rdrf_write 3 6826 NULL
103120 +make_8259A_irq_6828 make_8259A_irq 1 6828 NULL
103121 +calc_pages_for_6838 calc_pages_for 0-1-2 6838 NULL
103122 +mon_bin_read_6841 mon_bin_read 3 6841 NULL
103123 +snd_cs4281_BA0_read_6847 snd_cs4281_BA0_read 5 6847 NULL
103124 +ecryptfs_write_lower_6870 ecryptfs_write_lower 4 6870 NULL
103125 +dio_complete_6879 dio_complete 0-2-3 6879 NULL
103126 +ieee80211_if_fmt_path_refresh_time_6888 ieee80211_if_fmt_path_refresh_time 3 6888 NULL nohasharray
103127 +raw_seticmpfilter_6888 raw_seticmpfilter 3 6888 &ieee80211_if_fmt_path_refresh_time_6888
103128 +dlmfs_file_write_6892 dlmfs_file_write 3 6892 NULL
103129 +ext4_inode_bitmap_6902 ext4_inode_bitmap 0 6902 NULL
103130 +spi_show_regs_6911 spi_show_regs 3 6911 NULL nohasharray
103131 +proc_sessionid_read_6911 proc_sessionid_read 3 6911 &spi_show_regs_6911 nohasharray
103132 +acm_alloc_minor_6911 acm_alloc_minor 0 6911 &proc_sessionid_read_6911
103133 +__kfifo_dma_in_finish_r_6913 __kfifo_dma_in_finish_r 2-3 6913 NULL
103134 +do_msgrcv_6921 do_msgrcv 3 6921 NULL
103135 +__vxge_hw_mempool_create_6923 __vxge_hw_mempool_create 3-2-6 6923 NULL
103136 +cache_do_downcall_6926 cache_do_downcall 3 6926 NULL
103137 +ipath_verbs_send_dma_6929 ipath_verbs_send_dma 6 6929 NULL
103138 +qsfp_cks_6945 qsfp_cks 2-0 6945 NULL
103139 +tg3_nvram_write_block_unbuffered_6955 tg3_nvram_write_block_unbuffered 3 6955 NULL
103140 +pch_uart_hal_read_6961 pch_uart_hal_read 0 6961 NULL
103141 +videobuf_dma_init_kernel_6963 videobuf_dma_init_kernel 3 6963 NULL
103142 +i40e_dbg_dump_write_6973 i40e_dbg_dump_write 3 6973 NULL nohasharray
103143 +rsa_extract_mpi_6973 rsa_extract_mpi 5 6973 &i40e_dbg_dump_write_6973
103144 +crypto_authenc_esn_setkey_6985 crypto_authenc_esn_setkey 3 6985 NULL
103145 +request_key_async_6990 request_key_async 4 6990 NULL
103146 +tpl_write_6998 tpl_write 3 6998 NULL
103147 +r871x_set_wpa_ie_7000 r871x_set_wpa_ie 3 7000 NULL
103148 +log_wait_commit_7005 log_wait_commit 0 7005 NULL
103149 +cipso_v4_gentag_enum_7006 cipso_v4_gentag_enum 0 7006 NULL
103150 +tracing_cpumask_read_7010 tracing_cpumask_read 3 7010 NULL
103151 +ld_usb_write_7022 ld_usb_write 3 7022 NULL
103152 +wimax_msg_7030 wimax_msg 4 7030 NULL
103153 +ipath_get_base_info_7043 ipath_get_base_info 3 7043 NULL
103154 +snd_pcm_oss_bytes_7051 snd_pcm_oss_bytes 2 7051 NULL
103155 +hci_sock_recvmsg_7072 hci_sock_recvmsg 4 7072 NULL
103156 +event_enable_read_7074 event_enable_read 3 7074 NULL
103157 +ip_vs_sync_conn_7075 ip_vs_sync_conn 3 7075 NULL
103158 +beacon_interval_read_7091 beacon_interval_read 3 7091 NULL
103159 +pipeline_enc_rx_stat_fifo_int_read_7107 pipeline_enc_rx_stat_fifo_int_read 3 7107 NULL
103160 +check_header_7108 check_header 0 7108 NULL
103161 +osc_resend_count_seq_write_7120 osc_resend_count_seq_write 3 7120 NULL
103162 +qib_format_hwerrors_7133 qib_format_hwerrors 5 7133 NULL
103163 +kvm_mmu_notifier_test_young_7139 kvm_mmu_notifier_test_young 3 7139 NULL
103164 +ipv6_recv_rxpmtu_7142 ipv6_recv_rxpmtu 3 7142 NULL
103165 +qlcnic_enable_msix_7144 qlcnic_enable_msix 2 7144 NULL
103166 +ocfs2_get_left_path_7159 ocfs2_get_left_path 0 7159 NULL
103167 +core_alua_write_tpg_metadata_7168 core_alua_write_tpg_metadata 3 7168 NULL
103168 +ext3_xattr_ibody_list_7201 ext3_xattr_ibody_list 3-0 7201 NULL
103169 +__alloc_objio_seg_7203 __alloc_objio_seg 1 7203 NULL
103170 +get_param_h_7247 get_param_h 0 7247 NULL
103171 +af_alg_make_sg_7254 af_alg_make_sg 3-0 7254 NULL
103172 +hdlc_loop_7255 hdlc_loop 0 7255 NULL
103173 +vm_mmap_pgoff_7259 vm_mmap_pgoff 0 7259 NULL
103174 +snd_mask_refine_7267 snd_mask_refine 0 7267 NULL
103175 +f_midi_start_ep_7270 f_midi_start_ep 0 7270 NULL
103176 +dma_ops_alloc_addresses_7272 dma_ops_alloc_addresses 3-4-5-0 7272 NULL
103177 +rx_rate_rx_frames_per_rates_read_7282 rx_rate_rx_frames_per_rates_read 3 7282 NULL
103178 +get_string_7302 get_string 0 7302 NULL
103179 +wb_remove_mapping_7307 wb_remove_mapping 2 7307 NULL
103180 +wait_on_sync_kiocb_7327 wait_on_sync_kiocb 0 7327 NULL
103181 +mgmt_control_7349 mgmt_control 3 7349 NULL
103182 +max8998_irq_domain_map_7359 max8998_irq_domain_map 2 7359 NULL
103183 +i915_gem_do_execbuffer_7362 i915_gem_do_execbuffer 0 7362 NULL nohasharray
103184 +ext3_free_blocks_7362 ext3_free_blocks 3-4 7362 &i915_gem_do_execbuffer_7362
103185 +at_est2timeout_7365 at_est2timeout 0-1 7365 NULL
103186 +ieee80211_if_read_dot11MeshHWMPactivePathTimeout_7368 ieee80211_if_read_dot11MeshHWMPactivePathTimeout 3 7368 NULL
103187 +schedule_timeout_7371 schedule_timeout 0 7371 NULL
103188 +ath10k_read_fw_stats_7387 ath10k_read_fw_stats 3 7387 NULL
103189 +hweight_long_7388 hweight_long 1-0 7388 NULL
103190 +sl_change_mtu_7396 sl_change_mtu 2 7396 NULL
103191 +_ore_add_stripe_unit_7399 _ore_add_stripe_unit 6-3 7399 NULL
103192 +readb_7401 readb 0 7401 NULL
103193 +drm_property_create_blob_7414 drm_property_create_blob 2 7414 NULL
103194 +ip_options_get_alloc_7448 ip_options_get_alloc 1 7448 NULL
103195 +SYSC_setgroups_7454 SYSC_setgroups 1 7454 NULL
103196 +rt2x00debug_read_queue_stats_7455 rt2x00debug_read_queue_stats 3 7455 NULL
103197 +l2tp_ip6_sendmsg_7461 l2tp_ip6_sendmsg 4 7461 NULL
103198 +ReadHSCX_7471 ReadHSCX 0 7471 NULL nohasharray
103199 +garp_request_join_7471 garp_request_join 4 7471 &ReadHSCX_7471
103200 +snd_pcm_lib_read1_7491 snd_pcm_lib_read1 0-3 7491 NULL
103201 +iwl_mvm_power_dbgfs_read_7502 iwl_mvm_power_dbgfs_read 0 7502 NULL
103202 +sdhci_alloc_host_7509 sdhci_alloc_host 2 7509 NULL nohasharray
103203 +ahash_instance_headroom_7509 ahash_instance_headroom 0 7509 &sdhci_alloc_host_7509
103204 +array_zalloc_7519 array_zalloc 2-1 7519 NULL
103205 +btrfs_insert_xattr_item_7545 btrfs_insert_xattr_item 0 7545 NULL
103206 +goal_in_my_reservation_7553 goal_in_my_reservation 3 7553 NULL
103207 +smk_read_mapped_7562 smk_read_mapped 3 7562 NULL
103208 +cfs_cpt_num_estimate_7571 cfs_cpt_num_estimate 0 7571 NULL
103209 +ext4_ext_insert_extent_7576 ext4_ext_insert_extent 0 7576 NULL
103210 +btrfs_block_rsv_add_7579 btrfs_block_rsv_add 3-0 7579 NULL
103211 +ext3_try_to_allocate_7590 ext3_try_to_allocate 5-3-0 7590 NULL
103212 +ocfs2_lock_create_7612 ocfs2_lock_create 0 7612 NULL
103213 +create_dir_7614 create_dir 0 7614 NULL nohasharray
103214 +groups_alloc_7614 groups_alloc 1 7614 &create_dir_7614
103215 +_rtw_zmalloc_7636 _rtw_zmalloc 1 7636 NULL
103216 +fault_inject_write_7662 fault_inject_write 3 7662 NULL
103217 +acpi_ex_allocate_name_string_7685 acpi_ex_allocate_name_string 1-2 7685 NULL
103218 +acpi_ns_get_pathname_length_7699 acpi_ns_get_pathname_length 0 7699 NULL
103219 +dev_write_7708 dev_write 3 7708 NULL
103220 +unmap_region_7709 unmap_region 1 7709 NULL
103221 +dbg_check_cats_7713 dbg_check_cats 0 7713 NULL
103222 +pci_raw_set_power_state_7729 pci_raw_set_power_state 0 7729 NULL
103223 +vxge_device_register_7752 vxge_device_register 4 7752 NULL
103224 +ubi_io_read_vid_hdr_7766 ubi_io_read_vid_hdr 0 7766 NULL
103225 +paths_from_inode_7774 paths_from_inode 0 7774 NULL
103226 +alloc_candev_7776 alloc_candev 1-2 7776 NULL
103227 +dfs_global_file_read_7787 dfs_global_file_read 3 7787 NULL
103228 +bnx2_nvram_write_7790 bnx2_nvram_write 2-4 7790 NULL
103229 +diva_os_copy_from_user_7792 diva_os_copy_from_user 4 7792 NULL nohasharray
103230 +lustre_packed_msg_size_7792 lustre_packed_msg_size 0 7792 &diva_os_copy_from_user_7792
103231 +ubifs_leb_read_7828 ubifs_leb_read 0 7828 NULL
103232 +cfs_trace_dump_debug_buffer_usrstr_7861 cfs_trace_dump_debug_buffer_usrstr 2 7861 NULL
103233 +tipc_alloc_entry_7875 tipc_alloc_entry 2 7875 NULL
103234 +btrfs_find_space_for_alloc_7876 btrfs_find_space_for_alloc 2 7876 NULL
103235 +config_desc_7878 config_desc 0 7878 NULL
103236 +dvb_dmxdev_read_sec_7892 dvb_dmxdev_read_sec 4 7892 NULL
103237 +xfs_trans_get_efi_7898 xfs_trans_get_efi 2 7898 NULL
103238 +ext3_group_extend_7911 ext3_group_extend 3 7911 NULL
103239 +libfc_host_alloc_7917 libfc_host_alloc 2 7917 NULL
103240 +f_hidg_write_7932 f_hidg_write 3 7932 NULL
103241 +io_apic_setup_irq_pin_once_7934 io_apic_setup_irq_pin_once 1-2 7934 NULL
103242 +compare_refs_7938 compare_refs 0 7938 NULL
103243 +fsnotify_7943 fsnotify 0 7943 NULL
103244 +hash_netiface6_expire_7944 hash_netiface6_expire 3 7944 NULL
103245 +integrity_digsig_verify_7956 integrity_digsig_verify 3 7956 NULL
103246 +smk_write_load_self_7958 smk_write_load_self 3 7958 NULL
103247 +bch_btree_to_text_7960 bch_btree_to_text 2 7960 NULL
103248 +fixup_inode_link_count_8002 fixup_inode_link_count 0 8002 NULL
103249 +extend_or_restart_transaction_8008 extend_or_restart_transaction 0 8008 NULL
103250 +tt3650_ci_msg_locked_8013 tt3650_ci_msg_locked 4 8013 NULL
103251 +vcs_read_8017 vcs_read 3 8017 NULL
103252 +vhost_add_used_and_signal_n_8038 vhost_add_used_and_signal_n 4 8038 NULL
103253 +ms_read_multiple_pages_8052 ms_read_multiple_pages 5-4 8052 NULL
103254 +dgrp_mon_read_8065 dgrp_mon_read 3 8065 NULL
103255 +leb_read_lock_8070 leb_read_lock 0 8070 NULL
103256 +spi_write_then_read_8073 spi_write_then_read 5-3 8073 NULL
103257 +alloc_targets_8074 alloc_targets 2 8074 NULL nohasharray
103258 +qla4xxx_post_ping_evt_work_8074 qla4xxx_post_ping_evt_work 4 8074 &alloc_targets_8074
103259 +ext4_ext_map_blocks_8078 ext4_ext_map_blocks 0 8078 NULL
103260 +venus_lookup_8121 venus_lookup 4 8121 NULL
103261 +ieee80211_if_fmt_num_buffered_multicast_8127 ieee80211_if_fmt_num_buffered_multicast 3 8127 NULL
103262 +xfs_iomap_prealloc_size_8141 xfs_iomap_prealloc_size 3 8141 NULL
103263 +dma_map_area_8178 dma_map_area 3-2-5-0 8178 NULL
103264 +ore_truncate_8181 ore_truncate 3 8181 NULL
103265 +__sk_mem_schedule_8185 __sk_mem_schedule 2 8185 NULL
103266 +ieee80211_if_fmt_dot11MeshHoldingTimeout_8187 ieee80211_if_fmt_dot11MeshHoldingTimeout 3 8187 NULL
103267 +update_cowonly_root_8200 update_cowonly_root 0 8200 NULL
103268 +recent_mt_proc_write_8206 recent_mt_proc_write 3 8206 NULL
103269 +__ocfs2_lock_refcount_tree_8207 __ocfs2_lock_refcount_tree 0 8207 NULL
103270 +rt2x00debug_write_bbp_8212 rt2x00debug_write_bbp 3 8212 NULL
103271 +ad7879_spi_multi_read_8218 ad7879_spi_multi_read 3 8218 NULL
103272 +play_iframe_8219 play_iframe 3 8219 NULL
103273 +create_log_8225 create_log 2 8225 NULL nohasharray
103274 +kvm_mmu_page_set_gfn_8225 kvm_mmu_page_set_gfn 2 8225 &create_log_8225
103275 +sctp_ssnmap_size_8228 sctp_ssnmap_size 0-1-2 8228 NULL
103276 +ceph_sync_write_8233 ceph_sync_write 4 8233 NULL
103277 +bnx2x_iov_get_max_queue_count_8235 bnx2x_iov_get_max_queue_count 0 8235 NULL
103278 +check_xattr_ref_inode_8244 check_xattr_ref_inode 0 8244 NULL
103279 +t3_init_l2t_8261 t3_init_l2t 1 8261 NULL
103280 +init_cdev_8274 init_cdev 1 8274 NULL
103281 +rproc_recovery_write_8281 rproc_recovery_write 3 8281 NULL
103282 +qib_decode_7220_err_8315 qib_decode_7220_err 3 8315 NULL
103283 +snd_pcm_update_state_8320 snd_pcm_update_state 0 8320 NULL
103284 +construct_key_and_link_8321 construct_key_and_link 4 8321 NULL
103285 +ipwireless_send_packet_8328 ipwireless_send_packet 4 8328 NULL
103286 +tracing_entries_read_8345 tracing_entries_read 3 8345 NULL
103287 +ieee80211_if_fmt_ht_opmode_8347 ieee80211_if_fmt_ht_opmode 3 8347 NULL
103288 +generic_write_sync_8358 generic_write_sync 0 8358 NULL
103289 +ping_getfrag_8360 ping_getfrag 4-3 8360 NULL
103290 +ath6kl_lrssi_roam_write_8362 ath6kl_lrssi_roam_write 3 8362 NULL
103291 +ocfs2_decrease_refcount_rec_8385 ocfs2_decrease_refcount_rec 0 8385 NULL
103292 +xdi_copy_from_user_8395 xdi_copy_from_user 4 8395 NULL
103293 +zd_rf_scnprint_id_8406 zd_rf_scnprint_id 0-3 8406 NULL
103294 +smk_write_change_rule_8411 smk_write_change_rule 3 8411 NULL nohasharray
103295 +uvc_v4l2_ioctl_8411 uvc_v4l2_ioctl 2 8411 &smk_write_change_rule_8411
103296 +pca953x_gpio_to_irq_8424 pca953x_gpio_to_irq 2 8424 NULL
103297 +irq_create_mapping_8437 irq_create_mapping 2-0 8437 NULL
103298 +generic_bin_search_8440 generic_bin_search 0 8440 NULL
103299 +ring_wait_for_space_8457 ring_wait_for_space 0 8457 NULL
103300 +dir_changed_8471 dir_changed 0 8471 NULL
103301 +afs_cell_lookup_8482 afs_cell_lookup 2 8482 NULL
103302 +fore200e_chunk_alloc_8501 fore200e_chunk_alloc 4-3 8501 NULL
103303 +batadv_tt_len_8502 batadv_tt_len 0-1 8502 NULL
103304 +dev_config_8506 dev_config 3 8506 NULL
103305 +ACL_to_cifs_posix_8509 ACL_to_cifs_posix 3 8509 NULL
103306 +opticon_process_data_packet_8524 opticon_process_data_packet 3 8524 NULL
103307 +alloc_pg_vec_8533 alloc_pg_vec 2 8533 NULL
103308 +ocfs2_read_virt_blocks_8538 ocfs2_read_virt_blocks 2-3 8538 NULL
103309 +user_on_off_8552 user_on_off 2 8552 NULL
103310 +profile_remove_8556 profile_remove 3 8556 NULL
103311 +remove_extent_backref_8559 remove_extent_backref 0 8559 NULL
103312 +cache_slow_downcall_8570 cache_slow_downcall 2 8570 NULL
103313 +isr_dma0_done_read_8574 isr_dma0_done_read 3 8574 NULL
103314 +tower_write_8580 tower_write 3 8580 NULL
103315 +ocfs2_reserve_local_alloc_bits_8581 ocfs2_reserve_local_alloc_bits 0 8581 NULL
103316 +cfs_cpt_number_8618 cfs_cpt_number 0 8618 NULL
103317 +shash_setkey_unaligned_8620 shash_setkey_unaligned 3 8620 NULL
103318 +iommu_unmap_8624 iommu_unmap 2-0 8624 NULL
103319 +it821x_firmware_command_8628 it821x_firmware_command 3 8628 NULL
103320 +scsi_dma_map_8632 scsi_dma_map 0 8632 NULL
103321 +fuse_send_write_pages_8636 fuse_send_write_pages 0-5 8636 NULL
103322 +generic_acl_set_8658 generic_acl_set 4 8658 NULL
103323 +mlx5_vzalloc_8663 mlx5_vzalloc 1 8663 NULL
103324 +dio_bio_alloc_8677 dio_bio_alloc 5 8677 NULL
103325 +lbs_bcnmiss_read_8678 lbs_bcnmiss_read 3 8678 NULL
103326 +tc3589x_gpio_irq_unmap_8680 tc3589x_gpio_irq_unmap 2 8680 NULL
103327 +rproc_trace_read_8686 rproc_trace_read 3 8686 NULL
103328 +skb_frag_size_8695 skb_frag_size 0 8695 NULL
103329 +arcfb_write_8702 arcfb_write 3 8702 NULL
103330 +i_size_read_8703 i_size_read 0 8703 NULL nohasharray
103331 +init_header_8703 init_header 0 8703 &i_size_read_8703
103332 +HDLC_irq_8709 HDLC_irq 2 8709 NULL
103333 +ctrl_out_8712 ctrl_out 5-3 8712 NULL
103334 +__create_free_space_inode_8724 __create_free_space_inode 0 8724 NULL
103335 +tracing_max_lat_write_8728 tracing_max_lat_write 3 8728 NULL
103336 +jffs2_acl_count_8729 jffs2_acl_count 0-1 8729 NULL
103337 +f_dupfd_8730 f_dupfd 1 8730 NULL
103338 +__create_irqs_8733 __create_irqs 2-1-0-3 8733 NULL
103339 +pca953x_gpio_irq_map_8737 pca953x_gpio_irq_map 2 8737 NULL
103340 +tx_tx_exch_expiry_read_8749 tx_tx_exch_expiry_read 3 8749 NULL
103341 +compound_order_8750 compound_order 0 8750 NULL
103342 +ocfs2_find_path_8754 ocfs2_find_path 0 8754 NULL
103343 +yurex_write_8761 yurex_write 3 8761 NULL
103344 +joydev_compat_ioctl_8765 joydev_compat_ioctl 2 8765 NULL
103345 +x32_arch_ptrace_8767 x32_arch_ptrace 3 8767 NULL
103346 +kstrtoint_from_user_8778 kstrtoint_from_user 2 8778 NULL
103347 +paging32_prefetch_gpte_8783 paging32_prefetch_gpte 4 8783 NULL
103348 +ext4_try_to_write_inline_data_8785 ext4_try_to_write_inline_data 3-4 8785 NULL
103349 +aligned_nrpages_8791 aligned_nrpages 0-1-2 8791 NULL
103350 +__bitmap_weight_8796 __bitmap_weight 0-2 8796 NULL
103351 +cpuset_common_file_read_8800 cpuset_common_file_read 5 8800 NULL
103352 +intel_ring_begin_8808 intel_ring_begin 0 8808 NULL
103353 +metronomefb_write_8823 metronomefb_write 3 8823 NULL
103354 +SyS_llistxattr_8824 SyS_llistxattr 3 8824 NULL
103355 +get_queue_depth_8833 get_queue_depth 0 8833 NULL
103356 +dvb_ringbuffer_pkt_next_8834 dvb_ringbuffer_pkt_next 0-2 8834 NULL
103357 +usb_ep_queue_8839 usb_ep_queue 0 8839 NULL
103358 +clear_bitset_8840 clear_bitset 2 8840 NULL
103359 +debug_debug1_read_8856 debug_debug1_read 3 8856 NULL
103360 +wa_nep_queue_8858 wa_nep_queue 2 8858 NULL
103361 +sk_memory_allocated_8882 sk_memory_allocated 0 8882 NULL
103362 +compressed_bio_size_8887 compressed_bio_size 0-2 8887 NULL
103363 +ab3100_get_set_reg_8890 ab3100_get_set_reg 3 8890 NULL nohasharray
103364 +tracing_max_lat_read_8890 tracing_max_lat_read 3 8890 &ab3100_get_set_reg_8890
103365 +xfs_contig_bits_8904 xfs_contig_bits 3-0 8904 NULL
103366 +sdio_max_byte_size_8907 sdio_max_byte_size 0 8907 NULL
103367 +sysfs_merge_group_8917 sysfs_merge_group 0 8917 NULL
103368 +write_file_ani_8918 write_file_ani 3 8918 NULL
103369 +layout_commit_8926 layout_commit 3 8926 NULL
103370 +adjust_priv_size_8935 adjust_priv_size 0-1 8935 NULL
103371 +driver_stats_read_8944 driver_stats_read 3 8944 NULL
103372 +lookup_zone_8956 lookup_zone 2 8956 NULL
103373 +read_file_tgt_stats_8959 read_file_tgt_stats 3 8959 NULL
103374 +seq_bitmap_list_8963 seq_bitmap_list 3 8963 NULL
103375 +usb_allocate_stream_buffers_8964 usb_allocate_stream_buffers 3 8964 NULL
103376 +qib_qsfp_dump_8966 qib_qsfp_dump 0-3 8966 NULL
103377 +venus_mkdir_8967 venus_mkdir 4 8967 NULL
103378 +seq_open_net_8968 seq_open_net 4 8968 NULL nohasharray
103379 +vol_cdev_read_8968 vol_cdev_read 3 8968 &seq_open_net_8968
103380 +bio_integrity_get_tag_8974 bio_integrity_get_tag 3 8974 NULL
103381 +btrfs_alloc_free_block_8986 btrfs_alloc_free_block 3-8 8986 NULL
103382 +jbd2_journal_blocks_per_page_9004 jbd2_journal_blocks_per_page 0 9004 NULL
103383 +il_dbgfs_clear_ucode_stats_write_9016 il_dbgfs_clear_ucode_stats_write 3 9016 NULL
103384 +sparse_index_alloc_9021 sparse_index_alloc 1 9021 NULL
103385 +snd_emu10k1_ptr_read_9026 snd_emu10k1_ptr_read 0-2 9026 NULL
103386 +fd_ioctl_9028 fd_ioctl 3 9028 NULL
103387 +nla_put_9042 nla_put 3 9042 NULL
103388 +offset_il_node_9059 offset_il_node 0 9059 NULL
103389 +snd_emu10k1_synth_copy_from_user_9061 snd_emu10k1_synth_copy_from_user 5-3 9061 NULL
103390 +snd_gus_dram_peek_9062 snd_gus_dram_peek 4 9062 NULL
103391 +fib_info_hash_alloc_9075 fib_info_hash_alloc 1 9075 NULL
103392 +create_queues_9088 create_queues 3-2 9088 NULL
103393 +ftdi_prepare_write_buffer_9093 ftdi_prepare_write_buffer 3 9093 NULL
103394 +adxl34x_spi_read_block_9108 adxl34x_spi_read_block 3 9108 NULL
103395 +alloc_slabmgmt_9109 alloc_slabmgmt 5 9109 NULL
103396 +caif_stream_sendmsg_9110 caif_stream_sendmsg 4 9110 NULL nohasharray
103397 +gfn_to_rmap_9110 gfn_to_rmap 3-2 9110 &caif_stream_sendmsg_9110
103398 +udf_direct_IO_9111 udf_direct_IO 4 9111 NULL
103399 +pmcraid_change_queue_depth_9116 pmcraid_change_queue_depth 2 9116 NULL
103400 +mq_remove_mapping_9124 mq_remove_mapping 2 9124 NULL
103401 +mlx4_alloc_resize_umem_9132 mlx4_alloc_resize_umem 3 9132 NULL
103402 +ext4_list_backups_9138 ext4_list_backups 0 9138 NULL
103403 +apei_resources_merge_9149 apei_resources_merge 0 9149 NULL
103404 +vb2_dma_sg_alloc_9157 vb2_dma_sg_alloc 2 9157 NULL
103405 +dbg_command_buf_9165 dbg_command_buf 2 9165 NULL
103406 +__btrfs_add_delayed_deletion_item_9177 __btrfs_add_delayed_deletion_item 0 9177 NULL
103407 +isr_irqs_read_9181 isr_irqs_read 3 9181 NULL
103408 +count_leading_zeros_9183 count_leading_zeros 0 9183 NULL
103409 +altera_swap_ir_9194 altera_swap_ir 2 9194 NULL
103410 +snd_m3_get_pointer_9206 snd_m3_get_pointer 0 9206 NULL
103411 +get_pfn_9207 get_pfn 1 9207 NULL
103412 +virtqueue_add_9217 virtqueue_add 4-5 9217 NULL
103413 +tx_tx_prepared_descs_read_9221 tx_tx_prepared_descs_read 3 9221 NULL
103414 +sctp_getsockopt_delayed_ack_9232 sctp_getsockopt_delayed_ack 2 9232 NULL
103415 +ext4_mark_iloc_dirty_9239 ext4_mark_iloc_dirty 0 9239 NULL
103416 +ocfs2_clear_ext_refcount_9256 ocfs2_clear_ext_refcount 4-0 9256 NULL
103417 +hfsplus_bnode_read_u16_9262 hfsplus_bnode_read_u16 0 9262 NULL
103418 +btrfs_search_slot_9264 btrfs_search_slot 0 9264 NULL
103419 +ocfs2_merge_rec_right_9267 ocfs2_merge_rec_right 0 9267 NULL
103420 +sparse_early_usemaps_alloc_node_9269 sparse_early_usemaps_alloc_node 4 9269 NULL
103421 +hdpvr_read_9273 hdpvr_read 3 9273 NULL
103422 +flakey_status_9274 flakey_status 5 9274 NULL
103423 +iwl_dbgfs_stations_read_9309 iwl_dbgfs_stations_read 3 9309 NULL
103424 +ceph_sync_setxattr_9310 ceph_sync_setxattr 4 9310 NULL
103425 +ieee80211_if_fmt_txpower_9334 ieee80211_if_fmt_txpower 3 9334 NULL
103426 +nvme_trans_fmt_get_parm_header_9340 nvme_trans_fmt_get_parm_header 2 9340 NULL
103427 +ocfs2_orphan_for_truncate_9342 ocfs2_orphan_for_truncate 4 9342 NULL
103428 +ll_direct_rw_pages_9361 ll_direct_rw_pages 0 9361 NULL
103429 +of_node_to_nid_9367 of_node_to_nid 0 9367 NULL
103430 +sta_beacon_loss_count_read_9370 sta_beacon_loss_count_read 3 9370 NULL
103431 +get_request_type_9393 get_request_type 0 9393 NULL nohasharray
103432 +mlx4_bitmap_init_9393 mlx4_bitmap_init 5-2 9393 &get_request_type_9393
103433 +virtqueue_add_outbuf_9395 virtqueue_add_outbuf 3 9395 NULL
103434 +read_9397 read 3 9397 NULL
103435 +btrfs_drop_extents_9423 btrfs_drop_extents 4-0 9423 NULL
103436 +bm_realloc_pages_9431 bm_realloc_pages 2 9431 NULL
103437 +ffs_ep0_write_9438 ffs_ep0_write 3 9438 NULL
103438 +ieee80211_if_fmt_fwded_unicast_9454 ieee80211_if_fmt_fwded_unicast 3 9454 NULL
103439 +ext3_xattr_set_acl_9467 ext3_xattr_set_acl 4 9467 NULL
103440 +agp_generic_alloc_user_9470 agp_generic_alloc_user 1 9470 NULL nohasharray
103441 +get_registers_9470 get_registers 4 9470 &agp_generic_alloc_user_9470
103442 +btrfs_csum_file_blocks_9491 btrfs_csum_file_blocks 0 9491 NULL
103443 +crypt_status_9492 crypt_status 5 9492 NULL
103444 +lbs_threshold_write_9502 lbs_threshold_write 5 9502 NULL
103445 +btrfs_add_delayed_data_ref_9508 btrfs_add_delayed_data_ref 0 9508 NULL
103446 +lp_write_9511 lp_write 3 9511 NULL
103447 +mext_calc_swap_extents_9517 mext_calc_swap_extents 4 9517 NULL
103448 +scsi_tgt_kspace_exec_9522 scsi_tgt_kspace_exec 8 9522 NULL
103449 +ll_max_read_ahead_whole_mb_seq_write_9528 ll_max_read_ahead_whole_mb_seq_write 3 9528 NULL
103450 +read_file_dma_9530 read_file_dma 3 9530 NULL
103451 +ext3_alloc_branch_9534 ext3_alloc_branch 5 9534 NULL
103452 +iwl_dbgfs_bf_params_read_9542 iwl_dbgfs_bf_params_read 3 9542 NULL
103453 +il_dbgfs_missed_beacon_write_9546 il_dbgfs_missed_beacon_write 3 9546 NULL
103454 +compat_SyS_pwritev64_9548 compat_SyS_pwritev64 3 9548 NULL
103455 +readl_9557 readl 0 9557 NULL
103456 +fw_node_create_9559 fw_node_create 2 9559 NULL
103457 +ipath_get_user_pages_9561 ipath_get_user_pages 1-2 9561 NULL
103458 +kobj_map_9566 kobj_map 3-2 9566 NULL
103459 +f2fs_read_data_pages_9574 f2fs_read_data_pages 4 9574 NULL
103460 +use_block_rsv_9597 use_block_rsv 3 9597 NULL
103461 +snd_emu10k1_fx8010_read_9605 snd_emu10k1_fx8010_read 5-6 9605 NULL
103462 +ocfs2_claim_suballoc_bits_9615 ocfs2_claim_suballoc_bits 0 9615 NULL
103463 +lov_ost_pool_add_9626 lov_ost_pool_add 3 9626 NULL
103464 +saa7164_buffer_alloc_user_9627 saa7164_buffer_alloc_user 2 9627 NULL
103465 +ceph_copy_user_to_page_vector_9635 ceph_copy_user_to_page_vector 3-4 9635 NULL
103466 +acpi_ex_insert_into_field_9638 acpi_ex_insert_into_field 3 9638 NULL
103467 +compat_sys_keyctl_9639 compat_sys_keyctl 4 9639 NULL
103468 +ll_checksum_seq_write_9648 ll_checksum_seq_write 3 9648 NULL
103469 +ocfs2_xattr_get_rec_9652 ocfs2_xattr_get_rec 0 9652 NULL
103470 +queue_received_packet_9657 queue_received_packet 5 9657 NULL
103471 +snd_opl4_mem_proc_write_9670 snd_opl4_mem_proc_write 5 9670 NULL
103472 +dns_query_9676 dns_query 3 9676 NULL
103473 +qib_7322_handle_hwerrors_9678 qib_7322_handle_hwerrors 3 9678 NULL
103474 +__erst_read_from_storage_9690 __erst_read_from_storage 0 9690 NULL
103475 +vx_transfer_end_9701 vx_transfer_end 0 9701 NULL
103476 +fnb_9703 fnb 2-3-0 9703 NULL
103477 +fuse_iter_npages_9705 fuse_iter_npages 0 9705 NULL nohasharray
103478 +ieee80211_if_read_aid_9705 ieee80211_if_read_aid 3 9705 &fuse_iter_npages_9705
103479 +cfg80211_tx_mlme_mgmt_9715 cfg80211_tx_mlme_mgmt 3 9715 NULL
103480 +btrfs_stack_file_extent_num_bytes_9720 btrfs_stack_file_extent_num_bytes 0 9720 NULL
103481 +SYSC_ppoll_9721 SYSC_ppoll 2 9721 NULL
103482 +nla_get_u8_9736 nla_get_u8 0 9736 NULL
103483 +ieee80211_if_fmt_num_mcast_sta_9738 ieee80211_if_fmt_num_mcast_sta 3 9738 NULL
103484 +shmem_replace_page_9740 shmem_replace_page 0 9740 NULL
103485 +ddb_input_read_9743 ddb_input_read 3-0 9743 NULL
103486 +sta_last_ack_signal_read_9751 sta_last_ack_signal_read 3 9751 NULL
103487 +ni_calculate_power_boost_limit_9757 ni_calculate_power_boost_limit 3 9757 NULL
103488 +btrfs_super_root_9763 btrfs_super_root 0 9763 NULL
103489 +__alloc_percpu_9764 __alloc_percpu 2-1 9764 NULL
103490 +btrfs_write_and_wait_transaction_9768 btrfs_write_and_wait_transaction 0 9768 NULL
103491 +__blk_queue_init_tags_9778 __blk_queue_init_tags 2 9778 NULL
103492 +snd_mem_proc_write_9786 snd_mem_proc_write 3 9786 NULL
103493 +kvm_age_hva_9795 kvm_age_hva 2 9795 NULL
103494 +parse_uac2_sample_rate_range_9801 parse_uac2_sample_rate_range 0 9801 NULL
103495 +tpm_data_in_9802 tpm_data_in 0 9802 NULL
103496 +ttm_bo_fbdev_io_9805 ttm_bo_fbdev_io 4 9805 NULL
103497 +udpv6_recvmsg_9813 udpv6_recvmsg 4 9813 NULL nohasharray
103498 +ieee80211_if_read_state_9813 ieee80211_if_read_state 3 9813 &udpv6_recvmsg_9813
103499 +svc_pool_map_get_node_9817 svc_pool_map_get_node 0 9817 NULL
103500 +dvb_dvr_set_buffer_size_9840 dvb_dvr_set_buffer_size 2 9840 NULL
103501 +pmcraid_alloc_sglist_9864 pmcraid_alloc_sglist 1 9864 NULL
103502 +btrfs_free_reserved_extent_9867 btrfs_free_reserved_extent 2 9867 NULL
103503 +f1x_translate_sysaddr_to_cs_9868 f1x_translate_sysaddr_to_cs 2 9868 NULL
103504 +mlx4_bitmap_alloc_range_9876 mlx4_bitmap_alloc_range 2-3 9876 NULL
103505 +wil_read_file_ioblob_9878 wil_read_file_ioblob 3 9878 NULL
103506 +bm_register_write_9893 bm_register_write 3 9893 NULL nohasharray
103507 +snd_midi_event_new_9893 snd_midi_event_new 1 9893 &bm_register_write_9893
103508 +snd_gf1_pcm_playback_copy_9895 snd_gf1_pcm_playback_copy 5-3 9895 NULL
103509 +nonpaging_page_fault_9908 nonpaging_page_fault 2 9908 NULL
103510 +ext4_map_blocks_9916 ext4_map_blocks 0 9916 NULL
103511 +root_nfs_parse_options_9937 root_nfs_parse_options 3 9937 NULL
103512 +tc3589x_reg_read_9940 tc3589x_reg_read 0 9940 NULL
103513 +pstore_ftrace_knob_read_9947 pstore_ftrace_knob_read 3 9947 NULL
103514 +read_file_misc_9948 read_file_misc 3 9948 NULL
103515 +ext2_new_blocks_9954 ext2_new_blocks 2-0 9954 NULL
103516 +csum_partial_copy_fromiovecend_9957 csum_partial_copy_fromiovecend 4-3 9957 NULL
103517 +SyS_gethostname_9964 SyS_gethostname 2 9964 NULL
103518 +get_free_serial_index_9969 get_free_serial_index 0 9969 NULL
103519 +btrfs_add_link_9973 btrfs_add_link 5-0 9973 NULL
103520 +SYSC_move_pages_9986 SYSC_move_pages 2 9986 NULL
103521 +aat2870_dump_reg_10019 aat2870_dump_reg 0 10019 NULL
103522 +batadv_orig_hash_add_if_10033 batadv_orig_hash_add_if 2 10033 NULL
103523 +iterate_inodes_from_logical_10037 iterate_inodes_from_logical 0 10037 NULL
103524 +vm_iomap_memory_10038 vm_iomap_memory 2 10038 NULL
103525 +ieee80211_set_probe_resp_10077 ieee80211_set_probe_resp 3 10077 NULL
103526 +ufs_bitmap_search_10105 ufs_bitmap_search 0-3 10105 NULL
103527 +get_elem_size_10110 get_elem_size 0-2 10110 NULL nohasharray
103528 +dynamic_ps_timeout_read_10110 dynamic_ps_timeout_read 3 10110 &get_elem_size_10110
103529 +gfs2_meta_read_10112 gfs2_meta_read 0 10112 NULL
103530 +SyS_migrate_pages_10134 SyS_migrate_pages 2 10134 NULL nohasharray
103531 +offset_to_bit_10134 offset_to_bit 0-2-1-3 10134 &SyS_migrate_pages_10134
103532 +aes_decrypt_packets_read_10155 aes_decrypt_packets_read 3 10155 NULL
103533 +rx_out_of_mem_read_10157 rx_out_of_mem_read 3 10157 NULL
103534 +hidg_alloc_ep_req_10159 hidg_alloc_ep_req 2 10159 NULL nohasharray
103535 +ol_chunk_entries_10159 ol_chunk_entries 0 10159 &hidg_alloc_ep_req_10159
103536 +stmpe_irq_unmap_10164 stmpe_irq_unmap 2 10164 NULL
103537 +asd_store_update_bios_10165 asd_store_update_bios 4 10165 NULL
103538 +kstrtol_from_user_10168 kstrtol_from_user 2 10168 NULL
103539 +proc_pid_attr_read_10173 proc_pid_attr_read 3 10173 NULL
103540 +jffs2_user_setxattr_10182 jffs2_user_setxattr 4 10182 NULL
103541 +register_ftrace_function_10218 register_ftrace_function 0 10218 NULL
103542 +hdlc_rpr_irq_10240 hdlc_rpr_irq 2 10240 NULL
103543 +mutex_lock_killable_10244 mutex_lock_killable 0 10244 NULL
103544 +insert_orphan_item_10249 insert_orphan_item 0 10249 NULL
103545 +cciss_proc_write_10259 cciss_proc_write 3 10259 NULL
103546 +gpiochip_add_to_list_10262 gpiochip_add_to_list 0 10262 NULL
103547 +__qlcnic_pci_sriov_enable_10281 __qlcnic_pci_sriov_enable 2 10281 NULL
103548 +snd_rme9652_capture_copy_10287 snd_rme9652_capture_copy 5 10287 NULL
103549 +ubi_leb_change_10289 ubi_leb_change 0-4 10289 NULL
103550 +read_emulate_10310 read_emulate 2-4 10310 NULL
103551 +read_file_spectral_count_10320 read_file_spectral_count 3 10320 NULL
103552 +ttm_object_device_init_10321 ttm_object_device_init 2 10321 NULL
103553 +compat_SyS_writev_10327 compat_SyS_writev 3 10327 NULL
103554 +ubi_leb_read_10328 ubi_leb_read 0 10328 NULL
103555 +tun_sendmsg_10337 tun_sendmsg 4 10337 NULL
103556 +get_dump_page_10338 get_dump_page 1 10338 NULL
103557 +ufx_alloc_urb_list_10349 ufx_alloc_urb_list 3 10349 NULL
103558 +whci_add_cap_10350 whci_add_cap 0 10350 NULL
103559 +dbAllocAny_10354 dbAllocAny 0 10354 NULL
103560 +ath6kl_listen_int_read_10355 ath6kl_listen_int_read 3 10355 NULL
103561 +ms_write_multiple_pages_10362 ms_write_multiple_pages 6-5 10362 NULL
103562 +sta_ht_capa_read_10366 sta_ht_capa_read 3 10366 NULL
103563 +ecryptfs_decode_and_decrypt_filename_10379 ecryptfs_decode_and_decrypt_filename 5 10379 NULL
103564 +do_compat_pselect_10398 do_compat_pselect 1 10398 NULL
103565 +fwtty_rx_10434 fwtty_rx 3 10434 NULL
103566 +event_phy_transmit_error_read_10471 event_phy_transmit_error_read 3 10471 NULL
103567 +ext4_itable_unused_count_10501 ext4_itable_unused_count 0 10501 NULL
103568 +qib_alloc_fast_reg_page_list_10507 qib_alloc_fast_reg_page_list 2 10507 NULL
103569 +sel_write_disable_10511 sel_write_disable 3 10511 NULL
103570 +osd_req_write_sg_kern_10514 osd_req_write_sg_kern 5 10514 NULL
103571 +rds_message_alloc_10517 rds_message_alloc 1 10517 NULL
103572 +qlcnic_pci_sriov_enable_10519 qlcnic_pci_sriov_enable 2 10519 NULL nohasharray
103573 +hash_netiface4_expire_10519 hash_netiface4_expire 3 10519 &qlcnic_pci_sriov_enable_10519
103574 +snd_pcm_hw_params_user_10520 snd_pcm_hw_params_user 0 10520 NULL
103575 +ocfs2_add_refcounted_extent_10526 ocfs2_add_refcounted_extent 6 10526 NULL
103576 +snd_pcm_lib_read_10536 snd_pcm_lib_read 0-3 10536 NULL nohasharray
103577 +kstrtouint_from_user_10536 kstrtouint_from_user 2 10536 &snd_pcm_lib_read_10536
103578 +SYSC_read_10545 SYSC_read 3 10545 NULL
103579 +ext4_write_begin_10576 ext4_write_begin 3-4 10576 NULL
103580 +scrub_remap_extent_10588 scrub_remap_extent 2 10588 NULL
103581 +otp_read_10594 otp_read 5-4-2 10594 NULL
103582 +supply_map_read_file_10608 supply_map_read_file 3 10608 NULL
103583 +ima_show_htable_violations_10619 ima_show_htable_violations 3 10619 NULL
103584 +alloc_coherent_10632 alloc_coherent 2 10632 NULL
103585 +ubi_io_write_vid_hdr_10660 ubi_io_write_vid_hdr 0 10660 NULL nohasharray
103586 +nfs_idmap_lookup_id_10660 nfs_idmap_lookup_id 2 10660 &ubi_io_write_vid_hdr_10660
103587 +efx_max_tx_len_10662 efx_max_tx_len 0-2 10662 NULL
103588 +dtf_read_device_10663 dtf_read_device 3 10663 NULL
103589 +parport_write_10669 parport_write 0 10669 NULL
103590 +alloc_vmap_area_10682 alloc_vmap_area 5 10682 NULL
103591 +edge_write_10692 edge_write 4 10692 NULL
103592 +ubi_wl_get_peb_10699 ubi_wl_get_peb 0 10699 NULL
103593 +inl_10708 inl 0 10708 NULL nohasharray
103594 +selinux_inode_setxattr_10708 selinux_inode_setxattr 4 10708 &inl_10708
103595 +pvr2_ioread_read_10720 pvr2_ioread_read 3 10720 NULL nohasharray
103596 +shash_async_setkey_10720 shash_async_setkey 3 10720 &pvr2_ioread_read_10720
103597 +spi_sync_10731 spi_sync 0 10731 NULL
103598 +sctp_getsockopt_maxseg_10737 sctp_getsockopt_maxseg 2 10737 NULL nohasharray
103599 +apu_get_register_10737 apu_get_register 0 10737 &sctp_getsockopt_maxseg_10737
103600 +alloc_one_pg_vec_page_10747 alloc_one_pg_vec_page 1 10747 NULL
103601 +ttm_ref_object_add_10748 ttm_ref_object_add 0 10748 NULL
103602 +SyS_io_getevents_10756 SyS_io_getevents 3 10756 NULL
103603 +vhost_add_used_n_10760 vhost_add_used_n 3 10760 NULL
103604 +kvm_read_guest_atomic_10765 kvm_read_guest_atomic 2-4 10765 NULL
103605 +wb_set_dirty_10778 wb_set_dirty 2 10778 NULL
103606 +__qp_memcpy_to_queue_10779 __qp_memcpy_to_queue 2-4 10779 NULL
103607 +i915_gem_wait_for_error_10791 i915_gem_wait_for_error 0 10791 NULL
103608 +snd_mask_value_10794 snd_mask_value 0 10794 NULL
103609 +diva_set_trace_filter_10820 diva_set_trace_filter 0-1 10820 NULL
103610 +lbs_sleepparams_read_10840 lbs_sleepparams_read 3 10840 NULL
103611 +ida_get_new_above_10853 ida_get_new_above 2-0 10853 NULL
103612 +fuse_conn_max_background_read_10855 fuse_conn_max_background_read 3 10855 NULL
103613 +ol_chunk_blocks_10864 ol_chunk_blocks 0 10864 NULL
103614 +snd_pcm_oss_write1_10872 snd_pcm_oss_write1 3 10872 NULL
103615 +drm_ht_insert_item_10877 drm_ht_insert_item 0 10877 NULL
103616 +wiidebug_drm_write_10879 wiidebug_drm_write 3 10879 NULL
103617 +get_scq_10897 get_scq 2 10897 NULL
103618 +cgroup_write_string_10900 cgroup_write_string 5 10900 NULL
103619 +tifm_alloc_adapter_10903 tifm_alloc_adapter 1 10903 NULL
103620 +lprocfs_wr_atomic_10912 lprocfs_wr_atomic 3 10912 NULL
103621 +__copy_from_user_10918 __copy_from_user 3-0 10918 NULL
103622 +kobject_add_10919 kobject_add 0 10919 NULL
103623 +da9052_map_irq_10952 da9052_map_irq 2 10952 NULL
103624 +ci_port_test_write_10962 ci_port_test_write 3 10962 NULL
103625 +bm_entry_read_10976 bm_entry_read 3 10976 NULL
103626 +sched_autogroup_write_10984 sched_autogroup_write 3 10984 NULL
103627 +__hci_num_ctrl_10985 __hci_num_ctrl 0 10985 NULL
103628 +lz4_compress_10986 lz4_compress 2 10986 NULL
103629 +do_switch_10994 do_switch 0 10994 NULL
103630 +xfrm_hash_alloc_10997 xfrm_hash_alloc 1 10997 NULL
103631 +btrfs_add_delayed_extent_op_11000 btrfs_add_delayed_extent_op 0 11000 NULL
103632 +rx_filter_accum_arp_pend_requests_read_11003 rx_filter_accum_arp_pend_requests_read 3 11003 NULL
103633 +SetLineNumber_11023 SetLineNumber 0 11023 NULL
103634 +btrfs_find_space_for_alloc_11028 btrfs_find_space_for_alloc 2 11028 NULL
103635 +mb_find_next_bit_11037 mb_find_next_bit 0-2-3 11037 NULL
103636 +tda10048_writeregbulk_11050 tda10048_writeregbulk 4 11050 NULL
103637 +insert_inline_extent_backref_11063 insert_inline_extent_backref 8-0 11063 NULL
103638 +tcp_send_mss_11079 tcp_send_mss 0 11079 NULL
103639 +snd_pcm_delay_11081 snd_pcm_delay 0 11081 NULL
103640 +count_argc_11083 count_argc 0 11083 NULL
103641 +kvm_write_guest_cached_11106 kvm_write_guest_cached 4 11106 NULL
103642 +stmpe_gpio_to_irq_11110 stmpe_gpio_to_irq 2 11110 NULL
103643 +tw_change_queue_depth_11116 tw_change_queue_depth 2 11116 NULL
103644 +page_offset_11120 page_offset 0 11120 NULL
103645 +tracing_buffers_read_11124 tracing_buffers_read 3 11124 NULL nohasharray
103646 +cea_db_payload_len_11124 cea_db_payload_len 0 11124 &tracing_buffers_read_11124
103647 +alloc_alien_cache_11127 alloc_alien_cache 2-1 11127 NULL
103648 +eb_lookup_objects_11163 eb_lookup_objects 0 11163 NULL
103649 +snd_gf1_pcm_playback_silence_11172 snd_gf1_pcm_playback_silence 4-3 11172 NULL
103650 +il_dbgfs_rx_queue_read_11221 il_dbgfs_rx_queue_read 3 11221 NULL
103651 +comedi_alloc_spriv_11234 comedi_alloc_spriv 2 11234 NULL
103652 +mmap_region_11247 mmap_region 0-2 11247 NULL
103653 +ubifs_write_node_11258 ubifs_write_node 5-3 11258 NULL
103654 +dm_cache_discard_bitset_resize_11262 dm_cache_discard_bitset_resize 3 11262 NULL
103655 +hugetlbfs_read_11268 hugetlbfs_read 3 11268 NULL
103656 +ath6kl_power_params_write_11274 ath6kl_power_params_write 3 11274 NULL
103657 +__proc_daemon_file_11305 __proc_daemon_file 5 11305 NULL
103658 +split_vma_11312 split_vma 0 11312 NULL
103659 +btrfs_update_inode_fallback_11313 btrfs_update_inode_fallback 0 11313 NULL
103660 +ext4_xattr_check_names_11314 ext4_xattr_check_names 0 11314 NULL
103661 +sk_filter_size_11316 sk_filter_size 0 11316 NULL nohasharray
103662 +tcp_send_rcvq_11316 tcp_send_rcvq 3 11316 &sk_filter_size_11316
103663 +shmem_radix_tree_replace_11325 shmem_radix_tree_replace 0 11325 NULL
103664 +construct_key_11329 construct_key 3 11329 NULL nohasharray
103665 +__kfifo_out_peek_11329 __kfifo_out_peek 0-3 11329 &construct_key_11329
103666 +next_segment_11330 next_segment 0-2-1 11330 NULL
103667 +persistent_ram_buffer_map_11332 persistent_ram_buffer_map 2-1 11332 NULL
103668 +ext4_get_inline_size_11349 ext4_get_inline_size 0 11349 NULL
103669 +nl80211_send_mgmt_11353 nl80211_send_mgmt 7 11353 NULL nohasharray
103670 +sel_write_create_11353 sel_write_create 3 11353 &nl80211_send_mgmt_11353
103671 +drm_vblank_init_11362 drm_vblank_init 2 11362 NULL
103672 +qib_get_base_info_11369 qib_get_base_info 3 11369 NULL
103673 +isku_sysfs_read_keys_capslock_11392 isku_sysfs_read_keys_capslock 6 11392 NULL
103674 +dev_irnet_write_11398 dev_irnet_write 3 11398 NULL
103675 +__btrfs_add_delayed_insertion_item_11400 __btrfs_add_delayed_insertion_item 0 11400 NULL
103676 +lprocfs_wr_evict_client_11402 lprocfs_wr_evict_client 3 11402 NULL
103677 +___alloc_bootmem_11410 ___alloc_bootmem 1 11410 NULL
103678 +str_to_user_11411 str_to_user 2 11411 NULL
103679 +mem_fw_gen_free_mem_blks_read_11413 mem_fw_gen_free_mem_blks_read 3 11413 NULL
103680 +ath6kl_wmi_test_rx_11414 ath6kl_wmi_test_rx 3 11414 NULL
103681 +relocate_entry_gtt_11416 relocate_entry_gtt 0 11416 NULL
103682 +adis16480_show_firmware_revision_11417 adis16480_show_firmware_revision 3 11417 NULL
103683 +trace_options_read_11419 trace_options_read 3 11419 NULL
103684 +i40e_dbg_command_write_11421 i40e_dbg_command_write 3 11421 NULL
103685 +__irq_set_trigger_11422 __irq_set_trigger 0 11422 NULL nohasharray
103686 +xd_read_multiple_pages_11422 xd_read_multiple_pages 5-4 11422 &__irq_set_trigger_11422
103687 +prepare_image_11424 prepare_image 0 11424 NULL
103688 +ext3_xattr_block_list_11428 ext3_xattr_block_list 3 11428 NULL
103689 +bttv_read_11432 bttv_read 3 11432 NULL
103690 +create_zero_mask_11453 create_zero_mask 0-1 11453 NULL
103691 +do_blockdev_direct_IO_11455 do_blockdev_direct_IO 0-6 11455 NULL
103692 +swp_offset_11475 swp_offset 0 11475 NULL
103693 +st_sensors_write_data_with_mask_11476 st_sensors_write_data_with_mask 3 11476 NULL
103694 +pci_set_power_state_11479 pci_set_power_state 0 11479 NULL nohasharray
103695 +sca3000_read_first_n_hw_rb_11479 sca3000_read_first_n_hw_rb 2 11479 &pci_set_power_state_11479
103696 +xfs_file_buffered_aio_write_11492 xfs_file_buffered_aio_write 4 11492 NULL
103697 +sd_do_mode_sense_11507 sd_do_mode_sense 5 11507 NULL
103698 +kmem_zalloc_11510 kmem_zalloc 1 11510 NULL
103699 +ll_direct_IO_26_seg_11518 ll_direct_IO_26_seg 0 11518 NULL
103700 +twl_direction_in_11527 twl_direction_in 2 11527 NULL
103701 +setup_IO_APIC_irq_extra_11537 setup_IO_APIC_irq_extra 1 11537 NULL
103702 +radix_tree_extend_11555 radix_tree_extend 0 11555 NULL
103703 +skb_cow_data_11565 skb_cow_data 0 11565 NULL
103704 +posix_acl_create_masq_11567 posix_acl_create_masq 0 11567 NULL
103705 +qgroup_account_ref_step2_11575 qgroup_account_ref_step2 0 11575 NULL
103706 +lpfc_idiag_ctlacc_write_11576 lpfc_idiag_ctlacc_write 3 11576 NULL
103707 +oprofilefs_ulong_to_user_11582 oprofilefs_ulong_to_user 3 11582 NULL
103708 +snd_pcm_action_11589 snd_pcm_action 0 11589 NULL
103709 +fw_device_op_ioctl_11595 fw_device_op_ioctl 2 11595 NULL
103710 +btrfs_uuid_tree_add_11598 btrfs_uuid_tree_add 0 11598 NULL
103711 +SYSC_mq_timedsend_11607 SYSC_mq_timedsend 3 11607 NULL
103712 +i915_gem_object_pin_11630 i915_gem_object_pin 0 11630 NULL
103713 +add_new_bitmap_11644 add_new_bitmap 3 11644 NULL
103714 +sisusb_send_bridge_packet_11649 sisusb_send_bridge_packet 2 11649 NULL
103715 +nla_total_size_11658 nla_total_size 0-1 11658 NULL
103716 +slab_ksize_11664 slab_ksize 0 11664 NULL
103717 +__btrfs_run_delayed_items_11671 __btrfs_run_delayed_items 0 11671 NULL
103718 +ide_queue_pc_tail_11673 ide_queue_pc_tail 5 11673 NULL
103719 +compat_SyS_msgsnd_11675 compat_SyS_msgsnd 3 11675 NULL
103720 +btrfs_alloc_delayed_item_11678 btrfs_alloc_delayed_item 1 11678 NULL
103721 +dsp_buffer_alloc_11684 dsp_buffer_alloc 2 11684 NULL
103722 +sctp_setsockopt_hmac_ident_11687 sctp_setsockopt_hmac_ident 3 11687 NULL
103723 +split_11691 split 2 11691 NULL
103724 +snd_ctl_elem_user_tlv_11695 snd_ctl_elem_user_tlv 3 11695 NULL
103725 +blk_rq_cur_bytes_11723 blk_rq_cur_bytes 0 11723 NULL
103726 +dm_bio_prison_create_11749 dm_bio_prison_create 1 11749 NULL
103727 +iwl_dbgfs_qos_read_11753 iwl_dbgfs_qos_read 3 11753 NULL
103728 +intel_map_page_11762 intel_map_page 4-3 11762 NULL
103729 +ocfs2_relink_block_group_11769 ocfs2_relink_block_group 0 11769 NULL
103730 +ps_pspoll_timeouts_read_11776 ps_pspoll_timeouts_read 3 11776 NULL
103731 +ebt_buf_add_11779 ebt_buf_add 0 11779 NULL
103732 +btrfs_key_blockptr_11786 btrfs_key_blockptr 0 11786 NULL
103733 +rtw_alloc_etherdev_11792 rtw_alloc_etherdev 1 11792 NULL
103734 +pcpu_fc_alloc_11818 pcpu_fc_alloc 2 11818 NULL
103735 +umc_device_register_11824 umc_device_register 0 11824 NULL
103736 +zerocopy_sg_from_iovec_11828 zerocopy_sg_from_iovec 3 11828 NULL
103737 +sctp_setsockopt_maxseg_11829 sctp_setsockopt_maxseg 3 11829 NULL
103738 +rts51x_read_status_11830 rts51x_read_status 4 11830 NULL
103739 +unix_stream_connect_11844 unix_stream_connect 3 11844 NULL
103740 +ecryptfs_copy_filename_11868 ecryptfs_copy_filename 4 11868 NULL
103741 +ieee80211_rx_bss_info_11887 ieee80211_rx_bss_info 3 11887 NULL
103742 +mdc_rename_11899 mdc_rename 4-6 11899 NULL
103743 +xstateregs_get_11906 xstateregs_get 4 11906 NULL
103744 +ti_write_11916 ti_write 4 11916 NULL
103745 +fs_devrw_entry_11924 fs_devrw_entry 3 11924 NULL
103746 +bitmap_remap_11929 bitmap_remap 5 11929 NULL
103747 +atomic_sub_return_11939 atomic_sub_return 0-1 11939 NULL
103748 +r1_sync_page_io_11963 r1_sync_page_io 3 11963 NULL
103749 +f1x_swap_interleaved_region_11970 f1x_swap_interleaved_region 0-2 11970 NULL
103750 +usc_InReg_11976 usc_InReg 0 11976 NULL nohasharray
103751 +split_node_11976 split_node 0 11976 &usc_InReg_11976
103752 +BeceemFlashBulkRead_11979 BeceemFlashBulkRead 0 11979 NULL
103753 +read_and_add_raw_conns_11987 read_and_add_raw_conns 0 11987 NULL
103754 +i40e_pci_sriov_configure_12011 i40e_pci_sriov_configure 2 12011 NULL
103755 +intel_init_ring_buffer_12016 intel_init_ring_buffer 0 12016 NULL
103756 +ftdi_elan_total_command_size_12045 ftdi_elan_total_command_size 0 12045 NULL
103757 +did_overwrite_ref_12046 did_overwrite_ref 0 12046 NULL
103758 +ieee80211_if_read_user_power_level_12050 ieee80211_if_read_user_power_level 3 12050 NULL
103759 +il4965_ucode_tx_stats_read_12064 il4965_ucode_tx_stats_read 3 12064 NULL
103760 +ptc_proc_write_12076 ptc_proc_write 3 12076 NULL
103761 +ubifs_recover_log_leb_12079 ubifs_recover_log_leb 3 12079 NULL
103762 +pse36_gfn_delta_12087 pse36_gfn_delta 0-1 12087 NULL
103763 +rtw_malloc2d_12102 rtw_malloc2d 1-2-3 12102 NULL
103764 +twl6030_irq_map_12105 twl6030_irq_map 2 12105 NULL
103765 +i915_gem_evict_something_12118 i915_gem_evict_something 0 12118 NULL
103766 +alloc_bulk_urbs_generic_12127 alloc_bulk_urbs_generic 5 12127 NULL
103767 +set_powered_12129 set_powered 4 12129 NULL
103768 +ramoops_init_prz_12134 ramoops_init_prz 5 12134 NULL
103769 +xfs_handle_to_dentry_12135 xfs_handle_to_dentry 3 12135 NULL
103770 +rawv6_seticmpfilter_12137 rawv6_seticmpfilter 5 12137 NULL
103771 +vmw_fifo_reserve_12141 vmw_fifo_reserve 2 12141 NULL
103772 +rawsock_recvmsg_12144 rawsock_recvmsg 4 12144 NULL
103773 +get_idx_gc_leb_12148 get_idx_gc_leb 0 12148 NULL
103774 +btmrvl_sdio_host_to_card_12152 btmrvl_sdio_host_to_card 3 12152 NULL
103775 +ocfs2_local_alloc_new_window_12153 ocfs2_local_alloc_new_window 0 12153 NULL
103776 +vmbus_open_12154 vmbus_open 2-3 12154 NULL
103777 +dma_memcpy_to_iovec_12173 dma_memcpy_to_iovec 5 12173 NULL
103778 +LNetEQAlloc_12178 LNetEQAlloc 1 12178 NULL
103779 +ddp_make_gl_12179 ddp_make_gl 1 12179 NULL
103780 +compat_do_arpt_set_ctl_12184 compat_do_arpt_set_ctl 4 12184 NULL
103781 +ip_generic_getfrag_12187 ip_generic_getfrag 3-4 12187 NULL
103782 +scaled_div_12201 scaled_div 2-1-0 12201 NULL
103783 +snd_pcm_kernel_ioctl_12219 snd_pcm_kernel_ioctl 0 12219 NULL
103784 +fuse_get_req_12221 fuse_get_req 2 12221 NULL nohasharray
103785 +aat2870_reg_read_file_12221 aat2870_reg_read_file 3 12221 &fuse_get_req_12221
103786 +__alloc_bootmem_low_nopanic_12235 __alloc_bootmem_low_nopanic 1 12235 NULL
103787 +kvirt_to_pa_12247 kvirt_to_pa 0 12247 NULL
103788 +ib_uverbs_unmarshall_recv_12251 ib_uverbs_unmarshall_recv 5 12251 NULL
103789 +shash_compat_setkey_12267 shash_compat_setkey 3 12267 NULL
103790 +add_sctp_bind_addr_12269 add_sctp_bind_addr 3 12269 NULL
103791 +note_last_dentry_12285 note_last_dentry 3 12285 NULL
103792 +il_dbgfs_nvm_read_12288 il_dbgfs_nvm_read 3 12288 NULL nohasharray
103793 +roundup_to_multiple_of_64_12288 roundup_to_multiple_of_64 0-1 12288 &il_dbgfs_nvm_read_12288
103794 +wrap_min_12303 wrap_min 0-1-2 12303 NULL
103795 +bt_sock_recvmsg_12316 bt_sock_recvmsg 4 12316 NULL
103796 +pcbit_writecmd_12332 pcbit_writecmd 2 12332 NULL
103797 +btrfs_lookup_file_extent_12341 btrfs_lookup_file_extent 0 12341 NULL
103798 +mptctl_ioctl_12355 mptctl_ioctl 2 12355 NULL
103799 +paging32_walk_addr_12359 paging32_walk_addr 3 12359 NULL
103800 +__nf_ct_ext_add_length_12364 __nf_ct_ext_add_length 3 12364 NULL
103801 +xfs_iext_inline_to_direct_12384 xfs_iext_inline_to_direct 2 12384 NULL
103802 +btrfs_file_extent_ram_bytes_12391 btrfs_file_extent_ram_bytes 0 12391 NULL nohasharray
103803 +populate_dir_12391 populate_dir 0 12391 &btrfs_file_extent_ram_bytes_12391
103804 +ntfs_get_size_for_mapping_pairs_12413 ntfs_get_size_for_mapping_pairs 0 12413 NULL nohasharray
103805 +ext4_bg_num_gdb_nometa_12413 ext4_bg_num_gdb_nometa 0 12413 &ntfs_get_size_for_mapping_pairs_12413
103806 +hbucket_elem_add_12416 hbucket_elem_add 3 12416 NULL
103807 +ieee80211_if_read_num_mcast_sta_12419 ieee80211_if_read_num_mcast_sta 3 12419 NULL
103808 +cfs_array_alloc_12441 cfs_array_alloc 2 12441 NULL
103809 +skb_do_copy_data_nocache_12465 skb_do_copy_data_nocache 5 12465 NULL
103810 +x25_sendmsg_12487 x25_sendmsg 4 12487 NULL
103811 +fnic_trace_ctrl_read_12497 fnic_trace_ctrl_read 3 12497 NULL
103812 +qib_alloc_fast_reg_mr_12526 qib_alloc_fast_reg_mr 2 12526 NULL
103813 +xfs_get_extsz_hint_12531 xfs_get_extsz_hint 0 12531 NULL
103814 +kvm_setup_async_pf_12555 kvm_setup_async_pf 3 12555 NULL
103815 +ib_umem_get_12557 ib_umem_get 2-3 12557 NULL
103816 +ceph_osdc_wait_request_12572 ceph_osdc_wait_request 0 12572 NULL
103817 +hvc_alloc_12579 hvc_alloc 4 12579 NULL
103818 +snd_pcm_plugin_alloc_12580 snd_pcm_plugin_alloc 2 12580 NULL
103819 +pcpu_extend_area_map_12589 pcpu_extend_area_map 2 12589 NULL
103820 +tlbflush_write_file_12598 tlbflush_write_file 3 12598 NULL
103821 +vhci_put_user_12604 vhci_put_user 4 12604 NULL
103822 +ipath_mmap_mem_12625 ipath_mmap_mem 3 12625 NULL
103823 +sdhci_pltfm_init_12627 sdhci_pltfm_init 3 12627 NULL
103824 +pwr_rcvd_awake_bcns_cnt_read_12632 pwr_rcvd_awake_bcns_cnt_read 3 12632 NULL
103825 +pn_sendmsg_12640 pn_sendmsg 4 12640 NULL
103826 +dwc3_link_state_write_12641 dwc3_link_state_write 3 12641 NULL
103827 +nr_recvmsg_12649 nr_recvmsg 4 12649 NULL
103828 +wb_create_12651 wb_create 1 12651 NULL
103829 +rtw_android_get_link_speed_12655 rtw_android_get_link_speed 0 12655 NULL
103830 +ocfs2_read_block_12659 ocfs2_read_block 0 12659 NULL
103831 +sel_read_class_12669 sel_read_class 3 12669 NULL nohasharray
103832 +sparse_mem_maps_populate_node_12669 sparse_mem_maps_populate_node 4 12669 &sel_read_class_12669
103833 +ext4_writepage_trans_blocks_12674 ext4_writepage_trans_blocks 0 12674 NULL
103834 +ext4_bg_num_gdb_meta_12702 ext4_bg_num_gdb_meta 0 12702 NULL
103835 +iwl_dbgfs_calib_disabled_write_12707 iwl_dbgfs_calib_disabled_write 3 12707 NULL
103836 +ieee80211_if_read_num_buffered_multicast_12716 ieee80211_if_read_num_buffered_multicast 3 12716 NULL
103837 +ivtv_write_12721 ivtv_write 3 12721 NULL
103838 +key_rx_spec_read_12736 key_rx_spec_read 3 12736 NULL
103839 +__mei_cl_async_send_12737 __mei_cl_async_send 3 12737 NULL
103840 +run_delayed_data_ref_12749 run_delayed_data_ref 0 12749 NULL
103841 +ieee80211_if_read_dot11MeshMaxRetries_12756 ieee80211_if_read_dot11MeshMaxRetries 3 12756 NULL
103842 +listxattr_12769 listxattr 3 12769 NULL
103843 +sctp_ssnmap_init_12772 sctp_ssnmap_init 2-3 12772 NULL
103844 +btrfs_remove_free_space_12793 btrfs_remove_free_space 2-0 12793 NULL
103845 +scsi_adjust_queue_depth_12802 scsi_adjust_queue_depth 3 12802 NULL
103846 +xfs_inumbers_fmt_12817 xfs_inumbers_fmt 3 12817 NULL
103847 +tlv_put_uuid_12824 tlv_put_uuid 0 12824 NULL
103848 +readq_12825 readq 0 12825 NULL
103849 +SyS_add_key_12834 SyS_add_key 4 12834 NULL
103850 +TSS_authhmac_12839 TSS_authhmac 3 12839 NULL
103851 +spidev_sync_12842 spidev_sync 0 12842 NULL
103852 +spidev_ioctl_12846 spidev_ioctl 2 12846 NULL
103853 +get_leb_cnt_12892 get_leb_cnt 0-2 12892 NULL
103854 +ocfs2_hamming_encode_block_12904 ocfs2_hamming_encode_block 2 12904 NULL
103855 +get_virtual_node_size_12908 get_virtual_node_size 0 12908 NULL
103856 +rds_pages_in_vec_12922 rds_pages_in_vec 0 12922 NULL
103857 +free_tind_blocks_12926 free_tind_blocks 0 12926 NULL
103858 +ci_ll_init_12930 ci_ll_init 3 12930 NULL
103859 +SYSC_sendfile_12936 SYSC_sendfile 4 12936 NULL
103860 +do_inode_permission_12946 do_inode_permission 0 12946 NULL
103861 +bm_status_write_12964 bm_status_write 3 12964 NULL
103862 +raid56_parity_recover_12987 raid56_parity_recover 5 12987 NULL
103863 +TransmitTcb_12989 TransmitTcb 4 12989 NULL
103864 +sk_peek_offset_12991 sk_peek_offset 0 12991 NULL
103865 +subsystem_filter_write_13022 subsystem_filter_write 3 13022 NULL
103866 +btrfs_write_dirty_block_groups_13030 btrfs_write_dirty_block_groups 0 13030 NULL
103867 +generic_segment_checks_13041 generic_segment_checks 0 13041 NULL
103868 +SyS_sendfile64_13043 SyS_sendfile64 4 13043 NULL
103869 +ocfs2_write_begin_13045 ocfs2_write_begin 3-4 13045 NULL
103870 +ptlrpc_lprocfs_threads_min_seq_write_13060 ptlrpc_lprocfs_threads_min_seq_write 3 13060 NULL nohasharray
103871 +__dn_setsockopt_13060 __dn_setsockopt 5 13060 &ptlrpc_lprocfs_threads_min_seq_write_13060
103872 +biovec_create_pool_13079 biovec_create_pool 2 13079 NULL
103873 +_ocfs2_free_suballoc_bits_13085 _ocfs2_free_suballoc_bits 0 13085 NULL
103874 +irq_set_chip_and_handler_13088 irq_set_chip_and_handler 1 13088 NULL
103875 +xattr_getsecurity_13090 xattr_getsecurity 0 13090 NULL
103876 +mb_find_next_zero_bit_13100 mb_find_next_zero_bit 2-3-0 13100 NULL
103877 +ttm_dma_pool_alloc_new_pages_13105 ttm_dma_pool_alloc_new_pages 3 13105 NULL
103878 +SyS_msgrcv_13109 SyS_msgrcv 3 13109 NULL
103879 +snd_rme96_playback_copy_13111 snd_rme96_playback_copy 5 13111 NULL
103880 +xen_allocate_irq_dynamic_13116 xen_allocate_irq_dynamic 0 13116 NULL
103881 +bfad_debugfs_read_13119 bfad_debugfs_read 3 13119 NULL
103882 +blk_update_request_13146 blk_update_request 3 13146 NULL
103883 +caif_stream_recvmsg_13173 caif_stream_recvmsg 4 13173 NULL
103884 +pwr_disable_ps_read_13176 pwr_disable_ps_read 3 13176 NULL
103885 +ucs2_strlen_13178 ucs2_strlen 0 13178 NULL
103886 +dgrp_net_ioctl_13183 dgrp_net_ioctl 2 13183 NULL
103887 +create_trace_uprobe_13184 create_trace_uprobe 1 13184 NULL
103888 +__cmpxchg64_13187 __cmpxchg64 0 13187 NULL
103889 +comedi_read_13199 comedi_read 3 13199 NULL
103890 +mmc_ext_csd_read_13205 mmc_ext_csd_read 3 13205 NULL
103891 +__nodes_fold_13215 __nodes_fold 4 13215 NULL
103892 +get_unaligned_le64_13219 get_unaligned_le64 0 13219 NULL
103893 +svm_msrpm_offset_13220 svm_msrpm_offset 0-1 13220 NULL
103894 +fnic_trace_ctrl_write_13229 fnic_trace_ctrl_write 3 13229 NULL
103895 +asix_read_cmd_13245 asix_read_cmd 5 13245 NULL
103896 +kvm_lapic_enable_pv_eoi_13249 kvm_lapic_enable_pv_eoi 2 13249 NULL
103897 +init_tid_tabs_13252 init_tid_tabs 2-3-4 13252 NULL
103898 +bio_integrity_trim_13259 bio_integrity_trim 3 13259 NULL
103899 +simple_attr_write_13260 simple_attr_write 3 13260 NULL
103900 +c4iw_reg_user_mr_13269 c4iw_reg_user_mr 2-3 13269 NULL
103901 +pmcraid_notify_aen_13274 pmcraid_notify_aen 3 13274 NULL
103902 +il4965_stats_flag_13281 il4965_stats_flag 0-3 13281 NULL
103903 +lpfc_idiag_mbxacc_get_setup_13282 lpfc_idiag_mbxacc_get_setup 0 13282 NULL
103904 +sd_major_13294 sd_major 0-1 13294 NULL
103905 +kempld_read16_13297 kempld_read16 0 13297 NULL
103906 +reexecute_instruction_13321 reexecute_instruction 2 13321 NULL
103907 +__clone_and_map_data_bio_13334 __clone_and_map_data_bio 4-8 13334 NULL
103908 +kvm_read_nested_guest_page_13337 kvm_read_nested_guest_page 5-2 13337 NULL
103909 +get_bits_13353 get_bits 0-2 13353 NULL
103910 +hscx_empty_fifo_13360 hscx_empty_fifo 2 13360 NULL
103911 +iso_sched_alloc_13377 iso_sched_alloc 1 13377 NULL nohasharray
103912 +wep_key_not_found_read_13377 wep_key_not_found_read 3 13377 &iso_sched_alloc_13377
103913 +ext4_meta_trans_blocks_13380 ext4_meta_trans_blocks 0-3-2 13380 NULL
103914 +lov_mds_md_size_13388 lov_mds_md_size 0-1 13388 NULL nohasharray
103915 +dis_bypass_write_13388 dis_bypass_write 3 13388 &lov_mds_md_size_13388
103916 +BcmSetActiveSection_13389 BcmSetActiveSection 0 13389 NULL
103917 +ocfs2_inode_lock_update_13414 ocfs2_inode_lock_update 0 13414 NULL
103918 +netxen_alloc_sds_rings_13417 netxen_alloc_sds_rings 2 13417 NULL
103919 +compat_SyS_sendfile64_13420 compat_SyS_sendfile64 4 13420 NULL
103920 +keyring_read_13438 keyring_read 3 13438 NULL
103921 +sctp_setsockopt_peer_primary_addr_13440 sctp_setsockopt_peer_primary_addr 3 13440 NULL
103922 +ath6kl_cfg80211_connect_event_13443 ath6kl_cfg80211_connect_event 8-9-7 13443 NULL
103923 +sb_init_dio_done_wq_13482 sb_init_dio_done_wq 0 13482 NULL
103924 +data_read_13494 data_read 3 13494 NULL
103925 +i915_switch_context_13498 i915_switch_context 0 13498 NULL
103926 +ioat_chansts_32_13506 ioat_chansts_32 0 13506 NULL
103927 +ocfs2_align_bytes_to_blocks_13512 ocfs2_align_bytes_to_blocks 2-0 13512 NULL
103928 +core_status_13515 core_status 4 13515 NULL
103929 +smk_write_mapped_13519 smk_write_mapped 3 13519 NULL
103930 +bm_init_13529 bm_init 2 13529 NULL
103931 +kvm_get_cr8_13538 kvm_get_cr8 0 13538 NULL
103932 +SYSC_remap_file_pages_13540 SYSC_remap_file_pages 1-2 13540 NULL nohasharray
103933 +non_atomic_pte_lookup_13540 non_atomic_pte_lookup 2 13540 &SYSC_remap_file_pages_13540
103934 +__btrfs_alloc_chunk_13554 __btrfs_alloc_chunk 0 13554 NULL
103935 +llcp_sock_recvmsg_13556 llcp_sock_recvmsg 4 13556 NULL
103936 +ieee80211_if_read_ap_power_level_13558 ieee80211_if_read_ap_power_level 3 13558 NULL
103937 +ubifs_get_idx_gc_leb_13566 ubifs_get_idx_gc_leb 0 13566 NULL
103938 +read_file_antenna_13574 read_file_antenna 3 13574 NULL
103939 +cache_write_13589 cache_write 3 13589 NULL
103940 +Rd_Indx_13602 Rd_Indx 3-2 13602 NULL
103941 +swap_cgroup_swapon_13614 swap_cgroup_swapon 2 13614 NULL
103942 +wm8994_bulk_write_13615 wm8994_bulk_write 2-3 13615 NULL
103943 +pmcraid_get_minor_13619 pmcraid_get_minor 0 13619 NULL
103944 +packet_snd_13634 packet_snd 3 13634 NULL
103945 +blk_msg_write_13655 blk_msg_write 3 13655 NULL
103946 +cache_downcall_13666 cache_downcall 3 13666 NULL
103947 +ext3_xattr_list_entries_13682 ext3_xattr_list_entries 0-4 13682 NULL
103948 +nv94_aux_13689 nv94_aux 2-5 13689 NULL
103949 +usb_get_string_13693 usb_get_string 0 13693 NULL
103950 +atomic_cmpxchg_13700 atomic_cmpxchg 0 13700 NULL
103951 +fw_iso_buffer_alloc_13704 fw_iso_buffer_alloc 2 13704 NULL
103952 +ocfs2_cache_block_dealloc_13731 ocfs2_cache_block_dealloc 0 13731 NULL
103953 +netdev_queue_numa_node_read_13732 netdev_queue_numa_node_read 0 13732 NULL
103954 +audit_unpack_string_13748 audit_unpack_string 3 13748 NULL
103955 +ufs_dtog_13750 ufs_dtog 0-2 13750 NULL
103956 +ieee802154_alloc_device_13767 ieee802154_alloc_device 1 13767 NULL
103957 +fb_sys_read_13778 fb_sys_read 3 13778 NULL
103958 +ath6kl_mgmt_powersave_ap_13791 ath6kl_mgmt_powersave_ap 6 13791 NULL
103959 +random_read_13815 random_read 3 13815 NULL
103960 +mutex_lock_interruptible_nested_13817 mutex_lock_interruptible_nested 0 13817 NULL
103961 +hsi_register_board_info_13820 hsi_register_board_info 2 13820 NULL
103962 +___mei_cl_send_13821 ___mei_cl_send 3 13821 NULL
103963 +enc_pools_insert_13849 enc_pools_insert 3 13849 NULL
103964 +evdev_ioctl_compat_13851 evdev_ioctl_compat 2 13851 NULL
103965 +compat_ip_setsockopt_13870 compat_ip_setsockopt 5 13870 NULL
103966 +btrfs_insert_empty_item_13885 btrfs_insert_empty_item 0 13885 NULL
103967 +qp_memcpy_to_queue_13886 qp_memcpy_to_queue 5-2 13886 NULL nohasharray
103968 +__fsnotify_parent_13886 __fsnotify_parent 0 13886 &qp_memcpy_to_queue_13886
103969 +window_alignment_13895 window_alignment 0 13895 NULL
103970 +snd_pcm_aio_read_13900 snd_pcm_aio_read 3 13900 NULL
103971 +is_inode_existent_13913 is_inode_existent 0 13913 NULL
103972 +cfg80211_inform_bss_width_13933 cfg80211_inform_bss_width 9 13933 NULL
103973 +ext3_xattr_block_get_13936 ext3_xattr_block_get 0 13936 NULL
103974 +ieee80211_if_read_dot11MeshForwarding_13940 ieee80211_if_read_dot11MeshForwarding 3 13940 NULL nohasharray
103975 +ocfs2_xa_value_truncate_13940 ocfs2_xa_value_truncate 2 13940 &ieee80211_if_read_dot11MeshForwarding_13940
103976 +iwl_dbgfs_protection_mode_read_13943 iwl_dbgfs_protection_mode_read 3 13943 NULL
103977 +ieee80211_if_read_min_discovery_timeout_13946 ieee80211_if_read_min_discovery_timeout 3 13946 NULL
103978 +qib_mmap_mem_13947 qib_mmap_mem 3 13947 NULL
103979 +lpfc_idiag_queacc_read_13950 lpfc_idiag_queacc_read 3 13950 NULL
103980 +osc_grant_shrink_interval_seq_write_13952 osc_grant_shrink_interval_seq_write 3 13952 NULL
103981 +ocfs2_refresh_slot_info_13957 ocfs2_refresh_slot_info 0 13957 NULL
103982 +snd_pcm_plug_slave_size_13967 snd_pcm_plug_slave_size 0-2 13967 NULL
103983 +qcam_read_13977 qcam_read 3 13977 NULL
103984 +dsp_read_13980 dsp_read 2 13980 NULL
103985 +bm_block_bits_13981 bm_block_bits 0 13981 NULL nohasharray
103986 +dvb_demux_read_13981 dvb_demux_read 3 13981 &bm_block_bits_13981
103987 +create_files_14003 create_files 0 14003 NULL
103988 +sddr09_write_data_14014 sddr09_write_data 3 14014 NULL
103989 +btrfs_get_blocks_direct_14016 btrfs_get_blocks_direct 2 14016 NULL
103990 +dmi_format_ids_14018 dmi_format_ids 2 14018 NULL
103991 +iscsi_create_flashnode_conn_14022 iscsi_create_flashnode_conn 4 14022 NULL
103992 +dvb_usercopy_14036 dvb_usercopy 2 14036 NULL
103993 +read_def_modal_eeprom_14041 read_def_modal_eeprom 3 14041 NULL
103994 +ieee80211_if_fmt_aid_14055 ieee80211_if_fmt_aid 3 14055 NULL
103995 +sta_agg_status_read_14058 sta_agg_status_read 3 14058 NULL
103996 +ovs_flow_actions_alloc_14072 ovs_flow_actions_alloc 1 14072 NULL
103997 +lov_stripeoffset_seq_write_14078 lov_stripeoffset_seq_write 3 14078 NULL
103998 +do_proc_readlink_14096 do_proc_readlink 3 14096 NULL
103999 +compat_sys_pselect6_14105 compat_sys_pselect6 1 14105 NULL
104000 +intel_ring_wait_seqno_14107 intel_ring_wait_seqno 0 14107 NULL
104001 +ext4_journal_blocks_per_page_14127 ext4_journal_blocks_per_page 0 14127 NULL
104002 +ntfs_rl_replace_14136 ntfs_rl_replace 4-2 14136 NULL
104003 +qfq_ffs_14139 qfq_ffs 2 14139 NULL
104004 +isku_sysfs_read_light_14140 isku_sysfs_read_light 6 14140 NULL
104005 +em_canid_change_14150 em_canid_change 3 14150 NULL
104006 +gsm_dlci_data_14155 gsm_dlci_data 3 14155 NULL
104007 +print_input_mask_14168 print_input_mask 3-0 14168 NULL
104008 +ocfs2_split_and_insert_14171 ocfs2_split_and_insert 0 14171 NULL
104009 +ocfs2_xattr_value_truncate_14183 ocfs2_xattr_value_truncate 3 14183 NULL
104010 +datafab_read_data_14186 datafab_read_data 4 14186 NULL
104011 +do_splice_14196 do_splice 5 14196 NULL
104012 +hfsplus_brec_find_14200 hfsplus_brec_find 0 14200 NULL
104013 +alloc_async_14208 alloc_async 1 14208 NULL
104014 +ath6kl_regread_write_14220 ath6kl_regread_write 3 14220 NULL
104015 +ieee80211_if_write_uapsd_max_sp_len_14233 ieee80211_if_write_uapsd_max_sp_len 3 14233 NULL
104016 +dma_declare_coherent_memory_14244 dma_declare_coherent_memory 4 14244 NULL
104017 +snd_soc_hw_bulk_write_raw_14245 snd_soc_hw_bulk_write_raw 2-4 14245 NULL
104018 +ext4_journal_restart_14251 ext4_journal_restart 0 14251 NULL
104019 +will_overwrite_ref_14252 will_overwrite_ref 0 14252 NULL
104020 +ath6kl_connect_event_14267 ath6kl_connect_event 7-8-9 14267 NULL
104021 +numa_mem_id_14279 numa_mem_id 0 14279 NULL
104022 +rr_status_14293 rr_status 5 14293 NULL
104023 +read_default_ldt_14302 read_default_ldt 2 14302 NULL
104024 +__readl_14308 __readl 0 14308 NULL
104025 +send_chown_14309 send_chown 0 14309 NULL
104026 +i915_gem_object_finish_gpu_14312 i915_gem_object_finish_gpu 0 14312 NULL
104027 +oo_objects_14319 oo_objects 0 14319 NULL
104028 +ww_mutex_deadlock_injection_14321 ww_mutex_deadlock_injection 0 14321 NULL
104029 +ll_get_user_pages_14328 ll_get_user_pages 2-3-0 14328 NULL
104030 +down_write_failed_14331 down_write_failed 2 14331 NULL
104031 +p9_client_zc_rpc_14345 p9_client_zc_rpc 7 14345 NULL
104032 +alloc_tx_struct_14349 alloc_tx_struct 1 14349 NULL
104033 +snd_pcm_lib_readv_14363 snd_pcm_lib_readv 0-3 14363 NULL
104034 +btrfs_set_inode_index_14379 btrfs_set_inode_index 0 14379 NULL
104035 +acpi_get_override_irq_14381 acpi_get_override_irq 1 14381 NULL
104036 +ath6kl_regdump_read_14393 ath6kl_regdump_read 3 14393 NULL
104037 +smk_write_onlycap_14400 smk_write_onlycap 3 14400 NULL
104038 +first_logical_byte_14403 first_logical_byte 0 14403 NULL
104039 +mtd_concat_create_14416 mtd_concat_create 2 14416 NULL
104040 +get_kcore_size_14425 get_kcore_size 0 14425 NULL
104041 +qib_user_sdma_page_length_14432 qib_user_sdma_page_length 0-2-1 14432 NULL
104042 +check_lpt_crc_14442 check_lpt_crc 0 14442 NULL
104043 +block_size_14443 block_size 0 14443 NULL
104044 +lmv_user_md_size_14456 lmv_user_md_size 0-1 14456 NULL
104045 +snd_emu10k1_proc_spdif_status_14457 snd_emu10k1_proc_spdif_status 4-5 14457 NULL
104046 +lustre_msg_size_v2_14470 lustre_msg_size_v2 0 14470 NULL
104047 +dma_transfer_size_14473 dma_transfer_size 0 14473 NULL
104048 +udplite_getfrag_14479 udplite_getfrag 3-4 14479 NULL
104049 +efx_mdio_check_mmds_14486 efx_mdio_check_mmds 2 14486 NULL nohasharray
104050 +ieee80211_if_read_dot11MeshGateAnnouncementProtocol_14486 ieee80211_if_read_dot11MeshGateAnnouncementProtocol 3 14486 &efx_mdio_check_mmds_14486
104051 +ocfs2_debug_read_14507 ocfs2_debug_read 3 14507 NULL
104052 +ep0_write_14536 ep0_write 3 14536 NULL nohasharray
104053 +dataflash_read_user_otp_14536 dataflash_read_user_otp 3-2 14536 &ep0_write_14536
104054 +register_trace_sched_switch_14545 register_trace_sched_switch 0 14545 NULL
104055 +picolcd_debug_eeprom_read_14549 picolcd_debug_eeprom_read 3 14549 NULL
104056 +drm_vmalloc_dma_14550 drm_vmalloc_dma 1 14550 NULL
104057 +qp_host_alloc_queue_14566 qp_host_alloc_queue 1 14566 NULL
104058 +SyS_setdomainname_14569 SyS_setdomainname 2 14569 NULL
104059 +remap_to_origin_then_cache_14583 remap_to_origin_then_cache 3 14583 NULL
104060 +idmap_pipe_downcall_14591 idmap_pipe_downcall 3 14591 NULL
104061 +ceph_osdc_alloc_request_14597 ceph_osdc_alloc_request 3 14597 NULL
104062 +ocfs2_steal_meta_14602 ocfs2_steal_meta 0 14602 NULL
104063 +ocfs2_trim_group_14641 ocfs2_trim_group 4-3 14641 NULL
104064 +dbJoin_14644 dbJoin 0 14644 NULL
104065 +profile_replace_14652 profile_replace 3 14652 NULL
104066 +add_to_page_cache_locked_14668 add_to_page_cache_locked 0 14668 NULL
104067 +min_bytes_needed_14675 min_bytes_needed 0 14675 NULL
104068 +nvme_trans_log_info_exceptions_14677 nvme_trans_log_info_exceptions 3 14677 NULL
104069 +pipeline_enc_tx_stat_fifo_int_read_14680 pipeline_enc_tx_stat_fifo_int_read 3 14680 NULL
104070 +ieee80211_if_fmt_rc_rateidx_mask_2ghz_14683 ieee80211_if_fmt_rc_rateidx_mask_2ghz 3 14683 NULL
104071 +SyS_fsetxattr_14702 SyS_fsetxattr 4 14702 NULL
104072 +persistent_ram_ecc_string_14704 persistent_ram_ecc_string 0 14704 NULL
104073 +u_audio_playback_14709 u_audio_playback 3 14709 NULL
104074 +rtw_cbuf_alloc_14710 rtw_cbuf_alloc 1 14710 NULL
104075 +cgroup_path_14713 cgroup_path 3 14713 NULL
104076 +get_bio_block_14714 get_bio_block 0 14714 NULL
104077 +vfd_write_14717 vfd_write 3 14717 NULL
104078 +SyS_sendfile_14718 SyS_sendfile 4 14718 NULL
104079 +__blk_end_request_14729 __blk_end_request 3 14729 NULL
104080 +raid1_resize_14740 raid1_resize 2 14740 NULL
104081 +i915_error_state_buf_init_14742 i915_error_state_buf_init 2 14742 NULL
104082 +btrfs_inode_extref_name_len_14752 btrfs_inode_extref_name_len 0 14752 NULL
104083 +rx_rx_cmplt_read_14753 rx_rx_cmplt_read 3 14753 NULL
104084 +regmap_range_read_file_14775 regmap_range_read_file 3 14775 NULL
104085 +sta_dev_read_14782 sta_dev_read 3 14782 NULL
104086 +keys_proc_write_14792 keys_proc_write 3 14792 NULL
104087 +ext4_kvmalloc_14796 ext4_kvmalloc 1 14796 NULL
104088 +__kfifo_in_14797 __kfifo_in 3-0 14797 NULL
104089 +hpet_readl_14801 hpet_readl 0 14801 NULL nohasharray
104090 +snd_als300_gcr_read_14801 snd_als300_gcr_read 0 14801 &hpet_readl_14801
104091 +changed_cb_14819 changed_cb 0 14819 NULL
104092 +do_tune_cpucache_14828 do_tune_cpucache 2 14828 NULL
104093 +mrp_attr_create_14853 mrp_attr_create 3 14853 NULL
104094 +lcd_write_14857 lcd_write 3 14857 NULL
104095 +get_user_cpu_mask_14861 get_user_cpu_mask 2 14861 NULL
104096 +gmux_index_read8_14890 gmux_index_read8 0 14890 NULL
104097 +acpi_os_allocate_14892 acpi_os_allocate 1 14892 NULL
104098 +SYSC_readv_14901 SYSC_readv 3 14901 NULL
104099 +regmap_irq_get_virq_14910 regmap_irq_get_virq 2-0 14910 NULL
104100 +__arch_hweight64_14923 __arch_hweight64 0 14923 NULL nohasharray
104101 +qp_memcpy_to_queue_iov_14923 qp_memcpy_to_queue_iov 5-2 14923 &__arch_hweight64_14923
104102 +ocfs2_expand_nonsparse_inode_14936 ocfs2_expand_nonsparse_inode 3-4 14936 NULL
104103 +range_to_mtrr_14940 range_to_mtrr 2 14940 NULL
104104 +queue_cnt_14951 queue_cnt 0 14951 NULL
104105 +unix_dgram_recvmsg_14952 unix_dgram_recvmsg 4 14952 NULL
104106 +i915_vma_unbind_14954 i915_vma_unbind 0 14954 NULL
104107 +videobuf_read_stream_14956 videobuf_read_stream 3 14956 NULL
104108 +mce_flush_rx_buffer_14976 mce_flush_rx_buffer 2 14976 NULL
104109 +setkey_14987 setkey 3 14987 NULL nohasharray
104110 +gpio_twl4030_write_14987 gpio_twl4030_write 1 14987 &setkey_14987
104111 +xfs_dinode_size_14996 xfs_dinode_size 0 14996 NULL
104112 +blk_integrity_tuple_size_15027 blk_integrity_tuple_size 0 15027 NULL
104113 +irq_get_next_irq_15053 irq_get_next_irq 1-0 15053 NULL
104114 +cld_pipe_downcall_15058 cld_pipe_downcall 3 15058 NULL
104115 +ieee80211_if_read_uapsd_max_sp_len_15067 ieee80211_if_read_uapsd_max_sp_len 3 15067 NULL
104116 +nfs4_write_cached_acl_15070 nfs4_write_cached_acl 4 15070 NULL
104117 +ntfs_copy_from_user_15072 ntfs_copy_from_user 3-5-0 15072 NULL
104118 +pppoe_recvmsg_15073 pppoe_recvmsg 4 15073 NULL
104119 +ceph_calc_ceph_pg_15075 ceph_calc_ceph_pg 0 15075 NULL
104120 +perf_trace_sched_stat_runtime_15115 perf_trace_sched_stat_runtime 3 15115 NULL
104121 +hex_dump_to_buffer_15121 hex_dump_to_buffer 6 15121 NULL
104122 +start_port_15124 start_port 0 15124 NULL
104123 +ipwireless_ppp_mru_15153 ipwireless_ppp_mru 0 15153 NULL
104124 +iwl_dbgfs_sta_drain_write_15167 iwl_dbgfs_sta_drain_write 3 15167 NULL
104125 +self_check_not_bad_15175 self_check_not_bad 0 15175 NULL
104126 +SYSC_setdomainname_15180 SYSC_setdomainname 2 15180 NULL
104127 +iscsi_create_endpoint_15193 iscsi_create_endpoint 1 15193 NULL
104128 +reserve_resources_15194 reserve_resources 3 15194 NULL
104129 +mtt_alloc_res_15211 mtt_alloc_res 5 15211 NULL
104130 +bfad_debugfs_write_regrd_15218 bfad_debugfs_write_regrd 3 15218 NULL
104131 +iwl_dbgfs_sram_write_15239 iwl_dbgfs_sram_write 3 15239 NULL
104132 +il_dbgfs_rx_stats_read_15243 il_dbgfs_rx_stats_read 3 15243 NULL
104133 +div64_u64_15263 div64_u64 0-1-2 15263 NULL
104134 +simple_strtol_15273 simple_strtol 0 15273 NULL
104135 +fw_realloc_buffer_15280 fw_realloc_buffer 2 15280 NULL
104136 +arch_enable_uv_irq_15294 arch_enable_uv_irq 2 15294 NULL
104137 +acpi_ev_create_gpe_block_15297 acpi_ev_create_gpe_block 5 15297 NULL
104138 +ocfs2_read_refcount_block_15305 ocfs2_read_refcount_block 0 15305 NULL
104139 +__ocfs2_remove_xattr_range_15330 __ocfs2_remove_xattr_range 4-3-5 15330 NULL
104140 +bfloat_mantissa_15334 bfloat_mantissa 0 15334 NULL
104141 +xlog_ticket_alloc_15335 xlog_ticket_alloc 2 15335 NULL
104142 +kovaplus_sysfs_read_15337 kovaplus_sysfs_read 6 15337 NULL
104143 +ioread16_15342 ioread16 0 15342 NULL
104144 +ept_prefetch_gpte_15348 ept_prefetch_gpte 4 15348 NULL
104145 +acpi_ut_create_string_object_15360 acpi_ut_create_string_object 1 15360 NULL
104146 +count_inode_extrefs_15366 count_inode_extrefs 0 15366 NULL
104147 +ext4_direct_IO_15369 ext4_direct_IO 4 15369 NULL
104148 +graph_depth_read_15371 graph_depth_read 3 15371 NULL
104149 +compat_sys_process_vm_readv_15374 compat_sys_process_vm_readv 3-5 15374 NULL
104150 +fq_codel_zalloc_15378 fq_codel_zalloc 1 15378 NULL
104151 +domain_flush_pages_15379 domain_flush_pages 2-3 15379 NULL
104152 +alloc_fddidev_15382 alloc_fddidev 1 15382 NULL
104153 +btrfs_level_size_15392 btrfs_level_size 0 15392 NULL
104154 +pipeline_csum_to_rx_xfer_swi_read_15403 pipeline_csum_to_rx_xfer_swi_read 3 15403 NULL
104155 +get_modalias_15406 get_modalias 2 15406 NULL
104156 +blockdev_direct_IO_15408 blockdev_direct_IO 0-5 15408 NULL
104157 +dm_cache_resize_15422 dm_cache_resize 2 15422 NULL
104158 +__videobuf_copy_to_user_15423 __videobuf_copy_to_user 4-0 15423 NULL
104159 +tcp_mtu_to_mss_15438 tcp_mtu_to_mss 2-0 15438 NULL
104160 +hpsa_change_queue_depth_15449 hpsa_change_queue_depth 2 15449 NULL
104161 +memweight_15450 memweight 2 15450 NULL
104162 +vmalloc_15464 vmalloc 1 15464 NULL
104163 +__mutex_lock_killable_slowpath_15472 __mutex_lock_killable_slowpath 0 15472 NULL
104164 +insert_old_idx_znode_15500 insert_old_idx_znode 0 15500 NULL
104165 +zd_chip_is_zd1211b_15518 zd_chip_is_zd1211b 0 15518 NULL
104166 +ifx_spi_write_15531 ifx_spi_write 3 15531 NULL
104167 +da9052_bat_irq_15533 da9052_bat_irq 1 15533 NULL
104168 +p9_check_zc_errors_15534 p9_check_zc_errors 4 15534 NULL
104169 +xfrm_state_mtu_15548 xfrm_state_mtu 0-2 15548 NULL
104170 +snd_pcm_channel_info_15572 snd_pcm_channel_info 0 15572 NULL
104171 +persistent_status_15574 persistent_status 4 15574 NULL
104172 +bnx2fc_process_unsol_compl_15576 bnx2fc_process_unsol_compl 2 15576 NULL
104173 +cl_io_submit_sync_15579 cl_io_submit_sync 0 15579 NULL
104174 +vme_user_write_15587 vme_user_write 3 15587 NULL
104175 +ocfs2_truncate_rec_15595 ocfs2_truncate_rec 7-0 15595 NULL
104176 +sx150x_install_irq_chip_15609 sx150x_install_irq_chip 3 15609 NULL
104177 +iommu_device_max_index_15620 iommu_device_max_index 0-3-2-1 15620 NULL nohasharray
104178 +compat_fillonedir_15620 compat_fillonedir 3 15620 &iommu_device_max_index_15620
104179 +proc_loginuid_read_15631 proc_loginuid_read 3 15631 NULL
104180 +tomoyo_scan_bprm_15642 tomoyo_scan_bprm 4-2 15642 NULL nohasharray
104181 +sk_memory_allocated_add_15642 sk_memory_allocated_add 2 15642 &tomoyo_scan_bprm_15642 nohasharray
104182 +pipeline_hs_tx_stat_fifo_int_read_15642 pipeline_hs_tx_stat_fifo_int_read 3 15642 &sk_memory_allocated_add_15642
104183 +joydev_handle_JSIOCSBTNMAP_15643 joydev_handle_JSIOCSBTNMAP 3 15643 NULL
104184 +fs_path_add_15648 fs_path_add 3-0 15648 NULL
104185 +xsd_read_15653 xsd_read 3 15653 NULL
104186 +unix_bind_15668 unix_bind 3 15668 NULL
104187 +SyS_connect_15674 SyS_connect 3 15674 NULL nohasharray
104188 +dm_read_15674 dm_read 3 15674 &SyS_connect_15674
104189 +pstore_mkfile_15675 pstore_mkfile 6 15675 NULL
104190 +i915_gem_object_set_to_cpu_domain_15705 i915_gem_object_set_to_cpu_domain 0 15705 NULL nohasharray
104191 +uncore_alloc_box_15705 uncore_alloc_box 2 15705 &i915_gem_object_set_to_cpu_domain_15705
104192 +ocfs2_split_tree_15716 ocfs2_split_tree 5-0 15716 NULL
104193 +tracing_snapshot_write_15719 tracing_snapshot_write 3 15719 NULL
104194 +HiSax_readstatus_15752 HiSax_readstatus 2 15752 NULL
104195 +ftrace_profile_init_cpu_15761 ftrace_profile_init_cpu 0 15761 NULL
104196 +bitmap_search_next_usable_block_15762 bitmap_search_next_usable_block 3-1-0 15762 NULL
104197 +i915_gem_init_seqno_15793 i915_gem_init_seqno 0 15793 NULL
104198 +smk_read_direct_15803 smk_read_direct 3 15803 NULL
104199 +nameseq_list_15817 nameseq_list 3-0 15817 NULL nohasharray
104200 +gnttab_expand_15817 gnttab_expand 1 15817 &nameseq_list_15817
104201 +afs_proc_rootcell_write_15822 afs_proc_rootcell_write 3 15822 NULL
104202 +brcmf_sdbrcm_died_dump_15841 brcmf_sdbrcm_died_dump 3 15841 NULL
104203 +table_size_15851 table_size 0-1-2 15851 NULL
104204 +ubi_io_write_15870 ubi_io_write 0-5-4 15870 NULL nohasharray
104205 +media_entity_init_15870 media_entity_init 2-4 15870 &ubi_io_write_15870
104206 +__mptctl_ioctl_15875 __mptctl_ioctl 2 15875 NULL
104207 +profile_pc_15887 profile_pc 0 15887 NULL
104208 +nfs_map_group_to_gid_15892 nfs_map_group_to_gid 3 15892 NULL
104209 +native_read_msr_15905 native_read_msr 0 15905 NULL
104210 +parse_audio_stream_data_15937 parse_audio_stream_data 3 15937 NULL
104211 +power_read_15939 power_read 3 15939 NULL
104212 +lpfc_idiag_drbacc_read_15948 lpfc_idiag_drbacc_read 3 15948 NULL
104213 +snd_pcm_lib_read_transfer_15952 snd_pcm_lib_read_transfer 5-2-4 15952 NULL
104214 +tfrc_calc_x_15975 tfrc_calc_x 2-1 15975 NULL
104215 +frame_alloc_15981 frame_alloc 4 15981 NULL
104216 +hdpvr_register_videodev_16010 hdpvr_register_videodev 3 16010 NULL
104217 +viafb_vt1636_proc_write_16018 viafb_vt1636_proc_write 3 16018 NULL
104218 +i915_gem_object_pin_16032 i915_gem_object_pin 0 16032 NULL
104219 +dccp_recvmsg_16056 dccp_recvmsg 4 16056 NULL
104220 +read_file_spectral_period_16057 read_file_spectral_period 3 16057 NULL
104221 +si5351_msynth_params_address_16062 si5351_msynth_params_address 0-1 16062 NULL
104222 +ocfs2_sync_local_to_main_16076 ocfs2_sync_local_to_main 0 16076 NULL
104223 +isr_tx_exch_complete_read_16103 isr_tx_exch_complete_read 3 16103 NULL
104224 +dma_tx_requested_read_16110 dma_tx_requested_read 3 16110 NULL nohasharray
104225 +isr_hw_pm_mode_changes_read_16110 isr_hw_pm_mode_changes_read 3 16110 &dma_tx_requested_read_16110
104226 +irq_set_chip_and_handler_name_16111 irq_set_chip_and_handler_name 1 16111 NULL
104227 +snd_dma_pointer_16126 snd_dma_pointer 0-2 16126 NULL
104228 +compat_sys_select_16131 compat_sys_select 1 16131 NULL
104229 +fsm_init_16134 fsm_init 2 16134 NULL
104230 +ext4_xattr_block_get_16148 ext4_xattr_block_get 0 16148 NULL
104231 +update_block_group_16155 update_block_group 0 16155 NULL
104232 +optimal_reclaimed_pages_16172 optimal_reclaimed_pages 0 16172 NULL
104233 +mapping_level_16188 mapping_level 2 16188 NULL
104234 +i40e_allocate_virt_mem_d_16191 i40e_allocate_virt_mem_d 3 16191 NULL
104235 +tcp_syn_options_16197 tcp_syn_options 0 16197 NULL
104236 +ath10k_htt_rx_ring_size_16201 ath10k_htt_rx_ring_size 0 16201 NULL
104237 +cipso_v4_map_cat_rng_hton_16203 cipso_v4_map_cat_rng_hton 0 16203 NULL
104238 +SyS_pselect6_16210 SyS_pselect6 1 16210 NULL
104239 +create_table_16213 create_table 2 16213 NULL
104240 +atomic_read_file_16227 atomic_read_file 3 16227 NULL
104241 +BcmGetSectionValStartOffset_16235 BcmGetSectionValStartOffset 0 16235 NULL
104242 +lov_prep_brw_set_16246 lov_prep_brw_set 3 16246 NULL
104243 +i40e_dbg_dump_read_16247 i40e_dbg_dump_read 3 16247 NULL nohasharray
104244 +btrfs_dev_extent_chunk_offset_16247 btrfs_dev_extent_chunk_offset 0 16247 &i40e_dbg_dump_read_16247
104245 +il_dbgfs_disable_ht40_write_16249 il_dbgfs_disable_ht40_write 3 16249 NULL
104246 +SyS_fgetxattr_16254 SyS_fgetxattr 4 16254 NULL
104247 +reiserfs_acl_count_16265 reiserfs_acl_count 0-1 16265 NULL
104248 +mq_force_mapping_16277 mq_force_mapping 2 16277 NULL
104249 +ocfs2_xattr_bucket_value_truncate_16279 ocfs2_xattr_bucket_value_truncate 4 16279 NULL
104250 +drbd_setsockopt_16280 drbd_setsockopt 5 16280 NULL nohasharray
104251 +nand_bch_init_16280 nand_bch_init 2-3 16280 &drbd_setsockopt_16280
104252 +account_16283 account 0-4-2 16283 NULL nohasharray
104253 +mirror_status_16283 mirror_status 5 16283 &account_16283
104254 +retry_instruction_16285 retry_instruction 2 16285 NULL
104255 +jumpshot_read_data_16287 jumpshot_read_data 4 16287 NULL
104256 +mo_xattr_get_16288 mo_xattr_get 0 16288 NULL
104257 +stk_allocate_buffers_16291 stk_allocate_buffers 2 16291 NULL
104258 +rbd_segment_offset_16293 rbd_segment_offset 0-2 16293 NULL
104259 +tfrc_invert_loss_event_rate_16295 tfrc_invert_loss_event_rate 1 16295 NULL
104260 +rsc_mgr_init_16299 rsc_mgr_init 3 16299 NULL
104261 +wb_map_16301 wb_map 2 16301 NULL
104262 +kvm_handle_hva_range_16312 kvm_handle_hva_range 3-2 16312 NULL
104263 +ext4_blocks_count_16320 ext4_blocks_count 0 16320 NULL
104264 +vmw_cursor_update_image_16332 vmw_cursor_update_image 3-4 16332 NULL
104265 +btrfs_insert_item_16357 btrfs_insert_item 0 16357 NULL
104266 +sysfs_create_groups_16360 sysfs_create_groups 0 16360 NULL
104267 +total_ps_buffered_read_16365 total_ps_buffered_read 3 16365 NULL
104268 +iscsi_tcp_conn_setup_16376 iscsi_tcp_conn_setup 2 16376 NULL
104269 +diva_os_malloc_16406 diva_os_malloc 2 16406 NULL
104270 +ieee80211_if_read_tsf_16420 ieee80211_if_read_tsf 3 16420 NULL
104271 +rxrpc_server_keyring_16431 rxrpc_server_keyring 3 16431 NULL
104272 +__bio_add_page_16435 __bio_add_page 0-4 16435 NULL
104273 +btrfs_truncate_inode_items_16452 btrfs_truncate_inode_items 0 16452 NULL
104274 +ocfs2_expand_refcount_tree_16455 ocfs2_expand_refcount_tree 0 16455 NULL
104275 +netlink_change_ngroups_16457 netlink_change_ngroups 2 16457 NULL
104276 +alloc_disk_node_16458 alloc_disk_node 2 16458 NULL
104277 +req_capsule_get_size_16467 req_capsule_get_size 0 16467 NULL
104278 +ocfs2_block_group_set_bits_16488 ocfs2_block_group_set_bits 0 16488 NULL
104279 +add_qgroup_item_16492 add_qgroup_item 0 16492 NULL
104280 +tracing_readme_read_16493 tracing_readme_read 3 16493 NULL
104281 +filemap_write_and_wait_16506 filemap_write_and_wait 0 16506 NULL
104282 +start_this_handle_16519 start_this_handle 0 16519 NULL
104283 +snd_interval_max_16529 snd_interval_max 0 16529 NULL
104284 +raid10_resize_16537 raid10_resize 2 16537 NULL
104285 +lpfc_debugfs_read_16566 lpfc_debugfs_read 3 16566 NULL
104286 +perf_event_set_period_16574 perf_event_set_period 2-3 16574 NULL
104287 +agp_allocate_memory_wrap_16576 agp_allocate_memory_wrap 1 16576 NULL
104288 +lustre_msg_hdr_size_v2_16589 lustre_msg_hdr_size_v2 0 16589 NULL
104289 +btrfs_insert_orphan_item_16602 btrfs_insert_orphan_item 0 16602 NULL
104290 +gmux_index_read32_16604 gmux_index_read32 0 16604 NULL
104291 +btrfs_end_transaction_16610 btrfs_end_transaction 0 16610 NULL
104292 +palmas_irq_get_virq_16613 palmas_irq_get_virq 2 16613 NULL
104293 +btrfs_wait_marked_extents_16615 btrfs_wait_marked_extents 0 16615 NULL
104294 +rtw_set_wpa_ie_16633 rtw_set_wpa_ie 3 16633 NULL
104295 +btrfs_get_token_32_16651 btrfs_get_token_32 0 16651 NULL
104296 +packet_recv_error_16669 packet_recv_error 3 16669 NULL
104297 +__proc_lnet_buffers_16717 __proc_lnet_buffers 5 16717 NULL
104298 +__copy_to_user_swizzled_16748 __copy_to_user_swizzled 3-4 16748 NULL
104299 +arcmsr_adjust_disk_queue_depth_16756 arcmsr_adjust_disk_queue_depth 2 16756 NULL
104300 +blk_rq_map_user_iov_16772 blk_rq_map_user_iov 5 16772 NULL
104301 +i2o_parm_issue_16790 i2o_parm_issue 0 16790 NULL
104302 +get_server_iovec_16804 get_server_iovec 2 16804 NULL
104303 +tipc_send2name_16809 tipc_send2name 6 16809 NULL
104304 +dm_vcalloc_16814 dm_vcalloc 1-2 16814 NULL
104305 +cache_grow_16818 cache_grow 3 16818 NULL
104306 +drm_malloc_ab_16831 drm_malloc_ab 1-2 16831 NULL
104307 +scsi_mode_sense_16835 scsi_mode_sense 5 16835 NULL
104308 +hfsplus_min_io_size_16859 hfsplus_min_io_size 0 16859 NULL
104309 +alloc_idx_lebs_16872 alloc_idx_lebs 2 16872 NULL
104310 +carl9170_debugfs_ampdu_state_read_16873 carl9170_debugfs_ampdu_state_read 3 16873 NULL
104311 +st_write_16874 st_write 3 16874 NULL
104312 +__kfifo_peek_n_16877 __kfifo_peek_n 0 16877 NULL
104313 +transport_init_session_tags_16878 transport_init_session_tags 1-2 16878 NULL
104314 +ext4_ext_zeroout_16895 ext4_ext_zeroout 0 16895 NULL
104315 +psb_unlocked_ioctl_16926 psb_unlocked_ioctl 2 16926 NULL nohasharray
104316 +snd_gf1_mem_proc_dump_16926 snd_gf1_mem_proc_dump 5 16926 &psb_unlocked_ioctl_16926
104317 +_sp2d_alloc_16944 _sp2d_alloc 3-2-1 16944 NULL
104318 +squashfs_read_table_16945 squashfs_read_table 3 16945 NULL
104319 +wrm_16966 wrm 0 16966 NULL
104320 +keyctl_instantiate_key_iov_16969 keyctl_instantiate_key_iov 3 16969 NULL
104321 +ocfs2_read_quota_phys_block_16990 ocfs2_read_quota_phys_block 0 16990 NULL
104322 +ceph_read_dir_17005 ceph_read_dir 3 17005 NULL
104323 +snd_mask_refine_first_17026 snd_mask_refine_first 0 17026 NULL
104324 +copy_counters_to_user_17027 copy_counters_to_user 5 17027 NULL
104325 +btrfs_unlink_inode_17043 btrfs_unlink_inode 0 17043 NULL
104326 +jffs2_trusted_setxattr_17048 jffs2_trusted_setxattr 4 17048 NULL
104327 +__arch_hweight32_17060 __arch_hweight32 0 17060 NULL
104328 +__copy_user_nocache_17065 __copy_user_nocache 0 17065 NULL
104329 +sddr55_read_data_17072 sddr55_read_data 4 17072 NULL
104330 +dvb_dvr_read_17073 dvb_dvr_read 3 17073 NULL
104331 +simple_transaction_read_17076 simple_transaction_read 3 17076 NULL
104332 +__kmalloc_reserve_17080 __kmalloc_reserve 3 17080 NULL
104333 +carl9170_debugfs_mem_usage_read_17084 carl9170_debugfs_mem_usage_read 3 17084 NULL
104334 +entry_length_17093 entry_length 0 17093 NULL
104335 +ocfs2_get_refcount_cpos_end_17113 ocfs2_get_refcount_cpos_end 0 17113 NULL
104336 +write_mem_17114 write_mem 3 17114 NULL
104337 +pvr2_hdw_state_report_17121 pvr2_hdw_state_report 3 17121 NULL
104338 +wrmaltWithLock_17139 wrmaltWithLock 0 17139 NULL
104339 +nouveau_instobj_create__17144 nouveau_instobj_create_ 4 17144 NULL
104340 +jumpshot_write_data_17151 jumpshot_write_data 4 17151 NULL
104341 +sep_read_17161 sep_read 3 17161 NULL
104342 +befs_nls2utf_17163 befs_nls2utf 3 17163 NULL
104343 +tx_tx_start_templates_read_17164 tx_tx_start_templates_read 3 17164 NULL
104344 +UniStrnlen_17169 UniStrnlen 0 17169 NULL
104345 +ocfs2_flock_handle_signal_17189 ocfs2_flock_handle_signal 0 17189 NULL nohasharray
104346 +access_remote_vm_17189 access_remote_vm 0-4-2 17189 &ocfs2_flock_handle_signal_17189 nohasharray
104347 +iwl_dbgfs_txfifo_flush_write_17189 iwl_dbgfs_txfifo_flush_write 3 17189 &access_remote_vm_17189
104348 +driver_state_read_17194 driver_state_read 3 17194 NULL nohasharray
104349 +iscsit_find_cmd_from_itt_or_dump_17194 iscsit_find_cmd_from_itt_or_dump 3 17194 &driver_state_read_17194
104350 +sync_request_17208 sync_request 2 17208 NULL
104351 +dn_recvmsg_17213 dn_recvmsg 4 17213 NULL
104352 +send_write_or_clone_17241 send_write_or_clone 0 17241 NULL
104353 +to_oblock_17254 to_oblock 0-1 17254 NULL
104354 +unpack_value_17259 unpack_value 1 17259 NULL
104355 +lprocfs_read_frac_helper_17261 lprocfs_read_frac_helper 0 17261 NULL
104356 +error_error_frame_cts_nul_flid_read_17262 error_error_frame_cts_nul_flid_read 3 17262 NULL
104357 +alloc_reserved_file_extent_17267 alloc_reserved_file_extent 0 17267 NULL
104358 +alloc_ep_17269 alloc_ep 1 17269 NULL
104359 +hw_test_and_write_17271 hw_test_and_write 3 17271 NULL
104360 +pg_read_17276 pg_read 3 17276 NULL
104361 +raw_recvmsg_17277 raw_recvmsg 4 17277 NULL
104362 +hmac_sha256_17278 hmac_sha256 2 17278 NULL
104363 +neigh_hash_grow_17283 neigh_hash_grow 2 17283 NULL
104364 +minstrel_stats_read_17290 minstrel_stats_read 3 17290 NULL
104365 +install_breakpoint_17292 install_breakpoint 4 17292 NULL
104366 +ieee80211_if_fmt_dot11MeshForwarding_17301 ieee80211_if_fmt_dot11MeshForwarding 3 17301 NULL
104367 +mb_cache_create_17307 mb_cache_create 2 17307 NULL
104368 +gnttab_map_frames_v2_17314 gnttab_map_frames_v2 2 17314 NULL
104369 +SYSC_pread64_17337 SYSC_pread64 3 17337 NULL
104370 +ieee80211_if_read_dot11MeshHWMPperrMinInterval_17346 ieee80211_if_read_dot11MeshHWMPperrMinInterval 3 17346 NULL
104371 +ath6kl_wmi_send_mgmt_cmd_17347 ath6kl_wmi_send_mgmt_cmd 7 17347 NULL
104372 +mdc_import_seq_write_17409 mdc_import_seq_write 3 17409 NULL
104373 +lpfc_debugfs_dif_err_write_17424 lpfc_debugfs_dif_err_write 3 17424 NULL
104374 +compat_sys_ppoll_17430 compat_sys_ppoll 2 17430 NULL
104375 +sta_connected_time_read_17435 sta_connected_time_read 3 17435 NULL
104376 +SYSC_fcntl_17441 SYSC_fcntl 3 17441 NULL
104377 +libcfs_ipif_enumerate_17445 libcfs_ipif_enumerate 0 17445 NULL
104378 +nla_get_u32_17455 nla_get_u32 0 17455 NULL
104379 +__ref_totlen_17461 __ref_totlen 0 17461 NULL
104380 +probe_kernel_write_17481 probe_kernel_write 3 17481 NULL
104381 +TSS_rawhmac_17486 TSS_rawhmac 3 17486 NULL
104382 +lookup_tree_block_ref_17494 lookup_tree_block_ref 0 17494 NULL
104383 +bitmap_pos_to_ord_17503 bitmap_pos_to_ord 3 17503 NULL
104384 +lbs_highrssi_write_17515 lbs_highrssi_write 3 17515 NULL
104385 +qp_free_res_17541 qp_free_res 5 17541 NULL
104386 +xlog_do_log_recovery_17550 xlog_do_log_recovery 3 17550 NULL
104387 +__copy_to_user_17551 __copy_to_user 3-0 17551 NULL
104388 +copy_from_user_17559 copy_from_user 3-0 17559 NULL
104389 +snd_pcm_action_lock_irq_17569 snd_pcm_action_lock_irq 0 17569 NULL
104390 +acpi_ut_create_package_object_17594 acpi_ut_create_package_object 1 17594 NULL
104391 +neigh_hash_alloc_17595 neigh_hash_alloc 1 17595 NULL
104392 +__inode_info_17603 __inode_info 0 17603 NULL
104393 +wm8994_gpio_to_irq_17604 wm8994_gpio_to_irq 2 17604 NULL
104394 +osst_execute_17607 osst_execute 7-6 17607 NULL
104395 +ocfs2_mark_extent_written_17615 ocfs2_mark_extent_written 6 17615 NULL
104396 +ieee80211_if_read_dot11MeshHWMPactivePathToRootTimeout_17618 ieee80211_if_read_dot11MeshHWMPactivePathToRootTimeout 3 17618 NULL
104397 +dma_map_page_17628 dma_map_page 0 17628 NULL
104398 +ocfs2_rotate_subtree_left_17634 ocfs2_rotate_subtree_left 0 17634 NULL
104399 +twl4030_set_gpio_direction_17645 twl4030_set_gpio_direction 1 17645 NULL
104400 +SYSC_migrate_pages_17657 SYSC_migrate_pages 2 17657 NULL
104401 +packet_setsockopt_17662 packet_setsockopt 5 17662 NULL nohasharray
104402 +ubi_io_read_data_17662 ubi_io_read_data 0 17662 &packet_setsockopt_17662
104403 +kernel_write_17665 kernel_write 3 17665 NULL
104404 +pwr_enable_ps_read_17686 pwr_enable_ps_read 3 17686 NULL
104405 +filemap_fdatawait_17688 filemap_fdatawait 0 17688 NULL
104406 +gfn_to_pfn_memslot_17693 gfn_to_pfn_memslot 2-0 17693 NULL
104407 +__einj_error_trigger_17707 __einj_error_trigger 0 17707 NULL nohasharray
104408 +venus_rename_17707 venus_rename 4-5 17707 &__einj_error_trigger_17707
104409 +exofs_read_lookup_dev_table_17733 exofs_read_lookup_dev_table 3 17733 NULL
104410 +sctpprobe_read_17741 sctpprobe_read 3 17741 NULL
104411 +mark_unsafe_pages_17759 mark_unsafe_pages 0 17759 NULL
104412 +dgap_do_fep_load_17765 dgap_do_fep_load 3 17765 NULL
104413 +dtf_read_run_17768 dtf_read_run 3 17768 NULL
104414 +brcmf_sdio_chip_verifynvram_17776 brcmf_sdio_chip_verifynvram 4 17776 NULL
104415 +hash_ipport6_expire_17784 hash_ipport6_expire 3 17784 NULL
104416 +perf_clock_17787 perf_clock 0 17787 NULL
104417 +ubifs_leb_change_17789 ubifs_leb_change 0-4 17789 NULL
104418 +get_unaligned_be64_17794 get_unaligned_be64 0 17794 NULL nohasharray
104419 +shrink_slab_node_17794 shrink_slab_node 3-4 17794 &get_unaligned_be64_17794
104420 +bkey_to_cacheline_17811 bkey_to_cacheline 0 17811 NULL
104421 +_snd_pcm_lib_alloc_vmalloc_buffer_17820 _snd_pcm_lib_alloc_vmalloc_buffer 2 17820 NULL
104422 +gnet_stats_copy_app_17821 gnet_stats_copy_app 3 17821 NULL
104423 +cipso_v4_gentag_rbm_17836 cipso_v4_gentag_rbm 0 17836 NULL
104424 +dm_stats_message_17863 dm_stats_message 5 17863 NULL
104425 +sisusb_send_bulk_msg_17864 sisusb_send_bulk_msg 3 17864 NULL
104426 +alloc_sja1000dev_17868 alloc_sja1000dev 1 17868 NULL
104427 +ray_cs_essid_proc_write_17875 ray_cs_essid_proc_write 3 17875 NULL
104428 +orinoco_set_key_17878 orinoco_set_key 7-5 17878 NULL nohasharray
104429 +i40e_align_l2obj_base_17878 i40e_align_l2obj_base 0-1 17878 &orinoco_set_key_17878
104430 +init_per_cpu_17880 init_per_cpu 1 17880 NULL
104431 +ieee80211_if_fmt_dot11MeshMaxPeerLinks_17883 ieee80211_if_fmt_dot11MeshMaxPeerLinks 3 17883 NULL
104432 +ieee80211_if_fmt_dot11MeshHWMPRootMode_17890 ieee80211_if_fmt_dot11MeshHWMPRootMode 3 17890 NULL
104433 +ocfs2_clusters_to_blocks_17896 ocfs2_clusters_to_blocks 0-2 17896 NULL
104434 +recover_head_17904 recover_head 3 17904 NULL
104435 +xfs_buf_associate_memory_17915 xfs_buf_associate_memory 3 17915 NULL
104436 +scsi_bufflen_17933 scsi_bufflen 0 17933 NULL
104437 +__mutex_lock_check_stamp_17947 __mutex_lock_check_stamp 0 17947 NULL
104438 +beacon_interval_write_17952 beacon_interval_write 3 17952 NULL
104439 +ufs_free_blocks_17963 ufs_free_blocks 3-2 17963 NULL nohasharray
104440 +tlv_put_u64_17963 tlv_put_u64 0 17963 &ufs_free_blocks_17963
104441 +calc_nr_buckets_17976 calc_nr_buckets 0 17976 NULL
104442 +ext4_ext_calc_credits_for_single_extent_17983 ext4_ext_calc_credits_for_single_extent 0-2 17983 NULL
104443 +smk_write_cipso_17989 smk_write_cipso 3 17989 NULL
104444 +gnttab_max_grant_frames_17993 gnttab_max_grant_frames 0 17993 NULL
104445 +ext4_num_overhead_clusters_18001 ext4_num_overhead_clusters 2 18001 NULL
104446 +pvr2_v4l2_read_18006 pvr2_v4l2_read 3 18006 NULL
104447 +alloc_rx_desc_ring_18016 alloc_rx_desc_ring 2 18016 NULL
104448 +fill_read_18019 fill_read 0 18019 NULL
104449 +o2hb_highest_node_18034 o2hb_highest_node 2-0 18034 NULL
104450 +__posix_lock_file_18035 __posix_lock_file 0 18035 NULL
104451 +ocfs2_cache_cluster_dealloc_18043 ocfs2_cache_cluster_dealloc 0 18043 NULL
104452 +cryptd_alloc_instance_18048 cryptd_alloc_instance 3-2 18048 NULL
104453 +find_next_inuse_18051 find_next_inuse 2-3-0 18051 NULL
104454 +ddebug_proc_write_18055 ddebug_proc_write 3 18055 NULL
104455 +lua_sysfs_read_18062 lua_sysfs_read 6 18062 NULL
104456 +fpregs_get_18066 fpregs_get 4 18066 NULL
104457 +kvm_read_guest_page_18074 kvm_read_guest_page 5-2 18074 NULL
104458 +SYSC_pselect6_18076 SYSC_pselect6 1 18076 NULL
104459 +SYSC_semtimedop_18091 SYSC_semtimedop 3 18091 NULL
104460 +mpi_alloc_18094 mpi_alloc 1 18094 NULL
104461 +hfs_direct_IO_18104 hfs_direct_IO 4 18104 NULL
104462 +dfs_file_read_18116 dfs_file_read 3 18116 NULL
104463 +svc_getnl_18120 svc_getnl 0 18120 NULL
104464 +paging32_gpte_to_gfn_lvl_18131 paging32_gpte_to_gfn_lvl 0-2-1 18131 NULL
104465 +vmw_surface_dma_size_18132 vmw_surface_dma_size 0 18132 NULL
104466 +selinux_inode_setsecurity_18148 selinux_inode_setsecurity 4 18148 NULL
104467 +is_idx_node_in_use_18165 is_idx_node_in_use 0 18165 NULL
104468 +pccard_store_cis_18176 pccard_store_cis 6 18176 NULL
104469 +snd_pcm_hw_refine_user_18204 snd_pcm_hw_refine_user 0 18204 NULL
104470 +orinoco_add_extscan_result_18207 orinoco_add_extscan_result 3 18207 NULL
104471 +gsm_control_message_18209 gsm_control_message 4 18209 NULL
104472 +ocfs2_divide_leaf_refcount_block_18214 ocfs2_divide_leaf_refcount_block 0 18214 NULL
104473 +do_ipv6_setsockopt_18215 do_ipv6_setsockopt 5 18215 NULL
104474 +gnttab_alloc_grant_references_18240 gnttab_alloc_grant_references 1 18240 NULL
104475 +alloc_trace_uprobe_18247 alloc_trace_uprobe 3 18247 NULL
104476 +rfcomm_sock_setsockopt_18254 rfcomm_sock_setsockopt 5 18254 NULL
104477 +__sysfs_add_one_18258 __sysfs_add_one 0 18258 NULL
104478 +qdisc_class_hash_alloc_18262 qdisc_class_hash_alloc 1 18262 NULL
104479 +gfs2_alloc_sort_buffer_18275 gfs2_alloc_sort_buffer 1 18275 NULL
104480 +alloc_ring_18278 alloc_ring 4-2 18278 NULL
104481 +find_dirty_idx_leb_18280 find_dirty_idx_leb 0 18280 NULL
104482 +nouveau_subdev_create__18281 nouveau_subdev_create_ 7 18281 NULL nohasharray
104483 +bio_phys_segments_18281 bio_phys_segments 0 18281 &nouveau_subdev_create__18281
104484 +ext4_readpages_18283 ext4_readpages 4 18283 NULL
104485 +mmc_send_bus_test_18285 mmc_send_bus_test 4 18285 NULL
104486 +um_idi_write_18293 um_idi_write 3 18293 NULL
104487 +nouveau_disp_create__18305 nouveau_disp_create_ 4-7 18305 NULL
104488 +vga_r_18310 vga_r 0 18310 NULL
104489 +class_add_profile_18315 class_add_profile 1-3-5 18315 NULL
104490 +csio_mem_read_18319 csio_mem_read 3 18319 NULL
104491 +alloc_and_copy_string_18321 alloc_and_copy_string 2 18321 NULL
104492 +ecryptfs_send_message_18322 ecryptfs_send_message 2 18322 NULL
104493 +bio_integrity_advance_18324 bio_integrity_advance 2 18324 NULL
104494 +__inorder_to_tree_18329 __inorder_to_tree 0-3-1 18329 NULL
104495 +lcd_proc_write_18351 lcd_proc_write 3 18351 NULL
104496 +pwr_power_save_off_read_18355 pwr_power_save_off_read 3 18355 NULL
104497 +xlbd_reserve_minors_18365 xlbd_reserve_minors 1-2 18365 NULL
104498 +SyS_process_vm_readv_18366 SyS_process_vm_readv 5-3 18366 NULL
104499 +ep_io_18367 ep_io 0 18367 NULL
104500 +qib_user_sdma_num_pages_18371 qib_user_sdma_num_pages 0 18371 NULL
104501 +ci_role_write_18388 ci_role_write 3 18388 NULL nohasharray
104502 +irq_find_mapping_18388 irq_find_mapping 0-2 18388 &ci_role_write_18388
104503 +btrfs_update_inode_18394 btrfs_update_inode 0 18394 NULL
104504 +hdlc_empty_fifo_18397 hdlc_empty_fifo 2 18397 NULL
104505 +__video_register_device_18399 __video_register_device 3 18399 NULL
104506 +hash_ip4_expire_18402 hash_ip4_expire 3 18402 NULL nohasharray
104507 +adis16136_show_serial_18402 adis16136_show_serial 3 18402 &hash_ip4_expire_18402
104508 +btrfs_rmap_block_18403 btrfs_rmap_block 0 18403 NULL
104509 +crystalhd_user_data_18407 crystalhd_user_data 3 18407 NULL
104510 +batadv_orig_node_add_if_18433 batadv_orig_node_add_if 2 18433 NULL nohasharray
104511 +iscsi_create_flashnode_sess_18433 iscsi_create_flashnode_sess 4 18433 &batadv_orig_node_add_if_18433
104512 +snd_hda_get_connections_18437 snd_hda_get_connections 0 18437 NULL
104513 +btrfs_uuid_tree_lookup_18451 btrfs_uuid_tree_lookup 0 18451 NULL
104514 +flash_dev_cache_miss_18454 flash_dev_cache_miss 4 18454 NULL
104515 +fuse_perform_write_18457 fuse_perform_write 4 18457 NULL
104516 +regset_tls_set_18459 regset_tls_set 4 18459 NULL
104517 +pcibios_window_alignment_18460 pcibios_window_alignment 0 18460 NULL
104518 +dma_alloc_from_contiguous_18466 dma_alloc_from_contiguous 3-2 18466 NULL
104519 +pci_vpd_lrdt_size_18479 pci_vpd_lrdt_size 0 18479 NULL nohasharray
104520 +mite_bytes_in_transit_18479 mite_bytes_in_transit 0 18479 &pci_vpd_lrdt_size_18479
104521 +r600_texture_size_18487 r600_texture_size 4-5-6 18487 NULL nohasharray
104522 +udpv6_setsockopt_18487 udpv6_setsockopt 5 18487 &r600_texture_size_18487
104523 +btrfs_fiemap_18501 btrfs_fiemap 3 18501 NULL nohasharray
104524 +remap_pmd_range_18501 remap_pmd_range 3-4-5 18501 &btrfs_fiemap_18501
104525 +i915_gem_object_wait_fence_18508 i915_gem_object_wait_fence 0 18508 NULL
104526 +__copy_user_zeroing_intel_18510 __copy_user_zeroing_intel 0-3 18510 NULL
104527 +snd_vx_inb_18514 snd_vx_inb 0 18514 NULL
104528 +snd_gus_dram_poke_18525 snd_gus_dram_poke 4 18525 NULL
104529 +nouveau_fifo_channel_create__18530 nouveau_fifo_channel_create_ 9 18530 NULL
104530 +seq_copy_in_user_18543 seq_copy_in_user 3 18543 NULL
104531 +acpi_register_gsi_ioapic_18550 acpi_register_gsi_ioapic 2 18550 NULL
104532 +sas_change_queue_depth_18555 sas_change_queue_depth 2 18555 NULL
104533 +vb2_streamon_18562 vb2_streamon 0 18562 NULL
104534 +smk_write_rules_list_18565 smk_write_rules_list 3 18565 NULL
104535 +debug_output_18575 debug_output 3 18575 NULL
104536 +is_extent_unchanged_18576 is_extent_unchanged 0 18576 NULL
104537 +check_lpt_type_18577 check_lpt_type 0 18577 NULL
104538 +numa_node_id_18596 numa_node_id 0 18596 NULL
104539 +filemap_fdatawait_range_18600 filemap_fdatawait_range 0 18600 NULL nohasharray
104540 +slabinfo_write_18600 slabinfo_write 3 18600 &filemap_fdatawait_range_18600
104541 +iowarrior_write_18604 iowarrior_write 3 18604 NULL
104542 +audio_get_endpoint_req_18624 audio_get_endpoint_req 0 18624 NULL
104543 +from_buffer_18625 from_buffer 3 18625 NULL
104544 +snd_pcm_oss_write3_18657 snd_pcm_oss_write3 0-3 18657 NULL
104545 +ieee80211_if_fmt_rssi_threshold_18664 ieee80211_if_fmt_rssi_threshold 3 18664 NULL
104546 +unmap_page_18665 unmap_page 2-3 18665 NULL
104547 +xfs_iext_insert_18667 xfs_iext_insert 3 18667 NULL
104548 +__alloc_skb_head_18683 __alloc_skb_head 2 18683 NULL
104549 +echo_client_prep_commit_18693 echo_client_prep_commit 8 18693 NULL
104550 +replay_log_leb_18704 replay_log_leb 3 18704 NULL
104551 +iwl_dbgfs_rx_handlers_read_18708 iwl_dbgfs_rx_handlers_read 3 18708 NULL
104552 +ceph_alloc_page_vector_18710 ceph_alloc_page_vector 1 18710 NULL
104553 +ocfs2_trim_extent_18711 ocfs2_trim_extent 3-4 18711 NULL
104554 +blk_rq_bytes_18715 blk_rq_bytes 0 18715 NULL
104555 +byt_gpio_to_irq_18721 byt_gpio_to_irq 2 18721 NULL
104556 +ext4_es_insert_extent_18729 ext4_es_insert_extent 0 18729 NULL
104557 +snd_als4k_gcr_read_addr_18741 snd_als4k_gcr_read_addr 0 18741 NULL
104558 +o2hb_debug_create_18744 o2hb_debug_create 4 18744 NULL
104559 +__erst_read_to_erange_from_nvram_18748 __erst_read_to_erange_from_nvram 0 18748 NULL
104560 +wep_packets_read_18751 wep_packets_read 3 18751 NULL
104561 +read_file_dump_nfcal_18766 read_file_dump_nfcal 3 18766 NULL
104562 +ffs_epfile_read_18775 ffs_epfile_read 3 18775 NULL
104563 +SyS_lsetxattr_18776 SyS_lsetxattr 4 18776 NULL
104564 +alloc_fcdev_18780 alloc_fcdev 1 18780 NULL
104565 +prealloc_18800 prealloc 0 18800 NULL
104566 +madvise_hwpoison_18812 madvise_hwpoison 2 18812 NULL
104567 +setup_ioapic_irq_18813 setup_ioapic_irq 1 18813 NULL
104568 +dm_stats_print_18815 dm_stats_print 7 18815 NULL
104569 +sys_modify_ldt_18824 sys_modify_ldt 3 18824 NULL
104570 +mtf_test_write_18844 mtf_test_write 3 18844 NULL
104571 +iterate_inode_refs_18846 iterate_inode_refs 0 18846 NULL
104572 +drm_ht_create_18853 drm_ht_create 2 18853 NULL
104573 +sctp_setsockopt_events_18862 sctp_setsockopt_events 3 18862 NULL
104574 +ieee80211_if_read_element_ttl_18869 ieee80211_if_read_element_ttl 3 18869 NULL nohasharray
104575 +heads_to_leaves_18869 heads_to_leaves 2-0 18869 &ieee80211_if_read_element_ttl_18869
104576 +xlog_find_verify_log_record_18870 xlog_find_verify_log_record 2 18870 NULL
104577 +width_to_agaw_18883 width_to_agaw 0-1 18883 NULL
104578 +overwrite_item_18896 overwrite_item 0 18896 NULL
104579 +kmem_cache_alloc_node_18899 kmem_cache_alloc_node 3 18899 NULL
104580 +ceph_setxattr_18913 ceph_setxattr 4 18913 NULL
104581 +ext4_block_in_group_18922 ext4_block_in_group 2 18922 NULL
104582 +ieee80211_rx_mgmt_disassoc_18927 ieee80211_rx_mgmt_disassoc 3 18927 NULL
104583 +create_pending_snapshot_18936 create_pending_snapshot 0 18936 NULL
104584 +snapshot_write_next_18937 snapshot_write_next 0 18937 NULL
104585 +regcache_sync_block_18963 regcache_sync_block 4-3 18963 NULL
104586 +__nla_reserve_18974 __nla_reserve 3 18974 NULL
104587 +__blockdev_direct_IO_18977 __blockdev_direct_IO 0-6 18977 NULL
104588 +gfn_to_pfn_atomic_18981 gfn_to_pfn_atomic 2 18981 NULL
104589 +get_inode_path_18988 get_inode_path 0 18988 NULL
104590 +find_dirtiest_idx_leb_19001 find_dirtiest_idx_leb 0 19001 NULL nohasharray
104591 +test_check_exists_19001 test_check_exists 2 19001 &find_dirtiest_idx_leb_19001
104592 +layout_in_gaps_19006 layout_in_gaps 2 19006 NULL
104593 +huge_page_size_19008 huge_page_size 0 19008 NULL
104594 +push_leaf_right_19017 push_leaf_right 0 19017 NULL
104595 +prepare_highmem_image_19028 prepare_highmem_image 0 19028 NULL
104596 +ocfs2_steal_resource_19036 ocfs2_steal_resource 0 19036 NULL
104597 +revalidate_19043 revalidate 2 19043 NULL
104598 +afs_vnode_store_data_19048 afs_vnode_store_data 2-3-4-5 19048 NULL
104599 +osc_pinger_recov_seq_write_19056 osc_pinger_recov_seq_write 3 19056 NULL
104600 +create_gpadl_header_19064 create_gpadl_header 2 19064 NULL
104601 +ieee80211_key_alloc_19065 ieee80211_key_alloc 3 19065 NULL
104602 +ceph_create_snap_context_19082 ceph_create_snap_context 1 19082 NULL
104603 +sta_last_seq_ctrl_read_19106 sta_last_seq_ctrl_read 3 19106 NULL
104604 +cifs_readv_from_socket_19109 cifs_readv_from_socket 3 19109 NULL
104605 +ATOMIC_SUB_RETURN_19115 ATOMIC_SUB_RETURN 2 19115 NULL
104606 +ext4_inode_table_19125 ext4_inode_table 0 19125 NULL
104607 +snd_als4k_iobase_readl_19136 snd_als4k_iobase_readl 0 19136 NULL
104608 +btrfs_run_delayed_refs_19137 btrfs_run_delayed_refs 0 19137 NULL
104609 +alloc_irdadev_19140 alloc_irdadev 1 19140 NULL
104610 +sleep_auth_read_19159 sleep_auth_read 3 19159 NULL
104611 +ext3_reserve_inode_write_19163 ext3_reserve_inode_write 0 19163 NULL
104612 +smk_write_access2_19170 smk_write_access2 3 19170 NULL
104613 +iwl_dbgfs_reply_tx_error_read_19205 iwl_dbgfs_reply_tx_error_read 3 19205 NULL
104614 +vmw_unlocked_ioctl_19212 vmw_unlocked_ioctl 2 19212 NULL
104615 +__copy_to_user_inatomic_19214 __copy_to_user_inatomic 3-0 19214 NULL
104616 +dev_counters_read_19216 dev_counters_read 3 19216 NULL
104617 +wbcir_tx_19219 wbcir_tx 3 19219 NULL
104618 +gsi_to_irq_19220 gsi_to_irq 0-1 19220 NULL
104619 +snd_mask_max_19224 snd_mask_max 0 19224 NULL
104620 +snd_pcm_capture_rewind_19229 snd_pcm_capture_rewind 0-2 19229 NULL
104621 +bio_alloc_mddev_19238 bio_alloc_mddev 2 19238 NULL
104622 +ucma_query_19260 ucma_query 4 19260 NULL
104623 +write_one_cache_group_19261 write_one_cache_group 0 19261 NULL
104624 +il_dbgfs_rxon_filter_flags_read_19281 il_dbgfs_rxon_filter_flags_read 3 19281 NULL
104625 +cfg80211_rx_unprot_mlme_mgmt_19288 cfg80211_rx_unprot_mlme_mgmt 3 19288 NULL
104626 +____cache_alloc_node_19297 ____cache_alloc_node 3 19297 NULL
104627 +qc_capture_19298 qc_capture 3 19298 NULL
104628 +ocfs2_prepare_inode_for_refcount_19303 ocfs2_prepare_inode_for_refcount 4-3 19303 NULL
104629 +event_tx_stuck_read_19305 event_tx_stuck_read 3 19305 NULL
104630 +gfn_to_gpa_19320 gfn_to_gpa 0-1 19320 NULL
104631 +debug_read_19322 debug_read 3 19322 NULL
104632 +SYSC_sendfile64_19327 SYSC_sendfile64 4 19327 NULL
104633 +cfg80211_inform_bss_19332 cfg80211_inform_bss 8 19332 NULL nohasharray
104634 +lbs_host_sleep_write_19332 lbs_host_sleep_write 3 19332 &cfg80211_inform_bss_19332
104635 +closure_sub_19359 closure_sub 2 19359 NULL
104636 +firmware_data_write_19360 firmware_data_write 6-5 19360 NULL
104637 +read_zero_19366 read_zero 3 19366 NULL
104638 +interpret_user_input_19393 interpret_user_input 2 19393 NULL
104639 +sync_fill_pt_info_19397 sync_fill_pt_info 0 19397 NULL
104640 +get_unaligned_be16_19400 get_unaligned_be16 0 19400 NULL
104641 +get_n_events_by_type_19401 get_n_events_by_type 0 19401 NULL
104642 +pep_recvmsg_19402 pep_recvmsg 4 19402 NULL
104643 +dvbdmx_write_19423 dvbdmx_write 3 19423 NULL
104644 +__phys_addr_19434 __phys_addr 0 19434 NULL
104645 +SyS_sched_getaffinity_19444 SyS_sched_getaffinity 2 19444 NULL
104646 +xfrm_alg_auth_len_19454 xfrm_alg_auth_len 0 19454 NULL
104647 +gnet_stats_copy_19458 gnet_stats_copy 4 19458 NULL
104648 +sky2_read16_19475 sky2_read16 0 19475 NULL
104649 +__read_status_pciv2_19492 __read_status_pciv2 0 19492 NULL
104650 +kstrtoll_from_user_19500 kstrtoll_from_user 2 19500 NULL
104651 +ext4_add_new_descs_19509 ext4_add_new_descs 3 19509 NULL
104652 +cfc_write_array_to_buffer_19529 cfc_write_array_to_buffer 3 19529 NULL nohasharray
104653 +apei_exec_pre_map_gars_19529 apei_exec_pre_map_gars 0 19529 &cfc_write_array_to_buffer_19529
104654 +nfc_llcp_build_tlv_19536 nfc_llcp_build_tlv 3 19536 NULL
104655 +howmany_64_19548 howmany_64 2 19548 NULL
104656 +btrfs_xattr_security_init_19553 btrfs_xattr_security_init 0 19553 NULL
104657 +gfn_to_index_19558 gfn_to_index 0-1-3-2 19558 NULL
104658 +kernel_read_19559 kernel_read 4-0 19559 NULL
104659 +ocfs2_control_message_19564 ocfs2_control_message 3 19564 NULL
104660 +ieee80211_if_read_tkip_mic_test_19565 ieee80211_if_read_tkip_mic_test 3 19565 NULL
104661 +nfsd_read_19568 nfsd_read 5 19568 NULL
104662 +cgroup_read_s64_19570 cgroup_read_s64 5 19570 NULL
104663 +bm_status_read_19583 bm_status_read 3 19583 NULL
104664 +batadv_tt_update_orig_19586 batadv_tt_update_orig 4 19586 NULL
104665 +load_xattr_datum_19594 load_xattr_datum 0 19594 NULL
104666 +__mei_cl_recv_19636 __mei_cl_recv 3 19636 NULL
104667 +usbvision_rvmalloc_19655 usbvision_rvmalloc 1 19655 NULL
104668 +LoadBitmap_19658 LoadBitmap 2 19658 NULL
104669 +i915_gem_object_bind_to_gtt_19682 i915_gem_object_bind_to_gtt 0 19682 NULL
104670 +bio_detain_19690 bio_detain 2 19690 NULL
104671 +btrfs_del_inode_extref_19692 btrfs_del_inode_extref 0 19692 NULL
104672 +mem_cgroup_swappiness_19718 mem_cgroup_swappiness 0 19718 NULL
104673 +btrfs_write_marked_extents_19720 btrfs_write_marked_extents 0 19720 NULL
104674 +read_reg_19723 read_reg 0 19723 NULL
104675 +wm8350_block_write_19727 wm8350_block_write 2-3 19727 NULL
104676 +memcpy_toiovecend_19736 memcpy_toiovecend 3-4-0 19736 NULL
104677 +snd_es1968_get_dma_ptr_19747 snd_es1968_get_dma_ptr 0 19747 NULL
104678 +p9_client_read_19750 p9_client_read 0-5 19750 NULL
104679 +pnpbios_proc_write_19758 pnpbios_proc_write 3 19758 NULL
104680 +ocfs2_readpages_19759 ocfs2_readpages 4 19759 NULL
104681 +jffs2_acl_from_medium_19762 jffs2_acl_from_medium 2 19762 NULL
104682 +readhscx_19769 readhscx 0 19769 NULL
104683 +ocfs2_read_group_descriptor_19771 ocfs2_read_group_descriptor 0 19771 NULL
104684 +__set_print_fmt_19776 __set_print_fmt 0 19776 NULL
104685 +saa7146_vmalloc_build_pgtable_19780 saa7146_vmalloc_build_pgtable 2 19780 NULL
104686 +irda_setsockopt_19824 irda_setsockopt 5 19824 NULL
104687 +pcpu_next_unpop_19831 pcpu_next_unpop 4 19831 NULL
104688 +vfs_getxattr_19832 vfs_getxattr 0 19832 NULL
104689 +security_context_to_sid_19839 security_context_to_sid 2 19839 NULL
104690 +crypt_alloc_buffer_19846 crypt_alloc_buffer 2 19846 NULL
104691 +cfg80211_mlme_register_mgmt_19852 cfg80211_mlme_register_mgmt 5 19852 NULL
104692 +__nla_put_19857 __nla_put 3 19857 NULL
104693 +mrp_request_join_19882 mrp_request_join 4 19882 NULL
104694 +blk_alloc_queue_node_19887 blk_alloc_queue_node 2 19887 NULL
104695 +aes_decrypt_interrupt_read_19910 aes_decrypt_interrupt_read 3 19910 NULL
104696 +ps_upsd_max_apturn_read_19918 ps_upsd_max_apturn_read 3 19918 NULL
104697 +mangle_name_19923 mangle_name 0 19923 NULL
104698 +cgroup_task_count_19930 cgroup_task_count 0 19930 NULL
104699 +guest_read_tsc_19931 guest_read_tsc 0 19931 NULL
104700 +iwl_dbgfs_rx_queue_read_19943 iwl_dbgfs_rx_queue_read 3 19943 NULL
104701 +cfg80211_rx_assoc_resp_19944 cfg80211_rx_assoc_resp 4 19944 NULL
104702 +alloc_elfnotes_buf_19974 alloc_elfnotes_buf 1 19974 NULL
104703 +get_jack_mode_name_19976 get_jack_mode_name 4 19976 NULL
104704 +attach_hdlc_protocol_19986 attach_hdlc_protocol 3 19986 NULL
104705 +rtw_set_wps_probe_resp_19989 rtw_set_wps_probe_resp 3 19989 NULL
104706 +diva_um_idi_read_20003 diva_um_idi_read 0 20003 NULL
104707 +lov_stripe_md_size_20009 lov_stripe_md_size 0-1 20009 NULL
104708 +SYSC_fgetxattr_20027 SYSC_fgetxattr 4 20027 NULL
104709 +split_scan_timeout_read_20029 split_scan_timeout_read 3 20029 NULL
104710 +mlx5_ib_db_map_user_20037 mlx5_ib_db_map_user 2 20037 NULL
104711 +btrfs_block_rsv_migrate_20050 btrfs_block_rsv_migrate 0 20050 NULL
104712 +__be32_to_cpup_20056 __be32_to_cpup 0 20056 NULL
104713 +alloc_ieee80211_20063 alloc_ieee80211 1 20063 NULL
104714 +iwl_mvm_power_mac_dbgfs_read_20067 iwl_mvm_power_mac_dbgfs_read 4 20067 NULL
104715 +btrfs_pin_extent_for_log_replay_20069 btrfs_pin_extent_for_log_replay 2 20069 NULL
104716 +target_message_20072 target_message 2 20072 NULL
104717 +rawv6_sendmsg_20080 rawv6_sendmsg 4 20080 NULL
104718 +fuse_conn_limit_read_20084 fuse_conn_limit_read 3 20084 NULL
104719 +aat2870_reg_write_file_20086 aat2870_reg_write_file 3 20086 NULL
104720 +team_options_register_20091 team_options_register 3 20091 NULL
104721 +qla2x00_adjust_sdev_qdepth_up_20097 qla2x00_adjust_sdev_qdepth_up 2 20097 NULL
104722 +read_int_20098 read_int 0 20098 NULL
104723 +root_nfs_copy_20111 root_nfs_copy 3 20111 NULL
104724 +hptiop_adjust_disk_queue_depth_20122 hptiop_adjust_disk_queue_depth 2 20122 NULL
104725 +self_check_vid_hdr_20131 self_check_vid_hdr 0 20131 NULL
104726 +tomoyo_commit_ok_20167 tomoyo_commit_ok 2 20167 NULL
104727 +read_flush_pipefs_20171 read_flush_pipefs 3 20171 NULL
104728 +wep_addr_key_count_read_20174 wep_addr_key_count_read 3 20174 NULL
104729 +create_trace_probe_20175 create_trace_probe 1 20175 NULL
104730 +crystalhd_map_dio_20181 crystalhd_map_dio 3 20181 NULL
104731 +udf_bitmap_new_block_20214 udf_bitmap_new_block 4 20214 NULL
104732 +pvr2_ctrl_value_to_sym_20229 pvr2_ctrl_value_to_sym 5 20229 NULL
104733 +rose_sendmsg_20249 rose_sendmsg 4 20249 NULL
104734 +tm6000_i2c_send_regs_20250 tm6000_i2c_send_regs 5 20250 NULL
104735 +pcpu_alloc_20255 pcpu_alloc 1-2 20255 NULL
104736 +resource_size_20256 resource_size 0 20256 NULL
104737 +r10_sync_page_io_20307 r10_sync_page_io 3 20307 NULL
104738 +dm_get_reserved_bio_based_ios_20315 dm_get_reserved_bio_based_ios 0 20315 NULL
104739 +tx_tx_burst_programmed_read_20320 tx_tx_burst_programmed_read 3 20320 NULL
104740 +vx_send_msg_nolock_20322 vx_send_msg_nolock 0 20322 NULL
104741 +snd_cs4281_BA1_read_20323 snd_cs4281_BA1_read 5 20323 NULL
104742 +ocfs2_et_insert_check_20341 ocfs2_et_insert_check 0 20341 NULL
104743 +gfs2_glock_nq_m_20347 gfs2_glock_nq_m 1 20347 NULL
104744 +handle_arr_calc_size_20355 handle_arr_calc_size 0-1 20355 NULL
104745 +snd_pcm_stop_20376 snd_pcm_stop 0 20376 NULL
104746 +smk_set_cipso_20379 smk_set_cipso 3 20379 NULL
104747 +block_read_full_page_20380 block_read_full_page 0 20380 NULL
104748 +snd_nm256_readl_20394 snd_nm256_readl 0 20394 NULL nohasharray
104749 +read_7220_creg32_20394 read_7220_creg32 0 20394 &snd_nm256_readl_20394
104750 +__kfifo_from_user_20399 __kfifo_from_user 3 20399 NULL nohasharray
104751 +SyS_get_mempolicy_20399 SyS_get_mempolicy 3-4 20399 &__kfifo_from_user_20399
104752 +btrfs_set_acl_20440 btrfs_set_acl 0 20440 NULL
104753 +nfs3_setxattr_20458 nfs3_setxattr 4 20458 NULL
104754 +compat_ipv6_setsockopt_20468 compat_ipv6_setsockopt 5 20468 NULL
104755 +read_buf_20469 read_buf 2 20469 NULL
104756 +btrfs_get_32_20476 btrfs_get_32 0 20476 NULL
104757 +fast_user_write_20494 fast_user_write 5 20494 NULL
104758 +ocfs2_db_frozen_trigger_20503 ocfs2_db_frozen_trigger 4 20503 NULL
104759 +pcpu_alloc_area_20511 pcpu_alloc_area 0-3 20511 NULL
104760 +link_free_space_20512 link_free_space 0 20512 NULL
104761 +pcpu_depopulate_chunk_20517 pcpu_depopulate_chunk 3-2 20517 NULL
104762 +xfs_iext_realloc_direct_20521 xfs_iext_realloc_direct 2 20521 NULL
104763 +drbd_bm_resize_20522 drbd_bm_resize 2 20522 NULL
104764 +amd_create_gatt_pages_20537 amd_create_gatt_pages 1 20537 NULL
104765 +scsi_report_opcode_20551 scsi_report_opcode 3 20551 NULL
104766 +venus_create_20555 venus_create 4 20555 NULL
104767 +btrfs_super_log_root_20565 btrfs_super_log_root 0 20565 NULL
104768 +crypto_ahash_reqsize_20569 crypto_ahash_reqsize 0 20569 NULL
104769 +batadv_tt_append_diff_20588 batadv_tt_append_diff 4 20588 NULL nohasharray
104770 +ocfs2_cluster_lock_20588 ocfs2_cluster_lock 0 20588 &batadv_tt_append_diff_20588
104771 +kvm_test_age_hva_20593 kvm_test_age_hva 2 20593 NULL
104772 +sync_timeline_create_20601 sync_timeline_create 2 20601 NULL
104773 +lirc_write_20604 lirc_write 3 20604 NULL
104774 +qib_qsfp_write_20614 qib_qsfp_write 0-2-4 20614 NULL
104775 +snd_pcm_oss_prepare_20641 snd_pcm_oss_prepare 0 20641 NULL
104776 +get_extent_skip_holes_20642 get_extent_skip_holes 2 20642 NULL
104777 +kfifo_copy_to_user_20646 kfifo_copy_to_user 4-3 20646 NULL
104778 +cpulist_scnprintf_20648 cpulist_scnprintf 2-0 20648 NULL
104779 +oz_add_farewell_20652 oz_add_farewell 5 20652 NULL
104780 +oz_cdev_read_20659 oz_cdev_read 3 20659 NULL
104781 +snd_hdsp_playback_copy_20676 snd_hdsp_playback_copy 5 20676 NULL nohasharray
104782 +btrfs_qgroup_reserve_20676 btrfs_qgroup_reserve 0 20676 &snd_hdsp_playback_copy_20676
104783 +get_user_page_nowait_20682 get_user_page_nowait 3 20682 NULL nohasharray
104784 +dvb_dmxdev_buffer_read_20682 dvb_dmxdev_buffer_read 0-4 20682 &get_user_page_nowait_20682
104785 +cpumask_size_20683 cpumask_size 0 20683 NULL
104786 +btrfs_node_blockptr_20685 btrfs_node_blockptr 0 20685 NULL
104787 +gru_vtop_20689 gru_vtop 2 20689 NULL
104788 +read_file_tgt_int_stats_20697 read_file_tgt_int_stats 3 20697 NULL
104789 +i915_gem_obj_ggtt_pin_20698 i915_gem_obj_ggtt_pin 0 20698 NULL
104790 +__maestro_read_20700 __maestro_read 0 20700 NULL
104791 +cipso_v4_gentag_rng_20703 cipso_v4_gentag_rng 0 20703 NULL
104792 +pcpu_page_first_chunk_20712 pcpu_page_first_chunk 1 20712 NULL
104793 +ocfs2_read_xattr_bucket_20722 ocfs2_read_xattr_bucket 0 20722 NULL
104794 +security_context_to_sid_force_20724 security_context_to_sid_force 2 20724 NULL
104795 +io_apic_set_pci_routing_20740 io_apic_set_pci_routing 2 20740 NULL
104796 +fb_prepare_logo_20743 fb_prepare_logo 0 20743 NULL
104797 +vol_cdev_direct_write_20751 vol_cdev_direct_write 3 20751 NULL
104798 +ocfs2_align_bytes_to_clusters_20754 ocfs2_align_bytes_to_clusters 2 20754 NULL
104799 +brcmf_p2p_escan_20763 brcmf_p2p_escan 2 20763 NULL
104800 +ubi_io_read_20767 ubi_io_read 0 20767 NULL
104801 +ext4_r_blocks_count_20768 ext4_r_blocks_count 0 20768 NULL
104802 +fb_alloc_cmap_gfp_20792 fb_alloc_cmap_gfp 2 20792 NULL
104803 +iommu_range_alloc_20794 iommu_range_alloc 3 20794 NULL
104804 +iwl_dbgfs_rxon_flags_read_20795 iwl_dbgfs_rxon_flags_read 3 20795 NULL
104805 +ext4_convert_unwritten_extents_endio_20812 ext4_convert_unwritten_extents_endio 0 20812 NULL
104806 +strndup_user_20819 strndup_user 2 20819 NULL
104807 +dtf_read_channel_20831 dtf_read_channel 3 20831 NULL
104808 +wl1271_format_buffer_20834 wl1271_format_buffer 2 20834 NULL
104809 +uvc_alloc_entity_20836 uvc_alloc_entity 3-4 20836 NULL
104810 +btrfs_orphan_add_20840 btrfs_orphan_add 0 20840 NULL
104811 +p9_tag_alloc_20845 p9_tag_alloc 3 20845 NULL
104812 +nvme_trans_supported_vpd_pages_20847 nvme_trans_supported_vpd_pages 4 20847 NULL
104813 +get_name_20855 get_name 4 20855 NULL
104814 +iwl_dbgfs_pm_params_read_20866 iwl_dbgfs_pm_params_read 3 20866 NULL
104815 +snd_pcm_capture_avail_20867 snd_pcm_capture_avail 0 20867 NULL
104816 +srq_free_res_20868 srq_free_res 5 20868 NULL
104817 +ocfs2_bmap_20874 ocfs2_bmap 2 20874 NULL
104818 +cfs_cpt_table_create_20884 cfs_cpt_table_create 1 20884 NULL
104819 +rb_simple_write_20890 rb_simple_write 3 20890 NULL
104820 +sisusb_send_packet_20891 sisusb_send_packet 2 20891 NULL
104821 +key_icverrors_read_20895 key_icverrors_read 3 20895 NULL
104822 +vfio_msi_enable_20906 vfio_msi_enable 2 20906 NULL
104823 +lbs_rdbbp_write_20918 lbs_rdbbp_write 3 20918 NULL
104824 +htable_bits_20933 htable_bits 0 20933 NULL
104825 +check_eofblocks_fl_20942 check_eofblocks_fl 0 20942 NULL
104826 +altera_set_ir_post_20948 altera_set_ir_post 2 20948 NULL
104827 +rx_rx_phy_hdr_read_20950 rx_rx_phy_hdr_read 3 20950 NULL
104828 +rsxx_cram_read_20957 rsxx_cram_read 3 20957 NULL
104829 +nfs_map_name_to_uid_20962 nfs_map_name_to_uid 3 20962 NULL
104830 +snd_rme9652_playback_copy_20970 snd_rme9652_playback_copy 5 20970 NULL
104831 +alg_setsockopt_20985 alg_setsockopt 5 20985 NULL
104832 +qib_verbs_send_20999 qib_verbs_send 5-3 20999 NULL
104833 +ocfs2_free_clusters_21001 ocfs2_free_clusters 4-0 21001 NULL
104834 +btrfs_inode_ref_name_len_21024 btrfs_inode_ref_name_len 0 21024 NULL
104835 +rx_defrag_tkip_called_read_21031 rx_defrag_tkip_called_read 3 21031 NULL
104836 +lbs_threshold_read_21046 lbs_threshold_read 5 21046 NULL
104837 +reiserfs_direct_IO_21051 reiserfs_direct_IO 4 21051 NULL
104838 +proc_fault_inject_write_21058 proc_fault_inject_write 3 21058 NULL
104839 +btrfs_insert_root_21061 btrfs_insert_root 0 21061 NULL
104840 +qdisc_get_default_21072 qdisc_get_default 2 21072 NULL
104841 +event_calibration_read_21083 event_calibration_read 3 21083 NULL
104842 +bl_add_page_to_bio_21094 bl_add_page_to_bio 2 21094 NULL nohasharray
104843 +multipath_status_21094 multipath_status 5 21094 &bl_add_page_to_bio_21094
104844 +ext2_valid_block_bitmap_21101 ext2_valid_block_bitmap 3 21101 NULL
104845 +ath6kl_send_go_probe_resp_21113 ath6kl_send_go_probe_resp 3 21113 NULL
104846 +bitset_size_in_bytes_21124 bitset_size_in_bytes 0-1 21124 NULL
104847 +i2400m_rx_trace_21127 i2400m_rx_trace 3 21127 NULL
104848 +tps6586x_irq_init_21144 tps6586x_irq_init 3 21144 NULL
104849 +chunk_size_21146 chunk_size 0 21146 NULL
104850 +ocfs2_block_check_validate_21149 ocfs2_block_check_validate 2 21149 NULL
104851 +alloc_pg_vec_21159 alloc_pg_vec 3 21159 NULL
104852 +btrfs_add_root_ref_21186 btrfs_add_root_ref 0 21186 NULL
104853 +cx18_v4l2_read_21196 cx18_v4l2_read 3 21196 NULL
104854 +ipc_rcu_alloc_21208 ipc_rcu_alloc 1 21208 NULL
104855 +scsi_execute_req_flags_21215 scsi_execute_req_flags 5 21215 NULL
104856 +_ocfs2_free_clusters_21220 _ocfs2_free_clusters 4-0 21220 NULL
104857 +get_numpages_21227 get_numpages 0-1-2 21227 NULL
104858 +SyS_mlock_21238 SyS_mlock 1-2 21238 NULL
104859 +input_ff_create_21240 input_ff_create 2 21240 NULL
104860 +cfg80211_notify_new_peer_candidate_21242 cfg80211_notify_new_peer_candidate 4 21242 NULL
104861 +fru_length_21257 fru_length 0 21257 NULL
104862 +rtw_set_wps_beacon_21262 rtw_set_wps_beacon 3 21262 NULL
104863 +ocfs2_blocks_for_bytes_21268 ocfs2_blocks_for_bytes 0-2 21268 NULL
104864 +vmw_gmr2_bind_21305 vmw_gmr2_bind 3 21305 NULL
104865 +do_msg_fill_21307 do_msg_fill 3 21307 NULL
104866 +add_res_range_21310 add_res_range 4 21310 NULL
104867 +get_zeroed_page_21322 get_zeroed_page 0 21322 NULL
104868 +ftrace_profile_read_21327 ftrace_profile_read 3 21327 NULL
104869 +gfs2_ea_get_copy_21353 gfs2_ea_get_copy 0 21353 NULL
104870 +max77693_irq_domain_map_21357 max77693_irq_domain_map 2 21357 NULL
104871 +alloc_orinocodev_21371 alloc_orinocodev 1 21371 NULL
104872 +split_leaf_21378 split_leaf 0 21378 NULL
104873 +SYSC_rt_sigpending_21379 SYSC_rt_sigpending 2 21379 NULL
104874 +video_ioctl2_21380 video_ioctl2 2 21380 NULL
104875 +diva_get_driver_dbg_mask_21399 diva_get_driver_dbg_mask 0 21399 NULL
104876 +snd_m3_inw_21406 snd_m3_inw 0 21406 NULL
104877 +snapshot_read_next_21426 snapshot_read_next 0 21426 NULL
104878 +tcp_bound_to_half_wnd_21429 tcp_bound_to_half_wnd 0-2 21429 NULL
104879 +tracing_saved_cmdlines_read_21434 tracing_saved_cmdlines_read 3 21434 NULL
104880 +aggr_size_tx_agg_vs_rate_read_21438 aggr_size_tx_agg_vs_rate_read 3 21438 NULL
104881 +__ertm_hdr_size_21450 __ertm_hdr_size 0 21450 NULL
104882 +ReadISAR_21453 ReadISAR 0 21453 NULL
104883 +mei_nfc_send_21477 mei_nfc_send 3 21477 NULL
104884 +read_file_xmit_21487 read_file_xmit 3 21487 NULL
104885 +mmc_alloc_sg_21504 mmc_alloc_sg 1 21504 NULL
104886 +dma_skb_copy_datagram_iovec_21516 dma_skb_copy_datagram_iovec 3-5 21516 NULL
104887 +btrfs_file_aio_write_21520 btrfs_file_aio_write 4 21520 NULL
104888 +il_dbgfs_stations_read_21532 il_dbgfs_stations_read 3 21532 NULL
104889 +cipso_v4_map_cat_enum_hton_21540 cipso_v4_map_cat_enum_hton 0 21540 NULL
104890 +rxrpc_send_data_21553 rxrpc_send_data 5 21553 NULL
104891 +rx_rx_beacon_early_term_read_21559 rx_rx_beacon_early_term_read 3 21559 NULL
104892 +xfs_buf_read_uncached_21585 xfs_buf_read_uncached 3 21585 NULL
104893 +snd_es18xx_mixer_read_21586 snd_es18xx_mixer_read 0 21586 NULL
104894 +ocfs2_acl_from_xattr_21604 ocfs2_acl_from_xattr 2 21604 NULL
104895 +filemap_get_page_21606 filemap_get_page 2 21606 NULL
104896 +xlog_do_recovery_pass_21618 xlog_do_recovery_pass 3 21618 NULL
104897 +pci_cardbus_resource_alignment_21625 pci_cardbus_resource_alignment 0 21625 NULL
104898 +add_pin_to_irq_node_21628 add_pin_to_irq_node 2 21628 NULL
104899 +ocfs2_refcount_cow_hunk_21630 ocfs2_refcount_cow_hunk 3-4 21630 NULL
104900 +__jfs_getxattr_21631 __jfs_getxattr 0 21631 NULL
104901 +validate_nnode_21638 validate_nnode 0 21638 NULL
104902 +__irq_alloc_descs_21639 __irq_alloc_descs 2-1-0-3-4 21639 NULL
104903 +ocfs2_lock_refcount_allocators_21646 ocfs2_lock_refcount_allocators 0 21646 NULL
104904 +atalk_sendmsg_21677 atalk_sendmsg 4 21677 NULL
104905 +ocfs2_xattr_get_nolock_21678 ocfs2_xattr_get_nolock 0 21678 NULL
104906 +rtllib_alloc_txb_21687 rtllib_alloc_txb 1 21687 NULL
104907 +evdev_ioctl_handler_21705 evdev_ioctl_handler 2 21705 NULL
104908 +btrfs_find_all_leafs_21712 btrfs_find_all_leafs 0 21712 NULL
104909 +unix_skb_len_21722 unix_skb_len 0 21722 NULL
104910 +lprocfs_wr_import_21728 lprocfs_wr_import 3 21728 NULL
104911 +ocfs2_remove_rightmost_path_21729 ocfs2_remove_rightmost_path 0 21729 NULL
104912 +reiserfs_allocate_list_bitmaps_21732 reiserfs_allocate_list_bitmaps 3 21732 NULL nohasharray
104913 +ext4_split_extent_at_21732 ext4_split_extent_at 0 21732 &reiserfs_allocate_list_bitmaps_21732
104914 +vm_brk_21739 vm_brk 1-2 21739 NULL
104915 +mthca_alloc_init_21754 mthca_alloc_init 2 21754 NULL
104916 +usbat_flash_read_data_21762 usbat_flash_read_data 4 21762 NULL
104917 +gen_pool_add_21776 gen_pool_add 3-4 21776 NULL
104918 +SyS_sendfile_21777 SyS_sendfile 4 21777 NULL
104919 +atomic64_cmpxchg_21782 atomic64_cmpxchg 0 21782 NULL
104920 +xfs_da_grow_inode_int_21785 xfs_da_grow_inode_int 3 21785 NULL
104921 +dvb_generic_ioctl_21810 dvb_generic_ioctl 2 21810 NULL
104922 +__ocfs2_cluster_lock_21812 __ocfs2_cluster_lock 0 21812 NULL
104923 +wm8994_request_irq_21822 wm8994_request_irq 2 21822 NULL
104924 +oom_adj_read_21847 oom_adj_read 3 21847 NULL
104925 +gen_unique_name_21852 gen_unique_name 0 21852 NULL
104926 +lpfc_idiag_extacc_avail_get_21865 lpfc_idiag_extacc_avail_get 0-3 21865 NULL
104927 +brcms_debugfs_hardware_read_21867 brcms_debugfs_hardware_read 3 21867 NULL
104928 +sisusbcon_bmove_21873 sisusbcon_bmove 6-5-7 21873 NULL
104929 +ldlm_lock_create_21888 ldlm_lock_create 7 21888 NULL
104930 +__alloc_reserved_percpu_21895 __alloc_reserved_percpu 2-1 21895 NULL
104931 +rio_destid_first_21900 rio_destid_first 0 21900 NULL
104932 +dbAllocCtl_21911 dbAllocCtl 0 21911 NULL
104933 +qsfp_1_read_21915 qsfp_1_read 3 21915 NULL
104934 +ast_ttm_tt_create_21917 ast_ttm_tt_create 2 21917 NULL
104935 +__ocfs2_claim_clusters_21936 __ocfs2_claim_clusters 0 21936 NULL
104936 +alloc_ldt_21972 alloc_ldt 2 21972 NULL
104937 +SYSC_prctl_21980 SYSC_prctl 4 21980 NULL
104938 +rxpipe_descr_host_int_trig_rx_data_read_22001 rxpipe_descr_host_int_trig_rx_data_read 3 22001 NULL nohasharray
104939 +compat_rw_copy_check_uvector_22001 compat_rw_copy_check_uvector 3-0 22001 &rxpipe_descr_host_int_trig_rx_data_read_22001
104940 +ocfs2_reserve_cluster_bitmap_bits_22016 ocfs2_reserve_cluster_bitmap_bits 0 22016 NULL
104941 +regcache_sync_block_raw_flush_22021 regcache_sync_block_raw_flush 3-4 22021 NULL
104942 +btrfs_get_16_22023 btrfs_get_16 0 22023 NULL
104943 +i915_gem_evict_something_22028 i915_gem_evict_something 0 22028 NULL
104944 +_sp2d_min_pg_22032 _sp2d_min_pg 0 22032 NULL
104945 +zd_usb_read_fw_22049 zd_usb_read_fw 4 22049 NULL
104946 +atalk_recvmsg_22053 atalk_recvmsg 4 22053 NULL
104947 +ieee80211_if_fmt_dropped_frames_ttl_22054 ieee80211_if_fmt_dropped_frames_ttl 3 22054 NULL
104948 +btrfs_reloc_clone_csums_22077 btrfs_reloc_clone_csums 2-3 22077 NULL
104949 +write_opcode_22082 write_opcode 2 22082 NULL
104950 +mem_rw_22085 mem_rw 3 22085 NULL
104951 +snd_pcm_xrun_22088 snd_pcm_xrun 0 22088 NULL
104952 +sched_clock_cpu_22098 sched_clock_cpu 0 22098 NULL
104953 +rt2x00debug_read_crypto_stats_22109 rt2x00debug_read_crypto_stats 3 22109 NULL
104954 +shmem_add_to_page_cache_22121 shmem_add_to_page_cache 0 22121 NULL
104955 +snd_hda_codec_read_22130 snd_hda_codec_read 0 22130 NULL
104956 +SyS_sched_setaffinity_22148 SyS_sched_setaffinity 2 22148 NULL
104957 +do_tcp_sendpages_22155 do_tcp_sendpages 4 22155 NULL
104958 +remap_pud_range_22164 remap_pud_range 3-4-5 22164 NULL
104959 +__kfifo_alloc_22173 __kfifo_alloc 3 22173 NULL nohasharray
104960 +vmci_qp_broker_map_22173 vmci_qp_broker_map 3 22173 &__kfifo_alloc_22173
104961 +fls_22210 fls 0 22210 NULL
104962 +rfcomm_sock_recvmsg_22227 rfcomm_sock_recvmsg 4 22227 NULL nohasharray
104963 +bitmap_clear_bits_22227 bitmap_clear_bits 3 22227 &rfcomm_sock_recvmsg_22227
104964 +mem_write_22232 mem_write 3 22232 NULL
104965 +p9_virtio_zc_request_22240 p9_virtio_zc_request 6-5 22240 NULL
104966 +fsnotify_parent_22243 fsnotify_parent 0 22243 NULL
104967 +atomic64_xchg_22246 atomic64_xchg 0 22246 NULL
104968 +compat_process_vm_rw_22254 compat_process_vm_rw 3-5 22254 NULL
104969 +ping_common_sendmsg_22261 ping_common_sendmsg 5 22261 NULL
104970 +add_res_tree_22263 add_res_tree 7 22263 NULL
104971 +__btrfs_direct_write_22273 __btrfs_direct_write 4 22273 NULL
104972 +queue_max_sectors_22280 queue_max_sectors 0 22280 NULL
104973 +i915_gem_execbuffer_relocate_22294 i915_gem_execbuffer_relocate 0 22294 NULL
104974 +pci_vpd_srdt_size_22300 pci_vpd_srdt_size 0 22300 NULL nohasharray
104975 +__tun_chr_ioctl_22300 __tun_chr_ioctl 4 22300 &pci_vpd_srdt_size_22300
104976 +mesh_table_alloc_22305 mesh_table_alloc 1 22305 NULL
104977 +lov_setstripe_22307 lov_setstripe 2 22307 NULL
104978 +udpv6_sendmsg_22316 udpv6_sendmsg 4 22316 NULL
104979 +C_SYSC_msgrcv_22320 C_SYSC_msgrcv 3 22320 NULL
104980 +radix_tree_find_next_bit_22334 radix_tree_find_next_bit 3-2-0 22334 NULL
104981 +atomic_read_22342 atomic_read 0 22342 NULL
104982 +ll_lazystatfs_seq_write_22353 ll_lazystatfs_seq_write 3 22353 NULL
104983 +mlx4_db_alloc_22358 mlx4_db_alloc 3 22358 NULL
104984 +irq_reserve_irq_22360 irq_reserve_irq 1 22360 NULL nohasharray
104985 +memcg_size_22360 memcg_size 0 22360 &irq_reserve_irq_22360
104986 +snd_pcm_alsa_frames_22363 snd_pcm_alsa_frames 2 22363 NULL
104987 +tps6586x_gpio_to_irq_22365 tps6586x_gpio_to_irq 2 22365 NULL
104988 +evdev_ioctl_22371 evdev_ioctl 2 22371 NULL
104989 +alloc_large_system_hash_22391 alloc_large_system_hash 2-8-9 22391 NULL
104990 +ocfs2_assign_bh_22392 ocfs2_assign_bh 0 22392 NULL
104991 +zoran_write_22404 zoran_write 3 22404 NULL
104992 +ATOMIC_ADD_RETURN_22413 ATOMIC_ADD_RETURN 2 22413 NULL
104993 +queue_reply_22416 queue_reply 3 22416 NULL
104994 +__set_enter_print_fmt_22431 __set_enter_print_fmt 0 22431 NULL
104995 +queue_max_segments_22441 queue_max_segments 0 22441 NULL
104996 +_rtw_vmalloc_22444 _rtw_vmalloc 1 22444 NULL
104997 +handle_received_packet_22457 handle_received_packet 3 22457 NULL
104998 +mem_cgroup_read_22461 mem_cgroup_read 5 22461 NULL
104999 +btrfs_write_out_cache_22471 btrfs_write_out_cache 0 22471 NULL nohasharray
105000 +dtf_write_device_22471 dtf_write_device 3 22471 &btrfs_write_out_cache_22471
105001 +source_sink_start_ep_22472 source_sink_start_ep 0 22472 NULL
105002 +alloc_desc_22487 alloc_desc 2 22487 NULL
105003 +ecryptfs_write_22488 ecryptfs_write 4-3 22488 NULL
105004 +qib_user_sdma_alloc_header_22490 qib_user_sdma_alloc_header 2 22490 NULL
105005 +cache_write_procfs_22491 cache_write_procfs 3 22491 NULL
105006 +mp_find_ioapic_pin_22499 mp_find_ioapic_pin 0-2 22499 NULL
105007 +mutex_lock_interruptible_22505 mutex_lock_interruptible 0 22505 NULL
105008 +__btrfs_add_delayed_item_22511 __btrfs_add_delayed_item 0 22511 NULL
105009 +trim_no_bitmap_22524 trim_no_bitmap 4-3 22524 NULL
105010 +ocfs2_read_extent_block_22550 ocfs2_read_extent_block 0 22550 NULL
105011 +agp_alloc_page_array_22554 agp_alloc_page_array 1 22554 NULL
105012 +snd_pcm_hw_params_choose_22560 snd_pcm_hw_params_choose 0 22560 NULL
105013 +dbFindCtl_22587 dbFindCtl 0 22587 NULL
105014 +snapshot_read_22601 snapshot_read 3 22601 NULL
105015 +ocfs2_get_refcount_block_22610 ocfs2_get_refcount_block 0 22610 NULL
105016 +remove_breakpoint_22628 remove_breakpoint 3 22628 NULL
105017 +sctp_setsockopt_connectx_old_22631 sctp_setsockopt_connectx_old 3 22631 NULL
105018 +ide_core_cp_entry_22636 ide_core_cp_entry 3 22636 NULL
105019 +wl1271_rx_filter_get_fields_size_22638 wl1271_rx_filter_get_fields_size 0 22638 NULL
105020 +pwr_wake_on_timer_exp_read_22640 pwr_wake_on_timer_exp_read 3 22640 NULL
105021 +sysfs_attr_ns_22645 sysfs_attr_ns 0 22645 NULL
105022 +iwl_dbgfs_calib_disabled_read_22649 iwl_dbgfs_calib_disabled_read 3 22649 NULL
105023 +compat_SyS_msgrcv_22661 compat_SyS_msgrcv 3 22661 NULL
105024 +ubifs_leb_write_22679 ubifs_leb_write 4-5 22679 NULL nohasharray
105025 +ext4_ext_direct_IO_22679 ext4_ext_direct_IO 4 22679 &ubifs_leb_write_22679
105026 +fill_gap_22681 fill_gap 0 22681 NULL nohasharray
105027 +l2tp_ip_recvmsg_22681 l2tp_ip_recvmsg 4 22681 &fill_gap_22681
105028 +bch_dump_read_22685 bch_dump_read 3 22685 NULL
105029 +reg_umr_22686 reg_umr 5 22686 NULL
105030 +ocfs2_get_block_22687 ocfs2_get_block 2 22687 NULL
105031 +map_22700 map 2 22700 NULL nohasharray
105032 +btrfs_del_inode_ref_in_log_22700 btrfs_del_inode_ref_in_log 0 22700 &map_22700
105033 +alloc_libipw_22708 alloc_libipw 1 22708 NULL
105034 +ecryptfs_write_metadata_to_contents_22721 ecryptfs_write_metadata_to_contents 3 22721 NULL
105035 +cx18_copy_buf_to_user_22735 cx18_copy_buf_to_user 4-0 22735 NULL
105036 +ceph_decode_32_22738 ceph_decode_32 0 22738 NULL nohasharray
105037 +__mei_cl_send_22738 __mei_cl_send 3 22738 &ceph_decode_32_22738
105038 +iio_debugfs_write_reg_22742 iio_debugfs_write_reg 3 22742 NULL
105039 +qlcnic_sriov_init_22762 qlcnic_sriov_init 2 22762 NULL
105040 +print_frame_22769 print_frame 0 22769 NULL
105041 +ftrace_arch_read_dyn_info_22773 ftrace_arch_read_dyn_info 0 22773 NULL
105042 +ocfs2_block_group_alloc_22774 ocfs2_block_group_alloc 0 22774 NULL
105043 +pla_ocp_write_22802 pla_ocp_write 4 22802 NULL
105044 +__generic_copy_to_user_intel_22806 __generic_copy_to_user_intel 0-3 22806 NULL
105045 +clone_bio_integrity_22842 clone_bio_integrity 4 22842 NULL
105046 +read_file_rcstat_22854 read_file_rcstat 3 22854 NULL
105047 +create_attr_set_22861 create_attr_set 1 22861 NULL
105048 +vmw_execbuf_process_22885 vmw_execbuf_process 5 22885 NULL
105049 +usblp_new_writeurb_22894 usblp_new_writeurb 2 22894 NULL
105050 +mdc800_device_read_22896 mdc800_device_read 3 22896 NULL
105051 +policy_emit_config_values_22900 policy_emit_config_values 3 22900 NULL
105052 +__btrfs_add_free_space_22917 __btrfs_add_free_space 0 22917 NULL
105053 +xstateregs_set_22932 xstateregs_set 4 22932 NULL
105054 +pcpu_mem_zalloc_22948 pcpu_mem_zalloc 1 22948 NULL
105055 +alloc_sglist_22960 alloc_sglist 3-2 22960 NULL
105056 +caif_seqpkt_sendmsg_22961 caif_seqpkt_sendmsg 4 22961 NULL
105057 +vme_get_size_22964 vme_get_size 0 22964 NULL
105058 +tx_frag_key_not_found_read_22971 tx_frag_key_not_found_read 3 22971 NULL
105059 +cached_dev_cache_miss_22979 cached_dev_cache_miss 4 22979 NULL
105060 +usb_get_langid_22983 usb_get_langid 0 22983 NULL
105061 +set_msr_hyperv_22985 set_msr_hyperv 3 22985 NULL
105062 +remote_settings_file_write_22987 remote_settings_file_write 3 22987 NULL
105063 +brcmf_sdio_chip_exit_download_23001 brcmf_sdio_chip_exit_download 4 23001 NULL
105064 +viafb_dvp0_proc_write_23023 viafb_dvp0_proc_write 3 23023 NULL
105065 +cifs_local_to_utf16_bytes_23025 cifs_local_to_utf16_bytes 0 23025 NULL
105066 +ocfs2_refcount_cow_xattr_23029 ocfs2_refcount_cow_xattr 0-6-7 23029 NULL
105067 +st_status_23032 st_status 5 23032 NULL
105068 +nv50_disp_chan_create__23056 nv50_disp_chan_create_ 5 23056 NULL
105069 +comedi_buf_write_n_available_23057 comedi_buf_write_n_available 0 23057 NULL
105070 +reiserfs_add_entry_23062 reiserfs_add_entry 4 23062 NULL nohasharray
105071 +unix_seqpacket_recvmsg_23062 unix_seqpacket_recvmsg 4 23062 &reiserfs_add_entry_23062
105072 +mei_cl_send_23068 mei_cl_send 3 23068 NULL
105073 +filp_close_23071 filp_close 0 23071 NULL
105074 +kvm_mmu_gva_to_gpa_write_23075 kvm_mmu_gva_to_gpa_write 0 23075 NULL
105075 +vm_map_ram_23078 vm_map_ram 3 23078 NULL nohasharray
105076 +raw_sendmsg_23078 raw_sendmsg 4 23078 &vm_map_ram_23078
105077 +get_user_hdr_len_23079 get_user_hdr_len 0 23079 NULL
105078 +isr_tx_procs_read_23084 isr_tx_procs_read 3 23084 NULL
105079 +lnw_gpio_irq_map_23087 lnw_gpio_irq_map 2 23087 NULL
105080 +rt2x00debug_write_eeprom_23091 rt2x00debug_write_eeprom 3 23091 NULL
105081 +__add_prelim_ref_23095 __add_prelim_ref 0 23095 NULL
105082 +fls_long_23096 fls_long 0 23096 NULL
105083 +ntfs_ucstonls_23097 ntfs_ucstonls 5-3 23097 NULL
105084 +pipe_iov_copy_from_user_23102 pipe_iov_copy_from_user 3 23102 NULL
105085 +dgram_recvmsg_23104 dgram_recvmsg 4 23104 NULL
105086 +ip_recv_error_23109 ip_recv_error 3 23109 NULL
105087 +mwl8k_cmd_set_beacon_23110 mwl8k_cmd_set_beacon 4 23110 NULL
105088 +nl80211_send_rx_auth_23111 nl80211_send_rx_auth 4 23111 NULL
105089 +__clear_user_23118 __clear_user 0-2 23118 NULL
105090 +drm_mode_create_tv_properties_23122 drm_mode_create_tv_properties 2 23122 NULL
105091 +ata_scsi_change_queue_depth_23126 ata_scsi_change_queue_depth 2 23126 NULL
105092 +ext3_listxattr_23137 ext3_listxattr 3 23137 NULL
105093 +read_file_ani_23161 read_file_ani 3 23161 NULL
105094 +tg_get_cfs_quota_23176 tg_get_cfs_quota 0 23176 NULL
105095 +usblp_write_23178 usblp_write 3 23178 NULL
105096 +msnd_fifo_alloc_23179 msnd_fifo_alloc 2 23179 NULL
105097 +gss_pipe_downcall_23182 gss_pipe_downcall 3 23182 NULL
105098 +fix_unclean_leb_23188 fix_unclean_leb 3 23188 NULL
105099 +mpi_alloc_limb_space_23190 mpi_alloc_limb_space 1 23190 NULL
105100 +convert_ip_to_linear_23198 convert_ip_to_linear 0 23198 NULL
105101 +pm80x_free_irq_23210 pm80x_free_irq 2 23210 NULL
105102 +tty_buffer_request_room_23228 tty_buffer_request_room 2-0 23228 NULL
105103 +__read_status_pci_23229 __read_status_pci 0 23229 NULL nohasharray
105104 +xlog_get_bp_23229 xlog_get_bp 2 23229 &__read_status_pci_23229
105105 +ft1000_read_dpram_mag_32_23232 ft1000_read_dpram_mag_32 0 23232 NULL
105106 +rxrpc_client_sendmsg_23236 rxrpc_client_sendmsg 5 23236 NULL
105107 +__gfn_to_rmap_23240 __gfn_to_rmap 2-1 23240 NULL
105108 +sctp_recvmsg_23265 sctp_recvmsg 4 23265 NULL
105109 +uwb_dev_addr_print_23282 uwb_dev_addr_print 2 23282 NULL
105110 +diva_get_trace_filter_23286 diva_get_trace_filter 0 23286 NULL
105111 +gru_preload_tlb_23305 gru_preload_tlb 7-4 23305 NULL
105112 +i2cdev_write_23310 i2cdev_write 3 23310 NULL
105113 +__aa_kvmalloc_23320 __aa_kvmalloc 1 23320 NULL
105114 +__es_remove_extent_23323 __es_remove_extent 0 23323 NULL
105115 +page_readlink_23346 page_readlink 3 23346 NULL
105116 +kmem_zalloc_large_23351 kmem_zalloc_large 1 23351 NULL
105117 +get_dst_timing_23358 get_dst_timing 0 23358 NULL
105118 +fd_setup_write_same_buf_23369 fd_setup_write_same_buf 3 23369 NULL
105119 +iscsi_change_queue_depth_23416 iscsi_change_queue_depth 2 23416 NULL
105120 +vga_mm_r_23419 vga_mm_r 0 23419 NULL
105121 +vzalloc_node_23424 vzalloc_node 1-2 23424 NULL
105122 +__ctzsi2_23444 __ctzsi2 1 23444 NULL
105123 +ocfs2_zero_tail_23447 ocfs2_zero_tail 3 23447 NULL
105124 +hidraw_send_report_23449 hidraw_send_report 3 23449 NULL
105125 +__ata_change_queue_depth_23484 __ata_change_queue_depth 3-0 23484 NULL
105126 +linear_conf_23485 linear_conf 2 23485 NULL
105127 +copy_module_from_user_23492 copy_module_from_user 2 23492 NULL
105128 +event_filter_read_23494 event_filter_read 3 23494 NULL
105129 +ext4_remove_blocks_23497 ext4_remove_blocks 0 23497 NULL
105130 +lustre_acl_xattr_merge2ext_23502 lustre_acl_xattr_merge2ext 2 23502 NULL
105131 +__gfn_to_hva_many_23508 __gfn_to_hva_many 0-2 23508 NULL
105132 +devm_iio_device_alloc_23511 devm_iio_device_alloc 2 23511 NULL
105133 +__proc_cpt_table_23516 __proc_cpt_table 5 23516 NULL
105134 +ima_show_measurements_count_23536 ima_show_measurements_count 3 23536 NULL
105135 +__es_insert_extent_23543 __es_insert_extent 0 23543 NULL
105136 +xen_allocate_irq_gsi_23546 xen_allocate_irq_gsi 1-0 23546 NULL
105137 +tcp_current_mss_23552 tcp_current_mss 0 23552 NULL
105138 +dbg_leb_change_23555 dbg_leb_change 0-4 23555 NULL
105139 +btrfs_super_bytenr_23561 btrfs_super_bytenr 0 23561 NULL
105140 +venus_symlink_23570 venus_symlink 6-4 23570 NULL
105141 +iwl_dbgfs_interrupt_read_23574 iwl_dbgfs_interrupt_read 3 23574 NULL
105142 +xfpregs_get_23586 xfpregs_get 4 23586 NULL
105143 +snd_interval_min_23590 snd_interval_min 0 23590 NULL
105144 +do_mmap_pgoff_23600 do_mmap_pgoff 0 23600 NULL
105145 +islpci_mgt_transaction_23610 islpci_mgt_transaction 5 23610 NULL
105146 +ocfs2_journal_access_23616 ocfs2_journal_access 0 23616 NULL
105147 +alloc_pte_23642 alloc_pte 3 23642 NULL
105148 +__i2400mu_send_barker_23652 __i2400mu_send_barker 3 23652 NULL
105149 +sInW_23663 sInW 0 23663 NULL
105150 +SyS_connect_23669 SyS_connect 3 23669 NULL
105151 +cx18_read_23699 cx18_read 3 23699 NULL
105152 +btrfs_insert_delayed_item_23705 btrfs_insert_delayed_item 0 23705 NULL
105153 +at_get_23708 at_get 0 23708 NULL
105154 +snd_pcm_hw_refine_23721 snd_pcm_hw_refine 0 23721 NULL
105155 +mp_config_acpi_gsi_23728 mp_config_acpi_gsi 2 23728 NULL
105156 +rx_rx_dropped_frame_read_23748 rx_rx_dropped_frame_read 3 23748 NULL
105157 +__kfifo_max_r_23768 __kfifo_max_r 0-2-1 23768 NULL
105158 +svc_prepare_thread_23772 svc_prepare_thread 3 23772 NULL
105159 +__build_packet_message_23778 __build_packet_message 4-10 23778 NULL
105160 +security_inode_getxattr_23781 security_inode_getxattr 0 23781 NULL
105161 +cfg80211_inform_bss_width_frame_23782 cfg80211_inform_bss_width_frame 5 23782 NULL
105162 +mpt_free_res_23793 mpt_free_res 5 23793 NULL
105163 +map_write_23795 map_write 3 23795 NULL
105164 +diva_alloc_dma_map_23798 diva_alloc_dma_map 2 23798 NULL
105165 +rx_path_reset_read_23801 rx_path_reset_read 3 23801 NULL
105166 +ocfs2_replace_cow_23803 ocfs2_replace_cow 0 23803 NULL
105167 +__earlyonly_bootmem_alloc_23824 __earlyonly_bootmem_alloc 2 23824 NULL
105168 +lustre_msg_buflen_23827 lustre_msg_buflen 0 23827 NULL
105169 +ceph_copy_page_vector_to_user_23829 ceph_copy_page_vector_to_user 0-4-3 23829 NULL
105170 +tfrc_binsearch_23833 tfrc_binsearch 0 23833 NULL
105171 +pgdat_end_pfn_23842 pgdat_end_pfn 0 23842 NULL
105172 +iwl_dbgfs_nvm_read_23845 iwl_dbgfs_nvm_read 3 23845 NULL
105173 +p54_init_common_23850 p54_init_common 1 23850 NULL
105174 +gart_alloc_coherent_23852 gart_alloc_coherent 2 23852 NULL
105175 +bin_to_hex_dup_23853 bin_to_hex_dup 2 23853 NULL
105176 +ocfs2_xattr_get_clusters_23857 ocfs2_xattr_get_clusters 0 23857 NULL
105177 +ieee80211_if_read_dot11MeshMaxPeerLinks_23878 ieee80211_if_read_dot11MeshMaxPeerLinks 3 23878 NULL
105178 +nes_alloc_resource_23891 nes_alloc_resource 3 23891 NULL
105179 +_rtw_zvmalloc_23892 _rtw_zvmalloc 1 23892 NULL
105180 +tipc_snprintf_23893 tipc_snprintf 2-0 23893 NULL
105181 +usbg_prepare_w_request_23895 usbg_prepare_w_request 0 23895 NULL
105182 +add_new_gdb_meta_bg_23911 add_new_gdb_meta_bg 3 23911 NULL nohasharray
105183 +ieee80211_if_read_hw_queues_23911 ieee80211_if_read_hw_queues 3 23911 &add_new_gdb_meta_bg_23911
105184 +device_create_bin_file_23914 device_create_bin_file 0 23914 NULL
105185 +f2fs_getxattr_23917 f2fs_getxattr 0 23917 NULL
105186 +ipath_reg_phys_mr_23918 ipath_reg_phys_mr 3 23918 NULL nohasharray
105187 +mpihelp_mul_karatsuba_case_23918 mpihelp_mul_karatsuba_case 5-3 23918 &ipath_reg_phys_mr_23918
105188 +kvm_read_guest_23928 kvm_read_guest 4-2 23928 NULL nohasharray
105189 +intel_ring_alloc_seqno_23928 intel_ring_alloc_seqno 0 23928 &kvm_read_guest_23928
105190 +__alloc_skb_23940 __alloc_skb 4 23940 NULL
105191 +uvc_endpoint_max_bpi_23944 uvc_endpoint_max_bpi 0 23944 NULL
105192 +cifs_setxattr_23957 cifs_setxattr 4 23957 NULL
105193 +size_roundup_power2_23958 size_roundup_power2 0-1 23958 NULL
105194 +vfs_write_23971 vfs_write 0-3 23971 NULL
105195 +sddr55_write_data_23983 sddr55_write_data 4 23983 NULL
105196 +zd_usb_iowrite16v_async_23984 zd_usb_iowrite16v_async 3 23984 NULL
105197 +cxgb_alloc_mem_24007 cxgb_alloc_mem 1 24007 NULL
105198 +intel_ring_idle_24014 intel_ring_idle 0 24014 NULL
105199 +give_pages_24021 give_pages 3 24021 NULL
105200 +ocfs2_mark_extent_refcounted_24035 ocfs2_mark_extent_refcounted 6 24035 NULL
105201 +adis16400_show_serial_number_24037 adis16400_show_serial_number 3 24037 NULL
105202 +hmac_setkey_24043 hmac_setkey 3 24043 NULL
105203 +afs_cell_alloc_24052 afs_cell_alloc 2 24052 NULL
105204 +blkcipher_copy_iv_24075 blkcipher_copy_iv 3 24075 NULL
105205 +vb2_fop_read_24080 vb2_fop_read 3 24080 NULL
105206 +ocfs2_cannibalize_resv_24090 ocfs2_cannibalize_resv 3 24090 NULL
105207 +pipeline_post_proc_swi_read_24108 pipeline_post_proc_swi_read 3 24108 NULL
105208 +request_key_auth_read_24109 request_key_auth_read 3 24109 NULL
105209 +lov_brw_24122 lov_brw 4 24122 NULL
105210 +mpu401_read_24126 mpu401_read 3-0 24126 NULL
105211 +_picolcd_flash_write_24134 _picolcd_flash_write 4 24134 NULL
105212 +irnet_ctrl_write_24139 irnet_ctrl_write 3 24139 NULL
105213 +SyS_sethostname_24150 SyS_sethostname 2 24150 NULL
105214 +trim_bitmaps_24158 trim_bitmaps 3 24158 NULL
105215 +set_discard_24162 set_discard 2 24162 NULL
105216 +__copy_user_zeroing_intel_nocache_24163 __copy_user_zeroing_intel_nocache 0-3 24163 NULL
105217 +adu_read_24177 adu_read 3 24177 NULL
105218 +safe_prepare_write_buffer_24187 safe_prepare_write_buffer 3 24187 NULL
105219 +shrink_tnc_24190 shrink_tnc 0 24190 NULL
105220 +irq_remapping_setup_msi_irqs_24194 irq_remapping_setup_msi_irqs 2 24194 NULL
105221 +ieee80211_if_read_dot11MeshHWMPpreqMinInterval_24208 ieee80211_if_read_dot11MeshHWMPpreqMinInterval 3 24208 NULL
105222 +efx_vf_size_24213 efx_vf_size 0 24213 NULL
105223 +SyS_sendfile64_24220 SyS_sendfile64 4 24220 NULL
105224 +tcpprobe_sprint_24222 tcpprobe_sprint 0-2 24222 NULL
105225 +pcpu_embed_first_chunk_24224 pcpu_embed_first_chunk 3-2-1 24224 NULL nohasharray
105226 +mei_amthif_read_24224 mei_amthif_read 4 24224 &pcpu_embed_first_chunk_24224
105227 +pci_num_vf_24235 pci_num_vf 0 24235 NULL
105228 +sel_read_bool_24236 sel_read_bool 3 24236 NULL
105229 +dm_cache_save_hint_24257 dm_cache_save_hint 2 24257 NULL
105230 +em28xx_alloc_urbs_24260 em28xx_alloc_urbs 4-6 24260 NULL
105231 +calculate_sizes_24273 calculate_sizes 2 24273 NULL
105232 +thin_status_24278 thin_status 5 24278 NULL
105233 +msg_size_24288 msg_size 0 24288 NULL
105234 +ext2_free_blocks_24292 ext2_free_blocks 3-2 24292 NULL
105235 +i2c_smbus_check_pec_24297 i2c_smbus_check_pec 0 24297 NULL
105236 +map_page_24298 map_page 3-4 24298 NULL
105237 +gserial_connect_24302 gserial_connect 0 24302 NULL
105238 +btmrvl_pscmd_read_24308 btmrvl_pscmd_read 3 24308 NULL
105239 +reserve_metadata_bytes_24313 reserve_metadata_bytes 3-0 24313 NULL
105240 +ath6kl_add_bss_if_needed_24317 ath6kl_add_bss_if_needed 6 24317 NULL
105241 +ocfs2_direct_IO_get_blocks_24333 ocfs2_direct_IO_get_blocks 2 24333 NULL
105242 +si476x_radio_read_acf_blob_24336 si476x_radio_read_acf_blob 3 24336 NULL
105243 +kzalloc_node_24352 kzalloc_node 1-3 24352 NULL
105244 +qla2x00_handle_queue_full_24365 qla2x00_handle_queue_full 2 24365 NULL
105245 +cfi_read_pri_24366 cfi_read_pri 3 24366 NULL
105246 +btrfs_item_size_nr_24367 btrfs_item_size_nr 0 24367 NULL
105247 +igetword_24373 igetword 0 24373 NULL
105248 +max_io_len_24384 max_io_len 0-1 24384 NULL
105249 +mpt_alloc_res_24387 mpt_alloc_res 5 24387 NULL
105250 +osc_cur_grant_bytes_seq_write_24396 osc_cur_grant_bytes_seq_write 3 24396 NULL
105251 +pvr2_v4l2_ioctl_24398 pvr2_v4l2_ioctl 2 24398 NULL nohasharray
105252 +getxattr_24398 getxattr 4 24398 &pvr2_v4l2_ioctl_24398 nohasharray
105253 +__btrfs_write_out_cache_24398 __btrfs_write_out_cache 0 24398 &getxattr_24398
105254 +blk_update_bidi_request_24415 blk_update_bidi_request 3-4 24415 NULL
105255 +nvme_trans_log_supp_pages_24418 nvme_trans_log_supp_pages 3 24418 NULL
105256 +b43_debugfs_read_24425 b43_debugfs_read 3 24425 NULL
105257 +xenbus_file_read_24427 xenbus_file_read 3 24427 NULL
105258 +ieee80211_rx_mgmt_beacon_24430 ieee80211_rx_mgmt_beacon 3 24430 NULL
105259 +copy_and_ioctl_24434 copy_and_ioctl 4 24434 NULL
105260 +ixgbe_alloc_q_vector_24439 ixgbe_alloc_q_vector 6-4 24439 NULL
105261 +smk_user_access_24440 smk_user_access 3 24440 NULL nohasharray
105262 +rtw_set_wps_assoc_resp_24440 rtw_set_wps_assoc_resp 3 24440 &smk_user_access_24440
105263 +__push_leaf_left_24456 __push_leaf_left 0 24456 NULL
105264 +evdev_do_ioctl_24459 evdev_do_ioctl 2 24459 NULL
105265 +lbs_highsnr_write_24460 lbs_highsnr_write 3 24460 NULL
105266 +skb_copy_and_csum_datagram_iovec_24466 skb_copy_and_csum_datagram_iovec 2 24466 NULL nohasharray
105267 +ocfs2_write_cluster_by_desc_24466 ocfs2_write_cluster_by_desc 6-5 24466 &skb_copy_and_csum_datagram_iovec_24466
105268 +snd_pcm_hw_param_first_24487 snd_pcm_hw_param_first 0 24487 NULL
105269 +read_file_spec_scan_ctl_24491 read_file_spec_scan_ctl 3 24491 NULL
105270 +i915_gem_obj_offset_24494 i915_gem_obj_offset 0 24494 NULL
105271 +push_nodes_for_insert_24496 push_nodes_for_insert 0 24496 NULL
105272 +pd_video_read_24510 pd_video_read 3 24510 NULL
105273 +request_key_with_auxdata_24515 request_key_with_auxdata 4 24515 NULL
105274 +xfs_buf_get_map_24522 xfs_buf_get_map 3 24522 NULL
105275 +do_mpage_readpage_24536 do_mpage_readpage 3 24536 NULL
105276 +write_cache_pages_24562 write_cache_pages 0 24562 NULL
105277 +SyS_pselect6_24582 SyS_pselect6 1 24582 NULL
105278 +udf_compute_nr_groups_24594 udf_compute_nr_groups 0 24594 NULL
105279 +sensor_hub_get_physical_device_count_24605 sensor_hub_get_physical_device_count 0 24605 NULL nohasharray
105280 +lov_alloc_memmd_24605 lov_alloc_memmd 2 24605 &sensor_hub_get_physical_device_count_24605
105281 +SyS_poll_24620 SyS_poll 2 24620 NULL
105282 +kvm_pv_enable_async_pf_24637 kvm_pv_enable_async_pf 2 24637 NULL
105283 +context_alloc_24645 context_alloc 3 24645 NULL
105284 +blk_rq_err_bytes_24650 blk_rq_err_bytes 0 24650 NULL
105285 +btrfs_check_data_free_space_24692 btrfs_check_data_free_space 0 24692 NULL
105286 +datafab_write_data_24696 datafab_write_data 4 24696 NULL
105287 +intelfbhw_get_p1p2_24703 intelfbhw_get_p1p2 2 24703 NULL
105288 +simple_attr_read_24738 simple_attr_read 3 24738 NULL
105289 +qla2x00_change_queue_depth_24742 qla2x00_change_queue_depth 2 24742 NULL
105290 +get_dma_residue_24749 get_dma_residue 0 24749 NULL
105291 +ocfs2_cow_file_pos_24751 ocfs2_cow_file_pos 3 24751 NULL
105292 +kgdb_hex2mem_24755 kgdb_hex2mem 3 24755 NULL
105293 +kempld_read8_24756 kempld_read8 0 24756 NULL
105294 +ocfs2_read_blocks_24777 ocfs2_read_blocks 0 24777 NULL
105295 +datablob_hmac_verify_24786 datablob_hmac_verify 4 24786 NULL
105296 +cache_read_24790 cache_read 3 24790 NULL
105297 +__xfs_get_blocks_24791 __xfs_get_blocks 2 24791 NULL
105298 +i915_gem_check_wedge_24793 i915_gem_check_wedge 0 24793 NULL
105299 +user_regset_copyout_24796 user_regset_copyout 7 24796 NULL
105300 +kvm_read_guest_virt_helper_24804 kvm_read_guest_virt_helper 3-1 24804 NULL
105301 +__next_cpu_nr_24805 __next_cpu_nr 1 24805 NULL
105302 +sb_set_blocksize_24807 sb_set_blocksize 0-2 24807 NULL
105303 +ath6kl_fwlog_mask_write_24810 ath6kl_fwlog_mask_write 3 24810 NULL
105304 +comedi_buf_alloc_24822 comedi_buf_alloc 3 24822 NULL
105305 +net2272_read_24825 net2272_read 0 24825 NULL
105306 +snd_als4k_gcr_read_24840 snd_als4k_gcr_read 0 24840 NULL
105307 +btrfs_next_old_item_24843 btrfs_next_old_item 0 24843 NULL
105308 +xfs_free_file_space_24853 xfs_free_file_space 2-3 24853 NULL
105309 +snd_pcm_lib_buffer_bytes_24865 snd_pcm_lib_buffer_bytes 0 24865 NULL
105310 +pnp_alloc_24869 pnp_alloc 1 24869 NULL nohasharray
105311 +l2cap_create_basic_pdu_24869 l2cap_create_basic_pdu 3 24869 &pnp_alloc_24869
105312 +setup_buffering_24872 setup_buffering 3 24872 NULL
105313 +queues_read_24877 queues_read 3 24877 NULL
105314 +__vxge_hw_vp_initialize_24885 __vxge_hw_vp_initialize 2 24885 NULL
105315 +codec_list_read_file_24910 codec_list_read_file 3 24910 NULL
105316 +__btrfs_free_extent_24927 __btrfs_free_extent 7-0 24927 NULL nohasharray
105317 +v4l2_ctrl_new_24927 v4l2_ctrl_new 7 24927 &__btrfs_free_extent_24927
105318 +ocfs2_fiemap_24949 ocfs2_fiemap 4-3 24949 NULL
105319 +packet_sendmsg_24954 packet_sendmsg 4 24954 NULL
105320 +ensure_wear_leveling_24971 ensure_wear_leveling 0 24971 NULL
105321 +twl_i2c_write_u8_24976 twl_i2c_write_u8 3 24976 NULL
105322 +llc_ui_sendmsg_24987 llc_ui_sendmsg 4 24987 NULL
105323 +btrfs_update_delayed_inode_24988 btrfs_update_delayed_inode 0 24988 NULL
105324 +key_conf_hw_key_idx_read_25003 key_conf_hw_key_idx_read 3 25003 NULL
105325 +il_dbgfs_channels_read_25005 il_dbgfs_channels_read 3 25005 NULL
105326 +twl6030_irq_unmap_25014 twl6030_irq_unmap 2 25014 NULL
105327 +ni_660x_num_counters_25031 ni_660x_num_counters 0 25031 NULL
105328 +nfs_dns_resolve_name_25036 nfs_dns_resolve_name 3 25036 NULL
105329 +load_unaligned_zeropad_25050 load_unaligned_zeropad 0 25050 NULL
105330 +btrfs_stack_key_blockptr_25058 btrfs_stack_key_blockptr 0 25058 NULL
105331 +gs_buf_alloc_25067 gs_buf_alloc 2 25067 NULL
105332 +ll_track_pid_seq_write_25068 ll_track_pid_seq_write 3 25068 NULL
105333 +SYSC_listxattr_25072 SYSC_listxattr 3 25072 NULL
105334 +iwl_dbgfs_tx_flush_write_25091 iwl_dbgfs_tx_flush_write 3 25091 NULL
105335 +gfs2_iter_unstuffed_25099 gfs2_iter_unstuffed 0 25099 NULL nohasharray
105336 +blkg_path_25099 blkg_path 3 25099 &gfs2_iter_unstuffed_25099
105337 +snd_rawmidi_kernel_write_25106 snd_rawmidi_kernel_write 3 25106 NULL
105338 +fs32_to_cpu_25143 fs32_to_cpu 0 25143 NULL
105339 +record_new_ref_25154 record_new_ref 0 25154 NULL
105340 +ipath_init_qp_table_25167 ipath_init_qp_table 2 25167 NULL nohasharray
105341 +btrfs_delete_delayed_items_25167 btrfs_delete_delayed_items 0 25167 &ipath_init_qp_table_25167
105342 +kvm_mmu_notifier_change_pte_25169 kvm_mmu_notifier_change_pte 3 25169 NULL
105343 +sctp_getsockopt_local_addrs_25178 sctp_getsockopt_local_addrs 2 25178 NULL
105344 +res_counter_read_u64_25180 res_counter_read_u64 0 25180 NULL
105345 +send_create_inode_if_needed_25211 send_create_inode_if_needed 0 25211 NULL
105346 +security_socket_post_create_25221 security_socket_post_create 0 25221 NULL
105347 +ocfs2_block_check_compute_25223 ocfs2_block_check_compute 2 25223 NULL
105348 +dtf_write_string_25232 dtf_write_string 5 25232 NULL
105349 +mon_stat_read_25238 mon_stat_read 3 25238 NULL
105350 +nilfs_palloc_find_available_slot_25245 nilfs_palloc_find_available_slot 5-3 25245 NULL
105351 +stripe_status_25259 stripe_status 5 25259 NULL
105352 +snd_pcm_start_25273 snd_pcm_start 0 25273 NULL
105353 +crypto_alloc_instance2_25277 crypto_alloc_instance2 3 25277 NULL
105354 +vfs_writev_25278 vfs_writev 3 25278 NULL
105355 +l2tp_session_create_25286 l2tp_session_create 1 25286 NULL
105356 +ath9k_debugfs_read_buf_25316 ath9k_debugfs_read_buf 3 25316 NULL
105357 +rng_buffer_size_25348 rng_buffer_size 0 25348 NULL
105358 +SYSC_kexec_load_25361 SYSC_kexec_load 2 25361 NULL
105359 +rio_destid_next_25368 rio_destid_next 2-0 25368 NULL nohasharray
105360 +unix_mkname_25368 unix_mkname 0-2 25368 &rio_destid_next_25368
105361 +sel_read_mls_25369 sel_read_mls 3 25369 NULL
105362 +tc3589x_gpio_to_irq_25371 tc3589x_gpio_to_irq 2 25371 NULL
105363 +orphanize_inode_25382 orphanize_inode 0 25382 NULL
105364 +SyS_splice_25390 SyS_splice 5 25390 NULL
105365 +btrfs_update_reserved_bytes_25393 btrfs_update_reserved_bytes 0 25393 NULL
105366 +vsp1_entity_init_25407 vsp1_entity_init 3 25407 NULL
105367 +ebt_buf_add_pad_25413 ebt_buf_add_pad 0 25413 NULL
105368 +dai_list_read_file_25421 dai_list_read_file 3 25421 NULL
105369 +generic_file_buffered_write_25464 generic_file_buffered_write 4 25464 NULL
105370 +ipath_decode_err_25468 ipath_decode_err 3 25468 NULL
105371 +crypto_hash_digestsize_25469 crypto_hash_digestsize 0 25469 NULL
105372 +ocfs2_hamming_encode_25501 ocfs2_hamming_encode 3 25501 NULL
105373 +ivtv_buf_copy_from_user_25502 ivtv_buf_copy_from_user 4-0 25502 NULL
105374 +evm_init_hmac_25504 evm_init_hmac 0 25504 NULL
105375 +snd_pcm_plugin_build_25505 snd_pcm_plugin_build 5 25505 NULL
105376 +sb_permission_25523 sb_permission 0 25523 NULL
105377 +down_read_failed_25532 down_read_failed 2 25532 NULL
105378 +ext3_get_inode_loc_25542 ext3_get_inode_loc 0 25542 NULL
105379 +ieee80211_if_read_path_refresh_time_25545 ieee80211_if_read_path_refresh_time 3 25545 NULL
105380 +wimax_addr_scnprint_25548 wimax_addr_scnprint 2 25548 NULL
105381 +mgag200_ttm_tt_create_25550 mgag200_ttm_tt_create 2 25550 NULL
105382 +ht_print_chan_25556 ht_print_chan 0 25556 NULL
105383 +skb_tailroom_25567 skb_tailroom 0 25567 NULL
105384 +ping_recvmsg_25597 ping_recvmsg 4 25597 NULL nohasharray
105385 +find_extend_vma_25597 find_extend_vma 2 25597 &ping_recvmsg_25597
105386 +copy_user_generic_25611 copy_user_generic 0 25611 NULL
105387 +proc_coredump_filter_write_25625 proc_coredump_filter_write 3 25625 NULL
105388 +__get_user_pages_25628 __get_user_pages 0-3-4 25628 NULL nohasharray
105389 +befs_utf2nls_25628 befs_utf2nls 3 25628 &__get_user_pages_25628
105390 +__direct_map_25647 __direct_map 6-5 25647 NULL
105391 +ext2_try_to_allocate_25667 ext2_try_to_allocate 4-2-0 25667 NULL
105392 +aircable_prepare_write_buffer_25669 aircable_prepare_write_buffer 3 25669 NULL
105393 +lpfc_idiag_cmd_get_25672 lpfc_idiag_cmd_get 2 25672 NULL
105394 +sta_inactive_ms_read_25690 sta_inactive_ms_read 3 25690 NULL
105395 +ebitmap_start_positive_25703 ebitmap_start_positive 0 25703 NULL
105396 +wl1271_tx_enabled_rates_get_25712 wl1271_tx_enabled_rates_get 0 25712 NULL nohasharray
105397 +rx_filter_mc_filter_read_25712 rx_filter_mc_filter_read 3 25712 &wl1271_tx_enabled_rates_get_25712
105398 +ibmasm_new_command_25714 ibmasm_new_command 2 25714 NULL
105399 +ttm_tt_init_25717 ttm_tt_init 3 25717 NULL
105400 +sel_write_context_25726 sel_write_context 3 25726 NULL nohasharray
105401 +__alloc_bootmem_low_node_25726 __alloc_bootmem_low_node 2 25726 &sel_write_context_25726
105402 +ext2_find_near_25734 ext2_find_near 0 25734 NULL
105403 +__set_clear_dirty_25744 __set_clear_dirty 2 25744 NULL
105404 +cxgbi_device_portmap_create_25747 cxgbi_device_portmap_create 3 25747 NULL
105405 +dtf_write_channel_25748 dtf_write_channel 3 25748 NULL
105406 +event_rx_pool_read_25792 event_rx_pool_read 3 25792 NULL
105407 +sg_read_25799 sg_read 3 25799 NULL
105408 +system_enable_read_25815 system_enable_read 3 25815 NULL
105409 +realloc_buffer_25816 realloc_buffer 2 25816 NULL
105410 +ftrace_profile_init_25821 ftrace_profile_init 0 25821 NULL
105411 +mthca_map_user_db_25823 mthca_map_user_db 5 25823 NULL
105412 +pwr_missing_bcns_read_25824 pwr_missing_bcns_read 3 25824 NULL
105413 +parport_read_25855 parport_read 0 25855 NULL
105414 +xfs_dir2_sf_hdr_size_25858 xfs_dir2_sf_hdr_size 0 25858 NULL
105415 +key_attr_size_25865 key_attr_size 0 25865 NULL
105416 +ath6kl_regread_read_25884 ath6kl_regread_read 3 25884 NULL
105417 +run_delalloc_nocow_25896 run_delalloc_nocow 3-4 25896 NULL
105418 +sisusbcon_scroll_area_25899 sisusbcon_scroll_area 4-3 25899 NULL
105419 +lpfc_change_queue_depth_25905 lpfc_change_queue_depth 2 25905 NULL
105420 +nvme_trans_mode_page_create_25908 nvme_trans_mode_page_create 7-4 25908 NULL
105421 +do_jffs2_setxattr_25910 do_jffs2_setxattr 5 25910 NULL
105422 +rcname_read_25919 rcname_read 3 25919 NULL
105423 +snd_es1938_capture_copy_25930 snd_es1938_capture_copy 5 25930 NULL
105424 +key_flags_read_25931 key_flags_read 3 25931 NULL
105425 +copy_play_buf_25932 copy_play_buf 3 25932 NULL
105426 +flush_25957 flush 2 25957 NULL
105427 +video_register_device_25971 video_register_device 3 25971 NULL
105428 +udp_setsockopt_25985 udp_setsockopt 5 25985 NULL
105429 +lustre_msg_buflen_v2_25997 lustre_msg_buflen_v2 0 25997 NULL
105430 +ebt_compat_entry_padsize_26001 ebt_compat_entry_padsize 0 26001 NULL
105431 +blk_init_queue_node_26015 blk_init_queue_node 3 26015 NULL
105432 +SyS_process_vm_readv_26019 SyS_process_vm_readv 3-5 26019 NULL
105433 +irq_create_strict_mappings_26025 irq_create_strict_mappings 2-4 26025 NULL
105434 +xfs_xattr_acl_set_26028 xfs_xattr_acl_set 4 26028 NULL
105435 +mptscsih_change_queue_depth_26036 mptscsih_change_queue_depth 2 26036 NULL
105436 +selinux_inode_post_setxattr_26037 selinux_inode_post_setxattr 4 26037 NULL
105437 +tun_do_read_26047 tun_do_read 5 26047 NULL
105438 +make_bfloat_26056 make_bfloat 2 26056 NULL
105439 +keyctl_update_key_26061 keyctl_update_key 3 26061 NULL
105440 +rx_rx_wa_density_dropped_frame_read_26095 rx_rx_wa_density_dropped_frame_read 3 26095 NULL
105441 +__add_inline_refs_26096 __add_inline_refs 0 26096 NULL
105442 +dup_ref_26100 dup_ref 0 26100 NULL
105443 +intel_wrap_ring_buffer_26117 intel_wrap_ring_buffer 0 26117 NULL
105444 +read_sb_page_26119 read_sb_page 5 26119 NULL
105445 +__fswab64_26155 __fswab64 0 26155 NULL
105446 +copy_oldmem_page_26164 copy_oldmem_page 3 26164 NULL
105447 +gfs2_xattr_acl_get_26166 gfs2_xattr_acl_get 0 26166 NULL nohasharray
105448 +ath6kl_roam_table_read_26166 ath6kl_roam_table_read 3 26166 &gfs2_xattr_acl_get_26166
105449 +disk_devt_26180 disk_devt 0 26180 NULL
105450 +cgroup_setxattr_26188 cgroup_setxattr 4 26188 NULL
105451 +ieee80211_if_fmt_dot11MeshTTL_26198 ieee80211_if_fmt_dot11MeshTTL 3 26198 NULL
105452 +xfs_idata_realloc_26199 xfs_idata_realloc 2 26199 NULL
105453 +mce_write_26201 mce_write 3 26201 NULL
105454 +SyS_splice_26206 SyS_splice 5 26206 NULL
105455 +mwifiex_regrdwr_write_26225 mwifiex_regrdwr_write 3 26225 NULL
105456 +_scsih_change_queue_depth_26230 _scsih_change_queue_depth 2 26230 NULL
105457 +rxrpc_recvmsg_26233 rxrpc_recvmsg 4 26233 NULL
105458 +bio_split_26235 bio_split 2 26235 NULL
105459 +btrfs_delayed_inode_reserve_metadata_26236 btrfs_delayed_inode_reserve_metadata 0 26236 NULL
105460 +ecryptfs_read_lower_page_segment_26244 ecryptfs_read_lower_page_segment 4 26244 NULL
105461 +do_setxattr_26264 do_setxattr 0 26264 NULL
105462 +crypto_ctxsize_26278 crypto_ctxsize 0 26278 NULL
105463 +apei_resources_request_26279 apei_resources_request 0 26279 NULL
105464 +wacom_set_device_mode_26280 wacom_set_device_mode 3 26280 NULL
105465 +ext2_find_goal_26306 ext2_find_goal 0 26306 NULL
105466 +snd_pcm_plug_client_channels_buf_26309 snd_pcm_plug_client_channels_buf 0-3 26309 NULL nohasharray
105467 +pax_get_random_long_26309 pax_get_random_long 0 26309 &snd_pcm_plug_client_channels_buf_26309
105468 +pwr_wake_on_host_read_26321 pwr_wake_on_host_read 3 26321 NULL
105469 +check_can_nocow_26336 check_can_nocow 2 26336 NULL
105470 +snd_vx_check_reg_bit_26344 snd_vx_check_reg_bit 0 26344 NULL
105471 +ocfs2_duplicate_clusters_by_page_26357 ocfs2_duplicate_clusters_by_page 5-0-6-3 26357 NULL
105472 +cifs_readdata_alloc_26360 cifs_readdata_alloc 1 26360 NULL
105473 +invalidate_inode_pages2_range_26403 invalidate_inode_pages2_range 0 26403 NULL
105474 +ntty_write_26404 ntty_write 3 26404 NULL
105475 +pagemap_read_26441 pagemap_read 3 26441 NULL
105476 +tower_read_26461 tower_read 3 26461 NULL nohasharray
105477 +enc_pools_add_pages_26461 enc_pools_add_pages 1 26461 &tower_read_26461 nohasharray
105478 +numa_cpu_node_26461 numa_cpu_node 0 26461 &enc_pools_add_pages_26461
105479 +memory_present_26470 memory_present 1 26470 NULL
105480 +ib_alloc_device_26483 ib_alloc_device 1 26483 NULL
105481 +ulong_write_file_26485 ulong_write_file 3 26485 NULL
105482 +dvb_ca_en50221_io_ioctl_26490 dvb_ca_en50221_io_ioctl 2 26490 NULL
105483 +vfio_pin_pages_26494 vfio_pin_pages 1 26494 NULL
105484 +read_vmcore_26501 read_vmcore 3 26501 NULL
105485 +uhid_char_write_26502 uhid_char_write 3 26502 NULL
105486 +vfio_pci_set_msi_trigger_26507 vfio_pci_set_msi_trigger 4-3 26507 NULL
105487 +iwl_dbgfs_rf_reset_read_26512 iwl_dbgfs_rf_reset_read 3 26512 NULL
105488 +SyS_rt_sigpending_26538 SyS_rt_sigpending 2 26538 NULL
105489 +rds_message_inc_copy_to_user_26540 rds_message_inc_copy_to_user 3 26540 NULL
105490 +__vhost_add_used_n_26554 __vhost_add_used_n 3 26554 NULL
105491 +qgroup_account_ref_step3_26558 qgroup_account_ref_step3 0 26558 NULL
105492 +dio_new_bio_26562 dio_new_bio 0 26562 NULL
105493 +kvm_iommu_put_pages_26571 kvm_iommu_put_pages 2 26571 NULL
105494 +rts51x_read_mem_26577 rts51x_read_mem 4 26577 NULL
105495 +regcache_set_reg_present_26598 regcache_set_reg_present 2 26598 NULL
105496 +__unmap_single_26604 __unmap_single 2-3 26604 NULL
105497 +dev_to_node_26617 dev_to_node 0 26617 NULL
105498 +iommu_alloc_26621 iommu_alloc 4 26621 NULL
105499 +pack_value_26625 pack_value 1 26625 NULL
105500 +pwr_fix_tsf_ps_read_26627 pwr_fix_tsf_ps_read 3 26627 NULL
105501 +drm_ht_find_item_26637 drm_ht_find_item 0 26637 NULL
105502 +process_extent_26646 process_extent 0 26646 NULL nohasharray
105503 +btrfs_lookup_inode_26646 btrfs_lookup_inode 0 26646 &process_extent_26646
105504 +irq_alloc_generic_chip_26650 irq_alloc_generic_chip 2 26650 NULL nohasharray
105505 +inb_p_26650 inb_p 0 26650 &irq_alloc_generic_chip_26650
105506 +usb_reset_device_26661 usb_reset_device 0 26661 NULL
105507 +cipso_v4_map_cat_rbm_hton_26680 cipso_v4_map_cat_rbm_hton 0 26680 NULL
105508 +nouveau_namedb_create__26732 nouveau_namedb_create_ 7 26732 NULL
105509 +SyS_fcntl_26737 SyS_fcntl 3 26737 NULL
105510 +pipeline_tcp_rx_stat_fifo_int_read_26745 pipeline_tcp_rx_stat_fifo_int_read 3 26745 NULL
105511 +bos_desc_26752 bos_desc 0 26752 NULL
105512 +snd_hda_get_raw_connections_26762 snd_hda_get_raw_connections 0 26762 NULL
105513 +dma_map_single_attrs_26779 dma_map_single_attrs 0 26779 NULL
105514 +cache_save_setup_26783 cache_save_setup 0 26783 NULL
105515 +qlcnic_alloc_sds_rings_26795 qlcnic_alloc_sds_rings 2 26795 NULL
105516 +cipso_v4_genopt_26812 cipso_v4_genopt 0 26812 NULL
105517 +iwl_trans_read_mem32_26825 iwl_trans_read_mem32 0 26825 NULL
105518 +smk_write_load_26829 smk_write_load 3 26829 NULL
105519 +ept_get_level1_sp_gpa_26831 ept_get_level1_sp_gpa 0 26831 NULL
105520 +__nodes_onto_26838 __nodes_onto 4 26838 NULL
105521 +scnprint_id_26842 scnprint_id 3-0 26842 NULL
105522 +ecryptfs_miscdev_write_26847 ecryptfs_miscdev_write 3 26847 NULL
105523 +tipc_conn_sendmsg_26867 tipc_conn_sendmsg 5 26867 NULL
105524 +ath6kl_create_qos_write_26879 ath6kl_create_qos_write 3 26879 NULL
105525 +svc_print_xprts_26881 svc_print_xprts 0 26881 NULL
105526 +cfg80211_process_auth_26916 cfg80211_process_auth 3 26916 NULL
105527 +x25_asy_change_mtu_26928 x25_asy_change_mtu 2 26928 NULL
105528 +compat_mtw_from_user_26932 compat_mtw_from_user 0 26932 NULL
105529 +scsi_tgt_copy_sense_26933 scsi_tgt_copy_sense 3 26933 NULL
105530 +pwr_ps_enter_read_26935 pwr_ps_enter_read 3 26935 NULL nohasharray
105531 +sctp_setsockopt_adaptation_layer_26935 sctp_setsockopt_adaptation_layer 3 26935 &pwr_ps_enter_read_26935
105532 +remove_from_bitmap_26939 remove_from_bitmap 0 26939 NULL
105533 +create_bm_block_list_26940 create_bm_block_list 0 26940 NULL
105534 +hecubafb_write_26942 hecubafb_write 3 26942 NULL
105535 +extract_entropy_user_26952 extract_entropy_user 3 26952 NULL nohasharray
105536 +do_trimming_26952 do_trimming 3 26952 &extract_entropy_user_26952
105537 +xlog_grant_push_ail_26972 xlog_grant_push_ail 2 26972 NULL
105538 +do_direct_IO_26979 do_direct_IO 0 26979 NULL
105539 +pcf857x_irq_domain_map_26998 pcf857x_irq_domain_map 2 26998 NULL
105540 +i2c_smbus_xfer_27006 i2c_smbus_xfer 0 27006 NULL
105541 +omfs_allocate_range_27034 omfs_allocate_range 3 27034 NULL
105542 +ufs_alloc_fragments_27059 ufs_alloc_fragments 3-0-2 27059 NULL
105543 +__videobuf_alloc_vb_27062 __videobuf_alloc_vb 1 27062 NULL
105544 +ext4_convert_unwritten_extents_27064 ext4_convert_unwritten_extents 4-3-0 27064 NULL
105545 +snd_pcm_lib_period_bytes_27071 snd_pcm_lib_period_bytes 0 27071 NULL
105546 +paravirt_read_msr_27077 paravirt_read_msr 0 27077 NULL
105547 +snd_mixer_oss_set_recsrc_27080 snd_mixer_oss_set_recsrc 2 27080 NULL
105548 +alloc_fdmem_27083 alloc_fdmem 1 27083 NULL
105549 +find_first_bit_27088 find_first_bit 0-2 27088 NULL
105550 +btmrvl_hscmd_write_27089 btmrvl_hscmd_write 3 27089 NULL
105551 +nes_reg_user_mr_27106 nes_reg_user_mr 2-3 27106 NULL
105552 +__devcgroup_inode_permission_27108 __devcgroup_inode_permission 0 27108 NULL
105553 +i915_gem_execbuffer_relocate_slow_27116 i915_gem_execbuffer_relocate_slow 0 27116 NULL
105554 +get_kernel_page_27133 get_kernel_page 0 27133 NULL
105555 +__ext4_handle_dirty_metadata_27137 __ext4_handle_dirty_metadata 0 27137 NULL
105556 +drbd_get_capacity_27141 drbd_get_capacity 0 27141 NULL
105557 +pms_capture_27142 pms_capture 4 27142 NULL
105558 +btmrvl_hscfgcmd_write_27143 btmrvl_hscfgcmd_write 3 27143 NULL
105559 +snd_compr_calc_avail_27165 snd_compr_calc_avail 0 27165 NULL
105560 +ieee80211_if_read_rc_rateidx_mask_5ghz_27183 ieee80211_if_read_rc_rateidx_mask_5ghz 3 27183 NULL
105561 +get_unaligned_be32_27184 get_unaligned_be32 0 27184 NULL
105562 +__intel_ring_begin_27197 __intel_ring_begin 0 27197 NULL
105563 +__sg_alloc_table_27198 __sg_alloc_table 0 27198 NULL
105564 +ocfs2_read_blocks_sync_27210 ocfs2_read_blocks_sync 0 27210 NULL
105565 +write_kmem_27225 write_kmem 3 27225 NULL
105566 +dbAllocAG_27228 dbAllocAG 0 27228 NULL
105567 +rxrpc_request_key_27235 rxrpc_request_key 3 27235 NULL
105568 +ocfs2_journal_access_path_27243 ocfs2_journal_access_path 0 27243 NULL
105569 +ll_track_gid_seq_write_27267 ll_track_gid_seq_write 3 27267 NULL
105570 +qfq_unblock_groups_27269 qfq_unblock_groups 2 27269 NULL
105571 +comedi_alloc_devpriv_27272 comedi_alloc_devpriv 2 27272 NULL
105572 +__dma_map_cont_27289 __dma_map_cont 5 27289 NULL
105573 +copy_from_buf_27308 copy_from_buf 2-4 27308 NULL
105574 +virtqueue_add_inbuf_27312 virtqueue_add_inbuf 3 27312 NULL
105575 +write_buf_27316 write_buf 0-3 27316 NULL
105576 +ocfs2_blocks_to_clusters_27327 ocfs2_blocks_to_clusters 0-2 27327 NULL
105577 +snd_pcm_oss_write2_27332 snd_pcm_oss_write2 3-0 27332 NULL
105578 +afs_cell_create_27346 afs_cell_create 2 27346 NULL
105579 +iwl_dbgfs_csr_write_27363 iwl_dbgfs_csr_write 3 27363 NULL
105580 +pcbit_stat_27364 pcbit_stat 2 27364 NULL
105581 +lz4_compress_crypto_27387 lz4_compress_crypto 3 27387 NULL
105582 +seq_read_27411 seq_read 3 27411 NULL
105583 +ib_dma_map_sg_27413 ib_dma_map_sg 0 27413 NULL
105584 +ieee80211_if_read_smps_27416 ieee80211_if_read_smps 3 27416 NULL
105585 +ocfs2_refcount_cal_cow_clusters_27422 ocfs2_refcount_cal_cow_clusters 0-3-4 27422 NULL nohasharray
105586 +evm_inode_init_security_27422 evm_inode_init_security 0 27422 &ocfs2_refcount_cal_cow_clusters_27422
105587 +cypress_write_27423 cypress_write 4 27423 NULL
105588 +sddr09_read_data_27447 sddr09_read_data 3 27447 NULL
105589 +ktime_to_us_27455 ktime_to_us 0 27455 NULL
105590 +sk_extract_addr_27474 sk_extract_addr 0 27474 NULL
105591 +v4l2_ctrl_new_std_menu_items_27487 v4l2_ctrl_new_std_menu_items 4 27487 NULL
105592 +hcd_buffer_alloc_27495 hcd_buffer_alloc 2 27495 NULL
105593 +qib_create_cq_27497 qib_create_cq 2 27497 NULL
105594 +ip_set_get_h32_27498 ip_set_get_h32 0 27498 NULL
105595 +btrfs_get_64_27499 btrfs_get_64 0 27499 NULL
105596 +ept_walk_addr_generic_27501 ept_walk_addr_generic 4 27501 NULL
105597 +garmin_read_process_27509 garmin_read_process 3 27509 NULL
105598 +oti_alloc_cookies_27510 oti_alloc_cookies 2 27510 NULL
105599 +ib_copy_to_udata_27525 ib_copy_to_udata 3 27525 NULL
105600 +snd_sonicvibes_getdmaa_27552 snd_sonicvibes_getdmaa 0 27552 NULL
105601 +SyS_fgetxattr_27571 SyS_fgetxattr 4 27571 NULL
105602 +sco_sock_recvmsg_27572 sco_sock_recvmsg 4 27572 NULL
105603 +libipw_alloc_txb_27579 libipw_alloc_txb 1 27579 NULL
105604 +read_flush_procfs_27642 read_flush_procfs 3 27642 NULL nohasharray
105605 +nl80211_send_connect_result_27642 nl80211_send_connect_result 5-7 27642 &read_flush_procfs_27642 nohasharray
105606 +ocfs2_direct_IO_27642 ocfs2_direct_IO 4 27642 &nl80211_send_connect_result_27642 nohasharray
105607 +ocfs2_xattr_ibody_get_27642 ocfs2_xattr_ibody_get 0 27642 &ocfs2_direct_IO_27642
105608 +add_new_gdb_27643 add_new_gdb 3 27643 NULL
105609 +btrfs_fallocate_27647 btrfs_fallocate 3-4 27647 NULL
105610 +qnx6_readpages_27657 qnx6_readpages 4 27657 NULL
105611 +cdrom_read_cdda_old_27664 cdrom_read_cdda_old 4 27664 NULL
105612 +record_changed_ref_27665 record_changed_ref 0 27665 NULL
105613 +iommu_pgsize_27677 iommu_pgsize 2-0 27677 NULL
105614 +ocfs2_extend_dir_27695 ocfs2_extend_dir 4 27695 NULL
105615 +fs_path_add_from_extent_buffer_27702 fs_path_add_from_extent_buffer 4-0 27702 NULL
105616 +evm_write_key_27715 evm_write_key 3 27715 NULL
105617 +ieee80211_if_fmt_dot11MeshGateAnnouncementProtocol_27722 ieee80211_if_fmt_dot11MeshGateAnnouncementProtocol 3 27722 NULL
105618 +xfs_dir2_block_sfsize_27727 xfs_dir2_block_sfsize 0 27727 NULL
105619 +macvtap_skb_to_vnet_hdr_27747 macvtap_skb_to_vnet_hdr 0 27747 NULL
105620 +SyS_setsockopt_27759 SyS_setsockopt 5 27759 NULL
105621 +gpiochip_export_27776 gpiochip_export 0 27776 NULL
105622 +__lov_setstripe_27782 __lov_setstripe 2 27782 NULL
105623 +twl4030_set_gpio_dataout_27792 twl4030_set_gpio_dataout 1 27792 NULL
105624 +DivaSTraceGetMemotyRequirement_27797 DivaSTraceGetMemotyRequirement 0-1 27797 NULL
105625 +ttm_object_file_init_27804 ttm_object_file_init 2 27804 NULL nohasharray
105626 +SyS_readv_27804 SyS_readv 3 27804 &ttm_object_file_init_27804
105627 +mpihelp_mul_27805 mpihelp_mul 5-3 27805 NULL
105628 +fwtty_buffer_rx_27821 fwtty_buffer_rx 3 27821 NULL
105629 +hpt374_read_freq_27828 hpt374_read_freq 0 27828 NULL
105630 +init_header_complete_27833 init_header_complete 0 27833 NULL
105631 +read_profile_27859 read_profile 3 27859 NULL
105632 +sky2_pci_read16_27863 sky2_pci_read16 0 27863 NULL
105633 +ieee80211_if_read_dot11MeshHWMProotInterval_27873 ieee80211_if_read_dot11MeshHWMProotInterval 3 27873 NULL
105634 +process_all_extents_27879 process_all_extents 0 27879 NULL
105635 +unix_seqpacket_sendmsg_27893 unix_seqpacket_sendmsg 4 27893 NULL
105636 +gluebi_write_27905 gluebi_write 3-2 27905 NULL
105637 +SyS_ptrace_27924 SyS_ptrace 3 27924 NULL
105638 +bm_find_next_27929 bm_find_next 2 27929 NULL
105639 +check_mapped_name_27943 check_mapped_name 3 27943 NULL
105640 +i915_gem_execbuffer_reserve_object_27956 i915_gem_execbuffer_reserve_object 0 27956 NULL
105641 +tracing_clock_write_27961 tracing_clock_write 3 27961 NULL
105642 +tipc_media_addr_printf_27971 tipc_media_addr_printf 2 27971 NULL
105643 +device_register_27972 device_register 0 27972 NULL nohasharray
105644 +mic_rx_pkts_read_27972 mic_rx_pkts_read 3 27972 &device_register_27972
105645 +pci_enable_device_flags_27977 pci_enable_device_flags 0 27977 NULL
105646 +f2fs_bio_alloc_27983 f2fs_bio_alloc 2 27983 NULL
105647 +edt_ft5x06_debugfs_raw_data_read_28002 edt_ft5x06_debugfs_raw_data_read 3 28002 NULL
105648 +snd_rawmidi_write_28008 snd_rawmidi_write 3 28008 NULL
105649 +remove_extent_data_ref_28023 remove_extent_data_ref 0 28023 NULL
105650 +alloc_one_pg_vec_page_28031 alloc_one_pg_vec_page 1 28031 NULL
105651 +record_deleted_ref_28039 record_deleted_ref 0 28039 NULL
105652 +sctp_setsockopt_maxburst_28041 sctp_setsockopt_maxburst 3 28041 NULL
105653 +rts51x_xd_rw_28046 rts51x_xd_rw 3-4 28046 NULL
105654 +p9_fd_write_28050 p9_fd_write 3 28050 NULL
105655 +cx231xx_init_vbi_isoc_28053 cx231xx_init_vbi_isoc 3-2-4 28053 NULL
105656 +pool_status_28055 pool_status 5 28055 NULL
105657 +init_rs_non_canonical_28059 init_rs_non_canonical 1 28059 NULL
105658 +lpfc_idiag_mbxacc_read_28061 lpfc_idiag_mbxacc_read 3 28061 NULL
105659 +tx_frag_bad_mblk_num_read_28064 tx_frag_bad_mblk_num_read 3 28064 NULL
105660 +ext4_read_block_bitmap_nowait_28078 ext4_read_block_bitmap_nowait 2 28078 NULL
105661 +platform_get_irq_28088 platform_get_irq 0 28088 NULL
105662 +SyS_brk_28096 SyS_brk 1 28096 NULL
105663 +mmc_test_alloc_mem_28102 mmc_test_alloc_mem 2-3 28102 NULL
105664 +rx_defrag_need_defrag_read_28117 rx_defrag_need_defrag_read 3 28117 NULL
105665 +vgacon_adjust_height_28124 vgacon_adjust_height 2 28124 NULL
105666 +tipc_msg_init_28128 tipc_msg_init 4-2 28128 NULL
105667 +video_read_28148 video_read 3 28148 NULL
105668 +snd_midi_channel_alloc_set_28153 snd_midi_channel_alloc_set 1 28153 NULL
105669 +stats_dot11FCSErrorCount_read_28154 stats_dot11FCSErrorCount_read 3 28154 NULL
105670 +__add_reloc_root_28155 __add_reloc_root 0 28155 NULL
105671 +vread_28173 vread 0-3 28173 NULL
105672 +macvtap_get_user_28185 macvtap_get_user 4 28185 NULL
105673 +counter_free_res_28187 counter_free_res 5 28187 NULL
105674 +read_disk_sb_28188 read_disk_sb 2 28188 NULL
105675 +nouveau_mxm_create__28200 nouveau_mxm_create_ 4 28200 NULL
105676 +__exclude_logged_extent_28212 __exclude_logged_extent 2-0 28212 NULL
105677 +__qp_memcpy_from_queue_28220 __qp_memcpy_from_queue 3-4 28220 NULL
105678 +ocfs2_cow_sync_writeback_28221 ocfs2_cow_sync_writeback 0 28221 NULL
105679 +line6_alloc_sysex_buffer_28225 line6_alloc_sysex_buffer 4 28225 NULL
105680 +amd_nb_num_28228 amd_nb_num 0 28228 NULL
105681 +ext4_validate_block_bitmap_28243 ext4_validate_block_bitmap 3 28243 NULL
105682 +fuse_direct_IO_28275 fuse_direct_IO 4 28275 NULL
105683 +usemap_size_28281 usemap_size 0 28281 NULL
105684 +inline_xattr_size_28285 inline_xattr_size 0 28285 NULL
105685 +dma_map_sg_attrs_28289 dma_map_sg_attrs 0 28289 NULL
105686 +SyS_ppoll_28290 SyS_ppoll 2 28290 NULL
105687 +kstrtos16_from_user_28300 kstrtos16_from_user 2 28300 NULL
105688 +acpi_register_gsi_xen_28305 acpi_register_gsi_xen 2 28305 NULL nohasharray
105689 +nouveau_compat_ioctl_28305 nouveau_compat_ioctl 2 28305 &acpi_register_gsi_xen_28305
105690 +create_io_context_28306 create_io_context 2 28306 NULL
105691 +__mlock_vma_pages_range_28315 __mlock_vma_pages_range 2-3-0 28315 NULL
105692 +snd_pcm_oss_read_28317 snd_pcm_oss_read 3 28317 NULL
105693 +bm_entry_write_28338 bm_entry_write 3 28338 NULL
105694 +tcp_copy_to_iovec_28344 tcp_copy_to_iovec 3 28344 NULL
105695 +cpuset_spread_node_28351 cpuset_spread_node 0 28351 NULL nohasharray
105696 +snapshot_write_28351 snapshot_write 3 28351 &cpuset_spread_node_28351
105697 +xfs_iomap_write_unwritten_28365 xfs_iomap_write_unwritten 3-2 28365 NULL
105698 +dlmfs_file_read_28385 dlmfs_file_read 3 28385 NULL
105699 +tx_frag_cache_miss_read_28394 tx_frag_cache_miss_read 3 28394 NULL
105700 +bypass_pwup_write_28416 bypass_pwup_write 3 28416 NULL
105701 +subdev_ioctl_28417 subdev_ioctl 2 28417 NULL
105702 +get_extent_allocation_hint_28423 get_extent_allocation_hint 0 28423 NULL
105703 +ksocknal_alloc_tx_28426 ksocknal_alloc_tx 2 28426 NULL
105704 +mpage_readpages_28436 mpage_readpages 3 28436 NULL
105705 +snd_emu10k1_efx_read_28452 snd_emu10k1_efx_read 2 28452 NULL
105706 +key_mic_failures_read_28457 key_mic_failures_read 3 28457 NULL
105707 +alloc_irq_cpu_rmap_28459 alloc_irq_cpu_rmap 1 28459 NULL
105708 +vmw_du_crtc_cursor_set_28479 vmw_du_crtc_cursor_set 4-5 28479 NULL
105709 +ocfs2_backup_super_blkno_28484 ocfs2_backup_super_blkno 0-2 28484 NULL
105710 +__filemap_fdatawrite_28485 __filemap_fdatawrite 0 28485 NULL
105711 +clear_discard_28494 clear_discard 2 28494 NULL
105712 +ps_poll_upsd_utilization_read_28519 ps_poll_upsd_utilization_read 3 28519 NULL
105713 +__next_node_28521 __next_node 1-0 28521 NULL
105714 +i2400m_tx_stats_read_28527 i2400m_tx_stats_read 3 28527 NULL
105715 +sel_read_policycap_28544 sel_read_policycap 3 28544 NULL
105716 +run_delalloc_range_28545 run_delalloc_range 3-4 28545 NULL nohasharray
105717 +mptctl_getiocinfo_28545 mptctl_getiocinfo 2 28545 &run_delalloc_range_28545 nohasharray
105718 +aio_read_events_28545 aio_read_events 3 28545 &mptctl_getiocinfo_28545
105719 +sysfs_create_bin_file_28551 sysfs_create_bin_file 0 28551 NULL
105720 +b43legacy_debugfs_write_28556 b43legacy_debugfs_write 3 28556 NULL
105721 +i2o_msg_post_wait_mem_28558 i2o_msg_post_wait_mem 0 28558 NULL
105722 +asymmetric_verify_28567 asymmetric_verify 3 28567 NULL
105723 +oxygen_read32_28582 oxygen_read32 0 28582 NULL
105724 +ocfs2_read_dir_block_28587 ocfs2_read_dir_block 2 28587 NULL
105725 +extract_entropy_28604 extract_entropy 5-3 28604 NULL
105726 +kfifo_unused_28612 kfifo_unused 0 28612 NULL
105727 +mp_override_legacy_irq_28618 mp_override_legacy_irq 4 28618 NULL
105728 +snd_nm256_capture_copy_28622 snd_nm256_capture_copy 5-3 28622 NULL
105729 +setup_usemap_28636 setup_usemap 3-4 28636 NULL
105730 +qib_handle_6120_hwerrors_28642 qib_handle_6120_hwerrors 3 28642 NULL
105731 +p9_fcall_alloc_28652 p9_fcall_alloc 1 28652 NULL
105732 +read_nic_io_byte_28654 read_nic_io_byte 0 28654 NULL
105733 +btrfs_previous_item_28667 btrfs_previous_item 0 28667 NULL
105734 +blk_queue_resize_tags_28670 blk_queue_resize_tags 2 28670 NULL
105735 +__perf_sw_event_28684 __perf_sw_event 2 28684 NULL
105736 +SyS_setgroups16_28686 SyS_setgroups16 1 28686 NULL
105737 +kvm_mmu_get_page_28692 kvm_mmu_get_page 2 28692 NULL
105738 +balance_level_28707 balance_level 0 28707 NULL
105739 +drm_plane_init_28731 drm_plane_init 6 28731 NULL
105740 +alloc_irq_cfg_28734 alloc_irq_cfg 2 28734 NULL
105741 +spi_execute_28736 spi_execute 5 28736 NULL
105742 +snd_pcm_aio_write_28738 snd_pcm_aio_write 3 28738 NULL
105743 +read_file_btcoex_28743 read_file_btcoex 3 28743 NULL
105744 +max_hw_blocks_28748 max_hw_blocks 0 28748 NULL
105745 +rpc_pipe_generic_upcall_28766 rpc_pipe_generic_upcall 4 28766 NULL
105746 +atomic_inc_return_unchecked_28778 atomic_inc_return_unchecked 0 28778 NULL
105747 +ath6kl_get_num_reg_28780 ath6kl_get_num_reg 0 28780 NULL
105748 +btrfs_block_rsv_refill_28800 btrfs_block_rsv_refill 3 28800 NULL nohasharray
105749 +sel_write_member_28800 sel_write_member 3 28800 &btrfs_block_rsv_refill_28800
105750 +cgroup_file_read_28804 cgroup_file_read 3 28804 NULL
105751 +memory_bm_create_28814 memory_bm_create 0 28814 NULL
105752 +iwl_dbgfs_rxon_filter_flags_read_28832 iwl_dbgfs_rxon_filter_flags_read 3 28832 NULL
105753 +vp_request_msix_vectors_28849 vp_request_msix_vectors 2 28849 NULL
105754 +ipv6_renew_options_28867 ipv6_renew_options 5 28867 NULL
105755 +max_io_len_target_boundary_28879 max_io_len_target_boundary 0-1 28879 NULL
105756 +packet_sendmsg_spkt_28885 packet_sendmsg_spkt 4 28885 NULL
105757 +to_cblock_28899 to_cblock 0-1 28899 NULL
105758 +da9055_group_write_28904 da9055_group_write 2-3 28904 NULL
105759 +ps_upsd_timeouts_read_28924 ps_upsd_timeouts_read 3 28924 NULL
105760 +iwl_dbgfs_sleep_level_override_write_28925 iwl_dbgfs_sleep_level_override_write 3 28925 NULL
105761 +ocfs2_frozen_trigger_28929 ocfs2_frozen_trigger 4 28929 NULL
105762 +push_rx_28939 push_rx 3 28939 NULL
105763 +btrfs_trim_block_group_28963 btrfs_trim_block_group 4-3 28963 NULL
105764 +alloc_sched_domains_28972 alloc_sched_domains 1 28972 NULL
105765 +remap_pfn_range_28976 remap_pfn_range 3-4-2 28976 NULL
105766 +ext4_mb_add_groupinfo_28988 ext4_mb_add_groupinfo 2 28988 NULL
105767 +hci_sock_setsockopt_28993 hci_sock_setsockopt 5 28993 NULL
105768 +bin_uuid_28999 bin_uuid 3 28999 NULL
105769 +fd_execute_rw_29004 fd_execute_rw 3 29004 NULL nohasharray
105770 +offset_to_bitmap_29004 offset_to_bitmap 2 29004 &fd_execute_rw_29004
105771 +xz_dec_init_29029 xz_dec_init 2 29029 NULL
105772 +i915_gem_object_bind_to_vm_29035 i915_gem_object_bind_to_vm 0 29035 NULL
105773 +ieee80211_if_read_ht_opmode_29044 ieee80211_if_read_ht_opmode 3 29044 NULL
105774 +ProcessGetHostMibs_29049 ProcessGetHostMibs 0 29049 NULL nohasharray
105775 +rxrpc_sendmsg_29049 rxrpc_sendmsg 4 29049 &ProcessGetHostMibs_29049
105776 +btrfs_root_bytenr_29058 btrfs_root_bytenr 0 29058 NULL
105777 +iso_packets_buffer_init_29061 iso_packets_buffer_init 3-4 29061 NULL
105778 +roundup_64_29066 roundup_64 2-0-1 29066 NULL
105779 +lpfc_idiag_extacc_drivr_get_29067 lpfc_idiag_extacc_drivr_get 0-3 29067 NULL
105780 +sctp_getsockopt_assoc_stats_29074 sctp_getsockopt_assoc_stats 2 29074 NULL
105781 +iwl_dbgfs_log_event_write_29088 iwl_dbgfs_log_event_write 3 29088 NULL
105782 +i915_error_object_create_sized_29091 i915_error_object_create_sized 3 29091 NULL
105783 +init_cache_node_node_29092 init_cache_node_node 1 29092 NULL
105784 +isdn_ppp_write_29109 isdn_ppp_write 4 29109 NULL
105785 +snprintf_29125 snprintf 0 29125 NULL
105786 +iov_shorten_29130 iov_shorten 0 29130 NULL
105787 +proc_scsi_write_29142 proc_scsi_write 3 29142 NULL
105788 +alloc_irqs_from_29152 alloc_irqs_from 1-2-0-3 29152 NULL
105789 +kvm_mmu_notifier_clear_flush_young_29154 kvm_mmu_notifier_clear_flush_young 3 29154 NULL
105790 +drm_property_create_enum_29201 drm_property_create_enum 5 29201 NULL
105791 +wusb_prf_256_29203 wusb_prf_256 7 29203 NULL
105792 +__mm_populate_29204 __mm_populate 1-2 29204 NULL
105793 +do_shrinker_shrink_29208 do_shrinker_shrink 0 29208 NULL
105794 +rds_iw_inc_copy_to_user_29214 rds_iw_inc_copy_to_user 3 29214 NULL
105795 +iwl_dbgfs_temperature_read_29224 iwl_dbgfs_temperature_read 3 29224 NULL
105796 +nvme_trans_copy_from_user_29227 nvme_trans_copy_from_user 3 29227 NULL
105797 +irq_domain_add_linear_29236 irq_domain_add_linear 2 29236 NULL
105798 +recover_peb_29238 recover_peb 0-7-6 29238 NULL
105799 +evdev_handle_get_val_29242 evdev_handle_get_val 5-6 29242 NULL
105800 +rw_verify_area_29243 rw_verify_area 0-4 29243 NULL
105801 +security_context_to_sid_core_29248 security_context_to_sid_core 2 29248 NULL
105802 +block_div_29268 block_div 0-1-2 29268 NULL
105803 +prism2_set_genericelement_29277 prism2_set_genericelement 3 29277 NULL
105804 +bitmap_ord_to_pos_29279 bitmap_ord_to_pos 3 29279 NULL
105805 +ext4_fiemap_29296 ext4_fiemap 4 29296 NULL
105806 +sn9c102_read_29305 sn9c102_read 3 29305 NULL
105807 +replace_file_extents_29312 replace_file_extents 0 29312 NULL
105808 +__fuse_get_req_29315 __fuse_get_req 2 29315 NULL
105809 +lprocfs_write_helper_29323 lprocfs_write_helper 2 29323 NULL
105810 +kvm_handle_hva_29326 kvm_handle_hva 2 29326 NULL
105811 +tun_put_user_29337 tun_put_user 5 29337 NULL
105812 +__alloc_ei_netdev_29338 __alloc_ei_netdev 1 29338 NULL
105813 +ide_read_altstatus_29343 ide_read_altstatus 0 29343 NULL
105814 +l2cap_sock_setsockopt_old_29346 l2cap_sock_setsockopt_old 4 29346 NULL
105815 +gpiochip_find_base_29366 gpiochip_find_base 0-1 29366 NULL
105816 +ktime_us_delta_29375 ktime_us_delta 0 29375 NULL
105817 +mwifiex_cfg80211_mgmt_tx_29387 mwifiex_cfg80211_mgmt_tx 7 29387 NULL
105818 +pca953x_irq_setup_29407 pca953x_irq_setup 3 29407 NULL
105819 +btrfs_run_delayed_items_29428 btrfs_run_delayed_items 0 29428 NULL
105820 +mempool_create_29437 mempool_create 1 29437 NULL
105821 +crypto_ahash_alignmask_29445 crypto_ahash_alignmask 0 29445 NULL
105822 +p9_client_prepare_req_29448 p9_client_prepare_req 3 29448 NULL
105823 +ept_page_fault_29450 ept_page_fault 2 29450 NULL
105824 +__kmalloc_node_29455 __kmalloc_node 3 29455 NULL
105825 +validate_scan_freqs_29462 validate_scan_freqs 0 29462 NULL
105826 +SyS_flistxattr_29474 SyS_flistxattr 3 29474 NULL
105827 +do_register_entry_29478 do_register_entry 4 29478 NULL
105828 +simple_strtoul_29480 simple_strtoul 0 29480 NULL
105829 +sched_clock_local_29498 sched_clock_local 0 29498 NULL
105830 +btmrvl_pscmd_write_29504 btmrvl_pscmd_write 3 29504 NULL
105831 +btrfs_file_extent_disk_bytenr_29505 btrfs_file_extent_disk_bytenr 0 29505 NULL
105832 +write_file_regidx_29517 write_file_regidx 3 29517 NULL
105833 +atk_debugfs_ggrp_read_29522 atk_debugfs_ggrp_read 3 29522 NULL
105834 +_regmap_raw_write_29541 _regmap_raw_write 2-4 29541 NULL
105835 +vfs_read_29543 vfs_read 0-3 29543 NULL
105836 +set_brk_29551 set_brk 1-2 29551 NULL nohasharray
105837 +ftrace_write_29551 ftrace_write 3 29551 &set_brk_29551
105838 +idetape_queue_rw_tail_29562 idetape_queue_rw_tail 3 29562 NULL
105839 +leaf_dealloc_29566 leaf_dealloc 3 29566 NULL
105840 +kvm_read_guest_virt_system_29569 kvm_read_guest_virt_system 4-2 29569 NULL
105841 +p9_fd_read_29570 p9_fd_read 3 29570 NULL
105842 +lbs_lowsnr_read_29571 lbs_lowsnr_read 3 29571 NULL
105843 +iwl_dbgfs_missed_beacon_write_29586 iwl_dbgfs_missed_beacon_write 3 29586 NULL
105844 +pvr2_hdw_report_unlocked_29589 pvr2_hdw_report_unlocked 4-0 29589 NULL
105845 +dio_set_defer_completion_29599 dio_set_defer_completion 0 29599 NULL
105846 +slots_per_page_29601 slots_per_page 0 29601 NULL
105847 +osc_cached_mb_seq_write_29610 osc_cached_mb_seq_write 3 29610 NULL
105848 +nla_get_u16_29624 nla_get_u16 0 29624 NULL
105849 +tx_frag_cache_hit_read_29639 tx_frag_cache_hit_read 3 29639 NULL
105850 +sctp_make_abort_user_29654 sctp_make_abort_user 3 29654 NULL
105851 +sisusb_write_mem_bulk_29678 sisusb_write_mem_bulk 4 29678 NULL
105852 +tracepoint_probe_register_29688 tracepoint_probe_register 0 29688 NULL
105853 +__btrfs_setxattr_29689 __btrfs_setxattr 0 29689 NULL
105854 +jbd2_journal_restart_29692 jbd2_journal_restart 0 29692 NULL
105855 +lustre_posix_acl_xattr_2ext_29693 lustre_posix_acl_xattr_2ext 2 29693 NULL
105856 +posix_acl_from_xattr_29708 posix_acl_from_xattr 3 29708 NULL
105857 +probes_write_29711 probes_write 3 29711 NULL
105858 +read_cis_cache_29735 read_cis_cache 4 29735 NULL
105859 +xfs_new_eof_29737 xfs_new_eof 2 29737 NULL
105860 +std_nic_write_29752 std_nic_write 3 29752 NULL
105861 +dbAlloc_29794 dbAlloc 0 29794 NULL
105862 +ext4_trim_all_free_29806 ext4_trim_all_free 4-3-2 29806 NULL
105863 +tcp_sendpage_29829 tcp_sendpage 4 29829 NULL
105864 +scan_bitmap_block_29840 scan_bitmap_block 4 29840 NULL
105865 +__probe_kernel_write_29842 __probe_kernel_write 3 29842 NULL
105866 +kvm_read_hva_atomic_29848 kvm_read_hva_atomic 3 29848 NULL
105867 +count_partial_29850 count_partial 0 29850 NULL
105868 +radeon_ttm_tt_create_29859 radeon_ttm_tt_create 2 29859 NULL
105869 +solo_enc_alloc_29860 solo_enc_alloc 3 29860 NULL
105870 +ipv6_setsockopt_29871 ipv6_setsockopt 5 29871 NULL
105871 +tlv_put_29872 tlv_put 0 29872 NULL
105872 +scsi_end_request_29876 scsi_end_request 3 29876 NULL
105873 +changed_extent_29881 changed_extent 0 29881 NULL
105874 +crypto_aead_alignmask_29885 crypto_aead_alignmask 0 29885 NULL
105875 +lov_ost_pool_extend_29914 lov_ost_pool_extend 2 29914 NULL
105876 +write_file_queue_29922 write_file_queue 3 29922 NULL
105877 +ext4_xattr_set_acl_29930 ext4_xattr_set_acl 4 29930 NULL
105878 +__btrfs_getxattr_29947 __btrfs_getxattr 0 29947 NULL
105879 +diva_os_get_context_size_29983 diva_os_get_context_size 0 29983 NULL
105880 +arch_setup_dmar_msi_29992 arch_setup_dmar_msi 1 29992 NULL
105881 +vmci_host_setup_notify_30002 vmci_host_setup_notify 2 30002 NULL
105882 +dev_mem_write_30028 dev_mem_write 3 30028 NULL
105883 +alloc_netdev_mqs_30030 alloc_netdev_mqs 1 30030 NULL
105884 +scsi_vpd_inquiry_30040 scsi_vpd_inquiry 4 30040 NULL
105885 +drp_wmove_30043 drp_wmove 4 30043 NULL nohasharray
105886 +wrmalt_30043 wrmalt 0 30043 &drp_wmove_30043
105887 +mem_cgroup_charge_common_30047 mem_cgroup_charge_common 0 30047 NULL
105888 +SyS_write_30059 SyS_write 3 30059 NULL
105889 +cxgbi_ddp_reserve_30091 cxgbi_ddp_reserve 4 30091 NULL
105890 +snd_midi_channel_init_set_30092 snd_midi_channel_init_set 1 30092 NULL
105891 +rx_filter_data_filter_read_30098 rx_filter_data_filter_read 3 30098 NULL
105892 +defragment_dma_buffer_30113 defragment_dma_buffer 0 30113 NULL
105893 +spi_async_locked_30117 spi_async_locked 0 30117 NULL
105894 +calgary_unmap_page_30130 calgary_unmap_page 3-2 30130 NULL
105895 +recv_stream_30138 recv_stream 4 30138 NULL
105896 +u_memcpya_30139 u_memcpya 3-2 30139 NULL
105897 +elfcorehdr_read_30159 elfcorehdr_read 2 30159 NULL
105898 +alloc_switch_ctx_30165 alloc_switch_ctx 2 30165 NULL
105899 +expand_inode_data_30169 expand_inode_data 2-3 30169 NULL
105900 +btrfs_start_transaction_lflush_30178 btrfs_start_transaction_lflush 2 30178 NULL
105901 +mempool_create_page_pool_30189 mempool_create_page_pool 1 30189 NULL
105902 +drm_property_create_bitmask_30195 drm_property_create_bitmask 5 30195 NULL
105903 +snd_pcm_playback_forward_30201 snd_pcm_playback_forward 0-2 30201 NULL
105904 +usblp_ioctl_30203 usblp_ioctl 2 30203 NULL
105905 +read_4k_modal_eeprom_30212 read_4k_modal_eeprom 3 30212 NULL
105906 +bitmap_file_set_bit_30228 bitmap_file_set_bit 2 30228 NULL
105907 +shmem_unuse_inode_30263 shmem_unuse_inode 0 30263 NULL
105908 +rawv6_recvmsg_30265 rawv6_recvmsg 4 30265 NULL
105909 +hfsplus_trusted_setxattr_30270 hfsplus_trusted_setxattr 4 30270 NULL
105910 +isr_pci_pm_read_30271 isr_pci_pm_read 3 30271 NULL
105911 +compat_readv_30273 compat_readv 3 30273 NULL
105912 +lapic_register_intr_30279 lapic_register_intr 1 30279 NULL
105913 +skcipher_sendmsg_30290 skcipher_sendmsg 4 30290 NULL
105914 +pipeline_sec_frag_swi_read_30294 pipeline_sec_frag_swi_read 3 30294 NULL
105915 +tcp_sendmsg_30296 tcp_sendmsg 4 30296 NULL
105916 +osc_contention_seconds_seq_write_30305 osc_contention_seconds_seq_write 3 30305 NULL
105917 +drm_core_get_reg_ofs_30309 drm_core_get_reg_ofs 0 30309 NULL
105918 +ext4_acl_from_disk_30320 ext4_acl_from_disk 2 30320 NULL
105919 +i8254_read_30330 i8254_read 0 30330 NULL
105920 +generic_ptrace_pokedata_30338 generic_ptrace_pokedata 2 30338 NULL
105921 +resource_from_user_30341 resource_from_user 3 30341 NULL
105922 +o2nm_this_node_30342 o2nm_this_node 0 30342 NULL
105923 +__vmalloc_node_flags_30352 __vmalloc_node_flags 1-2 30352 NULL
105924 +kstrtou32_from_user_30361 kstrtou32_from_user 2 30361 NULL
105925 +inet_getid_30365 inet_getid 2 30365 NULL
105926 +C_SYSC_readv_30369 C_SYSC_readv 3 30369 NULL
105927 +blkdev_issue_zeroout_30392 blkdev_issue_zeroout 3-0 30392 NULL
105928 +c4iw_init_resource_30393 c4iw_init_resource 2-3 30393 NULL
105929 +get_kernel_pages_30397 get_kernel_pages 0 30397 NULL
105930 +_drbd_bm_find_next_zero_30415 _drbd_bm_find_next_zero 2 30415 NULL
105931 +ext3_xattr_list_30419 ext3_xattr_list 3 30419 NULL
105932 +vb2_fop_write_30420 vb2_fop_write 3 30420 NULL
105933 +tx_tx_template_prepared_read_30424 tx_tx_template_prepared_read 3 30424 NULL
105934 +mq_create_30425 mq_create 1 30425 NULL nohasharray
105935 +lstcon_session_info_30425 lstcon_session_info 6 30425 &mq_create_30425
105936 +ext4_ext_create_new_leaf_30428 ext4_ext_create_new_leaf 0 30428 NULL
105937 +enable_write_30456 enable_write 3 30456 NULL
105938 +pci_resource_alignment_30457 pci_resource_alignment 0 30457 NULL
105939 +tx_tx_template_programmed_read_30461 tx_tx_template_programmed_read 3 30461 NULL
105940 +urandom_read_30462 urandom_read 3 30462 NULL
105941 +zoran_ioctl_30465 zoran_ioctl 2 30465 NULL
105942 +i2c_ctrl_read_30467 i2c_ctrl_read 0 30467 NULL
105943 +send_rmdir_30470 send_rmdir 0 30470 NULL
105944 +i915_mutex_lock_interruptible_30474 i915_mutex_lock_interruptible 0 30474 NULL nohasharray
105945 +ocrdma_reg_user_mr_30474 ocrdma_reg_user_mr 2-3 30474 &i915_mutex_lock_interruptible_30474
105946 +write_head_30481 write_head 4 30481 NULL
105947 +adu_write_30487 adu_write 3 30487 NULL
105948 +dtim_interval_write_30489 dtim_interval_write 3 30489 NULL
105949 +btrfs_free_extent_30515 btrfs_free_extent 0 30515 NULL
105950 +dwc3_testmode_write_30516 dwc3_testmode_write 3 30516 NULL
105951 +debug_debug2_read_30526 debug_debug2_read 3 30526 NULL nohasharray
105952 +set_config_30526 set_config 0 30526 &debug_debug2_read_30526
105953 +disk_expand_part_tbl_30561 disk_expand_part_tbl 2 30561 NULL
105954 +set_le_30581 set_le 4 30581 NULL
105955 +from_cblock_30582 from_cblock 0-1 30582 NULL
105956 +blk_init_tags_30592 blk_init_tags 1 30592 NULL
105957 +i2c_hid_get_report_length_30598 i2c_hid_get_report_length 0 30598 NULL
105958 +sgl_map_user_pages_30610 sgl_map_user_pages 2-3-4 30610 NULL
105959 +SyS_msgrcv_30611 SyS_msgrcv 3 30611 NULL
105960 +macvtap_sendmsg_30629 macvtap_sendmsg 4 30629 NULL
105961 +ieee80211_if_read_dot11MeshAwakeWindowDuration_30631 ieee80211_if_read_dot11MeshAwakeWindowDuration 3 30631 NULL
105962 +compat_raw_setsockopt_30634 compat_raw_setsockopt 5 30634 NULL
105963 +mlx5_ib_alloc_fast_reg_page_list_30638 mlx5_ib_alloc_fast_reg_page_list 2 30638 NULL
105964 +SyS_listxattr_30647 SyS_listxattr 3 30647 NULL
105965 +agp_remap_30665 agp_remap 2 30665 NULL
105966 +jffs2_flash_read_30667 jffs2_flash_read 0 30667 NULL
105967 +ni_ai_fifo_read_30681 ni_ai_fifo_read 3 30681 NULL
105968 +dccp_setsockopt_ccid_30701 dccp_setsockopt_ccid 4 30701 NULL
105969 +lbs_wrbbp_write_30712 lbs_wrbbp_write 3 30712 NULL
105970 +ocfs2_find_cpos_for_left_leaf_30713 ocfs2_find_cpos_for_left_leaf 0 30713 NULL
105971 +__mutex_lock_common_30717 __mutex_lock_common 0 30717 NULL
105972 +lbs_debugfs_read_30721 lbs_debugfs_read 3 30721 NULL
105973 +snd_nm256_playback_silence_30727 snd_nm256_playback_silence 4-3 30727 NULL
105974 +snapshot_status_30744 snapshot_status 5 30744 NULL
105975 +fuse_conn_limit_write_30777 fuse_conn_limit_write 3 30777 NULL
105976 +SyS_pread64_30778 SyS_pread64 3 30778 NULL
105977 +btrfs_run_ordered_operations_30793 btrfs_run_ordered_operations 0 30793 NULL
105978 +smk_read_doi_30813 smk_read_doi 3 30813 NULL
105979 +SYSC_splice_30820 SYSC_splice 5 30820 NULL
105980 +xlog_grant_head_wait_30829 xlog_grant_head_wait 4 30829 NULL
105981 +get_kobj_path_length_30831 get_kobj_path_length 0 30831 NULL
105982 +sctp_setsockopt_auth_chunk_30843 sctp_setsockopt_auth_chunk 3 30843 NULL
105983 +cfg80211_rx_mgmt_30844 cfg80211_rx_mgmt 5 30844 NULL
105984 +wd_autoreset_write_30862 wd_autoreset_write 3 30862 NULL
105985 +ieee80211_if_fmt_dropped_frames_no_route_30884 ieee80211_if_fmt_dropped_frames_no_route 3 30884 NULL
105986 +pn_recvmsg_30887 pn_recvmsg 4 30887 NULL
105987 +sctp_setsockopt_rtoinfo_30941 sctp_setsockopt_rtoinfo 3 30941 NULL
105988 +find_free_dev_extent_30963 find_free_dev_extent 0 30963 NULL
105989 +tty_insert_flip_string_flags_30969 tty_insert_flip_string_flags 4 30969 NULL
105990 +huge_page_mask_30981 huge_page_mask 0 30981 NULL
105991 +read_file_bt_ant_diversity_30983 read_file_bt_ant_diversity 3 30983 NULL
105992 +lbs_host_sleep_read_31013 lbs_host_sleep_read 3 31013 NULL
105993 +do_setup_msi_irqs_31043 do_setup_msi_irqs 2 31043 NULL
105994 +stride_pg_count_31053 stride_pg_count 0-2-1-4-3-5 31053 NULL
105995 +lbs_failcount_read_31063 lbs_failcount_read 3 31063 NULL
105996 +find_next_bit_le_31064 find_next_bit_le 0-2-3 31064 NULL
105997 +sctp_setsockopt_context_31091 sctp_setsockopt_context 3 31091 NULL
105998 +proc_gid_map_write_31093 proc_gid_map_write 3 31093 NULL
105999 +compat_sys_get_mempolicy_31109 compat_sys_get_mempolicy 3 31109 NULL
106000 +si_calculate_power_efficiency_ratio_31111 si_calculate_power_efficiency_ratio 3-2 31111 NULL
106001 +depth_read_31112 depth_read 3 31112 NULL
106002 +kimage_normal_alloc_31140 kimage_normal_alloc 3 31140 NULL
106003 +size_inside_page_31141 size_inside_page 0-1-2 31141 NULL
106004 +w9966_v4l_read_31148 w9966_v4l_read 3 31148 NULL
106005 +ch_do_scsi_31171 ch_do_scsi 4 31171 NULL
106006 +r592_read_fifo_pio_31198 r592_read_fifo_pio 3 31198 NULL
106007 +mtdchar_readoob_31200 mtdchar_readoob 4 31200 NULL
106008 +__btrfs_free_reserved_extent_31207 __btrfs_free_reserved_extent 2 31207 NULL
106009 +kvm_mmu_page_fault_31213 kvm_mmu_page_fault 2 31213 NULL
106010 +cpumask_weight_31215 cpumask_weight 0 31215 NULL
106011 +__read_reg_31216 __read_reg 0 31216 NULL
106012 +atm_get_addr_31221 atm_get_addr 3 31221 NULL
106013 +ulist_rbtree_insert_31235 ulist_rbtree_insert 0 31235 NULL
106014 +tcp_recvmsg_31238 tcp_recvmsg 4 31238 NULL
106015 +cyy_readb_31240 cyy_readb 0 31240 NULL
106016 +_create_sg_bios_31244 _create_sg_bios 4 31244 NULL
106017 +ieee80211_if_read_last_beacon_31257 ieee80211_if_read_last_beacon 3 31257 NULL
106018 +sctp_tsnmap_find_gap_ack_31272 sctp_tsnmap_find_gap_ack 3-2 31272 NULL
106019 +uvc_simplify_fraction_31303 uvc_simplify_fraction 3 31303 NULL
106020 +push_leaf_left_31306 push_leaf_left 0 31306 NULL
106021 +sisusbcon_scroll_31315 sisusbcon_scroll 5-2-3 31315 NULL
106022 +command_file_write_31318 command_file_write 3 31318 NULL
106023 +ext4_xattr_block_list_31325 ext4_xattr_block_list 3 31325 NULL
106024 +hwerr_crcbits_31334 hwerr_crcbits 4 31334 NULL
106025 +radix_tree_insert_31336 radix_tree_insert 0 31336 NULL
106026 +em28xx_init_usb_xfer_31337 em28xx_init_usb_xfer 4-6 31337 NULL
106027 +__cpu_to_node_31345 __cpu_to_node 0 31345 NULL
106028 +outlen_write_31358 outlen_write 3 31358 NULL
106029 +ieee80211_rx_mgmt_auth_31366 ieee80211_rx_mgmt_auth 3 31366 NULL
106030 +xprt_rdma_allocate_31372 xprt_rdma_allocate 2 31372 NULL
106031 +vb2_vmalloc_get_userptr_31374 vb2_vmalloc_get_userptr 2-3 31374 NULL
106032 +trace_parser_get_init_31379 trace_parser_get_init 2 31379 NULL
106033 +inb_31388 inb 0 31388 NULL
106034 +key_ifindex_read_31411 key_ifindex_read 3 31411 NULL
106035 +i915_gem_object_put_fence_31413 i915_gem_object_put_fence 0 31413 NULL
106036 +_sp2d_max_pg_31422 _sp2d_max_pg 0 31422 NULL
106037 +TSS_checkhmac1_31429 TSS_checkhmac1 5 31429 NULL
106038 +snd_aw2_saa7146_get_hw_ptr_capture_31431 snd_aw2_saa7146_get_hw_ptr_capture 0 31431 NULL
106039 +acpi_sci_ioapic_setup_31445 acpi_sci_ioapic_setup 4 31445 NULL
106040 +transport_alloc_session_tags_31449 transport_alloc_session_tags 2-3 31449 NULL
106041 +opera1_xilinx_rw_31453 opera1_xilinx_rw 5 31453 NULL
106042 +register_ftrace_graph_31456 register_ftrace_graph 0 31456 NULL
106043 +input_get_new_minor_31464 input_get_new_minor 1 31464 NULL
106044 +do_fcntl_31468 do_fcntl 3 31468 NULL
106045 +xfs_btree_get_numrecs_31477 xfs_btree_get_numrecs 0 31477 NULL
106046 +__ext4_journal_get_write_access_31482 __ext4_journal_get_write_access 0 31482 NULL
106047 +alg_setkey_31485 alg_setkey 3 31485 NULL
106048 +rds_message_map_pages_31487 rds_message_map_pages 2 31487 NULL
106049 +qsfp_2_read_31491 qsfp_2_read 3 31491 NULL
106050 +__alloc_bootmem_31498 __alloc_bootmem 1 31498 NULL
106051 +nouveau_mc_create__31513 nouveau_mc_create_ 5 31513 NULL
106052 +hidraw_write_31536 hidraw_write 3 31536 NULL
106053 +mtd_div_by_eb_31543 mtd_div_by_eb 0-1 31543 NULL
106054 +usbvision_read_31555 usbvision_read 3 31555 NULL
106055 +tx_frag_tkip_called_read_31575 tx_frag_tkip_called_read 3 31575 NULL
106056 +get_max_inline_xattr_value_size_31578 get_max_inline_xattr_value_size 0 31578 NULL
106057 +osst_write_31581 osst_write 3 31581 NULL
106058 +snd_compr_get_avail_31584 snd_compr_get_avail 0 31584 NULL
106059 +iwl_dbgfs_ucode_tx_stats_read_31611 iwl_dbgfs_ucode_tx_stats_read 3 31611 NULL
106060 +mtd_get_user_prot_info_31616 mtd_get_user_prot_info 0 31616 NULL
106061 +arvo_sysfs_read_31617 arvo_sysfs_read 6 31617 NULL
106062 +videobuf_read_one_31637 videobuf_read_one 3 31637 NULL
106063 +pod_alloc_sysex_buffer_31651 pod_alloc_sysex_buffer 3 31651 NULL
106064 +xfer_secondary_pool_31661 xfer_secondary_pool 2 31661 NULL
106065 +emulator_set_cr_31665 emulator_set_cr 3 31665 NULL
106066 +__lgread_31668 __lgread 4 31668 NULL
106067 +forced_ps_read_31685 forced_ps_read 3 31685 NULL
106068 +fst_recover_rx_error_31687 fst_recover_rx_error 3 31687 NULL
106069 +reiserfs_in_journal_31689 reiserfs_in_journal 3 31689 NULL
106070 +gfn_to_hva_read_31728 gfn_to_hva_read 2 31728 NULL
106071 +utf16s_to_utf8s_31735 utf16s_to_utf8s 0 31735 NULL nohasharray
106072 +lu_buf_check_and_grow_31735 lu_buf_check_and_grow 2 31735 &utf16s_to_utf8s_31735
106073 +shmem_pwrite_slow_31741 shmem_pwrite_slow 3-2 31741 NULL
106074 +NCR_700_change_queue_depth_31742 NCR_700_change_queue_depth 2 31742 NULL nohasharray
106075 +input_abs_get_max_31742 input_abs_get_max 0 31742 &NCR_700_change_queue_depth_31742
106076 +muldiv64_31743 muldiv64 3-2-0 31743 NULL
106077 +stmpe_set_altfunc_31750 stmpe_set_altfunc 2 31750 NULL nohasharray
106078 +bcm_char_read_31750 bcm_char_read 3 31750 &stmpe_set_altfunc_31750
106079 +snd_seq_device_new_31753 snd_seq_device_new 4 31753 NULL
106080 +SyS_lsetxattr_31766 SyS_lsetxattr 4 31766 NULL
106081 +usblp_cache_device_id_string_31790 usblp_cache_device_id_string 0 31790 NULL
106082 +ecryptfs_send_message_locked_31801 ecryptfs_send_message_locked 2 31801 NULL
106083 +isr_rx_procs_read_31804 isr_rx_procs_read 3 31804 NULL
106084 +data_write_31805 data_write 3 31805 NULL
106085 +SyS_msgsnd_31814 SyS_msgsnd 3 31814 NULL
106086 +strnlen_user_31815 strnlen_user 0-2 31815 NULL
106087 +sta_last_signal_read_31818 sta_last_signal_read 3 31818 NULL
106088 +fsnotify_perm_31843 fsnotify_perm 0 31843 NULL
106089 +SyS_ppoll_31855 SyS_ppoll 2 31855 NULL
106090 +iwl_dbgfs_disable_ht40_write_31876 iwl_dbgfs_disable_ht40_write 3 31876 NULL
106091 +drm_mode_crtc_set_gamma_size_31881 drm_mode_crtc_set_gamma_size 2 31881 NULL
106092 +ddb_output_write_31902 ddb_output_write 3-0 31902 NULL
106093 +xattr_permission_31907 xattr_permission 0 31907 NULL
106094 +lu_buf_realloc_31915 lu_buf_realloc 2 31915 NULL
106095 +new_dir_31919 new_dir 3 31919 NULL
106096 +kmem_alloc_31920 kmem_alloc 1 31920 NULL
106097 +guestwidth_to_adjustwidth_31937 guestwidth_to_adjustwidth 0-1 31937 NULL
106098 +process_recorded_refs_if_needed_31938 process_recorded_refs_if_needed 0 31938 NULL
106099 +SYSC_sethostname_31940 SYSC_sethostname 2 31940 NULL
106100 +iov_iter_copy_from_user_31942 iov_iter_copy_from_user 4-0 31942 NULL nohasharray
106101 +read_mem_31942 read_mem 3 31942 &iov_iter_copy_from_user_31942
106102 +vb2_write_31948 vb2_write 3 31948 NULL
106103 +pvr2_ctrl_get_valname_31951 pvr2_ctrl_get_valname 4 31951 NULL
106104 +regcache_rbtree_sync_31964 regcache_rbtree_sync 2 31964 NULL
106105 +copy_from_user_toio_31966 copy_from_user_toio 3 31966 NULL
106106 +mtd_add_partition_31971 mtd_add_partition 3 31971 NULL
106107 +btrfs_insert_empty_inode_31975 btrfs_insert_empty_inode 0 31975 NULL
106108 +vx_read_status_31982 vx_read_status 0 31982 NULL nohasharray
106109 +iblock_execute_rw_31982 iblock_execute_rw 3 31982 &vx_read_status_31982
106110 +find_next_zero_bit_31990 find_next_zero_bit 3-2-0 31990 NULL
106111 +default_setup_hpet_msi_31991 default_setup_hpet_msi 1 31991 NULL
106112 +lustre_acl_xattr_merge2posix_31992 lustre_acl_xattr_merge2posix 2 31992 NULL
106113 +sysfs_create_file_31996 sysfs_create_file 0 31996 NULL
106114 +tps6586x_irq_map_32002 tps6586x_irq_map 2 32002 NULL
106115 +calc_hmac_32010 calc_hmac 3 32010 NULL
106116 +vmcs_read64_32012 vmcs_read64 0 32012 NULL
106117 +resource_alignment_32020 resource_alignment 0 32020 NULL
106118 +aead_len_32021 aead_len 0 32021 NULL
106119 +ocfs2_remove_extent_32032 ocfs2_remove_extent 4-3-0 32032 NULL
106120 +posix_acl_set_32037 posix_acl_set 4 32037 NULL
106121 +stk_read_32038 stk_read 3 32038 NULL
106122 +vmw_cursor_update_dmabuf_32045 vmw_cursor_update_dmabuf 3-4 32045 NULL
106123 +ocfs2_update_edge_lengths_32046 ocfs2_update_edge_lengths 0 32046 NULL
106124 +SYSC_llistxattr_32061 SYSC_llistxattr 3 32061 NULL
106125 +proc_scsi_devinfo_write_32064 proc_scsi_devinfo_write 3 32064 NULL
106126 +cow_file_range_inline_32091 cow_file_range_inline 3 32091 NULL
106127 +bio_alloc_32095 bio_alloc 2 32095 NULL
106128 +alloc_pwms_32100 alloc_pwms 1-2 32100 NULL
106129 +ath6kl_fwlog_read_32101 ath6kl_fwlog_read 3 32101 NULL
106130 +disk_status_32120 disk_status 4 32120 NULL
106131 +kobject_add_internal_32133 kobject_add_internal 0 32133 NULL
106132 +btrfs_split_item_32164 btrfs_split_item 0 32164 NULL
106133 +venus_link_32165 venus_link 5 32165 NULL
106134 +do_writepages_32173 do_writepages 0 32173 NULL nohasharray
106135 +ntfs_rl_realloc_nofail_32173 ntfs_rl_realloc_nofail 3 32173 &do_writepages_32173
106136 +load_header_32183 load_header 0 32183 NULL
106137 +ubi_wl_scrub_peb_32196 ubi_wl_scrub_peb 0 32196 NULL
106138 +wusb_ccm_mac_32199 wusb_ccm_mac 7 32199 NULL
106139 +__mem_cgroup_try_charge_swapin_32204 __mem_cgroup_try_charge_swapin 0 32204 NULL
106140 +riva_get_cmap_len_32218 riva_get_cmap_len 0 32218 NULL
106141 +caif_seqpkt_recvmsg_32241 caif_seqpkt_recvmsg 4 32241 NULL
106142 +lbs_lowrssi_read_32242 lbs_lowrssi_read 3 32242 NULL
106143 +ocfs2_xattr_find_entry_32260 ocfs2_xattr_find_entry 0 32260 NULL
106144 +vmalloc_user_32308 vmalloc_user 1 32308 NULL
106145 +kvm_set_spte_hva_32312 kvm_set_spte_hva 2 32312 NULL
106146 +cas_calc_tabort_32316 cas_calc_tabort 0 32316 NULL
106147 +SyS_select_32319 SyS_select 1 32319 NULL
106148 +nouveau_bar_create__32332 nouveau_bar_create_ 4 32332 NULL
106149 +nl80211_send_mlme_event_32337 nl80211_send_mlme_event 4 32337 NULL
106150 +apic_get_tmcct_32338 apic_get_tmcct 0 32338 NULL
106151 +t4_alloc_mem_32342 t4_alloc_mem 1 32342 NULL
106152 +dispatch_ioctl_32357 dispatch_ioctl 2 32357 NULL nohasharray
106153 +rx_streaming_always_write_32357 rx_streaming_always_write 3 32357 &dispatch_ioctl_32357
106154 +sel_read_initcon_32362 sel_read_initcon 3 32362 NULL nohasharray
106155 +ReadHDLCPCI_32362 ReadHDLCPCI 0 32362 &sel_read_initcon_32362
106156 +__wait_seqno_32370 __wait_seqno 0 32370 NULL
106157 +_drbd_bm_find_next_32372 _drbd_bm_find_next 2 32372 NULL
106158 +cpuset_slab_spread_node_32376 cpuset_slab_spread_node 0 32376 NULL
106159 +intel_iommu_map_32384 intel_iommu_map 4-3 32384 NULL
106160 +local_clock_32385 local_clock 0 32385 NULL
106161 +ocfs2_cancel_convert_32392 ocfs2_cancel_convert 0 32392 NULL
106162 +ll_setxattr_common_32398 ll_setxattr_common 4 32398 NULL
106163 +xfs_iext_add_indirect_multi_32400 xfs_iext_add_indirect_multi 3 32400 NULL
106164 +__add_missing_keys_32402 __add_missing_keys 0 32402 NULL
106165 +vmci_qp_alloc_32405 vmci_qp_alloc 5-3 32405 NULL
106166 +regmap_irq_map_32429 regmap_irq_map 2 32429 NULL
106167 +__ext4_handle_dirty_super_32458 __ext4_handle_dirty_super 0 32458 NULL
106168 +snd_pcm_sync_ptr_32461 snd_pcm_sync_ptr 0 32461 NULL
106169 +cache_status_32462 cache_status 5 32462 NULL
106170 +fill_readbuf_32464 fill_readbuf 3 32464 NULL
106171 +dgap_usertoboard_32490 dgap_usertoboard 4 32490 NULL
106172 +ide_driver_proc_write_32493 ide_driver_proc_write 3 32493 NULL
106173 +bypass_pwoff_write_32499 bypass_pwoff_write 3 32499 NULL
106174 +mdc_pinger_recov_seq_write_32510 mdc_pinger_recov_seq_write 3 32510 NULL
106175 +ctrl_std_val_to_sym_32516 ctrl_std_val_to_sym 5 32516 NULL
106176 +ocfs2_local_alloc_reserve_for_window_32518 ocfs2_local_alloc_reserve_for_window 0 32518 NULL
106177 +disconnect_32521 disconnect 4 32521 NULL
106178 +qsfp_read_32522 qsfp_read 0-2-4 32522 NULL
106179 +audio_get_intf_req_32524 audio_get_intf_req 0 32524 NULL nohasharray
106180 +ocfs2_refresh_qinfo_32524 ocfs2_refresh_qinfo 0 32524 &audio_get_intf_req_32524
106181 +ilo_read_32531 ilo_read 3 32531 NULL
106182 +ieee80211_if_read_estab_plinks_32533 ieee80211_if_read_estab_plinks 3 32533 NULL
106183 +format_devstat_counter_32550 format_devstat_counter 3 32550 NULL
106184 +__first_node_32558 __first_node 0 32558 NULL
106185 +aes_encrypt_fail_read_32562 aes_encrypt_fail_read 3 32562 NULL
106186 +osc_iocontrol_32565 osc_iocontrol 3 32565 NULL
106187 +mem_swapout_entry_32586 mem_swapout_entry 3 32586 NULL
106188 +pipeline_tcp_tx_stat_fifo_int_read_32589 pipeline_tcp_tx_stat_fifo_int_read 3 32589 NULL
106189 +read_file_beacon_32595 read_file_beacon 3 32595 NULL
106190 +ieee80211_if_read_dropped_frames_congestion_32603 ieee80211_if_read_dropped_frames_congestion 3 32603 NULL
106191 +irda_recvmsg_dgram_32631 irda_recvmsg_dgram 4 32631 NULL
106192 +cfg80211_roamed_32632 cfg80211_roamed 5-7 32632 NULL
106193 +ite_decode_bytes_32642 ite_decode_bytes 3 32642 NULL
106194 +kvmalloc_32646 kvmalloc 1 32646 NULL
106195 +ib_sg_dma_len_32649 ib_sg_dma_len 0 32649 NULL
106196 +generic_readlink_32654 generic_readlink 3 32654 NULL nohasharray
106197 +ftrace_startup_32654 ftrace_startup 0 32654 &generic_readlink_32654
106198 +move_addr_to_kernel_32673 move_addr_to_kernel 2 32673 NULL
106199 +apei_res_add_32674 apei_res_add 0 32674 NULL
106200 +jfs_readpages_32702 jfs_readpages 4 32702 NULL
106201 +rt2x00debug_read_queue_dump_32712 rt2x00debug_read_queue_dump 3 32712 NULL
106202 +i40e_pci_sriov_enable_32742 i40e_pci_sriov_enable 2 32742 NULL
106203 +get_arg_page_32746 get_arg_page 2 32746 NULL
106204 +megasas_change_queue_depth_32747 megasas_change_queue_depth 2 32747 NULL
106205 +stats_read_ul_32751 stats_read_ul 3 32751 NULL
106206 +begin_cmd_32766 begin_cmd 0 32766 NULL
106207 +vmci_transport_dgram_dequeue_32775 vmci_transport_dgram_dequeue 4 32775 NULL
106208 +sctp_tsnmap_grow_32784 sctp_tsnmap_grow 2 32784 NULL
106209 +ocfs2_read_inode_block_full_32790 ocfs2_read_inode_block_full 0 32790 NULL
106210 +rproc_name_read_32805 rproc_name_read 3 32805 NULL
106211 +new_tape_buffer_32866 new_tape_buffer 2 32866 NULL
106212 +io_apic_setup_irq_pin_32868 io_apic_setup_irq_pin 1-2 32868 NULL
106213 +ath6kl_usb_submit_ctrl_in_32880 ath6kl_usb_submit_ctrl_in 6 32880 NULL nohasharray
106214 +cifs_writedata_alloc_32880 cifs_writedata_alloc 1 32880 &ath6kl_usb_submit_ctrl_in_32880
106215 +vp702x_usb_inout_cmd_32884 vp702x_usb_inout_cmd 6-4 32884 NULL
106216 +ext4_get_group_number_32899 ext4_get_group_number 0-2 32899 NULL
106217 +il_dbgfs_tx_stats_read_32913 il_dbgfs_tx_stats_read 3 32913 NULL
106218 +zlib_inflate_workspacesize_32927 zlib_inflate_workspacesize 0 32927 NULL
106219 +rmap_recycle_32938 rmap_recycle 3 32938 NULL
106220 +irq_reserve_irqs_32946 irq_reserve_irqs 1-2 32946 NULL
106221 +ext4_valid_block_bitmap_32958 ext4_valid_block_bitmap 3 32958 NULL
106222 +xfs_log_reserve_32959 xfs_log_reserve 2 32959 NULL
106223 +ext4_group_overhead_blocks_32971 ext4_group_overhead_blocks 0 32971 NULL
106224 +arch_ptrace_32981 arch_ptrace 3 32981 NULL
106225 +compat_filldir_32999 compat_filldir 3 32999 NULL
106226 +btrfs_lookup_extent_info_33000 btrfs_lookup_extent_info 0 33000 NULL
106227 +ext3_alloc_blocks_33007 ext3_alloc_blocks 3-0 33007 NULL nohasharray
106228 +SyS_syslog_33007 SyS_syslog 3 33007 &ext3_alloc_blocks_33007
106229 +br_multicast_set_hash_max_33012 br_multicast_set_hash_max 2 33012 NULL
106230 +write_file_bt_ant_diversity_33019 write_file_bt_ant_diversity 3 33019 NULL
106231 +snd_pcm_prepare_33036 snd_pcm_prepare 0 33036 NULL
106232 +SYSC_lgetxattr_33049 SYSC_lgetxattr 4 33049 NULL
106233 +pipeline_dec_packet_in_fifo_full_read_33052 pipeline_dec_packet_in_fifo_full_read 3 33052 NULL
106234 +ebt_compat_match_offset_33053 ebt_compat_match_offset 0-2 33053 NULL
106235 +bitmap_resize_33054 bitmap_resize 2-3 33054 NULL
106236 +intel_ring_flush_all_caches_33059 intel_ring_flush_all_caches 0 33059 NULL
106237 +stats_dot11RTSSuccessCount_read_33065 stats_dot11RTSSuccessCount_read 3 33065 NULL
106238 +sel_read_checkreqprot_33068 sel_read_checkreqprot 3 33068 NULL
106239 +alloc_tio_33077 alloc_tio 3 33077 NULL
106240 +acl_permission_check_33083 acl_permission_check 0 33083 NULL
106241 +write_node_33121 write_node 4 33121 NULL
106242 +fb_sys_write_33130 fb_sys_write 3 33130 NULL
106243 +__len_within_target_33132 __len_within_target 0 33132 NULL
106244 +SyS_poll_33152 SyS_poll 2 33152 NULL
106245 +debug_debug6_read_33168 debug_debug6_read 3 33168 NULL
106246 +dataflash_read_fact_otp_33204 dataflash_read_fact_otp 3-2 33204 NULL
106247 +pp_read_33210 pp_read 3 33210 NULL
106248 +xfs_file_aio_write_33234 xfs_file_aio_write 4 33234 NULL nohasharray
106249 +i915_gem_object_wait_rendering__tail_33234 i915_gem_object_wait_rendering__tail 0 33234 &xfs_file_aio_write_33234
106250 +__vb2_wait_for_done_vb_33246 __vb2_wait_for_done_vb 0 33246 NULL
106251 +snd_pcm_plug_client_size_33267 snd_pcm_plug_client_size 0-2 33267 NULL
106252 +cachefiles_cook_key_33274 cachefiles_cook_key 2 33274 NULL
106253 +sync_pt_create_33282 sync_pt_create 2 33282 NULL
106254 +btrfs_delete_one_dir_name_33303 btrfs_delete_one_dir_name 0 33303 NULL
106255 +mcs7830_get_reg_33308 mcs7830_get_reg 3 33308 NULL
106256 +isku_sysfs_read_keys_easyzone_33318 isku_sysfs_read_keys_easyzone 6 33318 NULL
106257 +vx_send_irq_dsp_33329 vx_send_irq_dsp 0 33329 NULL
106258 +joydev_ioctl_33343 joydev_ioctl 2 33343 NULL
106259 +lov_stripesize_seq_write_33353 lov_stripesize_seq_write 3 33353 NULL
106260 +create_xattr_datum_33356 create_xattr_datum 5 33356 NULL nohasharray
106261 +irq_pkt_threshold_read_33356 irq_pkt_threshold_read 3 33356 &create_xattr_datum_33356
106262 +read_file_regidx_33370 read_file_regidx 3 33370 NULL
106263 +ocfs2_quota_read_33382 ocfs2_quota_read 5 33382 NULL
106264 +ieee80211_if_read_dropped_frames_no_route_33383 ieee80211_if_read_dropped_frames_no_route 3 33383 NULL
106265 +scsi_varlen_cdb_length_33385 scsi_varlen_cdb_length 0 33385 NULL
106266 +tg_get_cfs_period_33390 tg_get_cfs_period 0 33390 NULL
106267 +ocfs2_allocate_unwritten_extents_33394 ocfs2_allocate_unwritten_extents 3-2 33394 NULL
106268 +cfs_trace_copyin_string_33396 cfs_trace_copyin_string 4 33396 NULL
106269 +ext4_meta_bg_first_block_no_33408 ext4_meta_bg_first_block_no 2 33408 NULL nohasharray
106270 +snd_pcm_capture_ioctl1_33408 snd_pcm_capture_ioctl1 0 33408 &ext4_meta_bg_first_block_no_33408
106271 +ufs_getfrag_block_33409 ufs_getfrag_block 2 33409 NULL
106272 +filemap_fdatawrite_33415 filemap_fdatawrite 0 33415 NULL
106273 +dis_tap_write_33426 dis_tap_write 3 33426 NULL
106274 +ubh_scanc_33436 ubh_scanc 0-3-4 33436 NULL
106275 +message_stats_list_33440 message_stats_list 5 33440 NULL
106276 +ovs_vport_alloc_33475 ovs_vport_alloc 1 33475 NULL
106277 +create_entry_33479 create_entry 2 33479 NULL
106278 +ip_setsockopt_33487 ip_setsockopt 5 33487 NULL nohasharray
106279 +elf_map_33487 elf_map 0-2 33487 &ip_setsockopt_33487
106280 +ol_dqblk_chunk_off_33489 ol_dqblk_chunk_off 2 33489 NULL
106281 +res_counter_read_33499 res_counter_read 4 33499 NULL
106282 +fb_read_33506 fb_read 3 33506 NULL
106283 +musb_test_mode_write_33518 musb_test_mode_write 3 33518 NULL
106284 +ahash_setkey_unaligned_33521 ahash_setkey_unaligned 3 33521 NULL
106285 +nes_alloc_fast_reg_page_list_33523 nes_alloc_fast_reg_page_list 2 33523 NULL
106286 +aggr_size_rx_size_read_33526 aggr_size_rx_size_read 3 33526 NULL
106287 +acpi_gsi_to_irq_33533 acpi_gsi_to_irq 1 33533 NULL
106288 +osc_max_rpcs_in_flight_seq_write_33539 osc_max_rpcs_in_flight_seq_write 3 33539 NULL nohasharray
106289 +tomoyo_read_self_33539 tomoyo_read_self 3 33539 &osc_max_rpcs_in_flight_seq_write_33539
106290 +read_symlink_33572 read_symlink 0 33572 NULL
106291 +count_subheaders_33591 count_subheaders 0 33591 NULL
106292 +scsi_execute_33596 scsi_execute 5 33596 NULL
106293 +comedi_buf_write_n_allocated_33604 comedi_buf_write_n_allocated 0 33604 NULL
106294 +xt_compat_target_offset_33608 xt_compat_target_offset 0 33608 NULL
106295 +usb_gstrings_attach_33615 usb_gstrings_attach 3 33615 NULL nohasharray
106296 +il_dbgfs_qos_read_33615 il_dbgfs_qos_read 3 33615 &usb_gstrings_attach_33615
106297 +do_sync_write_33624 do_sync_write 0 33624 NULL
106298 +stride_page_count_33641 stride_page_count 2 33641 NULL
106299 +slab_alloc_node_33663 slab_alloc_node 3 33663 NULL
106300 +irq_blk_threshold_read_33666 irq_blk_threshold_read 3 33666 NULL
106301 +inw_p_33668 inw_p 0 33668 NULL
106302 +arp_hdr_len_33671 arp_hdr_len 0 33671 NULL
106303 +i2c_hid_alloc_buffers_33673 i2c_hid_alloc_buffers 2 33673 NULL
106304 +nv50_disp_dmac_create__33696 nv50_disp_dmac_create_ 6 33696 NULL
106305 +netlink_sendmsg_33708 netlink_sendmsg 4 33708 NULL
106306 +tipc_link_stats_33716 tipc_link_stats 3 33716 NULL
106307 +ext4_wb_update_i_disksize_33717 ext4_wb_update_i_disksize 2 33717 NULL
106308 +pvr2_stream_buffer_count_33719 pvr2_stream_buffer_count 2 33719 NULL
106309 +ocfs2_extent_map_get_blocks_33720 ocfs2_extent_map_get_blocks 2 33720 NULL
106310 +write_file_spectral_count_33723 write_file_spectral_count 3 33723 NULL nohasharray
106311 +ocfs2_lock_allocators_move_extents_33723 ocfs2_lock_allocators_move_extents 0 33723 &write_file_spectral_count_33723
106312 +__mutex_lock_interruptible_slowpath_33735 __mutex_lock_interruptible_slowpath 0 33735 NULL
106313 +do_munmap_33752 do_munmap 0 33752 NULL
106314 +vifs_state_read_33762 vifs_state_read 3 33762 NULL
106315 +hashtab_create_33769 hashtab_create 3 33769 NULL
106316 +btrfs_delayed_refs_qgroup_accounting_33775 btrfs_delayed_refs_qgroup_accounting 0 33775 NULL
106317 +irq_map_generic_chip_33793 irq_map_generic_chip 2 33793 NULL
106318 +if_sdio_read_rx_len_33800 if_sdio_read_rx_len 0 33800 NULL
106319 +find_next_offset_33804 find_next_offset 3-0 33804 NULL
106320 +filter_write_33819 filter_write 3 33819 NULL
106321 +sep_create_msgarea_context_33829 sep_create_msgarea_context 4 33829 NULL
106322 +scrub_setup_recheck_block_33831 scrub_setup_recheck_block 5-4 33831 NULL
106323 +ext4_journal_extend_33835 ext4_journal_extend 2-0 33835 NULL
106324 +snd_pcm_action_nonatomic_33844 snd_pcm_action_nonatomic 0 33844 NULL
106325 +calgary_alloc_coherent_33851 calgary_alloc_coherent 2 33851 NULL
106326 +oz_cdev_write_33852 oz_cdev_write 3 33852 NULL
106327 +bin_string_33884 bin_string 3-5 33884 NULL
106328 +get_user_pages_33908 get_user_pages 0-3-4 33908 NULL
106329 +ath6kl_roam_mode_write_33912 ath6kl_roam_mode_write 3 33912 NULL
106330 +queue_logical_block_size_33918 queue_logical_block_size 0 33918 NULL
106331 +atomic64_add_return_33927 atomic64_add_return 0-1 33927 NULL
106332 +sel_read_avc_cache_threshold_33942 sel_read_avc_cache_threshold 3 33942 NULL
106333 +lpfc_idiag_ctlacc_read_33943 lpfc_idiag_ctlacc_read 3 33943 NULL
106334 +read_file_tgt_rx_stats_33944 read_file_tgt_rx_stats 3 33944 NULL nohasharray
106335 +btrfs_uuid_tree_rem_33944 btrfs_uuid_tree_rem 0 33944 &read_file_tgt_rx_stats_33944
106336 +hfsplus_osx_setxattr_33952 hfsplus_osx_setxattr 4 33952 NULL
106337 +__proc_dump_kernel_33954 __proc_dump_kernel 5 33954 NULL
106338 +ocfs2_create_new_meta_bhs_33955 ocfs2_create_new_meta_bhs 0 33955 NULL
106339 +vga_switcheroo_debugfs_write_33984 vga_switcheroo_debugfs_write 3 33984 NULL
106340 +snd_interval_refine_33987 snd_interval_refine 0 33987 NULL
106341 +__ntfs_malloc_34022 __ntfs_malloc 1 34022 NULL
106342 +lbs_lowrssi_write_34025 lbs_lowrssi_write 3 34025 NULL
106343 +ppp_write_34034 ppp_write 3 34034 NULL
106344 +tty_insert_flip_string_34042 tty_insert_flip_string 3-0 34042 NULL
106345 +__domain_flush_pages_34045 __domain_flush_pages 2-3 34045 NULL
106346 +is_trap_at_addr_34047 is_trap_at_addr 2 34047 NULL
106347 +memcg_update_all_caches_34068 memcg_update_all_caches 1 34068 NULL
106348 +pipeline_pipeline_fifo_full_read_34095 pipeline_pipeline_fifo_full_read 3 34095 NULL
106349 +__irq_domain_add_34101 __irq_domain_add 2 34101 NULL
106350 +i915_gem_object_set_cache_level_34107 i915_gem_object_set_cache_level 0 34107 NULL nohasharray
106351 +proc_scsi_host_write_34107 proc_scsi_host_write 3 34107 &i915_gem_object_set_cache_level_34107
106352 +is_discarded_oblock_34120 is_discarded_oblock 2 34120 NULL
106353 +islpci_mgt_transmit_34133 islpci_mgt_transmit 5 34133 NULL
106354 +ttm_dma_page_pool_free_34135 ttm_dma_page_pool_free 2-0 34135 NULL
106355 +ixgbe_dbg_netdev_ops_write_34141 ixgbe_dbg_netdev_ops_write 3 34141 NULL
106356 +shmem_pread_fast_34147 shmem_pread_fast 3 34147 NULL
106357 +ext4_xattr_list_34162 ext4_xattr_list 3 34162 NULL
106358 +ocfs2_xattr_list_entry_34165 ocfs2_xattr_list_entry 0 34165 NULL
106359 +skb_to_sgvec_34171 skb_to_sgvec 0 34171 NULL
106360 +dtf_write_run_34196 dtf_write_run 3 34196 NULL
106361 +ext4_da_write_begin_34215 ext4_da_write_begin 3-4 34215 NULL
106362 +i915_gem_execbuffer_reserve_object_34224 i915_gem_execbuffer_reserve_object 0 34224 NULL
106363 +setup_nodes_for_search_34248 setup_nodes_for_search 0 34248 NULL
106364 +numa_migrate_prep_34256 numa_migrate_prep 0 34256 NULL
106365 +btrfs_bitmap_cluster_34257 btrfs_bitmap_cluster 4 34257 NULL
106366 +bl_pipe_downcall_34264 bl_pipe_downcall 3 34264 NULL
106367 +ocfs2_dlm_lock_34265 ocfs2_dlm_lock 0 34265 NULL
106368 +pcf857x_to_irq_34273 pcf857x_to_irq 2 34273 NULL
106369 +device_private_init_34279 device_private_init 0 34279 NULL
106370 +get_task_io_context_34316 get_task_io_context 3 34316 NULL
106371 +ext4_get_groups_count_34324 ext4_get_groups_count 0 34324 NULL
106372 +iov_iter_single_seg_count_34326 iov_iter_single_seg_count 0 34326 NULL nohasharray
106373 +pcpu_need_to_extend_34326 pcpu_need_to_extend 0 34326 &iov_iter_single_seg_count_34326
106374 +SYSC_brk_34331 SYSC_brk 1 34331 NULL
106375 +__insert_34349 __insert 2-3 34349 NULL
106376 +sync_page_io_34363 sync_page_io 3 34363 NULL nohasharray
106377 +crypto_ablkcipher_ivsize_34363 crypto_ablkcipher_ivsize 0 34363 &sync_page_io_34363
106378 +rngapi_reset_34366 rngapi_reset 3 34366 NULL
106379 +reiserfs_resize_34377 reiserfs_resize 2 34377 NULL
106380 +ea_read_34378 ea_read 0 34378 NULL
106381 +fuse_send_read_34379 fuse_send_read 4 34379 NULL
106382 +av7110_vbi_write_34384 av7110_vbi_write 3 34384 NULL
106383 +usbvision_v4l2_read_34386 usbvision_v4l2_read 3 34386 NULL
106384 +read_rbu_image_type_34387 read_rbu_image_type 6 34387 NULL
106385 +iwl_calib_set_34400 iwl_calib_set 3 34400 NULL nohasharray
106386 +ivtv_read_pos_34400 ivtv_read_pos 3 34400 &iwl_calib_set_34400
106387 +wd_exp_mode_write_34407 wd_exp_mode_write 3 34407 NULL
106388 +nl80211_send_disassoc_34424 nl80211_send_disassoc 4 34424 NULL
106389 +security_socket_create_34439 security_socket_create 0 34439 NULL
106390 +usbtest_alloc_urb_34446 usbtest_alloc_urb 5-3 34446 NULL
106391 +mwifiex_regrdwr_read_34472 mwifiex_regrdwr_read 3 34472 NULL
106392 +skcipher_sndbuf_34476 skcipher_sndbuf 0 34476 NULL
106393 +i2o_parm_field_get_34477 i2o_parm_field_get 5 34477 NULL
106394 +ocfs2_block_group_clear_bits_34484 ocfs2_block_group_clear_bits 0 34484 NULL
106395 +security_inode_permission_34488 security_inode_permission 0 34488 NULL
106396 +SyS_pwritev_34494 SyS_pwritev 3 34494 NULL nohasharray
106397 +__ffs64_34494 __ffs64 1-0 34494 &SyS_pwritev_34494
106398 +qp_alloc_res_34496 qp_alloc_res 5 34496 NULL
106399 +lu_buf_check_and_alloc_34505 lu_buf_check_and_alloc 2 34505 NULL
106400 +snd_pcm_hw_param_value_34525 snd_pcm_hw_param_value 0 34525 NULL
106401 +ext4_fallocate_34537 ext4_fallocate 4-3 34537 NULL nohasharray
106402 +tracing_stats_read_34537 tracing_stats_read 3 34537 &ext4_fallocate_34537
106403 +hugetlbfs_read_actor_34547 hugetlbfs_read_actor 4-5-2-0 34547 NULL
106404 +dbBackSplit_34561 dbBackSplit 0 34561 NULL
106405 +alloc_ieee80211_rsl_34564 alloc_ieee80211_rsl 1 34564 NULL nohasharray
106406 +self_check_peb_ec_hdr_34564 self_check_peb_ec_hdr 0 34564 &alloc_ieee80211_rsl_34564
106407 +i915_gem_execbuffer_relocate_object_34575 i915_gem_execbuffer_relocate_object 0 34575 NULL
106408 +lov_stripecount_seq_write_34582 lov_stripecount_seq_write 3 34582 NULL
106409 +init_send_hfcd_34586 init_send_hfcd 1 34586 NULL
106410 +inet6_ifla6_size_34591 inet6_ifla6_size 0 34591 NULL
106411 +ceph_msgpool_init_34599 ceph_msgpool_init 4 34599 NULL nohasharray
106412 +cw1200_queue_init_34599 cw1200_queue_init 4 34599 &ceph_msgpool_init_34599
106413 +__add_prelim_ref_34600 __add_prelim_ref 0 34600 NULL
106414 +brcmf_cfg80211_mgmt_tx_34608 brcmf_cfg80211_mgmt_tx 7 34608 NULL
106415 +__jffs2_ref_totlen_34609 __jffs2_ref_totlen 0 34609 NULL nohasharray
106416 +mtd_write_34609 mtd_write 0 34609 &__jffs2_ref_totlen_34609
106417 +apei_get_nvs_resources_34616 apei_get_nvs_resources 0 34616 NULL
106418 +__cfg80211_disconnected_34622 __cfg80211_disconnected 3 34622 NULL
106419 +cnic_alloc_dma_34641 cnic_alloc_dma 3 34641 NULL
106420 +tomoyo_dump_page_34649 tomoyo_dump_page 2 34649 NULL
106421 +kvm_set_spte_hva_34671 kvm_set_spte_hva 2 34671 NULL
106422 +sleep_auth_write_34676 sleep_auth_write 3 34676 NULL
106423 +isr_fiqs_read_34687 isr_fiqs_read 3 34687 NULL
106424 +port_print_34704 port_print 3 34704 NULL
106425 +alloc_irq_and_cfg_at_34706 alloc_irq_and_cfg_at 1-2 34706 NULL
106426 +ext4_listxattr_34712 ext4_listxattr 3 34712 NULL
106427 +ieee80211_if_read_num_sta_ps_34722 ieee80211_if_read_num_sta_ps 3 34722 NULL
106428 +platform_list_read_file_34734 platform_list_read_file 3 34734 NULL
106429 +reg_w_ixbuf_34736 reg_w_ixbuf 4 34736 NULL
106430 +lsm_alloc_plain_34755 lsm_alloc_plain 1 34755 NULL
106431 +device_add_34766 device_add 0 34766 NULL
106432 +qib_cdev_init_34778 qib_cdev_init 1 34778 NULL
106433 +SYSC_keyctl_34800 SYSC_keyctl 4 34800 NULL
106434 +can_nocow_extent_34801 can_nocow_extent 2 34801 NULL
106435 +drbd_get_max_capacity_34804 drbd_get_max_capacity 0 34804 NULL
106436 +ll_setxattr_34806 ll_setxattr 4 34806 NULL
106437 +file_page_index_34820 file_page_index 0-2 34820 NULL
106438 +b43_debugfs_write_34838 b43_debugfs_write 3 34838 NULL
106439 +nl_portid_hash_zalloc_34843 nl_portid_hash_zalloc 1 34843 NULL
106440 +acpi_system_write_wakeup_device_34853 acpi_system_write_wakeup_device 3 34853 NULL
106441 +usb_serial_generic_prepare_write_buffer_34857 usb_serial_generic_prepare_write_buffer 3 34857 NULL
106442 +ieee80211_if_read_txpower_34871 ieee80211_if_read_txpower 3 34871 NULL
106443 +msg_print_text_34889 msg_print_text 0 34889 NULL
106444 +ieee80211_if_write_34894 ieee80211_if_write 3 34894 NULL
106445 +si476x_radio_read_rsq_primary_blob_34916 si476x_radio_read_rsq_primary_blob 3 34916 NULL
106446 +__inode_permission_34925 __inode_permission 0 34925 NULL nohasharray
106447 +btrfs_super_chunk_root_34925 btrfs_super_chunk_root 0 34925 &__inode_permission_34925
106448 +ODM_AllocateMemory_34929 ODM_AllocateMemory 3 34929 NULL
106449 +ceph_aio_write_34930 ceph_aio_write 4 34930 NULL
106450 +sec_flags2str_34933 sec_flags2str 3 34933 NULL
106451 +snd_info_entry_read_34938 snd_info_entry_read 3 34938 NULL
106452 +i2c_transfer_34958 i2c_transfer 0 34958 NULL
106453 +do_add_page_to_bio_34974 do_add_page_to_bio 2-10 34974 NULL
106454 +mq_lookup_34990 mq_lookup 2 34990 NULL
106455 +i915_gem_gtt_prepare_object_34991 i915_gem_gtt_prepare_object 0 34991 NULL
106456 +schedule_erase_34996 schedule_erase 0 34996 NULL
106457 +rx_rx_hdr_overflow_read_35002 rx_rx_hdr_overflow_read 3 35002 NULL
106458 +l2cap_skbuff_fromiovec_35003 l2cap_skbuff_fromiovec 4-3 35003 NULL
106459 +dm_cache_insert_mapping_35005 dm_cache_insert_mapping 2-3 35005 NULL
106460 +sisusb_copy_memory_35016 sisusb_copy_memory 4 35016 NULL
106461 +snd_pcm_hw_params_35020 snd_pcm_hw_params 0 35020 NULL
106462 +process_changed_xattr_35025 process_changed_xattr 0 35025 NULL
106463 +coda_psdev_read_35029 coda_psdev_read 3 35029 NULL
106464 +brcmf_sdio_chip_writenvram_35042 brcmf_sdio_chip_writenvram 4 35042 NULL
106465 +pwr_connection_out_of_sync_read_35061 pwr_connection_out_of_sync_read 3 35061 NULL
106466 +ext4_split_unwritten_extents_35063 ext4_split_unwritten_extents 0 35063 NULL
106467 +store_ifalias_35088 store_ifalias 4 35088 NULL
106468 +__kfifo_uint_must_check_helper_35097 __kfifo_uint_must_check_helper 0-1 35097 NULL
106469 +capi_write_35104 capi_write 3 35104 NULL nohasharray
106470 +tx_tx_done_template_read_35104 tx_tx_done_template_read 3 35104 &capi_write_35104
106471 +ide_settings_proc_write_35110 ide_settings_proc_write 3 35110 NULL
106472 +ceph_osdc_start_request_35122 ceph_osdc_start_request 0 35122 NULL
106473 +message_stats_print_35158 message_stats_print 6 35158 NULL
106474 +iscsi_conn_setup_35159 iscsi_conn_setup 2 35159 NULL
106475 +ieee80211_if_read_bssid_35161 ieee80211_if_read_bssid 3 35161 NULL
106476 +relocate_entry_cpu_35176 relocate_entry_cpu 0 35176 NULL
106477 +solo_v4l2_init_35179 solo_v4l2_init 2 35179 NULL
106478 +SyS_init_module_35180 SyS_init_module 2 35180 NULL
106479 +mlx4_ib_get_cq_umem_35184 mlx4_ib_get_cq_umem 5-6 35184 NULL
106480 +uprobe_get_swbp_addr_35201 uprobe_get_swbp_addr 0 35201 NULL
106481 +unix_stream_recvmsg_35210 unix_stream_recvmsg 4 35210 NULL
106482 +striped_read_35218 striped_read 0-3-2 35218 NULL nohasharray
106483 +security_key_getsecurity_35218 security_key_getsecurity 0 35218 &striped_read_35218
106484 +video_register_device_no_warn_35226 video_register_device_no_warn 3 35226 NULL nohasharray
106485 +rx_rx_cmplt_task_read_35226 rx_rx_cmplt_task_read 3 35226 &video_register_device_no_warn_35226
106486 +gfn_to_page_many_atomic_35234 gfn_to_page_many_atomic 2 35234 NULL nohasharray
106487 +may_commit_transaction_35234 may_commit_transaction 0 35234 &gfn_to_page_many_atomic_35234
106488 +SYSC_madvise_35241 SYSC_madvise 1-2 35241 NULL
106489 +set_fd_set_35249 set_fd_set 1 35249 NULL
106490 +ioapic_setup_resources_35255 ioapic_setup_resources 1 35255 NULL
106491 +alloc_thread_groups_35256 alloc_thread_groups 2 35256 NULL
106492 +jbd2_journal_get_write_access_35263 jbd2_journal_get_write_access 0 35263 NULL
106493 +dis_disc_write_35265 dis_disc_write 3 35265 NULL
106494 +dma_show_regs_35266 dma_show_regs 3 35266 NULL
106495 +irda_recvmsg_stream_35280 irda_recvmsg_stream 4 35280 NULL
106496 +i2o_block_end_request_35282 i2o_block_end_request 3 35282 NULL
106497 +isr_rx_rdys_read_35283 isr_rx_rdys_read 3 35283 NULL
106498 +brcmf_sdio_forensic_read_35311 brcmf_sdio_forensic_read 3 35311 NULL nohasharray
106499 +__btrfs_buffered_write_35311 __btrfs_buffered_write 3 35311 &brcmf_sdio_forensic_read_35311
106500 +tracing_read_pipe_35312 tracing_read_pipe 3 35312 NULL
106501 +fallback_on_nodma_alloc_35332 fallback_on_nodma_alloc 2 35332 NULL
106502 +ieee80211_if_fmt_ap_power_level_35347 ieee80211_if_fmt_ap_power_level 3 35347 NULL
106503 +nouveau_devinit_create__35348 nouveau_devinit_create_ 4 35348 NULL
106504 +ieee80211_rx_mgmt_deauth_35351 ieee80211_rx_mgmt_deauth 3 35351 NULL
106505 +compat_filldir64_35354 compat_filldir64 3 35354 NULL
106506 +amd_iommu_map_35355 amd_iommu_map 4 35355 NULL
106507 +read_kmem_35372 read_kmem 3 35372 NULL
106508 +ocfs2_journal_access_di_35393 ocfs2_journal_access_di 0 35393 NULL
106509 +create_pending_snapshots_35402 create_pending_snapshots 0 35402 NULL
106510 +btrfs_search_old_slot_35406 btrfs_search_old_slot 0 35406 NULL
106511 +SyS_getxattr_35408 SyS_getxattr 4 35408 NULL
106512 +rawv6_send_hdrinc_35425 rawv6_send_hdrinc 3 35425 NULL
106513 +C_SYSC_sendfile_35432 C_SYSC_sendfile 4 35432 NULL
106514 +__set_test_and_free_35436 __set_test_and_free 2 35436 NULL
106515 +buffer_to_user_35439 buffer_to_user 3 35439 NULL
106516 +memcg_memory_allocated_read_35469 memcg_memory_allocated_read 0 35469 NULL
106517 +fiemap_prepare_and_copy_exts_35494 fiemap_prepare_and_copy_exts 5 35494 NULL
106518 +btrfs_prealloc_file_range_trans_35500 btrfs_prealloc_file_range_trans 4-0 35500 NULL
106519 +async_setkey_35521 async_setkey 3 35521 NULL
106520 +inet_mask_len_35527 inet_mask_len 1 35527 NULL
106521 +__filemap_fdatawrite_range_35528 __filemap_fdatawrite_range 0 35528 NULL
106522 +iwl_dbgfs_bt_traffic_read_35534 iwl_dbgfs_bt_traffic_read 3 35534 NULL
106523 +pstore_mkfile_35536 pstore_mkfile 7 35536 NULL
106524 +rxpipe_tx_xfr_host_int_trig_rx_data_read_35538 rxpipe_tx_xfr_host_int_trig_rx_data_read 3 35538 NULL
106525 +ibnl_put_attr_35541 ibnl_put_attr 3 35541 NULL
106526 +ieee80211_if_write_smps_35550 ieee80211_if_write_smps 3 35550 NULL
106527 +send_update_extent_35556 send_update_extent 0 35556 NULL
106528 +vb2_dqbuf_35559 vb2_dqbuf 0 35559 NULL
106529 +sysfs_create_subdir_35567 sysfs_create_subdir 0 35567 NULL
106530 +ext4_blocks_for_truncate_35579 ext4_blocks_for_truncate 0 35579 NULL
106531 +ext2_acl_from_disk_35580 ext2_acl_from_disk 2 35580 NULL
106532 +spk_msg_set_35586 spk_msg_set 3 35586 NULL
106533 +kernel_readv_35617 kernel_readv 3 35617 NULL
106534 +reiserfs_readpages_35629 reiserfs_readpages 4 35629 NULL
106535 +ptlrpcd_steal_rqset_35637 ptlrpcd_steal_rqset 0 35637 NULL
106536 +nv50_vm_create_35643 nv50_vm_create 2-3 35643 NULL
106537 +spi_register_board_info_35651 spi_register_board_info 2 35651 NULL
106538 +rdmaltWithLock_35669 rdmaltWithLock 0 35669 NULL
106539 +ext3_mark_iloc_dirty_35686 ext3_mark_iloc_dirty 0 35686 NULL
106540 +dm_table_create_35687 dm_table_create 3 35687 NULL
106541 +SYSC_pwritev_35690 SYSC_pwritev 3 35690 NULL
106542 +rds_page_copy_user_35691 rds_page_copy_user 4 35691 NULL
106543 +md_super_write_35703 md_super_write 4 35703 NULL
106544 +btrfs_commit_transaction_35725 btrfs_commit_transaction 0 35725 NULL
106545 +rtw_IOL_cmd_tx_pkt_buf_dump_35732 rtw_IOL_cmd_tx_pkt_buf_dump 2 35732 NULL
106546 +ext4_truncate_restart_trans_35750 ext4_truncate_restart_trans 0 35750 NULL
106547 +iwl_dbgfs_disable_ht40_read_35761 iwl_dbgfs_disable_ht40_read 3 35761 NULL
106548 +udf_alloc_i_data_35786 udf_alloc_i_data 2 35786 NULL
106549 +pvr2_hdw_cpufw_get_35824 pvr2_hdw_cpufw_get 0-4-2 35824 NULL
106550 +tx_tx_cmplt_read_35854 tx_tx_cmplt_read 3 35854 NULL
106551 +vx_query_hbuffer_size_35859 vx_query_hbuffer_size 0 35859 NULL
106552 +changed_xattr_35860 changed_xattr 0 35860 NULL
106553 +mthca_buf_alloc_35861 mthca_buf_alloc 2 35861 NULL
106554 +fls64_35862 fls64 0 35862 NULL
106555 +kvm_dirty_bitmap_bytes_35886 kvm_dirty_bitmap_bytes 0 35886 NULL
106556 +ieee80211_if_fmt_dot11MeshRetryTimeout_35890 ieee80211_if_fmt_dot11MeshRetryTimeout 3 35890 NULL
106557 +uwb_rc_cmd_done_35892 uwb_rc_cmd_done 4 35892 NULL
106558 +SyS_set_mempolicy_35909 SyS_set_mempolicy 3 35909 NULL
106559 +kernel_setsockopt_35913 kernel_setsockopt 5 35913 NULL
106560 +rbio_nr_pages_35916 rbio_nr_pages 0-1-2 35916 NULL
106561 +balance_node_right_35920 balance_node_right 0 35920 NULL
106562 +sctp_tsnmap_mark_35929 sctp_tsnmap_mark 2 35929 NULL
106563 +rx_defrag_init_called_read_35935 rx_defrag_init_called_read 3 35935 NULL
106564 +put_cmsg_compat_35937 put_cmsg_compat 4 35937 NULL
106565 +ext_rts51x_sd_execute_write_data_35971 ext_rts51x_sd_execute_write_data 9 35971 NULL
106566 +ceph_buffer_new_35974 ceph_buffer_new 1 35974 NULL nohasharray
106567 +generic_ocp_read_35974 generic_ocp_read 3 35974 &ceph_buffer_new_35974
106568 +acl_alloc_35979 acl_alloc 1 35979 NULL
106569 +device_add_class_symlinks_35985 device_add_class_symlinks 0 35985 NULL
106570 +generic_file_aio_read_35987 generic_file_aio_read 0 35987 NULL
106571 +write_file_antenna_35998 write_file_antenna 3 35998 NULL nohasharray
106572 +kuc_alloc_35998 kuc_alloc 1 35998 &write_file_antenna_35998
106573 +locks_mandatory_area_35999 locks_mandatory_area 0 35999 NULL
106574 +il3945_ucode_tx_stats_read_36016 il3945_ucode_tx_stats_read 3 36016 NULL
106575 +ubi_eba_write_leb_36029 ubi_eba_write_leb 0-6-5 36029 NULL
106576 +__videobuf_alloc_36031 __videobuf_alloc 1 36031 NULL
106577 +account_shadowed_36048 account_shadowed 2 36048 NULL
106578 +gpio_power_read_36059 gpio_power_read 3 36059 NULL
106579 +snd_pcm_playback_hw_avail_36061 snd_pcm_playback_hw_avail 0 36061 NULL
106580 +did_create_dir_36062 did_create_dir 0 36062 NULL
106581 +write_emulate_36065 write_emulate 2-4 36065 NULL
106582 +stack_max_size_write_36068 stack_max_size_write 3 36068 NULL
106583 +radeon_vm_num_pdes_36070 radeon_vm_num_pdes 0 36070 NULL
106584 +ieee80211_if_fmt_peer_36071 ieee80211_if_fmt_peer 3 36071 NULL
106585 +ext3_new_blocks_36073 ext3_new_blocks 3-0 36073 NULL
106586 +ieee80211_if_write_tsf_36077 ieee80211_if_write_tsf 3 36077 NULL
106587 +snd_pcm_plug_read_transfer_36080 snd_pcm_plug_read_transfer 0-3 36080 NULL
106588 +mtip_hw_read_device_status_36082 mtip_hw_read_device_status 3 36082 NULL
106589 +vga_arb_write_36112 vga_arb_write 3 36112 NULL
106590 +simple_xattr_alloc_36118 simple_xattr_alloc 2 36118 NULL
106591 +compat_ptrace_request_36131 compat_ptrace_request 3 36131 NULL
106592 +vmalloc_exec_36132 vmalloc_exec 1 36132 NULL
106593 +max8925_irq_domain_map_36133 max8925_irq_domain_map 2 36133 NULL
106594 +set_flexbg_block_bitmap_36136 set_flexbg_block_bitmap 0-4-5 36136 NULL
106595 +ext3_readpages_36144 ext3_readpages 4 36144 NULL
106596 +twl_set_36154 twl_set 2 36154 NULL
106597 +b1_alloc_card_36155 b1_alloc_card 1 36155 NULL
106598 +btrfs_file_extent_inline_len_36158 btrfs_file_extent_inline_len 0 36158 NULL
106599 +snd_korg1212_copy_from_36169 snd_korg1212_copy_from 6 36169 NULL
106600 +wm8994_edge_irq_map_36170 wm8994_edge_irq_map 2 36170 NULL
106601 +SyS_kexec_load_36176 SyS_kexec_load 2 36176 NULL
106602 +ramoops_init_przs_36199 ramoops_init_przs 4 36199 NULL
106603 +SYSC_sched_getaffinity_36208 SYSC_sched_getaffinity 2 36208 NULL
106604 +SYSC_process_vm_readv_36216 SYSC_process_vm_readv 5-3 36216 NULL
106605 +ubifs_read_nnode_36221 ubifs_read_nnode 0 36221 NULL
106606 +is_dirty_36223 is_dirty 2 36223 NULL
106607 +ept_walk_addr_36226 ept_walk_addr 3 36226 NULL
106608 +atomic_stats_read_36228 atomic_stats_read 3 36228 NULL
106609 +viafb_iga1_odev_proc_write_36241 viafb_iga1_odev_proc_write 3 36241 NULL
106610 +SYSC_getxattr_36242 SYSC_getxattr 4 36242 NULL
106611 +rproc_recovery_read_36245 rproc_recovery_read 3 36245 NULL
106612 +scrub_stripe_36248 scrub_stripe 5-4 36248 NULL
106613 +compat_sys_mbind_36256 compat_sys_mbind 5 36256 NULL
106614 +usb_buffer_alloc_36276 usb_buffer_alloc 2 36276 NULL nohasharray
106615 +cfs_hash_buckets_realloc_36276 cfs_hash_buckets_realloc 4 36276 &usb_buffer_alloc_36276
106616 +codec_reg_read_file_36280 codec_reg_read_file 3 36280 NULL
106617 +crypto_shash_digestsize_36284 crypto_shash_digestsize 0 36284 NULL
106618 +nouveau_cli_create_36293 nouveau_cli_create 3 36293 NULL
106619 +lpfc_debugfs_dif_err_read_36303 lpfc_debugfs_dif_err_read 3 36303 NULL
106620 +cfg80211_rx_mlme_mgmt_36306 cfg80211_rx_mlme_mgmt 3 36306 NULL
106621 +ad7879_spi_xfer_36311 ad7879_spi_xfer 3 36311 NULL
106622 +fuse_get_user_addr_36312 fuse_get_user_addr 0 36312 NULL
106623 +fat_compat_ioctl_filldir_36328 fat_compat_ioctl_filldir 3 36328 NULL
106624 +lc_create_36332 lc_create 4 36332 NULL
106625 +jbd2_journal_init_revoke_table_36336 jbd2_journal_init_revoke_table 1 36336 NULL
106626 +isku_sysfs_read_key_mask_36343 isku_sysfs_read_key_mask 6 36343 NULL
106627 +ath6kl_regwrite_write_36351 ath6kl_regwrite_write 3 36351 NULL
106628 +v9fs_file_readn_36353 v9fs_file_readn 4 36353 NULL nohasharray
106629 +xz_dec_lzma2_create_36353 xz_dec_lzma2_create 2 36353 &v9fs_file_readn_36353
106630 +to_sector_36361 to_sector 0-1 36361 NULL
106631 +irq_domain_disassociate_36367 irq_domain_disassociate 2 36367 NULL
106632 +posix_acl_create_36383 posix_acl_create 0 36383 NULL
106633 +tunables_read_36385 tunables_read 3 36385 NULL
106634 +afs_alloc_flat_call_36399 afs_alloc_flat_call 3-2 36399 NULL
106635 +sierra_write_36402 sierra_write 4 36402 NULL
106636 +msb_update_block_36412 msb_update_block 2 36412 NULL
106637 +SyS_sethostname_36417 SyS_sethostname 2 36417 NULL
106638 +ReadW6692B_36445 ReadW6692B 0 36445 NULL
106639 +sctp_tsnmap_init_36446 sctp_tsnmap_init 2 36446 NULL
106640 +alloc_etherdev_mqs_36450 alloc_etherdev_mqs 1 36450 NULL
106641 +check_extent_in_eb_36467 check_extent_in_eb 0 36467 NULL
106642 +SyS_process_vm_writev_36476 SyS_process_vm_writev 5-3 36476 NULL
106643 +b43_nphy_load_samples_36481 b43_nphy_load_samples 3 36481 NULL
106644 +set_var_mtrr_range_36483 set_var_mtrr_range 2 36483 NULL
106645 +ip6_append_data_36490 ip6_append_data 4 36490 NULL nohasharray
106646 +tx_tx_checksum_result_read_36490 tx_tx_checksum_result_read 3 36490 &ip6_append_data_36490
106647 +cmd_loop_36491 cmd_loop 0 36491 NULL
106648 +__hwahc_op_set_ptk_36510 __hwahc_op_set_ptk 5 36510 NULL
106649 +mcam_v4l_read_36513 mcam_v4l_read 3 36513 NULL
106650 +get_param_l_36518 get_param_l 0 36518 NULL
106651 +ieee80211_if_read_fwded_frames_36520 ieee80211_if_read_fwded_frames 3 36520 NULL
106652 +lguest_setup_irq_36531 lguest_setup_irq 1 36531 NULL
106653 +crypto_aead_authsize_36537 crypto_aead_authsize 0 36537 NULL
106654 +cpu_type_read_36540 cpu_type_read 3 36540 NULL
106655 +__kfifo_to_user_36555 __kfifo_to_user 3-0 36555 NULL nohasharray
106656 +macvtap_do_read_36555 macvtap_do_read 4 36555 &__kfifo_to_user_36555
106657 +btrfs_get_token_64_36572 btrfs_get_token_64 0 36572 NULL
106658 +__erst_read_36579 __erst_read 0 36579 NULL
106659 +put_cmsg_36589 put_cmsg 4 36589 NULL
106660 +do_sendfile_36610 do_sendfile 4-5 36610 NULL
106661 +fat_ioctl_filldir_36621 fat_ioctl_filldir 3 36621 NULL
106662 +i915_gem_execbuffer_relocate_slow_36634 i915_gem_execbuffer_relocate_slow 0 36634 NULL
106663 +vxge_config_vpaths_36636 vxge_config_vpaths 0 36636 NULL
106664 +convert_extent_item_v0_36645 convert_extent_item_v0 4-0 36645 NULL
106665 +ced_ioctl_36647 ced_ioctl 2 36647 NULL
106666 +lpfc_idiag_extacc_alloc_get_36648 lpfc_idiag_extacc_alloc_get 0-3 36648 NULL
106667 +osd_req_list_collection_objects_36664 osd_req_list_collection_objects 5 36664 NULL
106668 +iscsi_host_alloc_36671 iscsi_host_alloc 2 36671 NULL
106669 +xillybus_read_36678 xillybus_read 3 36678 NULL
106670 +tlv_put_btrfs_timespec_36685 tlv_put_btrfs_timespec 0 36685 NULL nohasharray
106671 +ext4_mb_discard_group_preallocations_36685 ext4_mb_discard_group_preallocations 2 36685 &tlv_put_btrfs_timespec_36685
106672 +gsmtty_write_36702 gsmtty_write 3 36702 NULL
106673 +sched_clock_36717 sched_clock 0 36717 NULL
106674 +ocfs2_rotate_tree_right_36723 ocfs2_rotate_tree_right 0 36723 NULL
106675 +snd_rawmidi_kernel_read1_36740 snd_rawmidi_kernel_read1 4-0 36740 NULL
106676 +cxgbi_device_register_36746 cxgbi_device_register 2-1 36746 NULL
106677 +fc_exch_mgr_alloc_36751 fc_exch_mgr_alloc 3-4 36751 NULL
106678 +ps_poll_upsd_timeouts_read_36755 ps_poll_upsd_timeouts_read 3 36755 NULL
106679 +ext4_ext_convert_to_initialized_36765 ext4_ext_convert_to_initialized 0 36765 NULL
106680 +ptp_filter_init_36780 ptp_filter_init 2 36780 NULL
106681 +i40e_init_lan_hmc_36796 i40e_init_lan_hmc 2-3-4-5 36796 NULL
106682 +proc_fault_inject_read_36802 proc_fault_inject_read 3 36802 NULL
106683 +hiddev_ioctl_36816 hiddev_ioctl 2 36816 NULL
106684 +ocfs2_journal_access_rb_36823 ocfs2_journal_access_rb 0 36823 NULL
106685 +int_hardware_entry_36833 int_hardware_entry 3 36833 NULL
106686 +fc_change_queue_depth_36841 fc_change_queue_depth 2 36841 NULL
106687 +keyctl_describe_key_36853 keyctl_describe_key 3 36853 NULL
106688 +cm_write_36858 cm_write 3 36858 NULL
106689 +range_to_mtrr_with_hole_36861 range_to_mtrr_with_hole 2 36861 NULL
106690 +tx_tx_data_programmed_read_36871 tx_tx_data_programmed_read 3 36871 NULL
106691 +svc_setsockopt_36876 svc_setsockopt 5 36876 NULL
106692 +raid56_parity_write_36877 raid56_parity_write 5 36877 NULL
106693 +__btrfs_map_block_36883 __btrfs_map_block 3 36883 NULL
106694 +ib_ucm_alloc_data_36885 ib_ucm_alloc_data 3 36885 NULL
106695 +selinux_inode_notifysecctx_36896 selinux_inode_notifysecctx 3 36896 NULL
106696 +OS_kmalloc_36909 OS_kmalloc 1 36909 NULL
106697 +audio_set_endpoint_req_36918 audio_set_endpoint_req 0 36918 NULL
106698 +build_key_36931 build_key 1 36931 NULL
106699 +crypto_blkcipher_ivsize_36944 crypto_blkcipher_ivsize 0 36944 NULL
106700 +div_u64_36951 div_u64 0 36951 NULL
106701 +write_leb_36957 write_leb 0-5 36957 NULL
106702 +ntfs_external_attr_find_36963 ntfs_external_attr_find 0 36963 NULL
106703 +sparse_early_mem_maps_alloc_node_36971 sparse_early_mem_maps_alloc_node 4 36971 NULL
106704 +il4965_rs_sta_dbgfs_scale_table_write_36979 il4965_rs_sta_dbgfs_scale_table_write 3 36979 NULL
106705 +drbd_new_dev_size_36998 drbd_new_dev_size 0-3 36998 NULL
106706 +auok190xfb_write_37001 auok190xfb_write 3 37001 NULL
106707 +setxattr_37006 setxattr 4 37006 NULL
106708 +btrfs_update_root_37035 btrfs_update_root 0 37035 NULL
106709 +ocfs2_dlm_unlock_37037 ocfs2_dlm_unlock 0 37037 NULL
106710 +command_file_read_37038 command_file_read 3 37038 NULL
106711 +__hfsplus_brec_find_37048 __hfsplus_brec_find 0 37048 NULL
106712 +figure_loop_size_37051 figure_loop_size 2-3 37051 NULL
106713 +qp_broker_create_37053 qp_broker_create 6-5 37053 NULL nohasharray
106714 +ieee80211_if_read_drop_unencrypted_37053 ieee80211_if_read_drop_unencrypted 3 37053 &qp_broker_create_37053
106715 +SYSC_setxattr_37078 SYSC_setxattr 4 37078 NULL
106716 +parse_command_37079 parse_command 2 37079 NULL
106717 +pipeline_cs_rx_packet_in_read_37089 pipeline_cs_rx_packet_in_read 3 37089 NULL
106718 +tun_get_user_37094 tun_get_user 5 37094 NULL
106719 +has_wrprotected_page_37123 has_wrprotected_page 3-2 37123 NULL
106720 +snd_hda_get_conn_list_37132 snd_hda_get_conn_list 0 37132 NULL
106721 +mtt_free_res_37144 mtt_free_res 5 37144 NULL
106722 +msg_word_37164 msg_word 0 37164 NULL
106723 +BeceemNVMRead_37166 BeceemNVMRead 0 37166 NULL
106724 +f2fs_direct_IO_37167 f2fs_direct_IO 4 37167 NULL
106725 +can_set_xattr_37182 can_set_xattr 4 37182 NULL
106726 +btrfs_insert_delayed_items_37191 btrfs_insert_delayed_items 0 37191 NULL
106727 +vcc_recvmsg_37198 vcc_recvmsg 4 37198 NULL
106728 +sysfs_add_file_37200 sysfs_add_file 0 37200 NULL
106729 +mpol_misplaced_37205 mpol_misplaced 0 37205 NULL
106730 +forced_ps_write_37209 forced_ps_write 3 37209 NULL
106731 +crypto_shash_descsize_37212 crypto_shash_descsize 0 37212 NULL nohasharray
106732 +ext4_ind_direct_IO_37212 ext4_ind_direct_IO 0-4 37212 &crypto_shash_descsize_37212
106733 +bchannel_get_rxbuf_37213 bchannel_get_rxbuf 2-0 37213 NULL
106734 +regmap_access_read_file_37223 regmap_access_read_file 3 37223 NULL
106735 +__do_replace_37227 __do_replace 5 37227 NULL
106736 +produce_free_peb_37232 produce_free_peb 0 37232 NULL
106737 +iwl_dbgfs_d3_sram_read_37237 iwl_dbgfs_d3_sram_read 3 37237 NULL
106738 +rx_filter_dup_filter_read_37238 rx_filter_dup_filter_read 3 37238 NULL
106739 +BeceemFlashBulkWrite_37255 BeceemFlashBulkWrite 0 37255 NULL
106740 +prot_queue_del_37258 prot_queue_del 0 37258 NULL
106741 +exofs_max_io_pages_37263 exofs_max_io_pages 0-2 37263 NULL
106742 +__add_keyed_refs_37264 __add_keyed_refs 0 37264 NULL
106743 +nested_svm_map_37268 nested_svm_map 2 37268 NULL
106744 +create_cq_user_37278 create_cq_user 5 37278 NULL
106745 +request_threaded_irq_37303 request_threaded_irq 0 37303 NULL
106746 +ieee80211_if_read_power_mode_37305 ieee80211_if_read_power_mode 3 37305 NULL
106747 +ext3_direct_IO_37308 ext3_direct_IO 4 37308 NULL
106748 +jffs2_write_dirent_37311 jffs2_write_dirent 5 37311 NULL
106749 +send_msg_37323 send_msg 4 37323 NULL
106750 +l2cap_create_connless_pdu_37327 l2cap_create_connless_pdu 3 37327 NULL nohasharray
106751 +bnx2x_vf_fill_fw_str_37327 bnx2x_vf_fill_fw_str 3 37327 &l2cap_create_connless_pdu_37327
106752 +scsi_mode_select_37330 scsi_mode_select 6 37330 NULL
106753 +rxrpc_server_sendmsg_37331 rxrpc_server_sendmsg 4 37331 NULL
106754 +lz4_compressbound_37337 lz4_compressbound 0-1 37337 NULL
106755 +move_vma_37341 move_vma 0-5 37341 NULL
106756 +security_inode_getsecurity_37354 security_inode_getsecurity 0 37354 NULL
106757 +cl_io_submit_rw_37374 cl_io_submit_rw 0 37374 NULL
106758 +iterate_leaf_refs_37385 iterate_leaf_refs 0 37385 NULL
106759 +iommu_num_pages_37391 iommu_num_pages 0-1-3-2 37391 NULL
106760 +btrfs_find_free_objectid_37412 btrfs_find_free_objectid 0 37412 NULL
106761 +hci_sock_sendmsg_37420 hci_sock_sendmsg 4 37420 NULL
106762 +acpi_os_allocate_zeroed_37422 acpi_os_allocate_zeroed 1 37422 NULL nohasharray
106763 +find_next_bit_37422 find_next_bit 0-3-2 37422 &acpi_os_allocate_zeroed_37422
106764 +ocfs2_insert_path_37425 ocfs2_insert_path 0 37425 NULL
106765 +tty_insert_flip_string_fixed_flag_37428 tty_insert_flip_string_fixed_flag 4-0 37428 NULL
106766 +iwl_print_last_event_logs_37433 iwl_print_last_event_logs 0-7-9 37433 NULL
106767 +fru_alloc_37442 fru_alloc 1 37442 NULL
106768 +tcp_established_options_37450 tcp_established_options 0 37450 NULL
106769 +brcmf_sdio_dump_console_37455 brcmf_sdio_dump_console 4 37455 NULL
106770 +__remove_37457 __remove 2 37457 NULL
106771 +ufs_data_ptr_to_cpu_37475 ufs_data_ptr_to_cpu 0 37475 NULL
106772 +get_est_timing_37484 get_est_timing 0 37484 NULL
106773 +kmem_realloc_37489 kmem_realloc 2 37489 NULL
106774 +__hfsplus_setxattr_37499 __hfsplus_setxattr 4 37499 NULL
106775 +bitmap_dirty_bits_37503 bitmap_dirty_bits 2 37503 NULL
106776 +osc_active_seq_write_37514 osc_active_seq_write 3 37514 NULL
106777 +bdev_writeseg_37519 bdev_writeseg 2-3 37519 NULL nohasharray
106778 +vmalloc_32_user_37519 vmalloc_32_user 1 37519 &bdev_writeseg_37519
106779 +xz_dec_test_write_37527 xz_dec_test_write 3 37527 NULL
106780 +fault_inject_read_37534 fault_inject_read 3 37534 NULL
106781 +hdr_size_37536 hdr_size 0 37536 NULL
106782 +extent_map_end_37550 extent_map_end 0 37550 NULL
106783 +sep_create_dcb_dmatables_context_37551 sep_create_dcb_dmatables_context 6 37551 NULL
106784 +ioat_chansts_37558 ioat_chansts 0 37558 NULL
106785 +xhci_alloc_streams_37586 xhci_alloc_streams 5 37586 NULL
106786 +ocfs2_add_branch_37588 ocfs2_add_branch 0 37588 NULL
106787 +alloc_descs_37593 alloc_descs 0-1-3 37593 NULL
106788 +qla2x00_debounce_register_37597 qla2x00_debounce_register 0 37597 NULL
106789 +find_extent_clone_37603 find_extent_clone 0 37603 NULL
106790 +btrfs_write_and_wait_marked_extents_37604 btrfs_write_and_wait_marked_extents 0 37604 NULL
106791 +kvm_read_guest_page_mmu_37611 kvm_read_guest_page_mmu 6-3 37611 NULL
106792 +SYSC_mbind_37622 SYSC_mbind 5 37622 NULL nohasharray
106793 +ocfs2_split_refcount_rec_37622 ocfs2_split_refcount_rec 0 37622 &SYSC_mbind_37622
106794 +btrfs_calc_trans_metadata_size_37629 btrfs_calc_trans_metadata_size 0-2 37629 NULL nohasharray
106795 +policy_residency_37629 policy_residency 0 37629 &btrfs_calc_trans_metadata_size_37629
106796 +alloc_fd_37637 alloc_fd 1 37637 NULL
106797 +SyS_mbind_37638 SyS_mbind 5 37638 NULL
106798 +bio_copy_user_iov_37660 bio_copy_user_iov 4 37660 NULL
106799 +rfcomm_sock_sendmsg_37661 rfcomm_sock_sendmsg 4 37661 NULL nohasharray
106800 +vmw_framebuffer_dmabuf_dirty_37661 vmw_framebuffer_dmabuf_dirty 6 37661 &rfcomm_sock_sendmsg_37661
106801 +SYSC_get_mempolicy_37664 SYSC_get_mempolicy 4-3 37664 NULL
106802 +lnw_gpio_to_irq_37665 lnw_gpio_to_irq 2 37665 NULL
106803 +ieee80211_if_read_rc_rateidx_mcs_mask_2ghz_37675 ieee80211_if_read_rc_rateidx_mcs_mask_2ghz 3 37675 NULL
106804 +regmap_map_read_file_37685 regmap_map_read_file 3 37685 NULL
106805 +page_chain_free_37697 page_chain_free 0 37697 NULL
106806 +nametbl_header_37698 nametbl_header 2-0 37698 NULL
106807 +__le32_to_cpup_37702 __le32_to_cpup 0 37702 NULL
106808 +dynamic_ps_timeout_write_37713 dynamic_ps_timeout_write 3 37713 NULL
106809 +dm_thin_remove_block_37724 dm_thin_remove_block 2 37724 NULL
106810 +find_active_uprobe_37733 find_active_uprobe 1 37733 NULL
106811 +read_enabled_file_bool_37744 read_enabled_file_bool 3 37744 NULL
106812 +ocfs2_duplicate_clusters_by_jbd_37749 ocfs2_duplicate_clusters_by_jbd 5-4-6 37749 NULL
106813 +ocfs2_control_cfu_37750 ocfs2_control_cfu 2 37750 NULL
106814 +ipath_cdev_init_37752 ipath_cdev_init 1 37752 NULL
106815 +dccp_setsockopt_cscov_37766 dccp_setsockopt_cscov 2 37766 NULL
106816 +il4965_rs_sta_dbgfs_rate_scale_data_read_37792 il4965_rs_sta_dbgfs_rate_scale_data_read 3 37792 NULL
106817 +smk_read_logging_37804 smk_read_logging 3 37804 NULL
106818 +deny_write_access_37813 deny_write_access 0 37813 NULL
106819 +ocrdma_alloc_frmr_page_list_37815 ocrdma_alloc_frmr_page_list 2 37815 NULL
106820 +rx_decrypt_key_not_found_read_37820 rx_decrypt_key_not_found_read 3 37820 NULL
106821 +bitmap_find_next_zero_area_37827 bitmap_find_next_zero_area 2-3-0-5-4 37827 NULL
106822 +android_get_p2p_addr_37832 android_get_p2p_addr 0 37832 NULL
106823 +jbd2_journal_get_undo_access_37837 jbd2_journal_get_undo_access 0 37837 NULL
106824 +o2hb_debug_read_37851 o2hb_debug_read 3 37851 NULL
106825 +SYSC_pwrite64_37862 SYSC_pwrite64 3 37862 NULL
106826 +xfs_dir2_block_to_sf_37868 xfs_dir2_block_to_sf 3 37868 NULL
106827 +set_registers_37883 set_registers 4 37883 NULL
106828 +btrfs_stack_file_extent_disk_bytenr_37888 btrfs_stack_file_extent_disk_bytenr 0 37888 NULL
106829 +max77686_irq_domain_map_37897 max77686_irq_domain_map 2 37897 NULL
106830 +tipc_link_send_sections_fast_37920 tipc_link_send_sections_fast 4 37920 NULL
106831 +_rtw_malloc_37928 _rtw_malloc 1 37928 NULL nohasharray
106832 +pkt_alloc_packet_data_37928 pkt_alloc_packet_data 1 37928 &_rtw_malloc_37928
106833 +read_rbu_packet_size_37939 read_rbu_packet_size 6 37939 NULL
106834 +write_file_bool_37957 write_file_bool 3 37957 NULL
106835 +fifo_alloc_37961 fifo_alloc 1 37961 NULL
106836 +ext3_free_blocks_sb_37967 ext3_free_blocks_sb 4-3 37967 NULL
106837 +rds_rdma_extra_size_37990 rds_rdma_extra_size 0 37990 NULL
106838 +persistent_ram_old_size_37997 persistent_ram_old_size 0 37997 NULL
106839 +vfs_readv_38011 vfs_readv 3 38011 NULL
106840 +aggr_recv_addba_req_evt_38037 aggr_recv_addba_req_evt 4 38037 NULL
106841 +SyS_pwrite64_38041 SyS_pwrite64 3 38041 NULL
106842 +klsi_105_prepare_write_buffer_38044 klsi_105_prepare_write_buffer 3 38044 NULL nohasharray
106843 +il_dbgfs_chain_noise_read_38044 il_dbgfs_chain_noise_read 3 38044 &klsi_105_prepare_write_buffer_38044
106844 +SyS_llistxattr_38048 SyS_llistxattr 3 38048 NULL
106845 +sysfs_do_create_link_38051 sysfs_do_create_link 0 38051 NULL
106846 +_xfs_buf_alloc_38058 _xfs_buf_alloc 3 38058 NULL nohasharray
106847 +is_discarded_38058 is_discarded 2 38058 &_xfs_buf_alloc_38058
106848 +nsm_create_handle_38060 nsm_create_handle 4 38060 NULL
106849 +alloc_ltalkdev_38071 alloc_ltalkdev 1 38071 NULL
106850 +xfs_buf_readahead_map_38081 xfs_buf_readahead_map 3 38081 NULL
106851 +uwb_mac_addr_print_38085 uwb_mac_addr_print 2 38085 NULL
106852 +request_key_auth_new_38092 request_key_auth_new 3 38092 NULL
106853 +proc_self_readlink_38094 proc_self_readlink 3 38094 NULL
106854 +ep0_read_38095 ep0_read 3 38095 NULL
106855 +sk_wmem_schedule_38096 sk_wmem_schedule 2 38096 NULL nohasharray
106856 +osc_checksum_seq_write_38096 osc_checksum_seq_write 3 38096 &sk_wmem_schedule_38096
106857 +o2hb_read_slots_38105 o2hb_read_slots 2 38105 NULL
106858 +snd_pcm_oss_write_38108 snd_pcm_oss_write 3 38108 NULL
106859 +_get_val_38115 _get_val 2 38115 NULL
106860 +vmw_kms_present_38130 vmw_kms_present 9 38130 NULL
106861 +__ntfs_copy_from_user_iovec_inatomic_38153 __ntfs_copy_from_user_iovec_inatomic 0-4-3 38153 NULL
106862 +kvm_clear_guest_38164 kvm_clear_guest 3-2 38164 NULL
106863 +cirrus_ttm_tt_create_38167 cirrus_ttm_tt_create 2 38167 NULL
106864 +send_rename_38170 send_rename 0 38170 NULL
106865 +cdev_add_38176 cdev_add 2-3 38176 NULL
106866 +create_srq_user_38191 create_srq_user 5 38191 NULL
106867 +rt2x00debug_write_rf_38195 rt2x00debug_write_rf 3 38195 NULL
106868 +do_chunk_alloc_38200 do_chunk_alloc 0 38200 NULL
106869 +get_ucode_user_38202 get_ucode_user 3 38202 NULL
106870 +ext3_new_block_38208 ext3_new_block 3-0 38208 NULL
106871 +stmpe_gpio_irq_map_38222 stmpe_gpio_irq_map 3 38222 NULL
106872 +osd_req_list_partition_collections_38223 osd_req_list_partition_collections 5 38223 NULL
106873 +palmas_gpio_to_irq_38235 palmas_gpio_to_irq 2 38235 NULL
106874 +ceph_decode_16_38239 ceph_decode_16 0 38239 NULL
106875 +_ipw_read_reg32_38245 _ipw_read_reg32 0 38245 NULL
106876 +snd_pcm_playback_rewind_38249 snd_pcm_playback_rewind 0-2 38249 NULL
106877 +from_dblock_38256 from_dblock 0-1 38256 NULL
106878 +vmci_qp_broker_set_page_store_38260 vmci_qp_broker_set_page_store 3-2 38260 NULL
106879 +SYSC_msgrcv_38268 SYSC_msgrcv 3 38268 NULL nohasharray
106880 +ieee80211_if_read_auto_open_plinks_38268 ieee80211_if_read_auto_open_plinks 3 38268 &SYSC_msgrcv_38268 nohasharray
106881 +mthca_alloc_icm_table_38268 mthca_alloc_icm_table 4-3 38268 &ieee80211_if_read_auto_open_plinks_38268
106882 +xfs_bmdr_to_bmbt_38275 xfs_bmdr_to_bmbt 5 38275 NULL nohasharray
106883 +xfs_bmbt_to_bmdr_38275 xfs_bmbt_to_bmdr 3 38275 &xfs_bmdr_to_bmbt_38275
106884 +ftdi_process_packet_38281 ftdi_process_packet 4 38281 NULL
106885 +gpa_to_gfn_38291 gpa_to_gfn 0-1 38291 NULL
106886 +ucma_query_path_38305 ucma_query_path 3 38305 NULL
106887 +isr_rx_headers_read_38325 isr_rx_headers_read 3 38325 NULL
106888 +ida_simple_get_38326 ida_simple_get 2-0 38326 NULL
106889 +ocfs2_rotate_rightmost_leaf_left_38330 ocfs2_rotate_rightmost_leaf_left 0 38330 NULL
106890 +__snd_gf1_look8_38333 __snd_gf1_look8 0 38333 NULL
106891 +ocfs2_replace_extent_rec_38357 ocfs2_replace_extent_rec 0 38357 NULL
106892 +btrfs_file_extent_disk_num_bytes_38363 btrfs_file_extent_disk_num_bytes 0 38363 NULL
106893 +dn_sendmsg_38390 dn_sendmsg 4 38390 NULL
106894 +get_valid_node_allowed_38412 get_valid_node_allowed 1-0 38412 NULL
106895 +ocfs2_which_cluster_group_38413 ocfs2_which_cluster_group 0-2 38413 NULL
106896 +ht_destroy_irq_38418 ht_destroy_irq 1 38418 NULL
106897 +ieee80211_if_read_dtim_count_38419 ieee80211_if_read_dtim_count 3 38419 NULL
106898 +pmcraid_copy_sglist_38431 pmcraid_copy_sglist 3 38431 NULL
106899 +kvm_write_guest_38454 kvm_write_guest 4-2 38454 NULL
106900 +btrfs_next_old_leaf_38465 btrfs_next_old_leaf 0 38465 NULL
106901 +kvm_arch_setup_async_pf_38481 kvm_arch_setup_async_pf 3 38481 NULL
106902 +blk_end_bidi_request_38482 blk_end_bidi_request 4-3 38482 NULL
106903 +cpu_to_mem_38501 cpu_to_mem 0 38501 NULL
106904 +dev_names_read_38509 dev_names_read 3 38509 NULL
106905 +iscsi_create_iface_38510 iscsi_create_iface 5 38510 NULL
106906 +event_rx_mismatch_read_38518 event_rx_mismatch_read 3 38518 NULL
106907 +mlx4_ib_db_map_user_38529 mlx4_ib_db_map_user 2 38529 NULL
106908 +ubifs_idx_node_sz_38546 ubifs_idx_node_sz 0-2 38546 NULL
106909 +btrfs_discard_extent_38547 btrfs_discard_extent 2 38547 NULL
106910 +kuc_len_38557 kuc_len 0-1 38557 NULL
106911 +cpu_to_node_38561 cpu_to_node 0 38561 NULL
106912 +irda_sendmsg_dgram_38563 irda_sendmsg_dgram 4 38563 NULL
106913 +il4965_rs_sta_dbgfs_scale_table_read_38564 il4965_rs_sta_dbgfs_scale_table_read 3 38564 NULL
106914 +_ipw_read32_38565 _ipw_read32 0 38565 NULL
106915 +snd_nm256_playback_copy_38567 snd_nm256_playback_copy 5-3 38567 NULL
106916 +copy_ctl_value_to_user_38587 copy_ctl_value_to_user 4 38587 NULL
106917 +compat_sys_ptrace_38595 compat_sys_ptrace 3 38595 NULL
106918 +blkg_stat_read_38612 blkg_stat_read 0 38612 NULL
106919 +icn_writecmd_38629 icn_writecmd 2 38629 NULL
106920 +write_enabled_file_bool_38630 write_enabled_file_bool 3 38630 NULL
106921 +ext2_readpages_38640 ext2_readpages 4 38640 NULL
106922 +cma_create_area_38642 cma_create_area 2 38642 NULL
106923 +audit_init_entry_38644 audit_init_entry 1 38644 NULL
106924 +qp_broker_alloc_38646 qp_broker_alloc 6-5 38646 NULL
106925 +mmc_send_cxd_data_38655 mmc_send_cxd_data 5 38655 NULL
106926 +nouveau_instmem_create__38664 nouveau_instmem_create_ 4 38664 NULL
106927 +snd_es1371_wait_src_ready_38673 snd_es1371_wait_src_ready 0 38673 NULL
106928 +iscsit_dump_data_payload_38683 iscsit_dump_data_payload 2 38683 NULL
106929 +ext4_wait_block_bitmap_38695 ext4_wait_block_bitmap 2 38695 NULL
106930 +validate_vid_hdr_38699 validate_vid_hdr 0 38699 NULL
106931 +rbio_add_io_page_38700 rbio_add_io_page 6 38700 NULL
106932 +find_next_usable_block_38716 find_next_usable_block 3-1-0 38716 NULL
106933 +alloc_trace_probe_38720 alloc_trace_probe 6 38720 NULL
106934 +w83977af_sir_interrupt_38738 w83977af_sir_interrupt 0 38738 NULL
106935 +udf_readpages_38761 udf_readpages 4 38761 NULL
106936 +iwl_dbgfs_thermal_throttling_read_38779 iwl_dbgfs_thermal_throttling_read 3 38779 NULL
106937 +bcache_device_init_38781 bcache_device_init 3 38781 NULL
106938 +snd_gus_dram_write_38784 snd_gus_dram_write 4 38784 NULL
106939 +slab_order_38794 slab_order 0 38794 NULL
106940 +do_pci_enable_device_38802 do_pci_enable_device 0 38802 NULL
106941 +err_decode_38804 err_decode 2 38804 NULL
106942 +btrfs_find_space_cluster_38812 btrfs_find_space_cluster 4-0 38812 NULL
106943 +ipv6_renew_option_38813 ipv6_renew_option 3 38813 NULL
106944 +direct_entry_38836 direct_entry 3 38836 NULL
106945 +compat_udp_setsockopt_38840 compat_udp_setsockopt 5 38840 NULL
106946 +read_nic_io_word_38853 read_nic_io_word 0 38853 NULL
106947 +interfaces_38859 interfaces 2 38859 NULL
106948 +pci_msix_table_size_38867 pci_msix_table_size 0 38867 NULL
106949 +dbgfs_state_38894 dbgfs_state 3 38894 NULL
106950 +f2fs_xattr_set_acl_38895 f2fs_xattr_set_acl 4 38895 NULL
106951 +traverse_38897 traverse 0 38897 NULL
106952 +__fswab16_38898 __fswab16 0 38898 NULL
106953 +ext3_trim_all_free_38929 ext3_trim_all_free 4-3-2 38929 NULL
106954 +il_dbgfs_sram_write_38942 il_dbgfs_sram_write 3 38942 NULL
106955 +__ath6kl_wmi_send_mgmt_cmd_38971 __ath6kl_wmi_send_mgmt_cmd 7 38971 NULL
106956 +C_SYSC_preadv64_38977 C_SYSC_preadv64 3 38977 NULL nohasharray
106957 +usb_maxpacket_38977 usb_maxpacket 0 38977 &C_SYSC_preadv64_38977
106958 +OSDSetBlock_38986 OSDSetBlock 2-4 38986 NULL
106959 +lpfc_idiag_extacc_write_38998 lpfc_idiag_extacc_write 3 38998 NULL
106960 +udf_new_block_38999 udf_new_block 4 38999 NULL
106961 +get_nodes_39012 get_nodes 3 39012 NULL
106962 +twl6030_interrupt_unmask_39013 twl6030_interrupt_unmask 2 39013 NULL
106963 +__blkdev_issue_zeroout_39020 __blkdev_issue_zeroout 3-0 39020 NULL
106964 +qgroup_account_ref_step1_39024 qgroup_account_ref_step1 0 39024 NULL
106965 +acpi_install_gpe_block_39031 acpi_install_gpe_block 4 39031 NULL
106966 +_zd_iowrite32v_async_locked_39034 _zd_iowrite32v_async_locked 3 39034 NULL
106967 +do_write_kmem_39051 do_write_kmem 1-3-0 39051 NULL
106968 +gen_pool_create_39064 gen_pool_create 2 39064 NULL
106969 +ext4_init_block_bitmap_39071 ext4_init_block_bitmap 3 39071 NULL
106970 +atomic64_add_negative_39098 atomic64_add_negative 1 39098 NULL
106971 +ReadHFC_39104 ReadHFC 0 39104 NULL
106972 +tomoyo_truncate_39105 tomoyo_truncate 0 39105 NULL
106973 +leb_write_lock_39111 leb_write_lock 0 39111 NULL
106974 +__kfifo_to_user_r_39123 __kfifo_to_user_r 5-3 39123 NULL
106975 +ttm_mem_global_alloc_zone_39125 ttm_mem_global_alloc_zone 0 39125 NULL
106976 +ea_foreach_39133 ea_foreach 0 39133 NULL
106977 +generic_permission_39150 generic_permission 0 39150 NULL
106978 +proc_coredump_filter_read_39153 proc_coredump_filter_read 3 39153 NULL
106979 +echo_client_kbrw_39170 echo_client_kbrw 6 39170 NULL
106980 +btrfs_start_delalloc_flush_39173 btrfs_start_delalloc_flush 0 39173 NULL
106981 +ext3_xattr_check_names_39174 ext3_xattr_check_names 0 39174 NULL
106982 +ubi_more_update_data_39189 ubi_more_update_data 4-0 39189 NULL
106983 +qcam_read_bytes_39205 qcam_read_bytes 0 39205 NULL
106984 +ivtv_v4l2_write_39226 ivtv_v4l2_write 3 39226 NULL
106985 +posix_acl_to_xattr_39237 posix_acl_to_xattr 0 39237 NULL
106986 +drm_order_39244 drm_order 0 39244 NULL
106987 +snd_pcm_capture_forward_39248 snd_pcm_capture_forward 0-2 39248 NULL
106988 +r128_compat_ioctl_39250 r128_compat_ioctl 2 39250 NULL nohasharray
106989 +pwr_cont_miss_bcns_spread_read_39250 pwr_cont_miss_bcns_spread_read 3 39250 &r128_compat_ioctl_39250
106990 +i915_error_state_read_39254 i915_error_state_read 3 39254 NULL
106991 +bitmap_set_bits_39272 bitmap_set_bits 3 39272 NULL
106992 +rx_filter_protection_filter_read_39282 rx_filter_protection_filter_read 3 39282 NULL
106993 +__vmalloc_node_39308 __vmalloc_node 1-5 39308 NULL
106994 +__cfg80211_connect_result_39326 __cfg80211_connect_result 4-6 39326 NULL
106995 +insert_reserved_file_extent_39327 insert_reserved_file_extent 3-0 39327 NULL
106996 +wimax_msg_alloc_39343 wimax_msg_alloc 4 39343 NULL
106997 +__copy_from_user_nocache_39351 __copy_from_user_nocache 3-0 39351 NULL
106998 +ide_complete_rq_39354 ide_complete_rq 3 39354 NULL
106999 +do_write_log_from_user_39362 do_write_log_from_user 3-0 39362 NULL
107000 +vortex_wtdma_getlinearpos_39371 vortex_wtdma_getlinearpos 0 39371 NULL
107001 +regmap_name_read_file_39379 regmap_name_read_file 3 39379 NULL
107002 +fnic_trace_debugfs_read_39380 fnic_trace_debugfs_read 3 39380 NULL
107003 +ps_poll_ps_poll_utilization_read_39383 ps_poll_ps_poll_utilization_read 3 39383 NULL
107004 +__send_to_port_39386 __send_to_port 3 39386 NULL
107005 +perf_trace_buf_submit_39413 perf_trace_buf_submit 5 39413 NULL
107006 +user_power_read_39414 user_power_read 3 39414 NULL
107007 +alloc_agpphysmem_i8xx_39427 alloc_agpphysmem_i8xx 1 39427 NULL
107008 +__vb2_get_done_vb_39448 __vb2_get_done_vb 0 39448 NULL
107009 +apei_resources_add_39470 apei_resources_add 0 39470 NULL
107010 +setkey_unaligned_39474 setkey_unaligned 3 39474 NULL
107011 +do_get_mempolicy_39485 do_get_mempolicy 3 39485 NULL
107012 +ieee80211_if_fmt_dot11MeshHWMPmaxPREQretries_39499 ieee80211_if_fmt_dot11MeshHWMPmaxPREQretries 3 39499 NULL
107013 +cl_req_alloc_39523 cl_req_alloc 4 39523 NULL
107014 +int_proc_write_39542 int_proc_write 3 39542 NULL
107015 +pp_write_39554 pp_write 3 39554 NULL
107016 +ol_dqblk_block_39558 ol_dqblk_block 2-0-3 39558 NULL
107017 +datablob_format_39571 datablob_format 2 39571 NULL nohasharray
107018 +ieee80211_if_read_fwded_mcast_39571 ieee80211_if_read_fwded_mcast 3 39571 &datablob_format_39571
107019 +ext_depth_39607 ext_depth 0 39607 NULL
107020 +nfs_idmap_get_key_39616 nfs_idmap_get_key 2 39616 NULL
107021 +sdio_readb_39618 sdio_readb 0 39618 NULL
107022 +set_dev_class_39645 set_dev_class 4 39645 NULL nohasharray
107023 +dm_exception_table_init_39645 dm_exception_table_init 2 39645 &set_dev_class_39645
107024 +snd_rme32_capture_copy_39653 snd_rme32_capture_copy 5 39653 NULL
107025 +tcp_try_rmem_schedule_39657 tcp_try_rmem_schedule 3 39657 NULL
107026 +kvm_read_guest_cached_39666 kvm_read_guest_cached 4 39666 NULL
107027 +v4l_stk_read_39672 v4l_stk_read 3 39672 NULL
107028 +hsc_msg_len_get_39673 hsc_msg_len_get 0 39673 NULL
107029 +do_surface_dirty_sou_39678 do_surface_dirty_sou 7 39678 NULL
107030 +vmx_set_cr3_39688 vmx_set_cr3 2 39688 NULL
107031 +sd_completed_bytes_39705 sd_completed_bytes 0 39705 NULL
107032 +ftrace_pid_write_39710 ftrace_pid_write 3 39710 NULL
107033 +test_add_free_space_entry_39754 test_add_free_space_entry 2-3 39754 NULL
107034 +adt7316_spi_multi_read_39765 adt7316_spi_multi_read 3 39765 NULL
107035 +remap_to_origin_clear_discard_39767 remap_to_origin_clear_discard 3 39767 NULL
107036 +crypto_ablkcipher_blocksize_39811 crypto_ablkcipher_blocksize 0 39811 NULL
107037 +security_inode_listsecurity_39812 security_inode_listsecurity 0 39812 NULL
107038 +snd_pcm_oss_writev3_39818 snd_pcm_oss_writev3 3 39818 NULL
107039 +get_priv_size_39828 get_priv_size 0-1 39828 NULL
107040 +can_rmdir_39890 can_rmdir 0 39890 NULL
107041 +pkt_add_39897 pkt_add 3 39897 NULL
107042 +read_file_modal_eeprom_39909 read_file_modal_eeprom 3 39909 NULL
107043 +gen_pool_add_virt_39913 gen_pool_add_virt 4-5 39913 NULL
107044 +dw210x_op_rw_39915 dw210x_op_rw 6 39915 NULL
107045 +dma_to_mm_pfn_39916 dma_to_mm_pfn 0-1 39916 NULL
107046 +aes_encrypt_interrupt_read_39919 aes_encrypt_interrupt_read 3 39919 NULL
107047 +exofs_read_kern_39921 exofs_read_kern 6 39921 NULL nohasharray
107048 +oom_score_adj_read_39921 oom_score_adj_read 3 39921 &exofs_read_kern_39921
107049 +__spi_async_39932 __spi_async 0 39932 NULL
107050 +__get_order_39935 __get_order 0 39935 NULL
107051 +error_error_frame_read_39947 error_error_frame_read 3 39947 NULL
107052 +tty_prepare_flip_string_39955 tty_prepare_flip_string 3-0 39955 NULL
107053 +lstcon_group_list_39958 lstcon_group_list 2 39958 NULL
107054 +dma_push_rx_39973 dma_push_rx 2 39973 NULL
107055 +broadsheetfb_write_39976 broadsheetfb_write 3 39976 NULL
107056 +mthca_array_init_39987 mthca_array_init 2 39987 NULL
107057 +fw_device_op_read_39990 fw_device_op_read 3 39990 NULL
107058 +server_name2svname_39998 server_name2svname 4 39998 NULL
107059 +xen_hvm_config_40018 xen_hvm_config 2 40018 NULL
107060 +ivtvfb_write_40023 ivtvfb_write 3 40023 NULL
107061 +disc_pwup_write_40027 disc_pwup_write 3 40027 NULL
107062 +ea_foreach_i_40028 ea_foreach_i 0 40028 NULL
107063 +datablob_hmac_append_40038 datablob_hmac_append 3 40038 NULL
107064 +regmap_add_irq_chip_40042 regmap_add_irq_chip 4 40042 NULL
107065 +ocfs2_claim_clusters_40050 ocfs2_claim_clusters 0 40050 NULL
107066 +add_tty_40055 add_tty 1 40055 NULL nohasharray
107067 +l2cap_create_iframe_pdu_40055 l2cap_create_iframe_pdu 3 40055 &add_tty_40055
107068 +atomic_xchg_40070 atomic_xchg 0 40070 NULL
107069 +snd_pcm_sw_params_user_40095 snd_pcm_sw_params_user 0 40095 NULL
107070 +gen_pool_first_fit_40110 gen_pool_first_fit 2-3-4 40110 NULL
107071 +sctp_setsockopt_delayed_ack_40129 sctp_setsockopt_delayed_ack 3 40129 NULL
107072 +dwc2_max_desc_num_40132 dwc2_max_desc_num 0 40132 NULL
107073 +rx_rx_frame_checksum_read_40140 rx_rx_frame_checksum_read 3 40140 NULL
107074 +ath10k_write_simulate_fw_crash_40143 ath10k_write_simulate_fw_crash 3 40143 NULL
107075 +iwch_alloc_fastreg_pbl_40153 iwch_alloc_fastreg_pbl 2 40153 NULL
107076 +clone_backref_node_40154 clone_backref_node 0 40154 NULL
107077 +pt_write_40159 pt_write 3 40159 NULL
107078 +scsi_sg_count_40182 scsi_sg_count 0 40182 NULL
107079 +ipr_alloc_ucode_buffer_40199 ipr_alloc_ucode_buffer 1 40199 NULL nohasharray
107080 +devnode_find_40199 devnode_find 3-2 40199 &ipr_alloc_ucode_buffer_40199
107081 +allocate_probes_40204 allocate_probes 1 40204 NULL
107082 +acpi_system_write_alarm_40205 acpi_system_write_alarm 3 40205 NULL
107083 +au0828_v4l2_read_40220 au0828_v4l2_read 3 40220 NULL
107084 +compress_file_range_40225 compress_file_range 3-4 40225 NULL
107085 +osst_read_40237 osst_read 3 40237 NULL
107086 +lpage_info_slot_40243 lpage_info_slot 3-1 40243 NULL
107087 +ocfs2_zero_extend_get_range_40248 ocfs2_zero_extend_get_range 4-3 40248 NULL
107088 +rs_sta_dbgfs_scale_table_read_40262 rs_sta_dbgfs_scale_table_read 3 40262 NULL
107089 +ext2_fiemap_40271 ext2_fiemap 4 40271 NULL
107090 +usbnet_read_cmd_40275 usbnet_read_cmd 7 40275 NULL
107091 +rx_xfr_hint_trig_read_40283 rx_xfr_hint_trig_read 3 40283 NULL
107092 +vfio_unmap_unpin_40284 vfio_unmap_unpin 3 40284 NULL
107093 +_calc_trunk_info_40291 _calc_trunk_info 2 40291 NULL
107094 +SyS_bind_40303 SyS_bind 3 40303 NULL
107095 +ubi_io_write_data_40305 ubi_io_write_data 0-5-4 40305 NULL
107096 +batadv_tt_changes_fill_buff_40323 batadv_tt_changes_fill_buff 4 40323 NULL
107097 +ib_get_mad_data_offset_40336 ib_get_mad_data_offset 0 40336 NULL
107098 +mmio_read_40348 mmio_read 4 40348 NULL
107099 +ocfs2_release_clusters_40355 ocfs2_release_clusters 4-0 40355 NULL
107100 +event_rx_mem_empty_read_40363 event_rx_mem_empty_read 3 40363 NULL
107101 +ocfs2_check_range_for_refcount_40365 ocfs2_check_range_for_refcount 3-2 40365 NULL
107102 +get_chars_40373 get_chars 3 40373 NULL
107103 +submit_page_section_40408 submit_page_section 0 40408 NULL
107104 +ecryptfs_read_lower_40419 ecryptfs_read_lower 3 40419 NULL
107105 +slab_node_40421 slab_node 0 40421 NULL
107106 +fb_prepare_extra_logos_40429 fb_prepare_extra_logos 0-2 40429 NULL
107107 +tomoyo_update_policy_40458 tomoyo_update_policy 2 40458 NULL
107108 +zd_usb_scnprint_id_40459 zd_usb_scnprint_id 0-3 40459 NULL
107109 +SyS_writev_40467 SyS_writev 3 40467 NULL
107110 +__i915_add_request_40469 __i915_add_request 0 40469 NULL
107111 +SyS_select_40473 SyS_select 1 40473 NULL
107112 +afs_fs_store_data_40484 afs_fs_store_data 3-4-5-6 40484 NULL
107113 +batadv_hash_new_40491 batadv_hash_new 1 40491 NULL
107114 +devcgroup_inode_permission_40492 devcgroup_inode_permission 0 40492 NULL
107115 +drm_vma_node_start_40500 drm_vma_node_start 0 40500 NULL
107116 +sg_phys_40507 sg_phys 0 40507 NULL
107117 +__ethtool_get_sset_count_40511 __ethtool_get_sset_count 0 40511 NULL
107118 +TSS_checkhmac2_40520 TSS_checkhmac2 7-5 40520 NULL
107119 +ixgbe_dbg_reg_ops_read_40540 ixgbe_dbg_reg_ops_read 3 40540 NULL
107120 +i915_gem_execbuffer_relocate_object_slow_40546 i915_gem_execbuffer_relocate_object_slow 0 40546 NULL
107121 +ima_write_policy_40548 ima_write_policy 3 40548 NULL
107122 +btrfs_flush_all_pending_stuffs_40553 btrfs_flush_all_pending_stuffs 0 40553 NULL
107123 +esp_alloc_tmp_40558 esp_alloc_tmp 2-3 40558 NULL
107124 +ufs_inode_getfrag_40560 ufs_inode_getfrag 2-4 40560 NULL
107125 +bdev_sectors_40564 bdev_sectors 0 40564 NULL
107126 +lba_to_map_index_40580 lba_to_map_index 0-1 40580 NULL
107127 +b1_get_byte_40597 b1_get_byte 0 40597 NULL
107128 +get_priv_descr_and_size_40612 get_priv_descr_and_size 0 40612 NULL
107129 +qla8044_rd_reg_40652 qla8044_rd_reg 0 40652 NULL
107130 +pid_nr_ns_40654 pid_nr_ns 0 40654 NULL
107131 +twl4030_kpwrite_u8_40665 twl4030_kpwrite_u8 3 40665 NULL
107132 +__cfg80211_roamed_40668 __cfg80211_roamed 4-6 40668 NULL
107133 +pipeline_rx_complete_stat_fifo_int_read_40671 pipeline_rx_complete_stat_fifo_int_read 3 40671 NULL
107134 +fops_read_40672 fops_read 3 40672 NULL
107135 +ext4_mark_inode_dirty_40673 ext4_mark_inode_dirty 0 40673 NULL
107136 +idr_get_empty_slot_40674 idr_get_empty_slot 0 40674 NULL
107137 +alloc_rbio_40676 alloc_rbio 4 40676 NULL
107138 +videobuf_dma_init_user_locked_40678 videobuf_dma_init_user_locked 3-4 40678 NULL
107139 +pci_enable_resources_40680 pci_enable_resources 0 40680 NULL
107140 +nfc_hci_set_param_40697 nfc_hci_set_param 5 40697 NULL
107141 +__seq_open_private_40715 __seq_open_private 3 40715 NULL
107142 +btrfs_find_one_extref_40724 btrfs_find_one_extref 0 40724 NULL
107143 +fuse_readpages_40737 fuse_readpages 4 40737 NULL
107144 +xfs_iext_remove_direct_40744 xfs_iext_remove_direct 3 40744 NULL nohasharray
107145 +find_next_zero_bit_le_40744 find_next_zero_bit_le 2-3-0 40744 &xfs_iext_remove_direct_40744
107146 +i915_gem_execbuffer_relocate_entry_40750 i915_gem_execbuffer_relocate_entry 0 40750 NULL
107147 +security_inode_listxattr_40752 security_inode_listxattr 0 40752 NULL
107148 +card_send_command_40757 card_send_command 3 40757 NULL
107149 +ad1889_readl_40765 ad1889_readl 0 40765 NULL
107150 +pg_write_40766 pg_write 3 40766 NULL
107151 +show_list_40775 show_list 3-0 40775 NULL
107152 +calcu_metadata_size_40782 calcu_metadata_size 0 40782 NULL
107153 +kfifo_out_copy_r_40784 kfifo_out_copy_r 3-0 40784 NULL
107154 +bitmap_weight_40791 bitmap_weight 0-2 40791 NULL
107155 +pyra_sysfs_read_40795 pyra_sysfs_read 6 40795 NULL
107156 +add_action_40811 add_action 4 40811 NULL
107157 +nl80211_send_roamed_40825 nl80211_send_roamed 5-7 40825 NULL
107158 +SyS_mbind_40828 SyS_mbind 5 40828 NULL
107159 +__mlx4_qp_reserve_range_40847 __mlx4_qp_reserve_range 2-3 40847 NULL
107160 +nilfs_mdt_init_40849 nilfs_mdt_init 3 40849 NULL
107161 +ocfs2_zero_partial_clusters_40856 ocfs2_zero_partial_clusters 2-3 40856 NULL
107162 +v9fs_file_read_40858 v9fs_file_read 3 40858 NULL
107163 +read_file_queue_40895 read_file_queue 3 40895 NULL
107164 +btrfs_set_inode_index_count_40901 btrfs_set_inode_index_count 0 40901 NULL
107165 +waiters_read_40902 waiters_read 3 40902 NULL
107166 +isdn_add_channels_40905 isdn_add_channels 3 40905 NULL
107167 +gfs2_ea_find_40913 gfs2_ea_find 0 40913 NULL
107168 +vol_cdev_write_40915 vol_cdev_write 3 40915 NULL
107169 +snd_vx_create_40948 snd_vx_create 4 40948 NULL nohasharray
107170 +sg_alloc_table_40948 sg_alloc_table 0 40948 &snd_vx_create_40948
107171 +wm8994_free_irq_40951 wm8994_free_irq 2 40951 NULL
107172 +rds_sendmsg_40976 rds_sendmsg 4 40976 NULL
107173 +btrfs_find_orphan_item_40977 btrfs_find_orphan_item 0 40977 NULL
107174 +insert_old_idx_40987 insert_old_idx 0 40987 NULL
107175 +il_dbgfs_fh_reg_read_40993 il_dbgfs_fh_reg_read 3 40993 NULL
107176 +mac80211_format_buffer_41010 mac80211_format_buffer 2 41010 NULL
107177 +mtd_block_isbad_41015 mtd_block_isbad 0 41015 NULL
107178 +__proc_dobitmasks_41029 __proc_dobitmasks 5 41029 NULL
107179 +_req_append_segment_41031 _req_append_segment 2 41031 NULL
107180 +mISDN_sock_sendmsg_41035 mISDN_sock_sendmsg 4 41035 NULL
107181 +ocfs2_xattr_index_block_find_41040 ocfs2_xattr_index_block_find 0 41040 NULL
107182 +lprocfs_write_frac_helper_41050 lprocfs_write_frac_helper 2 41050 NULL
107183 +BcmFlash2xBulkWrite_41054 BcmFlash2xBulkWrite 0 41054 NULL
107184 +calculate_order_41061 calculate_order 0 41061 NULL
107185 +vfs_listxattr_41062 vfs_listxattr 0 41062 NULL nohasharray
107186 +beacon_filtering_write_41062 beacon_filtering_write 3 41062 &vfs_listxattr_41062
107187 +cfg80211_inform_bss_frame_41078 cfg80211_inform_bss_frame 4 41078 NULL
107188 +roccat_read_41093 roccat_read 3 41093 NULL nohasharray
107189 +nvme_map_user_pages_41093 nvme_map_user_pages 4-3 41093 &roccat_read_41093
107190 +dma_attach_41094 dma_attach 6-5 41094 NULL
107191 +provide_user_output_41105 provide_user_output 3 41105 NULL
107192 +f_audio_buffer_alloc_41110 f_audio_buffer_alloc 1 41110 NULL
107193 +ath10k_read_wmi_services_41112 ath10k_read_wmi_services 3 41112 NULL
107194 +ocfs2_extend_trans_41116 ocfs2_extend_trans 0 41116 NULL
107195 +btrfs_subvolume_reserve_metadata_41130 btrfs_subvolume_reserve_metadata 3 41130 NULL
107196 +v4l2_ctrl_new_int_menu_41151 v4l2_ctrl_new_int_menu 4 41151 NULL
107197 +tx_frag_mpdu_alloc_failed_read_41167 tx_frag_mpdu_alloc_failed_read 3 41167 NULL
107198 +dvb_ca_write_41171 dvb_ca_write 3 41171 NULL
107199 +ol_quota_chunk_block_41177 ol_quota_chunk_block 0-2 41177 NULL
107200 +dgap_driver_kzmalloc_41189 dgap_driver_kzmalloc 1 41189 NULL
107201 +compat_sys_process_vm_writev_41194 compat_sys_process_vm_writev 3-5 41194 NULL
107202 +dfs_file_write_41196 dfs_file_write 3 41196 NULL
107203 +ocfs2_read_quota_block_41207 ocfs2_read_quota_block 2 41207 NULL
107204 +nfs_page_array_len_41219 nfs_page_array_len 0-2-1 41219 NULL
107205 +cfg80211_process_disassoc_41231 cfg80211_process_disassoc 3 41231 NULL
107206 +hiddev_compat_ioctl_41255 hiddev_compat_ioctl 2 41255 NULL
107207 +create_dir_41256 create_dir 0 41256 NULL
107208 +erst_read_41260 erst_read 0 41260 NULL
107209 +setup_cluster_bitmap_41270 setup_cluster_bitmap 4-0 41270 NULL
107210 +alloc_context_41283 alloc_context 1 41283 NULL
107211 +objio_alloc_io_state_41316 objio_alloc_io_state 7-6 41316 NULL
107212 +o2hb_setup_one_bio_41341 o2hb_setup_one_bio 4 41341 NULL
107213 +twl_change_queue_depth_41342 twl_change_queue_depth 2 41342 NULL
107214 +rtw_android_set_block_41347 rtw_android_set_block 0 41347 NULL
107215 +irq_expand_nr_irqs_41351 irq_expand_nr_irqs 0 41351 NULL
107216 +cnic_init_id_tbl_41354 cnic_init_id_tbl 2 41354 NULL
107217 +jbd2_alloc_41359 jbd2_alloc 1 41359 NULL
107218 +kmp_init_41373 kmp_init 2 41373 NULL
107219 +netlink_alloc_large_skb_41375 netlink_alloc_large_skb 1 41375 NULL
107220 +isr_commands_read_41398 isr_commands_read 3 41398 NULL
107221 +is_writethrough_io_41406 is_writethrough_io 3 41406 NULL
107222 +rx_defrag_decrypt_failed_read_41411 rx_defrag_decrypt_failed_read 3 41411 NULL
107223 +xfs_iext_add_41422 xfs_iext_add 3 41422 NULL
107224 +isdn_ppp_fill_rq_41428 isdn_ppp_fill_rq 2 41428 NULL
107225 +lbs_rdrf_read_41431 lbs_rdrf_read 3 41431 NULL
107226 +iio_device_alloc_41440 iio_device_alloc 1 41440 NULL
107227 +ntfs_file_buffered_write_41442 ntfs_file_buffered_write 6-4 41442 NULL
107228 +pcpu_build_alloc_info_41443 pcpu_build_alloc_info 1-2-3 41443 NULL
107229 +layout_leb_in_gaps_41470 layout_leb_in_gaps 0 41470 NULL
107230 +snd_pcm_status_41472 snd_pcm_status 0 41472 NULL
107231 +rt2x00debug_write_rfcsr_41473 rt2x00debug_write_rfcsr 3 41473 NULL
107232 +bl_alloc_init_bio_41478 bl_alloc_init_bio 1 41478 NULL
107233 +split_item_41483 split_item 0 41483 NULL
107234 +kvm_unmap_hva_range_41484 kvm_unmap_hva_range 3-2 41484 NULL
107235 +ipath_user_sdma_page_length_41490 ipath_user_sdma_page_length 0-2-1 41490 NULL
107236 +wep_interrupt_read_41492 wep_interrupt_read 3 41492 NULL
107237 +SyS_get_mempolicy_41495 SyS_get_mempolicy 3-4 41495 NULL
107238 +hpfs_translate_name_41497 hpfs_translate_name 3 41497 NULL
107239 +xfrm_hash_new_size_41505 xfrm_hash_new_size 0-1 41505 NULL
107240 +perf_sw_event_41517 perf_sw_event 2 41517 NULL
107241 +SyS_preadv_41523 SyS_preadv 3 41523 NULL
107242 +dm_get_reserved_rq_based_ios_41529 dm_get_reserved_rq_based_ios 0 41529 NULL
107243 +add_excluded_extent_41547 add_excluded_extent 0 41547 NULL
107244 +tx_tx_frame_checksum_read_41553 tx_tx_frame_checksum_read 3 41553 NULL
107245 +ath6kl_endpoint_stats_read_41554 ath6kl_endpoint_stats_read 3 41554 NULL
107246 +si476x_radio_fops_read_41559 si476x_radio_fops_read 3 41559 NULL nohasharray
107247 +nr_status_frames_41559 nr_status_frames 0-1 41559 &si476x_radio_fops_read_41559
107248 +rng_dev_read_41581 rng_dev_read 3 41581 NULL
107249 +vga_io_r_41609 vga_io_r 0 41609 NULL
107250 +tcp_hdrlen_41610 tcp_hdrlen 0 41610 NULL
107251 +lbs_bcnmiss_write_41613 lbs_bcnmiss_write 3 41613 NULL nohasharray
107252 +usb_endpoint_maxp_41613 usb_endpoint_maxp 0 41613 &lbs_bcnmiss_write_41613
107253 +a2mp_send_41615 a2mp_send 4 41615 NULL
107254 +btrfs_calc_trunc_metadata_size_41626 btrfs_calc_trunc_metadata_size 0-2 41626 NULL
107255 +lstcon_batch_list_41627 lstcon_batch_list 2 41627 NULL
107256 +mempool_create_kmalloc_pool_41650 mempool_create_kmalloc_pool 1 41650 NULL
107257 +rx_rx_pre_complt_read_41653 rx_rx_pre_complt_read 3 41653 NULL
107258 +get_std_timing_41654 get_std_timing 0 41654 NULL
107259 +start_graph_tracing_41656 start_graph_tracing 0 41656 NULL
107260 +ieee80211_if_fmt_bssid_41677 ieee80211_if_fmt_bssid 3 41677 NULL
107261 +params_period_bytes_41683 params_period_bytes 0 41683 NULL
107262 +fill_pcm_stream_name_41685 fill_pcm_stream_name 2 41685 NULL
107263 +lov_unpackmd_41701 lov_unpackmd 4 41701 NULL
107264 +__ext3_journal_get_write_access_41705 __ext3_journal_get_write_access 0 41705 NULL
107265 +apei_exec_for_each_entry_41717 apei_exec_for_each_entry 0 41717 NULL
107266 +bdx_tx_db_init_41719 bdx_tx_db_init 2 41719 NULL
107267 +ocfs2_block_group_fill_41744 ocfs2_block_group_fill 0 41744 NULL
107268 +fillonedir_41746 fillonedir 3 41746 NULL
107269 +ocfs2_dx_dir_rebalance_41793 ocfs2_dx_dir_rebalance 7 41793 NULL
107270 +iwl_dbgfs_bt_notif_read_41794 iwl_dbgfs_bt_notif_read 3 41794 NULL
107271 +remap_pte_range_41800 remap_pte_range 5 41800 NULL
107272 +hsi_alloc_controller_41802 hsi_alloc_controller 1 41802 NULL
107273 +regcache_sync_block_raw_41803 regcache_sync_block_raw 4-3 41803 NULL
107274 +rtw_android_get_macaddr_41812 rtw_android_get_macaddr 0 41812 NULL
107275 +da9052_enable_irq_41814 da9052_enable_irq 2 41814 NULL
107276 +sco_send_frame_41815 sco_send_frame 3 41815 NULL
107277 +lp_gpio_to_irq_41822 lp_gpio_to_irq 2 41822 NULL
107278 +ixgbe_dbg_netdev_ops_read_41839 ixgbe_dbg_netdev_ops_read 3 41839 NULL
107279 +do_ip_setsockopt_41852 do_ip_setsockopt 5 41852 NULL
107280 +keyctl_instantiate_key_41855 keyctl_instantiate_key 3 41855 NULL
107281 +pci_map_single_41869 pci_map_single 0 41869 NULL
107282 +usb_gadget_get_string_41871 usb_gadget_get_string 0 41871 NULL
107283 +v_APCI3120_InterruptDmaMoveBlock16bit_41914 v_APCI3120_InterruptDmaMoveBlock16bit 4 41914 NULL
107284 +get_fdb_entries_41916 get_fdb_entries 3 41916 NULL
107285 +find_ge_pid_41918 find_ge_pid 1 41918 NULL
107286 +build_inv_iotlb_pages_41922 build_inv_iotlb_pages 4-5 41922 NULL
107287 +nfsd_getxattr_41934 nfsd_getxattr 0 41934 NULL
107288 +ext4_da_write_inline_data_begin_41935 ext4_da_write_inline_data_begin 3-4 41935 NULL
107289 +read_gssp_41947 read_gssp 3 41947 NULL
107290 +ocfs2_xattr_bucket_get_name_value_41949 ocfs2_xattr_bucket_get_name_value 0 41949 NULL
107291 +portnames_read_41958 portnames_read 3 41958 NULL
107292 +ubi_self_check_all_ff_41959 ubi_self_check_all_ff 0-4 41959 NULL
107293 +dst_mtu_41969 dst_mtu 0 41969 NULL
107294 +btrfs_check_trunc_cache_free_space_41973 btrfs_check_trunc_cache_free_space 0 41973 NULL
107295 +cx24116_writeregN_41975 cx24116_writeregN 4 41975 NULL
107296 +ubi_io_is_bad_41983 ubi_io_is_bad 0 41983 NULL
107297 +pool_allocate_42012 pool_allocate 3 42012 NULL
107298 +spidev_sync_read_42014 spidev_sync_read 0 42014 NULL
107299 +rs_sta_dbgfs_scale_table_write_42017 rs_sta_dbgfs_scale_table_write 3 42017 NULL
107300 +nouveau_ttm_tt_create_42026 nouveau_ttm_tt_create 2 42026 NULL
107301 +acpi_ut_create_buffer_object_42030 acpi_ut_create_buffer_object 1 42030 NULL
107302 +__btrfs_drop_extents_42032 __btrfs_drop_extents 5-0 42032 NULL
107303 +__hwahc_op_set_gtk_42038 __hwahc_op_set_gtk 4 42038 NULL
107304 +irda_sendmsg_ultra_42047 irda_sendmsg_ultra 4 42047 NULL
107305 +dma_generic_alloc_coherent_42048 dma_generic_alloc_coherent 2 42048 NULL nohasharray
107306 +jffs2_do_link_42048 jffs2_do_link 6 42048 &dma_generic_alloc_coherent_42048
107307 +ps_poll_upsd_max_ap_turn_read_42050 ps_poll_upsd_max_ap_turn_read 3 42050 NULL
107308 +InterfaceTransmitPacket_42058 InterfaceTransmitPacket 3 42058 NULL
107309 +alloc_bitset_42085 alloc_bitset 1 42085 NULL
107310 +scsi_execute_req_42088 scsi_execute_req 5 42088 NULL
107311 +sk_chk_filter_42095 sk_chk_filter 2 42095 NULL
107312 +send_truncate_42107 send_truncate 0 42107 NULL
107313 +submit_inquiry_42108 submit_inquiry 3 42108 NULL
107314 +sysfs_read_file_42113 sysfs_read_file 3 42113 NULL nohasharray
107315 +dw_dma_cyclic_prep_42113 dw_dma_cyclic_prep 3-4 42113 &sysfs_read_file_42113
107316 +__btrfs_unlink_inode_42114 __btrfs_unlink_inode 0 42114 NULL
107317 +ext4_do_update_inode_42127 ext4_do_update_inode 0 42127 NULL
107318 +blk_ioctl_zeroout_42160 blk_ioctl_zeroout 3 42160 NULL
107319 +mmc_align_data_size_42161 mmc_align_data_size 0-2 42161 NULL
107320 +kvm_lapic_get_cr8_42166 kvm_lapic_get_cr8 0 42166 NULL
107321 +read_file_base_eeprom_42168 read_file_base_eeprom 3 42168 NULL
107322 +oprofilefs_str_to_user_42182 oprofilefs_str_to_user 3 42182 NULL
107323 +write_file_beacon_42185 write_file_beacon 3 42185 NULL
107324 +get_znodes_to_commit_42201 get_znodes_to_commit 0 42201 NULL
107325 +ocfs2_resv_window_bits_42207 ocfs2_resv_window_bits 0 42207 NULL
107326 +pla_ocp_read_42235 pla_ocp_read 3 42235 NULL
107327 +rx_defrag_need_decrypt_read_42253 rx_defrag_need_decrypt_read 3 42253 NULL
107328 +vfio_remove_dma_overlap_42255 vfio_remove_dma_overlap 2 42255 NULL
107329 +__pcpu_size_to_slot_42271 __pcpu_size_to_slot 0 42271 NULL
107330 +snd_pcm_hw_param_value_max_42280 snd_pcm_hw_param_value_max 0 42280 NULL
107331 +__cpus_weight_42299 __cpus_weight 2-0 42299 NULL
107332 +sel_read_perm_42302 sel_read_perm 3 42302 NULL
107333 +sctp_setsockopt_del_key_42304 sctp_setsockopt_del_key 3 42304 NULL nohasharray
107334 +ulong_read_file_42304 ulong_read_file 3 42304 &sctp_setsockopt_del_key_42304
107335 +gfn_to_hva_42305 gfn_to_hva 2-0 42305 NULL
107336 +close_cur_inode_file_42308 close_cur_inode_file 0 42308 NULL nohasharray
107337 +xfs_vm_readpages_42308 xfs_vm_readpages 4 42308 &close_cur_inode_file_42308
107338 +free_cblock_42318 free_cblock 2 42318 NULL
107339 +hysdn_conf_read_42324 hysdn_conf_read 3 42324 NULL
107340 +tcp_sync_mss_42330 tcp_sync_mss 2-0 42330 NULL
107341 +snd_pcm_plug_alloc_42339 snd_pcm_plug_alloc 2 42339 NULL
107342 +ide_raw_taskfile_42355 ide_raw_taskfile 4 42355 NULL
107343 +drbd_md_last_sector_42378 drbd_md_last_sector 0 42378 NULL
107344 +il_dbgfs_disable_ht40_read_42386 il_dbgfs_disable_ht40_read 3 42386 NULL
107345 +hash_ipportnet4_expire_42391 hash_ipportnet4_expire 3 42391 NULL
107346 +msnd_fifo_read_42406 msnd_fifo_read 0-3 42406 NULL
107347 +krng_get_random_42420 krng_get_random 3 42420 NULL
107348 +gsm_data_alloc_42437 gsm_data_alloc 3 42437 NULL
107349 +key_conf_keyidx_read_42443 key_conf_keyidx_read 3 42443 NULL
107350 +alloc_request_42448 alloc_request 0 42448 NULL
107351 +snd_pcm_action_group_42452 snd_pcm_action_group 0 42452 NULL
107352 +tcm_loop_change_queue_depth_42454 tcm_loop_change_queue_depth 2 42454 NULL
107353 +kuc_free_42455 kuc_free 2 42455 NULL
107354 +tc3589x_gpio_irq_get_virq_42457 tc3589x_gpio_irq_get_virq 2 42457 NULL
107355 +ext3_valid_block_bitmap_42459 ext3_valid_block_bitmap 3 42459 NULL
107356 +__simple_xattr_set_42474 __simple_xattr_set 4 42474 NULL
107357 +follow_hugetlb_page_42486 follow_hugetlb_page 0-7 42486 NULL
107358 +omfs_readpages_42490 omfs_readpages 4 42490 NULL
107359 +bypass_write_42498 bypass_write 3 42498 NULL
107360 +SyS_mincore_42511 SyS_mincore 1-2 42511 NULL
107361 +jbd2_log_wait_commit_42519 jbd2_log_wait_commit 0 42519 NULL
107362 +kvm_write_wall_clock_42520 kvm_write_wall_clock 2 42520 NULL
107363 +dio_bio_complete_42524 dio_bio_complete 0 42524 NULL
107364 +smk_write_netlbladdr_42525 smk_write_netlbladdr 3 42525 NULL
107365 +self_check_ec_hdr_42528 self_check_ec_hdr 0 42528 NULL
107366 +__register_ftrace_function_42543 __register_ftrace_function 0 42543 NULL
107367 +dbAllocNear_42546 dbAllocNear 0 42546 NULL
107368 +inorder_next_42548 inorder_next 1-0 42548 NULL
107369 +ath6kl_wmi_proc_events_vif_42549 ath6kl_wmi_proc_events_vif 5 42549 NULL
107370 +udp_recvmsg_42558 udp_recvmsg 4 42558 NULL
107371 +iwl_print_event_log_42566 iwl_print_event_log 0-5-7 42566 NULL
107372 +ocfs2_reserve_suballoc_bits_42569 ocfs2_reserve_suballoc_bits 0 42569 NULL
107373 +xfrm_new_hash_mask_42579 xfrm_new_hash_mask 0-1 42579 NULL
107374 +oom_score_adj_write_42594 oom_score_adj_write 3 42594 NULL
107375 +map_state_42602 map_state 1 42602 NULL
107376 +resp_write_42628 resp_write 2 42628 NULL
107377 +ieee80211_if_fmt_dot11MeshHWMPactivePathTimeout_42635 ieee80211_if_fmt_dot11MeshHWMPactivePathTimeout 3 42635 NULL
107378 +scsi_activate_tcq_42640 scsi_activate_tcq 2 42640 NULL
107379 +br_mdb_rehash_42643 br_mdb_rehash 2 42643 NULL
107380 +parport_pc_compat_write_block_pio_42644 parport_pc_compat_write_block_pio 3 42644 NULL
107381 +ocfs2_search_chain_42655 ocfs2_search_chain 0 42655 NULL
107382 +request_key_and_link_42693 request_key_and_link 4 42693 NULL
107383 +acpi_dev_get_irqresource_42694 acpi_dev_get_irqresource 2 42694 NULL
107384 +vb2_read_42703 vb2_read 3 42703 NULL
107385 +__ocfs2_decrease_refcount_42717 __ocfs2_decrease_refcount 5-4-0 42717 NULL
107386 +read_status_42722 read_status 0 42722 NULL
107387 +dvb_demux_ioctl_42733 dvb_demux_ioctl 2 42733 NULL
107388 +set_aoe_iflist_42737 set_aoe_iflist 2 42737 NULL
107389 +ax25_setsockopt_42740 ax25_setsockopt 5 42740 NULL
107390 +xen_bind_pirq_gsi_to_irq_42750 xen_bind_pirq_gsi_to_irq 1 42750 NULL
107391 +dpm_sysfs_add_42756 dpm_sysfs_add 0 42756 NULL
107392 +x25_recvmsg_42777 x25_recvmsg 4 42777 NULL
107393 +snd_midi_event_decode_42780 snd_midi_event_decode 0 42780 NULL
107394 +cryptd_hash_setkey_42781 cryptd_hash_setkey 3 42781 NULL nohasharray
107395 +isku_sysfs_read_info_42781 isku_sysfs_read_info 6 42781 &cryptd_hash_setkey_42781
107396 +elfcorehdr_read_notes_42786 elfcorehdr_read_notes 2 42786 NULL
107397 +koneplus_sysfs_read_42792 koneplus_sysfs_read 6 42792 NULL
107398 +ntfs_attr_extend_allocation_42796 ntfs_attr_extend_allocation 0-2 42796 NULL
107399 +fw_device_op_compat_ioctl_42804 fw_device_op_compat_ioctl 2 42804 NULL
107400 +drm_ioctl_42813 drm_ioctl 2 42813 NULL
107401 +iwl_dbgfs_ucode_bt_stats_read_42820 iwl_dbgfs_ucode_bt_stats_read 3 42820 NULL
107402 +xfs_iomap_eof_prealloc_initial_size_42822 xfs_iomap_eof_prealloc_initial_size 0-3 42822 NULL
107403 +set_arg_42824 set_arg 3 42824 NULL
107404 +si476x_radio_read_rsq_blob_42827 si476x_radio_read_rsq_blob 3 42827 NULL
107405 +ocfs2_desc_bitmap_to_cluster_off_42831 ocfs2_desc_bitmap_to_cluster_off 2 42831 NULL
107406 +prandom_u32_42853 prandom_u32 0 42853 NULL
107407 +ntfs_mapping_pairs_build_42859 ntfs_mapping_pairs_build 0 42859 NULL
107408 +nouveau_vm_create_42869 nouveau_vm_create 3-2 42869 NULL
107409 +ocfs2_clusters_for_bytes_42872 ocfs2_clusters_for_bytes 0-2 42872 NULL
107410 +nvme_trans_unit_serial_page_42879 nvme_trans_unit_serial_page 4 42879 NULL
107411 +xpc_kmalloc_cacheline_aligned_42895 xpc_kmalloc_cacheline_aligned 1 42895 NULL
107412 +hd_end_request_42904 hd_end_request 2 42904 NULL
107413 +sta_last_rx_rate_read_42909 sta_last_rx_rate_read 3 42909 NULL
107414 +sctp_getsockopt_maxburst_42941 sctp_getsockopt_maxburst 2 42941 NULL
107415 +get_unmapped_area_42944 get_unmapped_area 0 42944 NULL
107416 +vx_reset_chk_42946 vx_reset_chk 0 42946 NULL
107417 +send_link_42948 send_link 0 42948 NULL
107418 +blkdev_direct_IO_42962 blkdev_direct_IO 4 42962 NULL
107419 +read_file_node_stat_42964 read_file_node_stat 3 42964 NULL
107420 +compat_udpv6_setsockopt_42981 compat_udpv6_setsockopt 5 42981 NULL
107421 +nfs_idmap_get_desc_42990 nfs_idmap_get_desc 2-4 42990 NULL nohasharray
107422 +rtw_os_xmit_resource_alloc_42990 rtw_os_xmit_resource_alloc 3 42990 &nfs_idmap_get_desc_42990
107423 +mlx4_qp_reserve_range_43000 mlx4_qp_reserve_range 2-3 43000 NULL
107424 +isr_rx_mem_overflow_read_43025 isr_rx_mem_overflow_read 3 43025 NULL
107425 +add_bytes_to_bitmap_43026 add_bytes_to_bitmap 0-3-4 43026 NULL
107426 +init_phys_status_page_43028 init_phys_status_page 0 43028 NULL
107427 +wep_default_key_count_read_43035 wep_default_key_count_read 3 43035 NULL
107428 +send_to_group_43051 send_to_group 0 43051 NULL
107429 +nouveau_gpuobj_create__43072 nouveau_gpuobj_create_ 9 43072 NULL
107430 +nfs_map_group_to_gid_43082 nfs_map_group_to_gid 3 43082 NULL
107431 +ieee80211_if_fmt_drop_unencrypted_43107 ieee80211_if_fmt_drop_unencrypted 3 43107 NULL
107432 +calculate_node_totalpages_43118 calculate_node_totalpages 2-3 43118 NULL
107433 +cow_file_range_inline_43132 cow_file_range_inline 4 43132 NULL
107434 +read_file_dfs_43145 read_file_dfs 3 43145 NULL
107435 +cfs_cpt_table_alloc_43159 cfs_cpt_table_alloc 1 43159 NULL
107436 +usb_string_sub_43164 usb_string_sub 0 43164 NULL
107437 +il_dbgfs_power_save_status_read_43165 il_dbgfs_power_save_status_read 3 43165 NULL
107438 +send_cmd_43168 send_cmd 0 43168 NULL
107439 +ath6kl_set_assoc_req_ies_43185 ath6kl_set_assoc_req_ies 3 43185 NULL
107440 +ext4_xattr_ibody_get_43200 ext4_xattr_ibody_get 0 43200 NULL
107441 +uio_write_43202 uio_write 3 43202 NULL
107442 +iso_callback_43208 iso_callback 3 43208 NULL
107443 +ath10k_p2p_calc_noa_ie_len_43209 ath10k_p2p_calc_noa_ie_len 0 43209 NULL
107444 +f2fs_acl_from_disk_43210 f2fs_acl_from_disk 2 43210 NULL
107445 +atomic_long_add_return_43217 atomic_long_add_return 1-0 43217 NULL
107446 +vmemmap_alloc_block_43245 vmemmap_alloc_block 1 43245 NULL
107447 +fixup_leb_43256 fixup_leb 3 43256 NULL
107448 +ide_end_rq_43269 ide_end_rq 4 43269 NULL
107449 +nilfs_direct_IO_43271 nilfs_direct_IO 4 43271 NULL
107450 +mlx5_ib_reg_user_mr_43275 mlx5_ib_reg_user_mr 2-3 43275 NULL
107451 +parport_pc_ecp_write_block_pio_43278 parport_pc_ecp_write_block_pio 3 43278 NULL nohasharray
107452 +evtchn_write_43278 evtchn_write 3 43278 &parport_pc_ecp_write_block_pio_43278
107453 +filemap_write_and_wait_range_43279 filemap_write_and_wait_range 0 43279 NULL
107454 +mpage_alloc_43299 mpage_alloc 3 43299 NULL
107455 +get_nr_irqs_gsi_43315 get_nr_irqs_gsi 0 43315 NULL
107456 +mmu_set_spte_43327 mmu_set_spte 7-6 43327 NULL
107457 +__ext4_get_inode_loc_43332 __ext4_get_inode_loc 0 43332 NULL
107458 +kvm_host_page_size_43348 kvm_host_page_size 2-0 43348 NULL
107459 +gart_free_coherent_43362 gart_free_coherent 4-2 43362 NULL
107460 +hash_net4_expire_43378 hash_net4_expire 3 43378 NULL
107461 +xenfb_write_43412 xenfb_write 3 43412 NULL
107462 +__alloc_bootmem_low_43423 __alloc_bootmem_low 1 43423 NULL
107463 +usb_alloc_urb_43436 usb_alloc_urb 1 43436 NULL
107464 +ath6kl_wmi_roam_tbl_event_rx_43440 ath6kl_wmi_roam_tbl_event_rx 3 43440 NULL
107465 +ocfs2_rotate_tree_left_43442 ocfs2_rotate_tree_left 0 43442 NULL
107466 +usemap_size_43443 usemap_size 0-2-1 43443 NULL nohasharray
107467 +usb_string_43443 usb_string 0 43443 &usemap_size_43443
107468 +get_vm_area_size_43444 get_vm_area_size 0 43444 NULL
107469 +nvme_trans_device_id_page_43466 nvme_trans_device_id_page 4 43466 NULL
107470 +calculate_discard_block_size_43480 calculate_discard_block_size 0 43480 NULL nohasharray
107471 +alloc_new_reservation_43480 alloc_new_reservation 4-0-2 43480 &calculate_discard_block_size_43480
107472 +tx_tx_data_prepared_read_43497 tx_tx_data_prepared_read 3 43497 NULL
107473 +ieee80211_if_fmt_dot11MeshHWMPnetDiameterTraversalTime_43505 ieee80211_if_fmt_dot11MeshHWMPnetDiameterTraversalTime 3 43505 NULL
107474 +do_readlink_43518 do_readlink 2 43518 NULL
107475 +dvb_ca_en50221_io_write_43533 dvb_ca_en50221_io_write 3 43533 NULL
107476 +read_events_43534 read_events 3 43534 NULL
107477 +cachefiles_daemon_write_43535 cachefiles_daemon_write 3 43535 NULL
107478 +tx_frag_failed_read_43540 tx_frag_failed_read 3 43540 NULL nohasharray
107479 +ufs_alloccg_block_43540 ufs_alloccg_block 3-0 43540 &tx_frag_failed_read_43540
107480 +request_resource_43548 request_resource 0 43548 NULL
107481 +rpc_malloc_43573 rpc_malloc 2 43573 NULL
107482 +handle_frequent_errors_43599 handle_frequent_errors 4 43599 NULL
107483 +lpfc_idiag_drbacc_read_reg_43606 lpfc_idiag_drbacc_read_reg 0-3 43606 NULL
107484 +proc_read_43614 proc_read 3 43614 NULL
107485 +i915_gem_execbuffer_relocate_object_slow_43618 i915_gem_execbuffer_relocate_object_slow 0 43618 NULL nohasharray
107486 +disable_dma_on_even_43618 disable_dma_on_even 0 43618 &i915_gem_execbuffer_relocate_object_slow_43618
107487 +random_write_43656 random_write 3 43656 NULL
107488 +bio_integrity_tag_43658 bio_integrity_tag 3 43658 NULL
107489 +ext4_acl_count_43659 ext4_acl_count 0-1 43659 NULL
107490 +fs_path_copy_43673 fs_path_copy 0 43673 NULL
107491 +dmam_declare_coherent_memory_43679 dmam_declare_coherent_memory 4 43679 NULL
107492 +calgary_map_page_43686 calgary_map_page 4 43686 NULL
107493 +max77693_bulk_write_43698 max77693_bulk_write 2-3 43698 NULL
107494 +wait_for_completion_interruptible_43723 wait_for_completion_interruptible 0 43723 NULL
107495 +drbd_md_first_sector_43729 drbd_md_first_sector 0 43729 NULL
107496 +reset_card_proc_43731 reset_card_proc 0 43731 NULL
107497 +snd_rme32_playback_copy_43732 snd_rme32_playback_copy 5 43732 NULL
107498 +ocfs2_replace_clusters_43733 ocfs2_replace_clusters 5-0 43733 NULL
107499 +fuse_conn_congestion_threshold_write_43736 fuse_conn_congestion_threshold_write 3 43736 NULL
107500 +__bm_find_next_43748 __bm_find_next 2 43748 NULL
107501 +gigaset_initcs_43753 gigaset_initcs 2 43753 NULL
107502 +sctp_setsockopt_active_key_43755 sctp_setsockopt_active_key 3 43755 NULL
107503 +ocfs2_xattr_get_value_outside_43787 ocfs2_xattr_get_value_outside 0 43787 NULL nohasharray
107504 +byte_pos_43787 byte_pos 0-2 43787 &ocfs2_xattr_get_value_outside_43787
107505 +btrfs_copy_from_user_43806 btrfs_copy_from_user 0-3-1 43806 NULL
107506 +ext4_read_block_bitmap_43814 ext4_read_block_bitmap 2 43814 NULL
107507 +div64_u64_safe_43815 div64_u64_safe 2-1 43815 NULL
107508 +ext4_split_extent_43818 ext4_split_extent 0 43818 NULL
107509 +i915_gem_execbuffer_relocate_entry_43822 i915_gem_execbuffer_relocate_entry 0 43822 NULL
107510 +ieee80211_if_fmt_element_ttl_43825 ieee80211_if_fmt_element_ttl 3 43825 NULL
107511 +ieee80211_alloc_hw_43829 ieee80211_alloc_hw 1 43829 NULL
107512 +read_flush_43851 read_flush 3 43851 NULL
107513 +ocfs2_block_group_find_clear_bits_43874 ocfs2_block_group_find_clear_bits 4 43874 NULL
107514 +pm860x_bulk_write_43875 pm860x_bulk_write 2-3 43875 NULL
107515 +SendString_43928 SendString 3 43928 NULL
107516 +xen_register_gsi_43946 xen_register_gsi 2-1 43946 NULL
107517 +stats_dot11RTSFailureCount_read_43948 stats_dot11RTSFailureCount_read 3 43948 NULL
107518 +perf_tp_event_43971 perf_tp_event 2 43971 NULL
107519 +__get_required_blob_size_43980 __get_required_blob_size 0-3-2 43980 NULL
107520 +nla_reserve_43984 nla_reserve 3 43984 NULL
107521 +__clkdev_alloc_43990 __clkdev_alloc 1 43990 NULL
107522 +scsi_command_size_43992 scsi_command_size 0 43992 NULL nohasharray
107523 +kvm_read_guest_virt_43992 kvm_read_guest_virt 4-2 43992 &scsi_command_size_43992 nohasharray
107524 +bcm_recvmsg_43992 bcm_recvmsg 4 43992 &kvm_read_guest_virt_43992
107525 +ulist_add_43994 ulist_add 0 43994 NULL
107526 +emit_flags_44006 emit_flags 4-3 44006 NULL
107527 +write_flush_procfs_44011 write_flush_procfs 3 44011 NULL
107528 +fru_strlen_44046 fru_strlen 0 44046 NULL
107529 +tree_insert_offset_44069 tree_insert_offset 0 44069 NULL
107530 +SYSC_add_key_44079 SYSC_add_key 4 44079 NULL
107531 +btrfs_prev_leaf_44083 btrfs_prev_leaf 0 44083 NULL nohasharray
107532 +load_discard_44083 load_discard 3 44083 &btrfs_prev_leaf_44083
107533 +__vxge_hw_vpath_tim_configure_44093 __vxge_hw_vpath_tim_configure 2 44093 NULL
107534 +xlog_recover_add_to_cont_trans_44102 xlog_recover_add_to_cont_trans 4 44102 NULL
107535 +skb_frag_dma_map_44112 skb_frag_dma_map 0 44112 NULL
107536 +tracing_set_trace_read_44122 tracing_set_trace_read 3 44122 NULL
107537 +SyS_process_vm_writev_44129 SyS_process_vm_writev 3-5 44129 NULL
107538 +vmw_gmr_bind_44130 vmw_gmr_bind 3 44130 NULL
107539 +lookup_extent_data_ref_44136 lookup_extent_data_ref 0 44136 NULL
107540 +ttm_get_pages_44142 ttm_get_pages 2 44142 NULL
107541 +scsi_get_resid_44147 scsi_get_resid 0 44147 NULL
107542 +ubifs_find_dirty_idx_leb_44169 ubifs_find_dirty_idx_leb 0 44169 NULL
107543 +ocfs2_xattr_bucket_find_44174 ocfs2_xattr_bucket_find 0 44174 NULL
107544 +SYSC_set_mempolicy_44176 SYSC_set_mempolicy 3 44176 NULL
107545 +readreg_ipac_44186 readreg_ipac 0 44186 NULL
107546 +handle_eviocgbit_44193 handle_eviocgbit 3 44193 NULL
107547 +IO_APIC_get_PCI_irq_vector_44198 IO_APIC_get_PCI_irq_vector 0 44198 NULL
107548 +__set_free_44211 __set_free 2 44211 NULL
107549 +claim_ptd_buffers_44213 claim_ptd_buffers 3 44213 NULL
107550 +srp_alloc_iu_44227 srp_alloc_iu 2 44227 NULL
107551 +ioapic_register_intr_44238 ioapic_register_intr 1 44238 NULL
107552 +scsi_track_queue_full_44239 scsi_track_queue_full 2 44239 NULL
107553 +sigma_action_write_regmap_44240 sigma_action_write_regmap 3 44240 NULL
107554 +tc3589x_gpio_irq_map_44245 tc3589x_gpio_irq_map 2 44245 NULL
107555 +apei_resources_sub_44252 apei_resources_sub 0 44252 NULL
107556 +byt_gpio_irq_map_44275 byt_gpio_irq_map 2 44275 NULL
107557 +device_create_file_44285 device_create_file 0 44285 NULL
107558 +ufs_clusteracct_44293 ufs_clusteracct 3 44293 NULL
107559 +ocfs2_zero_range_for_truncate_44294 ocfs2_zero_range_for_truncate 3 44294 NULL
107560 +ath6kl_keepalive_read_44303 ath6kl_keepalive_read 3 44303 NULL
107561 +bitmap_scnprintf_44318 bitmap_scnprintf 0-2 44318 NULL
107562 +dispatch_proc_write_44320 dispatch_proc_write 3 44320 NULL
107563 +rs_init_44327 rs_init 1 44327 NULL
107564 +create_free_space_inode_44332 create_free_space_inode 0 44332 NULL
107565 +insert_into_bitmap_44340 insert_into_bitmap 0 44340 NULL
107566 +ubi_eba_write_leb_st_44343 ubi_eba_write_leb_st 0-5 44343 NULL
107567 +radix_tree_maybe_preload_44346 radix_tree_maybe_preload 0 44346 NULL
107568 +nfs_fscache_get_super_cookie_44355 nfs_fscache_get_super_cookie 3 44355 NULL nohasharray
107569 +blk_queue_init_tags_44355 blk_queue_init_tags 2 44355 &nfs_fscache_get_super_cookie_44355
107570 +__is_discarded_44359 __is_discarded 2 44359 NULL
107571 +ipx_recvmsg_44366 ipx_recvmsg 4 44366 NULL
107572 +alloc_requests_44372 alloc_requests 0 44372 NULL
107573 +rts_threshold_read_44384 rts_threshold_read 3 44384 NULL
107574 +iterate_dir_item_44386 iterate_dir_item 0 44386 NULL
107575 +mtip_hw_read_flags_44396 mtip_hw_read_flags 3 44396 NULL
107576 +aoedev_flush_44398 aoedev_flush 2 44398 NULL
107577 +strlcpy_44400 strlcpy 3 44400 NULL
107578 +drm_buffer_alloc_44405 drm_buffer_alloc 2 44405 NULL
107579 +osst_do_scsi_44410 osst_do_scsi 4 44410 NULL
107580 +check_user_page_hwpoison_44412 check_user_page_hwpoison 1 44412 NULL
107581 +ieee80211_if_read_rc_rateidx_mcs_mask_5ghz_44423 ieee80211_if_read_rc_rateidx_mcs_mask_5ghz 3 44423 NULL
107582 +prandom_u32_state_44445 prandom_u32_state 0 44445 NULL
107583 +iwl_dbgfs_bf_params_write_44450 iwl_dbgfs_bf_params_write 3 44450 NULL
107584 +write_file_debug_44476 write_file_debug 3 44476 NULL
107585 +btrfs_chunk_item_size_44478 btrfs_chunk_item_size 0-1 44478 NULL
107586 +sdio_align_size_44489 sdio_align_size 0-2 44489 NULL
107587 +bio_advance_44496 bio_advance 2 44496 NULL
107588 +ieee80211_if_read_dropped_frames_ttl_44500 ieee80211_if_read_dropped_frames_ttl 3 44500 NULL
107589 +ac_register_board_44504 ac_register_board 3 44504 NULL
107590 +security_getprocattr_44505 security_getprocattr 0 44505 NULL nohasharray
107591 +iwl_dbgfs_sram_read_44505 iwl_dbgfs_sram_read 3 44505 &security_getprocattr_44505
107592 +spidev_write_44510 spidev_write 3 44510 NULL
107593 +SyS_io_getevents_44519 SyS_io_getevents 3 44519 NULL
107594 +ieee80211_rx_mgmt_assoc_resp_44525 ieee80211_rx_mgmt_assoc_resp 3 44525 NULL
107595 +comm_write_44537 comm_write 3 44537 NULL
107596 +xfs_log_calc_unit_res_44540 xfs_log_calc_unit_res 0-2 44540 NULL
107597 +snd_pcm_drop_44542 snd_pcm_drop 0 44542 NULL
107598 +dbg_chk_pnode_44555 dbg_chk_pnode 0 44555 NULL
107599 +shmem_getpage_gfp_44556 shmem_getpage_gfp 0 44556 NULL
107600 +hash_ipport4_expire_44564 hash_ipport4_expire 3 44564 NULL
107601 +dgrp_config_proc_write_44571 dgrp_config_proc_write 3 44571 NULL
107602 +snd_pcm_alloc_vmalloc_buffer_44595 snd_pcm_alloc_vmalloc_buffer 2 44595 NULL
107603 +btrfs_qgroup_account_ref_44604 btrfs_qgroup_account_ref 0 44604 NULL
107604 +huge_page_shift_44618 huge_page_shift 0 44618 NULL
107605 +sysfs_add_one_44629 sysfs_add_one 0 44629 NULL
107606 +msb_get_free_block_44633 msb_get_free_block 2 44633 NULL
107607 +ext2_new_block_44645 ext2_new_block 2-0 44645 NULL
107608 +alloc_ctrl_packet_44667 alloc_ctrl_packet 1 44667 NULL
107609 +mpi_resize_44674 mpi_resize 2 44674 NULL
107610 +sysfs_create_link_44685 sysfs_create_link 0 44685 NULL nohasharray
107611 +__copy_user_intel_nocache_44685 __copy_user_intel_nocache 0-3 44685 &sysfs_create_link_44685
107612 +ts_read_44687 ts_read 3 44687 NULL
107613 +qib_get_user_pages_44689 qib_get_user_pages 1-2 44689 NULL
107614 +lov_emerg_alloc_44698 lov_emerg_alloc 1 44698 NULL
107615 +__ocfs2_rotate_tree_left_44705 __ocfs2_rotate_tree_left 0 44705 NULL
107616 +xfer_to_user_44713 xfer_to_user 3 44713 NULL nohasharray
107617 +__generic_block_fiemap_44713 __generic_block_fiemap 4 44713 &xfer_to_user_44713
107618 +_zd_iowrite32v_locked_44725 _zd_iowrite32v_locked 3 44725 NULL
107619 +clusterip_proc_write_44729 clusterip_proc_write 3 44729 NULL
107620 +fib_count_nexthops_44730 fib_count_nexthops 0 44730 NULL
107621 +SyS_read_44732 SyS_read 3 44732 NULL
107622 +vm_insert_mixed_44738 vm_insert_mixed 3 44738 NULL
107623 +key_tx_rx_count_read_44742 key_tx_rx_count_read 3 44742 NULL
107624 +set_brk_44749 set_brk 1-2 44749 NULL
107625 +tnode_new_44757 tnode_new 3 44757 NULL nohasharray
107626 +pty_write_44757 pty_write 3 44757 &tnode_new_44757
107627 +__videobuf_copy_stream_44769 __videobuf_copy_stream 4-0 44769 NULL
107628 +handsfree_ramp_44777 handsfree_ramp 2 44777 NULL
107629 +irq_domain_add_legacy_44781 irq_domain_add_legacy 4-2 44781 NULL
107630 +sctp_setsockopt_44788 sctp_setsockopt 5 44788 NULL
107631 +rx_dropped_read_44799 rx_dropped_read 3 44799 NULL
107632 +qla4xxx_alloc_work_44813 qla4xxx_alloc_work 2 44813 NULL
107633 +mei_cl_read_start_44824 mei_cl_read_start 2 44824 NULL
107634 +rmap_write_protect_44833 rmap_write_protect 2 44833 NULL
107635 +sisusb_write_44834 sisusb_write 3 44834 NULL
107636 +kvm_read_hva_44847 kvm_read_hva 3 44847 NULL
107637 +cubic_root_44848 cubic_root 1 44848 NULL
107638 +qib_verbs_send_dma_44850 qib_verbs_send_dma 6 44850 NULL
107639 +copydesc_user_44855 copydesc_user 3 44855 NULL
107640 +i915_gem_execbuffer_relocate_44868 i915_gem_execbuffer_relocate 0 44868 NULL
107641 +init_rs_44873 init_rs 1 44873 NULL
107642 +skb_availroom_44883 skb_availroom 0 44883 NULL
107643 +ocfs2_wait_for_mask_44893 ocfs2_wait_for_mask 0 44893 NULL
107644 +do_tty_write_44896 do_tty_write 5 44896 NULL
107645 +regmap_spi_read_44921 regmap_spi_read 3-5 44921 NULL
107646 +_snd_pcm_hw_param_last_44947 _snd_pcm_hw_param_last 0 44947 NULL
107647 +__add_delayed_refs_44977 __add_delayed_refs 0 44977 NULL
107648 +tx_queue_status_read_44978 tx_queue_status_read 3 44978 NULL
107649 +map_index_to_lba_44993 map_index_to_lba 0-1 44993 NULL
107650 +send_chmod_45011 send_chmod 0 45011 NULL
107651 +i915_gem_do_execbuffer_45012 i915_gem_do_execbuffer 0 45012 NULL
107652 +bytepos_delta_45017 bytepos_delta 0-2 45017 NULL
107653 +read_block_bitmap_45021 read_block_bitmap 2 45021 NULL nohasharray
107654 +ptrace_writedata_45021 ptrace_writedata 4-3 45021 &read_block_bitmap_45021
107655 +dm_kvzalloc_45025 dm_kvzalloc 1-2 45025 NULL
107656 +vhci_get_user_45039 vhci_get_user 3 45039 NULL
107657 +sysfs_do_create_link_sd_45057 sysfs_do_create_link_sd 0 45057 NULL
107658 +remap_oldmem_pfn_range_45060 remap_oldmem_pfn_range 2-3-4 45060 NULL nohasharray
107659 +sel_write_user_45060 sel_write_user 3 45060 &remap_oldmem_pfn_range_45060
107660 +vmscan_swappiness_45062 vmscan_swappiness 0 45062 NULL
107661 +snd_mixart_BA0_read_45069 snd_mixart_BA0_read 5 45069 NULL
107662 +kvm_mmu_page_get_gfn_45110 kvm_mmu_page_get_gfn 0-2 45110 NULL
107663 +pwr_missing_bcns_cnt_read_45113 pwr_missing_bcns_cnt_read 3 45113 NULL
107664 +usbdev_read_45114 usbdev_read 3 45114 NULL
107665 +send_to_tty_45141 send_to_tty 3 45141 NULL
107666 +stmpe_irq_map_45146 stmpe_irq_map 2 45146 NULL
107667 +cfs_trace_daemon_command_usrstr_45147 cfs_trace_daemon_command_usrstr 2 45147 NULL
107668 +gen_bitmask_string_45149 gen_bitmask_string 6 45149 NULL
107669 +ocfs2_remove_inode_range_45156 ocfs2_remove_inode_range 3-4 45156 NULL nohasharray
107670 +device_write_45156 device_write 3 45156 &ocfs2_remove_inode_range_45156
107671 +ocfs2_dq_frozen_trigger_45159 ocfs2_dq_frozen_trigger 4 45159 NULL
107672 +SYSC_write_45160 SYSC_write 3 45160 NULL
107673 +tomoyo_write_self_45161 tomoyo_write_self 3 45161 NULL
107674 +sta_agg_status_write_45164 sta_agg_status_write 3 45164 NULL
107675 +sctp_pack_cookie_45190 sctp_pack_cookie 6 45190 NULL nohasharray
107676 +snd_sb_csp_load_user_45190 snd_sb_csp_load_user 3 45190 &sctp_pack_cookie_45190
107677 +num_clusters_in_group_45194 num_clusters_in_group 2 45194 NULL
107678 +__radix_tree_preload_45197 __radix_tree_preload 0 45197 NULL
107679 +iso_alloc_urb_45206 iso_alloc_urb 4-5 45206 NULL
107680 +spi_alloc_master_45223 spi_alloc_master 2 45223 NULL
107681 +__dirty_45228 __dirty 2 45228 NULL
107682 +ieee80211_if_read_peer_45233 ieee80211_if_read_peer 3 45233 NULL
107683 +event_enable_write_45238 event_enable_write 3 45238 NULL
107684 +prism2_pda_proc_read_45246 prism2_pda_proc_read 3 45246 NULL
107685 +input_mt_init_slots_45279 input_mt_init_slots 2 45279 NULL
107686 +gfs2_fiemap_45282 gfs2_fiemap 4 45282 NULL
107687 +snd_pcm_oss_sync1_45298 snd_pcm_oss_sync1 2 45298 NULL
107688 +e1000_tx_map_45309 e1000_tx_map 5 45309 NULL
107689 +pte_val_45313 pte_val 0 45313 NULL
107690 +copy_vm86_regs_from_user_45340 copy_vm86_regs_from_user 3 45340 NULL
107691 +null_alloc_repbuf_45375 null_alloc_repbuf 3 45375 NULL
107692 +sock_recv_errqueue_45412 sock_recv_errqueue 3 45412 NULL
107693 +paging64_gva_to_gpa_45421 paging64_gva_to_gpa 2 45421 NULL nohasharray
107694 +ieee80211_if_fmt_dot11MeshHWMProotInterval_45421 ieee80211_if_fmt_dot11MeshHWMProotInterval 3 45421 &paging64_gva_to_gpa_45421
107695 +alloc_task_struct_node_45426 alloc_task_struct_node 1 45426 NULL
107696 +ll_iocontrol_register_45430 ll_iocontrol_register 2 45430 NULL
107697 +tty_buffer_alloc_45437 tty_buffer_alloc 2 45437 NULL
107698 +SYSC_mremap_45446 SYSC_mremap 5-1-2-3 45446 NULL
107699 +__node_remap_45458 __node_remap 4 45458 NULL
107700 +rds_ib_set_wr_signal_state_45463 rds_ib_set_wr_signal_state 0 45463 NULL
107701 +tracing_read_dyn_info_45468 tracing_read_dyn_info 3 45468 NULL
107702 +snd_pcm_hwsync_45479 snd_pcm_hwsync 0 45479 NULL
107703 +arizona_init_fll_45503 arizona_init_fll 5 45503 NULL
107704 +rds_message_copy_from_user_45510 rds_message_copy_from_user 3 45510 NULL
107705 +i40e_alloc_vfs_45511 i40e_alloc_vfs 2 45511 NULL
107706 +__split_vma_45522 __split_vma 0 45522 NULL
107707 +cgroup_read_u64_45532 cgroup_read_u64 5 45532 NULL
107708 +copy_macs_45534 copy_macs 4 45534 NULL
107709 +nla_attr_size_45545 nla_attr_size 0-1 45545 NULL
107710 +v9fs_direct_read_45546 v9fs_direct_read 3 45546 NULL
107711 +cx18_copy_mdl_to_user_45549 cx18_copy_mdl_to_user 4 45549 NULL
107712 +ext3_group_first_block_no_45555 ext3_group_first_block_no 0-2 45555 NULL
107713 +stats_dot11ACKFailureCount_read_45558 stats_dot11ACKFailureCount_read 3 45558 NULL
107714 +_regmap_bus_raw_write_45559 _regmap_bus_raw_write 2 45559 NULL
107715 +posix_acl_xattr_size_45561 posix_acl_xattr_size 0-1 45561 NULL
107716 +venus_rmdir_45564 venus_rmdir 4 45564 NULL
107717 +btrfs_find_free_ino_45585 btrfs_find_free_ino 0 45585 NULL
107718 +ipath_create_cq_45586 ipath_create_cq 2 45586 NULL
107719 +ath6kl_keepalive_write_45600 ath6kl_keepalive_write 3 45600 NULL
107720 +hidraw_get_report_45609 hidraw_get_report 3 45609 NULL
107721 +commit_cowonly_roots_45640 commit_cowonly_roots 0 45640 NULL
107722 +ebitmap_next_positive_45651 ebitmap_next_positive 3-0 45651 NULL
107723 +ext4_reserve_inode_write_45654 ext4_reserve_inode_write 0 45654 NULL
107724 +dma_map_cont_45668 dma_map_cont 5 45668 NULL
107725 +compat_mpctl_ioctl_45671 compat_mpctl_ioctl 2 45671 NULL
107726 +dgram_sendmsg_45679 dgram_sendmsg 4 45679 NULL
107727 +smk_write_ambient_45691 smk_write_ambient 3 45691 NULL
107728 +unix_dgram_sendmsg_45699 unix_dgram_sendmsg 4 45699 NULL nohasharray
107729 +bscnl_emit_45699 bscnl_emit 0-2-5 45699 &unix_dgram_sendmsg_45699
107730 +sg_proc_write_adio_45704 sg_proc_write_adio 3 45704 NULL
107731 +snd_cs46xx_io_read_45734 snd_cs46xx_io_read 5 45734 NULL nohasharray
107732 +task_cgroup_path_45734 task_cgroup_path 3 45734 &snd_cs46xx_io_read_45734
107733 +rw_copy_check_uvector_45748 rw_copy_check_uvector 3-0 45748 NULL nohasharray
107734 +v4l2_ctrl_new_std_45748 v4l2_ctrl_new_std 5 45748 &rw_copy_check_uvector_45748
107735 +lkdtm_debugfs_read_45752 lkdtm_debugfs_read 3 45752 NULL
107736 +btrfs_delete_delayed_dir_index_45757 btrfs_delete_delayed_dir_index 0 45757 NULL
107737 +alloc_ts_config_45775 alloc_ts_config 1 45775 NULL
107738 +osc_checksum_type_seq_write_45785 osc_checksum_type_seq_write 3 45785 NULL
107739 +raw_setsockopt_45800 raw_setsockopt 5 45800 NULL
107740 +rds_tcp_inc_copy_to_user_45804 rds_tcp_inc_copy_to_user 3 45804 NULL
107741 +lbs_rdbbp_read_45805 lbs_rdbbp_read 3 45805 NULL
107742 +pcpu_alloc_alloc_info_45813 pcpu_alloc_alloc_info 1-2 45813 NULL
107743 +ll_max_readahead_mb_seq_write_45815 ll_max_readahead_mb_seq_write 3 45815 NULL
107744 +fm_v4l2_init_video_device_45821 fm_v4l2_init_video_device 2 45821 NULL
107745 +memcg_update_cache_size_45828 memcg_update_cache_size 2 45828 NULL
107746 +task_state_char_45839 task_state_char 1 45839 NULL
107747 +__ip_select_ident_45851 __ip_select_ident 3 45851 NULL
107748 +x509_process_extension_45854 x509_process_extension 5 45854 NULL
107749 +efx_tx_queue_insert_45859 efx_tx_queue_insert 2 45859 NULL
107750 +isdn_write_45863 isdn_write 3 45863 NULL
107751 +unpack_orig_pfns_45867 unpack_orig_pfns 0 45867 NULL
107752 +tpm_config_in_45880 tpm_config_in 0 45880 NULL
107753 +get_rdac_req_45882 get_rdac_req 3 45882 NULL
107754 +ocfs2_xattr_block_find_45891 ocfs2_xattr_block_find 0 45891 NULL
107755 +online_page_cgroup_45894 online_page_cgroup 3 45894 NULL
107756 +cfs_cpt_weight_45903 cfs_cpt_weight 0 45903 NULL
107757 +wm_adsp_region_to_reg_45915 wm_adsp_region_to_reg 0-2 45915 NULL
107758 +dbgfs_frame_45917 dbgfs_frame 3 45917 NULL
107759 +alloc_mr_45935 alloc_mr 1 45935 NULL
107760 +kmem_cache_alloc_node_trace_45968 kmem_cache_alloc_node_trace 3 45968 NULL
107761 +copy_to_45969 copy_to 3 45969 NULL
107762 +rb_simple_read_45972 rb_simple_read 3 45972 NULL
107763 +ioat2_dca_count_dca_slots_45984 ioat2_dca_count_dca_slots 0 45984 NULL
107764 +ore_calc_stripe_info_46023 ore_calc_stripe_info 2 46023 NULL
107765 +sierra_setup_urb_46029 sierra_setup_urb 5 46029 NULL
107766 +get_free_entries_46030 get_free_entries 1 46030 NULL
107767 +__access_remote_vm_46031 __access_remote_vm 0-3-5 46031 NULL
107768 +snd_emu10k1x_ptr_read_46049 snd_emu10k1x_ptr_read 0 46049 NULL
107769 +acpi_register_gsi_xen_hvm_46052 acpi_register_gsi_xen_hvm 2 46052 NULL
107770 +__ocfs2_move_extent_46060 __ocfs2_move_extent 5-6-4-0-3 46060 NULL nohasharray
107771 +dma_tx_errors_read_46060 dma_tx_errors_read 3 46060 &__ocfs2_move_extent_46060
107772 +sel_commit_bools_write_46077 sel_commit_bools_write 3 46077 NULL
107773 +arizona_set_irq_wake_46101 arizona_set_irq_wake 2 46101 NULL
107774 +memcg_update_array_size_46111 memcg_update_array_size 1 46111 NULL nohasharray
107775 +il3945_ucode_general_stats_read_46111 il3945_ucode_general_stats_read 3 46111 &memcg_update_array_size_46111
107776 +C_SYSC_writev_46113 C_SYSC_writev 3 46113 NULL
107777 +mlx4_ib_alloc_fast_reg_page_list_46119 mlx4_ib_alloc_fast_reg_page_list 2 46119 NULL
107778 +paging32_walk_addr_nested_46121 paging32_walk_addr_nested 3 46121 NULL
107779 +replay_dir_deletes_46136 replay_dir_deletes 0 46136 NULL
107780 +rtw_buf_update_46138 rtw_buf_update 4 46138 NULL
107781 +vb2_dma_sg_get_userptr_46146 vb2_dma_sg_get_userptr 2-3 46146 NULL
107782 +__netlink_change_ngroups_46156 __netlink_change_ngroups 2 46156 NULL
107783 +alloc_iova_46160 alloc_iova 2 46160 NULL
107784 +twl_direction_out_46182 twl_direction_out 2 46182 NULL
107785 +vxge_os_dma_malloc_46184 vxge_os_dma_malloc 2 46184 NULL
107786 +fq_resize_46195 fq_resize 2 46195 NULL
107787 +add_conn_list_46197 add_conn_list 3-0 46197 NULL
107788 +i2400m_op_msg_from_user_46213 i2400m_op_msg_from_user 4 46213 NULL
107789 +tm6000_i2c_recv_regs_46215 tm6000_i2c_recv_regs 5 46215 NULL
107790 +dsp_write_46218 dsp_write 2 46218 NULL
107791 +xen_setup_msi_irqs_46245 xen_setup_msi_irqs 2 46245 NULL
107792 +mpi_read_raw_data_46248 mpi_read_raw_data 2 46248 NULL
107793 +ReadReg_46277 ReadReg 0 46277 NULL
107794 +sg_proc_write_dressz_46316 sg_proc_write_dressz 3 46316 NULL
107795 +__hwahc_dev_set_key_46328 __hwahc_dev_set_key 5 46328 NULL nohasharray
107796 +compat_SyS_readv_46328 compat_SyS_readv 3 46328 &__hwahc_dev_set_key_46328
107797 +iwl_dbgfs_chain_noise_read_46355 iwl_dbgfs_chain_noise_read 3 46355 NULL
107798 +smk_write_direct_46363 smk_write_direct 3 46363 NULL
107799 +__iommu_calculate_agaw_46366 __iommu_calculate_agaw 2 46366 NULL
107800 +ubi_dump_flash_46381 ubi_dump_flash 4 46381 NULL
107801 +mmap_ureg_46388 mmap_ureg 3 46388 NULL
107802 +vma_adjust_46390 vma_adjust 0 46390 NULL
107803 +fuse_file_aio_write_46399 fuse_file_aio_write 4 46399 NULL
107804 +crypto_ablkcipher_reqsize_46411 crypto_ablkcipher_reqsize 0 46411 NULL
107805 +ttm_page_pool_get_pages_46431 ttm_page_pool_get_pages 0-5 46431 NULL
107806 +cfs_power2_roundup_46433 cfs_power2_roundup 0-1 46433 NULL
107807 +hash_ipportip6_expire_46443 hash_ipportip6_expire 3 46443 NULL
107808 +cp210x_set_config_46447 cp210x_set_config 4 46447 NULL
107809 +parport_pc_fifo_write_block_46455 parport_pc_fifo_write_block 3 46455 NULL
107810 +il_dbgfs_clear_traffic_stats_write_46458 il_dbgfs_clear_traffic_stats_write 3 46458 NULL
107811 +filldir64_46469 filldir64 3 46469 NULL
107812 +ocfs2_reserve_clusters_with_limit_46479 ocfs2_reserve_clusters_with_limit 0 46479 NULL
107813 +fill_in_write_vector_46498 fill_in_write_vector 0 46498 NULL
107814 +p9pdu_vreadf_46500 p9pdu_vreadf 0 46500 NULL
107815 +pin_code_reply_46510 pin_code_reply 4 46510 NULL
107816 +mthca_alloc_cq_buf_46512 mthca_alloc_cq_buf 3 46512 NULL
107817 +nouveau_drm_ioctl_46514 nouveau_drm_ioctl 2 46514 NULL nohasharray
107818 +kmsg_read_46514 kmsg_read 3 46514 &nouveau_drm_ioctl_46514
107819 +bdx_rxdb_create_46525 bdx_rxdb_create 1 46525 NULL
107820 +nl80211_send_rx_assoc_46538 nl80211_send_rx_assoc 4 46538 NULL
107821 +pm860x_irq_domain_map_46553 pm860x_irq_domain_map 2 46553 NULL
107822 +link_send_sections_long_46556 link_send_sections_long 4 46556 NULL
107823 +dn_current_mss_46574 dn_current_mss 0 46574 NULL nohasharray
107824 +blk_flush_complete_seq_46574 blk_flush_complete_seq 2 46574 &dn_current_mss_46574
107825 +serverworks_create_gatt_pages_46582 serverworks_create_gatt_pages 1 46582 NULL
107826 +snd_compr_write_data_46592 snd_compr_write_data 3 46592 NULL
107827 +il3945_stats_flag_46606 il3945_stats_flag 0-3 46606 NULL
107828 +vscnprintf_46617 vscnprintf 0-2 46617 NULL
107829 +__kfifo_out_r_46623 __kfifo_out_r 3-0 46623 NULL
107830 +request_key_async_with_auxdata_46624 request_key_async_with_auxdata 4 46624 NULL
107831 +pci_enable_device_46642 pci_enable_device 0 46642 NULL
107832 +vfs_getxattr_alloc_46649 vfs_getxattr_alloc 0 46649 NULL
107833 +av7110_ipack_init_46655 av7110_ipack_init 2 46655 NULL
107834 +e1000_tx_map_46672 e1000_tx_map 4 46672 NULL
107835 +alloc_data_packet_46698 alloc_data_packet 1 46698 NULL
107836 +__ilog2_u32_46706 __ilog2_u32 0 46706 NULL
107837 +erst_dbg_write_46715 erst_dbg_write 3 46715 NULL
107838 +ide_read_status_46719 ide_read_status 0 46719 NULL
107839 +wl1271_rx_filter_alloc_field_46721 wl1271_rx_filter_alloc_field 5 46721 NULL
107840 +irq_domain_add_simple_46734 irq_domain_add_simple 2-3 46734 NULL
107841 +ext4_count_free_46754 ext4_count_free 2 46754 NULL nohasharray
107842 +pte_pfn_46754 pte_pfn 0 46754 &ext4_count_free_46754
107843 +hest_ghes_dev_register_46766 hest_ghes_dev_register 1 46766 NULL
107844 +int_hw_irq_en_46776 int_hw_irq_en 3 46776 NULL
107845 +regcache_lzo_sync_46777 regcache_lzo_sync 2 46777 NULL
107846 +_xfs_buf_get_pages_46811 _xfs_buf_get_pages 2 46811 NULL
107847 +btrfs_insert_empty_items_46822 btrfs_insert_empty_items 0 46822 NULL
107848 +xfs_iroot_realloc_46826 xfs_iroot_realloc 2 46826 NULL
107849 +shmem_pwrite_fast_46842 shmem_pwrite_fast 3 46842 NULL
107850 +readreg_46845 readreg 0 46845 NULL
107851 +spi_async_46857 spi_async 0 46857 NULL
107852 +vsnprintf_46863 vsnprintf 0 46863 NULL nohasharray
107853 +SyS_move_pages_46863 SyS_move_pages 2 46863 &vsnprintf_46863
107854 +nvme_alloc_queue_46865 nvme_alloc_queue 3 46865 NULL
107855 +rvmalloc_46873 rvmalloc 1 46873 NULL
107856 +qp_memcpy_from_queue_iov_46874 qp_memcpy_from_queue_iov 5-4 46874 NULL
107857 +lov_iocontrol_46876 lov_iocontrol 3 46876 NULL
107858 +stmpe_gpio_irq_unmap_46884 stmpe_gpio_irq_unmap 2 46884 NULL
107859 +ixgbe_dbg_reg_ops_write_46895 ixgbe_dbg_reg_ops_write 3 46895 NULL
107860 +sk_mem_pages_46896 sk_mem_pages 0-1 46896 NULL
107861 +ol_dqblk_off_46904 ol_dqblk_off 2-3 46904 NULL
107862 +ieee80211_if_fmt_power_mode_46906 ieee80211_if_fmt_power_mode 3 46906 NULL
107863 +wlcore_alloc_hw_46917 wlcore_alloc_hw 1-3 46917 NULL
107864 +fb_write_46924 fb_write 3 46924 NULL
107865 +i915_gem_check_olr_46925 i915_gem_check_olr 0 46925 NULL
107866 +kvm_register_read_46948 kvm_register_read 0 46948 NULL
107867 +__sctp_setsockopt_connectx_46949 __sctp_setsockopt_connectx 3 46949 NULL
107868 +qla4xxx_post_aen_work_46953 qla4xxx_post_aen_work 3 46953 NULL
107869 +SYSC_poll_46965 SYSC_poll 2 46965 NULL
107870 +crypto_tfm_alg_alignmask_46971 crypto_tfm_alg_alignmask 0 46971 NULL
107871 +mgmt_pending_add_46976 mgmt_pending_add 5 46976 NULL
107872 +strlcat_46985 strlcat 3 46985 NULL
107873 +bitmap_file_clear_bit_46990 bitmap_file_clear_bit 2 46990 NULL
107874 +gfs2_xattr_system_set_46996 gfs2_xattr_system_set 4 46996 NULL nohasharray
107875 +sel_write_bool_46996 sel_write_bool 3 46996 &gfs2_xattr_system_set_46996
107876 +ttm_bo_io_47000 ttm_bo_io 5 47000 NULL
107877 +blk_rq_map_kern_47004 blk_rq_map_kern 4 47004 NULL
107878 +__map_single_47020 __map_single 3-4-7-0 47020 NULL
107879 +cx231xx_init_bulk_47024 cx231xx_init_bulk 3-2-4 47024 NULL
107880 +fs_path_len_47060 fs_path_len 0 47060 NULL
107881 +ufs_new_fragments_47070 ufs_new_fragments 4-3-5 47070 NULL nohasharray
107882 +ext4_xattr_list_entries_47070 ext4_xattr_list_entries 0-4 47070 &ufs_new_fragments_47070
107883 +pipeline_dec_packet_in_read_47076 pipeline_dec_packet_in_read 3 47076 NULL
107884 +scsi_deactivate_tcq_47086 scsi_deactivate_tcq 2 47086 NULL
107885 +iwl_dump_nic_event_log_47089 iwl_dump_nic_event_log 0 47089 NULL
107886 +ptlrpc_lprocfs_threads_max_seq_write_47104 ptlrpc_lprocfs_threads_max_seq_write 3 47104 NULL
107887 +tboot_log_read_47110 tboot_log_read 3 47110 NULL
107888 +mousedev_read_47123 mousedev_read 3 47123 NULL
107889 +ubi_compare_lebs_47141 ubi_compare_lebs 0 47141 NULL
107890 +ses_recv_diag_47143 ses_recv_diag 4 47143 NULL nohasharray
107891 +acpi_ut_initialize_buffer_47143 acpi_ut_initialize_buffer 2 47143 &ses_recv_diag_47143
107892 +mxms_headerlen_47161 mxms_headerlen 0 47161 NULL
107893 +rs_sta_dbgfs_rate_scale_data_read_47165 rs_sta_dbgfs_rate_scale_data_read 3 47165 NULL
107894 +bpf_alloc_binary_47170 bpf_alloc_binary 1 47170 NULL
107895 +rts51x_ms_rw_47171 rts51x_ms_rw 3-4 47171 NULL
107896 +btrfs_del_inode_ref_47181 btrfs_del_inode_ref 0 47181 NULL
107897 +can_set_system_xattr_47182 can_set_system_xattr 4 47182 NULL
107898 +options_write_47243 options_write 3 47243 NULL
107899 +portcntrs_1_read_47253 portcntrs_1_read 3 47253 NULL
107900 +da9052_disable_irq_nosync_47260 da9052_disable_irq_nosync 2 47260 NULL
107901 +p9pdu_readf_47269 p9pdu_readf 0 47269 NULL
107902 +ablkcipher_next_slow_47274 ablkcipher_next_slow 3-4 47274 NULL
107903 +gfs2_readpages_47285 gfs2_readpages 4 47285 NULL
107904 +vsnprintf_47291 vsnprintf 0 47291 NULL
107905 +tx_internal_desc_overflow_read_47300 tx_internal_desc_overflow_read 3 47300 NULL
107906 +iterate_inode_ref_47322 iterate_inode_ref 0 47322 NULL
107907 +SyS_madvise_47354 SyS_madvise 1-2 47354 NULL
107908 +ieee80211_if_read_dot11MeshHoldingTimeout_47356 ieee80211_if_read_dot11MeshHoldingTimeout 3 47356 NULL
107909 +avc_get_hash_stats_47359 avc_get_hash_stats 0 47359 NULL
107910 +find_first_zero_bit_le_47369 find_first_zero_bit_le 2 47369 NULL
107911 +__bio_map_kern_47379 __bio_map_kern 3 47379 NULL
107912 +nv_rd32_47390 nv_rd32 0 47390 NULL nohasharray
107913 +trace_options_core_read_47390 trace_options_core_read 3 47390 &nv_rd32_47390
107914 +nametbl_list_47391 nametbl_list 2 47391 NULL
107915 +dgrp_net_write_47392 dgrp_net_write 3 47392 NULL
107916 +pfkey_sendmsg_47394 pfkey_sendmsg 4 47394 NULL
107917 +gfn_to_pfn_prot_47398 gfn_to_pfn_prot 2 47398 NULL
107918 +lbs_wrmac_write_47400 lbs_wrmac_write 3 47400 NULL
107919 +ocfs2_resv_end_47408 ocfs2_resv_end 0 47408 NULL
107920 +sta_vht_capa_read_47409 sta_vht_capa_read 3 47409 NULL
107921 +crypto_ablkcipher_alignmask_47410 crypto_ablkcipher_alignmask 0 47410 NULL
107922 +lbs_wrrf_write_47418 lbs_wrrf_write 3 47418 NULL
107923 +vzalloc_47421 vzalloc 1 47421 NULL
107924 +hash_ipportip4_expire_47426 hash_ipportip4_expire 3 47426 NULL
107925 +posix_acl_from_disk_47445 posix_acl_from_disk 2 47445 NULL
107926 +numaq_apicid_to_cpu_present_47449 numaq_apicid_to_cpu_present 1 47449 NULL
107927 +environ_read_47451 environ_read 3 47451 NULL
107928 +__load_mapping_47460 __load_mapping 2 47460 NULL
107929 +try_lock_extent_47465 try_lock_extent 0 47465 NULL
107930 +nvme_trans_send_fw_cmd_47479 nvme_trans_send_fw_cmd 4 47479 NULL
107931 +wb_force_mapping_47485 wb_force_mapping 2 47485 NULL nohasharray
107932 +newpart_47485 newpart 6-4 47485 &wb_force_mapping_47485
107933 +mcp23s17_read_regs_47491 mcp23s17_read_regs 4 47491 NULL
107934 +core_sys_select_47494 core_sys_select 1 47494 NULL
107935 +read_block_for_search_47502 read_block_for_search 0 47502 NULL
107936 +alloc_arraycache_47505 alloc_arraycache 2-1 47505 NULL nohasharray
107937 +btrfs_init_inode_security_47505 btrfs_init_inode_security 0 47505 &alloc_arraycache_47505
107938 +unlink_simple_47506 unlink_simple 3 47506 NULL
107939 +pstore_decompress_47510 pstore_decompress 0 47510 NULL
107940 +ufs_inode_getblock_47512 ufs_inode_getblock 4 47512 NULL
107941 +__proc_lnet_portal_rotor_47529 __proc_lnet_portal_rotor 5 47529 NULL
107942 +snd_pcm_resume_47530 snd_pcm_resume 0 47530 NULL
107943 +vscnprintf_47533 vscnprintf 0-2 47533 NULL nohasharray
107944 +process_vm_rw_47533 process_vm_rw 3-5 47533 &vscnprintf_47533
107945 +einj_check_trigger_header_47534 einj_check_trigger_header 0 47534 NULL
107946 +ieee80211_if_fmt_min_discovery_timeout_47539 ieee80211_if_fmt_min_discovery_timeout 3 47539 NULL
107947 +ocfs2_resv_find_window_47557 ocfs2_resv_find_window 3 47557 NULL
107948 +read_ldt_47570 read_ldt 2 47570 NULL
107949 +isku_sysfs_read_last_set_47572 isku_sysfs_read_last_set 6 47572 NULL
107950 +rpipe_get_idx_47579 rpipe_get_idx 2-0 47579 NULL
107951 +SYSC_fcntl64_47581 SYSC_fcntl64 3 47581 NULL
107952 +vendorextnReadSection_47583 vendorextnReadSection 0 47583 NULL
107953 +btrfs_stack_header_bytenr_47589 btrfs_stack_header_bytenr 0 47589 NULL
107954 +ext4_kvzalloc_47605 ext4_kvzalloc 1 47605 NULL
107955 +sctp_ssnmap_new_47608 sctp_ssnmap_new 2-1 47608 NULL
107956 +cache_read_pipefs_47615 cache_read_pipefs 3 47615 NULL
107957 +twl4030_clear_set_47624 twl4030_clear_set 4 47624 NULL
107958 +irq_set_chip_47638 irq_set_chip 1 47638 NULL
107959 +get_size_47644 get_size 1-2 47644 NULL
107960 +snd_pcm_info_47699 snd_pcm_info 0 47699 NULL
107961 +packet_recvmsg_47700 packet_recvmsg 4 47700 NULL nohasharray
107962 +ipath_format_hwmsg_47700 ipath_format_hwmsg 2 47700 &packet_recvmsg_47700
107963 +global_rt_runtime_47712 global_rt_runtime 0 47712 NULL
107964 +save_microcode_47717 save_microcode 3 47717 NULL
107965 +bits_to_user_47733 bits_to_user 3-2 47733 NULL
107966 +carl9170_debugfs_read_47738 carl9170_debugfs_read 3 47738 NULL
107967 +ir_prepare_write_buffer_47747 ir_prepare_write_buffer 3 47747 NULL
107968 +mvumi_alloc_mem_resource_47750 mvumi_alloc_mem_resource 3 47750 NULL
107969 +ext3_find_near_47752 ext3_find_near 0 47752 NULL
107970 +alloc_sched_domains_47756 alloc_sched_domains 1 47756 NULL
107971 +uwb_ie_dump_hex_47774 uwb_ie_dump_hex 4 47774 NULL
107972 +SyS_setgroups16_47780 SyS_setgroups16 1 47780 NULL
107973 +error_error_numll_frame_cts_start_read_47781 error_error_numll_frame_cts_start_read 3 47781 NULL
107974 +posix_acl_fix_xattr_from_user_47793 posix_acl_fix_xattr_from_user 2 47793 NULL
107975 +W6692_empty_Bfifo_47804 W6692_empty_Bfifo 2 47804 NULL
107976 +lov_packmd_47810 lov_packmd 0 47810 NULL
107977 +pinconf_dbg_config_write_47835 pinconf_dbg_config_write 3 47835 NULL
107978 +KEY_SIZE_47855 KEY_SIZE 0 47855 NULL
107979 +ubifs_unpack_nnode_47866 ubifs_unpack_nnode 0 47866 NULL
107980 +vhci_read_47878 vhci_read 3 47878 NULL
107981 +ubi_wl_put_peb_47886 ubi_wl_put_peb 0 47886 NULL
107982 +keyctl_instantiate_key_common_47889 keyctl_instantiate_key_common 4 47889 NULL
107983 +load_mapping_47904 load_mapping 3 47904 NULL
107984 +btrfs_duplicate_item_47910 btrfs_duplicate_item 0 47910 NULL
107985 +cfs_percpt_alloc_47918 cfs_percpt_alloc 2 47918 NULL
107986 +comedi_write_47926 comedi_write 3 47926 NULL
107987 +nvme_trans_get_blk_desc_len_47946 nvme_trans_get_blk_desc_len 0-2 47946 NULL
107988 +lp8788_irq_map_47964 lp8788_irq_map 2 47964 NULL
107989 +gether_get_ifname_47972 gether_get_ifname 3 47972 NULL
107990 +iwl_dbgfs_ucode_tracing_read_47983 iwl_dbgfs_ucode_tracing_read 3 47983 NULL nohasharray
107991 +mempool_resize_47983 mempool_resize 2 47983 &iwl_dbgfs_ucode_tracing_read_47983
107992 +dbg_port_buf_47990 dbg_port_buf 2 47990 NULL
107993 +ib_umad_write_47993 ib_umad_write 3 47993 NULL
107994 +ocfs2_find_refcount_split_pos_48001 ocfs2_find_refcount_split_pos 0 48001 NULL
107995 +lustre_cfg_len_48002 lustre_cfg_len 0 48002 NULL
107996 +gdm_tty_recv_complete_48011 gdm_tty_recv_complete 2 48011 NULL
107997 +ffs_epfile_write_48014 ffs_epfile_write 3 48014 NULL
107998 +bio_integrity_set_tag_48035 bio_integrity_set_tag 3 48035 NULL
107999 +pppoe_sendmsg_48039 pppoe_sendmsg 4 48039 NULL
108000 +SYSC_writev_48040 SYSC_writev 3 48040 NULL
108001 +btrfs_reserve_extent_48044 btrfs_reserve_extent 6 48044 NULL
108002 +wpan_phy_alloc_48056 wpan_phy_alloc 1 48056 NULL
108003 +ocfs2_change_refcount_rec_48059 ocfs2_change_refcount_rec 0 48059 NULL
108004 +posix_acl_alloc_48063 posix_acl_alloc 1 48063 NULL
108005 +palmas_bulk_write_48068 palmas_bulk_write 2-3-5 48068 NULL
108006 +disc_write_48070 disc_write 3 48070 NULL
108007 +mmc_alloc_host_48097 mmc_alloc_host 1 48097 NULL
108008 +skb_copy_datagram_const_iovec_48102 skb_copy_datagram_const_iovec 4-2-5-0 48102 NULL
108009 +radio_isa_common_probe_48107 radio_isa_common_probe 3 48107 NULL
108010 +vmw_framebuffer_surface_dirty_48132 vmw_framebuffer_surface_dirty 6 48132 NULL
108011 +set_discoverable_48141 set_discoverable 4 48141 NULL
108012 +dn_fib_count_nhs_48145 dn_fib_count_nhs 0 48145 NULL
108013 +get_cur_inode_state_48149 get_cur_inode_state 0 48149 NULL
108014 +_add_to_r4w_48152 _add_to_r4w 4 48152 NULL nohasharray
108015 +bitmap_onto_48152 bitmap_onto 4 48152 &_add_to_r4w_48152
108016 +isr_dma1_done_read_48159 isr_dma1_done_read 3 48159 NULL
108017 +c4iw_id_table_alloc_48163 c4iw_id_table_alloc 3 48163 NULL
108018 +ocfs2_find_next_zero_bit_unaligned_48170 ocfs2_find_next_zero_bit_unaligned 2-3 48170 NULL nohasharray
108019 +rbd_obj_method_sync_48170 rbd_obj_method_sync 8 48170 &ocfs2_find_next_zero_bit_unaligned_48170
108020 +alloc_cc770dev_48186 alloc_cc770dev 1 48186 NULL
108021 +init_ipath_48187 init_ipath 1 48187 NULL
108022 +brcmf_sdio_chip_cm3_exitdl_48192 brcmf_sdio_chip_cm3_exitdl 4 48192 NULL
108023 +cfg80211_process_deauth_48200 cfg80211_process_deauth 3 48200 NULL
108024 +ext4_index_trans_blocks_48205 ext4_index_trans_blocks 0-2 48205 NULL
108025 +snd_seq_dump_var_event_48209 snd_seq_dump_var_event 0 48209 NULL
108026 +ll_direct_IO_26_48216 ll_direct_IO_26 4 48216 NULL
108027 +is_block_in_journal_48223 is_block_in_journal 3 48223 NULL
108028 +uv_blade_nr_possible_cpus_48226 uv_blade_nr_possible_cpus 0 48226 NULL
108029 +nilfs_readpages_48229 nilfs_readpages 4 48229 NULL
108030 +read_file_recv_48232 read_file_recv 3 48232 NULL
108031 +unaccount_shadowed_48233 unaccount_shadowed 2 48233 NULL nohasharray
108032 +blk_rq_pos_48233 blk_rq_pos 0 48233 &unaccount_shadowed_48233
108033 +nouveau_i2c_port_create__48240 nouveau_i2c_port_create_ 7 48240 NULL
108034 +nfsctl_transaction_read_48250 nfsctl_transaction_read 3 48250 NULL
108035 +batadv_socket_read_48257 batadv_socket_read 3 48257 NULL
108036 +cache_write_pipefs_48270 cache_write_pipefs 3 48270 NULL
108037 +trace_options_write_48275 trace_options_write 3 48275 NULL
108038 +send_set_info_48288 send_set_info 7 48288 NULL
108039 +lpfc_idiag_extacc_read_48301 lpfc_idiag_extacc_read 3 48301 NULL
108040 +timblogiw_read_48305 timblogiw_read 3 48305 NULL
108041 +hash_setkey_48310 hash_setkey 3 48310 NULL
108042 +audio_set_intf_req_48319 audio_set_intf_req 0 48319 NULL
108043 +kvm_mmu_pte_write_48340 kvm_mmu_pte_write 2 48340 NULL
108044 +__alloc_fd_48356 __alloc_fd 2 48356 NULL
108045 +skb_add_data_48363 skb_add_data 3 48363 NULL
108046 +tx_frag_init_called_read_48377 tx_frag_init_called_read 3 48377 NULL
108047 +lbs_debugfs_write_48413 lbs_debugfs_write 3 48413 NULL
108048 +uhid_event_from_user_48417 uhid_event_from_user 2 48417 NULL
108049 +div64_u64_rem_48418 div64_u64_rem 0-1-2 48418 NULL
108050 +snd_power_wait_48422 snd_power_wait 0 48422 NULL
108051 +pwr_tx_without_ps_read_48423 pwr_tx_without_ps_read 3 48423 NULL
108052 +hugepage_madvise_48435 hugepage_madvise 0 48435 NULL
108053 +print_filtered_48442 print_filtered 2-0 48442 NULL
108054 +tun_recvmsg_48463 tun_recvmsg 4 48463 NULL
108055 +compat_SyS_preadv64_48469 compat_SyS_preadv64 3 48469 NULL
108056 +ipath_format_hwerrors_48487 ipath_format_hwerrors 5 48487 NULL
108057 +r8712_usbctrl_vendorreq_48489 r8712_usbctrl_vendorreq 6 48489 NULL
108058 +ocfs2_refcount_cow_48495 ocfs2_refcount_cow 3 48495 NULL
108059 +send_control_msg_48498 send_control_msg 6 48498 NULL
108060 +mlx4_en_create_tx_ring_48501 mlx4_en_create_tx_ring 4 48501 NULL
108061 +count_masked_bytes_48507 count_masked_bytes 0-1 48507 NULL
108062 +diva_os_copy_to_user_48508 diva_os_copy_to_user 4 48508 NULL
108063 +brcmf_sdio_trap_info_48510 brcmf_sdio_trap_info 4 48510 NULL
108064 +phantom_get_free_48514 phantom_get_free 0 48514 NULL
108065 +drbd_bm_capacity_48530 drbd_bm_capacity 0 48530 NULL
108066 +ext3_splice_branch_48531 ext3_splice_branch 6 48531 NULL
108067 +raid10_size_48571 raid10_size 0-2-3 48571 NULL
108068 +llog_data_len_48607 llog_data_len 1 48607 NULL
108069 +ufs_dtogd_48616 ufs_dtogd 0-2 48616 NULL
108070 +do_ip_vs_set_ctl_48641 do_ip_vs_set_ctl 4 48641 NULL
108071 +ll_rw_extents_stats_pp_seq_write_48651 ll_rw_extents_stats_pp_seq_write 3 48651 NULL
108072 +mtd_read_48655 mtd_read 0 48655 NULL
108073 +aes_encrypt_packets_read_48666 aes_encrypt_packets_read 3 48666 NULL
108074 +ore_get_rw_state_48667 ore_get_rw_state 5-4 48667 NULL
108075 +sm501_create_subdev_48668 sm501_create_subdev 4-3 48668 NULL
108076 +ubi_eba_unmap_leb_48671 ubi_eba_unmap_leb 0 48671 NULL
108077 +hysdn_log_write_48694 hysdn_log_write 3 48694 NULL
108078 +altera_drscan_48698 altera_drscan 2 48698 NULL
108079 +kvm_set_irq_routing_48704 kvm_set_irq_routing 3 48704 NULL
108080 +recv_msg_48709 recv_msg 4 48709 NULL
108081 +lpfc_idiag_drbacc_write_48712 lpfc_idiag_drbacc_write 3 48712 NULL
108082 +SyS_lgetxattr_48719 SyS_lgetxattr 4 48719 NULL
108083 +ath6kl_usb_bmi_read_48745 ath6kl_usb_bmi_read 3 48745 NULL
108084 +ath6kl_regwrite_read_48747 ath6kl_regwrite_read 3 48747 NULL
108085 +event_buffer_read_48772 event_buffer_read 3 48772 NULL nohasharray
108086 +l2cap_segment_sdu_48772 l2cap_segment_sdu 4 48772 &event_buffer_read_48772
108087 +gfs2_direct_IO_48774 gfs2_direct_IO 4 48774 NULL
108088 +il3945_sta_dbgfs_stats_table_read_48802 il3945_sta_dbgfs_stats_table_read 3 48802 NULL
108089 +twa_change_queue_depth_48808 twa_change_queue_depth 2 48808 NULL
108090 +register_ftrace_profiler_48816 register_ftrace_profiler 0 48816 NULL
108091 +atomic_counters_read_48827 atomic_counters_read 3 48827 NULL
108092 +azx_get_position_48841 azx_get_position 0 48841 NULL
108093 +vc_do_resize_48842 vc_do_resize 4-3 48842 NULL
108094 +comedi_buf_write_alloc_48846 comedi_buf_write_alloc 0-2 48846 NULL
108095 +suspend_dtim_interval_write_48854 suspend_dtim_interval_write 3 48854 NULL
108096 +C_SYSC_pwritev64_48864 C_SYSC_pwritev64 3 48864 NULL nohasharray
108097 +viafb_dvp1_proc_write_48864 viafb_dvp1_proc_write 3 48864 &C_SYSC_pwritev64_48864
108098 +__ffs_ep0_read_events_48868 __ffs_ep0_read_events 3 48868 NULL
108099 +ext2_alloc_branch_48889 ext2_alloc_branch 4 48889 NULL
108100 +crypto_cipher_ctxsize_48890 crypto_cipher_ctxsize 0 48890 NULL
108101 +joydev_handle_JSIOCSAXMAP_48898 joydev_handle_JSIOCSAXMAP 3 48898 NULL
108102 +xdi_copy_to_user_48900 xdi_copy_to_user 4 48900 NULL
108103 +msg_hdr_sz_48908 msg_hdr_sz 0 48908 NULL
108104 +snd_pcm_update_hw_ptr_48925 snd_pcm_update_hw_ptr 0 48925 NULL
108105 +sep_crypto_dma_48937 sep_crypto_dma 0 48937 NULL
108106 +si5351_write_parameters_48940 si5351_write_parameters 2 48940 NULL
108107 +event_heart_beat_read_48961 event_heart_beat_read 3 48961 NULL
108108 +nand_ecc_test_run_48966 nand_ecc_test_run 1 48966 NULL
108109 +vmci_handle_arr_create_48971 vmci_handle_arr_create 1 48971 NULL
108110 +batadv_orig_hash_del_if_48972 batadv_orig_hash_del_if 2 48972 NULL
108111 +btrfs_delete_delayed_insertion_item_48981 btrfs_delete_delayed_insertion_item 0 48981 NULL
108112 +rds_rm_size_48996 rds_rm_size 0-2 48996 NULL
108113 +sel_write_enforce_48998 sel_write_enforce 3 48998 NULL
108114 +null_alloc_rs_49019 null_alloc_rs 2 49019 NULL
108115 +filemap_check_errors_49022 filemap_check_errors 0 49022 NULL
108116 +aic_inb_49023 aic_inb 0 49023 NULL
108117 +transient_status_49027 transient_status 4 49027 NULL
108118 +iwl_mvm_power_legacy_dbgfs_read_49038 iwl_mvm_power_legacy_dbgfs_read 4 49038 NULL nohasharray
108119 +ipath_reg_user_mr_49038 ipath_reg_user_mr 2-3 49038 &iwl_mvm_power_legacy_dbgfs_read_49038
108120 +aic7xxx_rem_scb_from_disc_list_49041 aic7xxx_rem_scb_from_disc_list 0 49041 NULL
108121 +setup_msi_irq_49052 setup_msi_irq 3-4 49052 NULL
108122 +ubi_read_49061 ubi_read 0 49061 NULL
108123 +scsi_register_49094 scsi_register 2 49094 NULL
108124 +paging64_walk_addr_nested_49100 paging64_walk_addr_nested 3 49100 NULL
108125 +compat_do_readv_writev_49102 compat_do_readv_writev 4 49102 NULL
108126 +xfrm_replay_state_esn_len_49119 xfrm_replay_state_esn_len 0 49119 NULL
108127 +ll_max_cached_mb_seq_write_49122 ll_max_cached_mb_seq_write 3 49122 NULL
108128 +qib_user_sdma_pin_pages_49136 qib_user_sdma_pin_pages 4-5-6 49136 NULL nohasharray
108129 +pt_read_49136 pt_read 3 49136 &qib_user_sdma_pin_pages_49136
108130 +read_file_49137 read_file 4 49137 NULL
108131 +ipwireless_tty_received_49154 ipwireless_tty_received 3 49154 NULL
108132 +f2fs_acl_count_49155 f2fs_acl_count 0-1 49155 NULL
108133 +ipw_queue_tx_init_49161 ipw_queue_tx_init 3 49161 NULL
108134 +ext4_free_clusters_after_init_49174 ext4_free_clusters_after_init 2 49174 NULL
108135 +__jfs_setxattr_49175 __jfs_setxattr 5 49175 NULL
108136 +ath6kl_bgscan_int_write_49178 ath6kl_bgscan_int_write 3 49178 NULL
108137 +dvb_dvr_ioctl_49182 dvb_dvr_ioctl 2 49182 NULL
108138 +print_queue_49191 print_queue 0 49191 NULL
108139 +root_nfs_cat_49192 root_nfs_cat 3 49192 NULL
108140 +iwl_dbgfs_ucode_general_stats_read_49199 iwl_dbgfs_ucode_general_stats_read 3 49199 NULL
108141 +il4965_rs_sta_dbgfs_stats_table_read_49206 il4965_rs_sta_dbgfs_stats_table_read 3 49206 NULL
108142 +do_jffs2_getxattr_49210 do_jffs2_getxattr 0 49210 NULL
108143 +resp_write_same_49217 resp_write_same 2 49217 NULL
108144 +nouveau_therm_create__49228 nouveau_therm_create_ 4 49228 NULL
108145 +hugetlb_cgroup_read_49259 hugetlb_cgroup_read 5 49259 NULL
108146 +ieee80211_if_read_rssi_threshold_49260 ieee80211_if_read_rssi_threshold 3 49260 NULL
108147 +isku_sysfs_read_keys_media_49268 isku_sysfs_read_keys_media 6 49268 NULL
108148 +ptlrpc_check_set_49277 ptlrpc_check_set 0 49277 NULL
108149 +rx_filter_beacon_filter_read_49279 rx_filter_beacon_filter_read 3 49279 NULL
108150 +__ext4_ext_dirty_49284 __ext4_ext_dirty 0 49284 NULL
108151 +ext4_xattr_ibody_list_49287 ext4_xattr_ibody_list 3-0 49287 NULL
108152 +viafb_dfph_proc_write_49288 viafb_dfph_proc_write 3 49288 NULL
108153 +uio_read_49300 uio_read 3 49300 NULL
108154 +ocfs2_resmap_find_free_bits_49301 ocfs2_resmap_find_free_bits 3 49301 NULL
108155 +isku_sysfs_read_keys_macro_49312 isku_sysfs_read_keys_macro 6 49312 NULL
108156 +update_ref_for_cow_49313 update_ref_for_cow 0 49313 NULL
108157 +SYSC_mincore_49319 SYSC_mincore 2-1 49319 NULL
108158 +fwtty_port_handler_49327 fwtty_port_handler 9 49327 NULL
108159 +srpt_alloc_ioctx_ring_49330 srpt_alloc_ioctx_ring 2-4-3 49330 NULL
108160 +__intel_map_single_49338 __intel_map_single 3-2 49338 NULL
108161 +intel_ring_invalidate_all_caches_49346 intel_ring_invalidate_all_caches 0 49346 NULL
108162 +joydev_ioctl_common_49359 joydev_ioctl_common 2 49359 NULL
108163 +ocfs2_remove_btree_range_49370 ocfs2_remove_btree_range 4-3-5 49370 NULL
108164 +iscsi_alloc_session_49390 iscsi_alloc_session 3 49390 NULL
108165 +ext4_ext_index_trans_blocks_49396 ext4_ext_index_trans_blocks 0 49396 NULL
108166 +rx_streaming_always_read_49401 rx_streaming_always_read 3 49401 NULL
108167 +tnode_alloc_49407 tnode_alloc 1 49407 NULL
108168 +samples_to_bytes_49426 samples_to_bytes 0-2 49426 NULL
108169 +ubi_add_to_av_49432 ubi_add_to_av 0 49432 NULL nohasharray
108170 +md_domain_init_49432 md_domain_init 2 49432 &ubi_add_to_av_49432
108171 +compat_do_msg_fill_49440 compat_do_msg_fill 3 49440 NULL
108172 +get_lru_size_49441 get_lru_size 0 49441 NULL
108173 +i915_gem_object_set_to_gtt_domain_49450 i915_gem_object_set_to_gtt_domain 0 49450 NULL
108174 +ocfs2_merge_rec_left_49455 ocfs2_merge_rec_left 0 49455 NULL
108175 +__hfsplus_getxattr_49460 __hfsplus_getxattr 0 49460 NULL
108176 +agp_3_5_isochronous_node_enable_49465 agp_3_5_isochronous_node_enable 3 49465 NULL
108177 +xfs_iformat_local_49472 xfs_iformat_local 4 49472 NULL
108178 +savu_sysfs_read_49473 savu_sysfs_read 6 49473 NULL
108179 +isr_decrypt_done_read_49490 isr_decrypt_done_read 3 49490 NULL
108180 +SyS_listxattr_49519 SyS_listxattr 3 49519 NULL
108181 +emulator_write_phys_49520 emulator_write_phys 2-4 49520 NULL
108182 +btrfs_add_free_space_49524 btrfs_add_free_space 0 49524 NULL
108183 +smk_write_access_49561 smk_write_access 3 49561 NULL
108184 +ntfs_malloc_nofs_49572 ntfs_malloc_nofs 1 49572 NULL
108185 +alloc_chunk_49575 alloc_chunk 1 49575 NULL
108186 +sctp_setsockopt_default_send_param_49578 sctp_setsockopt_default_send_param 3 49578 NULL
108187 +readfifo_49583 readfifo 1 49583 NULL
108188 +tap_write_49595 tap_write 3 49595 NULL
108189 +create_task_io_context_49601 create_task_io_context 3 49601 NULL
108190 +isr_wakeups_read_49607 isr_wakeups_read 3 49607 NULL
108191 +btrfs_mksubvol_49616 btrfs_mksubvol 3 49616 NULL
108192 +heap_init_49617 heap_init 2 49617 NULL
108193 +smk_write_doi_49621 smk_write_doi 3 49621 NULL
108194 +port_fops_read_49626 port_fops_read 3 49626 NULL
108195 +btrfsic_cmp_log_and_dev_bytenr_49628 btrfsic_cmp_log_and_dev_bytenr 2 49628 NULL
108196 +__swab32p_49657 __swab32p 0 49657 NULL
108197 +ubi_wl_flush_49682 ubi_wl_flush 0 49682 NULL
108198 +aa_simple_write_to_buffer_49683 aa_simple_write_to_buffer 3-4 49683 NULL
108199 +SyS_pwritev_49688 SyS_pwritev 3 49688 NULL
108200 +__setup_irq_49696 __setup_irq 0 49696 NULL
108201 +cx2341x_ctrl_new_menu_49700 cx2341x_ctrl_new_menu 3 49700 NULL
108202 +do_splice_to_49714 do_splice_to 4 49714 NULL
108203 +write_pool_49718 write_pool 3 49718 NULL
108204 +dm_thin_insert_block_49720 dm_thin_insert_block 2-3 49720 NULL
108205 +kvm_mmu_notifier_invalidate_page_49723 kvm_mmu_notifier_invalidate_page 3 49723 NULL
108206 +sep_create_dcb_dmatables_context_kernel_49728 sep_create_dcb_dmatables_context_kernel 6 49728 NULL
108207 +zd_usb_iowrite16v_49744 zd_usb_iowrite16v 3 49744 NULL
108208 +btrfs_chunk_num_stripes_49751 btrfs_chunk_num_stripes 0 49751 NULL
108209 +fuse_wr_pages_49753 fuse_wr_pages 0-1-2 49753 NULL
108210 +key_conf_keylen_read_49758 key_conf_keylen_read 3 49758 NULL
108211 +fuse_conn_waiting_read_49762 fuse_conn_waiting_read 3 49762 NULL
108212 +w83977af_fir_interrupt_49775 w83977af_fir_interrupt 0 49775 NULL
108213 +ceph_osdc_readpages_49789 ceph_osdc_readpages 0 49789 NULL
108214 +nfs4_acl_new_49806 nfs4_acl_new 1 49806 NULL
108215 +ntfs_copy_from_user_iovec_49829 ntfs_copy_from_user_iovec 3-6-0 49829 NULL
108216 +add_uuid_49831 add_uuid 4 49831 NULL
108217 +ath6kl_fwlog_block_read_49836 ath6kl_fwlog_block_read 3 49836 NULL
108218 +iraw_loop_49842 iraw_loop 0-1 49842 NULL
108219 +twl4030_write_49846 twl4030_write 2 49846 NULL
108220 +scsi_dispatch_cmd_entry_49848 scsi_dispatch_cmd_entry 3 49848 NULL
108221 +timeradd_entry_49850 timeradd_entry 3 49850 NULL
108222 +ubifs_destroy_tnc_subtree_49853 ubifs_destroy_tnc_subtree 0 49853 NULL
108223 +btrfs_subvolume_reserve_metadata_49859 btrfs_subvolume_reserve_metadata 3 49859 NULL
108224 +fiemap_count_to_size_49869 fiemap_count_to_size 0-1 49869 NULL
108225 +sctp_setsockopt_bindx_49870 sctp_setsockopt_bindx 3 49870 NULL
108226 +snd_mask_eq_49889 snd_mask_eq 0 49889 NULL
108227 +ceph_get_caps_49890 ceph_get_caps 0 49890 NULL
108228 +osc_brw_49896 osc_brw 4 49896 NULL
108229 +__cow_file_range_49901 __cow_file_range 5 49901 NULL
108230 +__copy_from_user_inatomic_nocache_49921 __copy_from_user_inatomic_nocache 3 49921 NULL
108231 +config_ep_by_speed_49939 config_ep_by_speed 0 49939 NULL
108232 +batadv_tt_realloc_packet_buff_49960 batadv_tt_realloc_packet_buff 4 49960 NULL
108233 +ieee80211_if_fmt_dtim_count_49987 ieee80211_if_fmt_dtim_count 3 49987 NULL
108234 +drm_buffer_copy_from_user_49990 drm_buffer_copy_from_user 3 49990 NULL
108235 +sta2x11_swiotlb_alloc_coherent_49994 sta2x11_swiotlb_alloc_coherent 2 49994 NULL
108236 +l2cap_chan_send_49995 l2cap_chan_send 3 49995 NULL
108237 +__module_alloc_50004 __module_alloc 1 50004 NULL
108238 +dn_mss_from_pmtu_50011 dn_mss_from_pmtu 0-2 50011 NULL
108239 +ptrace_readdata_50020 ptrace_readdata 2-4 50020 NULL
108240 +isdn_read_50021 isdn_read 3 50021 NULL
108241 +mdc_rename_pack_50023 mdc_rename_pack 4-6 50023 NULL
108242 +qp_alloc_queue_50028 qp_alloc_queue 1 50028 NULL
108243 +ioread8_50049 ioread8 0 50049 NULL
108244 +fuse_conn_max_background_write_50061 fuse_conn_max_background_write 3 50061 NULL
108245 +vmw_surface_destroy_size_50072 vmw_surface_destroy_size 0 50072 NULL
108246 +arch_setup_ht_irq_50073 arch_setup_ht_irq 1 50073 NULL
108247 +__kfifo_dma_in_prepare_50081 __kfifo_dma_in_prepare 4 50081 NULL
108248 +dev_set_alias_50084 dev_set_alias 3 50084 NULL
108249 +libcfs_ioctl_popdata_50087 libcfs_ioctl_popdata 3 50087 NULL
108250 +sock_setsockopt_50088 sock_setsockopt 5 50088 NULL
108251 +altera_swap_dr_50090 altera_swap_dr 2 50090 NULL
108252 +android_set_cntry_50100 android_set_cntry 0 50100 NULL
108253 +process_recorded_refs_50110 process_recorded_refs 0 50110 NULL
108254 +read_file_slot_50111 read_file_slot 3 50111 NULL
108255 +xfs_dir3_sf_entsize_50112 xfs_dir3_sf_entsize 0-3 50112 NULL
108256 +rx_streaming_interval_write_50120 rx_streaming_interval_write 3 50120 NULL
108257 +ocfs2_search_one_group_50125 ocfs2_search_one_group 0 50125 NULL nohasharray
108258 +jfs_direct_IO_50125 jfs_direct_IO 4 50125 &ocfs2_search_one_group_50125
108259 +SYSC_preadv_50134 SYSC_preadv 3 50134 NULL
108260 +copy_items_50140 copy_items 6 50140 NULL
108261 +tx_frag_need_fragmentation_read_50153 tx_frag_need_fragmentation_read 3 50153 NULL
108262 +reiserfs_bmap_count_50160 reiserfs_bmap_count 0 50160 NULL
108263 +kmalloc_node_50163 kmalloc_node 1-3 50163 NULL
108264 +rx_filter_ibss_filter_read_50167 rx_filter_ibss_filter_read 3 50167 NULL
108265 +ahd_probe_stack_size_50168 ahd_probe_stack_size 0 50168 NULL
108266 +odev_update_50169 odev_update 2 50169 NULL
108267 +ieee80211_if_fmt_dot11MeshHWMPRannInterval_50172 ieee80211_if_fmt_dot11MeshHWMPRannInterval 3 50172 NULL nohasharray
108268 +xfs_get_blocks_direct_50172 xfs_get_blocks_direct 2 50172 &ieee80211_if_fmt_dot11MeshHWMPRannInterval_50172 nohasharray
108269 +ubi_resize_volume_50172 ubi_resize_volume 2 50172 &xfs_get_blocks_direct_50172
108270 +ext3_do_update_inode_50178 ext3_do_update_inode 0 50178 NULL
108271 +cfg80211_roamed_bss_50198 cfg80211_roamed_bss 6-4 50198 NULL
108272 +cyttsp4_probe_50201 cyttsp4_probe 4 50201 NULL
108273 +rx_rx_timeout_wa_read_50204 rx_rx_timeout_wa_read 3 50204 NULL
108274 +compat_SyS_sendfile_50206 compat_SyS_sendfile 4 50206 NULL nohasharray
108275 +mthca_buddy_init_50206 mthca_buddy_init 2 50206 &compat_SyS_sendfile_50206
108276 +l2cap_sock_setsockopt_50207 l2cap_sock_setsockopt 5 50207 NULL
108277 +mon_bin_compat_ioctl_50234 mon_bin_compat_ioctl 3 50234 NULL
108278 +sg_kmalloc_50240 sg_kmalloc 1 50240 NULL
108279 +vma_dup_policy_50269 vma_dup_policy 0 50269 NULL
108280 +rxrpc_setsockopt_50286 rxrpc_setsockopt 5 50286 NULL
108281 +soc_codec_reg_show_50302 soc_codec_reg_show 0-3 50302 NULL
108282 +SYSC_flistxattr_50307 SYSC_flistxattr 3 50307 NULL
108283 +SYSC_sched_setaffinity_50310 SYSC_sched_setaffinity 2 50310 NULL
108284 +iterate_irefs_50313 iterate_irefs 0 50313 NULL
108285 +soc_camera_read_50319 soc_camera_read 3 50319 NULL
108286 +do_launder_page_50329 do_launder_page 0 50329 NULL
108287 +nouveau_engine_create__50331 nouveau_engine_create_ 7 50331 NULL
108288 +lpfc_idiag_pcicfg_read_50334 lpfc_idiag_pcicfg_read 3 50334 NULL
108289 +ocfs2_block_to_cluster_group_50337 ocfs2_block_to_cluster_group 2 50337 NULL nohasharray
108290 +snd_pcm_lib_writev_50337 snd_pcm_lib_writev 0-3 50337 &ocfs2_block_to_cluster_group_50337
108291 +tpm_read_50344 tpm_read 3 50344 NULL
108292 +sched_clock_remote_50347 sched_clock_remote 0 50347 NULL
108293 +efx_nic_update_stats_50352 efx_nic_update_stats 2 50352 NULL
108294 +kvm_arch_create_memslot_50354 kvm_arch_create_memslot 2 50354 NULL
108295 +isdn_ppp_read_50356 isdn_ppp_read 4 50356 NULL
108296 +ocfs2_figure_insert_type_50362 ocfs2_figure_insert_type 0 50362 NULL nohasharray
108297 +iwl_dbgfs_echo_test_write_50362 iwl_dbgfs_echo_test_write 3 50362 &ocfs2_figure_insert_type_50362
108298 +xfrm_send_migrate_50365 xfrm_send_migrate 5 50365 NULL
108299 +roccat_common2_receive_50369 roccat_common2_receive 4 50369 NULL
108300 +sl_alloc_bufs_50380 sl_alloc_bufs 2 50380 NULL
108301 +hash_ip6_expire_50390 hash_ip6_expire 3 50390 NULL
108302 +snd_mask_refine_last_50406 snd_mask_refine_last 0 50406 NULL
108303 +l2tp_ip_sendmsg_50411 l2tp_ip_sendmsg 4 50411 NULL
108304 +iscsi_create_conn_50425 iscsi_create_conn 2 50425 NULL
108305 +validate_acl_mac_addrs_50429 validate_acl_mac_addrs 0 50429 NULL
108306 +btrfs_error_discard_extent_50444 btrfs_error_discard_extent 2 50444 NULL nohasharray
108307 +ecryptfs_write_lower_page_segment_50444 ecryptfs_write_lower_page_segment 4 50444 &btrfs_error_discard_extent_50444
108308 +calc_csum_metadata_size_50448 calc_csum_metadata_size 0 50448 NULL
108309 +pgctrl_write_50453 pgctrl_write 3 50453 NULL
108310 +device_create_sys_dev_entry_50458 device_create_sys_dev_entry 0 50458 NULL
108311 +force_mapping_50464 force_mapping 2 50464 NULL
108312 +cfs_size_round_50472 cfs_size_round 0-1 50472 NULL
108313 +cdrom_read_cdda_50478 cdrom_read_cdda 4 50478 NULL
108314 +mei_io_cb_alloc_req_buf_50493 mei_io_cb_alloc_req_buf 2 50493 NULL
108315 +pwr_rcvd_awake_beacons_read_50505 pwr_rcvd_awake_beacons_read 3 50505 NULL
108316 +__ctzdi2_50536 __ctzdi2 1 50536 NULL
108317 +ath6kl_set_ap_probe_resp_ies_50539 ath6kl_set_ap_probe_resp_ies 3 50539 NULL
108318 +usbat_flash_write_data_50553 usbat_flash_write_data 4 50553 NULL
108319 +self_check_peb_vid_hdr_50563 self_check_peb_vid_hdr 0 50563 NULL nohasharray
108320 +ttm_agp_tt_create_50563 ttm_agp_tt_create 3 50563 &self_check_peb_vid_hdr_50563
108321 +fat_readpages_50582 fat_readpages 4 50582 NULL
108322 +iwl_dbgfs_missed_beacon_read_50584 iwl_dbgfs_missed_beacon_read 3 50584 NULL
108323 +build_inv_iommu_pages_50589 build_inv_iommu_pages 2-3 50589 NULL
108324 +xillybus_write_50605 xillybus_write 3 50605 NULL
108325 +rx_rx_checksum_result_read_50617 rx_rx_checksum_result_read 3 50617 NULL
108326 +ocfs2_split_extent_50618 ocfs2_split_extent 0 50618 NULL
108327 +sparse_early_usemaps_alloc_node_50623 sparse_early_usemaps_alloc_node 4 50623 NULL
108328 +__ffs_50625 __ffs 0-1 50625 NULL
108329 +regcache_rbtree_write_50629 regcache_rbtree_write 2 50629 NULL
108330 +simple_transaction_get_50633 simple_transaction_get 3 50633 NULL
108331 +ocfs2_do_insert_extent_50658 ocfs2_do_insert_extent 0 50658 NULL
108332 +ath6kl_tm_rx_event_50664 ath6kl_tm_rx_event 3 50664 NULL
108333 +bnad_debugfs_read_50665 bnad_debugfs_read 3 50665 NULL
108334 +ext2_try_to_allocate_with_rsv_50669 ext2_try_to_allocate_with_rsv 4-2-0 50669 NULL
108335 +prism2_read_fid_reg_50689 prism2_read_fid_reg 0 50689 NULL nohasharray
108336 +i2c_smbus_read_byte_data_50689 i2c_smbus_read_byte_data 0 50689 &prism2_read_fid_reg_50689
108337 +paging32_gva_to_gpa_50696 paging32_gva_to_gpa 2 50696 NULL
108338 +xfs_growfs_get_hdr_buf_50697 xfs_growfs_get_hdr_buf 3 50697 NULL
108339 +dev_mem_read_50706 dev_mem_read 3 50706 NULL
108340 +blk_check_plugged_50736 blk_check_plugged 3 50736 NULL
108341 +__ext3_get_inode_loc_50744 __ext3_get_inode_loc 0 50744 NULL
108342 +btrfs_truncate_free_space_cache_50769 btrfs_truncate_free_space_cache 0 50769 NULL
108343 +ocfs2_xattr_block_get_50773 ocfs2_xattr_block_get 0 50773 NULL
108344 +tm6000_read_write_usb_50774 tm6000_read_write_usb 7 50774 NULL
108345 +bio_alloc_map_data_50782 bio_alloc_map_data 2-1 50782 NULL
108346 +tpm_write_50798 tpm_write 3 50798 NULL
108347 +write_flush_50803 write_flush 3 50803 NULL
108348 +dvb_play_50814 dvb_play 3 50814 NULL
108349 +dpcm_show_state_50827 dpcm_show_state 0 50827 NULL
108350 +acpi_ev_install_gpe_block_50829 acpi_ev_install_gpe_block 2 50829 NULL
108351 +SetArea_50835 SetArea 4 50835 NULL nohasharray
108352 +create_mem_extents_50835 create_mem_extents 0 50835 &SetArea_50835 nohasharray
108353 +mask_from_50835 mask_from 0-1-2 50835 &create_mem_extents_50835
108354 +videobuf_dma_init_user_50839 videobuf_dma_init_user 3-4 50839 NULL
108355 +btrfs_search_slot_for_read_50843 btrfs_search_slot_for_read 0 50843 NULL
108356 +self_check_write_50856 self_check_write 0-5 50856 NULL
108357 +carl9170_debugfs_write_50857 carl9170_debugfs_write 3 50857 NULL
108358 +__percpu_counter_init_50878 __percpu_counter_init 0 50878 NULL
108359 +btrfs_insert_inode_ref_50884 btrfs_insert_inode_ref 0 50884 NULL
108360 +SyS_lgetxattr_50889 SyS_lgetxattr 4 50889 NULL
108361 +netlbl_secattr_catmap_walk_rng_50894 netlbl_secattr_catmap_walk_rng 0-2 50894 NULL
108362 +__bdev_writeseg_50903 __bdev_writeseg 4 50903 NULL
108363 +xfs_iext_remove_50909 xfs_iext_remove 3 50909 NULL
108364 +blk_rq_cur_sectors_50910 blk_rq_cur_sectors 0 50910 NULL
108365 +hash_recvmsg_50924 hash_recvmsg 4 50924 NULL
108366 +chd_dec_fetch_cdata_50926 chd_dec_fetch_cdata 3 50926 NULL
108367 +show_device_status_50947 show_device_status 0 50947 NULL
108368 +irq_timeout_write_50950 irq_timeout_write 3 50950 NULL
108369 +ocfs2_add_refcount_flag_50952 ocfs2_add_refcount_flag 6 50952 NULL
108370 +sdio_uart_write_50954 sdio_uart_write 3 50954 NULL
108371 +SyS_setxattr_50957 SyS_setxattr 4 50957 NULL
108372 +btrfs_del_csums_50969 btrfs_del_csums 0 50969 NULL
108373 +__btrfs_mod_ref_50973 __btrfs_mod_ref 0 50973 NULL
108374 +iwl_statistics_flag_50981 iwl_statistics_flag 0-3 50981 NULL
108375 +timeout_write_50991 timeout_write 3 50991 NULL
108376 +wm831x_irq_map_50995 wm831x_irq_map 2 50995 NULL
108377 +proc_write_51003 proc_write 3 51003 NULL
108378 +jbd2_journal_extend_51012 jbd2_journal_extend 2-0 51012 NULL
108379 +lbs_dev_info_51023 lbs_dev_info 3 51023 NULL
108380 +ntfs_attr_find_51028 ntfs_attr_find 0 51028 NULL nohasharray
108381 +fuse_conn_congestion_threshold_read_51028 fuse_conn_congestion_threshold_read 3 51028 &ntfs_attr_find_51028
108382 +BcmGetSectionValEndOffset_51039 BcmGetSectionValEndOffset 0 51039 NULL
108383 +dump_midi_51040 dump_midi 3 51040 NULL
108384 +usb_get_descriptor_51041 usb_get_descriptor 0 51041 NULL
108385 +srpt_alloc_ioctx_51042 srpt_alloc_ioctx 2-3 51042 NULL
108386 +do_arpt_set_ctl_51053 do_arpt_set_ctl 4 51053 NULL
108387 +wusb_prf_64_51065 wusb_prf_64 7 51065 NULL
108388 +jbd2_journal_init_revoke_51088 jbd2_journal_init_revoke 2 51088 NULL
108389 +solo_enc_v4l2_init_51094 solo_enc_v4l2_init 2 51094 NULL
108390 +__ocfs2_find_path_51096 __ocfs2_find_path 0 51096 NULL
108391 +btrfs_del_item_51110 btrfs_del_item 0 51110 NULL nohasharray
108392 +ti_recv_51110 ti_recv 3 51110 &btrfs_del_item_51110
108393 +uasp_prepare_r_request_51124 uasp_prepare_r_request 0 51124 NULL
108394 +nfs_map_name_to_uid_51132 nfs_map_name_to_uid 3 51132 NULL
108395 +alloc_rtllib_51136 alloc_rtllib 1 51136 NULL
108396 +simple_xattr_set_51140 simple_xattr_set 4 51140 NULL
108397 +set_dirty_51144 set_dirty 3 51144 NULL
108398 +xfs_trans_get_efd_51148 xfs_trans_get_efd 3 51148 NULL
108399 +walk_page_buffers_51170 walk_page_buffers 0 51170 NULL
108400 +snd_pcm_unlink_51210 snd_pcm_unlink 0 51210 NULL
108401 +uhci_frame_skel_link_51213 uhci_frame_skel_link 2 51213 NULL
108402 +nf_ct_ext_create_51232 nf_ct_ext_create 3 51232 NULL
108403 +snd_pcm_write_51235 snd_pcm_write 3 51235 NULL
108404 +tipc_send_51238 tipc_send 4 51238 NULL
108405 +drm_property_create_51239 drm_property_create 4 51239 NULL
108406 +__mxt_read_reg_51249 __mxt_read_reg 0 51249 NULL
108407 +st_read_51251 st_read 3 51251 NULL
108408 +compat_dccp_setsockopt_51263 compat_dccp_setsockopt 5 51263 NULL
108409 +target_alloc_sgl_51264 target_alloc_sgl 3 51264 NULL
108410 +dvb_audio_write_51275 dvb_audio_write 3 51275 NULL
108411 +ipwireless_network_packet_received_51277 ipwireless_network_packet_received 4 51277 NULL
108412 +zone_reclaimable_pages_51283 zone_reclaimable_pages 0 51283 NULL nohasharray
108413 +__get_cur_name_and_parent_51283 __get_cur_name_and_parent 0 51283 &zone_reclaimable_pages_51283
108414 +pvr2_std_id_to_str_51288 pvr2_std_id_to_str 2 51288 NULL
108415 +bnad_debugfs_read_regrd_51308 bnad_debugfs_read_regrd 3 51308 NULL
108416 +get_cell_51316 get_cell 2 51316 NULL
108417 +init_map_ipmac_51317 init_map_ipmac 4-3-5 51317 NULL
108418 +ocfs2_read_inode_block_51319 ocfs2_read_inode_block 0 51319 NULL
108419 +alloc_hippi_dev_51320 alloc_hippi_dev 1 51320 NULL
108420 +ext2_xattr_get_51327 ext2_xattr_get 0 51327 NULL
108421 +alloc_smp_req_51337 alloc_smp_req 1 51337 NULL nohasharray
108422 +compat_arch_ptrace_51337 compat_arch_ptrace 3 51337 &alloc_smp_req_51337
108423 +ipw_get_event_log_len_51341 ipw_get_event_log_len 0 51341 NULL
108424 +ieee80211_if_fmt_estab_plinks_51370 ieee80211_if_fmt_estab_plinks 3 51370 NULL
108425 +radeon_kms_compat_ioctl_51371 radeon_kms_compat_ioctl 2 51371 NULL
108426 +pci_sriov_resource_alignment_51406 pci_sriov_resource_alignment 0 51406 NULL
108427 +ceph_sync_read_51410 ceph_sync_read 3-0 51410 NULL
108428 +get_first_ref_51413 get_first_ref 0 51413 NULL
108429 +__btrfs_end_transaction_51420 __btrfs_end_transaction 0 51420 NULL
108430 +blk_register_region_51424 blk_register_region 1-2 51424 NULL
108431 +mwifiex_rdeeprom_read_51429 mwifiex_rdeeprom_read 3 51429 NULL
108432 +hfsplus_brec_read_51436 hfsplus_brec_read 0 51436 NULL
108433 +ieee80211_if_read_dot11MeshHWMPRootMode_51441 ieee80211_if_read_dot11MeshHWMPRootMode 3 51441 NULL
108434 +print_devstats_dot11ACKFailureCount_51443 print_devstats_dot11ACKFailureCount 3 51443 NULL
108435 +____alloc_ei_netdev_51475 ____alloc_ei_netdev 1 51475 NULL
108436 +xfs_buf_get_uncached_51477 xfs_buf_get_uncached 2 51477 NULL
108437 +btrfs_find_space_cluster_51482 btrfs_find_space_cluster 5 51482 NULL
108438 +kvm_fetch_guest_virt_51493 kvm_fetch_guest_virt 4-2 51493 NULL
108439 +ieee80211_if_write_uapsd_queues_51526 ieee80211_if_write_uapsd_queues 3 51526 NULL
108440 +key_search_51533 key_search 0 51533 NULL
108441 +load_pdptrs_51541 load_pdptrs 3 51541 NULL
108442 +__alloc_eip_netdev_51549 __alloc_eip_netdev 1 51549 NULL
108443 +ixgb_get_eeprom_len_51586 ixgb_get_eeprom_len 0 51586 NULL
108444 +get_cur_path_51589 get_cur_path 0 51589 NULL nohasharray
108445 +snd_interval_refine_first_51589 snd_interval_refine_first 0 51589 &get_cur_path_51589
108446 +aac_convert_sgraw2_51598 aac_convert_sgraw2 4 51598 NULL
108447 +table_size_to_number_of_entries_51613 table_size_to_number_of_entries 0-1 51613 NULL
108448 +extent_fiemap_51621 extent_fiemap 3 51621 NULL
108449 +sctp_auth_create_key_51641 sctp_auth_create_key 1 51641 NULL
108450 +iscsi_create_session_51647 iscsi_create_session 3 51647 NULL
108451 +get_new_cssid_51665 get_new_cssid 2 51665 NULL
108452 +ps_upsd_utilization_read_51669 ps_upsd_utilization_read 3 51669 NULL
108453 +sctp_setsockopt_associnfo_51684 sctp_setsockopt_associnfo 3 51684 NULL
108454 +host_mapping_level_51696 host_mapping_level 2 51696 NULL
108455 +sel_write_access_51704 sel_write_access 3 51704 NULL
108456 +tty_cdev_add_51714 tty_cdev_add 2-4 51714 NULL
108457 +v9fs_alloc_rdir_buf_51716 v9fs_alloc_rdir_buf 2 51716 NULL
108458 +drm_compat_ioctl_51717 drm_compat_ioctl 2 51717 NULL
108459 +sg_read_oxfer_51724 sg_read_oxfer 3 51724 NULL
108460 +dbg_check_lpt_nodes_51727 dbg_check_lpt_nodes 0 51727 NULL
108461 +cm4040_read_51732 cm4040_read 3 51732 NULL
108462 +get_user_pages_fast_51751 get_user_pages_fast 1-2-0 51751 NULL
108463 +ifx_spi_insert_flip_string_51752 ifx_spi_insert_flip_string 3 51752 NULL
108464 +if_write_51756 if_write 3 51756 NULL
108465 +ext4_ext_create_new_leaf_51763 ext4_ext_create_new_leaf 0 51763 NULL
108466 +__fswab32_51781 __fswab32 0 51781 NULL
108467 +to_ratio_51809 to_ratio 1-2 51809 NULL
108468 +qib_alloc_devdata_51819 qib_alloc_devdata 2 51819 NULL
108469 +buffer_from_user_51826 buffer_from_user 3 51826 NULL
108470 +max732x_irq_pending_51840 max732x_irq_pending 0 51840 NULL
108471 +ioread32_51847 ioread32 0 51847 NULL nohasharray
108472 +read_file_tgt_tx_stats_51847 read_file_tgt_tx_stats 3 51847 &ioread32_51847
108473 +do_readv_writev_51849 do_readv_writev 4 51849 NULL
108474 +SYSC_sendto_51852 SYSC_sendto 6 51852 NULL
108475 +bm_page_io_async_51858 bm_page_io_async 2 51858 NULL
108476 +pointer_size_read_51863 pointer_size_read 3 51863 NULL
108477 +mlx4_alloc_db_from_pgdir_51865 mlx4_alloc_db_from_pgdir 3 51865 NULL
108478 +get_indirect_ea_51869 get_indirect_ea 4 51869 NULL
108479 +user_read_51881 user_read 3 51881 NULL
108480 +dbAdjCtl_51888 dbAdjCtl 0 51888 NULL
108481 +SyS_mq_timedsend_51896 SyS_mq_timedsend 3 51896 NULL nohasharray
108482 +virt_to_phys_51896 virt_to_phys 0 51896 &SyS_mq_timedsend_51896
108483 +commit_fs_roots_51898 commit_fs_roots 0 51898 NULL
108484 +wmi_set_ie_51919 wmi_set_ie 3 51919 NULL
108485 +dbg_status_buf_51930 dbg_status_buf 2 51930 NULL
108486 +__tcp_mtu_to_mss_51938 __tcp_mtu_to_mss 0-2 51938 NULL
108487 +xfrm_alg_len_51940 xfrm_alg_len 0 51940 NULL
108488 +irq_dispose_mapping_51941 irq_dispose_mapping 1 51941 NULL
108489 +scsi_get_vpd_page_51951 scsi_get_vpd_page 4 51951 NULL
108490 +arizona_free_irq_51969 arizona_free_irq 2 51969 NULL nohasharray
108491 +snd_mask_min_51969 snd_mask_min 0 51969 &arizona_free_irq_51969
108492 +__blkdev_get_51972 __blkdev_get 0 51972 NULL nohasharray
108493 +read_page_51972 read_page 2 51972 &__blkdev_get_51972
108494 +get_zone_51981 get_zone 0-1 51981 NULL
108495 +ath6kl_sdio_alloc_prep_scat_req_51986 ath6kl_sdio_alloc_prep_scat_req 2 51986 NULL
108496 +_c4iw_write_mem_dma_51991 _c4iw_write_mem_dma 3 51991 NULL
108497 +dwc3_mode_write_51997 dwc3_mode_write 3 51997 NULL
108498 +skb_copy_datagram_from_iovec_52014 skb_copy_datagram_from_iovec 4-2-5 52014 NULL
108499 +rdmalt_52022 rdmalt 0 52022 NULL
108500 +override_release_52032 override_release 2 52032 NULL
108501 +end_port_52042 end_port 0 52042 NULL
108502 +dma_rx_errors_read_52045 dma_rx_errors_read 3 52045 NULL
108503 +msnd_fifo_write_52052 msnd_fifo_write 0-3 52052 NULL
108504 +dvb_ringbuffer_avail_52057 dvb_ringbuffer_avail 0 52057 NULL
108505 +__fuse_request_alloc_52060 __fuse_request_alloc 1 52060 NULL
108506 +isofs_readpages_52067 isofs_readpages 4 52067 NULL
108507 +nsm_get_handle_52089 nsm_get_handle 4 52089 NULL
108508 +ulist_add_merge_52096 ulist_add_merge 0 52096 NULL
108509 +o2net_debug_read_52105 o2net_debug_read 3 52105 NULL
108510 +split_scan_timeout_write_52128 split_scan_timeout_write 3 52128 NULL
108511 +retry_count_read_52129 retry_count_read 3 52129 NULL
108512 +snd_pcm_channel_info_user_52135 snd_pcm_channel_info_user 0 52135 NULL
108513 +gdm_usb_hci_send_52138 gdm_usb_hci_send 3 52138 NULL
108514 +sub_alloc_52140 sub_alloc 0 52140 NULL nohasharray
108515 +zram_meta_alloc_52140 zram_meta_alloc 1 52140 &sub_alloc_52140
108516 +hysdn_conf_write_52145 hysdn_conf_write 3 52145 NULL nohasharray
108517 +ext2_alloc_blocks_52145 ext2_alloc_blocks 2-0 52145 &hysdn_conf_write_52145
108518 +htable_size_52148 htable_size 0-1 52148 NULL
108519 +smk_write_load2_52155 smk_write_load2 3 52155 NULL
108520 +ieee80211_if_read_dot11MeshRetryTimeout_52168 ieee80211_if_read_dot11MeshRetryTimeout 3 52168 NULL
108521 +mga_compat_ioctl_52170 mga_compat_ioctl 2 52170 NULL
108522 +print_prefix_52176 print_prefix 0 52176 NULL
108523 +proc_pid_readlink_52186 proc_pid_readlink 3 52186 NULL
108524 +vmci_qp_broker_alloc_52216 vmci_qp_broker_alloc 6-5 52216 NULL
108525 +do_dmabuf_dirty_ldu_52241 do_dmabuf_dirty_ldu 6 52241 NULL
108526 +fuse_request_alloc_52243 fuse_request_alloc 1 52243 NULL nohasharray
108527 +xfs_iomap_eof_align_last_fsb_52243 xfs_iomap_eof_align_last_fsb 3 52243 &fuse_request_alloc_52243
108528 +ocfs2_try_to_merge_extent_52244 ocfs2_try_to_merge_extent 0 52244 NULL
108529 +pm80x_request_irq_52250 pm80x_request_irq 2 52250 NULL
108530 +mdiobus_alloc_size_52259 mdiobus_alloc_size 1 52259 NULL
108531 +shrink_slab_52261 shrink_slab 2-3 52261 NULL
108532 +hva_to_pfn_slow_52262 hva_to_pfn_slow 1 52262 NULL
108533 +sisusbcon_do_font_op_52271 sisusbcon_do_font_op 9 52271 NULL
108534 +handle_supp_msgs_52284 handle_supp_msgs 4 52284 NULL
108535 +kobject_set_name_vargs_52309 kobject_set_name_vargs 0 52309 NULL
108536 +read_file_reset_52310 read_file_reset 3 52310 NULL
108537 +request_asymmetric_key_52317 request_asymmetric_key 4-2 52317 NULL
108538 +hwflags_read_52318 hwflags_read 3 52318 NULL
108539 +snd_pcm_hw_free_52327 snd_pcm_hw_free 0 52327 NULL
108540 +ntfs_rl_split_52328 ntfs_rl_split 4-2 52328 NULL
108541 +test_unaligned_bulk_52333 test_unaligned_bulk 3 52333 NULL
108542 +hur_len_52339 hur_len 0 52339 NULL
108543 +bytes_to_frames_52362 bytes_to_frames 0-2 52362 NULL
108544 +copy_entries_to_user_52367 copy_entries_to_user 1 52367 NULL
108545 +iwl_dump_fh_52371 iwl_dump_fh 0 52371 NULL
108546 +hfsplus_find_attr_52374 hfsplus_find_attr 0 52374 NULL
108547 +ocfs2_journal_access_eb_52377 ocfs2_journal_access_eb 0 52377 NULL
108548 +mq_emit_config_values_52378 mq_emit_config_values 3 52378 NULL
108549 +isdn_writebuf_stub_52383 isdn_writebuf_stub 4 52383 NULL
108550 +jfs_setxattr_52389 jfs_setxattr 4 52389 NULL
108551 +aer_inject_write_52399 aer_inject_write 3 52399 NULL nohasharray
108552 +cl_page_own_52399 cl_page_own 0 52399 &aer_inject_write_52399
108553 +cgroup_file_write_52417 cgroup_file_write 3 52417 NULL
108554 +line6_midibuf_init_52425 line6_midibuf_init 2 52425 NULL
108555 +hso_serial_common_create_52428 hso_serial_common_create 4 52428 NULL
108556 +delay_status_52431 delay_status 5 52431 NULL
108557 +ath6kl_delete_qos_write_52435 ath6kl_delete_qos_write 3 52435 NULL
108558 +ieee80211_if_fmt_num_sta_ps_52438 ieee80211_if_fmt_num_sta_ps 3 52438 NULL
108559 +acpi_nvs_for_each_region_52448 acpi_nvs_for_each_region 0 52448 NULL
108560 +alauda_read_data_52452 alauda_read_data 3 52452 NULL
108561 +ieee80211_alloc_txb_52477 ieee80211_alloc_txb 1 52477 NULL
108562 +usb_tranzport_write_52479 usb_tranzport_write 3 52479 NULL
108563 +ocfs2_extend_no_holes_52483 ocfs2_extend_no_holes 3-4 52483 NULL
108564 +fd_do_rw_52495 fd_do_rw 3 52495 NULL
108565 +qib_user_sdma_pin_pages_52498 qib_user_sdma_pin_pages 3-5-4 52498 NULL
108566 +int_tasklet_entry_52500 int_tasklet_entry 3 52500 NULL
108567 +lmv_get_easize_52504 lmv_get_easize 0 52504 NULL
108568 +pm_qos_power_write_52513 pm_qos_power_write 3 52513 NULL
108569 +bt_sock_stream_recvmsg_52518 bt_sock_stream_recvmsg 4 52518 NULL
108570 +dup_variable_bug_52525 dup_variable_bug 3 52525 NULL
108571 +raw_recvmsg_52529 raw_recvmsg 4 52529 NULL
108572 +from_oblock_52546 from_oblock 0-1 52546 NULL
108573 +dccpprobe_read_52549 dccpprobe_read 3 52549 NULL
108574 +ocfs2_make_right_split_rec_52562 ocfs2_make_right_split_rec 3 52562 NULL
108575 +debug_level_proc_write_52572 debug_level_proc_write 3 52572 NULL
108576 +isku_sysfs_read_macro_52587 isku_sysfs_read_macro 6 52587 NULL
108577 +snd_pcm_sw_params_52594 snd_pcm_sw_params 0 52594 NULL
108578 +SyS_setsockopt_52610 SyS_setsockopt 5 52610 NULL
108579 +ll_sa_entry_alloc_52611 ll_sa_entry_alloc 4 52611 NULL
108580 +affs_set_blocksize_52625 affs_set_blocksize 2 52625 NULL
108581 +tps80031_writes_52638 tps80031_writes 3-4 52638 NULL
108582 +brcmf_sdio_assert_info_52653 brcmf_sdio_assert_info 4 52653 NULL
108583 +perf_trace_sched_stat_template_52656 perf_trace_sched_stat_template 3 52656 NULL
108584 +nvme_queue_extra_52661 nvme_queue_extra 0-1 52661 NULL
108585 +htb_add_class_to_row_52663 htb_add_class_to_row 3 52663 NULL
108586 +posix_acl_equiv_mode_52666 posix_acl_equiv_mode 0 52666 NULL
108587 +SYSC_gethostname_52677 SYSC_gethostname 2 52677 NULL
108588 +ntfs_get_nr_significant_bytes_52688 ntfs_get_nr_significant_bytes 0 52688 NULL
108589 +nvd0_disp_pioc_create__52693 nvd0_disp_pioc_create_ 5 52693 NULL
108590 +vendorextnWriteSection_52698 vendorextnWriteSection 0 52698 NULL
108591 +nouveau_client_create__52715 nouveau_client_create_ 5 52715 NULL
108592 +__dm_stat_bio_52722 __dm_stat_bio 3 52722 NULL
108593 +cx25840_ir_rx_read_52724 cx25840_ir_rx_read 3 52724 NULL
108594 +blkcipher_next_slow_52733 blkcipher_next_slow 4-3 52733 NULL
108595 +relay_alloc_page_array_52735 relay_alloc_page_array 1 52735 NULL
108596 +hfcsusb_rx_frame_52745 hfcsusb_rx_frame 3 52745 NULL
108597 +carl9170_debugfs_vif_dump_read_52755 carl9170_debugfs_vif_dump_read 3 52755 NULL
108598 +ieee80211_if_read_beacon_timeout_52756 ieee80211_if_read_beacon_timeout 3 52756 NULL
108599 +radeon_get_ib_value_52757 radeon_get_ib_value 0 52757 NULL
108600 +nvme_trans_ext_inq_page_52776 nvme_trans_ext_inq_page 3 52776 NULL
108601 +pwr_rcvd_beacons_read_52836 pwr_rcvd_beacons_read 3 52836 NULL
108602 +map_try_harder_52846 map_try_harder 2-3 52846 NULL
108603 +ext2_xattr_set_acl_52857 ext2_xattr_set_acl 4 52857 NULL
108604 +process_deleted_xattr_52861 process_deleted_xattr 0 52861 NULL
108605 +mon_bin_get_event_52863 mon_bin_get_event 6-4 52863 NULL
108606 +twl6030_gpadc_write_52867 twl6030_gpadc_write 1 52867 NULL
108607 +qib_decode_6120_err_52876 qib_decode_6120_err 3 52876 NULL
108608 +twlreg_write_52880 twlreg_write 3 52880 NULL
108609 +pvr2_ctrl_value_to_sym_internal_52881 pvr2_ctrl_value_to_sym_internal 5 52881 NULL
108610 +cache_read_procfs_52882 cache_read_procfs 3 52882 NULL
108611 +kvm_kvzalloc_52894 kvm_kvzalloc 1 52894 NULL
108612 +arizona_request_irq_52908 arizona_request_irq 2 52908 NULL
108613 +create_vtbl_52909 create_vtbl 0 52909 NULL
108614 +dio_bio_reap_52913 dio_bio_reap 0 52913 NULL
108615 +__kfifo_out_peek_r_52919 __kfifo_out_peek_r 3 52919 NULL
108616 +iblock_get_bio_52936 iblock_get_bio 3 52936 NULL
108617 +__nodes_remap_52951 __nodes_remap 5 52951 NULL
108618 +send_packet_52960 send_packet 4 52960 NULL
108619 +ieee80211_if_fmt_fwded_mcast_52961 ieee80211_if_fmt_fwded_mcast 3 52961 NULL
108620 +tx_tx_exch_read_52986 tx_tx_exch_read 3 52986 NULL
108621 +num_node_state_52989 num_node_state 0 52989 NULL
108622 +efivarfs_file_write_53000 efivarfs_file_write 3 53000 NULL
108623 +uasp_alloc_stream_res_53015 uasp_alloc_stream_res 0 53015 NULL
108624 +btrfs_free_and_pin_reserved_extent_53016 btrfs_free_and_pin_reserved_extent 2 53016 NULL
108625 +tx_tx_exch_pending_read_53018 tx_tx_exch_pending_read 3 53018 NULL
108626 +ext4_meta_bg_first_group_53031 ext4_meta_bg_first_group 0-2 53031 NULL
108627 +ocfs2_new_leaf_refcount_block_53036 ocfs2_new_leaf_refcount_block 0 53036 NULL
108628 +bio_cur_bytes_53037 bio_cur_bytes 0 53037 NULL
108629 +regcache_lzo_block_count_53056 regcache_lzo_block_count 0 53056 NULL
108630 +cfi_read_query_53066 cfi_read_query 0 53066 NULL
108631 +iwl_dbgfs_interrupt_write_53069 iwl_dbgfs_interrupt_write 3 53069 NULL
108632 +mwifiex_debug_read_53074 mwifiex_debug_read 3 53074 NULL
108633 +page_to_nid_53085 page_to_nid 0 53085 NULL
108634 +qib_resize_cq_53090 qib_resize_cq 2 53090 NULL
108635 +insert_new_root_53097 insert_new_root 0 53097 NULL
108636 +verity_status_53120 verity_status 5 53120 NULL
108637 +__copy_from_user_ll_nocache_nozero_53123 __copy_from_user_ll_nocache_nozero 0-3 53123 NULL
108638 +brcmf_usb_dl_cmd_53130 brcmf_usb_dl_cmd 4 53130 NULL
108639 +btrfs_search_forward_53137 btrfs_search_forward 0 53137 NULL
108640 +ps_poll_ps_poll_max_ap_turn_read_53140 ps_poll_ps_poll_max_ap_turn_read 3 53140 NULL
108641 +ieee80211_bss_info_update_53170 ieee80211_bss_info_update 4 53170 NULL
108642 +btrfs_io_bio_alloc_53179 btrfs_io_bio_alloc 2 53179 NULL
108643 +clear_capture_buf_53192 clear_capture_buf 2 53192 NULL
108644 +SyS_init_module_53202 SyS_init_module 2 53202 NULL
108645 +mtdoops_erase_block_53206 mtdoops_erase_block 2 53206 NULL
108646 +fixup_user_fault_53210 fixup_user_fault 3 53210 NULL
108647 +tx_tx_start_data_read_53219 tx_tx_start_data_read 3 53219 NULL
108648 +ptlrpc_lprocfs_req_history_max_seq_write_53243 ptlrpc_lprocfs_req_history_max_seq_write 3 53243 NULL
108649 +hfsplus_xattr_set_posix_acl_53249 hfsplus_xattr_set_posix_acl 4 53249 NULL
108650 +xfs_trans_read_buf_map_53258 xfs_trans_read_buf_map 5 53258 NULL
108651 +wil_write_file_ssid_53266 wil_write_file_ssid 3 53266 NULL
108652 +btrfs_file_extent_num_bytes_53269 btrfs_file_extent_num_bytes 0 53269 NULL
108653 +tsk_fork_get_node_53271 tsk_fork_get_node 0 53271 NULL
108654 +btrfs_find_highest_objectid_53284 btrfs_find_highest_objectid 0 53284 NULL
108655 +setup_leaf_for_split_53312 setup_leaf_for_split 0 53312 NULL
108656 +ftrace_profile_write_53327 ftrace_profile_write 3 53327 NULL
108657 +setup_cluster_no_bitmap_53328 setup_cluster_no_bitmap 0 53328 NULL
108658 +gsm_control_reply_53333 gsm_control_reply 4 53333 NULL
108659 +vm_mmap_53339 vm_mmap 0 53339 NULL
108660 +vendorextnIoctl_53350 vendorextnIoctl 0 53350 NULL nohasharray
108661 +btrfs_find_all_roots_53350 btrfs_find_all_roots 0 53350 &vendorextnIoctl_53350
108662 +read_6120_creg32_53363 read_6120_creg32 0 53363 NULL
108663 +sock_setbindtodevice_53369 sock_setbindtodevice 3 53369 NULL
108664 +get_random_bytes_arch_53370 get_random_bytes_arch 2 53370 NULL
108665 +isolate_lru_page_53417 isolate_lru_page 0 53417 NULL
108666 +i915_gem_execbuffer_relocate_object_53435 i915_gem_execbuffer_relocate_object 0 53435 NULL
108667 +isr_cmd_cmplt_read_53439 isr_cmd_cmplt_read 3 53439 NULL
108668 +mwifiex_info_read_53447 mwifiex_info_read 3 53447 NULL
108669 +apei_exec_run_optional_53452 apei_exec_run_optional 0 53452 NULL
108670 +paging64_prefetch_gpte_53468 paging64_prefetch_gpte 4 53468 NULL
108671 +iowarrior_read_53483 iowarrior_read 3 53483 NULL
108672 +osd_req_write_kern_53486 osd_req_write_kern 5 53486 NULL
108673 +do_verify_xattr_datum_53499 do_verify_xattr_datum 0 53499 NULL
108674 +ext4_ext_grow_indepth_53503 ext4_ext_grow_indepth 0 53503 NULL
108675 +snd_pcm_format_physical_width_53505 snd_pcm_format_physical_width 0 53505 NULL
108676 +dbAllocNext_53506 dbAllocNext 0 53506 NULL
108677 +ocfs2_xattr_set_acl_53508 ocfs2_xattr_set_acl 4 53508 NULL
108678 +check_acl_53512 check_acl 0 53512 NULL
108679 +send_utimes_53516 send_utimes 0 53516 NULL
108680 +SYSC_bind_53582 SYSC_bind 3 53582 NULL
108681 +cifs_utf16_bytes_53593 cifs_utf16_bytes 0 53593 NULL
108682 +proc_uid_map_write_53596 proc_uid_map_write 3 53596 NULL
108683 +gfn_to_pfn_async_53597 gfn_to_pfn_async 2 53597 NULL
108684 +pfkey_recvmsg_53604 pfkey_recvmsg 4 53604 NULL
108685 +___alloc_bootmem_nopanic_53626 ___alloc_bootmem_nopanic 1 53626 NULL
108686 +xd_write_multiple_pages_53633 xd_write_multiple_pages 6-5 53633 NULL
108687 +stmpe_gpio_request_53634 stmpe_gpio_request 2 53634 NULL nohasharray
108688 +ccid_getsockopt_builtin_ccids_53634 ccid_getsockopt_builtin_ccids 2 53634 &stmpe_gpio_request_53634
108689 +nr_sendmsg_53656 nr_sendmsg 4 53656 NULL
108690 +fuse_fill_write_pages_53682 fuse_fill_write_pages 0-4 53682 NULL
108691 +v4l2_event_subscribe_53687 v4l2_event_subscribe 3 53687 NULL
108692 +bdev_logical_block_size_53690 bdev_logical_block_size 0 53690 NULL nohasharray
108693 +igb_alloc_q_vector_53690 igb_alloc_q_vector 6-4 53690 &bdev_logical_block_size_53690
108694 +find_overflow_devnum_53711 find_overflow_devnum 0 53711 NULL
108695 +bio_integrity_split_53714 bio_integrity_split 3 53714 NULL
108696 +__ocfs2_resv_find_window_53721 __ocfs2_resv_find_window 3 53721 NULL
108697 +__proc_debug_mb_53732 __proc_debug_mb 5 53732 NULL
108698 +wdm_write_53735 wdm_write 3 53735 NULL
108699 +ext3_try_to_allocate_with_rsv_53737 ext3_try_to_allocate_with_rsv 5-3-0 53737 NULL
108700 +da9052_disable_irq_53745 da9052_disable_irq 2 53745 NULL
108701 +lpfc_idiag_queacc_read_qe_53755 lpfc_idiag_queacc_read_qe 0-2 53755 NULL nohasharray
108702 +amdtp_out_stream_get_max_payload_53755 amdtp_out_stream_get_max_payload 0 53755 &lpfc_idiag_queacc_read_qe_53755
108703 +ext2_acl_count_53773 ext2_acl_count 0-1 53773 NULL
108704 +__kfifo_dma_in_prepare_r_53792 __kfifo_dma_in_prepare_r 4-5 53792 NULL
108705 +qp_alloc_host_work_53798 qp_alloc_host_work 5-3 53798 NULL
108706 +regmap_raw_write_53803 regmap_raw_write 2-4 53803 NULL
108707 +lpfc_idiag_ctlacc_read_reg_53809 lpfc_idiag_ctlacc_read_reg 0-3 53809 NULL
108708 +nls_nullsize_53815 nls_nullsize 0 53815 NULL
108709 +insert_pfn_53816 insert_pfn 3-0 53816 NULL
108710 +setup_data_read_53822 setup_data_read 3 53822 NULL
108711 +pms_read_53873 pms_read 3 53873 NULL
108712 +ieee80211_if_fmt_dropped_frames_congestion_53883 ieee80211_if_fmt_dropped_frames_congestion 3 53883 NULL
108713 +ocfs2_rm_xattr_cluster_53900 ocfs2_rm_xattr_cluster 4-5-3 53900 NULL nohasharray
108714 +SyS_setgroups_53900 SyS_setgroups 1 53900 &ocfs2_rm_xattr_cluster_53900
108715 +azx_via_get_position_53916 azx_via_get_position 0 53916 NULL
108716 +usb_serial_generic_write_53927 usb_serial_generic_write 4 53927 NULL
108717 +ocfs2_make_clusters_writable_53938 ocfs2_make_clusters_writable 5-4-0 53938 NULL
108718 +idetape_chrdev_write_53976 idetape_chrdev_write 3 53976 NULL
108719 +mthca_reg_user_mr_53980 mthca_reg_user_mr 2-3 53980 NULL
108720 +__ocfs2_xattr_set_value_outside_53981 __ocfs2_xattr_set_value_outside 5 53981 NULL
108721 +ieee80211_if_fmt_dot11MeshHWMPperrMinInterval_53998 ieee80211_if_fmt_dot11MeshHWMPperrMinInterval 3 53998 NULL
108722 +send_clone_54011 send_clone 0 54011 NULL
108723 +hfsplus_attr_build_key_54013 hfsplus_attr_build_key 0 54013 NULL
108724 +snd_pcm_lib_write_transfer_54018 snd_pcm_lib_write_transfer 5-2-4 54018 NULL
108725 +mdc_kuc_write_54019 mdc_kuc_write 3 54019 NULL
108726 +ipxrtr_route_packet_54036 ipxrtr_route_packet 4 54036 NULL
108727 +pipeline_dec_packet_out_read_54052 pipeline_dec_packet_out_read 3 54052 NULL
108728 +nl80211_send_disconnected_54056 nl80211_send_disconnected 5 54056 NULL
108729 +rproc_state_read_54057 rproc_state_read 3 54057 NULL
108730 +btrfs_start_transaction_54066 btrfs_start_transaction 2 54066 NULL
108731 +_malloc_54077 _malloc 1 54077 NULL
108732 +bitmap_bitremap_54096 bitmap_bitremap 4 54096 NULL
108733 +altera_set_ir_pre_54103 altera_set_ir_pre 2 54103 NULL nohasharray
108734 +lustre_posix_acl_xattr_filter_54103 lustre_posix_acl_xattr_filter 2 54103 &altera_set_ir_pre_54103
108735 +__comedi_buf_write_alloc_54112 __comedi_buf_write_alloc 0-2 54112 NULL
108736 +strn_len_54122 strn_len 0 54122 NULL
108737 +isku_receive_54130 isku_receive 4 54130 NULL
108738 +isr_host_acknowledges_read_54136 isr_host_acknowledges_read 3 54136 NULL
108739 +irq_blk_threshold_write_54138 irq_blk_threshold_write 3 54138 NULL
108740 +memcpy_toiovec_54166 memcpy_toiovec 3 54166 NULL
108741 +nouveau_falcon_create__54169 nouveau_falcon_create_ 8 54169 NULL
108742 +p9_client_prepare_req_54175 p9_client_prepare_req 3 54175 NULL
108743 +devm_request_threaded_irq_54215 devm_request_threaded_irq 0 54215 NULL
108744 +do_sys_poll_54221 do_sys_poll 2 54221 NULL
108745 +__register_chrdev_54223 __register_chrdev 2-3 54223 NULL
108746 +pi_read_regr_54231 pi_read_regr 0 54231 NULL
108747 +mcp23s08_read_regs_54246 mcp23s08_read_regs 4 54246 NULL
108748 +reada_add_block_54247 reada_add_block 2 54247 NULL
108749 +write_file_spec_scan_ctl_54248 write_file_spec_scan_ctl 3 54248 NULL
108750 +jbd2__journal_restart_54249 jbd2__journal_restart 0 54249 NULL
108751 +barrier_all_devices_54254 barrier_all_devices 0 54254 NULL nohasharray
108752 +xfs_dir2_sf_addname_hard_54254 xfs_dir2_sf_addname_hard 3 54254 &barrier_all_devices_54254
108753 +ceph_msgpool_get_54258 ceph_msgpool_get 2 54258 NULL
108754 +wusb_prf_54261 wusb_prf 7 54261 NULL nohasharray
108755 +audio_write_54261 audio_write 4 54261 &wusb_prf_54261
108756 +mwifiex_getlog_read_54269 mwifiex_getlog_read 3 54269 NULL
108757 +kstrtou16_from_user_54274 kstrtou16_from_user 2 54274 NULL
108758 +ubi_calc_data_len_54279 ubi_calc_data_len 0-3 54279 NULL
108759 +altera_set_dr_post_54291 altera_set_dr_post 2 54291 NULL
108760 +dlm_alloc_pagevec_54296 dlm_alloc_pagevec 1 54296 NULL
108761 +get_iovec_page_array_54298 get_iovec_page_array 6 54298 NULL
108762 +ttm_mem_global_alloc_54299 ttm_mem_global_alloc 0 54299 NULL
108763 +reclaim_pages_54301 reclaim_pages 3 54301 NULL
108764 +sprintf_54306 sprintf 0 54306 NULL
108765 +bio_add_pc_page_54319 bio_add_pc_page 4 54319 NULL
108766 +br_fdb_fillbuf_54339 br_fdb_fillbuf 0 54339 NULL
108767 +__alloc_dev_table_54343 __alloc_dev_table 2 54343 NULL
108768 +__get_free_pages_54352 __get_free_pages 0 54352 NULL
108769 +tcf_hash_create_54360 tcf_hash_create 4 54360 NULL
108770 +read_file_credit_dist_stats_54367 read_file_credit_dist_stats 3 54367 NULL
108771 +vfs_readlink_54368 vfs_readlink 3 54368 NULL
108772 +do_dccp_setsockopt_54377 do_dccp_setsockopt 5 54377 NULL nohasharray
108773 +intel_sdvo_write_cmd_54377 intel_sdvo_write_cmd 4 54377 &do_dccp_setsockopt_54377
108774 +ah_alloc_tmp_54378 ah_alloc_tmp 2-3 54378 NULL
108775 +gart_unmap_page_54379 gart_unmap_page 3-2 54379 NULL
108776 +snd_pcm_oss_read2_54387 snd_pcm_oss_read2 3-0 54387 NULL
108777 +iwl_dbgfs_power_save_status_read_54392 iwl_dbgfs_power_save_status_read 3 54392 NULL
108778 +efx_nic_describe_stats_54407 efx_nic_describe_stats 2 54407 NULL
108779 +ll_ra_count_get_54410 ll_ra_count_get 3 54410 NULL
108780 +copy_gadget_strings_54417 copy_gadget_strings 3-2 54417 NULL
108781 +btrfs_inc_extent_ref_54442 btrfs_inc_extent_ref 0 54442 NULL
108782 +sparse_early_mem_maps_alloc_node_54485 sparse_early_mem_maps_alloc_node 4 54485 NULL
108783 +simple_strtoull_54493 simple_strtoull 0 54493 NULL
108784 +swiotlb_tbl_map_single_54495 swiotlb_tbl_map_single 0 54495 NULL
108785 +btrfs_ordered_sum_size_54509 btrfs_ordered_sum_size 0-2 54509 NULL
108786 +cgroup_write_X64_54514 cgroup_write_X64 5 54514 NULL
108787 +rfc4106_set_key_54519 rfc4106_set_key 3 54519 NULL
108788 +vmci_transport_dgram_enqueue_54525 vmci_transport_dgram_enqueue 4 54525 NULL
108789 +viacam_read_54526 viacam_read 3 54526 NULL
108790 +unix_dgram_connect_54535 unix_dgram_connect 3 54535 NULL
108791 +setsockopt_54539 setsockopt 5 54539 NULL
108792 +i915_reset_gen7_sol_offsets_54547 i915_reset_gen7_sol_offsets 0 54547 NULL
108793 +lbs_lowsnr_write_54549 lbs_lowsnr_write 3 54549 NULL
108794 +i915_gem_get_seqno_54555 i915_gem_get_seqno 0 54555 NULL
108795 +btrfs_update_inode_item_54561 btrfs_update_inode_item 0 54561 NULL nohasharray
108796 +SYSC_setsockopt_54561 SYSC_setsockopt 5 54561 &btrfs_update_inode_item_54561
108797 +nfsd_vfs_write_54577 nfsd_vfs_write 6 54577 NULL
108798 +fw_iso_buffer_init_54582 fw_iso_buffer_init 3 54582 NULL
108799 +nvme_npages_54601 nvme_npages 0-1 54601 NULL
108800 +irq_pkt_threshold_write_54605 irq_pkt_threshold_write 3 54605 NULL
108801 +devm_gen_pool_create_54607 devm_gen_pool_create 3 54607 NULL
108802 +port_fops_write_54627 port_fops_write 3 54627 NULL
108803 +irq_timeout_read_54653 irq_timeout_read 3 54653 NULL
108804 +dns_resolver_read_54658 dns_resolver_read 3 54658 NULL
108805 +twl6030_interrupt_mask_54659 twl6030_interrupt_mask 2 54659 NULL
108806 +kvm_read_cr3_54662 kvm_read_cr3 0 54662 NULL
108807 +bus_add_device_54665 bus_add_device 0 54665 NULL
108808 +cw1200_queue_stats_init_54670 cw1200_queue_stats_init 2 54670 NULL
108809 +bio_kmalloc_54672 bio_kmalloc 2 54672 NULL
108810 +vring_new_virtqueue_54673 vring_new_virtqueue 2 54673 NULL
108811 +evm_read_key_54674 evm_read_key 3 54674 NULL
108812 +fs_path_add_path_54680 fs_path_add_path 0 54680 NULL
108813 +platform_get_irq_byname_54700 platform_get_irq_byname 0 54700 NULL
108814 +__btrfs_inc_extent_ref_54706 __btrfs_inc_extent_ref 7-0 54706 NULL
108815 +rfkill_fop_read_54711 rfkill_fop_read 3 54711 NULL
108816 +clk_divider_set_rate_54726 clk_divider_set_rate 3-2 54726 NULL
108817 +ocfs2_control_write_54737 ocfs2_control_write 3 54737 NULL
108818 +kzalloc_54740 kzalloc 1 54740 NULL
108819 +wep_iv_read_54744 wep_iv_read 3 54744 NULL
108820 +lpfc_idiag_pcicfg_write_54749 lpfc_idiag_pcicfg_write 3 54749 NULL
108821 +iio_event_chrdev_read_54757 iio_event_chrdev_read 3 54757 NULL
108822 +adis16480_show_firmware_date_54762 adis16480_show_firmware_date 3 54762 NULL
108823 +ldsem_atomic_update_54774 ldsem_atomic_update 1-0 54774 NULL
108824 +gpiochip_add_54781 gpiochip_add 0 54781 NULL
108825 +flexcop_device_kmalloc_54793 flexcop_device_kmalloc 1 54793 NULL
108826 +domain_init_54797 domain_init 2 54797 NULL
108827 +ext3_find_goal_54801 ext3_find_goal 0 54801 NULL
108828 +get_dev_size_54807 get_dev_size 0 54807 NULL
108829 +nfsd_write_54809 nfsd_write 6 54809 NULL
108830 +aes_decrypt_fail_read_54815 aes_decrypt_fail_read 3 54815 NULL nohasharray
108831 +kvzalloc_54815 kvzalloc 1 54815 &aes_decrypt_fail_read_54815 nohasharray
108832 +crypto_tfm_ctx_alignment_54815 crypto_tfm_ctx_alignment 0 54815 &kvzalloc_54815
108833 +generic_perform_write_54832 generic_perform_write 3 54832 NULL
108834 +write_rio_54837 write_rio 3 54837 NULL
108835 +nouveau_engctx_create__54839 nouveau_engctx_create_ 8 54839 NULL nohasharray
108836 +ext3_acl_from_disk_54839 ext3_acl_from_disk 2 54839 &nouveau_engctx_create__54839
108837 +ufx_ops_write_54848 ufx_ops_write 3 54848 NULL
108838 +printer_read_54851 printer_read 3 54851 NULL
108839 +qib_reg_user_mr_54858 qib_reg_user_mr 2-3 54858 NULL
108840 +alloc_ep_req_54860 alloc_ep_req 2 54860 NULL
108841 +broadsheet_spiflash_rewrite_sector_54864 broadsheet_spiflash_rewrite_sector 2 54864 NULL
108842 +prism_build_supp_rates_54865 prism_build_supp_rates 0 54865 NULL
108843 +iscsi_pool_init_54913 iscsi_pool_init 4-2 54913 NULL nohasharray
108844 +kobject_set_name_vargs_54913 kobject_set_name_vargs 0 54913 &iscsi_pool_init_54913
108845 +btrfs_stack_chunk_num_stripes_54923 btrfs_stack_chunk_num_stripes 0 54923 NULL
108846 +bio_add_page_54933 bio_add_page 0-3 54933 NULL
108847 +mxms_structlen_54939 mxms_structlen 0 54939 NULL
108848 +add_port_54941 add_port 2 54941 NULL
108849 +ath9k_dump_btcoex_54949 ath9k_dump_btcoex 0 54949 NULL
108850 +alauda_write_data_54967 alauda_write_data 3 54967 NULL
108851 +c4_add_card_54968 c4_add_card 3 54968 NULL
108852 +iwl_pcie_dump_fh_54975 iwl_pcie_dump_fh 0 54975 NULL
108853 +ubi_change_vtbl_record_54979 ubi_change_vtbl_record 0 54979 NULL
108854 +ext3_xattr_get_54989 ext3_xattr_get 0 54989 NULL
108855 +rds_ib_inc_copy_to_user_55007 rds_ib_inc_copy_to_user 3 55007 NULL
108856 +mem_cgroup_get_lru_size_55008 mem_cgroup_get_lru_size 0 55008 NULL
108857 +cx231xx_v4l2_read_55014 cx231xx_v4l2_read 3 55014 NULL
108858 +paging32_get_level1_sp_gpa_55022 paging32_get_level1_sp_gpa 0 55022 NULL
108859 +error_error_null_Frame_tx_start_read_55024 error_error_null_Frame_tx_start_read 3 55024 NULL
108860 +dgap_do_bios_load_55025 dgap_do_bios_load 3 55025 NULL
108861 +btrfs_init_acl_55028 btrfs_init_acl 0 55028 NULL
108862 +write_ctree_super_55039 write_ctree_super 0 55039 NULL
108863 +ext4_ext_handle_uninitialized_extents_55059 ext4_ext_handle_uninitialized_extents 0-6 55059 NULL
108864 +apei_exec_run_55075 apei_exec_run 0 55075 NULL
108865 +bitmap_storage_alloc_55077 bitmap_storage_alloc 2 55077 NULL
108866 +snd_pcm_capture_hw_avail_55086 snd_pcm_capture_hw_avail 0 55086 NULL nohasharray
108867 +read_dma_55086 read_dma 3 55086 &snd_pcm_capture_hw_avail_55086
108868 +rxpipe_beacon_buffer_thres_host_int_trig_rx_data_read_55106 rxpipe_beacon_buffer_thres_host_int_trig_rx_data_read 3 55106 NULL
108869 +corrupt_data_55120 corrupt_data 0-3 55120 NULL
108870 +crypto_ahash_setkey_55134 crypto_ahash_setkey 3 55134 NULL
108871 +ocfs2_prepare_refcount_change_for_del_55137 ocfs2_prepare_refcount_change_for_del 3-0 55137 NULL nohasharray
108872 +filldir_55137 filldir 3 55137 &ocfs2_prepare_refcount_change_for_del_55137
108873 +validate_vid_hdr_55145 validate_vid_hdr 0 55145 NULL
108874 +ocfs2_truncate_file_55148 ocfs2_truncate_file 3 55148 NULL
108875 +npages_to_npools_55149 npages_to_npools 0-1 55149 NULL
108876 +ieee80211_if_read_uapsd_queues_55150 ieee80211_if_read_uapsd_queues 3 55150 NULL
108877 +mtd_get_fact_prot_info_55186 mtd_get_fact_prot_info 0 55186 NULL
108878 +sel_write_relabel_55195 sel_write_relabel 3 55195 NULL
108879 +sched_feat_write_55202 sched_feat_write 3 55202 NULL
108880 +ht40allow_map_read_55209 ht40allow_map_read 3 55209 NULL
108881 +__kfifo_dma_out_prepare_r_55211 __kfifo_dma_out_prepare_r 4-5 55211 NULL
108882 +do_raw_setsockopt_55215 do_raw_setsockopt 5 55215 NULL
108883 +qxl_alloc_client_monitors_config_55216 qxl_alloc_client_monitors_config 2 55216 NULL
108884 +dbAllocDmap_55227 dbAllocDmap 0 55227 NULL
108885 +hash_netport6_expire_55232 hash_netport6_expire 3 55232 NULL
108886 +memcpy_fromiovec_55247 memcpy_fromiovec 3 55247 NULL
108887 +lbs_failcount_write_55276 lbs_failcount_write 3 55276 NULL
108888 +persistent_ram_new_55286 persistent_ram_new 2-1 55286 NULL
108889 +ptrace_request_55288 ptrace_request 3 55288 NULL
108890 +rx_streaming_interval_read_55291 rx_streaming_interval_read 3 55291 NULL
108891 +lov_get_stripecnt_55297 lov_get_stripecnt 0-3 55297 NULL
108892 +gsm_control_modem_55303 gsm_control_modem 3 55303 NULL
108893 +wimax_msg_len_55304 wimax_msg_len 0 55304 NULL
108894 +__get_vm_area_node_55305 __get_vm_area_node 6 55305 NULL nohasharray
108895 +qp_alloc_guest_work_55305 qp_alloc_guest_work 5-3 55305 &__get_vm_area_node_55305
108896 +__vxge_hw_vpath_initialize_55328 __vxge_hw_vpath_initialize 2 55328 NULL
108897 +do_shmat_55336 do_shmat 5 55336 NULL
108898 +vme_user_read_55338 vme_user_read 3 55338 NULL
108899 +sctp_datamsg_from_user_55342 sctp_datamsg_from_user 4 55342 NULL nohasharray
108900 +__wa_xfer_setup_sizes_55342 __wa_xfer_setup_sizes 0 55342 &sctp_datamsg_from_user_55342
108901 +iterate_inode_extrefs_55362 iterate_inode_extrefs 0 55362 NULL nohasharray
108902 +acpi_system_read_event_55362 acpi_system_read_event 3 55362 &iterate_inode_extrefs_55362
108903 +cw1200_sdio_align_size_55391 cw1200_sdio_align_size 2 55391 NULL
108904 +__domain_mapping_55393 __domain_mapping 5 55393 NULL
108905 +iwl_dbgfs_plcp_delta_read_55407 iwl_dbgfs_plcp_delta_read 3 55407 NULL
108906 +si476x_radio_read_rds_blckcnt_blob_55427 si476x_radio_read_rds_blckcnt_blob 3 55427 NULL
108907 +SyS_read_55449 SyS_read 3 55449 NULL
108908 +add_relation_rb_55451 add_relation_rb 0 55451 NULL
108909 +__vxge_hw_channel_allocate_55462 __vxge_hw_channel_allocate 3 55462 NULL
108910 +cx23888_ir_rx_read_55473 cx23888_ir_rx_read 3 55473 NULL
108911 +snd_pcm_lib_write_55483 snd_pcm_lib_write 0-3 55483 NULL
108912 +i2o_pool_alloc_55485 i2o_pool_alloc 4 55485 NULL
108913 +ocfs2_rec_clusters_55501 ocfs2_rec_clusters 0 55501 NULL nohasharray
108914 +ras_stride_increase_window_55501 ras_stride_increase_window 3 55501 &ocfs2_rec_clusters_55501
108915 +ext4_flex_bg_size_55502 ext4_flex_bg_size 0 55502 NULL
108916 +tx_tx_done_int_template_read_55511 tx_tx_done_int_template_read 3 55511 NULL
108917 +ea_get_55522 ea_get 3-0 55522 NULL
108918 +buffer_size_55534 buffer_size 0 55534 NULL
108919 +set_msr_interception_55538 set_msr_interception 2 55538 NULL
108920 +tty_port_register_device_55543 tty_port_register_device 3 55543 NULL
108921 +dgap_do_config_load_55548 dgap_do_config_load 2 55548 NULL
108922 +dm_stats_list_55551 dm_stats_list 4 55551 NULL
108923 +gfs2_bitfit_55566 gfs2_bitfit 2-3-0 55566 NULL
108924 +hash_netport4_expire_55584 hash_netport4_expire 3 55584 NULL
108925 +add_partition_55588 add_partition 2 55588 NULL
108926 +kstrtou8_from_user_55599 kstrtou8_from_user 2 55599 NULL
108927 +SyS_keyctl_55602 SyS_keyctl 4 55602 NULL
108928 +allocate_without_wrapping_disk_55607 allocate_without_wrapping_disk 4 55607 NULL
108929 +macvtap_put_user_55609 macvtap_put_user 4 55609 NULL
108930 +selinux_setprocattr_55611 selinux_setprocattr 4 55611 NULL
108931 +edge_tty_recv_55622 edge_tty_recv 3 55622 NULL
108932 +snd_pcm_hw_param_last_55624 snd_pcm_hw_param_last 0 55624 NULL
108933 +reiserfs_xattr_get_55628 reiserfs_xattr_get 0 55628 NULL nohasharray
108934 +pktgen_if_write_55628 pktgen_if_write 3 55628 &reiserfs_xattr_get_55628
108935 +osc_obd_max_pages_per_rpc_seq_write_55636 osc_obd_max_pages_per_rpc_seq_write 3 55636 NULL
108936 +dvb_dmxdev_set_buffer_size_55643 dvb_dmxdev_set_buffer_size 2 55643 NULL
108937 +mlx4_buddy_alloc_55647 mlx4_buddy_alloc 2 55647 NULL
108938 +xfs_bmbt_maxrecs_55649 xfs_bmbt_maxrecs 0-2 55649 NULL
108939 +lpfc_idiag_queinfo_read_55662 lpfc_idiag_queinfo_read 3 55662 NULL
108940 +il_dbgfs_tx_queue_read_55668 il_dbgfs_tx_queue_read 3 55668 NULL
108941 +btrfs_reloc_cow_block_55672 btrfs_reloc_cow_block 0 55672 NULL
108942 +get_info_55681 get_info 3 55681 NULL
108943 +iwl_dbgfs_plcp_delta_write_55682 iwl_dbgfs_plcp_delta_write 3 55682 NULL
108944 +pm8001_store_update_fw_55716 pm8001_store_update_fw 4 55716 NULL
108945 +ocfs2_lock_refcount_tree_55719 ocfs2_lock_refcount_tree 0 55719 NULL nohasharray
108946 +mtdswap_init_55719 mtdswap_init 2 55719 &ocfs2_lock_refcount_tree_55719
108947 +tap_pwup_write_55723 tap_pwup_write 3 55723 NULL
108948 +__iio_allocate_kfifo_55738 __iio_allocate_kfifo 2 55738 NULL
108949 +set_local_name_55757 set_local_name 4 55757 NULL
108950 +strlen_55778 strlen 0 55778 NULL nohasharray
108951 +is_idx_node_in_tnc_55778 is_idx_node_in_tnc 0 55778 &strlen_55778
108952 +set_spte_55783 set_spte 4-5 55783 NULL
108953 +req_bio_endio_55786 req_bio_endio 3 55786 NULL nohasharray
108954 +conf_read_55786 conf_read 3 55786 &req_bio_endio_55786
108955 +uwb_rc_neh_grok_event_55799 uwb_rc_neh_grok_event 3 55799 NULL
108956 +sb16_copy_from_user_55836 sb16_copy_from_user 7-6-10 55836 NULL
108957 +ept_gva_to_gpa_55848 ept_gva_to_gpa 2 55848 NULL
108958 +ip_hdrlen_55849 ip_hdrlen 0 55849 NULL
108959 +hcd_alloc_coherent_55862 hcd_alloc_coherent 5 55862 NULL
108960 +shmem_setxattr_55867 shmem_setxattr 4 55867 NULL
108961 +__check_block_validity_55869 __check_block_validity 0 55869 NULL
108962 +hsc_write_55875 hsc_write 3 55875 NULL
108963 +pm_qos_power_read_55891 pm_qos_power_read 3 55891 NULL
108964 +snd_pcm_hw_param_value_min_55917 snd_pcm_hw_param_value_min 0 55917 NULL
108965 +ext2_direct_IO_55932 ext2_direct_IO 4 55932 NULL
108966 +paging64_page_fault_55942 paging64_page_fault 2 55942 NULL
108967 +kvm_write_guest_virt_system_55944 kvm_write_guest_virt_system 4-2 55944 NULL
108968 +sel_read_policy_55947 sel_read_policy 3 55947 NULL
108969 +ceph_get_direct_page_vector_55956 ceph_get_direct_page_vector 2 55956 NULL
108970 +simple_read_from_buffer_55957 simple_read_from_buffer 5-2 55957 NULL
108971 +tx_tx_imm_resp_read_55964 tx_tx_imm_resp_read 3 55964 NULL
108972 +wa_xfer_create_subset_sg_55992 wa_xfer_create_subset_sg 2-3 55992 NULL
108973 +nvme_alloc_iod_56027 nvme_alloc_iod 1-2 56027 NULL
108974 +dccp_sendmsg_56058 dccp_sendmsg 4 56058 NULL
108975 +__set_discard_56081 __set_discard 2 56081 NULL
108976 +pscsi_get_bio_56103 pscsi_get_bio 1 56103 NULL
108977 +usb_alloc_stream_buffers_56123 usb_alloc_stream_buffers 3 56123 NULL
108978 +sel_read_handle_status_56139 sel_read_handle_status 3 56139 NULL
108979 +write_file_frameerrors_56145 write_file_frameerrors 3 56145 NULL
108980 +add_extent_mapping_56157 add_extent_mapping 0 56157 NULL
108981 +__i2c_transfer_56162 __i2c_transfer 0 56162 NULL
108982 +rawv6_setsockopt_56165 rawv6_setsockopt 5 56165 NULL
108983 +create_irq_nr_56180 create_irq_nr 1-0-2 56180 NULL
108984 +ath9k_dump_legacy_btcoex_56194 ath9k_dump_legacy_btcoex 0 56194 NULL
108985 +ocfs2_journal_access_gd_56209 ocfs2_journal_access_gd 0 56209 NULL
108986 +update_space_info_56213 update_space_info 0 56213 NULL
108987 +ncp_read_bounce_size_56221 ncp_read_bounce_size 0-1 56221 NULL
108988 +vring_add_indirect_56222 vring_add_indirect 4 56222 NULL
108989 +ocfs2_find_xe_in_bucket_56224 ocfs2_find_xe_in_bucket 0 56224 NULL
108990 +do_ipt_set_ctl_56238 do_ipt_set_ctl 4 56238 NULL
108991 +fd_copyin_56247 fd_copyin 3 56247 NULL
108992 +sk_rmem_schedule_56255 sk_rmem_schedule 3 56255 NULL
108993 +p9pdu_vreadf_56271 p9pdu_vreadf 0 56271 NULL
108994 +il4965_ucode_general_stats_read_56277 il4965_ucode_general_stats_read 3 56277 NULL
108995 +ieee80211_if_fmt_user_power_level_56283 ieee80211_if_fmt_user_power_level 3 56283 NULL
108996 +RESIZE_IF_NEEDED_56286 RESIZE_IF_NEEDED 2 56286 NULL
108997 +dvb_aplay_56296 dvb_aplay 3 56296 NULL
108998 +btmrvl_hscfgcmd_read_56303 btmrvl_hscfgcmd_read 3 56303 NULL
108999 +speakup_file_write_56310 speakup_file_write 3 56310 NULL
109000 +pipeline_pre_to_defrag_swi_read_56321 pipeline_pre_to_defrag_swi_read 3 56321 NULL
109001 +journal_init_revoke_table_56331 journal_init_revoke_table 1 56331 NULL
109002 +snd_rawmidi_read_56337 snd_rawmidi_read 3 56337 NULL
109003 +ipv6_recv_error_56347 ipv6_recv_error 3 56347 NULL
109004 +vxge_os_dma_malloc_async_56348 vxge_os_dma_malloc_async 3 56348 NULL
109005 +mite_device_bytes_transferred_56355 mite_device_bytes_transferred 0 56355 NULL
109006 +iov_iter_copy_from_user_atomic_56368 iov_iter_copy_from_user_atomic 0-4 56368 NULL
109007 +dev_read_56369 dev_read 3 56369 NULL
109008 +ath10k_read_simulate_fw_crash_56371 ath10k_read_simulate_fw_crash 3 56371 NULL
109009 +ata_qc_complete_multiple_56376 ata_qc_complete_multiple 2 56376 NULL
109010 +snd_pcm_common_ioctl1_56382 snd_pcm_common_ioctl1 0 56382 NULL
109011 +write_gssp_56404 write_gssp 3 56404 NULL
109012 +ocfs2_control_read_56405 ocfs2_control_read 3 56405 NULL
109013 +do_get_write_access_56410 do_get_write_access 0 56410 NULL
109014 +i915_gem_object_sync_56417 i915_gem_object_sync 0 56417 NULL nohasharray
109015 +store_msg_56417 store_msg 3 56417 &i915_gem_object_sync_56417
109016 +pppol2tp_sendmsg_56420 pppol2tp_sendmsg 4 56420 NULL
109017 +fl_create_56435 fl_create 5 56435 NULL
109018 +gnttab_map_56439 gnttab_map 2 56439 NULL
109019 +cx231xx_init_isoc_56453 cx231xx_init_isoc 3-2-4 56453 NULL
109020 +set_connectable_56458 set_connectable 4 56458 NULL
109021 +osd_req_list_partition_objects_56464 osd_req_list_partition_objects 5 56464 NULL
109022 +putused_user_56467 putused_user 3 56467 NULL
109023 +lbs_rdmac_write_56471 lbs_rdmac_write 3 56471 NULL
109024 +calc_linear_pos_56472 calc_linear_pos 0-3 56472 NULL
109025 +global_rt_period_56476 global_rt_period 0 56476 NULL
109026 +crypto_shash_alignmask_56486 crypto_shash_alignmask 0 56486 NULL
109027 +ieee80211_rx_mgmt_probe_beacon_56491 ieee80211_rx_mgmt_probe_beacon 3 56491 NULL
109028 +cfs_access_process_vm_56503 cfs_access_process_vm 2-4-0 56503 NULL
109029 +init_map_ip_56508 init_map_ip 5 56508 NULL
109030 +lustre_posix_acl_xattr_reduce_space_56512 lustre_posix_acl_xattr_reduce_space 3 56512 NULL
109031 +ext4_zeroout_es_56514 ext4_zeroout_es 0 56514 NULL
109032 +cfg80211_connect_result_56515 cfg80211_connect_result 6-4 56515 NULL
109033 +ip_options_get_56538 ip_options_get 4 56538 NULL
109034 +ll_wr_track_id_56544 ll_wr_track_id 2 56544 NULL
109035 +vb2_queue_or_prepare_buf_56547 vb2_queue_or_prepare_buf 0 56547 NULL
109036 +ocfs2_change_extent_flag_56549 ocfs2_change_extent_flag 5 56549 NULL
109037 +alloc_apertures_56561 alloc_apertures 1 56561 NULL
109038 +rs_sta_dbgfs_stats_table_read_56573 rs_sta_dbgfs_stats_table_read 3 56573 NULL
109039 +portcntrs_2_read_56586 portcntrs_2_read 3 56586 NULL
109040 +event_filter_write_56609 event_filter_write 3 56609 NULL
109041 +nvme_trans_log_temperature_56613 nvme_trans_log_temperature 3 56613 NULL
109042 +gather_array_56641 gather_array 3 56641 NULL
109043 +lookup_extent_backref_56644 lookup_extent_backref 9-0 56644 NULL
109044 +uvc_debugfs_stats_read_56651 uvc_debugfs_stats_read 3 56651 NULL
109045 +tg3_nvram_write_block_56666 tg3_nvram_write_block 3 56666 NULL
109046 +btrfs_cow_block_56678 btrfs_cow_block 0 56678 NULL
109047 +snd_gus_dram_read_56686 snd_gus_dram_read 4 56686 NULL nohasharray
109048 +da9055_gpio_to_irq_56686 da9055_gpio_to_irq 2 56686 &snd_gus_dram_read_56686
109049 +build_map_info_56696 build_map_info 2 56696 NULL
109050 +dvb_ringbuffer_read_user_56702 dvb_ringbuffer_read_user 3-0 56702 NULL
109051 +sta_flags_read_56710 sta_flags_read 3 56710 NULL
109052 +ipv6_getsockopt_sticky_56711 ipv6_getsockopt_sticky 5 56711 NULL
109053 +__wa_xfer_setup_segs_56725 __wa_xfer_setup_segs 2 56725 NULL
109054 +__copy_from_user_ll_56738 __copy_from_user_ll 0-3 56738 NULL
109055 +pcpu_populate_chunk_56741 pcpu_populate_chunk 3-2 56741 NULL
109056 +drm_agp_bind_pages_56748 drm_agp_bind_pages 3 56748 NULL
109057 +btrfsic_map_block_56751 btrfsic_map_block 2 56751 NULL
109058 +alloc_iommu_56778 alloc_iommu 2-3-0 56778 NULL
109059 +hash_lookup_56792 hash_lookup 2 56792 NULL nohasharray
109060 +ttm_alloc_new_pages_56792 ttm_alloc_new_pages 5 56792 &hash_lookup_56792
109061 +do_syslog_56807 do_syslog 3 56807 NULL
109062 +ext4_ext_rm_idx_56827 ext4_ext_rm_idx 0 56827 NULL
109063 +mtdchar_write_56831 mtdchar_write 3 56831 NULL nohasharray
109064 +ntfs_rl_realloc_56831 ntfs_rl_realloc 3 56831 &mtdchar_write_56831
109065 +sysctl_sync_threshold_56835 sysctl_sync_threshold 0 56835 NULL
109066 +snd_rawmidi_kernel_write1_56847 snd_rawmidi_kernel_write1 4-0 56847 NULL
109067 +si476x_radio_read_agc_blob_56849 si476x_radio_read_agc_blob 3 56849 NULL
109068 +wb_lookup_56858 wb_lookup 2 56858 NULL
109069 +ext3_xattr_ibody_get_56880 ext3_xattr_ibody_get 0 56880 NULL
109070 +pvr2_debugifc_print_status_56890 pvr2_debugifc_print_status 3 56890 NULL
109071 +debug_debug3_read_56894 debug_debug3_read 3 56894 NULL
109072 +batadv_tt_update_changes_56895 batadv_tt_update_changes 3 56895 NULL
109073 +hfsplus_find_cat_56899 hfsplus_find_cat 0 56899 NULL
109074 +hfsplus_setxattr_56902 hfsplus_setxattr 4 56902 NULL
109075 +__bitmap_clear_bits_56912 __bitmap_clear_bits 3 56912 NULL
109076 +strcspn_56913 strcspn 0 56913 NULL
109077 +__kfifo_out_56927 __kfifo_out 0-3 56927 NULL
109078 +CopyBufferToControlPacket_56933 CopyBufferToControlPacket 0 56933 NULL nohasharray
109079 +journal_init_revoke_56933 journal_init_revoke 2 56933 &CopyBufferToControlPacket_56933
109080 +nouveau_xtensa_create__56952 nouveau_xtensa_create_ 8 56952 NULL
109081 +diva_get_driver_info_56967 diva_get_driver_info 0 56967 NULL
109082 +nouveau_device_create__56984 nouveau_device_create_ 6 56984 NULL
109083 +sptlrpc_secflags2str_56995 sptlrpc_secflags2str 3 56995 NULL
109084 +vlsi_alloc_ring_57003 vlsi_alloc_ring 3-4 57003 NULL
109085 +btrfs_super_csum_size_57004 btrfs_super_csum_size 0 57004 NULL
109086 +aircable_process_packet_57027 aircable_process_packet 4 57027 NULL
109087 +i915_gem_evict_everything_57038 i915_gem_evict_everything 0 57038 NULL
109088 +skb_network_offset_57043 skb_network_offset 0 57043 NULL nohasharray
109089 +ieee80211_if_fmt_state_57043 ieee80211_if_fmt_state 3 57043 &skb_network_offset_57043
109090 +bytes_to_samples_57049 bytes_to_samples 0-2 57049 NULL
109091 +xfs_buf_read_map_57053 xfs_buf_read_map 3 57053 NULL
109092 +__wl_get_peb_57058 __wl_get_peb 0 57058 NULL
109093 +cx2341x_ctrl_new_std_57061 cx2341x_ctrl_new_std 4 57061 NULL
109094 +sca3000_read_data_57064 sca3000_read_data 4 57064 NULL
109095 +pcmcia_replace_cis_57066 pcmcia_replace_cis 3 57066 NULL
109096 +tracing_set_trace_write_57096 tracing_set_trace_write 3 57096 NULL
109097 +altera_get_note_57099 altera_get_note 6 57099 NULL
109098 +hpfs_readpages_57106 hpfs_readpages 4 57106 NULL
109099 +snd_pcm_hw_params_old_user_57108 snd_pcm_hw_params_old_user 0 57108 NULL
109100 +crypto_compress_ctxsize_57109 crypto_compress_ctxsize 0 57109 NULL
109101 +sysfs_write_file_57116 sysfs_write_file 3 57116 NULL
109102 +cipso_v4_gentag_loc_57119 cipso_v4_gentag_loc 0 57119 NULL
109103 +nl80211_send_deauth_57136 nl80211_send_deauth 4 57136 NULL nohasharray
109104 +rds_ib_sub_signaled_57136 rds_ib_sub_signaled 2 57136 &nl80211_send_deauth_57136 nohasharray
109105 +ima_show_htable_value_57136 ima_show_htable_value 2 57136 &rds_ib_sub_signaled_57136
109106 +snd_sonicvibes_getdmac_57140 snd_sonicvibes_getdmac 0 57140 NULL
109107 +changed_inode_57156 changed_inode 0 57156 NULL
109108 +udl_prime_create_57159 udl_prime_create 2 57159 NULL
109109 +__ipath_get_user_pages_57166 __ipath_get_user_pages 1-2 57166 NULL
109110 +stk_prepare_sio_buffers_57168 stk_prepare_sio_buffers 2 57168 NULL
109111 +rx_hw_stuck_read_57179 rx_hw_stuck_read 3 57179 NULL
109112 +ocfs2_claim_metadata_57192 ocfs2_claim_metadata 0 57192 NULL
109113 +tt3650_ci_msg_57219 tt3650_ci_msg 4 57219 NULL
109114 +dma_fifo_alloc_57236 dma_fifo_alloc 5-3-2 57236 NULL
109115 +flush_space_57241 flush_space 3-0 57241 NULL
109116 +rsxx_cram_write_57244 rsxx_cram_write 3 57244 NULL
109117 +ieee80211_if_fmt_tsf_57249 ieee80211_if_fmt_tsf 3 57249 NULL
109118 +oprofilefs_ulong_from_user_57251 oprofilefs_ulong_from_user 3 57251 NULL
109119 +alloc_flex_gd_57259 alloc_flex_gd 1 57259 NULL
109120 +lbs_sleepparams_write_57283 lbs_sleepparams_write 3 57283 NULL
109121 +pstore_file_read_57288 pstore_file_read 3 57288 NULL
109122 +snd_pcm_read_57289 snd_pcm_read 3 57289 NULL
109123 +fw_file_size_57307 fw_file_size 0 57307 NULL
109124 +ftdi_elan_write_57309 ftdi_elan_write 3 57309 NULL
109125 +write_file_regval_57313 write_file_regval 3 57313 NULL
109126 +__mxt_write_reg_57326 __mxt_write_reg 3 57326 NULL
109127 +ocfs2_xattr_shrink_size_57328 ocfs2_xattr_shrink_size 3 57328 NULL
109128 +usblp_read_57342 usblp_read 3 57342 NULL
109129 +print_devstats_dot11RTSFailureCount_57347 print_devstats_dot11RTSFailureCount 3 57347 NULL
109130 +dio_send_cur_page_57348 dio_send_cur_page 0 57348 NULL
109131 +tipc_bclink_stats_57372 tipc_bclink_stats 2 57372 NULL
109132 +max8997_irq_domain_map_57375 max8997_irq_domain_map 2 57375 NULL
109133 +tty_register_device_attr_57381 tty_register_device_attr 2 57381 NULL
109134 +read_file_blob_57406 read_file_blob 3 57406 NULL
109135 +enclosure_register_57412 enclosure_register 3 57412 NULL
109136 +compat_keyctl_instantiate_key_iov_57431 compat_keyctl_instantiate_key_iov 3 57431 NULL
109137 +copy_to_user_fromio_57432 copy_to_user_fromio 3 57432 NULL
109138 +__roundup_pow_of_two_57461 __roundup_pow_of_two 0 57461 NULL
109139 +crypto_tfm_alg_blocksize_57463 crypto_tfm_alg_blocksize 0 57463 NULL
109140 +sisusb_clear_vram_57466 sisusb_clear_vram 2-3 57466 NULL
109141 +blk_flush_cur_seq_57467 blk_flush_cur_seq 0 57467 NULL
109142 +ieee80211_if_read_flags_57470 ieee80211_if_read_flags 3 57470 NULL nohasharray
109143 +sep_lock_user_pages_57470 sep_lock_user_pages 2-3 57470 &ieee80211_if_read_flags_57470
109144 +ocfs2_write_cluster_57483 ocfs2_write_cluster 9-8-2 57483 NULL
109145 +bnad_debugfs_write_regwr_57500 bnad_debugfs_write_regwr 3 57500 NULL
109146 +skb_headlen_57501 skb_headlen 0 57501 NULL
109147 +copy_in_user_57502 copy_in_user 3 57502 NULL
109148 +ckhdid_printf_57505 ckhdid_printf 2 57505 NULL
109149 +init_tag_map_57515 init_tag_map 3 57515 NULL
109150 +wil_read_file_ssid_57517 wil_read_file_ssid 3 57517 NULL nohasharray
109151 +il_dbgfs_force_reset_read_57517 il_dbgfs_force_reset_read 3 57517 &wil_read_file_ssid_57517 nohasharray
109152 +btrfs_insert_inode_extref_57517 btrfs_insert_inode_extref 0 57517 &il_dbgfs_force_reset_read_57517
109153 +cmm_read_57520 cmm_read 3 57520 NULL
109154 +inode_permission_57531 inode_permission 0 57531 NULL
109155 +acpi_dev_get_resources_57534 acpi_dev_get_resources 0 57534 NULL
109156 +ptlrpc_lprocfs_hp_ratio_seq_write_57537 ptlrpc_lprocfs_hp_ratio_seq_write 3 57537 NULL
109157 +ReadHDLCPnP_57559 ReadHDLCPnP 0 57559 NULL nohasharray
109158 +ext4_group_first_block_no_57559 ext4_group_first_block_no 0-2 57559 &ReadHDLCPnP_57559
109159 +obd_unpackmd_57563 obd_unpackmd 0 57563 NULL
109160 +snd_pcm_playback_ioctl1_57569 snd_pcm_playback_ioctl1 0 57569 NULL
109161 +get_bridge_ifindices_57579 get_bridge_ifindices 0 57579 NULL
109162 +ldlm_cli_enqueue_local_57582 ldlm_cli_enqueue_local 11 57582 NULL
109163 +il_dbgfs_interrupt_write_57591 il_dbgfs_interrupt_write 3 57591 NULL
109164 +read_file_spectral_fft_period_57593 read_file_spectral_fft_period 3 57593 NULL
109165 +wm831x_gpio_to_irq_57614 wm831x_gpio_to_irq 2 57614 NULL
109166 +vma_kernel_pagesize_57616 vma_kernel_pagesize 0 57616 NULL
109167 +tx_tx_retry_template_read_57623 tx_tx_retry_template_read 3 57623 NULL
109168 +sisusbcon_putcs_57630 sisusbcon_putcs 3 57630 NULL
109169 +mem_read_57631 mem_read 3 57631 NULL
109170 +tc3589x_irq_map_57639 tc3589x_irq_map 2 57639 NULL
109171 +r3964_write_57662 r3964_write 4 57662 NULL
109172 +proc_ns_readlink_57664 proc_ns_readlink 3 57664 NULL
109173 +__lgwrite_57669 __lgwrite 4 57669 NULL
109174 +f1x_match_to_this_node_57695 f1x_match_to_this_node 3 57695 NULL
109175 +i2400m_rx_stats_read_57706 i2400m_rx_stats_read 3 57706 NULL
109176 +snd_interval_value_57713 snd_interval_value 0 57713 NULL
109177 +ieee80211_if_read_dot11MeshHWMPconfirmationInterval_57722 ieee80211_if_read_dot11MeshHWMPconfirmationInterval 3 57722 NULL
109178 +i915_gem_object_get_pages_57734 i915_gem_object_get_pages 0 57734 NULL
109179 +nouveau_gpio_create__57735 nouveau_gpio_create_ 4-5 57735 NULL
109180 +compat_sys_set_mempolicy_57742 compat_sys_set_mempolicy 3 57742 NULL nohasharray
109181 +pppol2tp_recvmsg_57742 pppol2tp_recvmsg 4 57742 &compat_sys_set_mempolicy_57742
109182 +ieee80211_if_fmt_dot11MeshHWMPpreqMinInterval_57762 ieee80211_if_fmt_dot11MeshHWMPpreqMinInterval 3 57762 NULL
109183 +SYSC_process_vm_writev_57776 SYSC_process_vm_writev 5-3 57776 NULL
109184 +apei_exec_collect_resources_57788 apei_exec_collect_resources 0 57788 NULL
109185 +ld2_57794 ld2 0 57794 NULL
109186 +ivtv_read_57796 ivtv_read 3 57796 NULL
109187 +generic_ptrace_peekdata_57806 generic_ptrace_peekdata 2 57806 NULL
109188 +ipath_user_sdma_num_pages_57813 ipath_user_sdma_num_pages 0 57813 NULL
109189 +bfad_debugfs_read_regrd_57830 bfad_debugfs_read_regrd 3 57830 NULL
109190 +copy_to_user_57835 copy_to_user 3-0 57835 NULL
109191 +flash_read_57843 flash_read 3 57843 NULL
109192 +kiblnd_create_tx_pool_57846 kiblnd_create_tx_pool 2 57846 NULL
109193 +process_all_new_xattrs_57881 process_all_new_xattrs 0 57881 NULL
109194 +xt_alloc_table_info_57903 xt_alloc_table_info 1 57903 NULL
109195 +iio_read_first_n_kfifo_57910 iio_read_first_n_kfifo 2 57910 NULL nohasharray
109196 +atomic_add_return_unchecked_57910 atomic_add_return_unchecked 0-1 57910 &iio_read_first_n_kfifo_57910
109197 +memcg_caches_array_size_57918 memcg_caches_array_size 0-1 57918 NULL
109198 +twl_i2c_write_57923 twl_i2c_write 3-4 57923 NULL
109199 +__snd_gf1_look16_57925 __snd_gf1_look16 0 57925 NULL
109200 +sel_read_handle_unknown_57933 sel_read_handle_unknown 3 57933 NULL
109201 +nvc0_vm_create_57942 nvc0_vm_create 2-3 57942 NULL
109202 +xfs_mru_cache_create_57943 xfs_mru_cache_create 3 57943 NULL
109203 +key_algorithm_read_57946 key_algorithm_read 3 57946 NULL
109204 +ip_set_alloc_57953 ip_set_alloc 1 57953 NULL nohasharray
109205 +ioat3_dca_count_dca_slots_57953 ioat3_dca_count_dca_slots 0 57953 &ip_set_alloc_57953
109206 +c2_reg_user_mr_57982 c2_reg_user_mr 2-3 57982 NULL
109207 +interleave_nodes_57992 interleave_nodes 0 57992 NULL
109208 +do_rx_dma_57996 do_rx_dma 5 57996 NULL
109209 +rx_reset_counter_read_58001 rx_reset_counter_read 3 58001 NULL
109210 +iwl_dbgfs_ucode_rx_stats_read_58023 iwl_dbgfs_ucode_rx_stats_read 3 58023 NULL
109211 +io_playback_transfer_58030 io_playback_transfer 4 58030 NULL
109212 +ext4_block_bitmap_58033 ext4_block_bitmap 0 58033 NULL
109213 +mce_async_out_58056 mce_async_out 3 58056 NULL
109214 +ocfs2_find_leaf_58065 ocfs2_find_leaf 0 58065 NULL
109215 +dt3155_alloc_coherent_58073 dt3155_alloc_coherent 2 58073 NULL
109216 +cm4040_write_58079 cm4040_write 3 58079 NULL
109217 +ipv6_flowlabel_opt_58135 ipv6_flowlabel_opt 3 58135 NULL nohasharray
109218 +slhc_init_58135 slhc_init 2-1 58135 &ipv6_flowlabel_opt_58135
109219 +ocfs2_reserve_clusters_58164 ocfs2_reserve_clusters 0 58164 NULL
109220 +ext4_bg_num_gdb_58171 ext4_bg_num_gdb 0 58171 NULL
109221 +garmin_write_bulk_58191 garmin_write_bulk 3 58191 NULL
109222 +ieee80211_if_fmt_flags_58205 ieee80211_if_fmt_flags 3 58205 NULL
109223 +sysfs_add_file_mode_58222 sysfs_add_file_mode 0 58222 NULL
109224 +hva_to_pfn_58241 hva_to_pfn 1-0 58241 NULL
109225 +btrfsic_create_link_to_next_block_58246 btrfsic_create_link_to_next_block 4 58246 NULL
109226 +read_file_debug_58256 read_file_debug 3 58256 NULL
109227 +osc_max_dirty_mb_seq_write_58263 osc_max_dirty_mb_seq_write 3 58263 NULL
109228 +cfg80211_mgmt_tx_status_58266 cfg80211_mgmt_tx_status 4 58266 NULL
109229 +profile_load_58267 profile_load 3 58267 NULL
109230 +kstrtos8_from_user_58268 kstrtos8_from_user 2 58268 NULL
109231 +acpi_ds_build_internal_package_obj_58271 acpi_ds_build_internal_package_obj 3 58271 NULL
109232 +iscsi_decode_text_input_58292 iscsi_decode_text_input 4 58292 NULL
109233 +intel_alloc_coherent_58302 intel_alloc_coherent 2 58302 NULL
109234 +ieee80211_if_read_dot11MeshTTL_58307 ieee80211_if_read_dot11MeshTTL 3 58307 NULL
109235 +i915_wait_seqno_58309 i915_wait_seqno 0 58309 NULL
109236 +tx_tx_start_int_templates_read_58324 tx_tx_start_int_templates_read 3 58324 NULL
109237 +ext4_ext_truncate_extend_restart_58331 ext4_ext_truncate_extend_restart 3 58331 NULL
109238 +diva_init_dma_map_58336 diva_init_dma_map 3 58336 NULL
109239 +__copy_from_user_swizzled_58337 __copy_from_user_swizzled 2-4 58337 NULL
109240 +next_pidmap_58347 next_pidmap 2-0 58347 NULL
109241 +SyS_migrate_pages_58348 SyS_migrate_pages 2 58348 NULL
109242 +save_hint_58359 save_hint 2 58359 NULL
109243 +vmw_ttm_tt_create_58369 vmw_ttm_tt_create 2 58369 NULL nohasharray
109244 +brcmf_debugfs_sdio_counter_read_58369 brcmf_debugfs_sdio_counter_read 3 58369 &vmw_ttm_tt_create_58369
109245 +hash_ipportnet6_expire_58379 hash_ipportnet6_expire 3 58379 NULL
109246 +il_dbgfs_status_read_58388 il_dbgfs_status_read 3 58388 NULL
109247 +_drbd_md_sync_page_io_58403 _drbd_md_sync_page_io 6 58403 NULL
109248 +kvm_mmu_write_protect_pt_masked_58406 kvm_mmu_write_protect_pt_masked 3-4 58406 NULL nohasharray
109249 +idetape_pad_zeros_58406 idetape_pad_zeros 2 58406 &kvm_mmu_write_protect_pt_masked_58406
109250 +i2400m_pld_size_58415 i2400m_pld_size 0 58415 NULL
109251 +__mlx4_alloc_mtt_range_58418 __mlx4_alloc_mtt_range 2 58418 NULL
109252 +capabilities_read_58457 capabilities_read 3 58457 NULL
109253 +batadv_iv_ogm_aggr_packet_58462 batadv_iv_ogm_aggr_packet 3 58462 NULL
109254 +lpfc_idiag_baracc_read_58466 lpfc_idiag_baracc_read 3 58466 NULL nohasharray
109255 +compat_do_ipt_set_ctl_58466 compat_do_ipt_set_ctl 4 58466 &lpfc_idiag_baracc_read_58466
109256 +nv_rd08_58472 nv_rd08 0 58472 NULL
109257 +snd_gf1_read_addr_58483 snd_gf1_read_addr 0 58483 NULL
109258 +snd_rme96_capture_copy_58484 snd_rme96_capture_copy 5 58484 NULL
109259 +btrfs_cont_expand_58498 btrfs_cont_expand 2-3 58498 NULL
109260 +rndis_add_response_58544 rndis_add_response 2 58544 NULL
109261 +__clear_discard_58546 __clear_discard 2 58546 NULL
109262 +wrap_max_58548 wrap_max 0-1-2 58548 NULL
109263 +wep_decrypt_fail_read_58567 wep_decrypt_fail_read 3 58567 NULL
109264 +scnprint_mac_oui_58578 scnprint_mac_oui 3-0 58578 NULL
109265 +get_rhf_errstring_58582 get_rhf_errstring 3 58582 NULL
109266 +ea_read_inline_58589 ea_read_inline 0 58589 NULL
109267 +isku_sysfs_read_keys_thumbster_58590 isku_sysfs_read_keys_thumbster 6 58590 NULL
109268 +xip_file_read_58592 xip_file_read 3 58592 NULL
109269 +ecryptfs_write_end_58594 ecryptfs_write_end 5-3 58594 NULL
109270 +radeon_bo_size_58606 radeon_bo_size 0 58606 NULL
109271 +ebt_buf_count_58607 ebt_buf_count 0 58607 NULL
109272 +xfs_iomap_write_delay_58616 xfs_iomap_write_delay 2 58616 NULL
109273 +skb_copy_to_page_nocache_58624 skb_copy_to_page_nocache 6 58624 NULL
109274 +filemap_fdatawrite_range_58630 filemap_fdatawrite_range 0 58630 NULL
109275 +module_alloc_update_bounds_rx_58634 module_alloc_update_bounds_rx 1 58634 NULL
109276 +tx_tx_start_fw_gen_read_58648 tx_tx_start_fw_gen_read 3 58648 NULL
109277 +ocfs2_block_to_cluster_start_58653 ocfs2_block_to_cluster_start 2 58653 NULL
109278 +iwl_dbgfs_rx_handlers_write_58655 iwl_dbgfs_rx_handlers_write 3 58655 NULL
109279 +__gfn_to_pfn_58671 __gfn_to_pfn 2 58671 NULL
109280 +find_zero_58685 find_zero 0-1 58685 NULL
109281 +uwb_bce_print_IEs_58686 uwb_bce_print_IEs 4 58686 NULL
109282 +tps6586x_writes_58689 tps6586x_writes 2-3 58689 NULL
109283 +vmalloc_node_58700 vmalloc_node 1-2 58700 NULL
109284 +vx_send_msg_58711 vx_send_msg 0 58711 NULL
109285 +i915_gem_execbuffer_reserve_58722 i915_gem_execbuffer_reserve 0 58722 NULL
109286 +da9052_gpio_to_irq_58729 da9052_gpio_to_irq 2 58729 NULL
109287 +csum_exist_in_range_58730 csum_exist_in_range 2-3 58730 NULL
109288 +frames_to_bytes_58741 frames_to_bytes 0-2 58741 NULL
109289 +ieee80211_if_write_tkip_mic_test_58748 ieee80211_if_write_tkip_mic_test 3 58748 NULL
109290 +agp_allocate_memory_58761 agp_allocate_memory 2 58761 NULL
109291 +oblock_to_dblock_58762 oblock_to_dblock 0-2 58762 NULL
109292 +regmap_calc_reg_len_58795 regmap_calc_reg_len 0 58795 NULL
109293 +raw_send_hdrinc_58803 raw_send_hdrinc 4 58803 NULL
109294 +isku_sysfs_read_58806 isku_sysfs_read 5 58806 NULL
109295 +write_file_58812 write_file 4 58812 NULL
109296 +ep_read_58813 ep_read 3 58813 NULL
109297 +command_write_58841 command_write 3 58841 NULL
109298 +ocfs2_truncate_log_append_58850 ocfs2_truncate_log_append 3-0 58850 NULL
109299 +ath6kl_wmi_send_action_cmd_58860 ath6kl_wmi_send_action_cmd 7 58860 NULL
109300 +gs_alloc_req_58883 gs_alloc_req 2 58883 NULL
109301 +esas2r_change_queue_depth_58886 esas2r_change_queue_depth 2 58886 NULL
109302 +lprocfs_wr_pinger_recov_58914 lprocfs_wr_pinger_recov 3 58914 NULL
109303 +print_devstats_dot11FCSErrorCount_58919 print_devstats_dot11FCSErrorCount 3 58919 NULL
109304 +pipeline_cs_rx_packet_out_read_58926 pipeline_cs_rx_packet_out_read 3 58926 NULL
109305 +SyS_pread64_58935 SyS_pread64 3 58935 NULL
109306 +wait_table_hash_nr_entries_58962 wait_table_hash_nr_entries 0 58962 NULL
109307 +ieee80211_if_fmt_dot11MeshHWMPactivePathToRootTimeout_58965 ieee80211_if_fmt_dot11MeshHWMPactivePathToRootTimeout 3 58965 NULL
109308 +crypto_aead_ivsize_58970 crypto_aead_ivsize 0 58970 NULL
109309 +__mem_cgroup_try_charge_58976 __mem_cgroup_try_charge 0 58976 NULL
109310 +init_list_58990 init_list 3 58990 NULL
109311 +remap_to_cache_dirty_58991 remap_to_cache_dirty 4-3 58991 NULL
109312 +ep_write_59008 ep_write 3 59008 NULL
109313 +lpfc_idiag_baracc_write_59014 lpfc_idiag_baracc_write 3 59014 NULL
109314 +SyS_preadv_59029 SyS_preadv 3 59029 NULL
109315 +init_pci_cap_msi_perm_59033 init_pci_cap_msi_perm 2 59033 NULL
109316 +selinux_transaction_write_59038 selinux_transaction_write 3 59038 NULL
109317 +crypto_aead_reqsize_59039 crypto_aead_reqsize 0 59039 NULL
109318 +regmap_bulk_write_59049 regmap_bulk_write 2-4 59049 NULL
109319 +sysfs_link_sibling_59078 sysfs_link_sibling 0 59078 NULL
109320 +do_perf_sw_event_59099 do_perf_sw_event 3 59099 NULL
109321 +mmc_sd_num_wr_blocks_59112 mmc_sd_num_wr_blocks 0 59112 NULL
109322 +scsi_io_completion_59122 scsi_io_completion 2 59122 NULL
109323 +init_status_page_59124 init_status_page 0 59124 NULL
109324 +nfc_llcp_send_i_frame_59130 nfc_llcp_send_i_frame 3 59130 NULL
109325 +print_devstats_dot11RTSSuccessCount_59145 print_devstats_dot11RTSSuccessCount 3 59145 NULL nohasharray
109326 +framebuffer_alloc_59145 framebuffer_alloc 1 59145 &print_devstats_dot11RTSSuccessCount_59145
109327 +ocfs2_claim_local_alloc_bits_59147 ocfs2_claim_local_alloc_bits 0 59147 NULL
109328 +radeon_compat_ioctl_59150 radeon_compat_ioctl 2 59150 NULL
109329 +pvr2_hdw_report_clients_59152 pvr2_hdw_report_clients 3 59152 NULL
109330 +ksize_59176 ksize 0 59176 NULL
109331 +setup_window_59178 setup_window 4-2-5-7 59178 NULL
109332 +ocfs2_move_extent_59187 ocfs2_move_extent 3-5-2 59187 NULL
109333 +validate_exec_list_59204 validate_exec_list 0 59204 NULL
109334 +xfs_iext_realloc_indirect_59211 xfs_iext_realloc_indirect 2 59211 NULL
109335 +check_mapped_selector_name_59216 check_mapped_selector_name 5 59216 NULL
109336 +dt3155_read_59226 dt3155_read 3 59226 NULL
109337 +paging64_gpte_to_gfn_lvl_59229 paging64_gpte_to_gfn_lvl 0-1-2 59229 NULL
109338 +tty_prepare_flip_string_flags_59240 tty_prepare_flip_string_flags 4 59240 NULL
109339 +nla_len_59258 nla_len 0 59258 NULL
109340 +drbd_bm_write_page_59290 drbd_bm_write_page 2 59290 NULL
109341 +__push_leaf_right_59302 __push_leaf_right 0 59302 NULL
109342 +btrfs_insert_dir_item_59304 btrfs_insert_dir_item 4-0 59304 NULL
109343 +fd_copyout_59323 fd_copyout 3 59323 NULL
109344 +read_9287_modal_eeprom_59327 read_9287_modal_eeprom 3 59327 NULL
109345 +rx_defrag_in_process_called_read_59338 rx_defrag_in_process_called_read 3 59338 NULL
109346 +paging64_get_level1_sp_gpa_59346 paging64_get_level1_sp_gpa 0 59346 NULL nohasharray
109347 +xfs_attrmulti_attr_set_59346 xfs_attrmulti_attr_set 4 59346 &paging64_get_level1_sp_gpa_59346
109348 +__map_request_59350 __map_request 0 59350 NULL
109349 +xfs_dir2_sf_entsize_59366 xfs_dir2_sf_entsize 0-2 59366 NULL
109350 +blk_flush_policy_59368 blk_flush_policy 0 59368 NULL
109351 +f2fs_fallocate_59377 f2fs_fallocate 3-4 59377 NULL
109352 +pvr2_debugifc_print_info_59380 pvr2_debugifc_print_info 3 59380 NULL
109353 +ocfs2_replay_truncate_records_59382 ocfs2_replay_truncate_records 0 59382 NULL
109354 +journal_init_dev_59384 journal_init_dev 5 59384 NULL
109355 +isku_sysfs_read_keys_function_59412 isku_sysfs_read_keys_function 6 59412 NULL
109356 +pci_ctrl_read_59424 pci_ctrl_read 0 59424 NULL
109357 +vxge_hw_ring_rxds_per_block_get_59425 vxge_hw_ring_rxds_per_block_get 0 59425 NULL
109358 +snd_pcm_tstamp_59431 snd_pcm_tstamp 0 59431 NULL
109359 +SyS_sched_setaffinity_59442 SyS_sched_setaffinity 2 59442 NULL
109360 +fs_path_ensure_buf_59445 fs_path_ensure_buf 2-0 59445 NULL
109361 +descriptor_loc_59446 descriptor_loc 3 59446 NULL
109362 +block_rsv_use_bytes_59464 block_rsv_use_bytes 0 59464 NULL
109363 +shrink_tnc_trees_59481 shrink_tnc_trees 0 59481 NULL
109364 +btrfs_del_dir_entries_in_log_59490 btrfs_del_dir_entries_in_log 0 59490 NULL
109365 +ib_copy_from_udata_59502 ib_copy_from_udata 3 59502 NULL
109366 +rds_pin_pages_59507 rds_pin_pages 1-2 59507 NULL
109367 +ext4_resize_fs_59543 ext4_resize_fs 2 59543 NULL
109368 +mpi_get_nbits_59551 mpi_get_nbits 0 59551 NULL
109369 +tunables_write_59563 tunables_write 3 59563 NULL
109370 +__copy_from_user_ll_nozero_59571 __copy_from_user_ll_nozero 0-3 59571 NULL
109371 +write_pbl_59583 write_pbl 4 59583 NULL
109372 +memdup_user_59590 memdup_user 2 59590 NULL
109373 +tps6586x_irq_get_virq_59601 tps6586x_irq_get_virq 2 59601 NULL
109374 +mem_fwlog_free_mem_blks_read_59616 mem_fwlog_free_mem_blks_read 3 59616 NULL nohasharray
109375 +xrcdn_free_res_59616 xrcdn_free_res 5 59616 &mem_fwlog_free_mem_blks_read_59616
109376 +ath6kl_endpoint_stats_write_59621 ath6kl_endpoint_stats_write 3 59621 NULL
109377 +mtrr_write_59622 mtrr_write 3 59622 NULL
109378 +ocfs2_adjust_rightmost_branch_59623 ocfs2_adjust_rightmost_branch 0 59623 NULL
109379 +find_first_zero_bit_59636 find_first_zero_bit 0-2 59636 NULL
109380 +SyS_setdomainname_59646 SyS_setdomainname 2 59646 NULL
109381 +hidraw_read_59650 hidraw_read 3 59650 NULL
109382 +v9fs_xattr_set_acl_59651 v9fs_xattr_set_acl 4 59651 NULL
109383 +paravirt_sched_clock_59660 paravirt_sched_clock 0 59660 NULL
109384 +__devcgroup_check_permission_59665 __devcgroup_check_permission 0 59665 NULL
109385 +iwl_dbgfs_mac_params_read_59666 iwl_dbgfs_mac_params_read 3 59666 NULL
109386 +alloc_dca_provider_59670 alloc_dca_provider 2 59670 NULL
109387 +mic_calc_failure_read_59700 mic_calc_failure_read 3 59700 NULL
109388 +ioperm_get_59701 ioperm_get 4-3 59701 NULL
109389 +snd_pcm_info_user_59711 snd_pcm_info_user 0 59711 NULL
109390 +prism2_info_scanresults_59729 prism2_info_scanresults 3 59729 NULL
109391 +ieee80211_if_read_fwded_unicast_59740 ieee80211_if_read_fwded_unicast 3 59740 NULL
109392 +fat_direct_IO_59741 fat_direct_IO 4 59741 NULL
109393 +qib_decode_7220_sdma_errs_59745 qib_decode_7220_sdma_errs 4 59745 NULL
109394 +strnlen_59746 strnlen 0 59746 NULL
109395 +process_all_refs_59754 process_all_refs 0 59754 NULL nohasharray
109396 +ext3_acl_count_59754 ext3_acl_count 0-1 59754 &process_all_refs_59754
109397 +process_new_xattr_59755 process_new_xattr 0 59755 NULL
109398 +long_retry_limit_read_59766 long_retry_limit_read 3 59766 NULL
109399 +venus_remove_59781 venus_remove 4 59781 NULL
109400 +mei_nfc_recv_59784 mei_nfc_recv 3 59784 NULL
109401 +xlog_do_recover_59789 xlog_do_recover 3 59789 NULL
109402 +msb_get_zone_from_lba_59800 msb_get_zone_from_lba 0-1 59800 NULL
109403 +ipw_write_59807 ipw_write 3 59807 NULL
109404 +scsi_init_shared_tag_map_59812 scsi_init_shared_tag_map 2 59812 NULL
109405 +ieee80211_if_read_dot11MeshHWMPmaxPREQretries_59829 ieee80211_if_read_dot11MeshHWMPmaxPREQretries 3 59829 NULL
109406 +gspca_dev_probe2_59833 gspca_dev_probe2 4 59833 NULL
109407 +fs64_to_cpu_59845 fs64_to_cpu 0 59845 NULL
109408 +regmap_raw_write_async_59849 regmap_raw_write_async 2-4 59849 NULL
109409 +intel_ring_wait_request_59865 intel_ring_wait_request 0 59865 NULL
109410 +pvr2_ioread_set_sync_key_59882 pvr2_ioread_set_sync_key 3 59882 NULL
109411 +shmem_zero_setup_59885 shmem_zero_setup 0 59885 NULL nohasharray
109412 +start_transaction_59885 start_transaction 2 59885 &shmem_zero_setup_59885
109413 +l2cap_sock_recvmsg_59886 l2cap_sock_recvmsg 4 59886 NULL
109414 +ffs_prepare_buffer_59892 ffs_prepare_buffer 2 59892 NULL
109415 +ocfs2_extend_rotate_transaction_59894 ocfs2_extend_rotate_transaction 0 59894 NULL
109416 +swiotlb_map_page_59909 swiotlb_map_page 3 59909 NULL
109417 +aic7xxx_abort_waiting_scb_59932 aic7xxx_abort_waiting_scb 0 59932 NULL
109418 +kvm_mmu_notifier_invalidate_range_start_59944 kvm_mmu_notifier_invalidate_range_start 3-4 59944 NULL
109419 +ocfs2_expand_inline_ref_root_59945 ocfs2_expand_inline_ref_root 0 59945 NULL
109420 +il_dbgfs_rxon_flags_read_59950 il_dbgfs_rxon_flags_read 3 59950 NULL nohasharray
109421 +dapm_widget_power_read_file_59950 dapm_widget_power_read_file 3 59950 &il_dbgfs_rxon_flags_read_59950
109422 +lookup_node_59953 lookup_node 2 59953 NULL
109423 +il_dbgfs_missed_beacon_read_59956 il_dbgfs_missed_beacon_read 3 59956 NULL
109424 +kvm_set_cr3_59965 kvm_set_cr3 2 59965 NULL
109425 +__arch_hweight16_59975 __arch_hweight16 0 59975 NULL
109426 +osd_req_read_kern_59990 osd_req_read_kern 5 59990 NULL
109427 +ghash_async_setkey_60001 ghash_async_setkey 3 60001 NULL
109428 +ieee80211_if_fmt_dot11MeshAwakeWindowDuration_60006 ieee80211_if_fmt_dot11MeshAwakeWindowDuration 3 60006 NULL
109429 +rawsock_sendmsg_60010 rawsock_sendmsg 4 60010 NULL
109430 +mthca_init_cq_60011 mthca_init_cq 2 60011 NULL
109431 +osd_req_list_dev_partitions_60027 osd_req_list_dev_partitions 4 60027 NULL
109432 +xlog_bread_offset_60030 xlog_bread_offset 3 60030 NULL
109433 +bio_integrity_hw_sectors_60039 bio_integrity_hw_sectors 0-2 60039 NULL
109434 +do_ip6t_set_ctl_60040 do_ip6t_set_ctl 4 60040 NULL
109435 +vcs_size_60050 vcs_size 0 60050 NULL nohasharray
109436 +pin_2_irq_60050 pin_2_irq 0-3 60050 &vcs_size_60050
109437 +gru_alloc_gts_60056 gru_alloc_gts 3-2 60056 NULL
109438 +open_cur_inode_file_60057 open_cur_inode_file 0 60057 NULL
109439 +compat_writev_60063 compat_writev 3 60063 NULL
109440 +ath6kl_listen_int_write_60066 ath6kl_listen_int_write 3 60066 NULL
109441 +c4iw_num_stags_60073 c4iw_num_stags 0 60073 NULL
109442 +mp_register_gsi_60079 mp_register_gsi 2 60079 NULL
109443 +rxrpc_kernel_send_data_60083 rxrpc_kernel_send_data 3 60083 NULL
109444 +ieee80211_if_fmt_fwded_frames_60103 ieee80211_if_fmt_fwded_frames 3 60103 NULL
109445 +SYSC_msgsnd_60113 SYSC_msgsnd 3 60113 NULL
109446 +nfs_idmap_request_key_60124 nfs_idmap_request_key 2 60124 NULL
109447 +__mutex_lock_common_60134 __mutex_lock_common 0 60134 NULL
109448 +ld_usb_read_60156 ld_usb_read 3 60156 NULL
109449 +jmb38x_ms_count_slots_60164 jmb38x_ms_count_slots 0 60164 NULL
109450 +init_state_60165 init_state 2 60165 NULL
109451 +sg_build_sgat_60179 sg_build_sgat 3 60179 NULL nohasharray
109452 +jffs2_alloc_full_dirent_60179 jffs2_alloc_full_dirent 1 60179 &sg_build_sgat_60179
109453 +fuse_async_req_send_60183 fuse_async_req_send 0-3 60183 NULL
109454 +rx_rx_tkip_replays_read_60193 rx_rx_tkip_replays_read 3 60193 NULL
109455 +qib_reg_phys_mr_60202 qib_reg_phys_mr 3 60202 NULL
109456 +btrfs_get_token_16_60220 btrfs_get_token_16 0 60220 NULL
109457 +arizona_map_irq_60230 arizona_map_irq 2 60230 NULL nohasharray
109458 +__phys_addr_nodebug_60230 __phys_addr_nodebug 0 60230 &arizona_map_irq_60230
109459 +wm831x_irq_60254 wm831x_irq 2 60254 NULL
109460 +irq_alloc_domain_generic_chips_60264 irq_alloc_domain_generic_chips 3-2 60264 NULL
109461 +printer_write_60276 printer_write 3 60276 NULL
109462 +alloc_irq_pin_list_60277 alloc_irq_pin_list 1 60277 NULL
109463 +do_xip_mapping_read_60297 do_xip_mapping_read 5 60297 NULL
109464 +getDataLength_60301 getDataLength 0 60301 NULL
109465 +xfs_next_bit_60322 xfs_next_bit 0-3 60322 NULL
109466 +inorder_to_tree_60331 inorder_to_tree 1-0 60331 NULL
109467 +usb_alphatrack_write_60341 usb_alphatrack_write 3 60341 NULL
109468 +__kfifo_from_user_r_60345 __kfifo_from_user_r 5-3 60345 NULL
109469 +max_unfragmented_pages_60362 max_unfragmented_pages 0 60362 NULL
109470 +dccp_setsockopt_60367 dccp_setsockopt 5 60367 NULL
109471 +ubi_eba_atomic_leb_change_60379 ubi_eba_atomic_leb_change 0-5 60379 NULL
109472 +instruction_pointer_60384 instruction_pointer 0 60384 NULL
109473 +drop_outstanding_extent_60390 drop_outstanding_extent 0 60390 NULL
109474 +mthca_alloc_resize_buf_60394 mthca_alloc_resize_buf 3 60394 NULL
109475 +ocfs2_zero_extend_60396 ocfs2_zero_extend 3 60396 NULL
109476 +driver_names_read_60399 driver_names_read 3 60399 NULL
109477 +paging32_walk_addr_generic_60415 paging32_walk_addr_generic 4 60415 NULL
109478 +simple_alloc_urb_60420 simple_alloc_urb 3 60420 NULL
109479 +excessive_retries_read_60425 excessive_retries_read 3 60425 NULL
109480 +tstats_write_60432 tstats_write 3 60432 NULL nohasharray
109481 +kmalloc_60432 kmalloc 1 60432 &tstats_write_60432
109482 +scaled_div32_60442 scaled_div32 2-1-0 60442 NULL
109483 +snd_hda_get_num_raw_conns_60462 snd_hda_get_num_raw_conns 0 60462 NULL
109484 +crypto_shash_setkey_60483 crypto_shash_setkey 3 60483 NULL
109485 +lustre_msg_early_size_60496 lustre_msg_early_size 0 60496 NULL
109486 +v9fs_fid_readn_60544 v9fs_fid_readn 4 60544 NULL
109487 +nonpaging_map_60551 nonpaging_map 4 60551 NULL
109488 +osc_lockless_truncate_seq_write_60553 osc_lockless_truncate_seq_write 3 60553 NULL
109489 +tracing_entries_write_60563 tracing_entries_write 3 60563 NULL
109490 +hash_net6_expire_60598 hash_net6_expire 3 60598 NULL
109491 +btrfs_add_delayed_tree_ref_60602 btrfs_add_delayed_tree_ref 0 60602 NULL
109492 +skb_transport_offset_60619 skb_transport_offset 0 60619 NULL
109493 +wl1273_fm_fops_write_60621 wl1273_fm_fops_write 3 60621 NULL
109494 +usb_control_msg_60624 usb_control_msg 0 60624 NULL
109495 +acl_alloc_stack_init_60630 acl_alloc_stack_init 1 60630 NULL
109496 +free_dind_blocks_60635 free_dind_blocks 0 60635 NULL
109497 +ubifs_recover_leb_60639 ubifs_recover_leb 3 60639 NULL
109498 +__proc_lnet_stats_60647 __proc_lnet_stats 5 60647 NULL
109499 +mv_ffc64_60648 mv_ffc64 1 60648 NULL
109500 +if_sdio_host_to_card_60666 if_sdio_host_to_card 4 60666 NULL
109501 +run_clustered_refs_60668 run_clustered_refs 0 60668 NULL
109502 +ieee80211_if_read_dot11MeshConfirmTimeout_60670 ieee80211_if_read_dot11MeshConfirmTimeout 3 60670 NULL
109503 +btrfs_reserve_extent_60674 btrfs_reserve_extent 5-0 60674 NULL
109504 +init_data_container_60709 init_data_container 1 60709 NULL
109505 +vga_rcrt_60731 vga_rcrt 0 60731 NULL
109506 +snd_ice1712_ds_read_60754 snd_ice1712_ds_read 0 60754 NULL
109507 +raid_status_60755 raid_status 5 60755 NULL
109508 +sel_write_checkreqprot_60774 sel_write_checkreqprot 3 60774 NULL
109509 +opticon_write_60775 opticon_write 4 60775 NULL
109510 +acl_alloc_num_60778 acl_alloc_num 1-2 60778 NULL
109511 +snd_pcm_oss_readv3_60792 snd_pcm_oss_readv3 3 60792 NULL
109512 +block_rsv_migrate_bytes_60843 block_rsv_migrate_bytes 0 60843 NULL
109513 +pwr_tx_with_ps_read_60851 pwr_tx_with_ps_read 3 60851 NULL
109514 +alloc_buf_60864 alloc_buf 2-3 60864 NULL
109515 +generic_writepages_60871 generic_writepages 0 60871 NULL
109516 +tipc_createport_60875 tipc_createport 4 60875 NULL
109517 +ubifs_read_one_lp_60882 ubifs_read_one_lp 0 60882 NULL
109518 +ext4_update_inline_data_60888 ext4_update_inline_data 3 60888 NULL
109519 +iio_debugfs_read_reg_60908 iio_debugfs_read_reg 3 60908 NULL
109520 +libcfs_sock_ioctl_60915 libcfs_sock_ioctl 0 60915 NULL
109521 +mgt_set_varlen_60916 mgt_set_varlen 4 60916 NULL
109522 +scrub_chunk_60926 scrub_chunk 5 60926 NULL
109523 +submit_extent_page_60928 submit_extent_page 5 60928 NULL
109524 +pti_char_write_60960 pti_char_write 3 60960 NULL
109525 +mwifiex_alloc_sdio_mpa_buffers_60961 mwifiex_alloc_sdio_mpa_buffers 3-2 60961 NULL
109526 +__a2mp_build_60987 __a2mp_build 3 60987 NULL
109527 +hsc_msg_alloc_60990 hsc_msg_alloc 1 60990 NULL
109528 +ath6kl_lrssi_roam_read_61022 ath6kl_lrssi_roam_read 3 61022 NULL
109529 +graph_depth_write_61024 graph_depth_write 3 61024 NULL
109530 +sdhci_pltfm_register_61031 sdhci_pltfm_register 3 61031 NULL
109531 +lpfc_idiag_queacc_write_61043 lpfc_idiag_queacc_write 3 61043 NULL
109532 +symtab_init_61050 symtab_init 2 61050 NULL
109533 +fuse_send_write_61053 fuse_send_write 0-4 61053 NULL
109534 +snd_pcm_pause_61054 snd_pcm_pause 0 61054 NULL
109535 +bitmap_scnlistprintf_61062 bitmap_scnlistprintf 0-4-2 61062 NULL
109536 +ahash_align_buffer_size_61070 ahash_align_buffer_size 0-1-2 61070 NULL
109537 +journal_stop_61080 journal_stop 0 61080 NULL
109538 +snd_pcm_update_hw_ptr0_61084 snd_pcm_update_hw_ptr0 0 61084 NULL
109539 +get_derived_key_61100 get_derived_key 4 61100 NULL
109540 +mem_cgroup_cache_charge_61101 mem_cgroup_cache_charge 0 61101 NULL
109541 +i40e_calculate_l2fpm_size_61104 i40e_calculate_l2fpm_size 0-1-2-3-4 61104 NULL
109542 +alloc_chrdev_region_61112 alloc_chrdev_region 0 61112 NULL
109543 +__probe_kernel_read_61119 __probe_kernel_read 3 61119 NULL
109544 +vmemmap_alloc_block_buf_61126 vmemmap_alloc_block_buf 1 61126 NULL
109545 +afs_proc_cells_write_61139 afs_proc_cells_write 3 61139 NULL
109546 +brcmf_sdio_chip_cr4_exitdl_61143 brcmf_sdio_chip_cr4_exitdl 4 61143 NULL
109547 +__vmalloc_61168 __vmalloc 1 61168 NULL
109548 +event_oom_late_read_61175 event_oom_late_read 3 61175 NULL nohasharray
109549 +pair_device_61175 pair_device 4 61175 &event_oom_late_read_61175
109550 +dio_bio_add_page_61178 dio_bio_add_page 0 61178 NULL
109551 +btrfs_reloc_post_snapshot_61189 btrfs_reloc_post_snapshot 0 61189 NULL
109552 +SyS_prctl_61202 SyS_prctl 4 61202 NULL
109553 +arch_hibernation_header_save_61212 arch_hibernation_header_save 0 61212 NULL
109554 +smk_read_ambient_61220 smk_read_ambient 3 61220 NULL
109555 +__verify_planes_array_61249 __verify_planes_array 0 61249 NULL
109556 +find_get_pages_tag_61270 find_get_pages_tag 0 61270 NULL nohasharray
109557 +ifalias_store_61270 ifalias_store 4 61270 &find_get_pages_tag_61270 nohasharray
109558 +btrfs_bio_alloc_61270 btrfs_bio_alloc 3 61270 &ifalias_store_61270
109559 +kick_a_thread_61273 kick_a_thread 0 61273 NULL
109560 +hfsplus_getxattr_finder_info_61283 hfsplus_getxattr_finder_info 0 61283 NULL nohasharray
109561 +vortex_adbdma_getlinearpos_61283 vortex_adbdma_getlinearpos 0 61283 &hfsplus_getxattr_finder_info_61283
109562 +nvme_trans_copy_to_user_61288 nvme_trans_copy_to_user 3 61288 NULL
109563 +ext4_issue_discard_61305 ext4_issue_discard 2 61305 NULL
109564 +xfer_from_user_61307 xfer_from_user 3 61307 NULL
109565 +ocfs2_get_sector_61309 ocfs2_get_sector 4 61309 NULL
109566 +timespec_to_ns_61317 timespec_to_ns 0 61317 NULL
109567 +xfrm_user_sec_ctx_size_61320 xfrm_user_sec_ctx_size 0 61320 NULL
109568 +C_SYSC_msgsnd_61330 C_SYSC_msgsnd 3 61330 NULL
109569 +write_file_spectral_short_repeat_61335 write_file_spectral_short_repeat 3 61335 NULL
109570 +__fls_61340 __fls 0 61340 NULL nohasharray
109571 +st5481_setup_isocpipes_61340 st5481_setup_isocpipes 6-4 61340 &__fls_61340
109572 +do_splice_direct_61341 do_splice_direct 5 61341 NULL nohasharray
109573 +rx_rx_wa_ba_not_expected_read_61341 rx_rx_wa_ba_not_expected_read 3 61341 &do_splice_direct_61341
109574 +__dm_get_reserved_ios_61342 __dm_get_reserved_ios 0-2-3 61342 NULL
109575 +f1x_map_sysaddr_to_csrow_61344 f1x_map_sysaddr_to_csrow 2 61344 NULL
109576 +kvm_apic_id_61363 kvm_apic_id 0 61363 NULL
109577 +debug_debug4_read_61367 debug_debug4_read 3 61367 NULL
109578 +get_inode_info_61387 get_inode_info 0 61387 NULL
109579 +system_enable_write_61396 system_enable_write 3 61396 NULL
109580 +size_entry_mwt_61400 size_entry_mwt 0 61400 NULL
109581 +xfs_zero_remaining_bytes_61423 xfs_zero_remaining_bytes 3 61423 NULL
109582 +i915_emit_box_61436 i915_emit_box 0 61436 NULL
109583 +dma_ops_area_alloc_61440 dma_ops_area_alloc 3-4-5-0 61440 NULL
109584 +tc3589x_irq_unmap_61447 tc3589x_irq_unmap 2 61447 NULL
109585 +unix_stream_sendmsg_61455 unix_stream_sendmsg 4 61455 NULL
109586 +snd_pcm_lib_writev_transfer_61483 snd_pcm_lib_writev_transfer 5-4-2 61483 NULL
109587 +btrfs_item_size_61485 btrfs_item_size 0 61485 NULL
109588 +ocfs2_get_refcount_rec_61514 ocfs2_get_refcount_rec 0 61514 NULL
109589 +__vmalloc_area_node_61525 __vmalloc_area_node 4 61525 NULL
109590 +erst_errno_61526 erst_errno 0 61526 NULL
109591 +ntfs_attr_lookup_61539 ntfs_attr_lookup 0 61539 NULL
109592 +get_ohm_of_thermistor_61545 get_ohm_of_thermistor 2 61545 NULL
109593 +trace_options_core_write_61551 trace_options_core_write 3 61551 NULL
109594 +o2hb_pop_count_61553 o2hb_pop_count 2 61553 NULL
109595 +dvb_net_ioctl_61559 dvb_net_ioctl 2 61559 NULL
109596 +parport_pc_fifo_write_block_dma_61568 parport_pc_fifo_write_block_dma 3 61568 NULL
109597 +fan_proc_write_61569 fan_proc_write 3 61569 NULL
109598 +ieee80211_if_read_rc_rateidx_mask_2ghz_61570 ieee80211_if_read_rc_rateidx_mask_2ghz 3 61570 NULL
109599 +ldlm_pool_rw_atomic_seq_write_61572 ldlm_pool_rw_atomic_seq_write 3 61572 NULL
109600 +seq_open_private_61589 seq_open_private 3 61589 NULL
109601 +ept_gpte_to_gfn_lvl_61591 ept_gpte_to_gfn_lvl 0-2-1 61591 NULL
109602 +netlink_recvmsg_61600 netlink_recvmsg 4 61600 NULL
109603 +nfs4_init_uniform_client_string_61601 nfs4_init_uniform_client_string 3 61601 NULL
109604 +configfs_write_file_61621 configfs_write_file 3 61621 NULL
109605 +ieee80211_if_fmt_hw_queues_61629 ieee80211_if_fmt_hw_queues 3 61629 NULL
109606 +i2o_parm_table_get_61635 i2o_parm_table_get 6 61635 NULL
109607 +snd_pcm_oss_read3_61643 snd_pcm_oss_read3 0-3 61643 NULL
109608 +resize_stripes_61650 resize_stripes 2 61650 NULL
109609 +ttm_page_pool_free_61661 ttm_page_pool_free 2-0 61661 NULL
109610 +insert_one_name_61668 insert_one_name 7 61668 NULL
109611 +snd_pcm_playback_avail_61671 snd_pcm_playback_avail 0 61671 NULL
109612 +qib_format_hwmsg_61679 qib_format_hwmsg 2 61679 NULL
109613 +lock_loop_61681 lock_loop 1 61681 NULL
109614 +__do_tune_cpucache_61684 __do_tune_cpucache 2 61684 NULL
109615 +filter_read_61692 filter_read 3 61692 NULL
109616 +prog_page_61711 prog_page 2 61711 NULL
109617 +iov_length_61716 iov_length 0 61716 NULL
109618 +fragmentation_threshold_read_61718 fragmentation_threshold_read 3 61718 NULL
109619 +null_alloc_reqbuf_61719 null_alloc_reqbuf 3 61719 NULL
109620 +read_file_interrupt_61742 read_file_interrupt 3 61742 NULL nohasharray
109621 +read_file_regval_61742 read_file_regval 3 61742 &read_file_interrupt_61742
109622 +SyS_sendto_61763 SyS_sendto 6 61763 NULL
109623 +gfs2_meta_wait_61773 gfs2_meta_wait 0 61773 NULL
109624 +num_counter_active_61789 num_counter_active 0 61789 NULL
109625 +mls_compute_context_len_61812 mls_compute_context_len 0 61812 NULL
109626 +tps80031_irq_init_61830 tps80031_irq_init 3 61830 NULL
109627 +bfad_debugfs_write_regwr_61841 bfad_debugfs_write_regwr 3 61841 NULL
109628 +regcache_sync_block_61846 regcache_sync_block 4-5 61846 NULL
109629 +fs_path_prepare_for_add_61854 fs_path_prepare_for_add 2-0 61854 NULL
109630 +evdev_compute_buffer_size_61863 evdev_compute_buffer_size 0 61863 NULL
109631 +SYSC_lsetxattr_61869 SYSC_lsetxattr 4 61869 NULL
109632 +get_fw_name_61874 get_fw_name 3 61874 NULL
109633 +twl4030_sih_setup_61878 twl4030_sih_setup 3-0 61878 NULL
109634 +btrfs_ioctl_clone_61886 btrfs_ioctl_clone 4-3-5 61886 NULL
109635 +lprocfs_write_frac_u64_helper_61897 lprocfs_write_frac_u64_helper 2 61897 NULL
109636 +lov_mds_md_stripecnt_61899 lov_mds_md_stripecnt 0-1 61899 NULL
109637 +clear_refs_write_61904 clear_refs_write 3 61904 NULL
109638 +rx_filter_arp_filter_read_61914 rx_filter_arp_filter_read 3 61914 NULL
109639 +au0828_init_isoc_61917 au0828_init_isoc 3-2-4 61917 NULL
109640 +sctp_sendmsg_61919 sctp_sendmsg 4 61919 NULL
109641 +ocfs2_reserve_new_metadata_blocks_61926 ocfs2_reserve_new_metadata_blocks 0 61926 NULL
109642 +SyS_kexec_load_61946 SyS_kexec_load 2 61946 NULL
109643 +gfn_to_pfn_memslot_atomic_61947 gfn_to_pfn_memslot_atomic 2 61947 NULL
109644 +il4965_ucode_rx_stats_read_61948 il4965_ucode_rx_stats_read 3 61948 NULL
109645 +squashfs_read_id_index_table_61961 squashfs_read_id_index_table 4 61961 NULL
109646 +fix_read_error_61965 fix_read_error 4 61965 NULL
109647 +mlx4_alloc_mtt_range_61966 mlx4_alloc_mtt_range 2 61966 NULL
109648 +ocfs2_quota_write_61972 ocfs2_quota_write 5-4 61972 NULL
109649 +fd_locked_ioctl_61978 fd_locked_ioctl 3 61978 NULL
109650 +cow_file_range_61979 cow_file_range 3 61979 NULL
109651 +module_alloc_exec_61991 module_alloc_exec 1 61991 NULL
109652 +dequeue_event_62000 dequeue_event 3 62000 NULL
109653 +xt_compat_match_offset_62011 xt_compat_match_offset 0 62011 NULL
109654 +SyS_setxattr_62019 SyS_setxattr 4 62019 NULL
109655 +jffs2_do_unlink_62020 jffs2_do_unlink 4 62020 NULL
109656 +SYSC_select_62024 SYSC_select 1 62024 NULL
109657 +pmcraid_build_passthrough_ioadls_62034 pmcraid_build_passthrough_ioadls 2 62034 NULL
109658 +sctp_user_addto_chunk_62047 sctp_user_addto_chunk 2-3 62047 NULL
109659 +do_pselect_62061 do_pselect 1 62061 NULL
109660 +pcpu_alloc_bootmem_62074 pcpu_alloc_bootmem 2 62074 NULL
109661 +get_domain_for_dev_62099 get_domain_for_dev 2 62099 NULL
109662 +ipath_user_sdma_pin_pages_62100 ipath_user_sdma_pin_pages 3-5-4 62100 NULL
109663 +jffs2_security_setxattr_62107 jffs2_security_setxattr 4 62107 NULL
109664 +btrfs_direct_IO_62114 btrfs_direct_IO 4 62114 NULL
109665 +generic_block_fiemap_62122 generic_block_fiemap 4 62122 NULL
109666 +llc_ui_header_len_62131 llc_ui_header_len 0 62131 NULL
109667 +qib_diag_write_62133 qib_diag_write 3 62133 NULL nohasharray
109668 +kobject_add_varg_62133 kobject_add_varg 0 62133 &qib_diag_write_62133
109669 +ql_status_62135 ql_status 5 62135 NULL nohasharray
109670 +device_add_attrs_62135 device_add_attrs 0 62135 &ql_status_62135
109671 +video_usercopy_62151 video_usercopy 2 62151 NULL
109672 +wrmWithLock_62164 wrmWithLock 0 62164 NULL
109673 +SyS_getxattr_62166 SyS_getxattr 4 62166 NULL
109674 +prism54_wpa_bss_ie_get_62173 prism54_wpa_bss_ie_get 0 62173 NULL
109675 +write_file_dfs_62180 write_file_dfs 3 62180 NULL
109676 +alloc_upcall_62186 alloc_upcall 2 62186 NULL
109677 +btrfs_xattr_acl_set_62203 btrfs_xattr_acl_set 4 62203 NULL
109678 +sock_kmalloc_62205 sock_kmalloc 2 62205 NULL
109679 +SYSC_setgroups16_62232 SYSC_setgroups16 1 62232 NULL
109680 +nfsd_read_file_62241 nfsd_read_file 6 62241 NULL
109681 +allocate_partition_62245 allocate_partition 4 62245 NULL
109682 +security_file_permission_62278 security_file_permission 0 62278 NULL
109683 +get_random_int_62279 get_random_int 0 62279 NULL
109684 +__qib_get_user_pages_62287 __qib_get_user_pages 1-2 62287 NULL
109685 +il_dbgfs_sram_read_62296 il_dbgfs_sram_read 3 62296 NULL
109686 +sparse_early_usemaps_alloc_pgdat_section_62304 sparse_early_usemaps_alloc_pgdat_section 2 62304 NULL
109687 +ocfs2_find_victim_alloc_group_62306 ocfs2_find_victim_alloc_group 0 62306 NULL
109688 +subsystem_filter_read_62310 subsystem_filter_read 3 62310 NULL
109689 +timespec_to_jiffies_62321 timespec_to_jiffies 0 62321 NULL
109690 +Wb35Reg_BurstWrite_62327 Wb35Reg_BurstWrite 4 62327 NULL
109691 +subseq_list_62332 subseq_list 3-0 62332 NULL
109692 +ll_statahead_max_seq_write_62333 ll_statahead_max_seq_write 3 62333 NULL
109693 +flash_write_62354 flash_write 3 62354 NULL
109694 +xfpregs_set_62363 xfpregs_set 4 62363 NULL
109695 +rx_rx_timeout_read_62389 rx_rx_timeout_read 3 62389 NULL
109696 +altera_irscan_62396 altera_irscan 2 62396 NULL
109697 +set_ssp_62411 set_ssp 4 62411 NULL
109698 +mlx4_en_create_rx_ring_62498 mlx4_en_create_rx_ring 3 62498 NULL
109699 +ext_rts51x_sd_execute_read_data_62501 ext_rts51x_sd_execute_read_data 9 62501 NULL
109700 +ocfs2_path_bh_journal_access_62504 ocfs2_path_bh_journal_access 0 62504 NULL
109701 +pep_sendmsg_62524 pep_sendmsg 4 62524 NULL
109702 +test_iso_queue_62534 test_iso_queue 5 62534 NULL nohasharray
109703 +__kmalloc_node_track_caller_62534 __kmalloc_node_track_caller 3 62534 &test_iso_queue_62534
109704 +debugfs_read_62535 debugfs_read 3 62535 NULL
109705 +sco_sock_sendmsg_62542 sco_sock_sendmsg 4 62542 NULL
109706 +qib_refresh_qsfp_cache_62547 qib_refresh_qsfp_cache 0 62547 NULL
109707 +xfrm_user_policy_62573 xfrm_user_policy 4 62573 NULL
109708 +get_subdir_62581 get_subdir 3 62581 NULL
109709 +nfsd_vfs_read_62605 nfsd_vfs_read 6 62605 NULL
109710 +get_desc_base_62617 get_desc_base 0 62617 NULL
109711 +iommu_area_alloc_62619 iommu_area_alloc 2-3-4-7-0 62619 NULL
109712 +vfs_fsync_range_62635 vfs_fsync_range 0 62635 NULL
109713 +lpfc_sli4_queue_alloc_62646 lpfc_sli4_queue_alloc 3 62646 NULL
109714 +write_62671 write 3 62671 NULL
109715 +ocfs2_wait_for_mask_interruptible_62675 ocfs2_wait_for_mask_interruptible 0 62675 NULL
109716 +printer_req_alloc_62687 printer_req_alloc 2 62687 NULL
109717 +ext4_ind_map_blocks_62690 ext4_ind_map_blocks 0 62690 NULL
109718 +htb_remove_class_from_row_62692 htb_remove_class_from_row 3 62692 NULL
109719 +qla4_83xx_rd_reg_62693 qla4_83xx_rd_reg 0 62693 NULL
109720 +bioset_integrity_create_62708 bioset_integrity_create 2 62708 NULL
109721 +gfs2_log_write_62717 gfs2_log_write 3 62717 NULL
109722 +rdm_62719 rdm 0 62719 NULL
109723 +obd_ioctl_popdata_62741 obd_ioctl_popdata 3 62741 NULL
109724 +key_replays_read_62746 key_replays_read 3 62746 NULL
109725 +lov_verify_lmm_62747 lov_verify_lmm 2 62747 NULL
109726 +mwifiex_rdeeprom_write_62754 mwifiex_rdeeprom_write 3 62754 NULL
109727 +ax25_sendmsg_62770 ax25_sendmsg 4 62770 NULL
109728 +page_key_alloc_62771 page_key_alloc 0 62771 NULL
109729 +C_SYSC_ipc_62776 C_SYSC_ipc 3 62776 NULL
109730 +SyS_sched_getaffinity_62786 SyS_sched_getaffinity 2 62786 NULL
109731 +dm_stats_account_io_62787 dm_stats_account_io 3 62787 NULL
109732 +posix_acl_valid_62788 posix_acl_valid 0 62788 NULL
109733 +is_first_ref_62805 is_first_ref 0 62805 NULL
109734 +tracing_total_entries_read_62817 tracing_total_entries_read 3 62817 NULL
109735 +name_cache_insert_62822 name_cache_insert 0 62822 NULL
109736 +BeceemEEPROMBulkRead_62835 BeceemEEPROMBulkRead 0 62835 NULL
109737 +__rounddown_pow_of_two_62836 __rounddown_pow_of_two 0 62836 NULL
109738 +bio_get_nr_vecs_62838 bio_get_nr_vecs 0 62838 NULL
109739 +xlog_recover_add_to_trans_62839 xlog_recover_add_to_trans 4 62839 NULL
109740 +rx_fcs_err_read_62844 rx_fcs_err_read 3 62844 NULL
109741 +set_swbp_62853 set_swbp 3 62853 NULL
109742 +read_nic_io_dword_62859 read_nic_io_dword 0 62859 NULL
109743 +l2tp_ip6_recvmsg_62874 l2tp_ip6_recvmsg 4 62874 NULL
109744 +aoechr_write_62883 aoechr_write 3 62883 NULL
109745 +if_spi_host_to_card_62890 if_spi_host_to_card 4 62890 NULL
109746 +ocfs2_validate_gd_parent_62905 ocfs2_validate_gd_parent 0 62905 NULL
109747 +mempool_create_slab_pool_62907 mempool_create_slab_pool 1 62907 NULL
109748 +getdqbuf_62908 getdqbuf 1 62908 NULL
109749 +try_async_pf_62914 try_async_pf 3 62914 NULL nohasharray
109750 +SyS_remap_file_pages_62914 SyS_remap_file_pages 1-2 62914 &try_async_pf_62914
109751 +ll_statahead_agl_seq_write_62928 ll_statahead_agl_seq_write 3 62928 NULL
109752 +atomic64_sub_return_62941 atomic64_sub_return 1 62941 NULL
109753 +agp_create_user_memory_62955 agp_create_user_memory 1 62955 NULL
109754 +send_write_62969 send_write 0-3 62969 NULL
109755 +__ext3_journal_stop_63017 __ext3_journal_stop 0 63017 NULL
109756 +kstrtoull_from_user_63026 kstrtoull_from_user 2 63026 NULL
109757 +PTR_ERR_63033 PTR_ERR 0 63033 NULL nohasharray
109758 +__vb2_perform_fileio_63033 __vb2_perform_fileio 3 63033 &PTR_ERR_63033
109759 +pipeline_defrag_to_csum_swi_read_63037 pipeline_defrag_to_csum_swi_read 3 63037 NULL
109760 +scsi_host_alloc_63041 scsi_host_alloc 2 63041 NULL
109761 +run_delayed_tree_ref_63042 run_delayed_tree_ref 0 63042 NULL
109762 +unlink1_63059 unlink1 3 63059 NULL
109763 +__do_munmap_63063 __do_munmap 0 63063 NULL
109764 +xen_set_nslabs_63066 xen_set_nslabs 0 63066 NULL
109765 +iwl_dbgfs_fw_rx_stats_read_63070 iwl_dbgfs_fw_rx_stats_read 3 63070 NULL
109766 +ocfs2_decrease_refcount_63078 ocfs2_decrease_refcount 4-3-0 63078 NULL
109767 +find_extent_in_eb_63082 find_extent_in_eb 0 63082 NULL
109768 +sep_prepare_input_output_dma_table_in_dcb_63087 sep_prepare_input_output_dma_table_in_dcb 4-5-3-2 63087 NULL
109769 +__ocfs2_flush_truncate_log_63097 __ocfs2_flush_truncate_log 0 63097 NULL
109770 +iwl_dbgfs_sensitivity_read_63116 iwl_dbgfs_sensitivity_read 3 63116 NULL
109771 +ext4_chunk_trans_blocks_63123 ext4_chunk_trans_blocks 0-2 63123 NULL
109772 +alloc_cblock_63133 alloc_cblock 2 63133 NULL
109773 +snd_pcm_status_user_63140 snd_pcm_status_user 0 63140 NULL
109774 +ubifs_change_one_lp_63157 ubifs_change_one_lp 0 63157 NULL
109775 +smk_write_revoke_subj_63173 smk_write_revoke_subj 3 63173 NULL
109776 +SyS_syslog_63178 SyS_syslog 3 63178 NULL
109777 +security_policydb_len_63198 security_policydb_len 0 63198 NULL
109778 +vme_master_read_63221 vme_master_read 0 63221 NULL
109779 +SyS_gethostname_63227 SyS_gethostname 2 63227 NULL
109780 +module_alloc_update_bounds_rw_63233 module_alloc_update_bounds_rw 1 63233 NULL
109781 +ptp_read_63251 ptp_read 4 63251 NULL
109782 +xfs_dir2_leaf_getdents_63262 xfs_dir2_leaf_getdents 3 63262 NULL
109783 +ntfs_attr_can_be_non_resident_63267 ntfs_attr_can_be_non_resident 0 63267 NULL
109784 +raid5_resize_63306 raid5_resize 2 63306 NULL
109785 +proc_info_read_63344 proc_info_read 3 63344 NULL
109786 +ps_upsd_max_sptime_read_63362 ps_upsd_max_sptime_read 3 63362 NULL
109787 +idmouse_read_63374 idmouse_read 3 63374 NULL
109788 +edac_pci_alloc_ctl_info_63388 edac_pci_alloc_ctl_info 1 63388 NULL nohasharray
109789 +usbnet_read_cmd_nopm_63388 usbnet_read_cmd_nopm 7 63388 &edac_pci_alloc_ctl_info_63388
109790 +rxpipe_missed_beacon_host_int_trig_rx_data_read_63405 rxpipe_missed_beacon_host_int_trig_rx_data_read 3 63405 NULL
109791 +nouveau_event_create_63411 nouveau_event_create 1 63411 NULL
109792 +l2cap_sock_sendmsg_63427 l2cap_sock_sendmsg 4 63427 NULL
109793 +sep_prepare_input_output_dma_table_63429 sep_prepare_input_output_dma_table 3-4-2 63429 NULL
109794 +gfn_to_hva_many_63437 gfn_to_hva_many 2-0 63437 NULL
109795 +nfsd_symlink_63442 nfsd_symlink 6 63442 NULL
109796 +lookup_dir_item_inode_63447 lookup_dir_item_inode 0 63447 NULL
109797 +i915_gem_object_get_fence_63455 i915_gem_object_get_fence 0 63455 NULL
109798 +__do_kmalloc_node_63461 __do_kmalloc_node 3 63461 NULL
109799 +si5351_bulk_write_63468 si5351_bulk_write 2-3 63468 NULL
109800 +snd_info_entry_write_63474 snd_info_entry_write 3 63474 NULL
109801 +do_work_63483 do_work 0 63483 NULL
109802 +reada_find_extent_63486 reada_find_extent 2 63486 NULL
109803 +__copy_from_user_ll_nocache_63487 __copy_from_user_ll_nocache 0-3 63487 NULL
109804 +read_kcore_63488 read_kcore 3 63488 NULL nohasharray
109805 +alloc_reserved_tree_block_63488 alloc_reserved_tree_block 0 63488 &read_kcore_63488
109806 +save_hint_63497 save_hint 2 63497 NULL
109807 +wl1271_tx_min_rate_get_63498 wl1271_tx_min_rate_get 2 63498 NULL
109808 +sis_voice_irq_63501 sis_voice_irq 1 63501 NULL
109809 +snd_pcm_plug_write_transfer_63503 snd_pcm_plug_write_transfer 0-3 63503 NULL
109810 +efx_mcdi_rpc_async_63529 efx_mcdi_rpc_async 5-4 63529 NULL
109811 +ubi_more_leb_change_data_63534 ubi_more_leb_change_data 4-0 63534 NULL
109812 +write_file_spectral_period_63536 write_file_spectral_period 3 63536 NULL
109813 +if_sdio_read_scratch_63540 if_sdio_read_scratch 0 63540 NULL
109814 +append_to_buffer_63550 append_to_buffer 3 63550 NULL
109815 +dbg_leb_write_63555 dbg_leb_write 4-5 63555 NULL nohasharray
109816 +kvm_write_guest_page_63555 kvm_write_guest_page 2-5 63555 &dbg_leb_write_63555
109817 +ubifs_lpt_scan_nolock_63572 ubifs_lpt_scan_nolock 0 63572 NULL
109818 +iwch_reg_user_mr_63575 iwch_reg_user_mr 2-3 63575 NULL
109819 +ocfs2_calc_trunc_pos_63576 ocfs2_calc_trunc_pos 4 63576 NULL
109820 +rproc_alloc_63577 rproc_alloc 5 63577 NULL
109821 +ext3_clear_blocks_63597 ext3_clear_blocks 4-5 63597 NULL
109822 +write_debug_level_63613 write_debug_level 3 63613 NULL
109823 +module_alloc_63630 module_alloc 1 63630 NULL
109824 +ntfs_malloc_nofs_nofail_63631 ntfs_malloc_nofs_nofail 1 63631 NULL
109825 +symbol_build_supp_rates_63634 symbol_build_supp_rates 0 63634 NULL
109826 +_ubh_find_next_zero_bit__63640 _ubh_find_next_zero_bit_ 3-5-4 63640 NULL
109827 +ext4_ext_get_access_63642 ext4_ext_get_access 0 63642 NULL
109828 +proc_loginuid_write_63648 proc_loginuid_write 3 63648 NULL
109829 +ValidateDSDParamsChecksum_63654 ValidateDSDParamsChecksum 3 63654 NULL
109830 +ldlm_cli_enqueue_63657 ldlm_cli_enqueue 8 63657 NULL
109831 +hidraw_ioctl_63658 hidraw_ioctl 2 63658 NULL
109832 +vbi_read_63673 vbi_read 3 63673 NULL nohasharray
109833 +xen_register_pirq_63673 xen_register_pirq 1-2 63673 &vbi_read_63673
109834 +write_file_spectral_fft_period_63696 write_file_spectral_fft_period 3 63696 NULL
109835 +bin_search_63697 bin_search 0 63697 NULL
109836 +arizona_irq_map_63709 arizona_irq_map 2 63709 NULL
109837 +ocfs2_et_root_journal_access_63713 ocfs2_et_root_journal_access 0 63713 NULL
109838 +nouveau_object_create__63715 nouveau_object_create_ 5 63715 NULL
109839 +btrfs_insert_delayed_dir_index_63720 btrfs_insert_delayed_dir_index 4-0 63720 NULL
109840 +selinux_secctx_to_secid_63744 selinux_secctx_to_secid 2 63744 NULL
109841 +snd_pcm_oss_read1_63771 snd_pcm_oss_read1 3 63771 NULL
109842 +snd_pcm_link_63772 snd_pcm_link 0 63772 NULL
109843 +snd_opl4_mem_proc_read_63774 snd_opl4_mem_proc_read 5 63774 NULL
109844 +spidev_compat_ioctl_63778 spidev_compat_ioctl 2 63778 NULL
109845 +mwifiex_11n_create_rx_reorder_tbl_63806 mwifiex_11n_create_rx_reorder_tbl 4 63806 NULL
109846 +copy_nodes_to_user_63807 copy_nodes_to_user 2 63807 NULL
109847 +prepare_copy_63826 prepare_copy 2 63826 NULL
109848 +sel_write_load_63830 sel_write_load 3 63830 NULL
109849 +ll_readlink_63836 ll_readlink 3 63836 NULL
109850 +IsSectionWritable_63842 IsSectionWritable 0 63842 NULL
109851 +proc_pid_attr_write_63845 proc_pid_attr_write 3 63845 NULL
109852 +divas_write_63901 divas_write 3 63901 NULL
109853 +IsOffsetWritable_63902 IsOffsetWritable 0 63902 NULL nohasharray
109854 +xhci_alloc_stream_info_63902 xhci_alloc_stream_info 3 63902 &IsOffsetWritable_63902
109855 +uvc_alloc_urb_buffers_63922 uvc_alloc_urb_buffers 0-2-3 63922 NULL
109856 +snd_compr_write_63923 snd_compr_write 3 63923 NULL
109857 +acpi_ev_get_gpe_xrupt_block_63924 acpi_ev_get_gpe_xrupt_block 1 63924 NULL
109858 +tipc_send2port_63935 tipc_send2port 5 63935 NULL
109859 +afs_send_simple_reply_63940 afs_send_simple_reply 3 63940 NULL
109860 +__team_options_register_63941 __team_options_register 3 63941 NULL
109861 +macvtap_recvmsg_63949 macvtap_recvmsg 4 63949 NULL
109862 +generic_acl_init_63955 generic_acl_init 0 63955 NULL
109863 +domain_pfn_mapping_63957 domain_pfn_mapping 4 63957 NULL
109864 +diva_xdi_write_63975 diva_xdi_write 4 63975 NULL
109865 +rs_extent_to_bm_page_63996 rs_extent_to_bm_page 0-1 63996 NULL
109866 +read_file_frameerrors_64001 read_file_frameerrors 3 64001 NULL
109867 +hfsplus_security_setxattr_64009 hfsplus_security_setxattr 4 64009 NULL
109868 +C_SYSC_sendfile64_64017 C_SYSC_sendfile64 4 64017 NULL
109869 +SyS_rt_sigpending_64018 SyS_rt_sigpending 2 64018 NULL
109870 +offset_to_vaddr_64025 offset_to_vaddr 0-2 64025 NULL
109871 +dbAllocDmapLev_64030 dbAllocDmapLev 0 64030 NULL
109872 +resize_async_buffer_64031 resize_async_buffer 4 64031 NULL
109873 +SyS_fsetxattr_64039 SyS_fsetxattr 4 64039 NULL
109874 +tfrc_calc_x_reverse_lookup_64057 tfrc_calc_x_reverse_lookup 0 64057 NULL
109875 +__sock_create_64069 __sock_create 0 64069 NULL
109876 +get_u8_64076 get_u8 0 64076 NULL
109877 +xilly_malloc_64077 xilly_malloc 2 64077 NULL
109878 +btrfs_copy_root_64079 btrfs_copy_root 0 64079 NULL
109879 +sl_realloc_bufs_64086 sl_realloc_bufs 2 64086 NULL
109880 +clear_update_marker_64088 clear_update_marker 0 64088 NULL nohasharray
109881 +vmci_handle_arr_get_size_64088 vmci_handle_arr_get_size 0 64088 &clear_update_marker_64088
109882 +lbs_highrssi_read_64089 lbs_highrssi_read 3 64089 NULL
109883 +SyS_set_mempolicy_64096 SyS_set_mempolicy 3 64096 NULL
109884 +SyS_mq_timedsend_64107 SyS_mq_timedsend 3 64107 NULL
109885 +rdma_addr_size_64116 rdma_addr_size 0 64116 NULL
109886 +do_load_xattr_datum_64118 do_load_xattr_datum 0 64118 NULL
109887 +bypass_wd_write_64120 bypass_wd_write 3 64120 NULL
109888 +ol_quota_entries_per_block_64122 ol_quota_entries_per_block 0 64122 NULL
109889 +ext4_prepare_inline_data_64124 ext4_prepare_inline_data 3 64124 NULL
109890 +init_bch_64130 init_bch 2-1 64130 NULL
109891 +SYSC_ptrace_64136 SYSC_ptrace 3 64136 NULL
109892 +ablkcipher_copy_iv_64140 ablkcipher_copy_iv 3 64140 NULL
109893 +dlfb_ops_write_64150 dlfb_ops_write 3 64150 NULL
109894 +__comedi_buf_alloc_64155 __comedi_buf_alloc 3 64155 NULL
109895 +cpumask_scnprintf_64170 cpumask_scnprintf 0-2 64170 NULL
109896 +ocfs2_reserve_blocks_for_rec_trunc_64206 ocfs2_reserve_blocks_for_rec_trunc 0 64206 NULL
109897 +xfs_vm_direct_IO_64223 xfs_vm_direct_IO 4 64223 NULL
109898 +read_pulse_64227 read_pulse 0-3 64227 NULL
109899 +ea_len_64229 ea_len 0 64229 NULL
109900 +btrfs_make_block_group_64241 btrfs_make_block_group 0 64241 NULL
109901 +__btrfs_update_delayed_inode_64248 __btrfs_update_delayed_inode 0 64248 NULL
109902 +io_capture_transfer_64276 io_capture_transfer 4 64276 NULL
109903 +btrfs_file_extent_offset_64278 btrfs_file_extent_offset 0 64278 NULL
109904 +btrfs_next_item_64285 btrfs_next_item 0 64285 NULL
109905 +sta_current_tx_rate_read_64286 sta_current_tx_rate_read 3 64286 NULL
109906 +event_id_read_64288 event_id_read 3 64288 NULL nohasharray
109907 +xfs_dir_cilookup_result_64288 xfs_dir_cilookup_result 3 64288 &event_id_read_64288
109908 +ocfs2_block_check_validate_bhs_64302 ocfs2_block_check_validate_bhs 0 64302 NULL
109909 +snd_hda_get_sub_nodes_64304 snd_hda_get_sub_nodes 0 64304 NULL
109910 +error_error_bar_retry_read_64305 error_error_bar_retry_read 3 64305 NULL
109911 +ffz_64324 ffz 0-1 64324 NULL
109912 +map_region_64328 map_region 1 64328 NULL
109913 +sisusbcon_clear_64329 sisusbcon_clear 4-3-5 64329 NULL
109914 +ts_write_64336 ts_write 3 64336 NULL
109915 +usbtmc_write_64340 usbtmc_write 3 64340 NULL
109916 +do_write_orph_node_64343 do_write_orph_node 2 64343 NULL
109917 +ft1000_read_reg_64352 ft1000_read_reg 0 64352 NULL
109918 +bnx2x_vfop_mcast_cmd_64354 bnx2x_vfop_mcast_cmd 5 64354 NULL
109919 +user_regset_copyin_64360 user_regset_copyin 7 64360 NULL
109920 +wlc_phy_loadsampletable_nphy_64367 wlc_phy_loadsampletable_nphy 3 64367 NULL
109921 +reg_create_64372 reg_create 5 64372 NULL
109922 +ilo_write_64378 ilo_write 3 64378 NULL
109923 +btrfs_map_block_64379 btrfs_map_block 3 64379 NULL
109924 +vmcs_readl_64381 vmcs_readl 0 64381 NULL
109925 +nilfs_alloc_seg_bio_64383 nilfs_alloc_seg_bio 3 64383 NULL
109926 +ir_lirc_transmit_ir_64403 ir_lirc_transmit_ir 3 64403 NULL
109927 +pidlist_allocate_64404 pidlist_allocate 1 64404 NULL
109928 +rx_hdr_overflow_read_64407 rx_hdr_overflow_read 3 64407 NULL
109929 +snd_card_create_64418 snd_card_create 4 64418 NULL nohasharray
109930 +keyctl_get_security_64418 keyctl_get_security 3 64418 &snd_card_create_64418
109931 +nl80211_send_mgmt_64419 nl80211_send_mgmt 7 64419 NULL
109932 +oom_adj_write_64428 oom_adj_write 3 64428 NULL
109933 +ext4_trim_extent_64431 ext4_trim_extent 4 64431 NULL nohasharray
109934 +read_file_spectral_short_repeat_64431 read_file_spectral_short_repeat 3 64431 &ext4_trim_extent_64431
109935 +ax25_recvmsg_64441 ax25_recvmsg 4 64441 NULL
109936 +single_open_size_64483 single_open_size 4 64483 NULL
109937 +p54_parse_rssical_64493 p54_parse_rssical 3 64493 NULL
109938 +msg_data_sz_64503 msg_data_sz 0 64503 NULL
109939 +remove_uuid_64505 remove_uuid 4 64505 NULL nohasharray
109940 +handle_abnormal_pfn_64505 handle_abnormal_pfn 3 64505 &remove_uuid_64505
109941 +crypto_blkcipher_alignmask_64520 crypto_blkcipher_alignmask 0 64520 NULL
109942 +opera1_usb_i2c_msgxfer_64521 opera1_usb_i2c_msgxfer 4 64521 NULL
109943 +iwl_dbgfs_ucode_tracing_write_64524 iwl_dbgfs_ucode_tracing_write 3 64524 NULL
109944 +ses_send_diag_64527 ses_send_diag 4 64527 NULL
109945 +prctl_set_mm_64538 prctl_set_mm 3 64538 NULL
109946 +SyS_bind_64544 SyS_bind 3 64544 NULL
109947 +rbd_obj_read_sync_64554 rbd_obj_read_sync 4-3 64554 NULL
109948 +__btrfs_prealloc_file_range_64557 __btrfs_prealloc_file_range 3-0 64557 NULL
109949 +__spi_sync_64561 __spi_sync 0 64561 NULL nohasharray
109950 +ll_max_rw_chunk_seq_write_64561 ll_max_rw_chunk_seq_write 3 64561 &__spi_sync_64561
109951 +__apei_exec_run_64563 __apei_exec_run 0 64563 NULL
109952 +kstrtoul_from_user_64569 kstrtoul_from_user 2 64569 NULL
109953 +do_erase_64574 do_erase 4 64574 NULL
109954 +fanotify_write_64623 fanotify_write 3 64623 NULL
109955 +ocfs2_remove_refcount_extent_64631 ocfs2_remove_refcount_extent 0 64631 NULL
109956 +to_dblock_64655 to_dblock 0-1 64655 NULL
109957 +regmap_read_debugfs_64658 regmap_read_debugfs 5 64658 NULL
109958 +ocfs2_read_xattr_block_64661 ocfs2_read_xattr_block 0 64661 NULL nohasharray
109959 +tlbflush_read_file_64661 tlbflush_read_file 3 64661 &ocfs2_read_xattr_block_64661 nohasharray
109960 +pool_create_64661 pool_create 3 64661 &tlbflush_read_file_64661
109961 +efx_tsoh_get_buffer_64664 efx_tsoh_get_buffer 3 64664 NULL
109962 +rx_rx_out_of_mpdu_nodes_read_64668 rx_rx_out_of_mpdu_nodes_read 3 64668 NULL
109963 +nr_free_zone_pages_64680 nr_free_zone_pages 0 64680 NULL
109964 +sec_bulk_write_64691 sec_bulk_write 2-3 64691 NULL nohasharray
109965 +mremap_to_64691 mremap_to 0-3 64691 &sec_bulk_write_64691
109966 +pfn_to_hpa_64703 pfn_to_hpa 0-1 64703 NULL
109967 +ip_select_ident_more_64707 ip_select_ident_more 4 64707 NULL
109968 +snd_pcm_oss_capture_position_fixup_64713 snd_pcm_oss_capture_position_fixup 0 64713 NULL
109969 +dapm_bias_read_file_64715 dapm_bias_read_file 3 64715 NULL
109970 +atomic_add_return_64720 atomic_add_return 0-1 64720 NULL
109971 +i2400m_msg_to_dev_64722 i2400m_msg_to_dev 3 64722 NULL
109972 +AscGetChipVersion_64737 AscGetChipVersion 0 64737 NULL
109973 +squashfs_read_inode_lookup_table_64739 squashfs_read_inode_lookup_table 4 64739 NULL
109974 +perf_swevent_event_64745 perf_swevent_event 2 64745 NULL
109975 +bio_map_kern_64751 bio_map_kern 3 64751 NULL
109976 +rt2x00debug_write_csr_64753 rt2x00debug_write_csr 3 64753 NULL
109977 +message_for_md_64777 message_for_md 5 64777 NULL
109978 +isr_low_rssi_read_64789 isr_low_rssi_read 3 64789 NULL
109979 +regmap_reg_ranges_read_file_64798 regmap_reg_ranges_read_file 3 64798 NULL
109980 +nfsctl_transaction_write_64800 nfsctl_transaction_write 3 64800 NULL
109981 +rfkill_fop_write_64808 rfkill_fop_write 3 64808 NULL
109982 +proc_projid_map_write_64810 proc_projid_map_write 3 64810 NULL
109983 +megaraid_change_queue_depth_64815 megaraid_change_queue_depth 2 64815 NULL
109984 +ecryptfs_send_miscdev_64816 ecryptfs_send_miscdev 2 64816 NULL
109985 +vaddr_get_pfn_64818 vaddr_get_pfn 1 64818 NULL
109986 +gfn_to_page_64826 gfn_to_page 2 64826 NULL
109987 +do_kimage_alloc_64827 do_kimage_alloc 3 64827 NULL
109988 +altera_set_dr_pre_64862 altera_set_dr_pre 2 64862 NULL
109989 +gfn_to_pfn_64870 gfn_to_pfn 2 64870 NULL
109990 +lprocfs_write_u64_helper_64880 lprocfs_write_u64_helper 2 64880 NULL
109991 +ffs_epfile_io_64886 ffs_epfile_io 3 64886 NULL
109992 +mk_pid_64894 mk_pid 0-3 64894 NULL
109993 +ieee80211_if_read_ave_beacon_64924 ieee80211_if_read_ave_beacon 3 64924 NULL
109994 +usb_reset_and_verify_device_64933 usb_reset_and_verify_device 0 64933 NULL
109995 +ubifs_wbuf_write_nolock_64946 ubifs_wbuf_write_nolock 3 64946 NULL
109996 +ip_options_get_from_user_64958 ip_options_get_from_user 4 64958 NULL
109997 +acpi_os_install_interrupt_handler_64968 acpi_os_install_interrupt_handler 1 64968 NULL
109998 +traceprobe_probes_write_64969 traceprobe_probes_write 3 64969 NULL
109999 +suspend_dtim_interval_read_64971 suspend_dtim_interval_read 3 64971 NULL
110000 +ext2_group_first_block_no_64972 ext2_group_first_block_no 0-2 64972 NULL
110001 +crypto_ahash_digestsize_65014 crypto_ahash_digestsize 0 65014 NULL
110002 +insert_dent_65034 insert_dent 7 65034 NULL
110003 +snd_hda_get_pin_label_65035 snd_hda_get_pin_label 5 65035 NULL
110004 +ext4_ind_trans_blocks_65053 ext4_ind_trans_blocks 0-2 65053 NULL
110005 +pcibios_enable_device_65059 pcibios_enable_device 0 65059 NULL
110006 +make_idx_node_65068 make_idx_node 0 65068 NULL
110007 +count_run_65072 count_run 0-2-4-5 65072 NULL
110008 +__alloc_bootmem_node_high_65076 __alloc_bootmem_node_high 2 65076 NULL
110009 +ocfs2_truncate_cluster_pages_65086 ocfs2_truncate_cluster_pages 2 65086 NULL
110010 +send_create_inode_65090 send_create_inode 0 65090 NULL nohasharray
110011 +ath9k_dump_mci_btcoex_65090 ath9k_dump_mci_btcoex 0 65090 &send_create_inode_65090
110012 +uasp_alloc_cmd_65097 uasp_alloc_cmd 0 65097 NULL
110013 +__ext3_journal_dirty_metadata_65103 __ext3_journal_dirty_metadata 0 65103 NULL
110014 +generic_ocp_write_65107 generic_ocp_write 4 65107 NULL
110015 +kswapd_shrink_zone_65174 kswapd_shrink_zone 4 65174 NULL
110016 +i2c_smbus_xfer_emulated_65183 i2c_smbus_xfer_emulated 0 65183 NULL
110017 +btrfs_run_delayed_items_nr_65204 btrfs_run_delayed_items_nr 0 65204 NULL
110018 +rx_rx_done_read_65217 rx_rx_done_read 3 65217 NULL
110019 +print_endpoint_stat_65232 print_endpoint_stat 3-4-0 65232 NULL
110020 +journal_get_write_access_65243 journal_get_write_access 0 65243 NULL
110021 +whci_n_caps_65247 whci_n_caps 0 65247 NULL
110022 +kmem_zalloc_greedy_65268 kmem_zalloc_greedy 3-2 65268 NULL
110023 +kmalloc_parameter_65279 kmalloc_parameter 1 65279 NULL
110024 +compat_core_sys_select_65285 compat_core_sys_select 1 65285 NULL
110025 +get_unaligned_le16_65293 get_unaligned_le16 0 65293 NULL
110026 +mpi_set_buffer_65294 mpi_set_buffer 3 65294 NULL
110027 +redirected_tty_write_65297 redirected_tty_write 3 65297 NULL
110028 +get_var_len_65304 get_var_len 0 65304 NULL
110029 +unpack_array_65318 unpack_array 0 65318 NULL
110030 +pci_vpd_find_tag_65325 pci_vpd_find_tag 0-2 65325 NULL
110031 +dccp_setsockopt_service_65336 dccp_setsockopt_service 4 65336 NULL
110032 +init_list_set_65351 init_list_set 3-2 65351 NULL
110033 +dma_rx_requested_read_65354 dma_rx_requested_read 3 65354 NULL
110034 +batadv_tt_save_orig_buffer_65361 batadv_tt_save_orig_buffer 4 65361 NULL
110035 +alloc_cpu_rmap_65363 alloc_cpu_rmap 1 65363 NULL
110036 +__ext4_new_inode_65370 __ext4_new_inode 5 65370 NULL
110037 +SyS_writev_65372 SyS_writev 3 65372 NULL
110038 +mi_set_context_65395 mi_set_context 0 65395 NULL
110039 +__alloc_bootmem_nopanic_65397 __alloc_bootmem_nopanic 1 65397 NULL
110040 +trace_seq_to_user_65398 trace_seq_to_user 3 65398 NULL
110041 +mtd_get_device_size_65400 mtd_get_device_size 0 65400 NULL
110042 +__read_vmcore_65402 __read_vmcore 2 65402 NULL
110043 +usb_ep_enable_65405 usb_ep_enable 0 65405 NULL
110044 +ocfs2_write_begin_nolock_65410 ocfs2_write_begin_nolock 4-3 65410 NULL
110045 +drm_calloc_large_65421 drm_calloc_large 2-1 65421 NULL
110046 +device_add_groups_65423 device_add_groups 0 65423 NULL
110047 +xpc_kzalloc_cacheline_aligned_65433 xpc_kzalloc_cacheline_aligned 1 65433 NULL
110048 +vmalloc_to_pfn_65437 vmalloc_to_pfn 0 65437 NULL
110049 +usb_alloc_coherent_65444 usb_alloc_coherent 2 65444 NULL
110050 +il_dbgfs_wd_timeout_write_65464 il_dbgfs_wd_timeout_write 3 65464 NULL
110051 +ext4_es_zeroout_65465 ext4_es_zeroout 0 65465 NULL
110052 +clear_user_65470 clear_user 2 65470 NULL
110053 +dpcm_state_read_file_65489 dpcm_state_read_file 3 65489 NULL
110054 +lookup_inline_extent_backref_65493 lookup_inline_extent_backref 9-0 65493 NULL
110055 +nvme_trans_standard_inquiry_page_65526 nvme_trans_standard_inquiry_page 4 65526 NULL
110056 diff --git a/tools/gcc/size_overflow_plugin.c b/tools/gcc/size_overflow_plugin.c
110057 new file mode 100644
110058 index 0000000..a3f9702
110059 --- /dev/null
110060 +++ b/tools/gcc/size_overflow_plugin.c
110061 @@ -0,0 +1,3870 @@
110062 +/*
110063 + * Copyright 2011, 2012, 2013 by Emese Revfy <re.emese@gmail.com>
110064 + * Licensed under the GPL v2, or (at your option) v3
110065 + *
110066 + * Homepage:
110067 + * http://www.grsecurity.net/~ephox/overflow_plugin/
110068 + *
110069 + * Documentation:
110070 + * http://forums.grsecurity.net/viewtopic.php?f=7&t=3043
110071 + *
110072 + * This plugin recomputes expressions of function arguments marked by a size_overflow attribute
110073 + * with double integer precision (DImode/TImode for 32/64 bit integer types).
110074 + * The recomputed argument is checked against TYPE_MAX and an event is logged on overflow and the triggering process is killed.
110075 + *
110076 + * Usage:
110077 + * $ 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
110078 + * $ gcc -fplugin=size_overflow_plugin.so test.c -O2
110079 + */
110080 +
110081 +#include "gcc-plugin.h"
110082 +#include "config.h"
110083 +#include "system.h"
110084 +#include "coretypes.h"
110085 +#include "tree.h"
110086 +#include "tree-pass.h"
110087 +#include "intl.h"
110088 +#include "plugin-version.h"
110089 +#include "tm.h"
110090 +#include "toplev.h"
110091 +#include "function.h"
110092 +#include "tree-flow.h"
110093 +#include "plugin.h"
110094 +#include "gimple.h"
110095 +#include "diagnostic.h"
110096 +#include "cfgloop.h"
110097 +
110098 +#if BUILDING_GCC_VERSION >= 4008
110099 +#define TODO_dump_func 0
110100 +#define TODO_dump_cgraph 0
110101 +#endif
110102 +
110103 +#define __unused __attribute__((__unused__))
110104 +#define ASM_NAME(node) IDENTIFIER_POINTER(DECL_ASSEMBLER_NAME(node))
110105 +#define NAME(node) IDENTIFIER_POINTER(DECL_NAME(node))
110106 +#define NAME_LEN(node) IDENTIFIER_LENGTH(DECL_NAME(node))
110107 +#define BEFORE_STMT true
110108 +#define AFTER_STMT false
110109 +#define CREATE_NEW_VAR NULL_TREE
110110 +#define CODES_LIMIT 32
110111 +#define MAX_PARAM 31
110112 +#define VEC_LEN 128
110113 +#define MY_STMT GF_PLF_1
110114 +#define NO_CAST_CHECK GF_PLF_2
110115 +#define RET_CHECK NULL_TREE
110116 +#define CANNOT_FIND_ARG 32
110117 +#define WRONG_NODE 32
110118 +#define NOT_INTENTIONAL_ASM NULL
110119 +#define MIN_CHECK true
110120 +#define MAX_CHECK false
110121 +
110122 +#if BUILDING_GCC_VERSION == 4005
110123 +#define DECL_CHAIN(NODE) (TREE_CHAIN(DECL_MINIMAL_CHECK(NODE)))
110124 +#endif
110125 +
110126 +struct size_overflow_hash {
110127 + const struct size_overflow_hash * const next;
110128 + const char * const name;
110129 + const unsigned int param;
110130 +};
110131 +
110132 +#include "size_overflow_hash.h"
110133 +
110134 +enum mark {
110135 + MARK_NO, MARK_YES, MARK_NOT_INTENTIONAL, MARK_TURN_OFF
110136 +};
110137 +
110138 +static unsigned int call_count;
110139 +
110140 +struct visited {
110141 + struct visited *next;
110142 + const_tree fndecl;
110143 + unsigned int num;
110144 + const_gimple first_stmt;
110145 +};
110146 +
110147 +struct next_cgraph_node {
110148 + struct next_cgraph_node *next;
110149 + struct cgraph_node *current_function;
110150 + tree callee_fndecl;
110151 + unsigned int num;
110152 +};
110153 +
110154 +struct interesting_node {
110155 + struct interesting_node *next;
110156 + gimple first_stmt;
110157 + const_tree fndecl;
110158 + tree node;
110159 +#if BUILDING_GCC_VERSION <= 4007
110160 + VEC(tree, gc) *last_nodes;
110161 +#else
110162 + vec<tree, va_gc> *last_nodes;
110163 +#endif
110164 + unsigned int num;
110165 + enum mark intentional_attr_decl;
110166 + enum mark intentional_attr_cur_fndecl;
110167 + gimple intentional_mark_from_gimple;
110168 +};
110169 +
110170 +int plugin_is_GPL_compatible;
110171 +void debug_gimple_stmt(gimple gs);
110172 +
110173 +static tree report_size_overflow_decl;
110174 +static const_tree const_char_ptr_type_node;
110175 +
110176 +static tree expand(struct pointer_set_t *visited, struct cgraph_node *caller_node, tree lhs);
110177 +static void set_conditions(struct pointer_set_t *visited, bool *interesting_conditions, const_tree lhs);
110178 +static void walk_use_def(struct pointer_set_t *visited, struct interesting_node *cur_node, tree lhs);
110179 +static enum mark search_intentional(struct pointer_set_t *visited, const_tree lhs);
110180 +static void search_size_overflow_attribute(struct pointer_set_t *visited, tree lhs);
110181 +
110182 +static void check_size_overflow(struct cgraph_node *caller_node, gimple stmt, tree size_overflow_type, tree cast_rhs, tree rhs, bool before);
110183 +static tree get_size_overflow_type(gimple stmt, const_tree node);
110184 +static tree dup_assign(struct pointer_set_t *visited, gimple oldstmt, const_tree node, tree rhs1, tree rhs2, tree __unused rhs3);
110185 +
110186 +static struct plugin_info size_overflow_plugin_info = {
110187 + .version = "20131203beta",
110188 + .help = "no-size-overflow\tturn off size overflow checking\n",
110189 +};
110190 +
110191 +static tree handle_size_overflow_attribute(tree *node, tree __unused name, tree args, int __unused flags, bool *no_add_attrs)
110192 +{
110193 + unsigned int arg_count;
110194 + enum tree_code code = TREE_CODE(*node);
110195 +
110196 + switch (code) {
110197 + case FUNCTION_DECL:
110198 + arg_count = type_num_arguments(TREE_TYPE(*node));
110199 + break;
110200 + case FUNCTION_TYPE:
110201 + case METHOD_TYPE:
110202 + arg_count = type_num_arguments(*node);
110203 + break;
110204 + default:
110205 + *no_add_attrs = true;
110206 + error("%s: %qE attribute only applies to functions", __func__, name);
110207 + return NULL_TREE;
110208 + }
110209 +
110210 + for (; args; args = TREE_CHAIN(args)) {
110211 + tree position = TREE_VALUE(args);
110212 + if (TREE_CODE(position) != INTEGER_CST || TREE_INT_CST_LOW(position) > arg_count ) {
110213 + error("%s: parameter %u is outside range.", __func__, (unsigned int)TREE_INT_CST_LOW(position));
110214 + *no_add_attrs = true;
110215 + }
110216 + }
110217 + return NULL_TREE;
110218 +}
110219 +
110220 +static tree handle_intentional_overflow_attribute(tree *node, tree __unused name, tree args, int __unused flags, bool *no_add_attrs)
110221 +{
110222 + unsigned int arg_count;
110223 + enum tree_code code = TREE_CODE(*node);
110224 +
110225 + switch (code) {
110226 + case FUNCTION_DECL:
110227 + arg_count = type_num_arguments(TREE_TYPE(*node));
110228 + break;
110229 + case FUNCTION_TYPE:
110230 + case METHOD_TYPE:
110231 + arg_count = type_num_arguments(*node);
110232 + break;
110233 + case FIELD_DECL:
110234 + return NULL_TREE;
110235 + default:
110236 + *no_add_attrs = true;
110237 + error("%qE attribute only applies to functions", name);
110238 + return NULL_TREE;
110239 + }
110240 +
110241 + if (TREE_INT_CST_HIGH(TREE_VALUE(args)) != 0)
110242 + return NULL_TREE;
110243 +
110244 + for (; args; args = TREE_CHAIN(args)) {
110245 + tree position = TREE_VALUE(args);
110246 + if (TREE_CODE(position) != INTEGER_CST || TREE_INT_CST_LOW(position) > arg_count ) {
110247 + error("%s: parameter %u is outside range.", __func__, (unsigned int)TREE_INT_CST_LOW(position));
110248 + *no_add_attrs = true;
110249 + }
110250 + }
110251 + return NULL_TREE;
110252 +}
110253 +
110254 +static struct attribute_spec size_overflow_attr = {
110255 + .name = "size_overflow",
110256 + .min_length = 1,
110257 + .max_length = -1,
110258 + .decl_required = true,
110259 + .type_required = false,
110260 + .function_type_required = false,
110261 + .handler = handle_size_overflow_attribute,
110262 +#if BUILDING_GCC_VERSION >= 4007
110263 + .affects_type_identity = false
110264 +#endif
110265 +};
110266 +
110267 +static struct attribute_spec intentional_overflow_attr = {
110268 + .name = "intentional_overflow",
110269 + .min_length = 1,
110270 + .max_length = -1,
110271 + .decl_required = true,
110272 + .type_required = false,
110273 + .function_type_required = false,
110274 + .handler = handle_intentional_overflow_attribute,
110275 +#if BUILDING_GCC_VERSION >= 4007
110276 + .affects_type_identity = false
110277 +#endif
110278 +};
110279 +
110280 +static void register_attributes(void __unused *event_data, void __unused *data)
110281 +{
110282 + register_attribute(&size_overflow_attr);
110283 + register_attribute(&intentional_overflow_attr);
110284 +}
110285 +
110286 +static bool is_bool(const_tree node)
110287 +{
110288 + const_tree type;
110289 +
110290 + if (node == NULL_TREE)
110291 + return false;
110292 +
110293 + type = TREE_TYPE(node);
110294 + if (!INTEGRAL_TYPE_P(type))
110295 + return false;
110296 + if (TREE_CODE(type) == BOOLEAN_TYPE)
110297 + return true;
110298 + if (TYPE_PRECISION(type) == 1)
110299 + return true;
110300 + return false;
110301 +}
110302 +
110303 +static bool skip_types(const_tree var)
110304 +{
110305 + tree type;
110306 + enum tree_code code;
110307 +
110308 + if (is_gimple_constant(var))
110309 + return true;
110310 +
110311 + switch (TREE_CODE(var)) {
110312 + case ADDR_EXPR:
110313 +#if BUILDING_GCC_VERSION >= 4006
110314 + case MEM_REF:
110315 +#endif
110316 + case ARRAY_REF:
110317 + case BIT_FIELD_REF:
110318 + case INDIRECT_REF:
110319 + case TARGET_MEM_REF:
110320 + case COMPONENT_REF:
110321 + case VAR_DECL:
110322 + case VIEW_CONVERT_EXPR:
110323 + return true;
110324 + default:
110325 + break;
110326 + }
110327 +
110328 + code = TREE_CODE(var);
110329 + gcc_assert(code == SSA_NAME || code == PARM_DECL);
110330 +
110331 + type = TREE_TYPE(var);
110332 + switch (TREE_CODE(type)) {
110333 + case INTEGER_TYPE:
110334 + case ENUMERAL_TYPE:
110335 + return false;
110336 + case BOOLEAN_TYPE:
110337 + return is_bool(var);
110338 + default:
110339 + return true;
110340 + }
110341 +}
110342 +
110343 +static inline gimple get_def_stmt(const_tree node)
110344 +{
110345 + gcc_assert(node != NULL_TREE);
110346 +
110347 + if (skip_types(node))
110348 + return NULL;
110349 +
110350 + if (TREE_CODE(node) != SSA_NAME)
110351 + return NULL;
110352 + return SSA_NAME_DEF_STMT(node);
110353 +}
110354 +
110355 +static unsigned char get_tree_code(const_tree type)
110356 +{
110357 + switch (TREE_CODE(type)) {
110358 + case ARRAY_TYPE:
110359 + return 0;
110360 + case BOOLEAN_TYPE:
110361 + return 1;
110362 + case ENUMERAL_TYPE:
110363 + return 2;
110364 + case FUNCTION_TYPE:
110365 + return 3;
110366 + case INTEGER_TYPE:
110367 + return 4;
110368 + case POINTER_TYPE:
110369 + return 5;
110370 + case RECORD_TYPE:
110371 + return 6;
110372 + case UNION_TYPE:
110373 + return 7;
110374 + case VOID_TYPE:
110375 + return 8;
110376 + case REAL_TYPE:
110377 + return 9;
110378 + case VECTOR_TYPE:
110379 + return 10;
110380 + case REFERENCE_TYPE:
110381 + return 11;
110382 + case OFFSET_TYPE:
110383 + return 12;
110384 + case COMPLEX_TYPE:
110385 + return 13;
110386 + default:
110387 + debug_tree((tree)type);
110388 + gcc_unreachable();
110389 + }
110390 +}
110391 +
110392 +struct function_hash {
110393 + size_t tree_codes_len;
110394 + unsigned char tree_codes[CODES_LIMIT];
110395 + tree fndecl;
110396 + unsigned int hash;
110397 +};
110398 +
110399 +// http://www.team5150.com/~andrew/noncryptohashzoo2~/CrapWow.html
110400 +static unsigned int CrapWow(const char *key, unsigned int len, unsigned int seed)
110401 +{
110402 +#define cwfold( a, b, lo, hi ) { p = (unsigned int)(a) * (unsigned long long)(b); lo ^= (unsigned int)p; hi ^= (unsigned int)(p >> 32); }
110403 +#define cwmixa( in ) { cwfold( in, m, k, h ); }
110404 +#define cwmixb( in ) { cwfold( in, n, h, k ); }
110405 +
110406 + unsigned int m = 0x57559429;
110407 + unsigned int n = 0x5052acdb;
110408 + const unsigned int *key4 = (const unsigned int *)key;
110409 + unsigned int h = len;
110410 + unsigned int k = len + seed + n;
110411 + unsigned long long p;
110412 +
110413 + while (len >= 8) {
110414 + cwmixb(key4[0]) cwmixa(key4[1]) key4 += 2;
110415 + len -= 8;
110416 + }
110417 + if (len >= 4) {
110418 + cwmixb(key4[0]) key4 += 1;
110419 + len -= 4;
110420 + }
110421 + if (len)
110422 + cwmixa(key4[0] & ((1 << (len * 8)) - 1 ));
110423 + cwmixb(h ^ (k + n));
110424 + return k ^ h;
110425 +
110426 +#undef cwfold
110427 +#undef cwmixa
110428 +#undef cwmixb
110429 +}
110430 +
110431 +static void set_hash(const char *fn_name, struct function_hash *fn_hash_data)
110432 +{
110433 + unsigned int fn, codes, seed = 0;
110434 +
110435 + fn = CrapWow(fn_name, strlen(fn_name), seed) & 0xffff;
110436 + codes = CrapWow((const char*)fn_hash_data->tree_codes, fn_hash_data->tree_codes_len, seed) & 0xffff;
110437 +
110438 + fn_hash_data->hash = fn ^ codes;
110439 +}
110440 +
110441 +static void set_node_codes(const_tree type, struct function_hash *fn_hash_data)
110442 +{
110443 + gcc_assert(type != NULL_TREE);
110444 + gcc_assert(TREE_CODE_CLASS(TREE_CODE(type)) == tcc_type);
110445 +
110446 + while (type && fn_hash_data->tree_codes_len < CODES_LIMIT) {
110447 + fn_hash_data->tree_codes[fn_hash_data->tree_codes_len] = get_tree_code(type);
110448 + fn_hash_data->tree_codes_len++;
110449 + type = TREE_TYPE(type);
110450 + }
110451 +}
110452 +
110453 +static void set_result_codes(const_tree node, struct function_hash *fn_hash_data)
110454 +{
110455 + const_tree result;
110456 +
110457 + gcc_assert(node != NULL_TREE);
110458 +
110459 + if (DECL_P(node)) {
110460 + result = DECL_RESULT(node);
110461 + if (result != NULL_TREE)
110462 + return set_node_codes(TREE_TYPE(result), fn_hash_data);
110463 + return set_result_codes(TREE_TYPE(node), fn_hash_data);
110464 + }
110465 +
110466 + gcc_assert(TYPE_P(node));
110467 +
110468 + if (TREE_CODE(node) == FUNCTION_TYPE)
110469 + return set_result_codes(TREE_TYPE(node), fn_hash_data);
110470 +
110471 + return set_node_codes(node, fn_hash_data);
110472 +}
110473 +
110474 +static void set_function_codes(struct function_hash *fn_hash_data)
110475 +{
110476 + const_tree arg, type = TREE_TYPE(fn_hash_data->fndecl);
110477 + enum tree_code code = TREE_CODE(type);
110478 +
110479 + gcc_assert(code == FUNCTION_TYPE || code == METHOD_TYPE);
110480 +
110481 + set_result_codes(fn_hash_data->fndecl, fn_hash_data);
110482 +
110483 + for (arg = TYPE_ARG_TYPES(type); arg != NULL_TREE && fn_hash_data->tree_codes_len < CODES_LIMIT; arg = TREE_CHAIN(arg))
110484 + set_node_codes(TREE_VALUE(arg), fn_hash_data);
110485 +}
110486 +
110487 +static const struct size_overflow_hash *get_function_hash(tree fndecl)
110488 +{
110489 + const struct size_overflow_hash *entry;
110490 + struct function_hash fn_hash_data;
110491 + const char *func_name;
110492 +
110493 + // skip builtins __builtin_constant_p
110494 + if (DECL_BUILT_IN(fndecl))
110495 + return NULL;
110496 +
110497 + fn_hash_data.fndecl = fndecl;
110498 + fn_hash_data.tree_codes_len = 0;
110499 +
110500 + set_function_codes(&fn_hash_data);
110501 + gcc_assert(fn_hash_data.tree_codes_len != 0);
110502 +
110503 + func_name = ASM_NAME(fn_hash_data.fndecl);
110504 + set_hash(func_name, &fn_hash_data);
110505 +
110506 + entry = size_overflow_hash[fn_hash_data.hash];
110507 +
110508 + while (entry) {
110509 + if (!strcmp(entry->name, func_name))
110510 + return entry;
110511 + entry = entry->next;
110512 + }
110513 + return NULL;
110514 +}
110515 +
110516 +static void print_missing_msg(tree func, unsigned int argnum)
110517 +{
110518 + location_t loc;
110519 + const char *curfunc;
110520 + struct function_hash fn_hash_data;
110521 +
110522 + fn_hash_data.fndecl = DECL_ORIGIN(func);
110523 + fn_hash_data.tree_codes_len = 0;
110524 +
110525 + loc = DECL_SOURCE_LOCATION(fn_hash_data.fndecl);
110526 + curfunc = ASM_NAME(fn_hash_data.fndecl);
110527 +
110528 + set_function_codes(&fn_hash_data);
110529 + set_hash(curfunc, &fn_hash_data);
110530 +
110531 + inform(loc, "Function %s is missing from the size_overflow hash table +%s+%u+%u+", curfunc, curfunc, argnum, fn_hash_data.hash);
110532 +}
110533 +
110534 +static unsigned int find_arg_number_tree(const_tree arg, const_tree func)
110535 +{
110536 + tree var;
110537 + unsigned int argnum = 1;
110538 +
110539 + if (TREE_CODE(arg) == SSA_NAME)
110540 + arg = SSA_NAME_VAR(arg);
110541 +
110542 + for (var = DECL_ARGUMENTS(func); var; var = TREE_CHAIN(var), argnum++) {
110543 + if (!operand_equal_p(arg, var, 0) && strcmp(NAME(var), NAME(arg)))
110544 + continue;
110545 + if (!skip_types(var))
110546 + return argnum;
110547 + }
110548 +
110549 + return CANNOT_FIND_ARG;
110550 +}
110551 +
110552 +static tree create_new_var(tree type)
110553 +{
110554 + tree new_var = create_tmp_var(type, "cicus");
110555 +
110556 +#if BUILDING_GCC_VERSION <= 4007
110557 + add_referenced_var(new_var);
110558 +#endif
110559 + return new_var;
110560 +}
110561 +
110562 +static gimple create_binary_assign(enum tree_code code, gimple stmt, tree rhs1, tree rhs2)
110563 +{
110564 + gimple assign;
110565 + gimple_stmt_iterator gsi = gsi_for_stmt(stmt);
110566 + tree type = TREE_TYPE(rhs1);
110567 + tree lhs = create_new_var(type);
110568 +
110569 + gcc_assert(types_compatible_p(type, TREE_TYPE(rhs2)));
110570 + assign = gimple_build_assign_with_ops(code, lhs, rhs1, rhs2);
110571 + gimple_assign_set_lhs(assign, make_ssa_name(lhs, assign));
110572 +
110573 + gsi_insert_before(&gsi, assign, GSI_NEW_STMT);
110574 + update_stmt(assign);
110575 + gimple_set_plf(assign, MY_STMT, true);
110576 + return assign;
110577 +}
110578 +
110579 +static tree cast_a_tree(tree type, tree var)
110580 +{
110581 + gcc_assert(type != NULL_TREE);
110582 + gcc_assert(var != NULL_TREE);
110583 + gcc_assert(fold_convertible_p(type, var));
110584 +
110585 + return fold_convert(type, var);
110586 +}
110587 +
110588 +static tree get_lhs(const_gimple stmt)
110589 +{
110590 + switch (gimple_code(stmt)) {
110591 + case GIMPLE_ASSIGN:
110592 + case GIMPLE_CALL:
110593 + return gimple_get_lhs(stmt);
110594 + case GIMPLE_PHI:
110595 + return gimple_phi_result(stmt);
110596 + default:
110597 + return NULL_TREE;
110598 + }
110599 +}
110600 +
110601 +static bool skip_cast(tree dst_type, const_tree rhs, bool force)
110602 +{
110603 + const_gimple def_stmt = get_def_stmt(rhs);
110604 +
110605 + if (force)
110606 + return false;
110607 +
110608 + if (is_gimple_constant(rhs))
110609 + return false;
110610 +
110611 + if (!def_stmt || gimple_code(def_stmt) == GIMPLE_NOP)
110612 + return false;
110613 +
110614 + if (!types_compatible_p(dst_type, TREE_TYPE(rhs)))
110615 + return false;
110616 +
110617 + // DI type can be on 32 bit (from create_assign) but overflow type stays DI
110618 + if (LONG_TYPE_SIZE == GET_MODE_BITSIZE(SImode))
110619 + return false;
110620 +
110621 + return true;
110622 +}
110623 +
110624 +static gimple build_cast_stmt(tree dst_type, tree rhs, tree lhs, gimple_stmt_iterator *gsi, bool before, bool force)
110625 +{
110626 + gimple assign, def_stmt;
110627 +
110628 + gcc_assert(dst_type != NULL_TREE && rhs != NULL_TREE);
110629 + if (gsi_end_p(*gsi) && before == AFTER_STMT)
110630 + gcc_unreachable();
110631 +
110632 + def_stmt = get_def_stmt(rhs);
110633 + if (def_stmt && gimple_code(def_stmt) != GIMPLE_NOP && skip_cast(dst_type, rhs, force) && gimple_plf(def_stmt, MY_STMT))
110634 + return def_stmt;
110635 +
110636 + if (lhs == CREATE_NEW_VAR)
110637 + lhs = create_new_var(dst_type);
110638 +
110639 + assign = gimple_build_assign(lhs, cast_a_tree(dst_type, rhs));
110640 +
110641 + if (!gsi_end_p(*gsi)) {
110642 + location_t loc = gimple_location(gsi_stmt(*gsi));
110643 + gimple_set_location(assign, loc);
110644 + }
110645 +
110646 + gimple_assign_set_lhs(assign, make_ssa_name(lhs, assign));
110647 +
110648 + if (before)
110649 + gsi_insert_before(gsi, assign, GSI_NEW_STMT);
110650 + else
110651 + gsi_insert_after(gsi, assign, GSI_NEW_STMT);
110652 + update_stmt(assign);
110653 + return assign;
110654 +}
110655 +
110656 +static tree cast_to_new_size_overflow_type(gimple stmt, tree rhs, tree size_overflow_type, bool before)
110657 +{
110658 + gimple_stmt_iterator gsi;
110659 + tree lhs;
110660 + gimple new_stmt;
110661 +
110662 + if (rhs == NULL_TREE)
110663 + return NULL_TREE;
110664 +
110665 + gsi = gsi_for_stmt(stmt);
110666 + new_stmt = build_cast_stmt(size_overflow_type, rhs, CREATE_NEW_VAR, &gsi, before, false);
110667 + gimple_set_plf(new_stmt, MY_STMT, true);
110668 +
110669 + lhs = get_lhs(new_stmt);
110670 + gcc_assert(lhs != NULL_TREE);
110671 + return lhs;
110672 +}
110673 +
110674 +static tree cast_to_TI_type(gimple stmt, tree node)
110675 +{
110676 + gimple_stmt_iterator gsi;
110677 + gimple cast_stmt;
110678 + tree type = TREE_TYPE(node);
110679 +
110680 + if (types_compatible_p(type, intTI_type_node))
110681 + return node;
110682 +
110683 + gsi = gsi_for_stmt(stmt);
110684 + cast_stmt = build_cast_stmt(intTI_type_node, node, CREATE_NEW_VAR, &gsi, BEFORE_STMT, false);
110685 + gimple_set_plf(cast_stmt, MY_STMT, true);
110686 + return gimple_assign_lhs(cast_stmt);
110687 +}
110688 +
110689 +static tree create_assign(struct pointer_set_t *visited, gimple oldstmt, tree rhs1, bool before)
110690 +{
110691 + tree lhs, new_lhs;
110692 + gimple_stmt_iterator gsi;
110693 +
110694 + if (rhs1 == NULL_TREE) {
110695 + debug_gimple_stmt(oldstmt);
110696 + error("%s: rhs1 is NULL_TREE", __func__);
110697 + gcc_unreachable();
110698 + }
110699 +
110700 + switch (gimple_code(oldstmt)) {
110701 + case GIMPLE_ASM:
110702 + lhs = rhs1;
110703 + break;
110704 + case GIMPLE_CALL:
110705 + case GIMPLE_ASSIGN:
110706 + lhs = gimple_get_lhs(oldstmt);
110707 + break;
110708 + default:
110709 + debug_gimple_stmt(oldstmt);
110710 + gcc_unreachable();
110711 + }
110712 +
110713 + gsi = gsi_for_stmt(oldstmt);
110714 + pointer_set_insert(visited, oldstmt);
110715 + if (lookup_stmt_eh_lp(oldstmt) != 0) {
110716 + basic_block next_bb, cur_bb;
110717 + const_edge e;
110718 +
110719 + gcc_assert(before == false);
110720 + gcc_assert(stmt_can_throw_internal(oldstmt));
110721 + gcc_assert(gimple_code(oldstmt) == GIMPLE_CALL);
110722 + gcc_assert(!gsi_end_p(gsi));
110723 +
110724 + cur_bb = gimple_bb(oldstmt);
110725 + next_bb = cur_bb->next_bb;
110726 + e = find_edge(cur_bb, next_bb);
110727 + gcc_assert(e != NULL);
110728 + gcc_assert(e->flags & EDGE_FALLTHRU);
110729 +
110730 + gsi = gsi_after_labels(next_bb);
110731 + gcc_assert(!gsi_end_p(gsi));
110732 +
110733 + before = true;
110734 + oldstmt = gsi_stmt(gsi);
110735 + }
110736 +
110737 + new_lhs = cast_to_new_size_overflow_type(oldstmt, rhs1, get_size_overflow_type(oldstmt, lhs), before);
110738 + return new_lhs;
110739 +}
110740 +
110741 +static tree dup_assign(struct pointer_set_t *visited, gimple oldstmt, const_tree node, tree rhs1, tree rhs2, tree __unused rhs3)
110742 +{
110743 + gimple stmt;
110744 + gimple_stmt_iterator gsi;
110745 + tree size_overflow_type, new_var, lhs = gimple_assign_lhs(oldstmt);
110746 +
110747 + if (gimple_plf(oldstmt, MY_STMT))
110748 + return lhs;
110749 +
110750 + if (gimple_num_ops(oldstmt) != 4 && rhs1 == NULL_TREE) {
110751 + rhs1 = gimple_assign_rhs1(oldstmt);
110752 + rhs1 = create_assign(visited, oldstmt, rhs1, BEFORE_STMT);
110753 + }
110754 + if (gimple_num_ops(oldstmt) == 3 && rhs2 == NULL_TREE) {
110755 + rhs2 = gimple_assign_rhs2(oldstmt);
110756 + rhs2 = create_assign(visited, oldstmt, rhs2, BEFORE_STMT);
110757 + }
110758 +
110759 + stmt = gimple_copy(oldstmt);
110760 + gimple_set_location(stmt, gimple_location(oldstmt));
110761 + gimple_set_plf(stmt, MY_STMT, true);
110762 +
110763 + if (gimple_assign_rhs_code(oldstmt) == WIDEN_MULT_EXPR)
110764 + gimple_assign_set_rhs_code(stmt, MULT_EXPR);
110765 +
110766 + size_overflow_type = get_size_overflow_type(oldstmt, node);
110767 +
110768 + new_var = create_new_var(size_overflow_type);
110769 + new_var = make_ssa_name(new_var, stmt);
110770 + gimple_assign_set_lhs(stmt, new_var);
110771 +
110772 + if (rhs1 != NULL_TREE)
110773 + gimple_assign_set_rhs1(stmt, rhs1);
110774 +
110775 + if (rhs2 != NULL_TREE)
110776 + gimple_assign_set_rhs2(stmt, rhs2);
110777 +#if BUILDING_GCC_VERSION >= 4007
110778 + if (rhs3 != NULL_TREE)
110779 + gimple_assign_set_rhs3(stmt, rhs3);
110780 +#endif
110781 + gimple_set_vuse(stmt, gimple_vuse(oldstmt));
110782 + gimple_set_vdef(stmt, gimple_vdef(oldstmt));
110783 +
110784 + gsi = gsi_for_stmt(oldstmt);
110785 + gsi_insert_after(&gsi, stmt, GSI_SAME_STMT);
110786 + update_stmt(stmt);
110787 + pointer_set_insert(visited, oldstmt);
110788 + return gimple_assign_lhs(stmt);
110789 +}
110790 +
110791 +static tree cast_parm_decl(tree phi_ssa_name, tree arg, tree size_overflow_type, basic_block bb)
110792 +{
110793 + gimple assign;
110794 + gimple_stmt_iterator gsi;
110795 + basic_block first_bb;
110796 +
110797 + gcc_assert(SSA_NAME_IS_DEFAULT_DEF(arg));
110798 +
110799 + if (bb->index == 0) {
110800 + first_bb = split_block_after_labels(ENTRY_BLOCK_PTR)->dest;
110801 + gcc_assert(dom_info_available_p(CDI_DOMINATORS));
110802 + set_immediate_dominator(CDI_DOMINATORS, first_bb, ENTRY_BLOCK_PTR);
110803 + bb = first_bb;
110804 + }
110805 +
110806 + gsi = gsi_after_labels(bb);
110807 + assign = build_cast_stmt(size_overflow_type, arg, phi_ssa_name, &gsi, BEFORE_STMT, false);
110808 + gimple_set_plf(assign, MY_STMT, true);
110809 +
110810 + return gimple_assign_lhs(assign);
110811 +}
110812 +
110813 +static tree use_phi_ssa_name(tree ssa_name_var, tree new_arg)
110814 +{
110815 + gimple_stmt_iterator gsi;
110816 + gimple assign, def_stmt = get_def_stmt(new_arg);
110817 +
110818 + if (gimple_code(def_stmt) == GIMPLE_PHI) {
110819 + gsi = gsi_after_labels(gimple_bb(def_stmt));
110820 + assign = build_cast_stmt(TREE_TYPE(new_arg), new_arg, ssa_name_var, &gsi, BEFORE_STMT, true);
110821 + } else {
110822 + gsi = gsi_for_stmt(def_stmt);
110823 + assign = build_cast_stmt(TREE_TYPE(new_arg), new_arg, ssa_name_var, &gsi, AFTER_STMT, true);
110824 + }
110825 +
110826 + gimple_set_plf(assign, MY_STMT, true);
110827 + return gimple_assign_lhs(assign);
110828 +}
110829 +
110830 +static tree cast_visited_phi_arg(tree ssa_name_var, tree arg, tree size_overflow_type)
110831 +{
110832 + basic_block bb;
110833 + gimple_stmt_iterator gsi;
110834 + const_gimple def_stmt;
110835 + gimple assign;
110836 +
110837 + def_stmt = get_def_stmt(arg);
110838 + bb = gimple_bb(def_stmt);
110839 + gcc_assert(bb->index != 0);
110840 + gsi = gsi_after_labels(bb);
110841 +
110842 + assign = build_cast_stmt(size_overflow_type, arg, ssa_name_var, &gsi, BEFORE_STMT, false);
110843 + gimple_set_plf(assign, MY_STMT, true);
110844 + return gimple_assign_lhs(assign);
110845 +}
110846 +
110847 +static tree create_new_phi_arg(tree ssa_name_var, tree new_arg, gimple oldstmt, unsigned int i)
110848 +{
110849 + tree size_overflow_type;
110850 + tree arg;
110851 + const_gimple def_stmt;
110852 +
110853 + if (new_arg != NULL_TREE && is_gimple_constant(new_arg))
110854 + return new_arg;
110855 +
110856 + arg = gimple_phi_arg_def(oldstmt, i);
110857 + def_stmt = get_def_stmt(arg);
110858 + gcc_assert(def_stmt != NULL);
110859 + size_overflow_type = get_size_overflow_type(oldstmt, arg);
110860 +
110861 + switch (gimple_code(def_stmt)) {
110862 + case GIMPLE_PHI:
110863 + return cast_visited_phi_arg(ssa_name_var, arg, size_overflow_type);
110864 + case GIMPLE_NOP: {
110865 + basic_block bb;
110866 +
110867 + bb = gimple_phi_arg_edge(oldstmt, i)->src;
110868 + return cast_parm_decl(ssa_name_var, arg, size_overflow_type, bb);
110869 + }
110870 + case GIMPLE_ASM: {
110871 + gimple_stmt_iterator gsi;
110872 + gimple assign, stmt = get_def_stmt(arg);
110873 +
110874 + gsi = gsi_for_stmt(stmt);
110875 + assign = build_cast_stmt(size_overflow_type, arg, ssa_name_var, &gsi, AFTER_STMT, false);
110876 + gimple_set_plf(assign, MY_STMT, true);
110877 + return gimple_assign_lhs(assign);
110878 + }
110879 + default:
110880 + gcc_assert(new_arg != NULL_TREE);
110881 + gcc_assert(types_compatible_p(TREE_TYPE(new_arg), size_overflow_type));
110882 + return use_phi_ssa_name(ssa_name_var, new_arg);
110883 + }
110884 +}
110885 +
110886 +static gimple overflow_create_phi_node(gimple oldstmt, tree result)
110887 +{
110888 + basic_block bb;
110889 + gimple phi;
110890 + gimple_seq seq;
110891 + gimple_stmt_iterator gsi = gsi_for_stmt(oldstmt);
110892 +
110893 + bb = gsi_bb(gsi);
110894 +
110895 + if (result == NULL_TREE) {
110896 + tree old_result = gimple_phi_result(oldstmt);
110897 + tree size_overflow_type = get_size_overflow_type(oldstmt, old_result);
110898 +
110899 + result = create_new_var(size_overflow_type);
110900 + }
110901 +
110902 + phi = create_phi_node(result, bb);
110903 + gimple_phi_set_result(phi, make_ssa_name(result, phi));
110904 + seq = phi_nodes(bb);
110905 + gsi = gsi_last(seq);
110906 + gsi_remove(&gsi, false);
110907 +
110908 + gsi = gsi_for_stmt(oldstmt);
110909 + gsi_insert_after(&gsi, phi, GSI_NEW_STMT);
110910 + gimple_set_bb(phi, bb);
110911 + gimple_set_plf(phi, MY_STMT, true);
110912 + return phi;
110913 +}
110914 +
110915 +#if BUILDING_GCC_VERSION <= 4007
110916 +static tree create_new_phi_node(VEC(tree, gc) *args, tree ssa_name_var, gimple oldstmt)
110917 +#else
110918 +static tree create_new_phi_node(vec<tree, va_gc> *args, tree ssa_name_var, gimple oldstmt)
110919 +#endif
110920 +{
110921 + gimple new_phi;
110922 + unsigned int i;
110923 + tree arg, result;
110924 + location_t loc = gimple_location(oldstmt);
110925 +
110926 +#if BUILDING_GCC_VERSION <= 4007
110927 + gcc_assert(!VEC_empty(tree, args));
110928 +#else
110929 + gcc_assert(!args->is_empty());
110930 +#endif
110931 +
110932 + new_phi = overflow_create_phi_node(oldstmt, ssa_name_var);
110933 + result = gimple_phi_result(new_phi);
110934 + ssa_name_var = SSA_NAME_VAR(result);
110935 +
110936 +
110937 +#if BUILDING_GCC_VERSION == 4005
110938 + for (i = 0; i < VEC_length(tree, args); i++) {
110939 + arg = VEC_index(tree, args, i);
110940 +#elif BUILDING_GCC_VERSION <= 4007
110941 + FOR_EACH_VEC_ELT(tree, args, i, arg) {
110942 +#else
110943 + FOR_EACH_VEC_ELT(*args, i, arg) {
110944 +#endif
110945 + arg = create_new_phi_arg(ssa_name_var, arg, oldstmt, i);
110946 + add_phi_arg(new_phi, arg, gimple_phi_arg_edge(oldstmt, i), loc);
110947 + }
110948 +
110949 +#if BUILDING_GCC_VERSION <= 4007
110950 + VEC_free(tree, gc, args);
110951 +#else
110952 + vec_free(args);
110953 +#endif
110954 + update_stmt(new_phi);
110955 + return result;
110956 +}
110957 +
110958 +static tree handle_phi(struct pointer_set_t *visited, struct cgraph_node *caller_node, tree orig_result)
110959 +{
110960 + tree ssa_name_var = NULL_TREE;
110961 +#if BUILDING_GCC_VERSION <= 4007
110962 + VEC(tree, gc) *args;
110963 +#else
110964 + vec<tree, va_gc> *args;
110965 +#endif
110966 + gimple oldstmt = get_def_stmt(orig_result);
110967 + unsigned int i, len = gimple_phi_num_args(oldstmt);
110968 +
110969 + pointer_set_insert(visited, oldstmt);
110970 +#if BUILDING_GCC_VERSION <= 4007
110971 + args = VEC_alloc(tree, gc, len);
110972 +#else
110973 + vec_alloc(args, len);
110974 +#endif
110975 + for (i = 0; i < len; i++) {
110976 + tree arg, new_arg;
110977 +
110978 + arg = gimple_phi_arg_def(oldstmt, i);
110979 + new_arg = expand(visited, caller_node, arg);
110980 +
110981 + if (ssa_name_var == NULL_TREE && new_arg != NULL_TREE)
110982 + ssa_name_var = SSA_NAME_VAR(new_arg);
110983 +
110984 + if (is_gimple_constant(arg)) {
110985 + tree size_overflow_type = get_size_overflow_type(oldstmt, arg);
110986 +
110987 + new_arg = cast_a_tree(size_overflow_type, arg);
110988 + }
110989 +
110990 +#if BUILDING_GCC_VERSION <= 4007
110991 + VEC_safe_push(tree, gc, args, new_arg);
110992 +#else
110993 + vec_safe_push(args, new_arg);
110994 +#endif
110995 + }
110996 +
110997 + return create_new_phi_node(args, ssa_name_var, oldstmt);
110998 +}
110999 +
111000 +static tree change_assign_rhs(gimple stmt, const_tree orig_rhs, tree new_rhs)
111001 +{
111002 + gimple assign;
111003 + gimple_stmt_iterator gsi = gsi_for_stmt(stmt);
111004 + tree origtype = TREE_TYPE(orig_rhs);
111005 +
111006 + gcc_assert(is_gimple_assign(stmt));
111007 +
111008 + assign = build_cast_stmt(origtype, new_rhs, CREATE_NEW_VAR, &gsi, BEFORE_STMT, false);
111009 + gimple_set_plf(assign, MY_STMT, true);
111010 + return gimple_assign_lhs(assign);
111011 +}
111012 +
111013 +static bool is_a_cast_and_const_overflow(const_tree no_const_rhs)
111014 +{
111015 + const_tree rhs1, lhs, rhs1_type, lhs_type;
111016 + enum machine_mode lhs_mode, rhs_mode;
111017 + gimple def_stmt = get_def_stmt(no_const_rhs);
111018 +
111019 + if (!def_stmt || !gimple_assign_cast_p(def_stmt))
111020 + return false;
111021 +
111022 + rhs1 = gimple_assign_rhs1(def_stmt);
111023 + lhs = gimple_assign_lhs(def_stmt);
111024 + rhs1_type = TREE_TYPE(rhs1);
111025 + lhs_type = TREE_TYPE(lhs);
111026 + rhs_mode = TYPE_MODE(rhs1_type);
111027 + lhs_mode = TYPE_MODE(lhs_type);
111028 + if (TYPE_UNSIGNED(lhs_type) == TYPE_UNSIGNED(rhs1_type) || lhs_mode != rhs_mode)
111029 + return false;
111030 +
111031 + return true;
111032 +}
111033 +
111034 +static tree create_cast_assign(struct pointer_set_t *visited, gimple stmt)
111035 +{
111036 + tree rhs1 = gimple_assign_rhs1(stmt);
111037 + tree lhs = gimple_assign_lhs(stmt);
111038 + const_tree rhs1_type = TREE_TYPE(rhs1);
111039 + const_tree lhs_type = TREE_TYPE(lhs);
111040 +
111041 + if (TYPE_UNSIGNED(rhs1_type) == TYPE_UNSIGNED(lhs_type))
111042 + return create_assign(visited, stmt, lhs, AFTER_STMT);
111043 +
111044 + return create_assign(visited, stmt, rhs1, AFTER_STMT);
111045 +}
111046 +
111047 +static bool no_uses(tree node)
111048 +{
111049 + imm_use_iterator imm_iter;
111050 + use_operand_p use_p;
111051 +
111052 + FOR_EACH_IMM_USE_FAST(use_p, imm_iter, node) {
111053 + const_gimple use_stmt = USE_STMT(use_p);
111054 +
111055 + if (use_stmt == NULL)
111056 + return true;
111057 + if (is_gimple_debug(use_stmt))
111058 + continue;
111059 + return false;
111060 + }
111061 + return true;
111062 +}
111063 +
111064 +// 3.8.5 mm/page-writeback.c __ilog2_u64(): ret, uint + uintmax; uint -> int; int max
111065 +static bool is_const_plus_unsigned_signed_truncation(const_tree lhs)
111066 +{
111067 + tree rhs1, lhs_type, rhs_type, rhs2, not_const_rhs;
111068 + gimple def_stmt = get_def_stmt(lhs);
111069 +
111070 + if (!def_stmt || !gimple_assign_cast_p(def_stmt))
111071 + return false;
111072 +
111073 + rhs1 = gimple_assign_rhs1(def_stmt);
111074 + rhs_type = TREE_TYPE(rhs1);
111075 + lhs_type = TREE_TYPE(lhs);
111076 + if (TYPE_UNSIGNED(lhs_type) || !TYPE_UNSIGNED(rhs_type))
111077 + return false;
111078 + if (TYPE_MODE(lhs_type) != TYPE_MODE(rhs_type))
111079 + return false;
111080 +
111081 + def_stmt = get_def_stmt(rhs1);
111082 + if (!def_stmt || !is_gimple_assign(def_stmt) || gimple_num_ops(def_stmt) != 3)
111083 + return false;
111084 +
111085 + if (gimple_assign_rhs_code(def_stmt) != PLUS_EXPR)
111086 + return false;
111087 +
111088 + rhs1 = gimple_assign_rhs1(def_stmt);
111089 + rhs2 = gimple_assign_rhs2(def_stmt);
111090 + if (!is_gimple_constant(rhs1) && !is_gimple_constant(rhs2))
111091 + return false;
111092 +
111093 + if (is_gimple_constant(rhs2))
111094 + not_const_rhs = rhs1;
111095 + else
111096 + not_const_rhs = rhs2;
111097 +
111098 + return no_uses(not_const_rhs);
111099 +}
111100 +
111101 +static bool skip_lhs_cast_check(const_gimple stmt)
111102 +{
111103 + const_tree rhs = gimple_assign_rhs1(stmt);
111104 + const_gimple def_stmt = get_def_stmt(rhs);
111105 +
111106 + // 3.8.2 kernel/futex_compat.c compat_exit_robust_list(): get_user() 64 ulong -> int (compat_long_t), int max
111107 + if (gimple_code(def_stmt) == GIMPLE_ASM)
111108 + return true;
111109 +
111110 + if (is_const_plus_unsigned_signed_truncation(rhs))
111111 + return true;
111112 +
111113 + return false;
111114 +}
111115 +
111116 +static tree create_cast_overflow_check(struct pointer_set_t *visited, struct cgraph_node *caller_node, tree new_rhs1, gimple stmt)
111117 +{
111118 + bool cast_lhs, cast_rhs;
111119 + tree lhs = gimple_assign_lhs(stmt);
111120 + tree rhs = gimple_assign_rhs1(stmt);
111121 + const_tree lhs_type = TREE_TYPE(lhs);
111122 + const_tree rhs_type = TREE_TYPE(rhs);
111123 + enum machine_mode lhs_mode = TYPE_MODE(lhs_type);
111124 + enum machine_mode rhs_mode = TYPE_MODE(rhs_type);
111125 + unsigned int lhs_size = GET_MODE_BITSIZE(lhs_mode);
111126 + unsigned int rhs_size = GET_MODE_BITSIZE(rhs_mode);
111127 +
111128 + static bool check_lhs[3][4] = {
111129 + // ss su us uu
111130 + { false, true, true, false }, // lhs > rhs
111131 + { false, false, false, false }, // lhs = rhs
111132 + { true, true, true, true }, // lhs < rhs
111133 + };
111134 +
111135 + static bool check_rhs[3][4] = {
111136 + // ss su us uu
111137 + { true, false, true, true }, // lhs > rhs
111138 + { true, false, true, true }, // lhs = rhs
111139 + { true, false, true, true }, // lhs < rhs
111140 + };
111141 +
111142 + // skip lhs check on signed SI -> HI cast or signed SI -> QI cast !!!!
111143 + if (rhs_mode == SImode && !TYPE_UNSIGNED(rhs_type) && (lhs_mode == HImode || lhs_mode == QImode))
111144 + return create_assign(visited, stmt, lhs, AFTER_STMT);
111145 +
111146 + if (lhs_size > rhs_size) {
111147 + cast_lhs = check_lhs[0][TYPE_UNSIGNED(rhs_type) + 2 * TYPE_UNSIGNED(lhs_type)];
111148 + cast_rhs = check_rhs[0][TYPE_UNSIGNED(rhs_type) + 2 * TYPE_UNSIGNED(lhs_type)];
111149 + } else if (lhs_size == rhs_size) {
111150 + cast_lhs = check_lhs[1][TYPE_UNSIGNED(rhs_type) + 2 * TYPE_UNSIGNED(lhs_type)];
111151 + cast_rhs = check_rhs[1][TYPE_UNSIGNED(rhs_type) + 2 * TYPE_UNSIGNED(lhs_type)];
111152 + } else {
111153 + cast_lhs = check_lhs[2][TYPE_UNSIGNED(rhs_type) + 2 * TYPE_UNSIGNED(lhs_type)];
111154 + cast_rhs = check_rhs[2][TYPE_UNSIGNED(rhs_type) + 2 * TYPE_UNSIGNED(lhs_type)];
111155 + }
111156 +
111157 + if (!cast_lhs && !cast_rhs)
111158 + return dup_assign(visited, stmt, lhs, new_rhs1, NULL_TREE, NULL_TREE);
111159 +
111160 + if (cast_lhs && !skip_lhs_cast_check(stmt))
111161 + check_size_overflow(caller_node, stmt, TREE_TYPE(new_rhs1), new_rhs1, lhs, BEFORE_STMT);
111162 +
111163 + if (cast_rhs)
111164 + check_size_overflow(caller_node, stmt, TREE_TYPE(new_rhs1), new_rhs1, rhs, BEFORE_STMT);
111165 +
111166 + return dup_assign(visited, stmt, lhs, new_rhs1, NULL_TREE, NULL_TREE);
111167 +}
111168 +
111169 +static tree handle_unary_rhs(struct pointer_set_t *visited, struct cgraph_node *caller_node, gimple stmt)
111170 +{
111171 + tree rhs1, new_rhs1, lhs = gimple_assign_lhs(stmt);
111172 +
111173 + if (gimple_plf(stmt, MY_STMT))
111174 + return lhs;
111175 +
111176 + rhs1 = gimple_assign_rhs1(stmt);
111177 + if (TREE_CODE(TREE_TYPE(rhs1)) == POINTER_TYPE)
111178 + return create_assign(visited, stmt, lhs, AFTER_STMT);
111179 +
111180 + new_rhs1 = expand(visited, caller_node, rhs1);
111181 +
111182 + if (new_rhs1 == NULL_TREE)
111183 + return create_cast_assign(visited, stmt);
111184 +
111185 + if (gimple_plf(stmt, NO_CAST_CHECK))
111186 + return dup_assign(visited, stmt, lhs, new_rhs1, NULL_TREE, NULL_TREE);
111187 +
111188 + if (gimple_assign_rhs_code(stmt) == BIT_NOT_EXPR) {
111189 + tree size_overflow_type = get_size_overflow_type(stmt, rhs1);
111190 +
111191 + new_rhs1 = cast_to_new_size_overflow_type(stmt, new_rhs1, size_overflow_type, BEFORE_STMT);
111192 + check_size_overflow(caller_node, stmt, size_overflow_type, new_rhs1, rhs1, BEFORE_STMT);
111193 + return create_assign(visited, stmt, lhs, AFTER_STMT);
111194 + }
111195 +
111196 + if (!gimple_assign_cast_p(stmt))
111197 + return dup_assign(visited, stmt, lhs, new_rhs1, NULL_TREE, NULL_TREE);
111198 +
111199 + return create_cast_overflow_check(visited, caller_node, new_rhs1, stmt);
111200 +}
111201 +
111202 +static tree handle_unary_ops(struct pointer_set_t *visited, struct cgraph_node *caller_node, gimple stmt)
111203 +{
111204 + tree rhs1, lhs = gimple_assign_lhs(stmt);
111205 + gimple def_stmt = get_def_stmt(lhs);
111206 +
111207 + gcc_assert(gimple_code(def_stmt) != GIMPLE_NOP);
111208 + rhs1 = gimple_assign_rhs1(def_stmt);
111209 +
111210 + if (is_gimple_constant(rhs1))
111211 + return create_assign(visited, def_stmt, lhs, AFTER_STMT);
111212 +
111213 + switch (TREE_CODE(rhs1)) {
111214 + case SSA_NAME:
111215 + return handle_unary_rhs(visited, caller_node, def_stmt);
111216 + case ARRAY_REF:
111217 + case BIT_FIELD_REF:
111218 + case ADDR_EXPR:
111219 + case COMPONENT_REF:
111220 + case INDIRECT_REF:
111221 +#if BUILDING_GCC_VERSION >= 4006
111222 + case MEM_REF:
111223 +#endif
111224 + case TARGET_MEM_REF:
111225 + case VIEW_CONVERT_EXPR:
111226 + return create_assign(visited, def_stmt, lhs, AFTER_STMT);
111227 + case PARM_DECL:
111228 + case VAR_DECL:
111229 + return create_assign(visited, stmt, lhs, AFTER_STMT);
111230 +
111231 + default:
111232 + debug_gimple_stmt(def_stmt);
111233 + debug_tree(rhs1);
111234 + gcc_unreachable();
111235 + }
111236 +}
111237 +
111238 +static void insert_cond(basic_block cond_bb, tree arg, enum tree_code cond_code, tree type_value)
111239 +{
111240 + gimple cond_stmt;
111241 + gimple_stmt_iterator gsi = gsi_last_bb(cond_bb);
111242 +
111243 + cond_stmt = gimple_build_cond(cond_code, arg, type_value, NULL_TREE, NULL_TREE);
111244 + gsi_insert_after(&gsi, cond_stmt, GSI_CONTINUE_LINKING);
111245 + update_stmt(cond_stmt);
111246 +}
111247 +
111248 +static tree create_string_param(tree string)
111249 +{
111250 + tree i_type, a_type;
111251 + const int length = TREE_STRING_LENGTH(string);
111252 +
111253 + gcc_assert(length > 0);
111254 +
111255 + i_type = build_index_type(build_int_cst(NULL_TREE, length - 1));
111256 + a_type = build_array_type(char_type_node, i_type);
111257 +
111258 + TREE_TYPE(string) = a_type;
111259 + TREE_CONSTANT(string) = 1;
111260 + TREE_READONLY(string) = 1;
111261 +
111262 + return build1(ADDR_EXPR, ptr_type_node, string);
111263 +}
111264 +
111265 +#if BUILDING_GCC_VERSION <= 4006
111266 +struct cgraph_node *cgraph_get_create_node(tree decl);
111267 +
111268 +struct cgraph_node *cgraph_get_create_node(tree decl)
111269 +{
111270 + struct cgraph_node *node;
111271 +
111272 + node = cgraph_get_node(decl);
111273 + if (node)
111274 + return node;
111275 + return cgraph_node(decl);
111276 +}
111277 +#endif
111278 +
111279 +static void insert_cond_result(struct cgraph_node *caller_node, basic_block bb_true, const_gimple stmt, const_tree arg, bool min)
111280 +{
111281 + gimple func_stmt;
111282 + const_gimple def_stmt;
111283 + const_tree loc_line;
111284 + tree loc_file, ssa_name, current_func;
111285 + expanded_location xloc;
111286 + char *ssa_name_buf;
111287 + int len;
111288 + struct cgraph_edge *edge;
111289 + struct cgraph_node *callee_node;
111290 + int frequency;
111291 + gimple_stmt_iterator gsi = gsi_start_bb(bb_true);
111292 +
111293 + def_stmt = get_def_stmt(arg);
111294 + xloc = expand_location(gimple_location(def_stmt));
111295 +
111296 + if (!gimple_has_location(def_stmt)) {
111297 + xloc = expand_location(gimple_location(stmt));
111298 + if (!gimple_has_location(stmt))
111299 + xloc = expand_location(DECL_SOURCE_LOCATION(current_function_decl));
111300 + }
111301 +
111302 + loc_line = build_int_cstu(unsigned_type_node, xloc.line);
111303 +
111304 + loc_file = build_string(strlen(xloc.file) + 1, xloc.file);
111305 + loc_file = create_string_param(loc_file);
111306 +
111307 + current_func = build_string(NAME_LEN(current_function_decl) + 1, NAME(current_function_decl));
111308 + current_func = create_string_param(current_func);
111309 +
111310 + gcc_assert(DECL_NAME(SSA_NAME_VAR(arg)) != NULL);
111311 + call_count++;
111312 + 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);
111313 + gcc_assert(len > 0);
111314 + ssa_name = build_string(len + 1, ssa_name_buf);
111315 + free(ssa_name_buf);
111316 + ssa_name = create_string_param(ssa_name);
111317 +
111318 + // void report_size_overflow(const char *file, unsigned int line, const char *func, const char *ssa_name)
111319 + func_stmt = gimple_build_call(report_size_overflow_decl, 4, loc_file, loc_line, current_func, ssa_name);
111320 + gsi_insert_after(&gsi, func_stmt, GSI_CONTINUE_LINKING);
111321 +
111322 + callee_node = cgraph_get_create_node(report_size_overflow_decl);
111323 + frequency = compute_call_stmt_bb_frequency(current_function_decl, bb_true);
111324 +
111325 +#if BUILDING_GCC_VERSION <= 4006
111326 + edge = cgraph_create_edge(caller_node, callee_node, func_stmt, bb_true->count, frequency, bb_true->loop_depth);
111327 +#else
111328 + edge = cgraph_create_edge(caller_node, callee_node, func_stmt, bb_true->count, frequency);
111329 +#endif
111330 + gcc_assert(edge != NULL);
111331 +}
111332 +
111333 +static void __unused print_the_code_insertions(const_gimple stmt)
111334 +{
111335 + location_t loc = gimple_location(stmt);
111336 +
111337 + inform(loc, "Integer size_overflow check applied here.");
111338 +}
111339 +
111340 +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)
111341 +{
111342 + basic_block cond_bb, join_bb, bb_true;
111343 + edge e;
111344 + gimple_stmt_iterator gsi = gsi_for_stmt(stmt);
111345 +
111346 + cond_bb = gimple_bb(stmt);
111347 + if (before)
111348 + gsi_prev(&gsi);
111349 + if (gsi_end_p(gsi))
111350 + e = split_block_after_labels(cond_bb);
111351 + else
111352 + e = split_block(cond_bb, gsi_stmt(gsi));
111353 + cond_bb = e->src;
111354 + join_bb = e->dest;
111355 + e->flags = EDGE_FALSE_VALUE;
111356 + e->probability = REG_BR_PROB_BASE;
111357 +
111358 + bb_true = create_empty_bb(cond_bb);
111359 + make_edge(cond_bb, bb_true, EDGE_TRUE_VALUE);
111360 + make_edge(cond_bb, join_bb, EDGE_FALSE_VALUE);
111361 + make_edge(bb_true, join_bb, EDGE_FALLTHRU);
111362 +
111363 + gcc_assert(dom_info_available_p(CDI_DOMINATORS));
111364 + set_immediate_dominator(CDI_DOMINATORS, bb_true, cond_bb);
111365 + set_immediate_dominator(CDI_DOMINATORS, join_bb, cond_bb);
111366 +
111367 + if (current_loops != NULL) {
111368 + gcc_assert(cond_bb->loop_father == join_bb->loop_father);
111369 + add_bb_to_loop(bb_true, cond_bb->loop_father);
111370 + }
111371 +
111372 + insert_cond(cond_bb, arg, cond_code, type_value);
111373 + insert_cond_result(caller_node, bb_true, stmt, arg, min);
111374 +
111375 +// print_the_code_insertions(stmt);
111376 +}
111377 +
111378 +static void check_size_overflow(struct cgraph_node *caller_node, gimple stmt, tree size_overflow_type, tree cast_rhs, tree rhs, bool before)
111379 +{
111380 + const_tree rhs_type = TREE_TYPE(rhs);
111381 + tree cast_rhs_type, type_max_type, type_min_type, type_max, type_min;
111382 +
111383 + gcc_assert(rhs_type != NULL_TREE);
111384 + if (TREE_CODE(rhs_type) == POINTER_TYPE)
111385 + return;
111386 +
111387 + gcc_assert(TREE_CODE(rhs_type) == INTEGER_TYPE || TREE_CODE(rhs_type) == ENUMERAL_TYPE);
111388 +
111389 + if (is_const_plus_unsigned_signed_truncation(rhs))
111390 + return;
111391 +
111392 + type_max = cast_a_tree(size_overflow_type, TYPE_MAX_VALUE(rhs_type));
111393 + // typemax (-1) < typemin (0)
111394 + if (TREE_OVERFLOW(type_max))
111395 + return;
111396 +
111397 + type_min = cast_a_tree(size_overflow_type, TYPE_MIN_VALUE(rhs_type));
111398 +
111399 + cast_rhs_type = TREE_TYPE(cast_rhs);
111400 + type_max_type = TREE_TYPE(type_max);
111401 + type_min_type = TREE_TYPE(type_min);
111402 + gcc_assert(types_compatible_p(cast_rhs_type, type_max_type));
111403 + gcc_assert(types_compatible_p(type_max_type, type_min_type));
111404 +
111405 + insert_check_size_overflow(caller_node, stmt, GT_EXPR, cast_rhs, type_max, before, MAX_CHECK);
111406 + insert_check_size_overflow(caller_node, stmt, LT_EXPR, cast_rhs, type_min, before, MIN_CHECK);
111407 +}
111408 +
111409 +static bool is_a_constant_overflow(const_gimple stmt, const_tree rhs)
111410 +{
111411 + if (gimple_assign_rhs_code(stmt) == MIN_EXPR)
111412 + return false;
111413 + if (!is_gimple_constant(rhs))
111414 + return false;
111415 + return true;
111416 +}
111417 +
111418 +static tree get_def_stmt_rhs(const_tree var)
111419 +{
111420 + tree rhs1, def_stmt_rhs1;
111421 + gimple rhs1_def_stmt, def_stmt_rhs1_def_stmt, def_stmt;
111422 +
111423 + def_stmt = get_def_stmt(var);
111424 + if (!gimple_assign_cast_p(def_stmt))
111425 + return NULL_TREE;
111426 + gcc_assert(gimple_code(def_stmt) != GIMPLE_NOP && gimple_plf(def_stmt, MY_STMT) && gimple_assign_cast_p(def_stmt));
111427 +
111428 + rhs1 = gimple_assign_rhs1(def_stmt);
111429 + rhs1_def_stmt = get_def_stmt(rhs1);
111430 + if (!gimple_assign_cast_p(rhs1_def_stmt))
111431 + return rhs1;
111432 +
111433 + def_stmt_rhs1 = gimple_assign_rhs1(rhs1_def_stmt);
111434 + def_stmt_rhs1_def_stmt = get_def_stmt(def_stmt_rhs1);
111435 +
111436 + switch (gimple_code(def_stmt_rhs1_def_stmt)) {
111437 + case GIMPLE_CALL:
111438 + case GIMPLE_NOP:
111439 + case GIMPLE_ASM:
111440 + case GIMPLE_PHI:
111441 + return def_stmt_rhs1;
111442 + case GIMPLE_ASSIGN:
111443 + return rhs1;
111444 + default:
111445 + debug_gimple_stmt(def_stmt_rhs1_def_stmt);
111446 + gcc_unreachable();
111447 + }
111448 +}
111449 +
111450 +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)
111451 +{
111452 + tree new_rhs, orig_rhs;
111453 + void (*gimple_assign_set_rhs)(gimple, tree);
111454 + tree rhs1 = gimple_assign_rhs1(stmt);
111455 + tree rhs2 = gimple_assign_rhs2(stmt);
111456 + tree lhs = gimple_assign_lhs(stmt);
111457 +
111458 + if (!check_overflow)
111459 + return create_assign(visited, stmt, lhs, AFTER_STMT);
111460 +
111461 + if (change_rhs == NULL_TREE)
111462 + return create_assign(visited, stmt, lhs, AFTER_STMT);
111463 +
111464 + if (new_rhs2 == NULL_TREE) {
111465 + orig_rhs = rhs1;
111466 + gimple_assign_set_rhs = &gimple_assign_set_rhs1;
111467 + } else {
111468 + orig_rhs = rhs2;
111469 + gimple_assign_set_rhs = &gimple_assign_set_rhs2;
111470 + }
111471 +
111472 + check_size_overflow(caller_node, stmt, TREE_TYPE(change_rhs), change_rhs, orig_rhs, BEFORE_STMT);
111473 +
111474 + new_rhs = change_assign_rhs(stmt, orig_rhs, change_rhs);
111475 + gimple_assign_set_rhs(stmt, new_rhs);
111476 + update_stmt(stmt);
111477 +
111478 + return create_assign(visited, stmt, lhs, AFTER_STMT);
111479 +}
111480 +
111481 +static bool is_subtraction_special(const_gimple stmt)
111482 +{
111483 + gimple rhs1_def_stmt, rhs2_def_stmt;
111484 + const_tree rhs1_def_stmt_rhs1, rhs2_def_stmt_rhs1, rhs1_def_stmt_lhs, rhs2_def_stmt_lhs;
111485 + enum machine_mode rhs1_def_stmt_rhs1_mode, rhs2_def_stmt_rhs1_mode, rhs1_def_stmt_lhs_mode, rhs2_def_stmt_lhs_mode;
111486 + const_tree rhs1 = gimple_assign_rhs1(stmt);
111487 + const_tree rhs2 = gimple_assign_rhs2(stmt);
111488 +
111489 + if (is_gimple_constant(rhs1) || is_gimple_constant(rhs2))
111490 + return false;
111491 +
111492 + gcc_assert(TREE_CODE(rhs1) == SSA_NAME && TREE_CODE(rhs2) == SSA_NAME);
111493 +
111494 + if (gimple_assign_rhs_code(stmt) != MINUS_EXPR)
111495 + return false;
111496 +
111497 + rhs1_def_stmt = get_def_stmt(rhs1);
111498 + rhs2_def_stmt = get_def_stmt(rhs2);
111499 + if (!gimple_assign_cast_p(rhs1_def_stmt) || !gimple_assign_cast_p(rhs2_def_stmt))
111500 + return false;
111501 +
111502 + rhs1_def_stmt_rhs1 = gimple_assign_rhs1(rhs1_def_stmt);
111503 + rhs2_def_stmt_rhs1 = gimple_assign_rhs1(rhs2_def_stmt);
111504 + rhs1_def_stmt_lhs = gimple_assign_lhs(rhs1_def_stmt);
111505 + rhs2_def_stmt_lhs = gimple_assign_lhs(rhs2_def_stmt);
111506 + rhs1_def_stmt_rhs1_mode = TYPE_MODE(TREE_TYPE(rhs1_def_stmt_rhs1));
111507 + rhs2_def_stmt_rhs1_mode = TYPE_MODE(TREE_TYPE(rhs2_def_stmt_rhs1));
111508 + rhs1_def_stmt_lhs_mode = TYPE_MODE(TREE_TYPE(rhs1_def_stmt_lhs));
111509 + rhs2_def_stmt_lhs_mode = TYPE_MODE(TREE_TYPE(rhs2_def_stmt_lhs));
111510 + if (GET_MODE_BITSIZE(rhs1_def_stmt_rhs1_mode) <= GET_MODE_BITSIZE(rhs1_def_stmt_lhs_mode))
111511 + return false;
111512 + if (GET_MODE_BITSIZE(rhs2_def_stmt_rhs1_mode) <= GET_MODE_BITSIZE(rhs2_def_stmt_lhs_mode))
111513 + return false;
111514 +
111515 + gimple_set_plf(rhs1_def_stmt, NO_CAST_CHECK, true);
111516 + gimple_set_plf(rhs2_def_stmt, NO_CAST_CHECK, true);
111517 + return true;
111518 +}
111519 +
111520 +static tree handle_integer_truncation(struct pointer_set_t *visited, struct cgraph_node *caller_node, const_tree lhs)
111521 +{
111522 + tree new_rhs1, new_rhs2;
111523 + tree new_rhs1_def_stmt_rhs1, new_rhs2_def_stmt_rhs1, new_lhs;
111524 + gimple assign, stmt = get_def_stmt(lhs);
111525 + tree rhs1 = gimple_assign_rhs1(stmt);
111526 + tree rhs2 = gimple_assign_rhs2(stmt);
111527 +
111528 + if (!is_subtraction_special(stmt))
111529 + return NULL_TREE;
111530 +
111531 + new_rhs1 = expand(visited, caller_node, rhs1);
111532 + new_rhs2 = expand(visited, caller_node, rhs2);
111533 +
111534 + new_rhs1_def_stmt_rhs1 = get_def_stmt_rhs(new_rhs1);
111535 + new_rhs2_def_stmt_rhs1 = get_def_stmt_rhs(new_rhs2);
111536 +
111537 + if (new_rhs1_def_stmt_rhs1 == NULL_TREE || new_rhs2_def_stmt_rhs1 == NULL_TREE)
111538 + return NULL_TREE;
111539 +
111540 + if (!types_compatible_p(TREE_TYPE(new_rhs1_def_stmt_rhs1), TREE_TYPE(new_rhs2_def_stmt_rhs1))) {
111541 + new_rhs1_def_stmt_rhs1 = cast_to_TI_type(stmt, new_rhs1_def_stmt_rhs1);
111542 + new_rhs2_def_stmt_rhs1 = cast_to_TI_type(stmt, new_rhs2_def_stmt_rhs1);
111543 + }
111544 +
111545 + assign = create_binary_assign(MINUS_EXPR, stmt, new_rhs1_def_stmt_rhs1, new_rhs2_def_stmt_rhs1);
111546 + new_lhs = gimple_assign_lhs(assign);
111547 + check_size_overflow(caller_node, assign, TREE_TYPE(new_lhs), new_lhs, rhs1, AFTER_STMT);
111548 +
111549 + return dup_assign(visited, stmt, lhs, new_rhs1, new_rhs2, NULL_TREE);
111550 +}
111551 +
111552 +static bool is_a_neg_overflow(const_gimple stmt, const_tree rhs)
111553 +{
111554 + const_gimple def_stmt;
111555 +
111556 + if (TREE_CODE(rhs) != SSA_NAME)
111557 + return false;
111558 +
111559 + if (gimple_assign_rhs_code(stmt) != PLUS_EXPR)
111560 + return false;
111561 +
111562 + def_stmt = get_def_stmt(rhs);
111563 + if (!is_gimple_assign(def_stmt) || gimple_assign_rhs_code(def_stmt) != BIT_NOT_EXPR)
111564 + return false;
111565 +
111566 + return true;
111567 +}
111568 +
111569 +static tree handle_binary_ops(struct pointer_set_t *visited, struct cgraph_node *caller_node, tree lhs)
111570 +{
111571 + tree rhs1, rhs2, new_lhs;
111572 + gimple def_stmt = get_def_stmt(lhs);
111573 + tree new_rhs1 = NULL_TREE;
111574 + tree new_rhs2 = NULL_TREE;
111575 +
111576 + rhs1 = gimple_assign_rhs1(def_stmt);
111577 + rhs2 = gimple_assign_rhs2(def_stmt);
111578 +
111579 + /* no DImode/TImode division in the 32/64 bit kernel */
111580 + switch (gimple_assign_rhs_code(def_stmt)) {
111581 + case RDIV_EXPR:
111582 + case TRUNC_DIV_EXPR:
111583 + case CEIL_DIV_EXPR:
111584 + case FLOOR_DIV_EXPR:
111585 + case ROUND_DIV_EXPR:
111586 + case TRUNC_MOD_EXPR:
111587 + case CEIL_MOD_EXPR:
111588 + case FLOOR_MOD_EXPR:
111589 + case ROUND_MOD_EXPR:
111590 + case EXACT_DIV_EXPR:
111591 + case POINTER_PLUS_EXPR:
111592 + case BIT_AND_EXPR:
111593 + return create_assign(visited, def_stmt, lhs, AFTER_STMT);
111594 + default:
111595 + break;
111596 + }
111597 +
111598 + new_lhs = handle_integer_truncation(visited, caller_node, lhs);
111599 + if (new_lhs != NULL_TREE)
111600 + return new_lhs;
111601 +
111602 + if (TREE_CODE(rhs1) == SSA_NAME)
111603 + new_rhs1 = expand(visited, caller_node, rhs1);
111604 + if (TREE_CODE(rhs2) == SSA_NAME)
111605 + new_rhs2 = expand(visited, caller_node, rhs2);
111606 +
111607 + if (is_a_neg_overflow(def_stmt, rhs2))
111608 + return handle_intentional_overflow(visited, caller_node, true, def_stmt, new_rhs1, NULL_TREE);
111609 + if (is_a_neg_overflow(def_stmt, rhs1))
111610 + return handle_intentional_overflow(visited, caller_node, true, def_stmt, new_rhs2, new_rhs2);
111611 +
111612 +
111613 + if (is_a_constant_overflow(def_stmt, rhs2))
111614 + return handle_intentional_overflow(visited, caller_node, !is_a_cast_and_const_overflow(rhs1), def_stmt, new_rhs1, NULL_TREE);
111615 + if (is_a_constant_overflow(def_stmt, rhs1))
111616 + return handle_intentional_overflow(visited, caller_node, !is_a_cast_and_const_overflow(rhs2), def_stmt, new_rhs2, new_rhs2);
111617 +
111618 + return dup_assign(visited, def_stmt, lhs, new_rhs1, new_rhs2, NULL_TREE);
111619 +}
111620 +
111621 +#if BUILDING_GCC_VERSION >= 4007
111622 +static tree get_new_rhs(struct pointer_set_t *visited, struct cgraph_node *caller_node, tree size_overflow_type, tree rhs)
111623 +{
111624 + if (is_gimple_constant(rhs))
111625 + return cast_a_tree(size_overflow_type, rhs);
111626 + if (TREE_CODE(rhs) != SSA_NAME)
111627 + return NULL_TREE;
111628 + return expand(visited, caller_node, rhs);
111629 +}
111630 +
111631 +static tree handle_ternary_ops(struct pointer_set_t *visited, struct cgraph_node *caller_node, tree lhs)
111632 +{
111633 + tree rhs1, rhs2, rhs3, new_rhs1, new_rhs2, new_rhs3, size_overflow_type;
111634 + gimple def_stmt = get_def_stmt(lhs);
111635 +
111636 + size_overflow_type = get_size_overflow_type(def_stmt, lhs);
111637 +
111638 + rhs1 = gimple_assign_rhs1(def_stmt);
111639 + rhs2 = gimple_assign_rhs2(def_stmt);
111640 + rhs3 = gimple_assign_rhs3(def_stmt);
111641 + new_rhs1 = get_new_rhs(visited, caller_node, size_overflow_type, rhs1);
111642 + new_rhs2 = get_new_rhs(visited, caller_node, size_overflow_type, rhs2);
111643 + new_rhs3 = get_new_rhs(visited, caller_node, size_overflow_type, rhs3);
111644 +
111645 + return dup_assign(visited, def_stmt, lhs, new_rhs1, new_rhs2, new_rhs3);
111646 +}
111647 +#endif
111648 +
111649 +static tree get_size_overflow_type(gimple stmt, const_tree node)
111650 +{
111651 + const_tree type;
111652 + tree new_type;
111653 +
111654 + gcc_assert(node != NULL_TREE);
111655 +
111656 + type = TREE_TYPE(node);
111657 +
111658 + if (gimple_plf(stmt, MY_STMT))
111659 + return TREE_TYPE(node);
111660 +
111661 + switch (TYPE_MODE(type)) {
111662 + case QImode:
111663 + new_type = intHI_type_node;
111664 + break;
111665 + case HImode:
111666 + new_type = intSI_type_node;
111667 + break;
111668 + case SImode:
111669 + new_type = intDI_type_node;
111670 + break;
111671 + case DImode:
111672 + if (LONG_TYPE_SIZE == GET_MODE_BITSIZE(SImode))
111673 + new_type = intDI_type_node;
111674 + else
111675 + new_type = intTI_type_node;
111676 + break;
111677 + case TImode:
111678 + gcc_assert(!TYPE_UNSIGNED(type));
111679 + new_type = intTI_type_node;
111680 + break;
111681 + default:
111682 + debug_tree((tree)node);
111683 + error("%s: unsupported gcc configuration (%qE).", __func__, current_function_decl);
111684 + gcc_unreachable();
111685 + }
111686 +
111687 + if (TYPE_QUALS(type) != 0)
111688 + return build_qualified_type(new_type, TYPE_QUALS(type));
111689 + return new_type;
111690 +}
111691 +
111692 +static tree expand_visited(gimple def_stmt)
111693 +{
111694 + const_gimple next_stmt;
111695 + gimple_stmt_iterator gsi;
111696 + enum gimple_code code = gimple_code(def_stmt);
111697 +
111698 + if (code == GIMPLE_ASM)
111699 + return NULL_TREE;
111700 +
111701 + gsi = gsi_for_stmt(def_stmt);
111702 + gsi_next(&gsi);
111703 +
111704 + if (gimple_code(def_stmt) == GIMPLE_PHI && gsi_end_p(gsi))
111705 + return NULL_TREE;
111706 + gcc_assert(!gsi_end_p(gsi));
111707 + next_stmt = gsi_stmt(gsi);
111708 +
111709 + if (gimple_code(def_stmt) == GIMPLE_PHI && !gimple_plf((gimple)next_stmt, MY_STMT))
111710 + return NULL_TREE;
111711 + gcc_assert(gimple_plf((gimple)next_stmt, MY_STMT));
111712 +
111713 + return get_lhs(next_stmt);
111714 +}
111715 +
111716 +static tree expand(struct pointer_set_t *visited, struct cgraph_node *caller_node, tree lhs)
111717 +{
111718 + gimple def_stmt;
111719 +
111720 + def_stmt = get_def_stmt(lhs);
111721 +
111722 + if (!def_stmt || gimple_code(def_stmt) == GIMPLE_NOP)
111723 + return NULL_TREE;
111724 +
111725 + if (gimple_plf(def_stmt, MY_STMT))
111726 + return lhs;
111727 +
111728 + if (pointer_set_contains(visited, def_stmt))
111729 + return expand_visited(def_stmt);
111730 +
111731 + switch (gimple_code(def_stmt)) {
111732 + case GIMPLE_PHI:
111733 + return handle_phi(visited, caller_node, lhs);
111734 + case GIMPLE_CALL:
111735 + case GIMPLE_ASM:
111736 + return create_assign(visited, def_stmt, lhs, AFTER_STMT);
111737 + case GIMPLE_ASSIGN:
111738 + switch (gimple_num_ops(def_stmt)) {
111739 + case 2:
111740 + return handle_unary_ops(visited, caller_node, def_stmt);
111741 + case 3:
111742 + return handle_binary_ops(visited, caller_node, lhs);
111743 +#if BUILDING_GCC_VERSION >= 4007
111744 + case 4:
111745 + return handle_ternary_ops(visited, caller_node, lhs);
111746 +#endif
111747 + }
111748 + default:
111749 + debug_gimple_stmt(def_stmt);
111750 + error("%s: unknown gimple code", __func__);
111751 + gcc_unreachable();
111752 + }
111753 +}
111754 +
111755 +static tree cast_to_orig_type(gimple stmt, const_tree orig_node, tree new_node)
111756 +{
111757 + const_gimple assign;
111758 + tree orig_type = TREE_TYPE(orig_node);
111759 + gimple_stmt_iterator gsi = gsi_for_stmt(stmt);
111760 +
111761 + assign = build_cast_stmt(orig_type, new_node, CREATE_NEW_VAR, &gsi, BEFORE_STMT, false);
111762 + return gimple_assign_lhs(assign);
111763 +}
111764 +
111765 +static void change_orig_node(struct interesting_node *cur_node, tree new_node)
111766 +{
111767 + void (*set_rhs)(gimple, tree);
111768 + gimple stmt = cur_node->first_stmt;
111769 + const_tree orig_node = cur_node->node;
111770 +
111771 + switch (gimple_code(stmt)) {
111772 + case GIMPLE_RETURN:
111773 + gimple_return_set_retval(stmt, cast_to_orig_type(stmt, orig_node, new_node));
111774 + break;
111775 + case GIMPLE_CALL:
111776 + gimple_call_set_arg(stmt, cur_node->num - 1, cast_to_orig_type(stmt, orig_node, new_node));
111777 + break;
111778 + case GIMPLE_ASSIGN:
111779 + switch (cur_node->num) {
111780 + case 1:
111781 + set_rhs = &gimple_assign_set_rhs1;
111782 + break;
111783 + case 2:
111784 + set_rhs = &gimple_assign_set_rhs2;
111785 + break;
111786 +#if BUILDING_GCC_VERSION > 4005
111787 + case 3:
111788 + set_rhs = &gimple_assign_set_rhs3;
111789 + break;
111790 +#endif
111791 + default:
111792 + gcc_unreachable();
111793 + }
111794 +
111795 + set_rhs(stmt, cast_to_orig_type(stmt, orig_node, new_node));
111796 + break;
111797 + default:
111798 + debug_gimple_stmt(stmt);
111799 + gcc_unreachable();
111800 + }
111801 +
111802 + update_stmt(stmt);
111803 +}
111804 +
111805 +static unsigned int get_correct_arg_count(unsigned int argnum, tree fndecl)
111806 +{
111807 + const struct size_overflow_hash *hash;
111808 + unsigned int new_argnum;
111809 + tree arg;
111810 + const_tree origarg;
111811 +
111812 + if (argnum == 0)
111813 + return argnum;
111814 +
111815 + hash = get_function_hash(fndecl);
111816 + if (hash && hash->param & (1U << argnum))
111817 + return argnum;
111818 +
111819 + if (DECL_EXTERNAL(fndecl))
111820 + return argnum;
111821 +
111822 + origarg = DECL_ARGUMENTS(DECL_ORIGIN(fndecl));
111823 + argnum--;
111824 + while (origarg && argnum) {
111825 + origarg = TREE_CHAIN(origarg);
111826 + argnum--;
111827 + }
111828 + gcc_assert(argnum == 0);
111829 + gcc_assert(origarg != NULL_TREE);
111830 +
111831 + for (arg = DECL_ARGUMENTS(fndecl), new_argnum = 1; arg; arg = TREE_CHAIN(arg), new_argnum++)
111832 + if (operand_equal_p(origarg, arg, 0) || !strcmp(NAME(origarg), NAME(arg)))
111833 + return new_argnum;
111834 +
111835 + return CANNOT_FIND_ARG;
111836 +}
111837 +
111838 +// Don't want to duplicate entries in next_cgraph_node
111839 +static bool is_in_next_cgraph_node(struct next_cgraph_node *head, struct cgraph_node *node, const_tree fndecl, unsigned int num)
111840 +{
111841 + const_tree new_callee_fndecl;
111842 + struct next_cgraph_node *cur_node;
111843 +
111844 + if (fndecl == RET_CHECK)
111845 +#if BUILDING_GCC_VERSION <= 4007
111846 + new_callee_fndecl = node->decl;
111847 +#else
111848 + new_callee_fndecl = node->symbol.decl;
111849 +#endif
111850 + else
111851 + new_callee_fndecl = fndecl;
111852 +
111853 + for (cur_node = head; cur_node; cur_node = cur_node->next) {
111854 +#if BUILDING_GCC_VERSION <= 4007
111855 + if (!operand_equal_p(cur_node->current_function->decl, node->decl, 0))
111856 +#else
111857 + if (!operand_equal_p(cur_node->current_function->symbol.decl, node->symbol.decl, 0))
111858 +#endif
111859 + continue;
111860 + if (!operand_equal_p(cur_node->callee_fndecl, new_callee_fndecl, 0))
111861 + continue;
111862 + if (num == cur_node->num)
111863 + return true;
111864 + }
111865 + return false;
111866 +}
111867 +
111868 +/* Add a next_cgraph_node into the list for handle_function().
111869 + * handle_function() iterates over all the next cgraph nodes and
111870 + * starts the overflow check insertion process.
111871 + */
111872 +static struct next_cgraph_node *create_new_next_cgraph_node(struct next_cgraph_node *head, struct cgraph_node *node, tree fndecl, unsigned int num)
111873 +{
111874 + struct next_cgraph_node *new_node;
111875 +
111876 + if (is_in_next_cgraph_node(head, node, fndecl, num))
111877 + return head;
111878 +
111879 + new_node = (struct next_cgraph_node *)xmalloc(sizeof(*new_node));
111880 + new_node->current_function = node;
111881 + new_node->next = NULL;
111882 + new_node->num = num;
111883 + if (fndecl == RET_CHECK)
111884 +#if BUILDING_GCC_VERSION <= 4007
111885 + new_node->callee_fndecl = node->decl;
111886 +#else
111887 + new_node->callee_fndecl = node->symbol.decl;
111888 +#endif
111889 + else
111890 + new_node->callee_fndecl = fndecl;
111891 +
111892 + if (!head)
111893 + return new_node;
111894 +
111895 + new_node->next = head;
111896 + return new_node;
111897 +}
111898 +
111899 +static struct next_cgraph_node *create_new_next_cgraph_nodes(struct next_cgraph_node *head, struct cgraph_node *node, unsigned int num)
111900 +{
111901 + struct cgraph_edge *e;
111902 +
111903 + if (num == 0)
111904 + return create_new_next_cgraph_node(head, node, RET_CHECK, num);
111905 +
111906 + for (e = node->callers; e; e = e->next_caller) {
111907 + tree fndecl = gimple_call_fndecl(e->call_stmt);
111908 +
111909 + gcc_assert(fndecl != NULL_TREE);
111910 + head = create_new_next_cgraph_node(head, e->caller, fndecl, num);
111911 + }
111912 +
111913 + return head;
111914 +}
111915 +
111916 +static bool is_a_return_check(const_tree node)
111917 +{
111918 + if (TREE_CODE(node) == FUNCTION_DECL)
111919 + return true;
111920 +
111921 + gcc_assert(TREE_CODE(node) == PARM_DECL);
111922 + return false;
111923 +}
111924 +
111925 +static bool is_in_hash_table(tree fndecl, unsigned int num)
111926 +{
111927 + const struct size_overflow_hash *hash;
111928 +
111929 + hash = get_function_hash(fndecl);
111930 + if (hash && (hash->param & (1U << num)))
111931 + return true;
111932 + return false;
111933 +}
111934 +
111935 +struct missing_functions {
111936 + struct missing_functions *next;
111937 + const_tree node;
111938 + tree fndecl;
111939 +};
111940 +
111941 +static struct missing_functions *create_new_missing_function(struct missing_functions *missing_fn_head, tree node)
111942 +{
111943 + struct missing_functions *new_function;
111944 +
111945 + new_function = (struct missing_functions *)xmalloc(sizeof(*new_function));
111946 + new_function->node = node;
111947 + new_function->next = NULL;
111948 +
111949 + if (TREE_CODE(node) == FUNCTION_DECL)
111950 + new_function->fndecl = node;
111951 + else
111952 + new_function->fndecl = current_function_decl;
111953 + gcc_assert(new_function->fndecl);
111954 +
111955 + if (!missing_fn_head)
111956 + return new_function;
111957 +
111958 + new_function->next = missing_fn_head;
111959 + return new_function;
111960 +}
111961 +
111962 +/* Check if the function has a size_overflow attribute or it is in the size_overflow hash table.
111963 + * If the function is missing everywhere then print the missing message into stderr.
111964 + */
111965 +static bool is_missing_function(tree orig_fndecl, unsigned int num)
111966 +{
111967 + switch (DECL_FUNCTION_CODE(orig_fndecl)) {
111968 +#if BUILDING_GCC_VERSION >= 4008
111969 + case BUILT_IN_BSWAP16:
111970 +#endif
111971 + case BUILT_IN_BSWAP32:
111972 + case BUILT_IN_BSWAP64:
111973 + case BUILT_IN_EXPECT:
111974 + case BUILT_IN_MEMCMP:
111975 + return false;
111976 + default:
111977 + break;
111978 + }
111979 +
111980 + // skip test.c
111981 + if (strcmp(NAME(current_function_decl), "coolmalloc")) {
111982 + if (lookup_attribute("size_overflow", DECL_ATTRIBUTES(orig_fndecl)))
111983 + warning(0, "unnecessary size_overflow attribute on: %s\n", NAME(orig_fndecl));
111984 + }
111985 +
111986 + if (is_in_hash_table(orig_fndecl, num))
111987 + return false;
111988 +
111989 + print_missing_msg(orig_fndecl, num);
111990 + return true;
111991 +}
111992 +
111993 +// Get the argnum of a function decl, if node is a return then the argnum is 0
111994 +static unsigned int get_function_num(const_tree node, const_tree orig_fndecl)
111995 +{
111996 + if (is_a_return_check(node))
111997 + return 0;
111998 + else
111999 + return find_arg_number_tree(node, orig_fndecl);
112000 +}
112001 +
112002 +/* If the function is missing from the hash table and it is a static function
112003 + * then create a next_cgraph_node from it for handle_function()
112004 + */
112005 +static struct next_cgraph_node *check_missing_overflow_attribute_and_create_next_node(struct next_cgraph_node *cnodes, struct missing_functions *missing_fn_head)
112006 +{
112007 + unsigned int num;
112008 + tree orig_fndecl;
112009 + struct cgraph_node *next_node = NULL;
112010 +
112011 + orig_fndecl = DECL_ORIGIN(missing_fn_head->fndecl);
112012 +
112013 + num = get_function_num(missing_fn_head->node, orig_fndecl);
112014 + if (num == CANNOT_FIND_ARG)
112015 + return cnodes;
112016 +
112017 + if (!is_missing_function(orig_fndecl, num))
112018 + return cnodes;
112019 +
112020 + next_node = cgraph_get_node(missing_fn_head->fndecl);
112021 + if (next_node && next_node->local.local)
112022 + cnodes = create_new_next_cgraph_nodes(cnodes, next_node, num);
112023 + return cnodes;
112024 +}
112025 +
112026 +/* Search for missing size_overflow attributes on the last nodes in ipa and collect them
112027 + * into the next_cgraph_node list. They will be the next interesting returns or callees.
112028 + */
112029 +static struct next_cgraph_node *search_overflow_attribute(struct next_cgraph_node *cnodes, struct interesting_node *cur_node)
112030 +{
112031 + unsigned int i;
112032 + tree node;
112033 + struct missing_functions *cur, *missing_fn_head = NULL;
112034 +
112035 +#if BUILDING_GCC_VERSION == 4005
112036 + for (i = 0; i < VEC_length(tree, cur_node->last_nodes); i++) {
112037 + node = VEC_index(tree, cur_node->last_nodes, i);
112038 +#elif BUILDING_GCC_VERSION <= 4007
112039 + FOR_EACH_VEC_ELT(tree, cur_node->last_nodes, i, node) {
112040 +#else
112041 + FOR_EACH_VEC_ELT(*cur_node->last_nodes, i, node) {
112042 +#endif
112043 + switch (TREE_CODE(node)) {
112044 + case PARM_DECL:
112045 + if (TREE_CODE(TREE_TYPE(node)) != INTEGER_TYPE)
112046 + break;
112047 + case FUNCTION_DECL:
112048 + missing_fn_head = create_new_missing_function(missing_fn_head, node);
112049 + break;
112050 + default:
112051 + break;
112052 + }
112053 + }
112054 +
112055 + while (missing_fn_head) {
112056 + cnodes = check_missing_overflow_attribute_and_create_next_node(cnodes, missing_fn_head);
112057 +
112058 + cur = missing_fn_head->next;
112059 + free(missing_fn_head);
112060 + missing_fn_head = cur;
112061 + }
112062 +
112063 + return cnodes;
112064 +}
112065 +
112066 +static void walk_phi_set_conditions(struct pointer_set_t *visited, bool *interesting_conditions, const_tree result)
112067 +{
112068 + gimple phi = get_def_stmt(result);
112069 + unsigned int i, n = gimple_phi_num_args(phi);
112070 +
112071 + pointer_set_insert(visited, phi);
112072 + for (i = 0; i < n; i++) {
112073 + const_tree arg = gimple_phi_arg_def(phi, i);
112074 +
112075 + set_conditions(visited, interesting_conditions, arg);
112076 + }
112077 +}
112078 +
112079 +enum conditions {
112080 + FROM_CONST, NOT_UNARY, CAST
112081 +};
112082 +
112083 +// Search for constants, cast assignments and binary/ternary assignments
112084 +static void set_conditions(struct pointer_set_t *visited, bool *interesting_conditions, const_tree lhs)
112085 +{
112086 + gimple def_stmt = get_def_stmt(lhs);
112087 +
112088 + if (is_gimple_constant(lhs)) {
112089 + interesting_conditions[FROM_CONST] = true;
112090 + return;
112091 + }
112092 +
112093 + if (!def_stmt)
112094 + return;
112095 +
112096 + if (pointer_set_contains(visited, def_stmt))
112097 + return;
112098 +
112099 + switch (gimple_code(def_stmt)) {
112100 + case GIMPLE_NOP:
112101 + case GIMPLE_CALL:
112102 + case GIMPLE_ASM:
112103 + return;
112104 + case GIMPLE_PHI:
112105 + return walk_phi_set_conditions(visited, interesting_conditions, lhs);
112106 + case GIMPLE_ASSIGN:
112107 + if (gimple_num_ops(def_stmt) == 2) {
112108 + const_tree rhs = gimple_assign_rhs1(def_stmt);
112109 +
112110 + if (gimple_assign_cast_p(def_stmt))
112111 + interesting_conditions[CAST] = true;
112112 +
112113 + return set_conditions(visited, interesting_conditions, rhs);
112114 + } else {
112115 + interesting_conditions[NOT_UNARY] = true;
112116 + return;
112117 + }
112118 + default:
112119 + debug_gimple_stmt(def_stmt);
112120 + gcc_unreachable();
112121 + }
112122 +}
112123 +
112124 +// determine whether duplication will be necessary or not.
112125 +static void search_interesting_conditions(struct interesting_node *cur_node, bool *interesting_conditions)
112126 +{
112127 + struct pointer_set_t *visited;
112128 +
112129 + if (gimple_assign_cast_p(cur_node->first_stmt))
112130 + interesting_conditions[CAST] = true;
112131 + else if (is_gimple_assign(cur_node->first_stmt) && gimple_num_ops(cur_node->first_stmt) > 2)
112132 + interesting_conditions[NOT_UNARY] = true;
112133 +
112134 + visited = pointer_set_create();
112135 + set_conditions(visited, interesting_conditions, cur_node->node);
112136 + pointer_set_destroy(visited);
112137 +}
112138 +
112139 +// Remove the size_overflow asm stmt and create an assignment from the input and output of the asm
112140 +static void replace_size_overflow_asm_with_assign(gimple asm_stmt, tree lhs, tree rhs)
112141 +{
112142 + gimple assign;
112143 + gimple_stmt_iterator gsi;
112144 +
112145 + // already removed
112146 + if (gimple_bb(asm_stmt) == NULL)
112147 + return;
112148 + gsi = gsi_for_stmt(asm_stmt);
112149 +
112150 + assign = gimple_build_assign(lhs, rhs);
112151 + gsi_insert_before(&gsi, assign, GSI_SAME_STMT);
112152 + SSA_NAME_DEF_STMT(lhs) = assign;
112153 +
112154 + gsi_remove(&gsi, true);
112155 +}
112156 +
112157 +// Get the field decl of a component ref for intentional_overflow checking
112158 +static const_tree search_field_decl(const_tree comp_ref)
112159 +{
112160 + const_tree field = NULL_TREE;
112161 + unsigned int i, len = TREE_OPERAND_LENGTH(comp_ref);
112162 +
112163 + for (i = 0; i < len; i++) {
112164 + field = TREE_OPERAND(comp_ref, i);
112165 + if (TREE_CODE(field) == FIELD_DECL)
112166 + break;
112167 + }
112168 + gcc_assert(TREE_CODE(field) == FIELD_DECL);
112169 + return field;
112170 +}
112171 +
112172 +/* Get the fndecl of an interesting stmt, the fndecl is the caller function if the interesting
112173 + * stmt is a return otherwise it is the callee function.
112174 + */
112175 +static const_tree get_interesting_orig_fndecl(const_gimple stmt, unsigned int argnum)
112176 +{
112177 + const_tree fndecl;
112178 +
112179 + if (argnum == 0)
112180 + fndecl = current_function_decl;
112181 + else
112182 + fndecl = gimple_call_fndecl(stmt);
112183 +
112184 + if (fndecl == NULL_TREE)
112185 + return NULL_TREE;
112186 +
112187 + return DECL_ORIGIN(fndecl);
112188 +}
112189 +
112190 +/* Get the param of the intentional_overflow attribute.
112191 + * * 0: MARK_NOT_INTENTIONAL
112192 + * * 1..MAX_PARAM: MARK_YES
112193 + * * -1: MARK_TURN_OFF
112194 + */
112195 +static tree get_attribute_param(const_tree decl)
112196 +{
112197 + const_tree attr;
112198 +
112199 + if (decl == NULL_TREE)
112200 + return NULL_TREE;
112201 +
112202 + attr = lookup_attribute("intentional_overflow", DECL_ATTRIBUTES(decl));
112203 + if (!attr || !TREE_VALUE(attr))
112204 + return NULL_TREE;
112205 +
112206 + return TREE_VALUE(attr);
112207 +}
112208 +
112209 +// MARK_TURN_OFF
112210 +static bool is_turn_off_intentional_attr(const_tree decl)
112211 +{
112212 + const_tree param_head;
112213 +
112214 + param_head = get_attribute_param(decl);
112215 + if (param_head == NULL_TREE)
112216 + return false;
112217 +
112218 + if (TREE_INT_CST_HIGH(TREE_VALUE(param_head)) == -1)
112219 + return true;
112220 + return false;
112221 +}
112222 +
112223 +// MARK_NOT_INTENTIONAL
112224 +static bool is_end_intentional_intentional_attr(const_tree decl, unsigned int argnum)
112225 +{
112226 + const_tree param_head;
112227 +
112228 + if (argnum == 0)
112229 + return false;
112230 +
112231 + param_head = get_attribute_param(decl);
112232 + if (param_head == NULL_TREE)
112233 + return false;
112234 +
112235 + if (!TREE_INT_CST_LOW(TREE_VALUE(param_head)))
112236 + return true;
112237 + return false;
112238 +}
112239 +
112240 +// MARK_YES
112241 +static bool is_yes_intentional_attr(const_tree decl, unsigned int argnum)
112242 +{
112243 + tree param, param_head;
112244 +
112245 + if (argnum == 0)
112246 + return false;
112247 +
112248 + param_head = get_attribute_param(decl);
112249 + for (param = param_head; param; param = TREE_CHAIN(param))
112250 + if (argnum == TREE_INT_CST_LOW(TREE_VALUE(param)))
112251 + return true;
112252 + return false;
112253 +}
112254 +
112255 +static bool is_size_overflow_intentional_asm_turn_off(const_gimple stmt)
112256 +{
112257 + const char *str;
112258 +
112259 + if (!stmt)
112260 + return false;
112261 +
112262 + str = gimple_asm_string(stmt);
112263 + return !strcmp(str, "# size_overflow MARK_TURN_OFF\n\t");
112264 +}
112265 +
112266 +static bool is_size_overflow_intentional_asm_yes(const_gimple stmt)
112267 +{
112268 + const char *str;
112269 +
112270 + if (!stmt)
112271 + return false;
112272 +
112273 + str = gimple_asm_string(stmt);
112274 + return !strcmp(str, "# size_overflow MARK_YES\n\t");
112275 +}
112276 +
112277 +static bool is_size_overflow_asm(const_gimple stmt)
112278 +{
112279 + const char *str;
112280 +
112281 + if (!stmt)
112282 + return false;
112283 +
112284 + str = gimple_asm_string(stmt);
112285 + return !strncmp(str, "# size_overflow", 15);
112286 +}
112287 +
112288 +static void print_missing_intentional(enum mark callee_attr, enum mark caller_attr, const_tree decl, unsigned int argnum)
112289 +{
112290 + location_t loc;
112291 +
112292 + if (caller_attr == MARK_NO || caller_attr == MARK_NOT_INTENTIONAL || caller_attr == MARK_TURN_OFF)
112293 + return;
112294 +
112295 + if (callee_attr == MARK_NOT_INTENTIONAL || callee_attr == MARK_YES)
112296 + return;
112297 +
112298 + loc = DECL_SOURCE_LOCATION(decl);
112299 + inform(loc, "The intentional_overflow attribute is missing from +%s+%u+", NAME(decl), argnum);
112300 +}
112301 +
112302 +/* Get the type of the intentional_overflow attribute of a node
112303 + * * MARK_TURN_OFF
112304 + * * MARK_YES
112305 + * * MARK_NO
112306 + * * MARK_NOT_INTENTIONAL
112307 + */
112308 +static enum mark get_intentional_attr_type(const_tree node)
112309 +{
112310 + const_tree cur_decl;
112311 +
112312 + if (node == NULL_TREE)
112313 + return MARK_NO;
112314 +
112315 + switch (TREE_CODE(node)) {
112316 + case COMPONENT_REF:
112317 + cur_decl = search_field_decl(node);
112318 + if (is_turn_off_intentional_attr(cur_decl))
112319 + return MARK_TURN_OFF;
112320 + if (is_end_intentional_intentional_attr(cur_decl, 1))
112321 + return MARK_YES;
112322 + break;
112323 + case PARM_DECL: {
112324 + unsigned int argnum;
112325 +
112326 + cur_decl = DECL_ORIGIN(current_function_decl);
112327 + argnum = find_arg_number_tree(node, cur_decl);
112328 + if (argnum == CANNOT_FIND_ARG)
112329 + return MARK_NO;
112330 + if (is_yes_intentional_attr(cur_decl, argnum))
112331 + return MARK_YES;
112332 + if (is_end_intentional_intentional_attr(cur_decl, argnum))
112333 + return MARK_NOT_INTENTIONAL;
112334 + break;
112335 + }
112336 + case FUNCTION_DECL:
112337 + if (is_turn_off_intentional_attr(DECL_ORIGIN(node)))
112338 + return MARK_TURN_OFF;
112339 + break;
112340 + default:
112341 + break;
112342 + }
112343 + return MARK_NO;
112344 +}
112345 +
112346 +// Search for the intentional_overflow attribute on the last nodes
112347 +static enum mark search_last_nodes_intentional(struct interesting_node *cur_node)
112348 +{
112349 + unsigned int i;
112350 + tree last_node;
112351 + enum mark mark = MARK_NO;
112352 +
112353 +#if BUILDING_GCC_VERSION == 4005
112354 + for (i = 0; i < VEC_length(tree, cur_node->last_nodes); i++) {
112355 + last_node = VEC_index(tree, cur_node->last_nodes, i);
112356 +#elif BUILDING_GCC_VERSION <= 4007
112357 + FOR_EACH_VEC_ELT(tree, cur_node->last_nodes, i, last_node) {
112358 +#else
112359 + FOR_EACH_VEC_ELT(*cur_node->last_nodes, i, last_node) {
112360 +#endif
112361 + mark = get_intentional_attr_type(last_node);
112362 + if (mark != MARK_NO)
112363 + break;
112364 + }
112365 + return mark;
112366 +}
112367 +
112368 +/* Check the intentional kind of size_overflow asm stmt (created by the gimple pass) and
112369 + * set the appropriate intentional_overflow type. Delete the asm stmt in the end.
112370 + */
112371 +static bool is_intentional_attribute_from_gimple(struct interesting_node *cur_node)
112372 +{
112373 + const_tree input, output;
112374 +
112375 + if (!cur_node->intentional_mark_from_gimple)
112376 + return false;
112377 +
112378 + if (is_size_overflow_intentional_asm_yes(cur_node->intentional_mark_from_gimple))
112379 + cur_node->intentional_attr_cur_fndecl = MARK_YES;
112380 + else
112381 + cur_node->intentional_attr_cur_fndecl = MARK_TURN_OFF;
112382 +
112383 + // skip param decls
112384 + if (gimple_asm_noutputs(cur_node->intentional_mark_from_gimple) == 0)
112385 + return true;
112386 + input = gimple_asm_input_op(cur_node->intentional_mark_from_gimple, 0);
112387 + output = gimple_asm_output_op(cur_node->intentional_mark_from_gimple, 0);
112388 +
112389 + replace_size_overflow_asm_with_assign(cur_node->intentional_mark_from_gimple, TREE_VALUE(output), TREE_VALUE(input));
112390 + return true;
112391 +}
112392 +
112393 +/* Search intentional_overflow attribute on caller and on callee too.
112394 + * 0</MARK_YES: no dup, search size_overflow and intentional_overflow attributes
112395 + * 0/MARK_NOT_INTENTIONAL: no dup, search size_overflow attribute (int)
112396 + * -1/MARK_TURN_OFF: no dup, no search, current_function_decl -> no dup
112397 +*/
112398 +static void check_intentional_attribute_ipa(struct interesting_node *cur_node)
112399 +{
112400 + const_tree fndecl;
112401 +
112402 + if (is_turn_off_intentional_attr(DECL_ORIGIN(current_function_decl))) {
112403 + cur_node->intentional_attr_cur_fndecl = MARK_TURN_OFF;
112404 + return;
112405 + }
112406 +
112407 + if (gimple_code(cur_node->first_stmt) == GIMPLE_ASM) {
112408 + cur_node->intentional_attr_cur_fndecl = MARK_NOT_INTENTIONAL;
112409 + return;
112410 + }
112411 +
112412 + if (gimple_code(cur_node->first_stmt) == GIMPLE_ASSIGN)
112413 + return;
112414 +
112415 + fndecl = get_interesting_orig_fndecl(cur_node->first_stmt, cur_node->num);
112416 + if (is_turn_off_intentional_attr(fndecl)) {
112417 + cur_node->intentional_attr_decl = MARK_TURN_OFF;
112418 + return;
112419 + }
112420 +
112421 + if (is_end_intentional_intentional_attr(fndecl, cur_node->num))
112422 + cur_node->intentional_attr_decl = MARK_NOT_INTENTIONAL;
112423 + else if (is_yes_intentional_attr(fndecl, cur_node->num))
112424 + cur_node->intentional_attr_decl = MARK_YES;
112425 +
112426 + if (is_intentional_attribute_from_gimple(cur_node))
112427 + return;
112428 +
112429 + cur_node->intentional_attr_cur_fndecl = search_last_nodes_intentional(cur_node);
112430 + print_missing_intentional(cur_node->intentional_attr_decl, cur_node->intentional_attr_cur_fndecl, cur_node->fndecl, cur_node->num);
112431 +}
112432 +
112433 +// e.g., 3.8.2, 64, arch/x86/ia32/ia32_signal.c copy_siginfo_from_user32(): compat_ptr() u32 max
112434 +static bool skip_asm(const_tree arg)
112435 +{
112436 + gimple def_stmt = get_def_stmt(arg);
112437 +
112438 + if (!def_stmt || !gimple_assign_cast_p(def_stmt))
112439 + return false;
112440 +
112441 + def_stmt = get_def_stmt(gimple_assign_rhs1(def_stmt));
112442 + return def_stmt && gimple_code(def_stmt) == GIMPLE_ASM;
112443 +}
112444 +
112445 +static void walk_use_def_phi(struct pointer_set_t *visited, struct interesting_node *cur_node, tree result)
112446 +{
112447 + gimple phi = get_def_stmt(result);
112448 + unsigned int i, n = gimple_phi_num_args(phi);
112449 +
112450 + pointer_set_insert(visited, phi);
112451 + for (i = 0; i < n; i++) {
112452 + tree arg = gimple_phi_arg_def(phi, i);
112453 +
112454 + walk_use_def(visited, cur_node, arg);
112455 + }
112456 +}
112457 +
112458 +static void walk_use_def_binary(struct pointer_set_t *visited, struct interesting_node *cur_node, tree lhs)
112459 +{
112460 + gimple def_stmt = get_def_stmt(lhs);
112461 + tree rhs1, rhs2;
112462 +
112463 + rhs1 = gimple_assign_rhs1(def_stmt);
112464 + rhs2 = gimple_assign_rhs2(def_stmt);
112465 +
112466 + walk_use_def(visited, cur_node, rhs1);
112467 + walk_use_def(visited, cur_node, rhs2);
112468 +}
112469 +
112470 +static void insert_last_node(struct interesting_node *cur_node, tree node)
112471 +{
112472 + unsigned int i;
112473 + tree element;
112474 + enum tree_code code;
112475 +
112476 + gcc_assert(node != NULL_TREE);
112477 +
112478 + if (is_gimple_constant(node))
112479 + return;
112480 +
112481 + code = TREE_CODE(node);
112482 + if (code == VAR_DECL) {
112483 + node = DECL_ORIGIN(node);
112484 + code = TREE_CODE(node);
112485 + }
112486 +
112487 + if (code != PARM_DECL && code != FUNCTION_DECL && code != COMPONENT_REF)
112488 + return;
112489 +
112490 +#if BUILDING_GCC_VERSION == 4005
112491 + for (i = 0; i < VEC_length(tree, cur_node->last_nodes); i++) {
112492 + element = VEC_index(tree, cur_node->last_nodes, i);
112493 +#elif BUILDING_GCC_VERSION <= 4007
112494 + FOR_EACH_VEC_ELT(tree, cur_node->last_nodes, i, element) {
112495 +#else
112496 + FOR_EACH_VEC_ELT(*cur_node->last_nodes, i, element) {
112497 +#endif
112498 + if (operand_equal_p(node, element, 0))
112499 + return;
112500 + }
112501 +
112502 +#if BUILDING_GCC_VERSION <= 4007
112503 + gcc_assert(VEC_length(tree, cur_node->last_nodes) < VEC_LEN);
112504 + VEC_safe_push(tree, gc, cur_node->last_nodes, node);
112505 +#else
112506 + gcc_assert(cur_node->last_nodes->length() < VEC_LEN);
112507 + vec_safe_push(cur_node->last_nodes, node);
112508 +#endif
112509 +}
112510 +
112511 +// a size_overflow asm stmt in the control flow doesn't stop the recursion
112512 +static void handle_asm_stmt(struct pointer_set_t *visited, struct interesting_node *cur_node, tree lhs, const_gimple stmt)
112513 +{
112514 + const_tree asm_lhs;
112515 +
112516 + if (!is_size_overflow_asm(stmt))
112517 + return walk_use_def(visited, cur_node, SSA_NAME_VAR(lhs));
112518 +
112519 + asm_lhs = gimple_asm_input_op(stmt, 0);
112520 + walk_use_def(visited, cur_node, TREE_VALUE(asm_lhs));
112521 +}
112522 +
112523 +/* collect the parm_decls and fndecls (for checking a missing size_overflow attribute (ret or arg) or intentional_overflow)
112524 + * and component refs (for checking the intentional_overflow attribute).
112525 + */
112526 +static void walk_use_def(struct pointer_set_t *visited, struct interesting_node *cur_node, tree lhs)
112527 +{
112528 + const_gimple def_stmt;
112529 +
112530 + if (TREE_CODE(lhs) != SSA_NAME) {
112531 + insert_last_node(cur_node, lhs);
112532 + return;
112533 + }
112534 +
112535 + def_stmt = get_def_stmt(lhs);
112536 + if (!def_stmt)
112537 + return;
112538 +
112539 + if (pointer_set_insert(visited, def_stmt))
112540 + return;
112541 +
112542 + switch (gimple_code(def_stmt)) {
112543 + case GIMPLE_NOP:
112544 + return walk_use_def(visited, cur_node, SSA_NAME_VAR(lhs));
112545 + case GIMPLE_ASM:
112546 + return handle_asm_stmt(visited, cur_node, lhs, def_stmt);
112547 + case GIMPLE_CALL: {
112548 + tree fndecl = gimple_call_fndecl(def_stmt);
112549 +
112550 + if (fndecl == NULL_TREE)
112551 + return;
112552 + insert_last_node(cur_node, fndecl);
112553 + return;
112554 + }
112555 + case GIMPLE_PHI:
112556 + return walk_use_def_phi(visited, cur_node, lhs);
112557 + case GIMPLE_ASSIGN:
112558 + switch (gimple_num_ops(def_stmt)) {
112559 + case 2:
112560 + return walk_use_def(visited, cur_node, gimple_assign_rhs1(def_stmt));
112561 + case 3:
112562 + return walk_use_def_binary(visited, cur_node, lhs);
112563 + }
112564 + default:
112565 + debug_gimple_stmt((gimple)def_stmt);
112566 + error("%s: unknown gimple code", __func__);
112567 + gcc_unreachable();
112568 + }
112569 +}
112570 +
112571 +// Collect all the last nodes for checking the intentional_overflow and size_overflow attributes
112572 +static void set_last_nodes(struct interesting_node *cur_node)
112573 +{
112574 + struct pointer_set_t *visited;
112575 +
112576 + visited = pointer_set_create();
112577 + walk_use_def(visited, cur_node, cur_node->node);
112578 + pointer_set_destroy(visited);
112579 +}
112580 +
112581 +/* This function calls the main recursion function (expand) that duplicates the stmts. Before that it checks the intentional_overflow attribute and asm stmts,
112582 + * 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
112583 + * in the original stmt (first stmt) and it inserts the overflow check for the arg of the callee or for the return value.
112584 + * 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.
112585 + * There is only missing size_overflow attribute checking if the intentional_overflow attribute is the mark_no type.
112586 + * Stmt duplication is unnecessary if there are no binary/ternary assignements or if the unary assignment isn't a cast.
112587 + * 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.
112588 + */
112589 +static struct next_cgraph_node *handle_interesting_stmt(struct next_cgraph_node *cnodes, struct interesting_node *cur_node, struct cgraph_node *caller_node)
112590 +{
112591 + struct pointer_set_t *visited;
112592 + bool interesting_conditions[3] = {false, false, false};
112593 + tree new_node, orig_node = cur_node->node;
112594 +
112595 + set_last_nodes(cur_node);
112596 +
112597 + check_intentional_attribute_ipa(cur_node);
112598 + if (cur_node->intentional_attr_decl == MARK_TURN_OFF || cur_node->intentional_attr_cur_fndecl == MARK_TURN_OFF)
112599 + return cnodes;
112600 +
112601 + search_interesting_conditions(cur_node, interesting_conditions);
112602 +
112603 + // error code
112604 + if (interesting_conditions[CAST] && interesting_conditions[FROM_CONST] && !interesting_conditions[NOT_UNARY])
112605 + return cnodes;
112606 +
112607 + cnodes = search_overflow_attribute(cnodes, cur_node);
112608 +
112609 + if (cur_node->intentional_attr_cur_fndecl != MARK_NO)
112610 + return cnodes;
112611 +
112612 + // unnecessary overflow check
112613 + if (!interesting_conditions[CAST] && !interesting_conditions[NOT_UNARY])
112614 + return cnodes;
112615 +
112616 + visited = pointer_set_create();
112617 + new_node = expand(visited, caller_node, orig_node);
112618 + pointer_set_destroy(visited);
112619 +
112620 + if (new_node == NULL_TREE)
112621 + return cnodes;
112622 +
112623 + change_orig_node(cur_node, new_node);
112624 + check_size_overflow(caller_node, cur_node->first_stmt, TREE_TYPE(new_node), new_node, orig_node, BEFORE_STMT);
112625 +
112626 + return cnodes;
112627 +}
112628 +
112629 +// Check visited interesting nodes.
112630 +static bool is_in_interesting_node(struct interesting_node *head, const_gimple first_stmt, const_tree node, unsigned int num)
112631 +{
112632 + struct interesting_node *cur;
112633 +
112634 + for (cur = head; cur; cur = cur->next) {
112635 + if (!operand_equal_p(node, cur->node, 0))
112636 + continue;
112637 + if (num != cur->num)
112638 + continue;
112639 + if (first_stmt == cur->first_stmt)
112640 + return true;
112641 + }
112642 + return false;
112643 +}
112644 +
112645 +/* Create an interesting node. The ipa pass starts to duplicate from these stmts.
112646 + 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
112647 + 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
112648 + the intentional_overflow attribute check. They are collected by set_last_nodes().
112649 + num: arg count of a call stmt or 0 when it is a ret
112650 + node: the recursion starts from here, it is a call arg or a return value
112651 + 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.
112652 + intentional_attr_decl: intentional_overflow attribute of the callee function
112653 + intentional_attr_cur_fndecl: intentional_overflow attribute of the caller function
112654 + intentional_mark_from_gimple: the intentional overflow type of size_overflow asm stmt from gimple if it exists
112655 + */
112656 +static struct interesting_node *create_new_interesting_node(struct interesting_node *head, gimple first_stmt, tree node, unsigned int num, gimple asm_stmt)
112657 +{
112658 + struct interesting_node *new_node;
112659 + tree fndecl;
112660 + enum gimple_code code;
112661 +
112662 + gcc_assert(node != NULL_TREE);
112663 + code = gimple_code(first_stmt);
112664 + gcc_assert(code == GIMPLE_CALL || code == GIMPLE_ASM || code == GIMPLE_ASSIGN || code == GIMPLE_RETURN);
112665 +
112666 + if (num == CANNOT_FIND_ARG)
112667 + return head;
112668 +
112669 + if (skip_types(node))
112670 + return head;
112671 +
112672 + if (skip_asm(node))
112673 + return head;
112674 +
112675 + if (is_gimple_call(first_stmt))
112676 + fndecl = gimple_call_fndecl(first_stmt);
112677 + else
112678 + fndecl = current_function_decl;
112679 +
112680 + if (fndecl == NULL_TREE)
112681 + return head;
112682 +
112683 + if (is_in_interesting_node(head, first_stmt, node, num))
112684 + return head;
112685 +
112686 + new_node = (struct interesting_node *)xmalloc(sizeof(*new_node));
112687 +
112688 + new_node->next = NULL;
112689 + new_node->first_stmt = first_stmt;
112690 +#if BUILDING_GCC_VERSION <= 4007
112691 + new_node->last_nodes = VEC_alloc(tree, gc, VEC_LEN);
112692 +#else
112693 + vec_alloc(new_node->last_nodes, VEC_LEN);
112694 +#endif
112695 + new_node->num = num;
112696 + new_node->node = node;
112697 + new_node->fndecl = fndecl;
112698 + new_node->intentional_attr_decl = MARK_NO;
112699 + new_node->intentional_attr_cur_fndecl = MARK_NO;
112700 + new_node->intentional_mark_from_gimple = asm_stmt;
112701 +
112702 + if (!head)
112703 + return new_node;
112704 +
112705 + new_node->next = head;
112706 + return new_node;
112707 +}
112708 +
112709 +/* 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).
112710 + * If the ret stmt is in the next cgraph node list then it's an interesting ret.
112711 + */
112712 +static struct interesting_node *handle_stmt_by_cgraph_nodes_ret(struct interesting_node *head, gimple stmt, struct next_cgraph_node *next_node)
112713 +{
112714 + struct next_cgraph_node *cur_node;
112715 + tree ret = gimple_return_retval(stmt);
112716 +
112717 + if (ret == NULL_TREE)
112718 + return head;
112719 +
112720 + for (cur_node = next_node; cur_node; cur_node = cur_node->next) {
112721 + if (!operand_equal_p(cur_node->callee_fndecl, DECL_ORIGIN(current_function_decl), 0))
112722 + continue;
112723 + if (cur_node->num == 0)
112724 + head = create_new_interesting_node(head, stmt, ret, 0, NOT_INTENTIONAL_ASM);
112725 + }
112726 +
112727 + return head;
112728 +}
112729 +
112730 +/* 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).
112731 + * If the call stmt is in the next cgraph node list then it's an interesting call.
112732 + */
112733 +static struct interesting_node *handle_stmt_by_cgraph_nodes_call(struct interesting_node *head, gimple stmt, struct next_cgraph_node *next_node)
112734 +{
112735 + unsigned int argnum;
112736 + tree fndecl, arg;
112737 + struct next_cgraph_node *cur_node;
112738 +
112739 + fndecl = gimple_call_fndecl(stmt);
112740 + if (fndecl == NULL_TREE)
112741 + return head;
112742 +
112743 + for (cur_node = next_node; cur_node; cur_node = cur_node->next) {
112744 + if (!operand_equal_p(cur_node->callee_fndecl, fndecl, 0))
112745 + continue;
112746 + argnum = get_correct_arg_count(cur_node->num, fndecl);
112747 + gcc_assert(argnum != CANNOT_FIND_ARG);
112748 + if (argnum == 0)
112749 + continue;
112750 +
112751 + arg = gimple_call_arg(stmt, argnum - 1);
112752 + head = create_new_interesting_node(head, stmt, arg, argnum, NOT_INTENTIONAL_ASM);
112753 + }
112754 +
112755 + return head;
112756 +}
112757 +
112758 +static unsigned int check_ops(const_tree orig_node, const_tree node, unsigned int ret_count)
112759 +{
112760 + if (!operand_equal_p(orig_node, node, 0))
112761 + return WRONG_NODE;
112762 + if (skip_types(node))
112763 + return WRONG_NODE;
112764 + return ret_count;
112765 +}
112766 +
112767 +// Get the index of the rhs node in an assignment
112768 +static unsigned int get_assign_ops_count(const_gimple stmt, tree node)
112769 +{
112770 + const_tree rhs1, rhs2;
112771 + unsigned int ret;
112772 +
112773 + gcc_assert(stmt);
112774 + gcc_assert(is_gimple_assign(stmt));
112775 +
112776 + rhs1 = gimple_assign_rhs1(stmt);
112777 + gcc_assert(rhs1 != NULL_TREE);
112778 +
112779 + switch (gimple_num_ops(stmt)) {
112780 + case 2:
112781 + return check_ops(node, rhs1, 1);
112782 + case 3:
112783 + ret = check_ops(node, rhs1, 1);
112784 + if (ret != WRONG_NODE)
112785 + return ret;
112786 +
112787 + rhs2 = gimple_assign_rhs2(stmt);
112788 + gcc_assert(rhs2 != NULL_TREE);
112789 + return check_ops(node, rhs2, 2);
112790 + default:
112791 + gcc_unreachable();
112792 + }
112793 +}
112794 +
112795 +// Find the correct arg number of a call stmt. It is needed when the interesting function is a cloned function.
112796 +static unsigned int find_arg_number_gimple(const_tree arg, const_gimple stmt)
112797 +{
112798 + unsigned int i;
112799 +
112800 + if (gimple_call_fndecl(stmt) == NULL_TREE)
112801 + return CANNOT_FIND_ARG;
112802 +
112803 + for (i = 0; i < gimple_call_num_args(stmt); i++) {
112804 + tree node;
112805 +
112806 + node = gimple_call_arg(stmt, i);
112807 + if (!operand_equal_p(arg, node, 0))
112808 + continue;
112809 + if (!skip_types(node))
112810 + return i + 1;
112811 + }
112812 +
112813 + return CANNOT_FIND_ARG;
112814 +}
112815 +
112816 +/* starting from the size_overflow asm stmt collect interesting stmts. They can be
112817 + * any of return, call or assignment stmts (because of inlining).
112818 + */
112819 +static struct interesting_node *get_interesting_ret_or_call(struct pointer_set_t *visited, struct interesting_node *head, tree node, gimple intentional_asm)
112820 +{
112821 + use_operand_p use_p;
112822 + imm_use_iterator imm_iter;
112823 + unsigned int argnum;
112824 +
112825 + if (is_size_overflow_intentional_asm_turn_off(intentional_asm))
112826 + return head;
112827 +
112828 + gcc_assert(TREE_CODE(node) == SSA_NAME);
112829 +
112830 + if (pointer_set_insert(visited, node))
112831 + return head;
112832 +
112833 + FOR_EACH_IMM_USE_FAST(use_p, imm_iter, node) {
112834 + gimple stmt = USE_STMT(use_p);
112835 +
112836 + if (stmt == NULL)
112837 + return head;
112838 + if (is_gimple_debug(stmt))
112839 + continue;
112840 +
112841 + switch (gimple_code(stmt)) {
112842 + case GIMPLE_CALL:
112843 + argnum = find_arg_number_gimple(node, stmt);
112844 + head = create_new_interesting_node(head, stmt, node, argnum, intentional_asm);
112845 + break;
112846 + case GIMPLE_RETURN:
112847 + head = create_new_interesting_node(head, stmt, node, 0, intentional_asm);
112848 + break;
112849 + case GIMPLE_ASSIGN:
112850 + argnum = get_assign_ops_count(stmt, node);
112851 + head = create_new_interesting_node(head, stmt, node, argnum, intentional_asm);
112852 + break;
112853 + case GIMPLE_PHI: {
112854 + tree result = gimple_phi_result(stmt);
112855 + head = get_interesting_ret_or_call(visited, head, result, intentional_asm);
112856 + break;
112857 + }
112858 + case GIMPLE_ASM:
112859 + if (gimple_asm_noutputs(stmt) != 0)
112860 + break;
112861 + if (!is_size_overflow_asm(stmt))
112862 + break;
112863 + head = create_new_interesting_node(head, stmt, node, 1, intentional_asm);
112864 + break;
112865 + case GIMPLE_COND:
112866 + case GIMPLE_SWITCH:
112867 + break;
112868 + default:
112869 + debug_gimple_stmt(stmt);
112870 + gcc_unreachable();
112871 + break;
112872 + }
112873 + }
112874 + return head;
112875 +}
112876 +
112877 +static void remove_size_overflow_asm(gimple stmt)
112878 +{
112879 + gimple_stmt_iterator gsi;
112880 + tree input, output;
112881 +
112882 + if (gimple_code(stmt) != GIMPLE_ASM)
112883 + return;
112884 + if (!is_size_overflow_asm(stmt))
112885 + return;
112886 +
112887 + if (gimple_asm_noutputs(stmt) == 0) {
112888 + gsi = gsi_for_stmt(stmt);
112889 + gsi_remove(&gsi, true);
112890 + return;
112891 + }
112892 +
112893 + input = gimple_asm_input_op(stmt, 0);
112894 + output = gimple_asm_output_op(stmt, 0);
112895 + replace_size_overflow_asm_with_assign(stmt, TREE_VALUE(output), TREE_VALUE(input));
112896 +}
112897 +
112898 +/* handle the size_overflow asm stmts from the gimple pass and collect the interesting stmts.
112899 + * If the asm stmt is a parm_decl kind (noutputs == 0) then remove it.
112900 + * If it is a simple asm stmt then replace it with an assignment from the asm input to the asm output.
112901 + */
112902 +static struct interesting_node *handle_stmt_by_size_overflow_asm(gimple stmt, struct interesting_node *head)
112903 +{
112904 + const_tree output;
112905 + struct pointer_set_t *visited;
112906 + gimple intentional_asm = NOT_INTENTIONAL_ASM;
112907 +
112908 + if (!is_size_overflow_asm(stmt))
112909 + return head;
112910 +
112911 + if (is_size_overflow_intentional_asm_yes(stmt) || is_size_overflow_intentional_asm_turn_off(stmt))
112912 + intentional_asm = stmt;
112913 +
112914 + gcc_assert(gimple_asm_ninputs(stmt) == 1);
112915 +
112916 + if (gimple_asm_noutputs(stmt) == 0) {
112917 + const_tree input = gimple_asm_input_op(stmt, 0);
112918 +
112919 + remove_size_overflow_asm(stmt);
112920 + if (is_gimple_constant(TREE_VALUE(input)))
112921 + return head;
112922 +
112923 + visited = pointer_set_create();
112924 + head = get_interesting_ret_or_call(visited, head, TREE_VALUE(input), intentional_asm);
112925 + pointer_set_destroy(visited);
112926 + return head;
112927 + }
112928 +
112929 + if (!is_size_overflow_intentional_asm_yes(stmt) && !is_size_overflow_intentional_asm_turn_off(stmt))
112930 + remove_size_overflow_asm(stmt);
112931 +
112932 + visited = pointer_set_create();
112933 + output = gimple_asm_output_op(stmt, 0);
112934 + head = get_interesting_ret_or_call(visited, head, TREE_VALUE(output), intentional_asm);
112935 + pointer_set_destroy(visited);
112936 + return head;
112937 +}
112938 +
112939 +/* Iterate over all the stmts of a function and look for the size_overflow asm stmts (they were created in the gimple pass)
112940 + * or a call stmt or a return stmt and store them in the interesting_node list
112941 + */
112942 +static struct interesting_node *collect_interesting_stmts(struct next_cgraph_node *next_node)
112943 +{
112944 + basic_block bb;
112945 + struct interesting_node *head = NULL;
112946 +
112947 + FOR_ALL_BB(bb) {
112948 + gimple_stmt_iterator gsi;
112949 +
112950 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
112951 + enum gimple_code code;
112952 + gimple stmt = gsi_stmt(gsi);
112953 +
112954 + code = gimple_code(stmt);
112955 +
112956 + if (code == GIMPLE_ASM)
112957 + head = handle_stmt_by_size_overflow_asm(stmt, head);
112958 +
112959 + if (!next_node)
112960 + continue;
112961 + if (code == GIMPLE_CALL)
112962 + head = handle_stmt_by_cgraph_nodes_call(head, stmt, next_node);
112963 + if (code == GIMPLE_RETURN)
112964 + head = handle_stmt_by_cgraph_nodes_ret(head, stmt, next_node);
112965 + }
112966 + }
112967 + return head;
112968 +}
112969 +
112970 +static void set_current_function_decl(tree fndecl)
112971 +{
112972 + gcc_assert(fndecl != NULL_TREE);
112973 +
112974 + push_cfun(DECL_STRUCT_FUNCTION(fndecl));
112975 + calculate_dominance_info(CDI_DOMINATORS);
112976 + current_function_decl = fndecl;
112977 +}
112978 +
112979 +static void unset_current_function_decl(void)
112980 +{
112981 + free_dominance_info(CDI_DOMINATORS);
112982 + pop_cfun();
112983 + current_function_decl = NULL_TREE;
112984 +}
112985 +
112986 +static void free_interesting_node(struct interesting_node *head)
112987 +{
112988 + struct interesting_node *cur;
112989 +
112990 + while (head) {
112991 + cur = head->next;
112992 +#if BUILDING_GCC_VERSION <= 4007
112993 + VEC_free(tree, gc, head->last_nodes);
112994 +#else
112995 + vec_free(head->last_nodes);
112996 +#endif
112997 + free(head);
112998 + head = cur;
112999 + }
113000 +}
113001 +
113002 +static struct visited *insert_visited_function(struct visited *head, struct interesting_node *cur_node)
113003 +{
113004 + struct visited *new_visited;
113005 +
113006 + new_visited = (struct visited *)xmalloc(sizeof(*new_visited));
113007 + new_visited->fndecl = cur_node->fndecl;
113008 + new_visited->num = cur_node->num;
113009 + new_visited->first_stmt = cur_node->first_stmt;
113010 + new_visited->next = NULL;
113011 +
113012 + if (!head)
113013 + return new_visited;
113014 +
113015 + new_visited->next = head;
113016 + return new_visited;
113017 +}
113018 +
113019 +/* 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
113020 + * it is a visited function.
113021 + */
113022 +static bool is_visited_function(struct visited *head, struct interesting_node *cur_node)
113023 +{
113024 + struct visited *cur;
113025 +
113026 + if (!head)
113027 + return false;
113028 +
113029 + for (cur = head; cur; cur = cur->next) {
113030 + if (!operand_equal_p(cur_node->fndecl, cur->fndecl, 0))
113031 + continue;
113032 + if (cur_node->num != cur->num)
113033 + continue;
113034 + if (cur_node->first_stmt == cur->first_stmt)
113035 + return true;
113036 + }
113037 + return false;
113038 +}
113039 +
113040 +static void free_next_cgraph_node(struct next_cgraph_node *head)
113041 +{
113042 + struct next_cgraph_node *cur;
113043 +
113044 + while (head) {
113045 + cur = head->next;
113046 + free(head);
113047 + head = cur;
113048 + }
113049 +}
113050 +
113051 +static void remove_all_size_overflow_asm(void)
113052 +{
113053 + basic_block bb;
113054 +
113055 + FOR_ALL_BB(bb) {
113056 + gimple_stmt_iterator si;
113057 +
113058 + for (si = gsi_start_bb(bb); !gsi_end_p(si); gsi_next(&si))
113059 + remove_size_overflow_asm(gsi_stmt(si));
113060 + }
113061 +}
113062 +
113063 +/* Main recursive walk of the ipa pass: iterate over the collected interesting stmts in a function
113064 + * (they are interesting if they have an associated size_overflow asm stmt) and recursively walk
113065 + * the newly collected interesting functions (they are interesting if there is control flow between
113066 + * the interesting stmts and them).
113067 + */
113068 +static struct visited *handle_function(struct cgraph_node *node, struct next_cgraph_node *next_node, struct visited *visited)
113069 +{
113070 + struct interesting_node *head, *cur_node;
113071 + struct next_cgraph_node *cur_cnodes, *cnodes_head = NULL;
113072 +
113073 +#if BUILDING_GCC_VERSION <= 4007
113074 + set_current_function_decl(node->decl);
113075 +#else
113076 + set_current_function_decl(node->symbol.decl);
113077 +#endif
113078 + call_count = 0;
113079 +
113080 + head = collect_interesting_stmts(next_node);
113081 + for (cur_node = head; cur_node; cur_node = cur_node->next) {
113082 + if (is_visited_function(visited, cur_node))
113083 + continue;
113084 + cnodes_head = handle_interesting_stmt(cnodes_head, cur_node, node);
113085 + visited = insert_visited_function(visited, cur_node);
113086 + }
113087 +
113088 + free_interesting_node(head);
113089 + remove_all_size_overflow_asm();
113090 + unset_current_function_decl();
113091 +
113092 + for (cur_cnodes = cnodes_head; cur_cnodes; cur_cnodes = cur_cnodes->next)
113093 + visited = handle_function(cur_cnodes->current_function, cur_cnodes, visited);
113094 +
113095 + free_next_cgraph_node(cnodes_head);
113096 + return visited;
113097 +}
113098 +
113099 +static void free_visited(struct visited *head)
113100 +{
113101 + struct visited *cur;
113102 +
113103 + while (head) {
113104 + cur = head->next;
113105 + free(head);
113106 + head = cur;
113107 + }
113108 +}
113109 +
113110 +// erase the local flag
113111 +static void set_plf_false(void)
113112 +{
113113 + basic_block bb;
113114 +
113115 + FOR_ALL_BB(bb) {
113116 + gimple_stmt_iterator si;
113117 +
113118 + for (si = gsi_start_bb(bb); !gsi_end_p(si); gsi_next(&si))
113119 + gimple_set_plf(gsi_stmt(si), MY_STMT, false);
113120 + for (si = gsi_start_phis(bb); !gsi_end_p(si); gsi_next(&si))
113121 + gimple_set_plf(gsi_stmt(si), MY_STMT, false);
113122 + }
113123 +}
113124 +
113125 +#if BUILDING_GCC_VERSION <= 4006
113126 +static bool cgraph_function_with_gimple_body_p(struct cgraph_node *node)
113127 +{
113128 + return node->analyzed && !node->thunk.thunk_p && !node->alias;
113129 +}
113130 +
113131 +static struct cgraph_node *cgraph_first_function_with_gimple_body(void)
113132 +{
113133 + struct cgraph_node *node;
113134 +
113135 + for (node = cgraph_nodes; node; node = node->next) {
113136 + if (cgraph_function_with_gimple_body_p(node))
113137 + return node;
113138 + }
113139 + return NULL;
113140 +}
113141 +
113142 +static inline struct cgraph_node *cgraph_next_function_with_gimple_body(struct cgraph_node *node)
113143 +{
113144 + for (node = node->next; node; node = node->next) {
113145 + if (cgraph_function_with_gimple_body_p(node))
113146 + return node;
113147 + }
113148 + return NULL;
113149 +}
113150 +
113151 +#define FOR_EACH_FUNCTION_WITH_GIMPLE_BODY(node) \
113152 + for ((node) = cgraph_first_function_with_gimple_body (); (node); \
113153 + (node) = cgraph_next_function_with_gimple_body (node))
113154 +
113155 +#endif
113156 +
113157 +// Main entry point of the ipa pass: erases the plf flag of all stmts and iterates over all the functions
113158 +static unsigned int search_function(void)
113159 +{
113160 + struct cgraph_node *node;
113161 + struct visited *visited = NULL;
113162 +
113163 + FOR_EACH_FUNCTION_WITH_GIMPLE_BODY(node) {
113164 +#if BUILDING_GCC_VERSION <= 4007
113165 + set_current_function_decl(node->decl);
113166 +#else
113167 + set_current_function_decl(node->symbol.decl);
113168 +#endif
113169 + set_plf_false();
113170 + unset_current_function_decl();
113171 + }
113172 +
113173 + FOR_EACH_FUNCTION_WITH_GIMPLE_BODY(node) {
113174 + gcc_assert(cgraph_function_flags_ready);
113175 +#if BUILDING_GCC_VERSION <= 4007
113176 + gcc_assert(node->reachable);
113177 +#endif
113178 +
113179 + visited = handle_function(node, NULL, visited);
113180 + }
113181 +
113182 + free_visited(visited);
113183 + return 0;
113184 +}
113185 +
113186 +static struct ipa_opt_pass_d pass_ipa = {
113187 + .pass = {
113188 + .type = SIMPLE_IPA_PASS,
113189 + .name = "size_overflow",
113190 +#if BUILDING_GCC_VERSION >= 4008
113191 + .optinfo_flags = OPTGROUP_NONE,
113192 +#endif
113193 + .gate = NULL,
113194 + .execute = search_function,
113195 + .sub = NULL,
113196 + .next = NULL,
113197 + .static_pass_number = 0,
113198 + .tv_id = TV_NONE,
113199 + .properties_required = 0,
113200 + .properties_provided = 0,
113201 + .properties_destroyed = 0,
113202 + .todo_flags_start = 0,
113203 + .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,
113204 + },
113205 + .generate_summary = NULL,
113206 + .write_summary = NULL,
113207 + .read_summary = NULL,
113208 +#if BUILDING_GCC_VERSION >= 4006
113209 + .write_optimization_summary = NULL,
113210 + .read_optimization_summary = NULL,
113211 +#endif
113212 + .stmt_fixup = NULL,
113213 + .function_transform_todo_flags_start = 0,
113214 + .function_transform = NULL,
113215 + .variable_transform = NULL,
113216 +};
113217 +
113218 +// data for the size_overflow asm stmt
113219 +struct asm_data {
113220 + gimple def_stmt;
113221 + tree input;
113222 + tree output;
113223 +};
113224 +
113225 +#if BUILDING_GCC_VERSION <= 4007
113226 +static VEC(tree, gc) *create_asm_io_list(tree string, tree io)
113227 +#else
113228 +static vec<tree, va_gc> *create_asm_io_list(tree string, tree io)
113229 +#endif
113230 +{
113231 + tree list;
113232 +#if BUILDING_GCC_VERSION <= 4007
113233 + VEC(tree, gc) *vec_list = NULL;
113234 +#else
113235 + vec<tree, va_gc> *vec_list = NULL;
113236 +#endif
113237 +
113238 + list = build_tree_list(NULL_TREE, string);
113239 + list = chainon(NULL_TREE, build_tree_list(list, io));
113240 +#if BUILDING_GCC_VERSION <= 4007
113241 + VEC_safe_push(tree, gc, vec_list, list);
113242 +#else
113243 + vec_safe_push(vec_list, list);
113244 +#endif
113245 + return vec_list;
113246 +}
113247 +
113248 +static void create_asm_stmt(const char *str, tree str_input, tree str_output, struct asm_data *asm_data)
113249 +{
113250 + gimple asm_stmt;
113251 + gimple_stmt_iterator gsi;
113252 +#if BUILDING_GCC_VERSION <= 4007
113253 + VEC(tree, gc) *input, *output = NULL;
113254 +#else
113255 + vec<tree, va_gc> *input, *output = NULL;
113256 +#endif
113257 +
113258 + input = create_asm_io_list(str_input, asm_data->input);
113259 +
113260 + if (asm_data->output)
113261 + output = create_asm_io_list(str_output, asm_data->output);
113262 +
113263 + asm_stmt = gimple_build_asm_vec(str, input, output, NULL, NULL);
113264 + gsi = gsi_for_stmt(asm_data->def_stmt);
113265 + gsi_insert_after(&gsi, asm_stmt, GSI_NEW_STMT);
113266 +
113267 + if (asm_data->output)
113268 + SSA_NAME_DEF_STMT(asm_data->output) = asm_stmt;
113269 +}
113270 +
113271 +static void replace_call_lhs(const struct asm_data *asm_data)
113272 +{
113273 + gimple_set_lhs(asm_data->def_stmt, asm_data->input);
113274 + update_stmt(asm_data->def_stmt);
113275 + SSA_NAME_DEF_STMT(asm_data->input) = asm_data->def_stmt;
113276 +}
113277 +
113278 +static enum mark search_intentional_phi(struct pointer_set_t *visited, const_tree result)
113279 +{
113280 + enum mark cur_fndecl_attr;
113281 + gimple phi = get_def_stmt(result);
113282 + unsigned int i, n = gimple_phi_num_args(phi);
113283 +
113284 + pointer_set_insert(visited, phi);
113285 + for (i = 0; i < n; i++) {
113286 + tree arg = gimple_phi_arg_def(phi, i);
113287 +
113288 + cur_fndecl_attr = search_intentional(visited, arg);
113289 + if (cur_fndecl_attr != MARK_NO)
113290 + return cur_fndecl_attr;
113291 + }
113292 + return MARK_NO;
113293 +}
113294 +
113295 +static enum mark search_intentional_binary(struct pointer_set_t *visited, const_tree lhs)
113296 +{
113297 + enum mark cur_fndecl_attr;
113298 + const_tree rhs1, rhs2;
113299 + gimple def_stmt = get_def_stmt(lhs);
113300 +
113301 + rhs1 = gimple_assign_rhs1(def_stmt);
113302 + rhs2 = gimple_assign_rhs2(def_stmt);
113303 +
113304 + cur_fndecl_attr = search_intentional(visited, rhs1);
113305 + if (cur_fndecl_attr != MARK_NO)
113306 + return cur_fndecl_attr;
113307 + return search_intentional(visited, rhs2);
113308 +}
113309 +
113310 +// Look up the intentional_overflow attribute on the caller and the callee functions.
113311 +static enum mark search_intentional(struct pointer_set_t *visited, const_tree lhs)
113312 +{
113313 + const_gimple def_stmt;
113314 +
113315 + if (TREE_CODE(lhs) != SSA_NAME)
113316 + return get_intentional_attr_type(lhs);
113317 +
113318 + def_stmt = get_def_stmt(lhs);
113319 + if (!def_stmt)
113320 + return MARK_NO;
113321 +
113322 + if (pointer_set_contains(visited, def_stmt))
113323 + return MARK_NO;
113324 +
113325 + switch (gimple_code(def_stmt)) {
113326 + case GIMPLE_NOP:
113327 + return search_intentional(visited, SSA_NAME_VAR(lhs));
113328 + case GIMPLE_ASM:
113329 + case GIMPLE_CALL:
113330 + return MARK_NO;
113331 + case GIMPLE_PHI:
113332 + return search_intentional_phi(visited, lhs);
113333 + case GIMPLE_ASSIGN:
113334 + switch (gimple_num_ops(def_stmt)) {
113335 + case 2:
113336 + return search_intentional(visited, gimple_assign_rhs1(def_stmt));
113337 + case 3:
113338 + return search_intentional_binary(visited, lhs);
113339 + }
113340 + case GIMPLE_RETURN:
113341 + return MARK_NO;
113342 + default:
113343 + debug_gimple_stmt((gimple)def_stmt);
113344 + error("%s: unknown gimple code", __func__);
113345 + gcc_unreachable();
113346 + }
113347 +}
113348 +
113349 +// Check the intentional_overflow attribute and create the asm comment string for the size_overflow asm stmt.
113350 +static const char *check_intentional_attribute_gimple(const_tree arg, const_gimple stmt, unsigned int argnum)
113351 +{
113352 + const_tree fndecl;
113353 + const char *asm_str;
113354 + struct pointer_set_t *visited;
113355 + enum mark cur_fndecl_attr, decl_attr = MARK_NO;
113356 +
113357 + fndecl = get_interesting_orig_fndecl(stmt, argnum);
113358 + if (is_end_intentional_intentional_attr(fndecl, argnum))
113359 + decl_attr = MARK_NOT_INTENTIONAL;
113360 + else if (is_yes_intentional_attr(fndecl, argnum))
113361 + decl_attr = MARK_YES;
113362 + else if (is_turn_off_intentional_attr(fndecl) || is_turn_off_intentional_attr(DECL_ORIGIN(current_function_decl))) {
113363 + return "# size_overflow MARK_TURN_OFF\n\t";
113364 + }
113365 +
113366 + visited = pointer_set_create();
113367 + cur_fndecl_attr = search_intentional(visited, arg);
113368 + pointer_set_destroy(visited);
113369 +
113370 + switch (cur_fndecl_attr) {
113371 + case MARK_NO:
113372 + asm_str = "# size_overflow\n\t";
113373 + break;
113374 + case MARK_TURN_OFF:
113375 + asm_str = "# size_overflow MARK_TURN_OFF\n\t";
113376 + break;
113377 + default:
113378 + asm_str = "# size_overflow MARK_YES\n\t";
113379 + print_missing_intentional(decl_attr, cur_fndecl_attr, fndecl, argnum);
113380 + break;
113381 + }
113382 +
113383 + return asm_str;
113384 +}
113385 +
113386 +static void check_missing_size_overflow_attribute(tree var)
113387 +{
113388 + tree orig_fndecl;
113389 + unsigned int num;
113390 +
113391 + if (is_a_return_check(var))
113392 + orig_fndecl = DECL_ORIGIN(var);
113393 + else
113394 + orig_fndecl = DECL_ORIGIN(current_function_decl);
113395 +
113396 + num = get_function_num(var, orig_fndecl);
113397 + if (num == CANNOT_FIND_ARG)
113398 + return;
113399 +
113400 + is_missing_function(orig_fndecl, num);
113401 +}
113402 +
113403 +static void search_size_overflow_attribute_phi(struct pointer_set_t *visited, const_tree result)
113404 +{
113405 + gimple phi = get_def_stmt(result);
113406 + unsigned int i, n = gimple_phi_num_args(phi);
113407 +
113408 + pointer_set_insert(visited, phi);
113409 + for (i = 0; i < n; i++) {
113410 + tree arg = gimple_phi_arg_def(phi, i);
113411 +
113412 + search_size_overflow_attribute(visited, arg);
113413 + }
113414 +}
113415 +
113416 +static void search_size_overflow_attribute_binary(struct pointer_set_t *visited, const_tree lhs)
113417 +{
113418 + const_gimple def_stmt = get_def_stmt(lhs);
113419 + tree rhs1, rhs2;
113420 +
113421 + rhs1 = gimple_assign_rhs1(def_stmt);
113422 + rhs2 = gimple_assign_rhs2(def_stmt);
113423 +
113424 + search_size_overflow_attribute(visited, rhs1);
113425 + search_size_overflow_attribute(visited, rhs2);
113426 +}
113427 +
113428 +static void search_size_overflow_attribute(struct pointer_set_t *visited, tree lhs)
113429 +{
113430 + const_gimple def_stmt;
113431 +
113432 + if (TREE_CODE(lhs) == PARM_DECL) {
113433 + check_missing_size_overflow_attribute(lhs);
113434 + return;
113435 + }
113436 +
113437 + def_stmt = get_def_stmt(lhs);
113438 + if (!def_stmt)
113439 + return;
113440 +
113441 + if (pointer_set_insert(visited, def_stmt))
113442 + return;
113443 +
113444 + switch (gimple_code(def_stmt)) {
113445 + case GIMPLE_NOP:
113446 + return search_size_overflow_attribute(visited, SSA_NAME_VAR(lhs));
113447 + case GIMPLE_ASM:
113448 + return;
113449 + case GIMPLE_CALL: {
113450 + tree fndecl = gimple_call_fndecl(def_stmt);
113451 +
113452 + if (fndecl == NULL_TREE)
113453 + return;
113454 + check_missing_size_overflow_attribute(fndecl);
113455 + return;
113456 + }
113457 + case GIMPLE_PHI:
113458 + return search_size_overflow_attribute_phi(visited, lhs);
113459 + case GIMPLE_ASSIGN:
113460 + switch (gimple_num_ops(def_stmt)) {
113461 + case 2:
113462 + return search_size_overflow_attribute(visited, gimple_assign_rhs1(def_stmt));
113463 + case 3:
113464 + return search_size_overflow_attribute_binary(visited, lhs);
113465 + }
113466 + default:
113467 + debug_gimple_stmt((gimple)def_stmt);
113468 + error("%s: unknown gimple code", __func__);
113469 + gcc_unreachable();
113470 + }
113471 +}
113472 +
113473 +// Search missing entries in the hash table (invoked from the gimple pass)
113474 +static void search_missing_size_overflow_attribute_gimple(const_gimple stmt, unsigned int num)
113475 +{
113476 + tree fndecl = NULL_TREE;
113477 + tree lhs;
113478 + struct pointer_set_t *visited;
113479 +
113480 + if (is_turn_off_intentional_attr(DECL_ORIGIN(current_function_decl)))
113481 + return;
113482 +
113483 + if (num == 0) {
113484 + gcc_assert(gimple_code(stmt) == GIMPLE_RETURN);
113485 + lhs = gimple_return_retval(stmt);
113486 + } else {
113487 + gcc_assert(is_gimple_call(stmt));
113488 + lhs = gimple_call_arg(stmt, num - 1);
113489 + fndecl = gimple_call_fndecl(stmt);
113490 + }
113491 +
113492 + if (fndecl != NULL_TREE && is_turn_off_intentional_attr(DECL_ORIGIN(fndecl)))
113493 + return;
113494 +
113495 + visited = pointer_set_create();
113496 + search_size_overflow_attribute(visited, lhs);
113497 + pointer_set_destroy(visited);
113498 +}
113499 +
113500 +static void create_output_from_phi(gimple stmt, unsigned int argnum, struct asm_data *asm_data)
113501 +{
113502 + gimple_stmt_iterator gsi;
113503 + gimple assign;
113504 +
113505 + assign = gimple_build_assign(asm_data->input, asm_data->output);
113506 + gsi = gsi_for_stmt(stmt);
113507 + gsi_insert_before(&gsi, assign, GSI_NEW_STMT);
113508 + asm_data->def_stmt = assign;
113509 +
113510 + asm_data->output = create_new_var(TREE_TYPE(asm_data->output));
113511 + asm_data->output = make_ssa_name(asm_data->output, stmt);
113512 + if (gimple_code(stmt) == GIMPLE_RETURN)
113513 + gimple_return_set_retval(stmt, asm_data->output);
113514 + else
113515 + gimple_call_set_arg(stmt, argnum - 1, asm_data->output);
113516 + update_stmt(stmt);
113517 +}
113518 +
113519 +/* Create the input of the size_overflow asm stmt.
113520 + * When the arg of the callee function is a parm_decl it creates this kind of size_overflow asm stmt:
113521 + * __asm__("# size_overflow MARK_YES" : : "rm" size_1(D));
113522 + * The input field in asm_data will be empty if there is no need for further size_overflow asm stmt insertion.
113523 + * otherwise create the input (for a phi stmt the output too) of the asm stmt.
113524 + */
113525 +static void create_asm_input(gimple stmt, unsigned int argnum, struct asm_data *asm_data)
113526 +{
113527 + if (!asm_data->def_stmt) {
113528 + asm_data->input = NULL_TREE;
113529 + return;
113530 + }
113531 +
113532 + asm_data->input = create_new_var(TREE_TYPE(asm_data->output));
113533 + asm_data->input = make_ssa_name(asm_data->input, asm_data->def_stmt);
113534 +
113535 + switch (gimple_code(asm_data->def_stmt)) {
113536 + case GIMPLE_ASSIGN:
113537 + case GIMPLE_CALL:
113538 + replace_call_lhs(asm_data);
113539 + break;
113540 + case GIMPLE_PHI:
113541 + create_output_from_phi(stmt, argnum, asm_data);
113542 + break;
113543 + case GIMPLE_NOP: {
113544 + const char *str = check_intentional_attribute_gimple(asm_data->output, stmt, argnum);
113545 +
113546 + asm_data->input = asm_data->output;
113547 + asm_data->output = NULL;
113548 + asm_data->def_stmt = stmt;
113549 +
113550 + create_asm_stmt(str, build_string(2, "rm"), NULL, asm_data);
113551 + asm_data->input = NULL_TREE;
113552 + break;
113553 + }
113554 + case GIMPLE_ASM:
113555 + if (is_size_overflow_asm(asm_data->def_stmt)) {
113556 + asm_data->input = NULL_TREE;
113557 + break;
113558 + }
113559 + default:
113560 + debug_gimple_stmt(asm_data->def_stmt);
113561 + gcc_unreachable();
113562 + }
113563 +}
113564 +
113565 +/* This is the gimple part of searching for a missing size_overflow attribute. If the intentional_overflow attribute type
113566 + * is of the right kind create the appropriate size_overflow asm stmts:
113567 + * __asm__("# size_overflow" : =rm" D.3344_8 : "0" cicus.4_16);
113568 + * __asm__("# size_overflow MARK_YES" : : "rm" size_1(D));
113569 + */
113570 +static void create_size_overflow_asm(gimple stmt, tree output_node, unsigned int argnum)
113571 +{
113572 + struct asm_data asm_data;
113573 + const char *str;
113574 +
113575 + if (is_gimple_constant(output_node))
113576 + return;
113577 +
113578 + search_missing_size_overflow_attribute_gimple(stmt, argnum);
113579 +
113580 + asm_data.output = output_node;
113581 + asm_data.def_stmt = get_def_stmt(asm_data.output);
113582 + create_asm_input(stmt, argnum, &asm_data);
113583 + if (asm_data.input == NULL_TREE)
113584 + return;
113585 +
113586 + str = check_intentional_attribute_gimple(asm_data.output, stmt, argnum);
113587 + create_asm_stmt(str, build_string(1, "0"), build_string(3, "=rm"), &asm_data);
113588 +}
113589 +
113590 +// Determine the return value and insert the asm stmt to mark the return stmt.
113591 +static void insert_asm_ret(gimple stmt)
113592 +{
113593 + tree ret;
113594 +
113595 + ret = gimple_return_retval(stmt);
113596 + create_size_overflow_asm(stmt, ret, 0);
113597 +}
113598 +
113599 +// Determine the correct arg index and arg and insert the asm stmt to mark the stmt.
113600 +static void insert_asm_arg(gimple stmt, unsigned int orig_argnum)
113601 +{
113602 + tree arg;
113603 + unsigned int argnum;
113604 +
113605 + argnum = get_correct_arg_count(orig_argnum, gimple_call_fndecl(stmt));
113606 + gcc_assert(argnum != 0);
113607 + if (argnum == CANNOT_FIND_ARG)
113608 + return;
113609 +
113610 + arg = gimple_call_arg(stmt, argnum - 1);
113611 + gcc_assert(arg != NULL_TREE);
113612 + create_size_overflow_asm(stmt, arg, argnum);
113613 +}
113614 +
113615 +// If a function arg or the return value is marked by the size_overflow attribute then set its index in the array.
113616 +static void set_argnum_attribute(const_tree attr, bool *argnums)
113617 +{
113618 + unsigned int argnum;
113619 + tree attr_value;
113620 +
113621 + for (attr_value = TREE_VALUE(attr); attr_value; attr_value = TREE_CHAIN(attr_value)) {
113622 + argnum = TREE_INT_CST_LOW(TREE_VALUE(attr_value));
113623 + argnums[argnum] = true;
113624 + }
113625 +}
113626 +
113627 +// If a function arg or the return value is in the hash table then set its index in the array.
113628 +static void set_argnum_hash(tree fndecl, bool *argnums)
113629 +{
113630 + unsigned int num;
113631 + const struct size_overflow_hash *hash;
113632 +
113633 + hash = get_function_hash(DECL_ORIGIN(fndecl));
113634 + if (!hash)
113635 + return;
113636 +
113637 + for (num = 0; num <= MAX_PARAM; num++) {
113638 + if (!(hash->param & (1U << num)))
113639 + continue;
113640 +
113641 + argnums[num] = true;
113642 + }
113643 +}
113644 +
113645 +static bool is_all_the_argnums_empty(bool *argnums)
113646 +{
113647 + unsigned int i;
113648 +
113649 + for (i = 0; i <= MAX_PARAM; i++)
113650 + if (argnums[i])
113651 + return false;
113652 + return true;
113653 +}
113654 +
113655 +// Check whether the arguments or the return value of the function are in the hash table or are marked by the size_overflow attribute.
113656 +static void search_interesting_args(tree fndecl, bool *argnums)
113657 +{
113658 + const_tree attr;
113659 +
113660 + set_argnum_hash(fndecl, argnums);
113661 + if (!is_all_the_argnums_empty(argnums))
113662 + return;
113663 +
113664 + attr = lookup_attribute("size_overflow", DECL_ATTRIBUTES(fndecl));
113665 + if (attr && TREE_VALUE(attr))
113666 + set_argnum_attribute(attr, argnums);
113667 +}
113668 +
113669 +/*
113670 + * Look up the intentional_overflow attribute that turns off ipa based duplication
113671 + * on the callee function, if found insert an asm stmt with "MARK_TURN_OFF".
113672 + */
113673 +static bool create_mark_turn_off_asm(gimple stmt)
113674 +{
113675 + enum mark mark;
113676 + struct asm_data asm_data;
113677 + const_tree fndecl = gimple_call_fndecl(stmt);
113678 +
113679 + mark = get_intentional_attr_type(DECL_ORIGIN(fndecl));
113680 + if (mark != MARK_TURN_OFF)
113681 + return false;
113682 +
113683 + asm_data.input = gimple_call_lhs(stmt);
113684 + if (asm_data.input == NULL_TREE) {
113685 + asm_data.input = gimple_call_arg(stmt, 0);
113686 + if (is_gimple_constant(asm_data.input))
113687 + return false;
113688 + }
113689 +
113690 + asm_data.output = NULL;
113691 + asm_data.def_stmt = stmt;
113692 + create_asm_stmt("# size_overflow MARK_TURN_OFF\n\t", build_string(2, "rm"), NULL, &asm_data);
113693 + return true;
113694 +}
113695 +
113696 +// 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
113697 +static void handle_interesting_function(gimple stmt)
113698 +{
113699 + unsigned int argnum;
113700 + tree fndecl;
113701 + bool orig_argnums[MAX_PARAM + 1] = {false};
113702 +
113703 + if (gimple_call_num_args(stmt) == 0)
113704 + return;
113705 + fndecl = gimple_call_fndecl(stmt);
113706 + if (fndecl == NULL_TREE)
113707 + return;
113708 + fndecl = DECL_ORIGIN(fndecl);
113709 +
113710 + if (create_mark_turn_off_asm(stmt))
113711 + return;
113712 +
113713 + search_interesting_args(fndecl, orig_argnums);
113714 +
113715 + for (argnum = 1; argnum < MAX_PARAM; argnum++)
113716 + if (orig_argnums[argnum])
113717 + insert_asm_arg(stmt, argnum);
113718 +}
113719 +
113720 +// 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
113721 +static void handle_interesting_ret(gimple stmt)
113722 +{
113723 + bool orig_argnums[MAX_PARAM + 1] = {false};
113724 +
113725 + search_interesting_args(current_function_decl, orig_argnums);
113726 +
113727 + if (orig_argnums[0])
113728 + insert_asm_ret(stmt);
113729 +}
113730 +
113731 +// Iterate over all the stmts and search for call and return stmts and mark them if they're in the hash table
113732 +static unsigned int search_interesting_functions(void)
113733 +{
113734 + basic_block bb;
113735 +
113736 + FOR_ALL_BB(bb) {
113737 + gimple_stmt_iterator gsi;
113738 +
113739 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
113740 + gimple stmt = gsi_stmt(gsi);
113741 +
113742 + if (is_gimple_call(stmt))
113743 + handle_interesting_function(stmt);
113744 + else if (gimple_code(stmt) == GIMPLE_RETURN)
113745 + handle_interesting_ret(stmt);
113746 + }
113747 + }
113748 + return 0;
113749 +}
113750 +
113751 +/*
113752 + * A lot of functions get inlined before the ipa passes so after the build_ssa gimple pass
113753 + * this pass inserts asm stmts to mark the interesting args
113754 + * that the ipa pass will detect and insert the size overflow checks for.
113755 + */
113756 +static struct gimple_opt_pass insert_size_overflow_asm_pass = {
113757 + .pass = {
113758 + .type = GIMPLE_PASS,
113759 + .name = "insert_size_overflow_asm",
113760 +#if BUILDING_GCC_VERSION >= 4008
113761 + .optinfo_flags = OPTGROUP_NONE,
113762 +#endif
113763 + .gate = NULL,
113764 + .execute = search_interesting_functions,
113765 + .sub = NULL,
113766 + .next = NULL,
113767 + .static_pass_number = 0,
113768 + .tv_id = TV_NONE,
113769 + .properties_required = PROP_cfg,
113770 + .properties_provided = 0,
113771 + .properties_destroyed = 0,
113772 + .todo_flags_start = 0,
113773 + .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
113774 + }
113775 +};
113776 +
113777 +// Create the noreturn report_size_overflow() function decl.
113778 +static void start_unit_callback(void __unused *gcc_data, void __unused *user_data)
113779 +{
113780 + tree fntype;
113781 +
113782 + const_char_ptr_type_node = build_pointer_type(build_type_variant(char_type_node, 1, 0));
113783 +
113784 + // void report_size_overflow(const char *loc_file, unsigned int loc_line, const char *current_func, const char *ssa_var)
113785 + fntype = build_function_type_list(void_type_node,
113786 + const_char_ptr_type_node,
113787 + unsigned_type_node,
113788 + const_char_ptr_type_node,
113789 + const_char_ptr_type_node,
113790 + NULL_TREE);
113791 + report_size_overflow_decl = build_fn_decl("report_size_overflow", fntype);
113792 +
113793 + DECL_ASSEMBLER_NAME(report_size_overflow_decl);
113794 + TREE_PUBLIC(report_size_overflow_decl) = 1;
113795 + DECL_EXTERNAL(report_size_overflow_decl) = 1;
113796 + DECL_ARTIFICIAL(report_size_overflow_decl) = 1;
113797 + TREE_THIS_VOLATILE(report_size_overflow_decl) = 1;
113798 +}
113799 +
113800 +static unsigned int dump_functions(void)
113801 +{
113802 + struct cgraph_node *node;
113803 +
113804 + FOR_EACH_FUNCTION_WITH_GIMPLE_BODY(node) {
113805 + basic_block bb;
113806 +
113807 +#if BUILDING_GCC_VERSION <= 4007
113808 + push_cfun(DECL_STRUCT_FUNCTION(node->decl));
113809 + current_function_decl = node->decl;
113810 +#else
113811 + push_cfun(DECL_STRUCT_FUNCTION(node->symbol.decl));
113812 + current_function_decl = node->symbol.decl;
113813 +#endif
113814 +
113815 + fprintf(stderr, "-----------------------------------------\n%s\n-----------------------------------------\n", NAME(current_function_decl));
113816 +
113817 + FOR_ALL_BB(bb) {
113818 + gimple_stmt_iterator si;
113819 +
113820 + fprintf(stderr, "<bb %u>:\n", bb->index);
113821 + for (si = gsi_start_phis(bb); !gsi_end_p(si); gsi_next(&si))
113822 + debug_gimple_stmt(gsi_stmt(si));
113823 + for (si = gsi_start_bb(bb); !gsi_end_p(si); gsi_next(&si))
113824 + debug_gimple_stmt(gsi_stmt(si));
113825 + fprintf(stderr, "\n");
113826 + }
113827 +
113828 + fprintf(stderr, "-------------------------------------------------------------------------\n");
113829 +
113830 + pop_cfun();
113831 + current_function_decl = NULL_TREE;
113832 + }
113833 +
113834 + fprintf(stderr, "###############################################################################\n");
113835 +
113836 + return 0;
113837 +}
113838 +
113839 +static struct ipa_opt_pass_d pass_dump = {
113840 + .pass = {
113841 + .type = SIMPLE_IPA_PASS,
113842 + .name = "dump",
113843 +#if BUILDING_GCC_VERSION >= 4008
113844 + .optinfo_flags = OPTGROUP_NONE,
113845 +#endif
113846 + .gate = NULL,
113847 + .execute = dump_functions,
113848 + .sub = NULL,
113849 + .next = NULL,
113850 + .static_pass_number = 0,
113851 + .tv_id = TV_NONE,
113852 + .properties_required = 0,
113853 + .properties_provided = 0,
113854 + .properties_destroyed = 0,
113855 + .todo_flags_start = 0,
113856 + .todo_flags_finish = 0,
113857 + },
113858 + .generate_summary = NULL,
113859 + .write_summary = NULL,
113860 + .read_summary = NULL,
113861 +#if BUILDING_GCC_VERSION >= 4006
113862 + .write_optimization_summary = NULL,
113863 + .read_optimization_summary = NULL,
113864 +#endif
113865 + .stmt_fixup = NULL,
113866 + .function_transform_todo_flags_start = 0,
113867 + .function_transform = NULL,
113868 + .variable_transform = NULL,
113869 +};
113870 +
113871 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
113872 +{
113873 + int i;
113874 + const char * const plugin_name = plugin_info->base_name;
113875 + const int argc = plugin_info->argc;
113876 + const struct plugin_argument * const argv = plugin_info->argv;
113877 + bool enable = true;
113878 +
113879 + struct register_pass_info insert_size_overflow_asm_pass_info = {
113880 + .pass = &insert_size_overflow_asm_pass.pass,
113881 + .reference_pass_name = "ssa",
113882 + .ref_pass_instance_number = 1,
113883 + .pos_op = PASS_POS_INSERT_AFTER
113884 + };
113885 +
113886 + struct register_pass_info __unused dump_before_pass_info = {
113887 + .pass = &pass_dump.pass,
113888 + .reference_pass_name = "increase_alignment",
113889 + .ref_pass_instance_number = 1,
113890 + .pos_op = PASS_POS_INSERT_BEFORE
113891 + };
113892 +
113893 + struct register_pass_info ipa_pass_info = {
113894 + .pass = &pass_ipa.pass,
113895 + .reference_pass_name = "increase_alignment",
113896 + .ref_pass_instance_number = 1,
113897 + .pos_op = PASS_POS_INSERT_BEFORE
113898 + };
113899 +
113900 + struct register_pass_info __unused dump_after_pass_info = {
113901 + .pass = &pass_dump.pass,
113902 + .reference_pass_name = "increase_alignment",
113903 + .ref_pass_instance_number = 1,
113904 + .pos_op = PASS_POS_INSERT_BEFORE
113905 + };
113906 +
113907 + if (!plugin_default_version_check(version, &gcc_version)) {
113908 + error(G_("incompatible gcc/plugin versions"));
113909 + return 1;
113910 + }
113911 +
113912 + for (i = 0; i < argc; ++i) {
113913 + if (!strcmp(argv[i].key, "no-size-overflow")) {
113914 + enable = false;
113915 + continue;
113916 + }
113917 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
113918 + }
113919 +
113920 + register_callback(plugin_name, PLUGIN_INFO, NULL, &size_overflow_plugin_info);
113921 + if (enable) {
113922 + register_callback("start_unit", PLUGIN_START_UNIT, &start_unit_callback, NULL);
113923 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &insert_size_overflow_asm_pass_info);
113924 +// register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &dump_before_pass_info);
113925 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &ipa_pass_info);
113926 +// register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &dump_after_pass_info);
113927 + }
113928 + register_callback(plugin_name, PLUGIN_ATTRIBUTES, register_attributes, NULL);
113929 +
113930 + return 0;
113931 +}
113932 diff --git a/tools/gcc/stackleak_plugin.c b/tools/gcc/stackleak_plugin.c
113933 new file mode 100644
113934 index 0000000..ac2901e
113935 --- /dev/null
113936 +++ b/tools/gcc/stackleak_plugin.c
113937 @@ -0,0 +1,327 @@
113938 +/*
113939 + * Copyright 2011-2013 by the PaX Team <pageexec@freemail.hu>
113940 + * Licensed under the GPL v2
113941 + *
113942 + * Note: the choice of the license means that the compilation process is
113943 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
113944 + * but for the kernel it doesn't matter since it doesn't link against
113945 + * any of the gcc libraries
113946 + *
113947 + * gcc plugin to help implement various PaX features
113948 + *
113949 + * - track lowest stack pointer
113950 + *
113951 + * TODO:
113952 + * - initialize all local variables
113953 + *
113954 + * BUGS:
113955 + * - none known
113956 + */
113957 +#include "gcc-plugin.h"
113958 +#include "config.h"
113959 +#include "system.h"
113960 +#include "coretypes.h"
113961 +#include "tree.h"
113962 +#include "tree-pass.h"
113963 +#include "flags.h"
113964 +#include "intl.h"
113965 +#include "toplev.h"
113966 +#include "plugin.h"
113967 +//#include "expr.h" where are you...
113968 +#include "diagnostic.h"
113969 +#include "plugin-version.h"
113970 +#include "tm.h"
113971 +#include "function.h"
113972 +#include "basic-block.h"
113973 +#include "gimple.h"
113974 +#include "rtl.h"
113975 +#include "emit-rtl.h"
113976 +
113977 +#if BUILDING_GCC_VERSION >= 4008
113978 +#define TODO_dump_func 0
113979 +#endif
113980 +
113981 +extern void print_gimple_stmt(FILE *, gimple, int, int);
113982 +
113983 +int plugin_is_GPL_compatible;
113984 +
113985 +static int track_frame_size = -1;
113986 +static const char track_function[] = "pax_track_stack";
113987 +static const char check_function[] = "pax_check_alloca";
113988 +static bool init_locals;
113989 +
113990 +static struct plugin_info stackleak_plugin_info = {
113991 + .version = "201302112000",
113992 + .help = "track-lowest-sp=nn\ttrack sp in functions whose frame size is at least nn bytes\n"
113993 +// "initialize-locals\t\tforcibly initialize all stack frames\n"
113994 +};
113995 +
113996 +static bool gate_stackleak_track_stack(void);
113997 +static unsigned int execute_stackleak_tree_instrument(void);
113998 +static unsigned int execute_stackleak_final(void);
113999 +
114000 +static struct gimple_opt_pass stackleak_tree_instrument_pass = {
114001 + .pass = {
114002 + .type = GIMPLE_PASS,
114003 + .name = "stackleak_tree_instrument",
114004 +#if BUILDING_GCC_VERSION >= 4008
114005 + .optinfo_flags = OPTGROUP_NONE,
114006 +#endif
114007 + .gate = gate_stackleak_track_stack,
114008 + .execute = execute_stackleak_tree_instrument,
114009 + .sub = NULL,
114010 + .next = NULL,
114011 + .static_pass_number = 0,
114012 + .tv_id = TV_NONE,
114013 + .properties_required = PROP_gimple_leh | PROP_cfg,
114014 + .properties_provided = 0,
114015 + .properties_destroyed = 0,
114016 + .todo_flags_start = 0, //TODO_verify_ssa | TODO_verify_flow | TODO_verify_stmts,
114017 + .todo_flags_finish = TODO_verify_ssa | TODO_verify_stmts | TODO_dump_func | TODO_update_ssa
114018 + }
114019 +};
114020 +
114021 +static struct rtl_opt_pass stackleak_final_rtl_opt_pass = {
114022 + .pass = {
114023 + .type = RTL_PASS,
114024 + .name = "stackleak_final",
114025 +#if BUILDING_GCC_VERSION >= 4008
114026 + .optinfo_flags = OPTGROUP_NONE,
114027 +#endif
114028 + .gate = gate_stackleak_track_stack,
114029 + .execute = execute_stackleak_final,
114030 + .sub = NULL,
114031 + .next = NULL,
114032 + .static_pass_number = 0,
114033 + .tv_id = TV_NONE,
114034 + .properties_required = 0,
114035 + .properties_provided = 0,
114036 + .properties_destroyed = 0,
114037 + .todo_flags_start = 0,
114038 + .todo_flags_finish = TODO_dump_func
114039 + }
114040 +};
114041 +
114042 +static bool gate_stackleak_track_stack(void)
114043 +{
114044 + return track_frame_size >= 0;
114045 +}
114046 +
114047 +static void stackleak_check_alloca(gimple_stmt_iterator *gsi)
114048 +{
114049 + gimple check_alloca;
114050 + tree fntype, fndecl, alloca_size;
114051 +
114052 + fntype = build_function_type_list(void_type_node, long_unsigned_type_node, NULL_TREE);
114053 + fndecl = build_fn_decl(check_function, fntype);
114054 + DECL_ASSEMBLER_NAME(fndecl); // for LTO
114055 +
114056 + // insert call to void pax_check_alloca(unsigned long size)
114057 + alloca_size = gimple_call_arg(gsi_stmt(*gsi), 0);
114058 + check_alloca = gimple_build_call(fndecl, 1, alloca_size);
114059 + gsi_insert_before(gsi, check_alloca, GSI_SAME_STMT);
114060 +}
114061 +
114062 +static void stackleak_add_instrumentation(gimple_stmt_iterator *gsi)
114063 +{
114064 + gimple track_stack;
114065 + tree fntype, fndecl;
114066 +
114067 + fntype = build_function_type_list(void_type_node, NULL_TREE);
114068 + fndecl = build_fn_decl(track_function, fntype);
114069 + DECL_ASSEMBLER_NAME(fndecl); // for LTO
114070 +
114071 + // insert call to void pax_track_stack(void)
114072 + track_stack = gimple_build_call(fndecl, 0);
114073 + gsi_insert_after(gsi, track_stack, GSI_CONTINUE_LINKING);
114074 +}
114075 +
114076 +#if BUILDING_GCC_VERSION == 4005
114077 +static bool gimple_call_builtin_p(gimple stmt, enum built_in_function code)
114078 +{
114079 + tree fndecl;
114080 +
114081 + if (!is_gimple_call(stmt))
114082 + return false;
114083 + fndecl = gimple_call_fndecl(stmt);
114084 + if (!fndecl)
114085 + return false;
114086 + if (DECL_BUILT_IN_CLASS(fndecl) != BUILT_IN_NORMAL)
114087 + return false;
114088 +// print_node(stderr, "pax", fndecl, 4);
114089 + return DECL_FUNCTION_CODE(fndecl) == code;
114090 +}
114091 +#endif
114092 +
114093 +static bool is_alloca(gimple stmt)
114094 +{
114095 + if (gimple_call_builtin_p(stmt, BUILT_IN_ALLOCA))
114096 + return true;
114097 +
114098 +#if BUILDING_GCC_VERSION >= 4007
114099 + if (gimple_call_builtin_p(stmt, BUILT_IN_ALLOCA_WITH_ALIGN))
114100 + return true;
114101 +#endif
114102 +
114103 + return false;
114104 +}
114105 +
114106 +static unsigned int execute_stackleak_tree_instrument(void)
114107 +{
114108 + basic_block bb, entry_bb;
114109 + bool prologue_instrumented = false, is_leaf = true;
114110 +
114111 + entry_bb = ENTRY_BLOCK_PTR_FOR_FUNCTION(cfun)->next_bb;
114112 +
114113 + // 1. loop through BBs and GIMPLE statements
114114 + FOR_EACH_BB(bb) {
114115 + gimple_stmt_iterator gsi;
114116 +
114117 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
114118 + gimple stmt;
114119 +
114120 + stmt = gsi_stmt(gsi);
114121 +
114122 + if (is_gimple_call(stmt))
114123 + is_leaf = false;
114124 +
114125 + // gimple match: align 8 built-in BUILT_IN_NORMAL:BUILT_IN_ALLOCA attributes <tree_list 0xb7576450>
114126 + if (!is_alloca(stmt))
114127 + continue;
114128 +
114129 + // 2. insert stack overflow check before each __builtin_alloca call
114130 + stackleak_check_alloca(&gsi);
114131 +
114132 + // 3. insert track call after each __builtin_alloca call
114133 + stackleak_add_instrumentation(&gsi);
114134 + if (bb == entry_bb)
114135 + prologue_instrumented = true;
114136 + }
114137 + }
114138 +
114139 + // special cases for some bad linux code: taking the address of static inline functions will materialize them
114140 + // but we mustn't instrument some of them as the resulting stack alignment required by the function call ABI
114141 + // will break other assumptions regarding the expected (but not otherwise enforced) register clobbering ABI.
114142 + // case in point: native_save_fl on amd64 when optimized for size clobbers rdx if it were instrumented here.
114143 + if (is_leaf && !TREE_PUBLIC(current_function_decl) && DECL_DECLARED_INLINE_P(current_function_decl))
114144 + return 0;
114145 + if (is_leaf && !strncmp(IDENTIFIER_POINTER(DECL_NAME(current_function_decl)), "_paravirt_", 10))
114146 + return 0;
114147 +
114148 + // 4. insert track call at the beginning
114149 + if (!prologue_instrumented) {
114150 + gimple_stmt_iterator gsi;
114151 +
114152 + bb = split_block_after_labels(ENTRY_BLOCK_PTR)->dest;
114153 + if (dom_info_available_p(CDI_DOMINATORS))
114154 + set_immediate_dominator(CDI_DOMINATORS, bb, ENTRY_BLOCK_PTR);
114155 + gsi = gsi_start_bb(bb);
114156 + stackleak_add_instrumentation(&gsi);
114157 + }
114158 +
114159 + return 0;
114160 +}
114161 +
114162 +static unsigned int execute_stackleak_final(void)
114163 +{
114164 + rtx insn, next;
114165 +
114166 + if (cfun->calls_alloca)
114167 + return 0;
114168 +
114169 + // keep calls only if function frame is big enough
114170 + if (get_frame_size() >= track_frame_size)
114171 + return 0;
114172 +
114173 + // 1. find pax_track_stack calls
114174 + for (insn = get_insns(); insn; insn = next) {
114175 + // 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))
114176 + rtx body;
114177 +
114178 + next = NEXT_INSN(insn);
114179 + if (!CALL_P(insn))
114180 + continue;
114181 + body = PATTERN(insn);
114182 + if (GET_CODE(body) != CALL)
114183 + continue;
114184 + body = XEXP(body, 0);
114185 + if (GET_CODE(body) != MEM)
114186 + continue;
114187 + body = XEXP(body, 0);
114188 + if (GET_CODE(body) != SYMBOL_REF)
114189 + continue;
114190 + if (strcmp(XSTR(body, 0), track_function))
114191 + continue;
114192 +// warning(0, "track_frame_size: %d %ld %d", cfun->calls_alloca, get_frame_size(), track_frame_size);
114193 + // 2. delete call
114194 + delete_insn_and_edges(insn);
114195 +#if BUILDING_GCC_VERSION >= 4007
114196 + if (GET_CODE(next) == NOTE && NOTE_KIND(next) == NOTE_INSN_CALL_ARG_LOCATION) {
114197 + insn = next;
114198 + next = NEXT_INSN(insn);
114199 + delete_insn_and_edges(insn);
114200 + }
114201 +#endif
114202 + }
114203 +
114204 +// print_simple_rtl(stderr, get_insns());
114205 +// print_rtl(stderr, get_insns());
114206 +// warning(0, "track_frame_size: %d %ld %d", cfun->calls_alloca, get_frame_size(), track_frame_size);
114207 +
114208 + return 0;
114209 +}
114210 +
114211 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
114212 +{
114213 + const char * const plugin_name = plugin_info->base_name;
114214 + const int argc = plugin_info->argc;
114215 + const struct plugin_argument * const argv = plugin_info->argv;
114216 + int i;
114217 + struct register_pass_info stackleak_tree_instrument_pass_info = {
114218 + .pass = &stackleak_tree_instrument_pass.pass,
114219 +// .reference_pass_name = "tree_profile",
114220 + .reference_pass_name = "optimized",
114221 + .ref_pass_instance_number = 1,
114222 + .pos_op = PASS_POS_INSERT_BEFORE
114223 + };
114224 + struct register_pass_info stackleak_final_pass_info = {
114225 + .pass = &stackleak_final_rtl_opt_pass.pass,
114226 + .reference_pass_name = "final",
114227 + .ref_pass_instance_number = 1,
114228 + .pos_op = PASS_POS_INSERT_BEFORE
114229 + };
114230 +
114231 + if (!plugin_default_version_check(version, &gcc_version)) {
114232 + error(G_("incompatible gcc/plugin versions"));
114233 + return 1;
114234 + }
114235 +
114236 + register_callback(plugin_name, PLUGIN_INFO, NULL, &stackleak_plugin_info);
114237 +
114238 + for (i = 0; i < argc; ++i) {
114239 + if (!strcmp(argv[i].key, "track-lowest-sp")) {
114240 + if (!argv[i].value) {
114241 + error(G_("no value supplied for option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
114242 + continue;
114243 + }
114244 + track_frame_size = atoi(argv[i].value);
114245 + if (argv[i].value[0] < '0' || argv[i].value[0] > '9' || track_frame_size < 0)
114246 + error(G_("invalid option argument '-fplugin-arg-%s-%s=%s'"), plugin_name, argv[i].key, argv[i].value);
114247 + continue;
114248 + }
114249 + if (!strcmp(argv[i].key, "initialize-locals")) {
114250 + if (argv[i].value) {
114251 + error(G_("invalid option argument '-fplugin-arg-%s-%s=%s'"), plugin_name, argv[i].key, argv[i].value);
114252 + continue;
114253 + }
114254 + init_locals = true;
114255 + continue;
114256 + }
114257 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
114258 + }
114259 +
114260 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &stackleak_tree_instrument_pass_info);
114261 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &stackleak_final_pass_info);
114262 +
114263 + return 0;
114264 +}
114265 diff --git a/tools/gcc/structleak_plugin.c b/tools/gcc/structleak_plugin.c
114266 new file mode 100644
114267 index 0000000..4fae911
114268 --- /dev/null
114269 +++ b/tools/gcc/structleak_plugin.c
114270 @@ -0,0 +1,277 @@
114271 +/*
114272 + * Copyright 2013 by PaX Team <pageexec@freemail.hu>
114273 + * Licensed under the GPL v2
114274 + *
114275 + * Note: the choice of the license means that the compilation process is
114276 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
114277 + * but for the kernel it doesn't matter since it doesn't link against
114278 + * any of the gcc libraries
114279 + *
114280 + * gcc plugin to forcibly initialize certain local variables that could
114281 + * otherwise leak kernel stack to userland if they aren't properly initialized
114282 + * by later code
114283 + *
114284 + * Homepage: http://pax.grsecurity.net/
114285 + *
114286 + * Usage:
114287 + * $ # for 4.5/4.6/C based 4.7
114288 + * $ 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
114289 + * $ # for C++ based 4.7/4.8+
114290 + * $ 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
114291 + * $ gcc -fplugin=./structleak_plugin.so test.c -O2
114292 + *
114293 + * TODO: eliminate redundant initializers
114294 + * increase type coverage
114295 + */
114296 +
114297 +#include "gcc-plugin.h"
114298 +#include "config.h"
114299 +#include "system.h"
114300 +#include "coretypes.h"
114301 +#include "tree.h"
114302 +#include "tree-pass.h"
114303 +#include "intl.h"
114304 +#include "plugin-version.h"
114305 +#include "tm.h"
114306 +#include "toplev.h"
114307 +#include "function.h"
114308 +#include "tree-flow.h"
114309 +#include "plugin.h"
114310 +#include "gimple.h"
114311 +#include "diagnostic.h"
114312 +#include "cfgloop.h"
114313 +#include "langhooks.h"
114314 +
114315 +#if BUILDING_GCC_VERSION >= 4008
114316 +#define TODO_dump_func 0
114317 +#endif
114318 +
114319 +#define NAME(node) IDENTIFIER_POINTER(DECL_NAME(node))
114320 +
114321 +// unused type flag in all versions 4.5-4.8
114322 +#define TYPE_USERSPACE(TYPE) TYPE_LANG_FLAG_3(TYPE)
114323 +
114324 +int plugin_is_GPL_compatible;
114325 +void debug_gimple_stmt(gimple gs);
114326 +
114327 +static struct plugin_info structleak_plugin_info = {
114328 + .version = "201304082245",
114329 + .help = "disable\tdo not activate plugin\n",
114330 +};
114331 +
114332 +static tree handle_user_attribute(tree *node, tree name, tree args, int flags, bool *no_add_attrs)
114333 +{
114334 + *no_add_attrs = true;
114335 +
114336 + // check for types? for now accept everything linux has to offer
114337 + if (TREE_CODE(*node) != FIELD_DECL)
114338 + return NULL_TREE;
114339 +
114340 + *no_add_attrs = false;
114341 + return NULL_TREE;
114342 +}
114343 +
114344 +static struct attribute_spec user_attr = {
114345 + .name = "user",
114346 + .min_length = 0,
114347 + .max_length = 0,
114348 + .decl_required = false,
114349 + .type_required = false,
114350 + .function_type_required = false,
114351 + .handler = handle_user_attribute,
114352 +#if BUILDING_GCC_VERSION >= 4007
114353 + .affects_type_identity = true
114354 +#endif
114355 +};
114356 +
114357 +static void register_attributes(void *event_data, void *data)
114358 +{
114359 + register_attribute(&user_attr);
114360 +// register_attribute(&force_attr);
114361 +}
114362 +
114363 +static tree get_field_type(tree field)
114364 +{
114365 + return strip_array_types(TREE_TYPE(field));
114366 +}
114367 +
114368 +static bool is_userspace_type(tree type)
114369 +{
114370 + tree field;
114371 +
114372 + for (field = TYPE_FIELDS(type); field; field = TREE_CHAIN(field)) {
114373 + tree fieldtype = get_field_type(field);
114374 + enum tree_code code = TREE_CODE(fieldtype);
114375 +
114376 + if (code == RECORD_TYPE || code == UNION_TYPE)
114377 + if (is_userspace_type(fieldtype))
114378 + return true;
114379 +
114380 + if (lookup_attribute("user", DECL_ATTRIBUTES(field)))
114381 + return true;
114382 + }
114383 + return false;
114384 +}
114385 +
114386 +static void finish_type(void *event_data, void *data)
114387 +{
114388 + tree type = (tree)event_data;
114389 +
114390 + if (TYPE_USERSPACE(type))
114391 + return;
114392 +
114393 + if (is_userspace_type(type))
114394 + TYPE_USERSPACE(type) = 1;
114395 +}
114396 +
114397 +static void initialize(tree var)
114398 +{
114399 + basic_block bb;
114400 + gimple_stmt_iterator gsi;
114401 + tree initializer;
114402 + gimple init_stmt;
114403 +
114404 + // this is the original entry bb before the forced split
114405 + // TODO: check further BBs in case more splits occured before us
114406 + bb = ENTRY_BLOCK_PTR->next_bb->next_bb;
114407 +
114408 + // first check if the variable is already initialized, warn otherwise
114409 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
114410 + gimple stmt = gsi_stmt(gsi);
114411 + tree rhs1;
114412 +
114413 + // we're looking for an assignment of a single rhs...
114414 + if (!gimple_assign_single_p(stmt))
114415 + continue;
114416 + rhs1 = gimple_assign_rhs1(stmt);
114417 +#if BUILDING_GCC_VERSION >= 4007
114418 + // ... of a non-clobbering expression...
114419 + if (TREE_CLOBBER_P(rhs1))
114420 + continue;
114421 +#endif
114422 + // ... to our variable...
114423 + if (gimple_get_lhs(stmt) != var)
114424 + continue;
114425 + // if it's an initializer then we're good
114426 + if (TREE_CODE(rhs1) == CONSTRUCTOR)
114427 + return;
114428 + }
114429 +
114430 + // these aren't the 0days you're looking for
114431 +// inform(DECL_SOURCE_LOCATION(var), "userspace variable will be forcibly initialized");
114432 +
114433 + // build the initializer expression
114434 + initializer = build_constructor(TREE_TYPE(var), NULL);
114435 +
114436 + // build the initializer stmt
114437 + init_stmt = gimple_build_assign(var, initializer);
114438 + gsi = gsi_start_bb(ENTRY_BLOCK_PTR->next_bb);
114439 + gsi_insert_before(&gsi, init_stmt, GSI_NEW_STMT);
114440 + update_stmt(init_stmt);
114441 +}
114442 +
114443 +static unsigned int handle_function(void)
114444 +{
114445 + basic_block bb;
114446 + unsigned int ret = 0;
114447 + tree var;
114448 +
114449 +#if BUILDING_GCC_VERSION == 4005
114450 + tree vars;
114451 +#else
114452 + unsigned int i;
114453 +#endif
114454 +
114455 + // split the first bb where we can put the forced initializers
114456 + bb = split_block_after_labels(ENTRY_BLOCK_PTR)->dest;
114457 + if (dom_info_available_p(CDI_DOMINATORS))
114458 + set_immediate_dominator(CDI_DOMINATORS, bb, ENTRY_BLOCK_PTR);
114459 +
114460 + // enumarate all local variables and forcibly initialize our targets
114461 +#if BUILDING_GCC_VERSION == 4005
114462 + for (vars = cfun->local_decls; vars; vars = TREE_CHAIN(vars)) {
114463 + var = TREE_VALUE(vars);
114464 +#else
114465 + FOR_EACH_LOCAL_DECL(cfun, i, var) {
114466 +#endif
114467 + tree type = TREE_TYPE(var);
114468 +
114469 + gcc_assert(DECL_P(var));
114470 + if (!auto_var_in_fn_p(var, current_function_decl))
114471 + continue;
114472 +
114473 + // only care about structure types
114474 + if (TREE_CODE(type) != RECORD_TYPE && TREE_CODE(type) != UNION_TYPE)
114475 + continue;
114476 +
114477 + // if the type is of interest, examine the variable
114478 + if (TYPE_USERSPACE(type))
114479 + initialize(var);
114480 + }
114481 +
114482 + return ret;
114483 +}
114484 +
114485 +static struct gimple_opt_pass structleak_pass = {
114486 + .pass = {
114487 + .type = GIMPLE_PASS,
114488 + .name = "structleak",
114489 +#if BUILDING_GCC_VERSION >= 4008
114490 + .optinfo_flags = OPTGROUP_NONE,
114491 +#endif
114492 + .gate = NULL,
114493 + .execute = handle_function,
114494 + .sub = NULL,
114495 + .next = NULL,
114496 + .static_pass_number = 0,
114497 + .tv_id = TV_NONE,
114498 + .properties_required = PROP_cfg,
114499 + .properties_provided = 0,
114500 + .properties_destroyed = 0,
114501 + .todo_flags_start = 0,
114502 + .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
114503 + }
114504 +};
114505 +
114506 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
114507 +{
114508 + int i;
114509 + const char * const plugin_name = plugin_info->base_name;
114510 + const int argc = plugin_info->argc;
114511 + const struct plugin_argument * const argv = plugin_info->argv;
114512 + bool enable = true;
114513 +
114514 + struct register_pass_info structleak_pass_info = {
114515 + .pass = &structleak_pass.pass,
114516 + .reference_pass_name = "ssa",
114517 + .ref_pass_instance_number = 1,
114518 + .pos_op = PASS_POS_INSERT_AFTER
114519 + };
114520 +
114521 + if (!plugin_default_version_check(version, &gcc_version)) {
114522 + error(G_("incompatible gcc/plugin versions"));
114523 + return 1;
114524 + }
114525 +
114526 + if (strcmp(lang_hooks.name, "GNU C")) {
114527 + inform(UNKNOWN_LOCATION, G_("%s supports C only"), plugin_name);
114528 + enable = false;
114529 + }
114530 +
114531 + for (i = 0; i < argc; ++i) {
114532 + if (!strcmp(argv[i].key, "disable")) {
114533 + enable = false;
114534 + continue;
114535 + }
114536 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
114537 + }
114538 +
114539 + register_callback(plugin_name, PLUGIN_INFO, NULL, &structleak_plugin_info);
114540 + if (enable) {
114541 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &structleak_pass_info);
114542 + register_callback(plugin_name, PLUGIN_FINISH_TYPE, finish_type, NULL);
114543 + }
114544 + register_callback(plugin_name, PLUGIN_ATTRIBUTES, register_attributes, NULL);
114545 +
114546 + return 0;
114547 +}
114548 diff --git a/tools/lib/lk/Makefile b/tools/lib/lk/Makefile
114549 index 3dba0a4..97175dc 100644
114550 --- a/tools/lib/lk/Makefile
114551 +++ b/tools/lib/lk/Makefile
114552 @@ -13,7 +13,7 @@ LIB_OBJS += $(OUTPUT)debugfs.o
114553
114554 LIBFILE = liblk.a
114555
114556 -CFLAGS = -ggdb3 -Wall -Wextra -std=gnu99 -Werror -O6 -D_FORTIFY_SOURCE=2 $(EXTRA_WARNINGS) $(EXTRA_CFLAGS) -fPIC
114557 +CFLAGS = -ggdb3 -Wall -Wextra -std=gnu99 -Werror -O6 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 $(EXTRA_WARNINGS) $(EXTRA_CFLAGS) -fPIC
114558 EXTLIBS = -lelf -lpthread -lrt -lm
114559 ALL_CFLAGS = $(CFLAGS) $(BASIC_CFLAGS) -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64
114560 ALL_LDFLAGS = $(LDFLAGS)
114561 diff --git a/tools/perf/util/include/asm/alternative-asm.h b/tools/perf/util/include/asm/alternative-asm.h
114562 index 6789d78..4afd019e 100644
114563 --- a/tools/perf/util/include/asm/alternative-asm.h
114564 +++ b/tools/perf/util/include/asm/alternative-asm.h
114565 @@ -5,4 +5,7 @@
114566
114567 #define altinstruction_entry #
114568
114569 + .macro pax_force_retaddr rip=0, reload=0
114570 + .endm
114571 +
114572 #endif
114573 diff --git a/tools/perf/util/include/linux/compiler.h b/tools/perf/util/include/linux/compiler.h
114574 index 96b919d..c49bb74 100644
114575 --- a/tools/perf/util/include/linux/compiler.h
114576 +++ b/tools/perf/util/include/linux/compiler.h
114577 @@ -18,4 +18,12 @@
114578 #define __force
114579 #endif
114580
114581 +#ifndef __size_overflow
114582 +# define __size_overflow(...)
114583 +#endif
114584 +
114585 +#ifndef __intentional_overflow
114586 +# define __intentional_overflow(...)
114587 +#endif
114588 +
114589 #endif
114590 diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
114591 index 1cf9ccb..b9236e2 100644
114592 --- a/virt/kvm/kvm_main.c
114593 +++ b/virt/kvm/kvm_main.c
114594 @@ -75,12 +75,17 @@ LIST_HEAD(vm_list);
114595
114596 static cpumask_var_t cpus_hardware_enabled;
114597 static int kvm_usage_count = 0;
114598 -static atomic_t hardware_enable_failed;
114599 +static atomic_unchecked_t hardware_enable_failed;
114600
114601 struct kmem_cache *kvm_vcpu_cache;
114602 EXPORT_SYMBOL_GPL(kvm_vcpu_cache);
114603
114604 -static __read_mostly struct preempt_ops kvm_preempt_ops;
114605 +static void kvm_sched_in(struct preempt_notifier *pn, int cpu);
114606 +static void kvm_sched_out(struct preempt_notifier *pn, struct task_struct *next);
114607 +static struct preempt_ops kvm_preempt_ops = {
114608 + .sched_in = kvm_sched_in,
114609 + .sched_out = kvm_sched_out,
114610 +};
114611
114612 struct dentry *kvm_debugfs_dir;
114613
114614 @@ -749,7 +754,7 @@ int __kvm_set_memory_region(struct kvm *kvm,
114615 /* We can read the guest memory with __xxx_user() later on. */
114616 if ((mem->slot < KVM_USER_MEM_SLOTS) &&
114617 ((mem->userspace_addr & (PAGE_SIZE - 1)) ||
114618 - !access_ok(VERIFY_WRITE,
114619 + !__access_ok(VERIFY_WRITE,
114620 (void __user *)(unsigned long)mem->userspace_addr,
114621 mem->memory_size)))
114622 goto out;
114623 @@ -1867,7 +1872,7 @@ static int kvm_vcpu_release(struct inode *inode, struct file *filp)
114624 return 0;
114625 }
114626
114627 -static struct file_operations kvm_vcpu_fops = {
114628 +static file_operations_no_const kvm_vcpu_fops __read_only = {
114629 .release = kvm_vcpu_release,
114630 .unlocked_ioctl = kvm_vcpu_ioctl,
114631 #ifdef CONFIG_COMPAT
114632 @@ -2550,7 +2555,7 @@ static int kvm_vm_mmap(struct file *file, struct vm_area_struct *vma)
114633 return 0;
114634 }
114635
114636 -static struct file_operations kvm_vm_fops = {
114637 +static file_operations_no_const kvm_vm_fops __read_only = {
114638 .release = kvm_vm_release,
114639 .unlocked_ioctl = kvm_vm_ioctl,
114640 #ifdef CONFIG_COMPAT
114641 @@ -2651,7 +2656,7 @@ out:
114642 return r;
114643 }
114644
114645 -static struct file_operations kvm_chardev_ops = {
114646 +static file_operations_no_const kvm_chardev_ops __read_only = {
114647 .unlocked_ioctl = kvm_dev_ioctl,
114648 .compat_ioctl = kvm_dev_ioctl,
114649 .llseek = noop_llseek,
114650 @@ -2677,7 +2682,7 @@ static void hardware_enable_nolock(void *junk)
114651
114652 if (r) {
114653 cpumask_clear_cpu(cpu, cpus_hardware_enabled);
114654 - atomic_inc(&hardware_enable_failed);
114655 + atomic_inc_unchecked(&hardware_enable_failed);
114656 printk(KERN_INFO "kvm: enabling virtualization on "
114657 "CPU%d failed\n", cpu);
114658 }
114659 @@ -2731,10 +2736,10 @@ static int hardware_enable_all(void)
114660
114661 kvm_usage_count++;
114662 if (kvm_usage_count == 1) {
114663 - atomic_set(&hardware_enable_failed, 0);
114664 + atomic_set_unchecked(&hardware_enable_failed, 0);
114665 on_each_cpu(hardware_enable_nolock, NULL, 1);
114666
114667 - if (atomic_read(&hardware_enable_failed)) {
114668 + if (atomic_read_unchecked(&hardware_enable_failed)) {
114669 hardware_disable_all_nolock();
114670 r = -EBUSY;
114671 }
114672 @@ -3168,7 +3173,7 @@ static void kvm_sched_out(struct preempt_notifier *pn,
114673 kvm_arch_vcpu_put(vcpu);
114674 }
114675
114676 -int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align,
114677 +int kvm_init(const void *opaque, unsigned vcpu_size, unsigned vcpu_align,
114678 struct module *module)
114679 {
114680 int r;
114681 @@ -3215,7 +3220,7 @@ int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align,
114682 if (!vcpu_align)
114683 vcpu_align = __alignof__(struct kvm_vcpu);
114684 kvm_vcpu_cache = kmem_cache_create("kvm_vcpu", vcpu_size, vcpu_align,
114685 - 0, NULL);
114686 + SLAB_USERCOPY, NULL);
114687 if (!kvm_vcpu_cache) {
114688 r = -ENOMEM;
114689 goto out_free_3;
114690 @@ -3225,9 +3230,11 @@ int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align,
114691 if (r)
114692 goto out_free;
114693
114694 + pax_open_kernel();
114695 kvm_chardev_ops.owner = module;
114696 kvm_vm_fops.owner = module;
114697 kvm_vcpu_fops.owner = module;
114698 + pax_close_kernel();
114699
114700 r = misc_register(&kvm_dev);
114701 if (r) {
114702 @@ -3237,9 +3244,6 @@ int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align,
114703
114704 register_syscore_ops(&kvm_syscore_ops);
114705
114706 - kvm_preempt_ops.sched_in = kvm_sched_in;
114707 - kvm_preempt_ops.sched_out = kvm_sched_out;
114708 -
114709 r = kvm_init_debug();
114710 if (r) {
114711 printk(KERN_ERR "kvm: create debugfs files failed\n");